X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fadvanced_help%2Fadvanced_help.module;fp=web%2Fmodules%2Fcontrib%2Fadvanced_help%2Fadvanced_help.module;h=9bfba51e340a992949b0049a287d1e3c1e556c22;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/advanced_help/advanced_help.module b/web/modules/contrib/advanced_help/advanced_help.module new file mode 100644 index 000000000..9bfba51e3 --- /dev/null +++ b/web/modules/contrib/advanced_help/advanced_help.module @@ -0,0 +1,76 @@ +moduleExists('help')) { + unset($links['advanced_help.main']); + } +} + +/** + * Implements hook_modules_installed(). + */ +function advanced_help_modules_installed($modules) { + $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); + \Drupal::cache('discovery')->invalidate('advanced_help_ini_' . $language); +} + +/** + * Implements hook_theme(). + */ +function advanced_help_theme() { + return [ + 'advanced_help_topic' => [ + 'variables' => [ + 'module' => NULL, + 'topic' => NULL, + 'type' => 'icon', + ] + ] + ]; +} + +/** + * Implements hook_preprocess_HOOK(). + */ +function advanced_help_preprocess_advanced_help_topic(&$variables) { + $module = $variables['module']; + $topic = $variables['topic']; + $type = $variables['type']; + + $advancedHelp = \Drupal::service('plugin.manager.advanced_help'); + $info = $variables['topic_exists'] = $advancedHelp->getTopic($module, $topic); + $variables['attributes'] = new Attribute(); + $variables['attributes']['class'] = []; + $variables['attributes']['title'] = $info['title']; + + if (\Drupal::currentUser()->hasPermission('view advanced help popup')) { + $variables['attributes']['class'][] = 'advanced-help-link'; + $variables['attributes']['class'][] = 'use-ajax'; + $variables['attributes']['data-dialog-type'] = 'modal'; + $variables['attributes']['data-dialog-options'] = Json::encode(['width' => $info['popup width'], 'height' => $info['popup height']]); + $variables['#attached']['library'][] = 'advanced_help/help.icon'; + } + switch ($type) { + case 'icon': + $variables['text'] = '' . t('Help') . ''; + break; + + case 'title': + $variables['text'] = $info['title']; + $variables['attributes']['class'][] = 'advanced-help-title'; + break; + + default: + $variables['text'] = $type; + $variables['attributes']['class'][] = 'advanced-help-title'; + break; + } +} \ No newline at end of file