/** * Load the model file of one module. * * @param string $methodName The method name, if empty, use current module's name. * @access public * @return object|bool If no model file, return false. Else return the model object. */ protected function loadModel($moduleName) { $modelFile = \helper::setModelFile($moduleName); /* If no model file, try load config. */ if (!\helper::import($modelFile)) { $this->app->loadConfig($moduleName, false); $this->app->loadLang($moduleName); $this->dao = new dao(); return false; } $modelClass = class_exists('ext' . $moduleName . 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model'; $modelClass = '\\' . $modelClass; if (!class_exists($modelClass)) { $this->app->triggerError(" The model {$modelClass} not found", __FILE__, __LINE__, $exit = true); } $this->{$moduleName} = new $modelClass(); $this->dao = $this->{$moduleName}->dao; return $this->{$moduleName}; }
/** * Load the model of one module. After loaded, can use $this->modulename to visit the model object. * * @param string $moduleName * @access public * @return object|bool the model object or false if model file not exists. */ public function loadModel($moduleName) { if (empty($moduleName)) { return false; } $modelFile = helper::setModelFile($moduleName); if (!helper::import($modelFile)) { return false; } $modelClass = class_exists('ext' . $moduleName . 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model'; if (!class_exists($modelClass)) { $this->app->triggerError(" The model {$modelClass} not found", __FILE__, __LINE__, $exit = true); } $this->{$moduleName} = new $modelClass(); return $this->{$moduleName}; }
/** * Load the common module * * The common module is a special module, which can be used to do some common things. For examle: * start session, check priviledge and so on. * This method should called manually in the router file(www/index.php) after the $lang, $config, $dbh loadde. * * @access public * @return object|bool the common control object or false if not exits. */ public function loadCommon() { $this->setModuleName('common'); $commonModelFile = helper::setModelFile('common'); if (!file_exists($commonModelFile)) { $commonModelFile = helper::setModelFile('common', 'sys'); } helper::import($commonModelFile); if (class_exists('extcommonModel')) { return new extcommonModel(); } elseif (class_exists('commonModel')) { return new commonModel(); } else { return false; } }
/** * Load the model file of one module. * * @param string $methodName The method name, if empty, use current module's name. * @access public * @return object|bool If no model file, return false. Else return the model object. */ public function loadModel($moduleName = '') { if (empty($moduleName)) { $moduleName = $this->moduleName; } $modelFile = helper::setModelFile($moduleName); /* If no model file, try load config. */ if (!helper::import($modelFile)) { $this->app->loadConfig($moduleName, false); $this->app->loadLang($moduleName); $this->dao = new dao(); return false; } $modelClass = class_exists('ext' . $moduleName . 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model'; if (!class_exists($modelClass)) { $this->app->error(" The model {$modelClass} not found", __FILE__, __LINE__, $exit = true); } $this->{$moduleName} = new $modelClass(); $this->dao = $this->{$moduleName}->dao; return $this->{$moduleName}; }