OSDN Git Service

ADD: <%parsedinclude%>でスキン内でスペシャルスキンパーツを展開する機能を追加
authorsakamocchi <o-takashi@sakamocchi.jp>
Sun, 6 May 2012 14:35:05 +0000 (23:35 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sun, 6 May 2012 14:35:05 +0000 (23:35 +0900)
Nucleus CMS日本語版3.41から実装された同機能を実装。詳細は以下を参照のこと。
http://sourceforge.jp/projects/nucleus-jp/lists/archive/developers/2012-May/000944.html

nucleus/libs/ACTIONS.php
nucleus/libs/BaseActions.php
nucleus/libs/PARSER.php
nucleus/libs/SKIN.php

index 7d9cc09..61d4930 100644 (file)
@@ -28,9 +28,6 @@ class Actions extends BaseActions
        // generating links to items/archives/... (e.g. catid)\r
        private $linkparams;\r
        \r
-       // reference to the skin object for which a part is being parsed\r
-       private $skin;\r
-       \r
        // used when including templated forms from the include/ dir. The $formdata var\r
        // contains the values to fill out in there (assoc array name -> value)\r
        private $formdata;\r
@@ -259,18 +256,6 @@ class Actions extends BaseActions
        }\r
        \r
        /**\r
-        * Actions::setSkin()\r
-        * Set the skin\r
-        * @param       object  $skin   an instance of Skin class\r
-        * @return      void\r
-        */\r
-       public function setSkin(&$skin)\r
-       {\r
-               $this->skin =& $skin;\r
-               return;\r
-       }\r
-       \r
-       /**\r
         * Actions::doForm()\r
         * Forms get parsedincluded now, using an extra <formdata> skinvar\r
         *\r
@@ -2131,7 +2116,7 @@ class Actions extends BaseActions
         */\r
        public function parse_skinname()\r
        {\r
-               echo $this->skin->getName();\r
+               echo $this->parser->skin->getName();\r
                return;\r
        }\r
        \r
@@ -2234,4 +2219,4 @@ class Actions extends BaseActions
                $this->postBlogContent('sticky',$b);\r
                return;\r
        }\r
-}
\ No newline at end of file
+}\r
index 7261ff3..d9e9152 100644 (file)
@@ -183,10 +183,10 @@ class BaseActions
         * BaseActions::parse_parsedinclude()
         * parsed include
         * 
-        * @param       string  $filename       filename to be included
+        * @param       string  $name   filename to be included
         * @return      void
         */
-       public function parse_parsedinclude($filename)
+       public function parse_parsedinclude($name)
        {
                // check current level
                if ( $this->level > 3 )
@@ -195,14 +195,15 @@ class BaseActions
                        return;
                }
                
-               $file = $this->getIncludeFileName($filename);
-               
-               if ( !file_exists($file) )
+               $file = $this->getIncludeFileName($name);
+               if ( !file_exists($file) && $this->parser->skin != NULL)
                {
-                       return;
+                       $contents = $this->parser->skin->getContentFromDB($name);
+               }
+               else
+               {
+                       $contents = file_get_contents($file);
                }
-               
-               $contents = file_get_contents($file);
                
                if ( empty($contents) )
                {
index 2c2dd73..06f67cb 100644 (file)
@@ -33,6 +33,9 @@ class Parser
        // reference to actions handler\r
        public $handler;\r
        \r
+       // reference to an instance of Skin class\r
+       public $skin = NULL;\r
+       \r
        // delimiters that can be used for skin/templatevars\r
        public $delim;\r
        \r
@@ -59,6 +62,8 @@ class Parser
                $this->pdelim   =  $pdelim;\r
                $this->norestrictions = 0;      // set this to 1 to disable checking for allowedActions\r
                \r
+               $this->skin             = NULL;\r
+               \r
                $handler->setParser($this);\r
                \r
                return;\r
@@ -120,6 +125,7 @@ class Parser
                }\r
                \r
                $actionlc = strtolower($action);\r
+               \r
                // skip execution of skinvars while inside an if condition which hides this part of the page\r
                $if_tags = array('else', 'elseif', 'endif', 'ifnot', 'elseifnot');\r
                if ( !$this->handler->getTopIfCondition()\r
@@ -152,6 +158,18 @@ class Parser
        }\r
        \r
        /**\r
+        * Parser::setSkin()\r
+        * Set the skin\r
+        * @param       object  $skin   an instance of Skin class\r
+        * @return      void\r
+        */\r
+       public function setSkin(&$skin)\r
+       {\r
+               $this->skin = &$skin;\r
+               return;\r
+       }\r
+       \r
+       /**\r
         * Parser::setProperty()\r
         * Set a property of the parser in the manager\r
         * \r
index d6b94a5..682a948 100644 (file)
@@ -376,6 +376,7 @@ class Skin
                \r
                // register action handler to parser\r
                $parser = new Parser($handler);\r
+               $parser->setSkin($this);\r
                $parser->parse($contents);\r
                \r
                $data = array(