OSDN Git Service

主だったスクリプトの改行コードを統一
[nucleus-jp/nucleus-next.git] / nucleus / libs / BODYACTIONS.php
index 22e5910..af00d41 100644 (file)
-<?php
-
-/*
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2009 The Nucleus Group
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * (see nucleus/documentation/index.html#license for more info)
- */
-/**
- * A class to parses plugin calls inside items
- *
- * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: BODYACTIONS.php 1626 2012-01-09 15:46:54Z sakamocchi $
- */
-
-class BODYACTIONS extends BaseActions {
-
-       var $currentItem;
-
-       var $template;
-
-       /**
-        * Constructor of the BODYACTIONS
-        */
-       function BODYACTIONS () {
-               $this->BaseActions();   
-       }
-
-       /**
-        * Set the current item
-        * 
-        * @param &$item
-        *                      reference to the current item
-        */
-       function setCurrentItem(&$item) {
-               $this->currentItem =& $item;
-               global $currentitemid;
-               $currentitemid = $this->currentItem->itemid;
-       }
-
-       /**
-        * Set the current template
-        * 
-        * @param $template
-        *                      Template to be used
-        */
-       function setTemplate($template) {
-               $this->template =& $template;
-       }
-
-       /**
-        * Get the defined actions in an item
-        */
-       function getDefinedActions() {
-               return array('image', 'media', 'popup', 'plugin', 'if', 'else', 'endif', 'elseif', 'ifnot', 'elseifnot');
-       }
-
-       /**
-        * Parse a plugin var
-        * Called if <%plugin(...)%> in an item appears
-        * 
-        * Calls the doItemVar function in the plugin
-        */
-       function parse_plugin($pluginName) {
-               global $manager;
-
-               // should be already tested from the parser (PARSER.php)
-               // only continue when the plugin is really installed
-               /*if (!$manager->pluginInstalled('NP_' . $pluginName)) {
-                       return;
-               }*/
-
-               $plugin =& $manager->getPlugin('NP_' . $pluginName);
-               if (!$plugin) return;
-
-               // get arguments
-               $params = func_get_args();
-
-               // remove plugin name
-               array_shift($params);
-
-               // add item reference (array_unshift didn't work)
-               $params = array_merge(array(&$this->currentItem),$params);
-
-               call_user_func_array(array(&$plugin,'doItemVar'), $params);
-       }
-
-       /**
-        * Parse image
-        * Called if <%image(...)%> in an item appears
-        */
-       function parse_image() {
-               // image/popup calls have arguments separated by |
-               $args = func_get_args();
-               $args = i18n::explode('|',implode($args,', '));
-               call_user_func_array(array(&$this,'createImageCode'),$args);
-       }
-       
-       /**
-        * Creates the code for an image
-        */
-       function createImageCode($filename, $width, $height, $text = '') {
-               global $CONF;
-
-               // select private collection when no collection given
-               if (!strstr($filename,'/')) {
-                       $filename = $this->currentItem->authorid . '/' . $filename;
-               }
-
-               $windowwidth = $width;
-               $windowheight = $height;
-
-               $vars['link']                   = ENTITY::hsc($CONF['MediaURL']. $filename);
-               $vars['text']                   = ENTITY::hsc($text);
-               $vars['image'] = '<img src="' . $vars['link'] . '" width="' . $width . '" height="' . $height . '" alt="' . $vars['text'] . '" title="' . $vars['text'] . '" />';
-               $vars['width']                  = $width;
-               $vars['height']                 = $height;
-               $vars['media']                  = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>';
-
-
-               echo TEMPLATE::fill($this->template['IMAGE_CODE'],$vars);;
-
-       }
-
-       /**
-        * Parse media
-        * Called if <%media(...)%> in an item appears
-        */
-       function parse_media() {
-               // image/popup calls have arguments separated by |
-               $args = func_get_args();
-               $args = i18n::explode('|',implode($args,', '));
-               call_user_func_array(array(&$this,'createMediaCode'),$args);
-       }
-
-       /**
-        * Creates the code for a media
-        */
-       function createMediaCode($filename, $text = '') {
-               global $CONF;
-
-               // select private collection when no collection given
-               if (!strstr($filename,'/')) {
-                       $filename = $this->currentItem->authorid . '/' . $filename;
-               }
-
-               $vars['link']                   = ENTITY::hsc($CONF['MediaURL'] . $filename);
-               $vars['text']                   = ENTITY::hsc($text);
-               $vars['media']                  = '<a href="' . $vars['link'] . '">' . $vars['text'] . '</a>';
-
-               echo TEMPLATE::fill($this->template['MEDIA_CODE'],$vars);;
-       }
-
-       /**
-        * Parse popup
-        * Called if <%popup(...)%> in an item appears
-        */
-       function parse_popup() {
-               // image/popup calls have arguments separated by |
-               $args = func_get_args();
-               $args = i18n::explode('|',implode($args,', '));
-               call_user_func_array(array(&$this,'createPopupCode'),$args);
-       }
-
-       /**
-        * Creates the code for a popup
-        */
-       function createPopupCode($filename, $width, $height, $text = '') {
-               global $CONF;
-
-               // select private collection when no collection given
-               if (!strstr($filename,'/')) {
-                       $filename = $this->currentItem->authorid . '/' . $filename;
-               }
-
-               $windowwidth = $width;
-               $windowheight = $height;
-
-               $vars['rawpopuplink']   = $CONF['Self'] . "?imagepopup=" . ENTITY::hsc($filename) . "&amp;width=$width&amp;height=$height&amp;imagetext=" . urlencode(ENTITY::hsc($text));
-               $vars['popupcode']              = "window.open(this.href,'imagepopup','status=no,toolbar=no,scrollbars=no,resizable=yes,width=$windowwidth,height=$windowheight');return false;";
-               $vars['popuptext']              = ENTITY::hsc($text);
-               $vars['popuplink']              = '<a href="' . $vars['rawpopuplink']. '" onclick="'. $vars['popupcode'].'" >' . $vars['popuptext'] . '</a>';
-               $vars['width']                  = $width;
-               $vars['height']                 = $height;
-               $vars['text']                   = $text;
-               $vars['link']                   = ENTITY::hsc($CONF['MediaURL'] . $filename);
-               $vars['media']                  = '<a href="' . $vars['link'] . '">' . $vars['popuptext'] . '</a>';
-
-               echo TEMPLATE::fill($this->template['POPUP_CODE'],$vars);
-       }
-       
-       // function to enable if-else-elseif-elseifnot-ifnot-endif to item template fields
-       
-       /**
-        * Checks conditions for if statements
-        *
-        * @param string $field type of <%if%>
-        * @param string $name property of field
-        * @param string $value value of property
-        */
-       function checkCondition($field, $name='', $value = '') {
-               global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
-
-               $condition = 0;
-               switch($field) {
-                       case 'category':
-                               $condition = ($blog && $this->_ifCategory($name,$value));
-                               break;
-                       case 'itemcategory':
-                               $condition = ($this->_ifItemCategory($name,$value));
-                               break;
-                       case 'blogsetting':
-                               $condition = ($blog && ($blog->getSetting($name) == $value));
-                               break;
-                       case 'itemblogsetting':
-                               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));
-                               $condition = ($b && ($b->getSetting($name) == $value));
-                               break;
-                       case 'loggedin':
-                               $condition = $member->isLoggedIn();
-                               break;
-                       case 'onteam':
-                               $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
-                               break;
-                       case 'admin':
-                               $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);
-                               break;
-                       case 'archivenextexists':
-                               $condition = ($archivenextexists == true);
-                               break; 
-                       case 'skintype':
-                               $condition = ($name == $this->skintype);
-                               break; */
-                       case 'hasplugin':
-                               $condition = $this->_ifHasPlugin($name, $value);
-                               break;
-                       default:
-                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);
-                               break;
-               }
-               return $condition;
-       }       
-       
-       /**
-        *  Different checks for a category
-        */
-       function _ifCategory($name = '', $value='') {
-               global $blog, $catid;
-
-               // when no parameter is defined, just check if a category is selected
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))
-                       return $blog->isValidCategory($catid);
-
-               // check category name
-               if ($name == 'catname') {
-                       $value = $blog->getCategoryIdFromName($value);
-                       if ($value == $catid)
-                               return $blog->isValidCategory($catid);
-               }
-
-               // check category id
-               if (($name == 'catid') && ($value == $catid))
-                       return $blog->isValidCategory($catid);
-
-               return false;
-       }
-       
-               
-       /**
-        *  Different checks for an author
-        */
-       function _ifAuthor($name = '', $value='') {
-               global $member, $manager;
-               
-               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));
-
-               // when no parameter is defined, just check if author is current visitor
-               if (($name != 'isadmin' && $name != 'name') || ($name == 'name' && $value == '')) {
-                       return (intval($member->getID()) > 0 && intval($member->getID()) == intval($this->currentItem->authorid));
-               }
-
-               // check author name
-               if ($name == 'name') {
-                       $value = strtolower($value);
-                       if ($value == strtolower($this->currentItem->author))
-                               return true;
-               }
-
-               // check if author is admin
-               if (($name == 'isadmin')) {                     
-                       $aid = intval($this->currentItem->authorid);
-                       $blogid = intval($b->getID());                  
-                       $amember =& $manager->getMember($aid);
-                       if ($amember->isAdmin())
-                               return true;
-                               
-                       return $amember->isBlogAdmin($blogid);
-               }
-
-               return false;
-       }
-       
-       /**
-        *  Different checks for a category
-        */
-       function _ifItemCategory($name = '', $value='') {
-               global $catid, $manager;
-               
-               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));
-
-               // when no parameter is defined, just check if a category is selected
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))
-                       return $b->isValidCategory($catid);
-                       
-               $icatid = $this->currentItem->catid;
-               //$icategory = $this->currentItem->category;
-
-               // check category name
-               if ($name == 'catname') {
-                       $value = $b->getCategoryIdFromName($value);
-                       if ($value == $icatid)
-                               return $b->isValidCategory($icatid);
-               }
-
-               // check category id
-               if (($name == 'catid') && ($value == $icatid))
-                       return $b->isValidCategory($icatid);
-
-               return false;
-       }
-
-       
-       /**
-        *  Checks if a member is on the team of a blog and return his rights
-        */
-       function _ifOnTeam($blogName = '') {
-               global $blog, $member, $manager;
-
-               // when no blog found
-               if (($blogName == '') && (!is_object($blog)))
-                       return 0;
-
-               // explicit blog selection
-               if ($blogName != '')
-                       $blogid = getBlogIDFromName($blogName);
-
-               if (($blogName == '') || !$manager->existsBlogID($blogid))
-                       // use current blog
-                       $blogid = $blog->getID();
-
-               return $member->teamRights($blogid);
-       }
-
-       /**
-        *  Checks if a member is admin of a blog
-        */
-       function _ifAdmin($blogName = '') {
-               global $blog, $member, $manager;
-
-               // when no blog found
-               if (($blogName == '') && (!is_object($blog)))
-                       return 0;
-
-               // explicit blog selection
-               if ($blogName != '')
-                       $blogid = getBlogIDFromName($blogName);
-
-               if (($blogName == '') || !$manager->existsBlogID($blogid))
-                       // use current blog
-                       $blogid = $blog->getID();
-
-               return $member->isBlogAdmin($blogid);
-       }
-
-       
-       /**
-        *      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
-        */
-       function _ifHasPlugin($name, $value) {
-               global $manager;
-               $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 == "") {
-                                       $condition = true;
-                               } else {
-                                       list($name2, $value2) = i18n::explode('=', $value, 2);
-                                       if ($value2 == "" && $plugin->getOption($name2) != 'no') {
-                                               $condition = true;
-                                       } else if ($plugin->getOption($name2) == $value2) {
-                                               $condition = true;
-                                       }
-                               }
-                       }
-               }
-               return $condition;
-       }
-
-       /**
-        * Checks if a plugin exists and call its doIf function
-        */
-       function _ifPlugin($name, $key = '', $value = '') {
-               global $manager;
-
-               $plugin =& $manager->getPlugin('NP_' . $name);
-               if (!$plugin) return;
-
-               $params = func_get_args();
-               array_shift($params);
-
-               return call_user_func_array(array(&$plugin, 'doIf'), $params);
-       }
-
-}
-?>
+<?php\r
+\r
+/*\r
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\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
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * (see nucleus/documentation/index.html#license for more info)\r
+ */\r
+/**\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-2009 The Nucleus Group\r
+ * @version $Id: BODYACTIONS.php 1626 2012-01-09 15:46:54Z sakamocchi $\r
+ */\r
+\r
+class BODYACTIONS extends BaseActions {\r
+\r
+       var $currentItem;\r
+\r
+       var $template;\r
+\r
+       /**\r
+        * Constructor of the BODYACTIONS\r
+        */\r
+       function BODYACTIONS () {\r
+               $this->BaseActions();   \r
+       }\r
+\r
+       /**\r
+        * Set the current item\r
+        * \r
+        * @param &$item\r
+        *                      reference to the current item\r
+        */\r
+       function setCurrentItem(&$item) {\r
+               $this->currentItem =& $item;\r
+               global $currentitemid;\r
+               $currentitemid = $this->currentItem->itemid;\r
+       }\r
+\r
+       /**\r
+        * Set the current template\r
+        * \r
+        * @param $template\r
+        *                      Template to be used\r
+        */\r
+       function setTemplate($template) {\r
+               $this->template =& $template;\r
+       }\r
+\r
+       /**\r
+        * Get the defined actions in an item\r
+        */\r
+       function getDefinedActions() {\r
+               return array('image', 'media', 'popup', 'plugin', 'if', 'else', 'endif', 'elseif', 'ifnot', 'elseifnot');\r
+       }\r
+\r
+       /**\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
+               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
+               $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
+               if (!$plugin) return;\r
+\r
+               // get arguments\r
+               $params = func_get_args();\r
+\r
+               // remove plugin name\r
+               array_shift($params);\r
+\r
+               // add item reference (array_unshift didn't work)\r
+               $params = array_merge(array(&$this->currentItem),$params);\r
+\r
+               call_user_func_array(array(&$plugin,'doItemVar'), $params);\r
+       }\r
+\r
+       /**\r
+        * Parse image\r
+        * Called if <%image(...)%> in an item appears\r
+        */\r
+       function parse_image() {\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
+       }\r
+       \r
+       /**\r
+        * Creates the code for an image\r
+        */\r
+       function createImageCode($filename, $width, $height, $text = '') {\r
+               global $CONF;\r
+\r
+               // select private collection when no collection given\r
+               if (!strstr($filename,'/')) {\r
+                       $filename = $this->currentItem->authorid . '/' . $filename;\r
+               }\r
+\r
+               $windowwidth = $width;\r
+               $windowheight = $height;\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
+\r
+       /**\r
+        * Parse media\r
+        * Called if <%media(...)%> in an item appears\r
+        */\r
+       function parse_media() {\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
+       }\r
+\r
+       /**\r
+        * Creates the code for a media\r
+        */\r
+       function createMediaCode($filename, $text = '') {\r
+               global $CONF;\r
+\r
+               // select private collection when no collection given\r
+               if (!strstr($filename,'/')) {\r
+                       $filename = $this->currentItem->authorid . '/' . $filename;\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
+       }\r
+\r
+       /**\r
+        * Parse popup\r
+        * Called if <%popup(...)%> in an item appears\r
+        */\r
+       function parse_popup() {\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
+       }\r
+\r
+       /**\r
+        * Creates the code for a popup\r
+        */\r
+       function createPopupCode($filename, $width, $height, $text = '') {\r
+               global $CONF;\r
+\r
+               // select private collection when no collection given\r
+               if (!strstr($filename,'/')) {\r
+                       $filename = $this->currentItem->authorid . '/' . $filename;\r
+               }\r
+\r
+               $windowwidth = $width;\r
+               $windowheight = $height;\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
+               $vars['popuplink']              = '<a href="' . $vars['rawpopuplink']. '" onclick="'. $vars['popupcode'].'" >' . $vars['popuptext'] . '</a>';\r
+               $vars['width']                  = $width;\r
+               $vars['height']                 = $height;\r
+               $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
+       \r
+       // function to enable if-else-elseif-elseifnot-ifnot-endif to item template fields\r
+       \r
+       /**\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
+        */\r
+       function checkCondition($field, $name='', $value = '') {\r
+               global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
+\r
+               $condition = 0;\r
+               switch($field) {\r
+                       case 'category':\r
+                               $condition = ($blog && $this->_ifCategory($name,$value));\r
+                               break;\r
+                       case 'itemcategory':\r
+                               $condition = ($this->_ifItemCategory($name,$value));\r
+                               break;\r
+                       case 'blogsetting':\r
+                               $condition = ($blog && ($blog->getSetting($name) == $value));\r
+                               break;\r
+                       case 'itemblogsetting':\r
+                               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));\r
+                               $condition = ($b && ($b->getSetting($name) == $value));\r
+                               break;\r
+                       case 'loggedin':\r
+                               $condition = $member->isLoggedIn();\r
+                               break;\r
+                       case 'onteam':\r
+                               $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);\r
+                               break;\r
+                       case 'admin':\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
+                               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
+                               break;\r
+                       default:\r
+                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);\r
+                               break;\r
+               }\r
+               return $condition;\r
+       }       \r
+       \r
+       /**\r
+        *  Different checks for a category\r
+        */\r
+       function _ifCategory($name = '', $value='') {\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
+                       return $blog->isValidCategory($catid);\r
+\r
+               // check category name\r
+               if ($name == 'catname') {\r
+                       $value = $blog->getCategoryIdFromName($value);\r
+                       if ($value == $catid)\r
+                               return $blog->isValidCategory($catid);\r
+               }\r
+\r
+               // check category id\r
+               if (($name == 'catid') && ($value == $catid))\r
+                       return $blog->isValidCategory($catid);\r
+\r
+               return false;\r
+       }\r
+       \r
+               \r
+       /**\r
+        *  Different checks for an author\r
+        */\r
+       function _ifAuthor($name = '', $value='') {\r
+               global $member, $manager;\r
+               \r
+               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));\r
+\r
+               // when no parameter is defined, just check if author is current visitor\r
+               if (($name != 'isadmin' && $name != 'name') || ($name == 'name' && $value == '')) {\r
+                       return (intval($member->getID()) > 0 && intval($member->getID()) == intval($this->currentItem->authorid));\r
+               }\r
+\r
+               // check author name\r
+               if ($name == 'name') {\r
+                       $value = strtolower($value);\r
+                       if ($value == strtolower($this->currentItem->author))\r
+                               return true;\r
+               }\r
+\r
+               // check if author is admin\r
+               if (($name == 'isadmin')) {                     \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
+                       return $amember->isBlogAdmin($blogid);\r
+               }\r
+\r
+               return false;\r
+       }\r
+       \r
+       /**\r
+        *  Different checks for a category\r
+        */\r
+       function _ifItemCategory($name = '', $value='') {\r
+               global $catid, $manager;\r
+               \r
+               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));\r
+\r
+               // when no parameter is defined, just check if a category is selected\r
+               if (($name != 'catname' && $name != 'catid') || ($value == ''))\r
+                       return $b->isValidCategory($catid);\r
+                       \r
+               $icatid = $this->currentItem->catid;\r
+               //$icategory = $this->currentItem->category;\r
+\r
+               // check category name\r
+               if ($name == 'catname') {\r
+                       $value = $b->getCategoryIdFromName($value);\r
+                       if ($value == $icatid)\r
+                               return $b->isValidCategory($icatid);\r
+               }\r
+\r
+               // check category id\r
+               if (($name == 'catid') && ($value == $icatid))\r
+                       return $b->isValidCategory($icatid);\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
+        */\r
+       function _ifOnTeam($blogName = '') {\r
+               global $blog, $member, $manager;\r
+\r
+               // when no blog found\r
+               if (($blogName == '') && (!is_object($blog)))\r
+                       return 0;\r
+\r
+               // explicit blog selection\r
+               if ($blogName != '')\r
+                       $blogid = getBlogIDFromName($blogName);\r
+\r
+               if (($blogName == '') || !$manager->existsBlogID($blogid))\r
+                       // use current blog\r
+                       $blogid = $blog->getID();\r
+\r
+               return $member->teamRights($blogid);\r
+       }\r
+\r
+       /**\r
+        *  Checks if a member is admin of a blog\r
+        */\r
+       function _ifAdmin($blogName = '') {\r
+               global $blog, $member, $manager;\r
+\r
+               // when no blog found\r
+               if (($blogName == '') && (!is_object($blog)))\r
+                       return 0;\r
+\r
+               // explicit blog selection\r
+               if ($blogName != '')\r
+                       $blogid = getBlogIDFromName($blogName);\r
+\r
+               if (($blogName == '') || !$manager->existsBlogID($blogid))\r
+                       // use current blog\r
+                       $blogid = $blog->getID();\r
+\r
+               return $member->isBlogAdmin($blogid);\r
+       }\r
+\r
+       \r
+       /**\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
+       function _ifHasPlugin($name, $value) {\r
+               global $manager;\r
+               $condition = false;\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
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               return $condition;\r
+       }\r
+\r
+       /**\r
+        * Checks if a plugin exists and call its doIf function\r
+        */\r
+       function _ifPlugin($name, $key = '', $value = '') {\r
+               global $manager;\r
+\r
+               $plugin =& $manager->getPlugin('NP_' . $name);\r
+               if (!$plugin) return;\r
+\r
+               $params = func_get_args();\r
+               array_shift($params);\r
+\r
+               return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
+       }\r
+\r
+}\r
+?>\r