Minahito
minah****@users*****
2006年 6月 5日 (月) 19:53:27 JST
Index: xoops2jp/html/kernel/XCube_Root.class.php diff -u xoops2jp/html/kernel/XCube_Root.class.php:1.1.2.11 xoops2jp/html/kernel/XCube_Root.class.php:1.1.2.12 --- xoops2jp/html/kernel/XCube_Root.class.php:1.1.2.11 Tue Feb 28 23:29:09 2006 +++ xoops2jp/html/kernel/XCube_Root.class.php Mon Jun 5 19:53:27 2006 @@ -1,6 +1,6 @@ <?php /** - * @version $Id: XCube_Root.class.php,v 1.1.2.11 2006/02/28 14:29:09 nobunobu Exp $ + * @version $Id: XCube_Root.class.php,v 1.1.2.12 2006/06/05 10:53:27 minahito Exp $ * @package Cube */ @@ -16,52 +16,27 @@ /** @access private */ - var $mController=null; + var $mController = null; /** - * @access private - */ - var $mFeatureManager=null; - - /** * @access private ? */ - var $mLanguageManager=null; + var $mLanguageManager = null; - var $mEventManager=null; + var $mEventManager = null; - var $mServiceManager=null; + var $mServiceManager = null; /** * @deprecated */ - var $mRenderSystem=null; - - var $mRenderSystems=array(); + var $mRenderSystem = null; - var $mSiteConfig=array(); + var $mRenderSystems = array(); - /** - * THIS IS TEST - * - * Why this is public is that PHP4 does not give property overload to us. - * This naming rule is test, too. - * - * @access public - */ - var $ContentManager=null; + var $mSiteConfig = array(); /** - * THIS IS TEST - * - * Why this is public is that PHP4 does not give property overload to us. - * This naming rule is test, too. - * - * @access public - */ - var $ModifierManager=null; - - /** * The theme is one in one time of request. * A decided theme is registered with this property * @@ -76,82 +51,105 @@ } /** + * Return a object of XCube_Root as singleton. + * * @return XCube_Root */ function &getSingleton() { static $instance; - if(!isset($instance)) - $instance=new XCube_Root(); + + if (!isset($instance)) + $instance = new XCube_Root(); return $instance; } /** * Load SiteConfig from plural files, and control set and override site config. + * + * @return void */ function loadSiteConfig() { - if(func_num_args()==0) + if (func_num_args() == 0) { die("FETAL: You doesn't have site setting config."); + } - $file=func_get_arg(0); - if(!file_exists($file)) + $file = func_get_arg(0); + if(!file_exists($file)) { die("FETAL: You cann't open site setting config."); + } - $this->setSiteConfig(parse_ini_file($file,true)); + $this->setSiteConfig(parse_ini_file($file, true)); // // Override setting. // - if(func_num_args()>1) { - for($i=1;$i<func_num_args();$i++) { - $overrideFile=func_get_arg($i); + if (func_num_args() > 1) { + for ($i = 1; $i < func_num_args(); $i++) { + $overrideFile = func_get_arg($i); - if(file_exists($overrideFile)) - $this->overrideSiteConfig(parse_ini_file($overrideFile,true)); + if (file_exists($overrideFile)) { + $this->overrideSiteConfig(parse_ini_file($overrideFile, true)); + } } } } + /** + * Set site configs. + * + * @param array $config + */ function setSiteConfig($config) { - $this->mSiteConfig=$config; + $this->mSiteConfig = $config; } /** - * Override site config. SiteConfig is overrided by $config value. And, if $config has new key, the key is set. + * Override site config. SiteConfig is overrided by $config value. And, if + * $config has new key, that key is set. + * + * @param array $config */ function overrideSiteConfig($config) { - foreach($config as $_overKey=>$_overVal) { - if(array_key_exists($_overKey,$this->mSiteConfig)) { - $this->mSiteConfig[$_overKey]=array_merge($this->mSiteConfig[$_overKey],$_overVal); + foreach ($config as $_overKey=>$_overVal) { + if (array_key_exists($_overKey, $this->mSiteConfig)) { + $this->mSiteConfig[$_overKey] = array_merge($this->mSiteConfig[$_overKey], $_overVal); } else { - $this->mSiteConfig[$_overKey]=$_overVal; + $this->mSiteConfig[$_overKey] = $_overVal; } } } + /** + * Return the value of site config that is defined by ini files. + * + * @return mixed If the value specified by parameters is no, return null. + */ function getSiteConfig() { // // TODO Check keys with using 'isset' // - if(func_num_args()==0) { + if (func_num_args() == 0) { return $this->mSiteConfig; } - elseif(func_num_args()==1) { - if(isset($this->mSiteConfig[func_get_arg(0)])) + elseif (func_num_args() == 1) { + if (isset($this->mSiteConfig[func_get_arg(0)])) { return $this->mSiteConfig[func_get_arg(0)]; + } } - elseif(func_num_args()==2) { - if(isset($this->mSiteConfig[func_get_arg(0)][func_get_arg(1)])) + elseif (func_num_args() == 2) { + if (isset($this->mSiteConfig[func_get_arg(0)][func_get_arg(1)])) { return $this->mSiteConfig[func_get_arg(0)][func_get_arg(1)]; + } } - elseif(func_num_args()==3) { - if(isset($this->mSiteConfig[func_get_arg(0)][func_get_arg(1)])) { + elseif (func_num_args() == 3) { + if (isset($this->mSiteConfig[func_get_arg(0)][func_get_arg(1)])) { return $this->mSiteConfig[func_get_arg(0)][func_get_arg(1)]; } else { @@ -163,7 +161,10 @@ } /** - * Create controller with own site setting. + * Create controller with the rule, and call member function prepare(). + * The class of creating controller is defined in ini.php files. + * + * @return void */ function setupController() { @@ -172,75 +173,110 @@ // We don't decide the style of SiteConfig. // $controllerName = $this->mSiteConfig['Cube']['Controller']; - $this->mController=&$this->_createInstance($this->mSiteConfig[$controllerName]['class'],$this->mSiteConfig[$controllerName]['path']); + $this->mController =& $this->_createInstance($this->mSiteConfig[$controllerName]['class'], $this->mSiteConfig[$controllerName]['path']); $this->mController->prepare($this); } + /** + * Return the instance of the controller. + * + * @return XCube_Controller + */ function &getController() { return $this->mController; } - function setFeatureManager(&$featureManager) - { - $this->mFeatureManager=&$featureManager; - } - - function &getFeatureManager() - { - return $this->mFeatureManager; - } - + /** + * Set the instance of the language manager. + * + * @param $languageManager XCube_LanguageManager + * @return void + */ function setLanguageManager(&$languageManager) { - $this->mLanguageManager=&$languageManager; + $this->mLanguageManager =& $languageManager; } + /** + * Return the instance of the language manager. + * + * @return XCube_LanguageManager + */ function &getLanguageManager() { return $this->mLanguageManager; } + /** + * Set the instance of the event manager. + * + * @param $eventManager XCube_EventManager + * @return void + */ function setEventManager(&$eventManager) { - $this->mEventManager=&$eventManager; + $this->mEventManager =& $eventManager; } + /** + * Return the instance of the event manager. + * + * @return XCube_EventManager + */ function &getEventManager() { return $this->mEventManager; } + /** + * Set the instance of the service manager. + * + * @param $languageManager XCube_ServiceManager + * @return void + */ function setServiceManager(&$serviceManager) { - $this->mServiceManager=&$serviceManager; + $this->mServiceManager =& $serviceManager; } + /** + * Return the instance of the service manager. + * + * @return XCube_EventManager + */ function &getServiceManager() { return $this->mServiceManager; } - - function setModifierManager(&$modifierManager) - { - $this->ModifierManager=&$modifierManager; - } - - function &getModifierManager() - { - return $this->ModifierManager; - } + /** + * Set the theme name. + * + * @param $theme string + */ function setThemeName($theme) { $this->mThemeName = $theme; } + /** + * Return the theme name. + * + * @return string + */ function getThemeName() { return $this->mThemeName; } + /** + * Return the instance of the cache system. The instance of cache system + * is singleton in XOOPS Cube. This member function is getInstance() at + * singleton pattern. + * + * @return XCube_CacheSystem + */ function &getCacheSystem() { if (!is_object($this->mCacheSystem)) { @@ -250,6 +286,14 @@ return $this->mCacheSystem; } + /** + * Return the instance of the render system by the name. If the render + * system specified by $name doesn't exist, raise fatal error. This member + * function does creating the instance and calling prepare(). + * + * @todo + * @param $name string the registed name of the render system. + */ function &getRenderSystem($name) { if (isset($this->mRenderSystems[$name])) { @@ -271,15 +315,28 @@ return $this->mRenderSystems[$name]; } + /** + * Create the instance dynamic with the rule and the string parameters. + * First, load the file from $classPath. The rule is XOOPS_ROOT_PATH + + * $classPath + $className + .class.php. Next, create the instance of the + * class if the class is defined rightly. This member function is called by + * other member functions of XCube_Root. + * + * @access private + * @param $className string the name of class. + * @param $classPath string the path that $className is defined in. + * @return void + * @todo If the file doesn't exist, require_once() raises fatal errors. + */ function &_createInstance($className, $classPath=null) { $ret = null; - if($classPath!=null) { + if ($classPath != null) { require_once XOOPS_ROOT_PATH . "/" . $classPath . "/" . $className . ".class.php"; } - if(class_exists($className)) { + if (class_exists($className)) { $ret =& new $className(); }