/** * Public function that creates a single instance */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Handle tag for displaying modules * * @param array $tag_params * @param array $children */ public function tag_ModuleList($tag_params, $children) { $module_list = array(); $selected_list = array(); // grab module list from backend module if (class_exists('backend')) { $module_list = backend::getInstance()->getModuleList(); } // if license is specified we need to populate selected list if (isset($tag_params['license'])) { $manager = LicenseManager::getInstance(); $license_modules_manager = LicenseModulesManager::getInstance(); $license = $tag_params['license']; if (is_object($manager->getSingleItem(array('id'), array('id' => $license)))) { $license_modules = $license_modules_manager->getItems(array('module'), array('license' => $license)); if (count($license_modules) > 0) { foreach ($license_modules as $item) { $selected_list[] = $item->module; } } } } if (isset($tag_params['template'])) { if (isset($tag_params['local']) && $tag_params['local'] == 1) { $template = new TemplateHandler($tag_params['template'], $this->path . 'templates/'); } else { $template = new TemplateHandler($tag_params['template']); } } else { $template = new TemplateHandler('module_list_item.xml', $this->path . 'templates/'); } if (count($module_list) > 0) { foreach ($module_list as $module) { $params = array('name' => $module, 'in_group' => in_array($module, $selected_list) ? 1 : 0); $template->restoreXML(); $template->setLocalParams($params); $template->parse(); } } }