Source of file InlineHelpExtension.php
Size: 1,310 Bytes - Last Modified: 2021-12-23T10:48:18+00:00
/var/www/docs.ssmods.com/process/src/code/InlineHelpExtension.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | <?php /** * Adds support for inline help items to a SiteTree object. * * @package silverstripe-inlinehelp */ class InlineHelpExtension extends DataExtension { private static $belongs_many_many = array( 'HelpTopics' => 'InlineHelpTopic' ); /** * Includes the required JS libraries and inline help definitions. */ public function onPageInit() { $template = 'InlineHelp'; $include = $this->owner->renderWith($template); if ($include) Requirements::customScript($include); } /** * Returns all the {@link InlineHelpTopic}s attached to this page. * * @return InlineHelpTopic[] */ public function getHelpItems() { $items = new ArrayList(); $items->merge(InlineHelpTopic::get()->where('"AttachType" = \'All\'')); $items->merge(InlineHelpTopic::get()->where( sprintf( '"AttachType" = \'Type\' AND "AttachPageType" = \'%s\'', $this->owner->class ) )); $items->merge($this->owner->HelpTopics()); $stack = $this->owner->parentStack(); array_shift($stack); if ($stack) { $items->merge(InlineHelpTopic::get()->where( sprintf( '"AttachType" = \'Children\' AND "ParentFilterID" IN(%s)', implode(', ', array_map(create_function('$self', 'return $self->ID;'), $stack)) ))); } $items->removeDuplicates(); return $items; } } |