/** * 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()) { 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)) { $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); $paths = array(JPATH_BASE . '/modules'); $paths = array_merge(self::addIncludePath(), $paths); if ($filePath = JPath::find($paths, $module->module . '/' . $module->module . '.php')) { $content = ''; ob_start(); include $filePath; $module->content = ob_get_contents() . $content; ob_end_clean(); } } // Load the module chrome functions if (!self::$chrome) { self::$chrome = array(); } include_once JPATH_THEMES . '/system/html/modules.php'; $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php'; if (!isset(self::$chrome[$chromePath])) { if (file_exists($chromePath)) { include_once $chromePath; } self::$chrome[$chromePath] = true; } // Make sure a style is set if (!isset($attribs['style'])) { $attribs['style'] = 'none'; } // Dynamically add outline style if ($app->input->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; }