public function onPrepareModuleList(&$modules)
 {
     foreach ($modules as $id => $module) {
         if (MageBridgeTemplateHelper::allowPosition($module->position) == false) {
             unset($modules[$id]);
             continue;
         }
     }
 }
Esempio n. 2
0
 function renderModule($module, $attribs = array())
 {
     static $chrome;
     global $mainframe, $option;
     if (is_object($module) && !empty($module->position) && MageBridgeTemplateHelper::allowPosition($module->position) == false) {
         return null;
     }
     $scope = $mainframe->scope;
     //record the scope
     $mainframe->scope = $module->module;
     //set scope to component name
     // Handle legacy globals if enabled
     if ($mainframe->getCfg('legacy')) {
         // Include legacy globals
         global $my, $database, $acl, $mosConfig_absolute_path;
         // Get the task variable for local scope
         $task = JRequest::getString('task');
         // For backwards compatibility extract the config vars as globals
         $registry =& JFactory::getConfig();
         foreach (get_object_vars($registry->toObject()) as $k => $v) {
             $name = 'mosConfig_' . $k;
             ${$name} = $v;
         }
         $contentConfig =& JComponentHelper::getParams('com_content');
         foreach (get_object_vars($contentConfig->toObject()) as $k => $v) {
             $name = 'mosConfig_' . $k;
             ${$name} = $v;
         }
         $usersConfig =& JComponentHelper::getParams('com_users');
         foreach (get_object_vars($usersConfig->toObject()) as $k => $v) {
             $name = 'mosConfig_' . $k;
             ${$name} = $v;
         }
     }
     // Get module parameters
     $params = new JParameter($module->params);
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = JPATH_BASE . DS . 'modules' . DS . $module->module . DS . $module->module . '.php';
     // Load the module
     if (!isset($module->user)) {
         $module->user = 0;
     }
     if (!$module->user && file_exists($path) && empty($module->content)) {
         $lang =& JFactory::getLanguage();
         $lang->load($module->module);
         $content = '';
         ob_start();
         require $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     require_once JPATH_BASE . DS . 'templates' . DS . 'system' . DS . 'html' . DS . 'modules.php';
     $chromePath = JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             require_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     //make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'none';
     }
     //dynamically add outline style
     if (JRequest::getBool('tp')) {
         $attribs['style'] .= ' outline';
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         // Apply chrome and render module
         if (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     $mainframe->scope = $scope;
     //revert the scope
     return $module->content;
 }
Esempio n. 3
0
 /**
  * Render the module.
  *
  * @param   object  $module   A module object.
  * @param   array   $attribs  An array of attributes for the module (probably from the XML).
  *
  * @return  string  The HTML content of the module output.
  *
  * @since   11.1
  */
 public static function renderModule($module, $attribs = array())
 {
     static $chrome;
     if (is_object($module) && isset($module->position) && MageBridgeTemplateHelper::allowPosition($module->position) == false) {
         return null;
     }
     if (constant('JDEBUG')) {
         JProfiler::getInstance('Application')->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     $app = JFactory::getApplication();
     // Record the scope.
     $scope = $app->scope;
     // Set scope to component name
     $app->scope = $module->module;
     // Get module parameters
     $params = new JRegistry();
     $params->loadString($module->params);
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = JPATH_BASE . '/modules/' . $module->module . '/' . $module->module . '.php';
     // Load the module
     // $module->user is a check for 1.0 custom modules and is deprecated refactoring
     if (empty($module->user) && file_exists($path)) {
         $lang = JFactory::getLanguage();
         // 1.5 or Core then 1.6 3PD
         $lang->load($module->module, JPATH_BASE, null, false, false) || $lang->load($module->module, dirname($path), null, false, false) || $lang->load($module->module, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($module->module, dirname($path), $lang->getDefault(), false, false);
         $content = '';
         ob_start();
         include $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     include_once JPATH_THEMES . '/system/html/modules.php';
     $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             include_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     // Make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'none';
     }
     // Dynamically add outline style
     if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) {
         $attribs['style'] .= ' outline';
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         // Apply chrome and render module
         if (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     //revert the scope
     $app->scope = $scope;
     if (constant('JDEBUG')) {
         JProfiler::getInstance('Application')->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     return $module->content;
 }