From 947732acf35b5e7f201342949cc069514c770f9b Mon Sep 17 00:00:00 2001 From: sakamocchi Date: Sun, 27 May 2012 11:00:45 +0900 Subject: [PATCH] =?utf8?q?ADD:=20=E3=82=B9=E3=82=AD=E3=83=B3=E3=82=92?= =?utf8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5=E3=81=99=E3=82=8B?= =?utf8?q?=E3=81=9F=E3=82=81=E3=81=ABManager:getSkin()=E3=82=92=E8=BF=BD?= =?utf8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit AdminActionsクラスでスキンオブジェクトを再利用する必要が生じたため。 加えてarray_key_exists()を用いてコードを整理した。 --- nucleus/libs/MANAGER.php | 69 ++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/nucleus/libs/MANAGER.php b/nucleus/libs/MANAGER.php index c8d9b01..e1fe1d4 100644 --- a/nucleus/libs/MANAGER.php +++ b/nucleus/libs/MANAGER.php @@ -38,6 +38,7 @@ class Manager private $karma; private $templates; private $members; + private $skins; /** * cachedInfo to avoid repeated SQL queries (see pidInstalled/pluginInstalled/getPidFromName) @@ -90,6 +91,8 @@ class Manager $this->blogs = array(); $this->plugins = array(); $this->karma = array(); + $this->templates = array(); + $this->skins = array(); $this->parserPrefs = array(); $this->cachedInfo = array(); return; @@ -156,17 +159,12 @@ class Manager */ public function &getBlog($blogid) { - $blog =& $this->blogs[$blogid]; - - if ( !$blog ) + if ( !array_key_exists($blogid, $this->blogs) ) { - // load class if needed $this->_loadClass('BLOG','BLOG.php'); - // load blog object - $blog = new Blog($blogid); - $this->blogs[$blogid] =& $blog; + $this->blogs[$blogid] = new Blog($blogid); } - return $blog; + return $this->blogs[$blogid]; } /** @@ -192,14 +190,12 @@ class Manager */ public function &getTemplate($templateName) { - $template =& $this->templates[$templateName]; - - if ( !$template ) + if ( !array_key_exists($templateName, $this->templates) ) { - $template = Template::read($templateName); - $this->templates[$templateName] =& $template; + $this->_loadClass('Template','TEMPLATE.php'); + $this->templates[$templateName] =& Template::read($templateName); } - return $template; + return $this->templates[$templateName]; } /** @@ -207,17 +203,12 @@ class Manager */ public function &getKarma($itemid) { - $karma =& $this->karma[$itemid]; - - if ( !$karma ) + if ( !array_key_exists($itemid, $this->karma) ) { - // load class if needed - $this->_loadClass('KARMA','KARMA.php'); - // create KARMA object - $karma = new Karma($itemid); - $this->karma[$itemid] =& $karma; + $this->_loadClass('Karma','KARMA.php'); + $this->karma[$itemid] = new Karma($itemid); } - return $karma; + return $this->karma[$itemid]; } /** @@ -225,17 +216,26 @@ class Manager */ public function &getMember($memberid) { - $mem =& $this->members[$memberid]; - - if ( !$mem ) + if ( !array_key_exists($memberid, $this->members) ) { - // load class if needed - $this->_loadClass('MEMBER','MEMBER.php'); - // create MEMBER object - $mem =& Member::createFromID($memberid); - $this->members[$memberid] =& $mem; + $this->_loadClass('Member','MEMBER.php'); + $this->members[$memberid] =& Member::createFromID($memberid);; } - return $mem; + return $this->members[$memberid]; + } + + /** + * + */ + public function &getSkin($skinid, $action_class='', $event_identifier='') + { + if ( !array_key_exists($skinid, $this->skins) ) + { + $this->_loadClass('Skin', 'SKIN.php'); + $this->skins[$skinid] = new Skin($skinid, $action_class, $event_identifier); + } + + return $this->skins[$skinid]; } /** @@ -262,10 +262,11 @@ class Manager */ private function _loadClass($name, $filename) { + global $DIR_LIBS; + if ( !class_exists($name) ) { - global $DIR_LIBS; - include($DIR_LIBS . $filename); + include($DIR_LIBS . $filename); } return; } -- 2.11.0