Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial upgrade to 3.1 #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Maintainer Contacts

Requirements
------------
* SilverStripe 2.4+
* SilverStripe 3.1+

Documentation
-------------
Expand Down
21 changes: 8 additions & 13 deletions code/InlineHelpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
)
Expand All @@ -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;'),
Expand Down
28 changes: 14 additions & 14 deletions code/InlineHelpTopic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
4 changes: 2 additions & 2 deletions javascript/InlineHelpAdmin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;(function($) {
Behaviour.register({
/*Behaviour.register({
'#AttachType': {
initialize: function() {
$(this).find(':checked').change();
Expand All @@ -10,7 +10,7 @@
$(this).find(':checked').change();
}
}
});
});*/

$('#AttachType :radio').live('change', function() {
switch ($(this).val()) {
Expand Down
24 changes: 12 additions & 12 deletions templates/InlineHelp.ss
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -36,6 +36,6 @@
link: '$Link.JS',
showOn: '$ShowTooltip.Lower.JS'
}); });
<% end_control %>
<% end_loop %>
})(jQuery);
<% end_if %>