OSDN Git Service

CHANGE: getBlogIDFromItemID()を使わずにManager::getItem()を使うよう変更
[nucleus-jp/nucleus-next.git] / nucleus / libs / MANAGER.php
index 0c55d27..8dd1b6a 100644 (file)
@@ -32,12 +32,12 @@ class Manager
         * The $items, $blogs, ... arrays map an id to an object (for plugins, the name is used\r
         * rather than an ID)\r
         */\r
-       var $items;\r
-       var $blogs;\r
-       var $plugins;\r
-       var $karma;\r
-       var $templates;\r
-       var $members;\r
+       private $items;\r
+       private $blogs;\r
+       private $plugins;\r
+       private $karma;\r
+       private $templates;\r
+       private $members;\r
        \r
        /**\r
         * cachedInfo to avoid repeated SQL queries (see pidInstalled/pluginInstalled/getPidFromName)\r
@@ -98,36 +98,32 @@ class Manager
        /**\r
         * Returns the requested item object. If it is not in the cache, it will\r
         * first be loaded and then placed in the cache.\r
-        * Intended use: $item =& $manager->getItem(1234)\r
+        * Intended use: $item =& $manager->getItem(1234, 0, 0)\r
         */\r
        public function &getItem($itemid, $allowdraft, $allowfuture)\r
        {\r
                $item =& $this->items[$itemid];\r
                \r
-               // check the draft and future rules if the item was already cached\r
-               if ( $item )\r
+               /* confirm to cached */\r
+               if ( !array_key_exists($itemid, $this->items) )\r
                {\r
-                       if ( (!$allowdraft) && ($item['draft']) )\r
-                       {\r
-                               return 0;\r
-                       }\r
-                       \r
-                       $blog =& $this->getBlog(getBlogIDFromItemID($itemid));\r
-                       \r
-                       if ( (!$allowfuture) && ($item['timestamp'] > $blog->getCorrectTime()) )\r
-                       {\r
-                               return 0;\r
-                       }\r
-               }\r
-               \r
-               if ( !$item )\r
-               {\r
-                       // load class if needed\r
                        $this->loadClass('ITEM');\r
-                       // load item object\r
                        $item = Item::getitem($itemid, $allowdraft, $allowfuture);\r
                        $this->items[$itemid] = $item;\r
                }\r
+               \r
+               $item =& $this->items[$itemid];\r
+               if ( !$allowdraft && ($item['draft']) )\r
+               {\r
+                       return 0;\r
+               }\r
+               \r
+               $blog =& $this->getBlog($item['blogid']);\r
+               if ( !$allowfuture && ($item['timestamp'] > $blog->getCorrectTime()) )\r
+               {\r
+                       return 0;\r
+               }\r
+               \r
                return $item;\r
        }\r
        \r