db = System::getInstance()->getDB(); } public function setUsedPlugins(array $plugins) { $this->usedPlugins = $plugins; } private function loadPluginInfo($plugin, $file, $cat) { include ($file); $result = array(); if(is_array($info)) { if(is_array($info['entries'])) { foreach($info['entries'] as $area=>$targets) { foreach($targets as $target) { list($priority, $realtarget) = explode(':', $target, 2); $result[$area][] = $priority . ':' . substr($cat, 0, 2) . '.' . strtolower($plugin) . ':' . $realtarget; } } } } return $result; } /** * Load the strings from the language files * * @param string $dir * the directory with the language files * @return array the string array */ private function loadPluginStrings($dir) { include ($dir . '_default_.php'); $loc = System::getInstance()->getActiveLocale(); if(include_exists($dir . $loc . '.php')) include ($dir . $loc . '.php'); return isset($text['menu']) ? $text['menu'] : array(); } public function run(Response &$response, $step, Context $context) { if($step == iPlugInContent::STEP_BEFORE_RUN) { $menu = array(); $menutext = array(); $selected = 'start'; $param = System::getInstance()->getRequest()->getParam(); if(empty($param['cat'])) $param['cat'] = 'co.mcms.mmpiadmincontent:welcome:index'; $authCfg = System::getInstance()->getConfig('auth'); $userPI = strtolower($authCfg['type']); foreach($this->usedPlugins as $cat=>$plugins) { foreach($plugins as $plugin) { $infodir = $cat . __DS__ . str_replace('.', __DS__, strtolower($plugin)) . __DS__ . '_admin_' . __DS__; if(file_exists(_PLUGINPATHX_ . __DS__ . $infodir . '_info_.php')) $basedir = _PLUGINPATHX_ . __DS__ . $infodir; elseif(file_exists(_PLUGINPATH_ . __DS__ . $infodir . '_info_.php')) $basedir = _PLUGINPATH_ . __DS__ . $infodir; else $basedir = NULL; if(!is_null($basedir)) { $info = $this->loadPluginInfo($plugin, $basedir . '_info_.php', $cat); if(is_array($info)) { foreach($info as $area=>$targets) { foreach($targets as $target) { $menu[$area][] = $target; list($a, $c, $target, $b) = explode(':', $target, 4); if(substr($cat, 0, 2) . '.' . strtolower($plugin) . ':' . $target == $param['cat'] && $b == $param['action']) { $selected = $area; } } // sort($menu[$area]); } } if(is_dir($basedir . __DS__ . 'langu' . __DS__)) { $text = $this->loadPluginStrings($basedir . __DS__ . 'langu' . __DS__); $menutext = array_merge($menutext, $text); } } } } foreach($menu as $area=>$targets) { // sort($menu[$area]); foreach($menu[$area] as $key=>$val) { list($prio, $val) = explode(':', $val, 2); $menu[$area][$key] = $val; } } $st = ''; $st .= 'Logout'; $response->setFragment('MENU1', $st); $st = ''; $response->setFragment('MENU2', $st); } } public function __destruct() { unset($this->db); } }