X-Git-Url: http://git.osdn.net/view?p=nucleus-jp%2Fnucleus-next.git;a=blobdiff_plain;f=nucleus%2Flibs%2FMANAGER.php;h=ea9a5ad6a8f3aac653795ec3cac710125c7e92cb;hp=8dd1b6a30752a7eeaca4d3f3b4341f6b3586caf4;hb=e8e71808dfab704b2201e270f65eba7a4316ff18;hpb=e77937313dbcaf91fdc737515a0f0949712934c0 diff --git a/nucleus/libs/MANAGER.php b/nucleus/libs/MANAGER.php index 8dd1b6a..ea9a5ad 100644 --- a/nucleus/libs/MANAGER.php +++ b/nucleus/libs/MANAGER.php @@ -20,7 +20,7 @@ * * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2009 The Nucleus Group - * @version $Id: MANAGER.php 1731 2012-04-08 15:10:35Z sakamocchi $ + * @version $Id: MANAGER.php 1878 2012-06-17 07:42:07Z sakamocchi $ */ class Manager { @@ -38,6 +38,7 @@ class Manager private $karma; private $templates; private $members; + private $skins; /** * cachedInfo to avoid repeated SQL queries (see pidInstalled/pluginInstalled/getPidFromName) @@ -71,7 +72,7 @@ class Manager * $manager =& Manager::instance(); to get a reference to the object * instead of a copy */ - public function &instance() + public static function &instance() { static $instance = array(); if ( empty($instance) ) @@ -90,8 +91,11 @@ class Manager $this->blogs = array(); $this->plugins = array(); $this->karma = array(); + $this->templates = array(); + $this->skins = array(); $this->parserPrefs = array(); $this->cachedInfo = array(); + $this->members = array(); return; } @@ -102,8 +106,6 @@ class Manager */ public function &getItem($itemid, $allowdraft, $allowfuture) { - $item =& $this->items[$itemid]; - /* confirm to cached */ if ( !array_key_exists($itemid, $this->items) ) { @@ -158,17 +160,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]; } /** @@ -194,14 +191,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]; } /** @@ -209,17 +204,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]; } /** @@ -227,17 +217,31 @@ 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]; + } + + /** + * Manager::getSkin() + * + * @param integer $skinid ID for skin + * @param string $action_class action class for handling skin variables + * @param string $event_identifier identifier for event name + * @return object instance of Skin class + */ + public function &getSkin($skinid, $action_class='Actions', $event_identifier='Skin') + { + 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]; } /** @@ -264,10 +268,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; } @@ -565,7 +570,7 @@ class Manager && !empty($this->plugins[$listener]) && method_exists($this->plugins[$listener], 'event_' . $eventName) ) { - call_user_func(array(&$this->plugins[$listener],'event_' . $eventName), $data); + call_user_func(array(&$this->plugins[$listener], 'event_' . $eventName), array(&$data)); } } }