OSDN Git Service

Merge branch 'skinnable-master'
[nucleus-jp/nucleus-next.git] / nucleus / libs / BaseActions.php
index 7fddf25..6ae996b 100644 (file)
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: BaseActions.php 1757 2012-04-15 09:02:32Z sakamocchi $
+<<<<<<< HEAD
+ * @version $Id: BaseActions.php 1848 2012-05-16 12:17:00Z sakamocchi $
+=======
+ * @version $Id: BaseActions.php 1882 2012-06-17 07:52:43Z sakamocchi $
+>>>>>>> skinnable-master
  */
 
 class BaseActions
@@ -52,6 +56,25 @@ class BaseActions
        // and parseHighlight() methods)
        private $aHighlight;
        
+       /* NOTE: defined actions for this base class */
+       static private $defined_actions = array(
+               'benchmark',
+               'charset',
+               'else',
+               'elseif',
+               'elseifnot',
+               'endif',
+               'if',
+               'ifnot',
+               'include',
+               'locale',
+               'parsedinclude',
+               'phpinclude',
+               'set',
+               'skinfile',
+               'text'
+       );
+       
        /**
         * BaseActions::__construct()
         *  Constructor for a new BaseAction object
@@ -72,6 +95,74 @@ class BaseActions
        }
        
        /**
+        * BaseActions::getAvailableActions()
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function getAvailableActions()
+       {
+               return self::$defined_actions;
+       }
+       
+       /**
+        * BaseActions::setParser()
+        * Set the parser
+        * 
+        * @param       object  $parser an instance of Parser class
+        * @return      void
+        */
+       public function setParser(&$parser)
+       {
+               $this->parser =& $parser;
+               return;
+       }
+       
+       /**
+        * BaseActions::parse_charset()
+        * Parse charset to appropriate character set name registered to IANA
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_charset()
+       {
+               global $member;
+               
+               if ( i18n::get_forced_charset() !== '' )
+               {
+                       echo i18n::get_forced_charset();
+               }
+               else
+               {
+                       echo i18n::get_current_charset();
+               }
+               
+               return;
+       }
+       
+       /**
+        * BaseActions::parse_locale()
+<<<<<<< HEAD
+        * Parse locale to language-script-region according to RFC 4646
+=======
+        * Parse locale to language-region according to RFC 4646
+>>>>>>> skinnable-master
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_locale()
+       {
+<<<<<<< HEAD
+               echo preg_replace('#_#', '-', i18n::get_current_locale());
+=======
+               echo preg_replace('#(.+)_(.+)_(.+)#', '$1-$3', i18n::get_current_locale());
+>>>>>>> skinnable-master
+               return;
+       }
+       
+       /**
         * BaseActions::parse_include()
         * include file (no parsing of php)
         * 
@@ -105,10 +196,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 )
@@ -117,14 +208,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) )
                {
@@ -202,13 +294,33 @@ class BaseActions
        }
        
        /**
+        * BaseActions::parse_text()
+        * Parse text
+        * 
+        * @param       string  $constant       named constant
+        * @return      void
+        */
+       public function parse_text($constant)
+       {
+               if ( !defined($constant) )
+               {
+                       echo $constant;
+               }
+               else
+               {
+                       echo constant($constant);
+               }
+               return;
+       }
+       
+       /**
         * BaseActions::addIfCondition()
         * Helper function: add if condition
         * 
         * @param       string  $condition      condition for if context
         * @return      void
         */
-       protected function addIfCondition($condition)
+       private function addIfCondition($condition)
        {
                array_push($this->if_conditions,$condition);
                $this->updateTopIfCondition();
@@ -310,6 +422,20 @@ class BaseActions
        }
        
        /**
+        * BaseActions::parse_benchmark()
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_benchmark()
+       {
+               global $StartTime;
+               $loadtime = microtime(TRUE) - $StartTime;
+               printf("%.3F sec/%d queries", $loadtime, DB::getExecCount());
+               return;
+       }
+       
+       /**
         * BaseActions::parse_if()
         * Parses <%if%> statements
         * 
@@ -320,7 +446,11 @@ class BaseActions
        {
                $this->addIfExecute();
                $args = func_get_args();
+<<<<<<< HEAD
                $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
+=======
+               $condition = call_user_func_array(array($this,'checkCondition'), $args);
+>>>>>>> skinnable-master
                $this->addIfCondition($condition);
                return;
        }
@@ -391,7 +521,11 @@ class BaseActions
                {
                        ob_end_clean();
                        $args = func_get_args();
+<<<<<<< HEAD
                        $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
+=======
+                       $condition = call_user_func_array(array($this,'checkCondition'), $args);
+>>>>>>> skinnable-master
                        $this->addIfCondition($condition);
                }
                return;
@@ -409,7 +543,11 @@ class BaseActions
                $this->addIfExecute();
                
                $args = func_get_args();
+<<<<<<< HEAD
                $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
+=======
+               $condition = call_user_func_array(array($this,'checkCondition'), $args);
+>>>>>>> skinnable-master
                $this->addIfCondition(!$condition);
                return;
        }
@@ -445,7 +583,11 @@ class BaseActions
                {
                        ob_end_clean();
                        $args = func_get_args();
+<<<<<<< HEAD
                        $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
+=======
+                       $condition = call_user_func_array(array($this,'checkCondition'), $args);
+>>>>>>> skinnable-master
                        $this->addIfCondition(!$condition);
                }
                return;