Advertisement
Guest User

Untitled

a guest
Jun 26th, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. <?php
  2.  
  3. class BBM_Listeners_Templates_Preloader
  4. {
  5. protected static $editor;
  6.  
  7. public static function preloader($templateName, array &$params, XenForo_Template_Abstract $template)
  8. {
  9. switch ($templateName)
  10. {
  11. case 'help_bb_codes':
  12. $template->preloadTemplate('help_bbm_bbcodes');
  13. break;
  14. case 'editor':
  15. /***
  16. Templates Preloader
  17. ***/
  18. if(XenForo_Application::get('options')->get('Bbm_Bm_ShowControllerInfo'))
  19. {
  20. $template->preloadTemplate('bbm_editor_extra_info');
  21. }
  22.  
  23. /***
  24. ADD PARAMS TO THE EDITOR TEMPLATE
  25. ***/
  26. $options = XenForo_Application::get('options');
  27.  
  28. if ($template instanceof XenForo_Template_Admin && !$options->Bbm_Bm_SetInAdmin)
  29. {
  30. break;
  31. }
  32.  
  33. $controllerName = $template->getParam('controllerName');
  34. $controllerAction = $template->getParam('controllerAction');
  35. $viewName = $template->getParam('viewName');
  36.  
  37. $extraParams = BBM_Helper_Buttons::getConfig($controllerName, $controllerAction, $viewName);
  38.  
  39. if(!is_array($extraParams)){
  40. $extraParams = array();
  41. }
  42.  
  43. $params = $extraParams+$params; //array + operator: first params overrides the second - is said faster than array_merge
  44. //$params = array_merge($params,$extraParams);
  45.  
  46. break;
  47. case 'forum_edit':
  48. if($template instanceof XenForo_Template_Admin && XenForo_Application::get('options')->get('Bbm_Bm_Forum_Config'))
  49. {
  50. $template->preloadTemplate('bbm_forum_edit_bbm_editor');
  51. }
  52. break;
  53. case 'home':
  54. if($template instanceof XenForo_Template_Admin)
  55. {
  56. $template->preloadTemplate('bbm_admin_icon');
  57. }
  58. break;
  59. }
  60. }
  61.  
  62. /***
  63. REDACTOR: Template callback if needed
  64. => will be used as a fallback
  65. */
  66.  
  67. public static function getJsConfig($content, $params, XenForo_Template_Abstract $template)
  68. {
  69. $options = XenForo_Application::get('options');
  70.  
  71. if ($template instanceof XenForo_Template_Admin && !$options->Bbm_Bm_SetInAdmin)
  72. {
  73. return;
  74. }
  75.  
  76. $controllerName = $template->getParam('controllerName');
  77. $controllerAction = $template->getParam('controllerAction');
  78. $viewName = $template->getParam('viewName');
  79.  
  80. $params = BBM_Helper_Buttons::getConfig($controllerName, $controllerAction, $viewName);
  81.  
  82. $bbmButtonsJsGrid = $params['bbmButtonsJsGrid'];
  83. $bbmCustomButtons = $params['bbmCustomButtons'];
  84.  
  85. $output = "<script>var BBM_Redactor = { buttonsGrid: [$bbmButtonsJsGrid],customButtonsConfig:{";
  86.  
  87. $i = 1;
  88. $total = count($bbmCustomButtons);
  89.  
  90. if(is_array($bbmCustomButtons))
  91. {
  92. foreach($bbmCustomButtons as $button)
  93. {
  94. $coma = ($i != $total) ? ',' : '';
  95. $tag = $button['tag'];
  96. $code = $button['code'];
  97. $desc = XenForo_Template_Helper_Core::jsEscape($button['description']);
  98. $opts = XenForo_Template_Helper_Core::jsEscape($button['tagOptions']);
  99. $content = XenForo_Template_Helper_Core::jsEscape($button['tagContent']);
  100. $separator = XenForo_Template_Helper_Core::jsEscape($button['seprarator']);
  101.  
  102. $output .= "$code:{tag:\"$tag\",code:\"$code\",description:\"$desc\",tagOptions:\"$opts\",tagContent:\"$content\",separator:\"$separator\"}$coma";
  103. }
  104. }
  105.  
  106. $output .= '}};</script>';
  107.  
  108. return $output;
  109. }
  110.  
  111. }
  112. // Zend_Debug::dump($abc);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement