/** * Get module by id * * @param integer $id The id of the module * @return object The Module object * @author Sakis Terz * @since 1.6.0 */ public static function &getModule($id) { $result = null; $modules =& JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { // Match the id of the module if ($modules[$i]->id == (int) $id) { // Found it $result =& $modules[$i]; break; // Found it } } // If we didn't find it, and the name is mod_something, create a dummy object if (is_null($result)) { $result = parent::getModule('mod_cf_filtering'); if (is_null($result)) { $result = new stdClass(); $result->id = 0; $result->title = ''; $result->module = 'mod_cf_filtering'; $result->position = ''; $result->content = ''; $result->showtitle = 0; $result->control = ''; $result->params = ''; $result->user = 0; } } return $result; }
public static function load() { if (MagebridgeModelConfig::load('preload_all_modules') == 0 && JRequest::getInt('Itemid') != 0) { static $modules = null; if (is_array($modules) == false) { $modules = JModuleHelper::_load(); foreach ($modules as $index => $module) { if (strstr($module->module, 'mod_magebridge') == false) { unset($modules[$index]); } } } return $modules; } $application = JFactory::getApplication(); $db = JFactory::getDBO(); $where = array(); $where[] = 'm.published = 1'; $where[] = 'm.module LIKE "mod_magebridge%"'; $where[] = 'm.client_id = ' . (int) $application->getClientId(); $query = 'SELECT m.*' . ' FROM #__modules AS m' . ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id' . ' WHERE ' . implode(' AND ', $where) . ' ORDER BY m.position, m.ordering'; $db->setQuery($query); $modules = $db->loadObjectList(); return $modules; }
/** * Get modules by position * * @param string $position The position of the module * * @return array An array of module objects * * @since 11.1 */ public static function getModules($position) { // [!] HUBzero compatibility if (class_exists('\\Module')) { return \Module::byPosition($position); } $position = strtolower($position); $result = array(); $modules =& JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { if ($modules[$i]->position == $position) { $result[] =& $modules[$i]; } } if (count($result) == 0) { if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) { $result[0] = JModuleHelper::getModule('mod_' . $position); $result[0]->title = $position; $result[0]->content = $position; $result[0]->position = $position; } } return $result; }
/** * Get modules by position * * @param string $position The position of the module * * @return array An array of module objects * * @since 11.1 */ public static function &getModules($position) { $app = JFactory::getApplication(); $position = strtolower($position); $result = array(); if (!empty($position) && MageBridgeTemplateHelper::allowPosition($position) == false) { return $result; } $modules = JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { if ($modules[$i]->position == $position) { $result[] =& $modules[$i]; } } if (count($result) == 0) { if (JRequest::getBool('tp') && JComponentHelper::getParams('com_templates')->get('template_positions_display')) { $result[0] = JModuleHelper::getModule('mod_' . $position); $result[0]->title = $position; $result[0]->content = $position; $result[0]->position = $position; } } return $result; }
/** * Constructor * * @param array An optional associative array of configuration settings. */ public function __construct(KConfig $config) { parent::__construct($config); $this->_state->insert('position', 'cmd')->insert('module', 'cmd')->insert('limit', 'int', 0); KLoader::load('lib.joomla.application.module.helper'); $this->_list =& JModuleHelper::_load(); $this->_total = count($this->_list); }
/** * Get modules by position * * @access public * @param string $position The position of the module * @return array An array of module objects */ function &getModules($position) { $position = strtolower($position); $result = array(); $modules =& JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { if ($modules[$i]->position == $position) { $result[] =& $modules[$i]; } } return $result; }
/** * Get modules by position * * @access public * @param string $position The position of the module * @return array An array of module objects */ function &getModules($position) { $position = strtolower($position); $result = array(); $modules =& JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { if ($modules[$i]->position == $position) { $result[] =& $modules[$i]; } } if (count($result) == 0) { if (JRequest::getBool('tp')) { $result[0] = JModuleHelper::getModule('mod_' . $position); $result[0]->title = $position; $result[0]->content = $position; $result[0]->position = $position; } } return $result; }
/** * Get modules by position * * @param string $position The position of the module * * @return array An array of module objects */ public static function &getModules($position) { $app =& JFactory::getApplication(); $position = strtolower($position); $result = array(); $modules =& JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { if ($modules[$i]->position == $position) { $result[] =& $modules[$i]; } } if (count($result) == 0) { if ($app->getCfg('debug_modules') && JRequest::getBool('tp')) { $result[0] = JModuleHelper::getModule('mod_' . $position); $result[0]->title = $position; $result[0]->content = $position; $result[0]->position = $position; } } return $result; }
/** * Displays the cart, expects to be called via ajax * * @return unknown_type */ function displayCart() { JLoader::import('com_tienda.library.json', JPATH_ADMINISTRATOR . '/components'); jimport('joomla.application.module.helper'); $modules = JModuleHelper::_load(); if (empty($modules)) { echo json_encode(array('msg' => '')); return; } foreach ($modules as $module) { if ($module->module == 'mod_tienda_cart') { $mainframe = JFactory::getApplication(); $mainframe->setUserState('mod_usercart.isAjax', '1'); echo json_encode(array('msg' => JModuleHelper::renderModule($module))); return; } } echo json_encode(array('msg' => '')); return; }
public function render($content = ' ', $title = false, array $module = array(), $attribs = array()) { /* KLoader::load('lib.joomla.application.module.helper'); $load =& JModuleHelper::_load(); $load[] = (object) array( 'id' => 50, 'title' => $title, 'module' => 'mod_custom', 'position' => 'above', 'content' => $content, 'showtitle' => 1, 'control' => '', 'params' => ' moduleclass_sfx=-slide red cache=0 ', 'user' => 0, 'name' => 'custom', //'style' => isset($module['style']) ? $module['style'] : 'rounded', 'style' => 'xhtml' ); return null; die('<pre>'.print_r($load, true).'</pre>'); //*/ /* 0 => stdClass::__set_state(array( 'id' => '50', 'title' => 'Breadcrumb', 'module' => 'mod_breadcrumbs', 'position' => 'breadcrumb', 'content' => '', 'showtitle' => '0', 'control' => '', 'params' => 'showHome=1 homeText=Home showLast=1 separator= moduleclass_sfx= cache=0 ', 'user' => 0, 'name' => 'breadcrumbs', 'style' => NULL, )), */ $tmp = $module; $module = new KObject(); $module->params = 'moduleclass_sfx=' . @$tmp['moduleclass_sfx']; $module->module = 'mod_' . $this->_identifier->package . '_' . $this->_identifier->name; $module->id = KFactory::tmp('lib.koowa.filter.int')->sanitize(uniqid()); $module->title = (string) $title; $module->style = isset($tmp['style']) ? $tmp['style'] : 'rounded'; $module->position = $this->_identifier->package . '-' . $this->_identifier->name; $module->showtitle = (bool) $title; $module->name = $this->_identifier->package . '_' . $this->_identifier->name; $module->user = 0; $module->content = $content; $module->set($tmp); if (!isset($attribs['name'])) { $attribs['name'] = $module->position; } if (!isset($attribs['style'])) { $attribs['style'] = $module->style; } if (!isset($attribs['first'])) { $attribs['first'] = null; } if (!isset($attribs['last'])) { $attribs['last'] = null; } if (($yoofix = JPATH_THEMES . DS . KFactory::get('lib.joomla.application')->getTemplate() . DS . 'lib' . DS . 'php' . DS . 'template.php') && ($isYoo = file_exists($yoofix))) { require_once $yoofix; } if ($isYoo) { $attribs['style'] = 'yoo'; } static $chrome; $mainframe = JFactory::getApplication(); $scope = $mainframe->scope; //record the scope $mainframe->scope = $module->module; //set scope to Component name // 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 (!$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(); } KLoader::load('lib.joomla.application.module.helper'); $load =& JModuleHelper::_load(); if (!$this->_modules) { $this->_modules_backup = $this->_modules = $load; } $this->_modules[] = $module; $load = $this->_modules; 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'] = 'rounded'; } //dynamically add outline style if (JRequest::getBool('tp')) { $attribs['style'] .= ' outline'; } $tpl = KFactory::get('lib.joomla.application')->getTemplate(); $yoofix = false; $warpfive = 'templates/' . $tpl . '/layouts/module.php'; if (JFile::exists(JPATH_ROOT . '/' . $warpfive)) { $tpl_dir = JPATH_ROOT . "/templates/{$tpl}"; //include warp require_once $tpl_dir . '/warp/warp.php'; $warp = Warp::getInstance(); $warp->getHelper('path')->register($tpl_dir . '/warp/systems/joomla.1.5/helpers', 'helpers'); $warp->getHelper('path')->register($tpl_dir . '/warp/systems/joomla.1.5/layouts', 'layouts'); $warp->getHelper('path')->register($tpl_dir . '/layouts', 'layouts'); $template = KFactory::tmp($this->getTemplate())->addFilters(array('alias')); $template->getFilter('alias')->append(array('$this' => '$warp_helper_template')); $data = array('warp_helper_template' => $warp->getHelper("template"), '$warp' => $warp); $module->menu = false; $yoofix = true; } foreach (explode(' ', $attribs['style']) as $style) { $chromeMethod = 'modChrome_' . $style; //Warp 5.5 fix if ($yoofix) { $module->parameter = new JParameter($module->params); $data['module'] = $module; $data['params'] = array(); //@TODO count this $count = 1; $index = 0; $data['params']['count'] = $count; $data['params']['order'] = $index + 1; $data['params']['first'] = $data['params']['order'] == 1; $data['params']['last'] = $data['params']['order'] == $count; $data['params']['suffix'] = $module->parameter->get('moduleclass_sfx', ''); $data['params']['menu'] = false; // get class suffix params $parts = preg_split('/[\\s]+/', $data['params']['suffix']); foreach ($parts as $part) { if (strpos($part, '-') !== false) { $yoostyles = explode('-', $part, 2); $data['params'][$yoostyles[0]] = $yoostyles[1]; } } $module->content = $template->loadPath($warpfive, $data)->render(true); } elseif (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; }
function removeMenu($menutype = 'mainmenu') { $tt =& JModuleHelper::_load(); foreach ($tt as $k => $mod) { if (!is_object($mod)) { continue; } if (preg_match("/menutype={$menutype}/i", $mod->params)) { $tt[$k]->position = 'none'; } } }
function getModule($id = 0, $name = '') { $modules =& JModuleHelper::_load(); $total = count($modules); for ($i = 0; $i < $total; $i++) { // Match the name of the module if ($modules[$i]->id == $id || $modules[$i]->name == $name) { return $modules[$i]; } } return null; }
/** * Implements myLoad to overwrite load() * * @return array */ public static function &myLoad( ) { return JModuleHelper::_load(); }
/** * Preload modules * * @todo: This is currently not working * @access private * @param null * @return null */ private function preloadModules() { //MageBridgeModelDebug::getInstance()->notice( 'System Plugin: Preloading modules' ); // Check the configuration variables $module_chrome = $this->loadConfig('module_chrome'); $module_show_title = $this->loadConfig('module_show_title'); if (empty($module_chrome) && empty($module_show_title)) { return; } // Import the module-helper jimport('joomla.application.module.helper'); $modules =& JModuleHelper::_load(); // Load settings foreach ($modules as $index => $module) { if (preg_match('/^mod_magebridge_/', $module->module)) { $mod =& JModuleHelper::getModule($module->name, $module->title); if (!empty($module_chrome)) { $mod->style = $module_chrome; } if (!empty($module_show_title)) { $mod->show_title = (int) $module_show_title; } } } }
/** * Return modules, optionally filtered by position * * @param string|null $position Module position * @return array */ public static function &getModules($position) { if ($position) { $modules =& JModuleHelper::getModules($position); } else { $modules =& JModuleHelper::_load(); } return $modules; }