OSDN Git Service

Merge branch 'skinnable-master' of ssh://shizuki@git.sourceforge.jp/gitroot/nucleus...
[nucleus-jp/nucleus-next.git] / nucleus / libs / COMMENTACTIONS.php
index 5065866..dd469f0 100644 (file)
@@ -1,7 +1,7 @@
 <?php\r
 /*\r
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2012 The Nucleus Group\r
+ * Copyright (C) 2002-2009 The Nucleus Group\r
  *\r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
  * This class is used when parsing comment templates\r
  *\r
  * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
  * @version $Id: CommentActions.php 1626 2012-01-09 15:46:54Z sakamocchi $\r
  */\r
 \r
 class CommentActions extends BaseActions\r
 {\r
-       // ref to COMMENTS object which is using this object to handle\r
-       // its templatevars\r
+       /**\r
+        * CommentsActions::$commentsObj\r
+        * ref to COMMENTS object which is using this object to handle its templatevars\r
+        */\r
        private $commentsObj;\r
        \r
-       // template to use to parse the comments\r
+       /**\r
+        * CommentsActions::$template\r
+        * template to use to parse the comments\r
+        */\r
        private $template;\r
        \r
-       // comment currenlty being handled (mysql result assoc array; see Comments::showComments())\r
+       /**\r
+        * CommentsActions::$currentComment\r
+        * comment currenlty being handled (mysql result assoc array; see Comments::showComments())\r
+        */\r
        private $currentComment;\r
        \r
+       /**\r
+        * CommentsActions::$defined_actions\r
+        * defined actions in this class\r
+        */\r
        static private $defined_actions = array(\r
+               'authtext',
+               'blogid',
                'blogurl',\r
+               'body',
                'commentcount',\r
+               'commentid',
                'commentword',\r
+               'date',
                'email',\r
+               'excerpt',
+               'host',
+               'ip',
+               'itemid',
                'itemlink',\r
-               'itemid',\r
                'itemtitle',\r
-               'date',\r
+               'memberid',
+               'plugin',
+               'short',
                'time',\r
-               'commentid',\r
-               'body',\r
-               'memberid',\r
                'timestamp',\r
-               'host',\r
-               'ip',\r
-               'blogid',\r
-               'authtext',\r
                'user',\r
+               'useremail',
                'userid',\r
+               'userlink',
                'userlinkraw',\r
-               'userlink',\r
-               'useremail',\r
                'userwebsite',\r
-               'userwebsitelink',\r
-               'excerpt',\r
-               'short',\r
-               'skinfile',\r
-               'set',\r
-               'plugin',\r
-               'include',\r
-               'phpinclude',\r
-               'parsedinclude',\r
-               'if',\r
-               'else',\r
-               'endif',\r
-               'elseif',\r
-               'ifnot',\r
-               'elseifnot'\r
+               'userwebsitelink'
        );\r
        \r
        /**\r
@@ -79,7 +80,7 @@ class CommentActions extends BaseActions
        public function __construct(&$comments)\r
        {\r
                // call constructor of superclass first\r
-               $this->BaseActions();\r
+               parent::__construct();
                \r
                // reference to the comments object\r
                $this->setCommentsObj($comments);\r
@@ -87,26 +88,14 @@ class CommentActions extends BaseActions
        }\r
        \r
        /**\r
-        * CommentActions::getDefinedActions()\r
+        * CommentActions::getAvailableActions()\r
         * \r
         * @param       void\r
         * @return array        actions array\r
         */\r
-       public function getDefinedActions()\r
+       public function getAvailableActions()\r
        {\r
-               return self::$defined_actions;\r
-       }\r
-       \r
-       /**\r
-        * CommentActions::setParser()\r
-        * \r
-        * @param       object  $parser instance of Parser class\r
-        * @return      void\r
-        */\r
-       public function setParser(&$parser)\r
-       {\r
-               $this->parser =& $parser;\r
-               return;\r
+               return array_merge(self::$defined_actions, parent::getAvailableActions());\r
        }\r
        \r
        /**\r
@@ -415,8 +404,8 @@ class CommentActions extends BaseActions
        {\r
                $data = array(\r
                        'itemid'        => $this->commentsObj->itemid,\r
-                       'timestamp'     => $this->commentsObj->itemActions->currentItem->timestamp,\r
-                       'title'         => $this->commentsObj->itemActions->currentItem->title,\r
+                       'timestamp'     => $this->commentsObj->itemActions->currentItem['timestamp'],\r
+                       'title'         => $this->commentsObj->itemActions->currentItem['title'],\r
                        'extra'         => $this->commentsObj->itemActions->linkparams\r
                );\r
                \r
@@ -485,7 +474,7 @@ class CommentActions extends BaseActions
         */\r
        public function parse_time($format = '')\r
        {\r
-               if ( $format === '' )\r
+               if ( $format !== '' )
                {\r
                        /* do nothing */\r
                        ;\r
@@ -652,7 +641,7 @@ class CommentActions extends BaseActions
         */\r
        public function parse_userlinkraw()\r
        {\r
-               echo $this->currentComment['userlinkraw'];\r
+               echo (array_key_exists('userlinkraw', $this->currentComment) && !empty($this->currentComment['userlinkraw'])) ? $this->currentComment['userlinkraw'] : '';\r
                return;\r
        }\r
        \r
@@ -696,11 +685,12 @@ class CommentActions extends BaseActions
         * CommentActions::checkCondition()\r
         * Checks conditions for if statements\r
         *\r
-        * @param string $field type of <%if%>\r
-        * @param string $name property of field\r
-        * @param string $value value of property\r
+        * @param       string  $field  type of <%if%>\r
+        * @param       string  $name   property of field\r
+        * @param       string  $value  value of property\r
+        * @return      boolean\r
         */\r
-       private function checkCondition($field, $name='', $value = '') {\r
+       protected function checkCondition($field, $name='', $value = '') {\r
                global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
                $condition = 0;\r
                switch ( $field )\r
@@ -744,21 +734,22 @@ class CommentActions extends BaseActions
         * CommentActions::ifCategory()\r
         * Different checks for a category\r
         * \r
-        * @param       void\r
-        * @return      void\r
+        * @param       string  $key    key of category\r
+        * @param       string  $value  value for key of category\r
+        * @return      boolean\r
         */\r
-       private function ifCategory($name = '', $value = '')\r
+       private function ifCategory($key = '', $value = '')\r
        {\r
                global $blog, $catid;\r
                \r
                // when no parameter is defined, just check if a category is selected\r
-               if ( ($name != 'catname' && $name != 'catid') || ($value == '') )\r
+               if ( ($key != 'catname' && $key != 'catid') || ($value == '') )\r
                {\r
                        return $blog->isValidCategory($catid);\r
                }\r
                \r
                // check category name\r
-               if ( $name == 'catname' )\r
+               if ( $key == 'catname' )\r
                {\r
                        $value = $blog->getCategoryIdFromName($value);\r
                        if ($value == $catid)\r
@@ -766,7 +757,7 @@ class CommentActions extends BaseActions
                }\r
                \r
                // check category id\r
-               if ( ($name == 'catid') && ($value == $catid) )\r
+               if ( ($key == 'catid') && ($value == $catid) )\r
                {\r
                        return $blog->isValidCategory($catid);\r
                }\r
@@ -882,8 +873,8 @@ class CommentActions extends BaseActions
         * CommentActions::ifOnTeam()\r
         * Checks if a member is on the team of a blog and return his rights\r
         * \r
-        * @param       void\r
-        * @return      void\r
+        * @param       string  $blogName       name of weblog\r
+        * @return      boolean correct or not\r
         */\r
        private function ifOnTeam($blogName = '')\r
        {\r
@@ -916,8 +907,8 @@ class CommentActions extends BaseActions
         * CommentActions::ifAdmin()\r
         * Checks if a member is admin of a blog\r
         * \r
-        * @param       void\r
-        * @return      void\r
+        * @param       string  $blogName       name of weblog\r
+        * @return      boolean correct or not\r
         */\r
        private function ifAdmin($blogName = '')\r
        {\r
@@ -956,8 +947,8 @@ class CommentActions extends BaseActions
         *         -> checks if the option OptionName from plugin PlugName is set to value\r
         *\r
         * @param       string  $name   name of plugin\r
-        * @param       string  $value  name (and value) of plugin option\r
-        * @return      boolean\r
+        * @param       string  $value  key (and value) of plugin option\r
+        * @return      boolean correct or not\r
         */\r
        private function ifHasPlugin($name, $value)\r
        {\r
@@ -996,8 +987,9 @@ class CommentActions extends BaseActions
         * Checks if a plugin exists and call its doIf function\r
         * \r
         * @param       string  $name   name of plugin\r
-        * @param       string  $key    key for confition\r
-        * @param       string  $value  value for contdition\r
+        * @param       string  $key    key of plugin option\r
+        * @param       string  $value  value of plugin option\r
+        * @return      boolean callback output from plugin\r
         */\r
        private function ifPlugin($name, $key = '', $value = '')\r
        {\r
@@ -1015,4 +1007,3 @@ class CommentActions extends BaseActions
                return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
        }\r
 }\r
-\r