OSDN Git Service

Merge branch 'master' into skinnable-master
authorsakamocchi <o-takashi@sakamocchi.jp>
Tue, 10 Apr 2012 12:40:33 +0000 (21:40 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Tue, 10 Apr 2012 12:40:33 +0000 (21:40 +0900)
nucleus/libs/BODYACTIONS.php

index f7d36ae..9baf242 100644 (file)
@@ -2,7 +2,7 @@
 \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
  * A class to parses plugin calls inside items\r
  *\r
  * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
- * @version $Id: BODYACTIONS.php 1626 2012-01-09 15:46:54Z sakamocchi $\r
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
+ * @version $Id: BODYACTIONS.php 1736 2012-04-10 12:33:36Z sakamocchi $\r
  */\r
 \r
 class BodyActions extends BaseActions\r
 {\r
-\r
-       var $currentItem;\r
-\r
-       var $template;\r
-\r
+       private $currentItem;\r
+       private $template;\r
+       \r
+       static private $defined_actions = array(\r
+               'image',\r
+               'media',\r
+               'popup',\r
+               'plugin',\r
+               'if',\r
+               'else',\r
+               'endif',\r
+               'elseif',\r
+               'ifnot',\r
+               'elseifnot'\r
+       );\r
+       \r
        /**\r
+        * BodyActions::__construct()\r
         * Constructor of the BODYACTIONS\r
+        * \r
+        * @param       void\r
+        * @return      void\r
         */\r
-       function __construct() {\r
+       public function __construct()\r
+       {\r
                $this->BaseActions();   \r
+               return;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::setCurrentItem()\r
         * Set the current item\r
         * \r
-        * @param &$item\r
-        *                      reference to the current item\r
+        * @param       object  &$item  reference to the current item\r
+        * @return      void\r
         */\r
-       function setCurrentItem(&$item) {\r
-               $this->currentItem =& $item;\r
+       public function setCurrentItem(&$item)\r
+       {\r
                global $currentitemid;\r
+               $this->currentItem =& $item;\r
                $currentitemid = $this->currentItem->itemid;\r
+               return;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::setTemplate()\r
         * Set the current template\r
         * \r
-        * @param $template\r
-        *                      Template to be used\r
+        * @param       string  $template       Template to be used\r
+        * @return      void\r
         */\r
-       function setTemplate($template) {\r
+       public function setTemplate($template)\r
+       {\r
                $this->template =& $template;\r
+               return;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::getDefinedActions()\r
         * Get the defined actions in an item\r
+        * \r
+        * @param       void\r
+        * @return      Array   self::$defined_actions\r
         */\r
-       function getDefinedActions() {\r
-               return array('image', 'media', 'popup', 'plugin', 'if', 'else', 'endif', 'elseif', 'ifnot', 'elseifnot');\r
+       public function getDefinedActions()\r
+       {\r
+               return self::$defined_actions;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::parse_plugin()\r
         * Parse a plugin var\r
         * Called if <%plugin(...)%> in an item appears\r
         * \r
         * Calls the doItemVar function in the plugin\r
         */\r
-       function parse_plugin($pluginName) {\r
+       public function parse_plugin($pluginName)\r
+       {\r
                global $manager;\r
-\r
-               // should be already tested from the parser (PARSER.php)\r
-               // only continue when the plugin is really installed\r
-               /*if (!$manager->pluginInstalled('NP_' . $pluginName)) {\r
-                       return;\r
-               }*/\r
-\r
+               \r
                $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
-               if (!$plugin) return;\r
-\r
+               if ( !$plugin )\r
+               {\r
+                       return; \r
+               }\r
+               \r
                // get arguments\r
                $params = func_get_args();\r
-\r
+               \r
                // remove plugin name\r
                array_shift($params);\r
-\r
+               \r
                // add item reference (array_unshift didn't work)\r
                $params = array_merge(array(&$this->currentItem),$params);\r
-\r
+               \r
                call_user_func_array(array(&$plugin,'doItemVar'), $params);\r
+               return;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::parse_image()\r
         * Parse image\r
         * Called if <%image(...)%> in an item appears\r
+        * \r
+        * @param       void\r
+        * @return      parsed image tag\r
         */\r
-       function parse_image() {\r
+       public function parse_image()\r
+       {\r
                // image/popup calls have arguments separated by |\r
                $args = func_get_args();\r
                $args = i18n::explode('|',implode($args,', '));\r
-               call_user_func_array(array(&$this,'createImageCode'),$args);\r
+               echo call_user_func_array(array(&$this,'createImageCode'),$args);\r
        }\r
        \r
        /**\r
+        * BaseActions::createImageCode()\r
         * Creates the code for an image\r
+        * \r
+        * @param       string  $filename       name of file from tag\r
+        * @param       integer $width          width of file from tag\r
+        * @param       integer $height         height of file from tag\r
+        * @return      string  image element with anchor element\r
         */\r
-       function createImageCode($filename, $width, $height, $text = '') {\r
+       public function createImageCode($filename, $width, $height, $text = '')\r
+       {\r
                global $CONF;\r
-\r
+               \r
                // select private collection when no collection given\r
-               if (!strstr($filename,'/')) {\r
+               if ( !strstr($filename,'/') )\r
+               {\r
                        $filename = $this->currentItem->authorid . '/' . $filename;\r
                }\r
-\r
+               \r
                $windowwidth = $width;\r
                $windowheight = $height;\r
-\r
+               \r
                $vars['link']                   = Entity::hsc($CONF['MediaURL']. $filename);\r
                $vars['text']                   = Entity::hsc($text);\r
                $vars['image'] = '<img src="' . $vars['link'] . '" width="' . $width . '" height="' . $height . '" alt="' . $vars['text'] . '" title="' . $vars['text'] . '" />';\r
                $vars['width']                  = $width;\r
                $vars['height']                 = $height;\r
                $vars['media']                  = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>';\r
-\r
-\r
-               echo Template::fill($this->template['IMAGE_CODE'],$vars);;\r
-\r
+               \r
+               return Template::fill($this->template['IMAGE_CODE'],$vars);;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::parse_media()\r
         * Parse media\r
         * Called if <%media(...)%> in an item appears\r
+        * \r
+        * @param       void\r
+        * @param       parsed media tag\r
         */\r
-       function parse_media() {\r
+       public function parse_media()\r
+       {\r
                // image/popup calls have arguments separated by |\r
                $args = func_get_args();\r
-               $args = i18n::explode('|',implode($args,', '));\r
-               call_user_func_array(array(&$this,'createMediaCode'),$args);\r
+               $args = preg_split('#\|#', implode($args,', '));\r
+               echo call_user_func_array(array(&$this,'createMediaCode'), $args);\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::createMediaCode()\r
         * Creates the code for a media\r
+        * \r
+        * @param       string  $filename       name of file from tag\r
+        * @param       string  $text           alternative text from tag\r
+        * @return      string  text element with anchor element\r
         */\r
-       function createMediaCode($filename, $text = '') {\r
+       public function createMediaCode($filename, $text = '')\r
+       {\r
                global $CONF;\r
-\r
+               \r
                // select private collection when no collection given\r
-               if (!strstr($filename,'/')) {\r
+               if ( !strstr($filename,'/') )\r
+               {\r
                        $filename = $this->currentItem->authorid . '/' . $filename;\r
                }\r
-\r
+               \r
                $vars['link']                   = Entity::hsc($CONF['MediaURL'] . $filename);\r
                $vars['text']                   = Entity::hsc($text);\r
-               $vars['media']                  = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>';\r
-\r
-               echo Template::fill($this->template['MEDIA_CODE'],$vars);;\r
+               $vars['media']                  = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>';\r
+               \r
+               return Template::fill($this->template['MEDIA_CODE'], $vars);;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::parse_popup()\r
         * Parse popup\r
         * Called if <%popup(...)%> in an item appears\r
+        * \r
+        * @param       void\r
+        * @return      string  parsed popup tag\r
         */\r
-       function parse_popup() {\r
+       public function parse_popup()\r
+       {\r
                // image/popup calls have arguments separated by |\r
                $args = func_get_args();\r
-               $args = i18n::explode('|',implode($args,', '));\r
-               call_user_func_array(array(&$this,'createPopupCode'),$args);\r
+               $args = preg_split('#\|#', implode($args,', '));\r
+               echo call_user_func_array(array(&$this,'createPopupCode'), $args);\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::createPopupCode()\r
         * Creates the code for a popup\r
+        * \r
+        * @param       string  $filename       name of file from tag\r
+        * @param       integer $width          width of file from tag\r
+        * @param       integer $height         height of file from tag\r
+        * @param       string  $text           alternative text from tag\r
+        * @return      string  text element with anchor element of JavaScript window.open\r
         */\r
-       function createPopupCode($filename, $width, $height, $text = '') {\r
+       public function createPopupCode($filename, $width, $height, $text = '')\r
+       {\r
                global $CONF;\r
-\r
+               \r
                // select private collection when no collection given\r
-               if (!strstr($filename,'/')) {\r
+               if ( !strstr($filename,'/') )\r
+               {\r
                        $filename = $this->currentItem->authorid . '/' . $filename;\r
                }\r
-\r
+               \r
                $windowwidth = $width;\r
                $windowheight = $height;\r
-\r
+               \r
                $vars['rawpopuplink']   = $CONF['Self'] . "?imagepopup=" . Entity::hsc($filename) . "&amp;width=$width&amp;height=$height&amp;imagetext=" . urlencode(Entity::hsc($text));\r
                $vars['popupcode']              = "window.open(this.href,'imagepopup','status=no,toolbar=no,scrollbars=no,resizable=yes,width=$windowwidth,height=$windowheight');return false;";\r
                $vars['popuptext']              = Entity::hsc($text);\r
@@ -191,29 +256,31 @@ class BodyActions extends BaseActions
                $vars['text']                   = $text;\r
                $vars['link']                   = Entity::hsc($CONF['MediaURL'] . $filename);\r
                $vars['media']                  = '<a href="' . $vars['link'] . '">' . $vars['popuptext'] . '</a>';\r
-\r
-               echo Template::fill($this->template['POPUP_CODE'],$vars);\r
+               \r
+               return Template::fill($this->template['POPUP_CODE'], $vars);\r
        }\r
        \r
-       // function to enable if-else-elseif-elseifnot-ifnot-endif to item template fields\r
-       \r
        /**\r
+        * BodyActions::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      condition\r
         */\r
-       function checkCondition($field, $name='', $value = '') {\r
+       public function checkCondition($field, $name='', $value = '')\r
+       {\r
                global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
-\r
+               \r
                $condition = 0;\r
-               switch($field) {\r
+               switch ( $field )\r
+               {\r
                        case 'category':\r
-                               $condition = ($blog && $this->_ifCategory($name,$value));\r
+                               $condition = ($blog && $this->ifCategory($name,$value));\r
                                break;\r
                        case 'itemcategory':\r
-                               $condition = ($this->_ifItemCategory($name,$value));\r
+                               $condition = ($this->ifItemCategory($name,$value));\r
                                break;\r
                        case 'blogsetting':\r
                                $condition = ($blog && ($blog->getSetting($name) == $value));\r
@@ -226,215 +293,277 @@ class BodyActions extends BaseActions
                                $condition = $member->isLoggedIn();\r
                                break;\r
                        case 'onteam':\r
-                               $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);\r
+                               $condition = $member->isLoggedIn() && $this->ifOnTeam($name);\r
                                break;\r
                        case 'admin':\r
-                               $condition = $member->isLoggedIn() && $this->_ifAdmin($name);\r
+                               $condition = $member->isLoggedIn() && $this->ifAdmin($name);\r
                                break;\r
                        case 'author':\r
-                               $condition = ($this->_ifAuthor($name,$value));\r
-                               break;\r
-/*                     case 'nextitem':\r
-                               $condition = ($itemidnext != '');\r
-                               break;\r
-                       case 'previtem':\r
-                               $condition = ($itemidprev != '');\r
+                               $condition = ($this->ifAuthor($name,$value));\r
                                break;\r
-                       case 'archiveprevexists':\r
-                               $condition = ($archiveprevexists == true);\r
-                               break;\r
-                       case 'archivenextexists':\r
-                               $condition = ($archivenextexists == true);\r
-                               break; \r
-                       case 'skintype':\r
-                               $condition = ($name == $this->skintype);\r
-                               break; */\r
                        case 'hasplugin':\r
-                               $condition = $this->_ifHasPlugin($name, $value);\r
+                               $condition = $this->ifHasPlugin($name, $value);\r
                                break;\r
                        default:\r
-                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);\r
+                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->ifPlugin($field, $name, $value);\r
                                break;\r
                }\r
                return $condition;\r
        }       \r
        \r
        /**\r
+        * BodyActions::ifCategory()\r
         *  Different checks for a category\r
+        *  \r
+        * @param       string  $key    key for data of category\r
+        * @param       string  $value  value for data of category\r
+        * @return      boolean\r
         */\r
-       function _ifCategory($name = '', $value='') {\r
+       private function ifCategory($key = '', $value = '')\r
+       {\r
                global $blog, $catid;\r
-\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
+               \r
                // check category name\r
-               if ($name == 'catname') {\r
+               if ( $key == 'catname' )\r
+               {\r
                        $value = $blog->getCategoryIdFromName($value);\r
-                       if ($value == $catid)\r
+                       if ( $value == $catid )\r
+                       {\r
                                return $blog->isValidCategory($catid);\r
+                       }\r
                }\r
-\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
-               return false;\r
+               }\r
+               \r
+               return FALSE;\r
        }\r
        \r
-               \r
        /**\r
-        *  Different checks for an author\r
+        * BodyActions::ifAuthor()\r
+        * Different checks for an author\r
+        * \r
+        * @param       string  $key    key for data of author\r
+        * @param       string  $value  value for data of author\r
+        * @return      boolean\r
         */\r
-       function _ifAuthor($name = '', $value='') {\r
+       private function ifAuthor($key = '', $value = '')\r
+       {\r
                global $member, $manager;\r
                \r
                $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));\r
-\r
+               \r
                // when no parameter is defined, just check if author is current visitor\r
-               if (($name != 'isadmin' && $name != 'name') || ($name == 'name' && $value == '')) {\r
+               if ( ($key != 'isadmin' && $key != 'name') || ($key == 'name' && $value == '') )\r
+               {\r
                        return (intval($member->getID()) > 0 && intval($member->getID()) == intval($this->currentItem->authorid));\r
                }\r
-\r
+               \r
                // check author name\r
-               if ($name == 'name') {\r
+               if ( $key == 'name' )\r
+               {\r
                        $value = strtolower($value);\r
-                       if ($value == strtolower($this->currentItem->author))\r
-                               return true;\r
+                       if ( $value == strtolower($this->currentItem->author) )\r
+                       {\r
+                               return TRUE;\r
+                       }\r
                }\r
-\r
+               \r
                // check if author is admin\r
-               if (($name == 'isadmin')) {                     \r
+               if ( ($key == 'isadmin') )\r
+               {\r
                        $aid = intval($this->currentItem->authorid);\r
                        $blogid = intval($b->getID());                  \r
                        $amember =& $manager->getMember($aid);\r
-                       if ($amember->isAdmin())\r
-                               return true;\r
-                               \r
+                       if ( $amember->isAdmin() )\r
+                       {\r
+                               return TRUE;\r
+                       }       \r
                        return $amember->isBlogAdmin($blogid);\r
                }\r
-\r
-               return false;\r
+               \r
+               return FALSE;\r
        }\r
        \r
        /**\r
-        *  Different checks for a category\r
+        * BodyActions::ifItemCategory()\r
+        * Different checks for a category\r
+        * \r
+        * @param       string  $key    key for data of category\r
+        * @param       string  $value  value for data of category\r
+        * @return      boolean \r
         */\r
-       function _ifItemCategory($name = '', $value='') {\r
+       private function ifItemCategory($key = '', $value = '')\r
+       {\r
                global $catid, $manager;\r
                \r
                $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));\r
-\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 $b->isValidCategory($catid);\r
+               }\r
                        \r
                $icatid = $this->currentItem->catid;\r
-               //$icategory = $this->currentItem->category;\r
-\r
+               \r
                // check category name\r
-               if ($name == 'catname') {\r
+               if ( $key == 'catname' )\r
+               {\r
                        $value = $b->getCategoryIdFromName($value);\r
-                       if ($value == $icatid)\r
+                       if ( $value == $icatid )\r
+                       {\r
                                return $b->isValidCategory($icatid);\r
+                       }\r
                }\r
-\r
+               \r
                // check category id\r
-               if (($name == 'catid') && ($value == $icatid))\r
+               if ( ($key == 'catid') && ($value == $icatid) )\r
+               {\r
                        return $b->isValidCategory($icatid);\r
-\r
-               return false;\r
+               }\r
+               return FALSE;\r
        }\r
-\r
        \r
        /**\r
-        *  Checks if a member is on the team of a blog and return his rights\r
+        * BodyActions::ifOnTeam()\r
+        * Checks if a member is on the team of a blog and return his rights\r
+        * \r
+        * @param       string  $blogName       name of weblog\r
+        * @return      boolean\r
         */\r
-       function _ifOnTeam($blogName = '') {\r
+       private function ifOnTeam($blogName = '')\r
+       {\r
                global $blog, $member, $manager;\r
-\r
+               \r
                // when no blog found\r
-               if (($blogName == '') && (!is_object($blog)))\r
+               if ( ($blogName == '') && (!is_object($blog)) )\r
+               {\r
                        return 0;\r
-\r
+               }\r
+               \r
                // explicit blog selection\r
-               if ($blogName != '')\r
+               if ( $blogName != '' )\r
+               {\r
                        $blogid = getBlogIDFromName($blogName);\r
-\r
-               if (($blogName == '') || !$manager->existsBlogID($blogid))\r
+               }\r
+               \r
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
+               {\r
                        // use current blog\r
                        $blogid = $blog->getID();\r
-\r
+               }\r
                return $member->teamRights($blogid);\r
        }\r
-\r
+       \r
        /**\r
-        *  Checks if a member is admin of a blog\r
+        * BodyActions::ifAdmin()\r
+        * Checks if a member is admin of a blog\r
+        * \r
+        * @param       string  $blogName       name of weblog\r
+        * @return      boolean\r
         */\r
-       function _ifAdmin($blogName = '') {\r
+       private function ifAdmin($blogName = '')\r
+       {\r
                global $blog, $member, $manager;\r
-\r
+               \r
                // when no blog found\r
-               if (($blogName == '') && (!is_object($blog)))\r
+               if ( ($blogName == '') && (!is_object($blog)) )\r
+               {\r
                        return 0;\r
-\r
+               }\r
+               \r
                // explicit blog selection\r
-               if ($blogName != '')\r
+               if ( $blogName != '' )\r
+               {\r
                        $blogid = getBlogIDFromName($blogName);\r
-\r
-               if (($blogName == '') || !$manager->existsBlogID($blogid))\r
+               }\r
+               \r
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
+               {\r
                        // use current blog\r
                        $blogid = $blog->getID();\r
-\r
+               }\r
                return $member->isBlogAdmin($blogid);\r
        }\r
-\r
+       \r
        \r
        /**\r
+        * BodyActions::ifHasPlugin()\r
         *      hasplugin,PlugName\r
         *         -> checks if plugin exists\r
         *      hasplugin,PlugName,OptionName\r
         *         -> checks if the option OptionName from plugin PlugName is not set to 'no'\r
         *      hasplugin,PlugName,OptionName=value\r
         *         -> checks if the option OptionName from plugin PlugName is set to value\r
+        *\r
+        * @param       string  $name   name of plugin\r
+        * @param       string  $value  value for plugin argument\r
+        * @return      boolean\r
         */\r
-       function _ifHasPlugin($name, $value) {\r
+       private function ifHasPlugin($name, $value)\r
+       {\r
                global $manager;\r
                $condition = false;\r
+               \r
                // (pluginInstalled method won't write a message in the actionlog on failure)\r
-               if ($manager->pluginInstalled('NP_'.$name)) {\r
-                       $plugin =& $manager->getPlugin('NP_' . $name);\r
-                       if ($plugin != NULL) {\r
-                               if ($value == "") {\r
-                                       $condition = true;\r
-                               } else {\r
-                                       list($name2, $value2) = i18n::explode('=', $value, 2);\r
-                                       if ($value2 == "" && $plugin->getOption($name2) != 'no') {\r
-                                               $condition = true;\r
-                                       } else if ($plugin->getOption($name2) == $value2) {\r
-                                               $condition = true;\r
+               if ( $manager->pluginInstalled("NP_{$name}") )\r
+               {\r
+                       $plugin =& $manager->getPlugin("NP_{$name}");\r
+                       if ( $plugin != NULL )\r
+                       {\r
+                               if ( $value == "" )\r
+                               {\r
+                                       $condition = TRUE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       list($name2, $value2) = preg_split('#=#', $value, 2);\r
+                                       if ( $value2 == "" && $plugin->getOption($name2) != 'no' )\r
+                                       {\r
+                                               $condition = TRUE;\r
+                                       }\r
+                                       else if ( $plugin->getOption($name2) == $value2 )\r
+                                       {\r
+                                               $condition = TRUE;\r
                                        }\r
                                }\r
                        }\r
                }\r
                return $condition;\r
        }\r
-\r
+       \r
        /**\r
+        * BodyActions::ifPlugin()\r
         * Checks if a plugin exists and call its doIf function\r
+        * \r
+        * @param       string  $name   name of plugin\r
+        * @param       string  $key    ...\r
+        * @param       string  $value  ...\r
+        * @return      string  result of plugin 'doIf'\r
         */\r
-       function _ifPlugin($name, $key = '', $value = '') {\r
+       private function ifPlugin($name, $key = '', $value = '')\r
+       {\r
                global $manager;\r
-\r
-               $plugin =& $manager->getPlugin('NP_' . $name);\r
-               if (!$plugin) return;\r
-\r
+               \r
+               $plugin =& $manager->getPlugin("NP_{$name}");\r
+               if ( !$plugin )\r
+               {\r
+                       return;\r
+               }\r
+               \r
                $params = func_get_args();\r
                array_shift($params);\r
-\r
+               \r
                return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
        }\r
-\r
 }\r
-?>\r