コード例 #1
0
 function loadModule()
 {
     $module = $this->httpRequest->getModule();
     $GLOBALS['Plugin'] = null;
     if (strpos($module, 'AdminPanel') === 0) {
         $pluginFolderName = strtolower(substr($module, 10));
         # Be carful, here parameters are moved
         $module = $this->httpRequest->getAction();
         if ($module == null) {
             throw new Exception(__('No module'));
         }
         $moduleFilePath = DIR_PLUGINS . $pluginFolderName . '/actions/' . $module . '.class.php';
         # Include admin module
         if (file_exists($moduleFilePath)) {
             require_once $moduleFilePath;
             $moduleController = new $module();
         } else {
             throw new Exception(__('No file found'));
         }
         # Get the action (Prob: HttpRequest->parseUrl() don't parse the second string following '/' )
         ereg($this->httpRequest->getModule() . '/' . $module . '/([^\\?$]+)', $_SERVER['REQUEST_URI'], $res);
         if (isset($res[1])) {
             $action = $res[1];
         } else {
             throw new Exception(__('No action'));
         }
         # if method exist call it
         if (method_exists($moduleController, $action)) {
             # search parameters method
             $reflect = new ReflectionMethod($module, $action);
             $parameters = $reflect->getParameters();
             $tabParam = array();
             foreach ($parameters as $param) {
                 $tabParam[$param->getName()] = $this->httpRequest->getArgument($param->getName());
             }
             try {
                 $pluginsInfoList = Plugin::getManifest($pluginFolderName);
                 $name = $pluginsInfoList['name'];
                 define('PLUGIN_ITSELF_URL_BASE', BASE_PORTAL_URI . 'index.php/' . $this->httpRequest->getModule() . '/');
                 ob_start();
                 //echo Plugin::getHeader($name);
                 # Call action of the plugin
                 call_user_func_array(array(new $module(), $action), $tabParam);
                 $GLOBALS['Plugin']['pluginViewContent'] = ob_get_clean();
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         } else {
             throw new Exception(__("No action"));
         }
         $GLOBALS['Plugin']['comingFromPlugin'] = true;
         $adminController = new Admin();
         $adminController->index();
     } else {
         parent::loadModule();
     }
 }