OSDN Git Service

MERGE: リビジョン1818。Parserクラスのコンストラクタを変更。BaseActions派生クラスのメソッド名を変更
[nucleus-jp/nucleus-next.git] / nucleus / libs / COMMENTACTIONS.php
index b191e9d..b320145 100644 (file)
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: COMMENTACTIONS.php 1626 2012-01-09 15:46:54Z sakamocchi $
+ * @version $Id: CommentActions.php 1626 2012-01-09 15:46:54Z sakamocchi $
  */
 
-class COMMENTACTIONS extends BaseActions {
-
-       // ref to COMMENTS object which is using this object to handle
-       // its templatevars
-       var $commentsObj;
-
-       // template to use to parse the comments
-       var $template;
-
-       // comment currenlty being handled (mysql result assoc array; see COMMENTS::showComments())
-       var $currentComment;
-
-       function COMMENTACTIONS(&$comments) {
+class CommentActions extends BaseActions
+{
+       /**
+        * CommentsActions::$commentsObj
+        * ref to COMMENTS object which is using this object to handle its templatevars
+        */
+       private $commentsObj;
+       
+       /**
+        * CommentsActions::$template
+        * template to use to parse the comments
+        */
+       private $template;
+       
+       /**
+        * CommentsActions::$currentComment
+        * comment currenlty being handled (mysql result assoc array; see Comments::showComments())
+        */
+       private $currentComment;
+       
+       /**
+        * CommentsActions::$defined_actions
+        * defined actions in this class
+        */
+       static private $defined_actions = array(
+               'authtext',
+               'blogid',
+               'blogurl',
+               'body',
+               'commentcount',
+               'commentid',
+               'commentword',
+               'date',
+               'email',
+               'excerpt',
+               'host',
+               'ip',
+               'itemid',
+               'itemlink',
+               'itemtitle',
+               'memberid',
+               'plugin',
+               'short',
+               'time',
+               'timestamp',
+               'user',
+               'useremail',
+               'userid',
+               'userlink',
+               'userlinkraw',
+               'userwebsite',
+               'userwebsitelink'
+       );
+       
+       /**
+        * CommentActions::__construct()
+        * 
+        * @param       object  $comments       instance of Comments class
+        * @return      void
+        */
+       public function __construct(&$comments)
+       {
                // call constructor of superclass first
-               $this->BaseActions();
-
+               parent::__construct();
+               
                // reference to the comments object
                $this->setCommentsObj($comments);
+               return;
        }
-
-       function getDefinedActions() {
-               return array(
-                       'blogurl',
-                       'commentcount',
-                       'commentword',
-                       'email',
-                       'itemlink',
-                       'itemid',
-                       'itemtitle',
-                       'date',
-                       'time',
-                       'commentid',
-                       'body',
-                       'memberid',
-                       'timestamp',
-                       'host',
-                       'ip',
-                       'blogid',
-                       'authtext',
-                       'user',
-                       'userid',
-                       'userlinkraw',
-                       'userlink',
-                       'useremail',
-                       'userwebsite',
-                       'userwebsitelink',
-                       'excerpt',
-                       'short',
-                       'skinfile',
-                       'set',
-                       'plugin',
-                       'include',
-                       'phpinclude',
-                       'parsedinclude',
-                       'if',
-                       'else',
-                       'endif',
-                       'elseif',
-                       'ifnot',
-                       'elseifnot'
-               );
-       }
-
-       function setParser(&$parser) {
-               $this->parser =& $parser;
+       
+       /**
+        * CommentActions::getAvailableActions()
+        * 
+        * @param       void
+        * @return array        actions array
+        */
+       public function getAvailableActions()
+       {
+               return array_merge(self::$defined_actions, parent::getAvailableActions());
        }
-
-       function setCommentsObj(&$commentsObj) {
+       
+       /**
+        * 
+        * CommentActions::setCommentsObj()
+        * 
+        * @param       object  $commentsObj    instance of Comments class
+        * @return      void
+        */
+       public function setCommentsObj(&$commentsObj)
+       {
                $this->commentsObj =& $commentsObj;
+               return;
        }
-
-       function setTemplate($template) {
+       
+       /**
+        * CommentActions::setTemplate()
+        * 
+        * @param       array   $template       array includes templates
+        * @return      void
+        */
+       public function setTemplate($template)
+       {
                $this->template =& $template;
+               return;
        }
        
        /**
-        * COMMENTACTIONS::setCurrentComment()
+        * CommentActions::setCurrentComment()
         * Set $currentcommentid and $currentcommentarray
         * 
-        * @param       Array   $comment        array with comment elements
+        * @param       array   $comment        associated array includes comment information
         * @return      void
-        * 
         */
-       function setCurrentComment(&$comment)
+       public function setCurrentComment(&$comment)
        {
-               global $manager;
+               global $currentcommentid, $currentcommentarray, $manager;
                
-               if ( $comment['memberid'] != 0)
+               if ( $comment['memberid'] != 0 )
                {
-                       $comment['authtext'] = $template['COMMENTS_AUTH'];
+                       if ( !array_key_exists('COMMENTS_AUTH', $this->template) )
+                       {
+                               $comment['authtext'] = '';
+                       }
+                       else
+                       {
+                               $comment['authtext'] = $this->template['COMMENTS_AUTH'];
+                       }
+                       
                        $mem =& $manager->getMember($comment['memberid']);
                        $comment['user'] = $mem->getDisplayName();
                        
@@ -119,19 +157,18 @@ class COMMENTACTIONS extends BaseActions {
                                $comment['userid'] = $mem->getEmail();
                        }
                        
-                       $comment['userlinkraw'] = createLink(
-                                                                               'member',
-                                                                               array(
-                                                                                       'memberid' => $comment['memberid'],
-                                                                                       'name' => $mem->getDisplayName(),
-                                                                                       'extra' => $this->commentsObj->itemActions->linkparams
-                                                                               )
-                                                                       );
+                       $data = array(
+                               'memberid'      => $comment['memberid'],
+                               'name'          => $mem->getDisplayName(),
+                               'extra'         => $this->commentsObj->itemActions->linkparams
+                       );
+                       
+                       $comment['userlinkraw'] = Link::create_link('member', $data);
                }
                else
                {
                        // create smart links
-                       if ( !empty($comment['userid']) )
+                       if ( !array_key_exists('userid', $comment) || !empty($comment['userid']) )
                        {
                                if ( (i18n::strpos($comment['userid'], 'http://') === 0) || (i18n::strpos($comment['userid'], 'https://') === 0) )
                                {
@@ -142,223 +179,382 @@ class COMMENTACTIONS extends BaseActions {
                                        $comment['userlinkraw'] = 'http://' . $comment['userid'];
                                }
                        }
-                       else if ( isValidMailAddress($comment['email']) )
+                       else if ( NOTIFICATION::address_validation($comment['email']) )
                        {
                                $comment['userlinkraw'] = 'mailto:' . $comment['email'];
                        }
-                       else if ( isValidMailAddress($comment['userid']) )
+                       else if ( NOTIFICATION::address_validation($comment['userid']) )
                        {
                                $comment['userlinkraw'] = 'mailto:' . $comment['userid'];
                        }
                }
                
                $this->currentComment =& $comment;
-               global $currentcommentid, $currentcommentarray;
                $currentcommentid = $comment['commentid'];
                $currentcommentarray = $comment;
                return;
        }
-
+       
        /**
+        * CommentActions::parse_authtext()
         * Parse templatevar authtext
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_authtext() {
-               if ($this->currentComment['memberid'] != 0)
+       public function parse_authtext()
+       {
+               if ( $this->currentComment['memberid'] != 0 )
+               {
                        $this->parser->parse($this->template['COMMENTS_AUTH']);
+               }
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_blogid()
         * Parse templatevar blogid
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_blogid() {
+       public function parse_blogid() {
                echo $this->currentComment['blogid'];
        }
-
+       
        /**
+        * CommentActions::parse_blogurl()
         * Parse templatevar blogurl
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_blogurl() {
+       public function parse_blogurl()
+       {
                global $manager;
                $blogid = getBlogIDFromItemID($this->commentsObj->itemid);
                $blog =& $manager->getBlog($blogid);
                echo $blog->getURL();
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_body()
         * Parse templatevar body
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_body() {
+       public function parse_body() {
                echo $this->highlight($this->currentComment['body']);
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_commentcount()
         * Parse templatevar commentcount
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_commentcount() {
-                       echo $this->commentsObj->commentcount;
+       public function parse_commentcount()
+       {
+               echo $this->commentsObj->commentcount;
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_commentid()
         * Parse templatevar commentid
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_commentid() {
+       public function parse_commentid()
+       {
                echo $this->currentComment['commentid'];
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_commentword()
         * Parse templatevar commentword
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_commentword() {
-               if ($this->commentsObj->commentcount == 1)
+       public function parse_commentword()
+       {
+               if ( $this->commentsObj->commentcount == 1 )
+               {
                        echo $this->template['COMMENTS_ONE'];
+               }
                else
+               {
                        echo $this->template['COMMENTS_MANY'];
+               }
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_date()
         * Parse templatevar date
+        * 
+        * @format      String  $format Date format according to PHP
+        * @return      void
         */
-       function parse_date($format = '') {
-               echo formatDate($format, $this->currentComment['timestamp'], $this->template['FORMAT_DATE'], $this->commentsObj->itemActions->blog);
+       public function parse_date($format = '')
+       {
+               if ( $format !== '' )
+               {
+                       /* do nothing */
+                       ;
+               }
+               else if ( !array_key_exists('FORMAT_DATE', $this->template) || $this->template['FORMAT_DATE'] === '' )
+               {
+                       $format = '%X';
+               }
+               else
+               {
+                       $format = $this->template['FORMAT_DATE'];
+               }
+               
+               $offset = $this->commentsObj->itemActions->blog->getTimeOffset() * 3600;
+               
+               echo i18n::formatted_datetime($format, $this->currentComment['timestamp'], $offset);
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_excerpt()
         * Parse templatevar email
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_email() {
+       public function parse_email()
+       {
                $email = $this->currentComment['email'];
                $email = str_replace('@', ' (at) ', $email);
                $email = str_replace('.', ' (dot) ', $email);
                echo $email;
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_excerpt()
         * Parse templatevar excerpt
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_excerpt()
+       public function parse_excerpt()
        {
-               echo stringToXML(shorten($this->currentComment['body'], 60, '...'));
+               echo Entity::hen(Entity::shorten($this->currentComment['body'], 60, '...'));
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_host()
         * Parse templatevar host
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_host() {
+       public function parse_host()
+       {
                echo $this->currentComment['host'];
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_ip()
         * Parse templatevar ip
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_ip() {
+       public function parse_ip()
+       {
                echo $this->currentComment['ip'];
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_itemid()
         * Parse templatevar itemid
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_itemid() {
+       public function parse_itemid()
+       {
                echo $this->commentsObj->itemid;
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_itemlink()
         * Parse templatevar itemlink
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_itemlink() {
-               echo createLink(
-                       'item',
-                       array(
-                               'itemid' => $this->commentsObj->itemid,
-                               'timestamp' => $this->commentsObj->itemActions->currentItem->timestamp,
-                               'title' => $this->commentsObj->itemActions->currentItem->title,
-                               'extra' => $this->commentsObj->itemActions->linkparams
-                       )
+       public function parse_itemlink()
+       {
+               $data = array(
+                       'itemid'        => $this->commentsObj->itemid,
+                       'timestamp'     => $this->commentsObj->itemActions->currentItem['timestamp'],
+                       'title'         => $this->commentsObj->itemActions->currentItem['title'],
+                       'extra'         => $this->commentsObj->itemActions->linkparams
                );
+               
+               echo Link::create_link('item', $data);
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_itemtitle()
         * Parse templatevar itemtitle
+        * 
+        * @param       integer $maxLength      maximum length for item title
+        * @return      void
         */
-       function parse_itemtitle($maxLength = 0) {
-               if ($maxLength == 0)
+       public function parse_itemtitle($maxLength = 0)
+       {
+               if ( $maxLength == 0 )
+               {
                        $this->commentsObj->itemActions->parse_title();
+               }
                else
+               {
                        $this->commentsObj->itemActions->parse_syndicate_title($maxLength);
+               }
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_memberid()
         * Parse templatevar memberid
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_memberid() {
+       public function parse_memberid()
+       {
                echo $this->currentComment['memberid'];
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_short()
         * Parse templatevar short
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_short() {
-               $tmp = strtok($this->currentComment['body'],"\n");
-               $tmp = str_replace('<br />','',$tmp);
+       public function parse_short()
+       {
+               $tmp = strtok($this->currentComment['body'], "\n");
+               $tmp = str_replace('<br />', '', $tmp);
                echo $tmp;
-               if ($tmp != $this->currentComment['body'])
+               if ( $tmp != $this->currentComment['body'] )
+               {
                        $this->parser->parse($this->template['COMMENTS_CONTINUED']);
+               }
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_time()
         * Parse templatevar time
+        * 
+        * @param       string  $format datetime format referring to strftime() in PHP's built-in function
+        * @return      void
         */
-       function parse_time($format = '') {
-               echo i18n::strftime(
-                               ($format == '') ? $this->template['FORMAT_TIME'] : $format,
-                               $this->currentComment['timestamp']
-                       );
+       public function parse_time($format = '')
+       {
+               if ( $format !== '' )
+               {
+                       /* do nothing */
+                       ;
+               }
+               else if ( !array_key_exists('FORMAT_TIME', $this->template) || $this->template['FORMAT_TIME'] === '' )
+               {
+                       $format = '%x';
+               }
+               else
+               {
+                       $format = $this->template['FORMAT_TIME'];
+               }
+               
+               echo i18n::formatted_datetime($format, $this->currentComment['timestamp']);
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_timestamp()
         * Parse templatevar timestamp
+        * 
+        * @param       void
+        * @return      void
+        * 
         */
-       function parse_timestamp() {
+       public function parse_timestamp()
+       {
                echo $this->currentComment['timestamp'];
+               return;
        }
-
+       
        /**
-         * Executes a plugin templatevar
-         *
-         * @param pluginName name of plugin (without the NP_)
-         *
-         * extra parameters can be added
-         */
-       function parse_plugin($pluginName) {
+        * CommentActions::parse_plugin()
+        * Executes a plugin templatevar
+        *
+        * @param       string  $pluginName     name of plugin (without the NP_)
+        * @param       extra parameters can be added
+        * @return      void
+        */
+       public function parse_plugin($pluginName)
+       {
                global $manager;
-
+               
                // only continue when the plugin is really installed
-               if (!$manager->pluginInstalled('NP_' . $pluginName))
+               if ( !$manager->pluginInstalled("NP_{$pluginName}") )
+               {
                        return;
-
-               $plugin =& $manager->getPlugin('NP_' . $pluginName);
-               if (!$plugin) return;
-
+               }
+               
+               $plugin =& $manager->getPlugin("NP_{$pluginName}");
+               if ( !$plugin )
+               {
+                       return;
+               }
+               
                // get arguments
                $params = func_get_args();
-
+               
                // remove plugin name
                array_shift($params);
-
+               
                // pass info on current item and current comment as well
-               $params = array_merge(array(&$this->currentComment),$params);
-               $params = array_merge(array(&$this->commentsObj->itemActions->currentItem),$params);
-
+               $params = array_merge(array(&$this->currentComment), $params);
+               $params = array_merge(array(&$this->commentsObj->itemActions->currentItem), $params);
+               
                call_user_func_array(array(&$plugin,'doTemplateCommentsVar'), $params);
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_user()
         * Parse templatevar user
-        * @param string $mode
+        * 
+        * @param       string  $mode   realname or else
+        * @return      void
         */
-       function parse_user($mode = '')
+       public function parse_user($mode = '')
        {
                global $manager;
-
+               
                if ( $mode == 'realname' && $this->currentComment['memberid'] > 0 )
                {
                        $member =& $manager->getMember($this->currentComment['memberid']);
@@ -366,18 +562,19 @@ class COMMENTACTIONS extends BaseActions {
                }
                else
                {
-                       echo i18n::hsc($this->currentComment['user']);
+                       echo Entity::hsc($this->currentComment['user']);
                }
+               return;
        }
-
+       
        /**
-        * COMMENTACTIONS::parse_useremail()
+        * CommentActions::parse_useremail()
         * Output mail address
         * 
         * @param       void
         * @return      void
         */
-       function parse_useremail() {
+       public function parse_useremail() {
                global $manager;
                if ( $this->currentComment['memberid'] > 0 )
                {
@@ -390,11 +587,11 @@ class COMMENTACTIONS extends BaseActions {
                }
                else
                {
-                       if ( isValidMailAddress($this->currentComment['email']) )
+                       if ( NOTIFICATION::address_validation($this->currentComment['email']) )
                        {
                                echo $this->currentComment['email'];
                        }
-                       elseif ( isValidMailAddress($this->currentComment['userid']) )
+                       elseif ( NOTIFICATION::address_validation($this->currentComment['userid']) )
                        {
                                echo $this->currentComment['userid'];
                        }
@@ -403,69 +600,106 @@ class COMMENTACTIONS extends BaseActions {
        }
        
        /**
+        * CommentActions::parse_userid()
         * Parse templatevar userid
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_userid() {
-                       echo $this->currentComment['userid'];
+       public function parse_userid()
+       {
+               echo $this->currentComment['userid'];
+               return;
        }
-
-
+       
        /**
+        * CommentActions::parse_userlink()
         * Parse templatevar userlink
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_userlink() {
-               if ($this->currentComment['userlinkraw']) {
+       public function parse_userlink()
+       {
+               if ( $this->currentComment['userlinkraw'] )
+               {
                        echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';
-               } else {
+               }
+               else
+               {
                        echo $this->currentComment['user'];
                }
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_userlinkraw()
         * Parse templatevar userlinkraw
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_userlinkraw() {
+       public function parse_userlinkraw()
+       {
                echo $this->currentComment['userlinkraw'];
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_userwebsite()
         * Parse templatevar userwebsite
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_userwebsite() {
-               if (!(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false))
+       public function parse_userwebsite()
+       {
+               if ( !(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false) )
+               {
                        echo $this->currentComment['userlinkraw'];
+               }
+               return;
        }
-
+       
        /**
+        * CommentActions::parse_userwebsitelink()
         * Parse templatevar userwebsitelink
+        * 
+        * @param       void
+        * @return      void
         */
-       function parse_userwebsitelink() {
-               if (!(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false)) {
+       public function parse_userwebsitelink()
+       {
+               if ( !(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false) )
+               {
                        echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';
-               } else {
+               }
+               else
+               {
                        echo $this->currentComment['user'];
                }
+               return;
        }
-
-       // function to enable if-else-elseif-elseifnot-ifnot-endif to comment template fields
-
+       
        /**
+        * CommentActions::checkCondition()
         * Checks conditions for if statements
         *
-        * @param string $field type of <%if%>
-        * @param string $name property of field
-        * @param string $value value of property
+        * @param       string  $field  type of <%if%>
+        * @param       string  $name   property of field
+        * @param       string  $value  value of property
+        * @return      boolean
         */
-       function checkCondition($field, $name='', $value = '') {
+       protected function checkCondition($field, $name='', $value = '') {
                global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
-
                $condition = 0;
-               switch($field) {
+               switch ( $field )
+               {
                        case 'category':
-                               $condition = ($blog && $this->_ifCategory($name,$value));
+                               $condition = ($blog && $this->ifCategory($name,$value));
                                break;
                        case 'itemcategory':
-                               $condition = ($this->_ifItemCategory($name,$value));
+                               $condition = ($this->ifItemCategory($name,$value));
                                break;
                        case 'blogsetting':
                                $condition = ($blog && ($blog->getSetting($name) == $value));
@@ -478,210 +712,268 @@ class COMMENTACTIONS extends BaseActions {
                                $condition = $member->isLoggedIn();
                                break;
                        case 'onteam':
-                               $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
+                               $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
                                break;
                        case 'admin':
-                               $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
+                               $condition = $member->isLoggedIn() && $this->ifAdmin($name);
                                break;
                        case 'author':
-                               $condition = ($this->_ifAuthor($name,$value));
-                               break;
-/*                     case 'nextitem':
-                               $condition = ($itemidnext != '');
-                               break;
-                       case 'previtem':
-                               $condition = ($itemidprev != '');
-                               break;
-                       case 'archiveprevexists':
-                               $condition = ($archiveprevexists == true);
+                               $condition = ($this->ifAuthor($name,$value));
                                break;
-                       case 'archivenextexists':
-                               $condition = ($archivenextexists == true);
-                               break;
-                       case 'skintype':
-                               $condition = ($name == $this->skintype);
-                               break; */
                        case 'hasplugin':
-                               $condition = $this->_ifHasPlugin($name, $value);
+                               $condition = $this->ifHasPlugin($name, $value);
                                break;
                        default:
-                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);
-                               break;
+                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->ifPlugin($field, $name, $value);
+                       break;
                }
                return $condition;
        }
-
+       
        /**
-        *  Different checks for a category
+        * CommentActions::ifCategory()
+        * Different checks for a category
+        * 
+        * @param       string  $key    key of category
+        * @param       string  $value  value for key of category
+        * @return      boolean
         */
-       function _ifCategory($name = '', $value='') {
+       private function ifCategory($key = '', $value = '')
+       {
                global $blog, $catid;
-
+               
                // when no parameter is defined, just check if a category is selected
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))
+               if ( ($key != 'catname' && $key != 'catid') || ($value == '') )
+               {
                        return $blog->isValidCategory($catid);
-
+               }
+               
                // check category name
-               if ($name == 'catname') {
+               if ( $key == 'catname' )
+               {
                        $value = $blog->getCategoryIdFromName($value);
                        if ($value == $catid)
-                               return $blog->isValidCategory($catid);
+                       return $blog->isValidCategory($catid);
                }
-
+               
                // check category id
-               if (($name == 'catid') && ($value == $catid))
+               if ( ($key == 'catid') && ($value == $catid) )
+               {
                        return $blog->isValidCategory($catid);
-
-               return false;
+               }
+               return FALSE;
        }
-
-
+       
        /**
-        *  Different checks for an author
+        * CommentActions::ifAuthor()
+        * Different checks for an author
+        *
+        * @param       string  $key    key of data for author
+        * @param       string  $value  value of data for author
+        * @return      boolean correct or not
         */
-       function _ifAuthor($name = '', $value='') {
+       private function ifAuthor($key = '', $value = '')
+       {
                global $member, $manager;
-
-               if ($this->currentComment['memberid'] == 0) return false;
-
+               
+               if ( $this->currentComment['memberid'] == 0 )
+               {
+                       return FALSE;
+               }
+               
                $mem =& $manager->getMember($this->currentComment['memberid']);
                $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
-               $citem =& $manager->getItem($this->currentComment['itemid'],1,1);
-
+               $citem =& $manager->getItem($this->currentComment['itemid'], 1, 1);
+               
                // when no parameter is defined, just check if item author is current visitor
-               if (($name != 'isadmin' && $name != 'name' && $name != 'isauthor' && $name != 'isonteam')) {
+               if (($key != 'isadmin' && $key != 'name' && $key != 'isauthor' && $key != 'isonteam')) {
                        return (intval($member->getID()) > 0 && intval($member->getID()) == intval($citem['authorid']));
                }
-
+               
                // check comment author name
-               if ($name == 'name') {
+               if ( $key == 'name' )
+               {
                        $value = trim(strtolower($value));
-                       if ($value == '')
-                               return false;
-                       if ($value == strtolower($mem->getDisplayName()))
-                               return true;
+                       if ( $value == '' )
+                       {
+                               return FALSE;
+                       }
+                       if ( $value == strtolower($mem->getDisplayName()) )
+                       {
+                               return TRUE;
+                       }
                }
-
+               
                // check if comment author is admin
-               if ($name == 'isadmin') {
+               if ( $key == 'isadmin' )
+               {
                        $blogid = intval($b->getID());
-                       if ($mem->isAdmin())
-                               return true;
-
+                       if ( $mem->isAdmin() )
+                       {
+                               return TRUE;
+                       }
                        return $mem->isBlogAdmin($blogid);
                }
-
+               
                // check if comment author is item author
-               if ($name == 'isauthor') {
+               if ( $key == 'isauthor' )
+               {
                        return (intval($citem['authorid']) == intval($this->currentComment['memberid']));
                }
-
+               
                // check if comment author is on team
-               if ($name == 'isonteam') {
+               if ( $key == 'isonteam' )
+               {
                        return $mem->teamRights(intval($b->getID()));
                }
-
-               return false;
+               return FALSE;
        }
-
+       
        /**
-        *  Different checks for a category
+        * CommentActions::ifItemCategory()
+        * Different checks for a category
+        *
+        * @param       string  $key    key of data for category to which item belongs
+        * @param       string  $value  value of data for category to which item belongs
+        * @return boolean      correct or not
         */
-       function _ifItemCategory($name = '', $value='') {
+       private function ifItemCategory($key = '', $value = '')
+       {
                global $catid, $manager;
-
+       
                $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
                $citem =& $manager->getItem($this->currentComment['itemid'],1,1);
                $icatid = $citem['catid'];
-
+       
                // when no parameter is defined, just check if a category is selected
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))
+               if ( ($key != 'catname' && $key != 'catid') || ($value == '') )
+               {
                        return $b->isValidCategory($icatid);
-
+               }
+       
                // check category name
-               if ($name == 'catname') {
+               if ( $key == 'catname' )
+               {
                        $value = $b->getCategoryIdFromName($value);
-                       if ($value == $icatid)
+                       if ( $value == $icatid )
+                       {
                                return $b->isValidCategory($icatid);
+                       }
                }
-
+       
                // check category id
-               if (($name == 'catid') && ($value == $icatid))
+               if ( ($key == 'catid') && ($value == $icatid) )
+               {
                        return $b->isValidCategory($icatid);
-
-               return false;
+               }
+               return FALSE;
        }
-
-
+       
        /**
-        *  Checks if a member is on the team of a blog and return his rights
+        * CommentActions::ifOnTeam()
+        * Checks if a member is on the team of a blog and return his rights
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      boolean correct or not
         */
-       function _ifOnTeam($blogName = '') {
+       private function ifOnTeam($blogName = '')
+       {
                global $blog, $member, $manager;
-
+               
                $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
-
+               
                // when no blog found
-               if (($blogName == '') && (!is_object($b)))
+               if ( ($blogName == '') && (!is_object($b)) )
+               {
                        return 0;
-
+               }
+               
                // explicit blog selection
-               if ($blogName != '')
+               if ( $blogName != '' )
+               {
                        $blogid = getBlogIDFromName($blogName);
-
-               if (($blogName == '') || !$manager->existsBlogID($blogid))
-                       // use current blog
+               }
+               
+               // use current blog
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
+               {
                        $blogid = $b->getID();
-
+               }
+               
                return $member->teamRights($blogid);
        }
-
+       
        /**
-        *  Checks if a member is admin of a blog
+        * CommentActions::ifAdmin()
+        * Checks if a member is admin of a blog
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      boolean correct or not
         */
-       function _ifAdmin($blogName = '') {
+       private function ifAdmin($blogName = '')
+       {
                global $blog, $member, $manager;
-
+               
                $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
-
+               
                // when no blog found
-               if (($blogName == '') && (!is_object($b)))
+               if ( ($blogName == '') && (!is_object($b)) )
+               {
                        return 0;
-
+               }
+               
                // explicit blog selection
-               if ($blogName != '')
+               if ( $blogName != '' )
+               {
                        $blogid = getBlogIDFromName($blogName);
-
-               if (($blogName == '') || !$manager->existsBlogID($blogid))
-                       // use current blog
+               }
+               
+               // use current blog
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
+               {
                        $blogid = $b->getID();
-
+               }
+               
                return $member->isBlogAdmin($blogid);
        }
-
-
+       
        /**
+        * CommentActions::ifHasPlugin()
         *      hasplugin,PlugName
         *         -> checks if plugin exists
         *      hasplugin,PlugName,OptionName
         *         -> checks if the option OptionName from plugin PlugName is not set to 'no'
         *      hasplugin,PlugName,OptionName=value
         *         -> checks if the option OptionName from plugin PlugName is set to value
+        *
+        * @param       string  $name   name of plugin
+        * @param       string  $value  key (and value) of plugin option
+        * @return      boolean correct or not
         */
-       function _ifHasPlugin($name, $value) {
+       private function ifHasPlugin($name, $value)
+       {
                global $manager;
-               $condition = false;
+               $condition = FALSE;
+               
                // (pluginInstalled method won't write a message in the actionlog on failure)
-               if ($manager->pluginInstalled('NP_'.$name)) {
-                       $plugin =& $manager->getPlugin('NP_' . $name);
-                       if ($plugin != NULL) {
-                               if ($value == "") {
+               if ( $manager->pluginInstalled('NP_'.$name) )
+               {
+                       $plugin =& $manager->getPlugin("NP_{$name}");
+                       if ( $plugin != NULL )
+                       {
+                               if ( $value == "" )
+                               {
                                        $condition = true;
-                               } else {
-                                       list($name2, $value2) = i18n::explode('=', $value, 2);
-                                       if ($value2 == "" && $plugin->getOption($name2) != 'no') {
+                               }
+                               else
+                               {
+                                       list($name2, $value2) = preg_split('#=#', $value, 2);
+                                       if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
+                                       {
                                                $condition = true;
-                                       } else if ($plugin->getOption($name2) == $value2) {
+                                       }
+                                       else if ( $plugin->getOption($name2) == $value2 )
+                                       {
                                                $condition = true;
                                        }
                                }
@@ -689,21 +981,29 @@ class COMMENTACTIONS extends BaseActions {
                }
                return $condition;
        }
-
+       
        /**
+        * CommentActions::ifPlugin()
         * Checks if a plugin exists and call its doIf function
+        * 
+        * @param       string  $name   name of plugin
+        * @param       string  $key    key of plugin option
+        * @param       string  $value  value of plugin option
+        * @return      boolean callback output from plugin
         */
-       function _ifPlugin($name, $key = '', $value = '') {
+       private function ifPlugin($name, $key = '', $value = '')
+       {
                global $manager;
-
-               $plugin =& $manager->getPlugin('NP_' . $name);
-               if (!$plugin) return;
-
+               
+               $plugin =& $manager->getPlugin("NP_{$name}");
+               if ( !$plugin )
+               {
+                       return;
+               }
+               
                $params = func_get_args();
                array_shift($params);
-
+               
                return call_user_func_array(array(&$plugin, 'doIf'), $params);
        }
-
 }
-?>