OSDN Git Service

MERGE: Skinクラスのみリビジョン1778/1779/1780をマージ
authorsakamocchi <o-takashi@sakamocchi.jp>
Sat, 21 Apr 2012 11:05:22 +0000 (20:05 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sat, 21 Apr 2012 11:05:22 +0000 (20:05 +0900)
nucleus/libs/SKIN.php

index 70ca513..06320a8 100644 (file)
@@ -14,7 +14,7 @@
  *\r
  * @license http://nucleuscms.org/license.txt GNU General Public License\r
  * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
- * @version $Id: SKIN.php 1773 2012-04-21 02:14:08Z sakamocchi $
+ * @version $Id: SKIN.php 1780 2012-04-21 10:41:52Z sakamocchi $\r
  */\r
 \r
 if ( !function_exists('requestVar') ) \r
@@ -54,17 +54,6 @@ class Skin
                \r
                $this->id = (integer) $id;\r
                \r
-               // read skin name/description/content type\r
-               $query = "SELECT * FROM %s WHERE sdnumber=%d";\r
-               $query = sprintf($query, sql_table('skin_desc'), (integer) $this->id);\r
-               $res = sql_query($query);\r
-               $obj = sql_fetch_object($res);\r
-               $this->valid = (sql_num_rows($res) > 0);\r
-               if ( !$this->valid )\r
-               {\r
-                       return;\r
-               }\r
-               \r
                /*\r
                 * NOTE: include needed action class\r
                 */\r
@@ -90,6 +79,18 @@ class Skin
                $this->action_class = $action_class;\r
                $this->event_identifier = $event_identifier;\r
                \r
+               // read skin name/description/content type\r
+               $query = "SELECT * FROM %s WHERE sdnumber=%d;";\r
+               $query = sprintf($query, sql_table('skin_desc'), $this->id);\r
+               $res = sql_query($query);\r
+               $obj = sql_fetch_object($res);\r
+               \r
+               $this->valid = (sql_num_rows($res) > 0);\r
+               if ( !$this->valid )\r
+               {\r
+                       return;\r
+               }\r
+               \r
                $this->name = $obj->sdname;\r
                $this->description = $obj->sddesc;\r
                $this->contentType = $obj->sdtype;\r
@@ -367,8 +368,9 @@ class Skin
                $action_class = $this->action_class;\r
                $handler = new $action_class($type);\r
                \r
-               $actions = $handler->getDefinedActions($type);
+               $actions = $handler->getDefinedActions($type);\r
                $parser = new Parser($actions, $handler);\r
+               \r
                $handler->setParser($parser);\r
                $handler->setSkin($this);\r
                $parser->parse($contents);\r
@@ -558,8 +560,8 @@ class Skin
                $includeMode    = sql_real_escape_string($includeMode);\r
                $includePrefix  = sql_real_escape_string($includePrefix);\r
                \r
-               $query ="UPDATE %s SET sdname='%s', sddesc='%s', sdtype='%s', sdincmode='%s', sdincpref='%s' WHERE sdnumber=%d";
-               $query = sprintf($query, sql_table('skin_desc'), $name, $desc, $type, $includeMode, $includePrefix, (integer) $this->id);
+               $query ="UPDATE %s SET sdname='%s', sddesc='%s', sdtype='%s', sdincmode='%s', sdincpref='%s' WHERE sdnumber=%d";\r
+               $query = sprintf($query, sql_table('skin_desc'), $name, $desc, $type, $includeMode, $includePrefix, (integer) $this->id);\r
                \r
                sql_query($query);\r
                return;\r
@@ -579,7 +581,6 @@ class Skin
                 * NOTE: static method with variable class name is supported since PHP 5.3\r
                 *  So now we utilize eval function.\r
                 */\r
-               $page_action_names = array();\r
                eval("\$defined_actions = {$this->action_class}::getDefinedActions('{$type}');");\r
                return $defined_actions;\r
        }\r
@@ -589,56 +590,16 @@ class Skin
         * Get an array with the names of possible skin parts\r
         * Used to show all possible parts of a skin in the administration backend\r
         * \r
-        * @static\r
-        * @param       string  $action_class   name of action class (optional)\r
-        * @param       array   type of the skin\r
+        * @param       string  void\r
+        * @return      array   type of the skin\r
         */\r
-       static public function getFriendlyNames($action_class='Actions')\r
+       public function getFriendlyNames()\r
        {\r
-               global $DIR_LIBS;\r
-               \r
-               /*\r
-                * NOTE: include needed action class\r
-                */\r
-               if ( $action_class != 'Actions' )\r
-               {\r
-                       if ( !class_exists($action_class, FALSE)\r
-                         && (!file_exists("{$DIR_LIBS}{$action_class}.php")\r
-                          || !include("{$DIR_LIBS}{$action_class}.php")) )\r
-                       {\r
-                               return;\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       if ( !class_exists('Actions', FALSE)\r
-                         && (!file_exists("{$DIR_LIBS}ACTIONS.php")\r
-                          || !include("{$DIR_LIBS}ACTIONS.php")) )\r
-                       {\r
-                               return;\r
-                       }\r
-               }\r
-               \r
                /**\r
                 * NOTE: static method with variable class name is supported since PHP 5.3\r
                 *  So now we utilize eval function.\r
                 */\r
-               eval("\$friendly_names = {$action_class}::getSkinTypeFriendlyNames();");\r
-               \r
-               $action_names = array();\r
-               foreach ( $friendly_names as $action_name => $friendly_name )\r
-               {\r
-                       $action_names[] = $action_name;\r
-               }\r
-               \r
-               $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s');";\r
-               $query = sprintf($query, sql_table('skin'), implode("','", $action_names));\r
-               $res = sql_query($query);\r
-               \r
-               while ( $row = sql_fetch_array($res) )\r
-               {\r
-                       $friendly_names[strtolower($row['stype'])] = $row['stype'];\r
-               }\r
+               eval("\$friendly_names = {$this->action_class}::getSkinTypeFriendlyNames();");\r
                return $friendly_names;\r
        }\r
 }\r