diff --git a/README.md b/README.md index 85a4648..349ae6a 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Maintainer Contacts Requirements ------------ -* SilverStripe 2.4+ +* SilverStripe 3.1+ Documentation ------------- diff --git a/code/InlineHelpExtension.php b/code/InlineHelpExtension.php index 86de1db..5969878 100755 --- a/code/InlineHelpExtension.php +++ b/code/InlineHelpExtension.php @@ -4,16 +4,14 @@ * * @package silverstripe-inlinehelp */ -class InlineHelpExtension extends DataObjectDecorator { +class InlineHelpExtension extends DataExtension { /** * @return array */ - public function extraStatics() { - return array('belongs_many_many' => array( - 'HelpTopics' => 'InlineHelpTopic' - )); - } + static $belongs_many_many = array( + 'HelpTopics' => 'InlineHelpTopic' + ); /** * Includes the required JS libraries and inline help definitions. @@ -31,13 +29,10 @@ public function contentcontrollerInit() { * @return InlineHelpTopic[] */ public function getHelpItems() { - $items = new DataObjectSet(); + $items = new ArrayList(); - $items->merge(DataObject::get('InlineHelpTopic', - '"AttachType" = \'All\'')); - $items->merge(DataObject::get( - 'InlineHelpTopic', - sprintf( + $items->merge(InlineHelpTopic::get()->where('"AttachType" = \'All\'')); + $items->merge(InlineHelpTopic::get()->where(sprintf( '"AttachType" = \'Type\' AND "AttachPageType" = \'%s\'', $this->owner->class ) @@ -48,7 +43,7 @@ public function getHelpItems() { array_shift($stack); if ($stack) { - $items->merge(DataObject::get('InlineHelpTopic', sprintf( + $items->merge(InlineHelpTopic::get()->where( sprintf( '"AttachType" = \'Children\' AND "ParentFilterID" IN(%s)', implode(', ', array_map(create_function('$self', 'return $self->ID;'), diff --git a/code/InlineHelpTopic.php b/code/InlineHelpTopic.php index e573328..ab27ba2 100755 --- a/code/InlineHelpTopic.php +++ b/code/InlineHelpTopic.php @@ -60,27 +60,27 @@ class InlineHelpTopic extends DataObject { * * @return string */ - public function getAttachedTo() { - switch ($this->AttachType) { - case 'All': - return 'All pages'; - case 'Pages': - return 'Specific pages: ' . implode(', ', $this->Pages()->map()); - case 'Children': - return 'Children of ' . $this->ParentFilter()->Title; - case 'Type': - return 'Pages of type ' . $this->AttachPageType; - } - } + public function getAttachedTo() { + switch ($this->AttachType) { + case 'All': + return 'All pages'; + case 'Pages': + if($this->Pages()->Count() >0)return 'Specific pages: ' . implode(', ', $this->Pages()->toArray()->map()); + case 'Children': + return 'Children of ' . $this->ParentFilter()->Title; + case 'Type': + return 'Pages of type ' . $this->AttachPageType; + } + } /** * @return FieldSet */ public function getCMSFields() { - Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); + //Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript('inlinehelp/javascript/InlineHelpAdmin.js'); - return new FieldSet(new TabSet('Root', + return new FieldList(new TabSet('Root', new Tab('Main', new HeaderField('HelpHeader', 'Help Topic'), new TextField('Title', 'Title'), diff --git a/javascript/InlineHelpAdmin.js b/javascript/InlineHelpAdmin.js index c5a5ef9..a0eb94c 100755 --- a/javascript/InlineHelpAdmin.js +++ b/javascript/InlineHelpAdmin.js @@ -1,5 +1,5 @@ ;(function($) { - Behaviour.register({ + /*Behaviour.register({ '#AttachType': { initialize: function() { $(this).find(':checked').change(); @@ -10,7 +10,7 @@ $(this).find(':checked').change(); } } - }); + });*/ $('#AttachType :radio').live('change', function() { switch ($(this).val()) { diff --git a/templates/InlineHelp.ss b/templates/InlineHelp.ss index 0a3100a..51255b1 100755 --- a/templates/InlineHelp.ss +++ b/templates/InlineHelp.ss @@ -1,30 +1,30 @@ -<% if HelpItems %> - <% require css(sapphire/thirdparty/jquery-ui-themes/base/jquery.ui.all.css) %> +<% if $HelpItems %> + <% require css(framework/thirdparty/jquery-ui-themes/smoothness/jquery-ui.min.css) %> <% require css(inlinehelp/css/ss.inlinehelp.css) %> - <% require javascript(sapphire/thirdparty/jquery/jquery.js) %> - <% require javascript(sapphire/thirdparty/jquery-ui/jquery-ui-1.8rc3.custom.js) %> - <% require javascript(sapphire/thirdparty/jquery-livequery/jquery.livequery.js) %> + <% require javascript(framework/thirdparty/jquery/jquery.min.js) %> + <% require javascript(framework/thirdparty/jquery-ui/jquery-ui.min.js) %> + <% require javascript(framework/thirdparty/jquery-livequery/jquery.livequery.js) %> <% require javascript(inlinehelp/javascript/ss.inlinehelp.js) %> (function($) { - <% control HelpItems %> + <% loop $HelpItems %> $('$DOMPattern').livequery(function() { $(this).inlineHelp({ - <% if IconHTML %>icon: '$IconHTML.JS',<% end_if %> - <% if IconMy && IconAt %> + <% if $IconHTML %>icon: '$IconHTML.JS',<% end_if %> + <% if $IconMy && $IconAt %> iconPosition: { - <% if IconOffset %>offset: '$IconOffset.JS',<% end_if %> + <% if $IconOffset %>offset: '$IconOffset.JS',<% end_if %> my: '$IconMy.JS', at: '$IconAt.JS' }, <% end_if %> - <% if TooltipMy && TooltipAt %> + <% if $TooltipMy && $TooltipAt %> tooltipPosition: { my: '$TooltipMy.JS', at: '$TooltipAt.JS' }, <% end_if %> - <% if TooltipWidth && TooltipHeight %> + <% if $TooltipWidth && $TooltipHeight %> tooltipSize: { width: $TooltipWidth.JS, height: $TooltipHeight.JS @@ -36,6 +36,6 @@ link: '$Link.JS', showOn: '$ShowTooltip.Lower.JS' }); }); - <% end_control %> + <% end_loop %> })(jQuery); <% end_if %> \ No newline at end of file