OSDN Git Service

CHANGE: getBlogIDFromItemID()を使わずにManager::getItem()を使うよう変更
[nucleus-jp/nucleus-next.git] / nucleus / libs / ITEMACTIONS.php
index 871fc49..b1de395 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)
- */
-/**
- * This class is used to parse item templates
- *
- * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: ITEMACTIONS.php 1626 2012-01-09 15:46:54Z sakamocchi $
- */
-class ITEMACTIONS extends BaseActions {
-
-       // contains an assoc array with parameters that need to be included when
-       // generating links to items/archives/... (e.g. catid)
-       var $linkparams;
-
-       // true when the current user is a blog admin (and thus allowed to edit all items)
-       var $allowEditAll;
-
-       // timestamp of last visit
-       var $lastVisit;
-
-       // item currently being handled (mysql result object, see BLOG::showUsingQuery)
-       var $currentItem;
-
-       // reference to the blog currently being displayed
-       var $blog;
-
-       // associative array with template info (part name => contents)
-       var $template;
-
-       // true when comments need to be displayed
-       var $showComments;
-
-       function ITEMACTIONS(&$blog) {
-               // call constructor of superclass first
-               $this->BaseActions();
-
-               // extra parameters for created links
-               global $catid;
-               if ($catid)
-                       $this->linkparams = array('catid' => $catid);
-
-               // check if member is blog admin (and thus allowed to edit all items)
-               global $member;
-               $this->allowEditAll = ($member->isLoggedIn() && $member->blogAdminRights($blog->getID()));
-               $this->setBlog($blog);
-       }
-
-       /**
-         * Returns an array with the actions that are defined
-         * in the ITEMACTIONS class
-         */
-       function getDefinedActions() {
-               return array(
-                       'blogid',
-                       'title',
-                       'body',
-                       'more',
-                       'smartbody',
-                       'itemid',
-                       'morelink',
-                       'category',
-                       'categorylink',
-                       'author',
-                       'authorid',
-                       'authorlink',
-                       'catid',
-                       'karma',
-                       'date',
-                       'time',
-                       'query',
-                       'itemlink',
-                       'blogurl',
-                       'closed',
-                       'syndicate_title',
-                       'syndicate_description',
-                       'karmaposlink',
-                       'karmaneglink',
-                       'new',
-                       'image',
-                       'popup',
-                       'media',
-                       'daylink',
-                       'query',
-                       'include',
-                       'phpinclude',
-                       'parsedinclude',
-                       'skinfile',
-                       'set',
-                       'plugin',
-                       'edit',
-                       'editlink',
-                       'editpopupcode',
-                       'comments',
-                       'relevance',
-                       'if',
-                       'else',
-                       'endif',
-                       'elseif',
-                       'ifnot',
-                       'elseifnot'
-               );
-       }
-
-       function setLastVisit($lastVisit) {
-               $this->lastVisit = $lastVisit;
-       }
-
-       function setParser(&$parser) {
-               $this->parser =& $parser;
-       }
-
-       function setCurrentItem(&$item) {
-               $this->currentItem =& $item;
-               global $currentitemid;
-               $currentitemid = $this->currentItem->itemid;
-       }
-
-       function setBlog(&$blog) {
-               $this->blog =& $blog;
-       }
-
-       function setTemplate($template) {
-               $this->template =& $template;
-       }
-
-       function setShowComments($val) {
-               $this->showComments = $val;
-       }
-
-       // methods used by parser to insert content
-
-
-       /**
-        * Parse templatevar blogid
-        */
-       function parse_blogid() {
-               echo $this->blog->getID();
-       }
-
-       /**
-        * Parse templatevar body
-        */
-       function parse_body() {
-               $this->highlightAndParse($this->currentItem->body);
-       }
-
-       /**
-        * Parse templatevar more
-        */
-       function parse_more() {
-               $this->highlightAndParse($this->currentItem->more);
-       }
-
-       /**
-        * Parse templatevar itemid
-        */
-       function parse_itemid() {
-               echo $this->currentItem->itemid;
-       }
-
-       /**
-        * Parse templatevar category
-        */
-       function parse_category() {
-               echo $this->currentItem->category;
-       }
-
-       /**
-        * Parse templatevar categorylink
-        */
-       function parse_categorylink() {
-               echo createLink('category', array('catid' => $this->currentItem->catid, 'name' => $this->currentItem->category));
-       }
-
-       /**
-        * Parse templatevar catid
-        */
-       function parse_catid() {
-               echo $this->currentItem->catid;
-       }
-
-       /**
-        * Parse templatevar authorid
-        */
-       function parse_authorid() {
-               echo $this->currentItem->authorid;
-       }
-
-       /**
-        * Parse templatevar authorlink
-        */
-       function parse_authorlink() {
-               echo createLink(
-                       'member',
-                       array(
-                               'memberid' => $this->currentItem->authorid,
-                               'name' => $this->currentItem->author,
-                               'extra' => $this->linkparams
-                       )
-               );
-       }
-
-       /**
-        * Parse templatevar query
-        */
-       function parse_query() {
-               echo $this->strHighlight;
-       }
-
-       /**
-        * Parse templatevar itemlink
-        */
-       function parse_itemlink() {
-               echo createLink(
-                       'item',
-                       array(
-                               'itemid' => $this->currentItem->itemid,
-                               'title' => $this->currentItem->title,
-                               'timestamp' => $this->currentItem->timestamp,
-                               'extra' => $this->linkparams
-                       )
-               );
-       }
-
-       /**
-        * Parse templatevar blogurl
-        */
-       function parse_blogurl() {
-               echo $this->blog->getURL();
-       }
-
-       /**
-        * Parse templatevar closed
-        */
-       function parse_closed() {
-               echo $this->currentItem->closed;
-       }
-
-       /**
-        * Parse templatevar relevance
-        */
-       function parse_relevance() {
-               echo round($this->currentItem->score,2);
-       }
-
-       /**
-        * Parse templatevar title
-        *
-        * @param string $format defines in which format the title is shown
-        */
-       function parse_title($format = '') {
-               if (is_array($this->currentItem)) {
-                       $itemtitle = $this->currentItem['title'];
-               } elseif (is_object($this->currentItem)) {
-                       $itemtitle = $this->currentItem->title;
-               }
-               switch ($format) {
-                       case 'xml':
-//                             echo stringToXML ($this->currentItem->title);
-                               echo stringToXML ($itemtitle);
-                               break;
-                       case 'attribute':
-//                             echo stringToAttribute ($this->currentItem->title);
-                               echo stringToAttribute ($itemtitle);
-                               break;
-                       case 'raw':
-//                             echo $this->currentItem->title;
-                               echo $itemtitle;
-                               break;
-                       default:
-//                             $this->highlightAndParse($this->currentItem->title);
-                               $this->highlightAndParse($itemtitle);
-                               break;
-               }
-       }
-
-       /**
-        * Parse templatevar karma
-        */
-       function parse_karma($type = 'totalscore') {
-               global $manager;
-
-               // get karma object
-               $karma =& $manager->getKarma($this->currentItem->itemid);
-
-               switch($type) {
-                       case 'pos':
-                               echo $karma->getNbPosVotes();
-                               break;
-                       case 'neg':
-                               echo $karma->getNbNegVotes();
-                               break;
-                       case 'votes':
-                               echo $karma->getNbOfVotes();
-                               break;
-                       case 'posp':
-                               $percentage = $karma->getNbOfVotes() ? 100 * ($karma->getNbPosVotes() / $karma->getNbOfVotes()) : 50;
-                               echo number_format($percentage,2), '%';
-                               break;
-                       case 'negp':
-                               $percentage = $karma->getNbOfVotes() ? 100 * ($karma->getNbNegVotes() / $karma->getNbOfVotes()) : 50;
-                               echo number_format($percentage,2), '%';
-                               break;
-                       case 'totalscore':
-                       default:
-                               echo $karma->getTotalScore();
-                               break;
-               }
-
-       }
-
-       /**
-        * Parse templatevar author
-        */
-       function parse_author($which = '') {
-               switch($which)
-               {
-                       case 'realname':
-                               echo $this->currentItem->authorname;
-                               break;
-                       case 'id':
-                               echo $this->currentItem->authorid;
-                               break;
-                       case 'email':
-                               echo $this->currentItem->authormail;
-                               break;
-                       case 'url':
-                               echo $this->currentItem->authorurl;
-                               break;
-                       case 'name':
-                       default:
-                               echo $this->currentItem->author;
-               }
-       }
-
-       /**
-        * Parse templatevar smartbody
-        */
-       function parse_smartbody() {
-               if (!$this->currentItem->more) {
-                       $this->highlightAndParse($this->currentItem->body);
-               } else {
-                       $this->highlightAndParse($this->currentItem->more);
-               }
-       }
-
-       /**
-        * Parse templatevar morelink
-        */
-       function parse_morelink() {
-               if ($this->currentItem->more)
-                       $this->parser->parse($this->template['MORELINK']);
-       }
-
-       /**
-        * Parse templatevar date
-        *
-        * @param format optional strftime format
-        */
-       function parse_date($format = '') {
-               if (!isset($this->template['FORMAT_DATE'])) $this->template['FORMAT_DATE'] = '';
-               echo formatDate($format, $this->currentItem->timestamp, $this->template['FORMAT_DATE'], $this->blog);
-       }
-
-       /**
-         * Parse templatevar time
-         *
-         * @param format optional strftime format
-         */
-       function parse_time($format = '') {
-               if (!isset($this->template['FORMAT_TIME'])) $this->template['FORMAT_TIME'] = '';
-               echo i18n::strftime($format ? $format : $this->template['FORMAT_TIME'],$this->currentItem->timestamp);
-       }
-
-       /**
-         * Parse templatevar syndicate_title
-         *
-         * @param maxLength optional maximum length
-         */
-       function parse_syndicate_title($maxLength = 100) {
-               $syndicated = strip_tags($this->currentItem->title);
-               echo i18n::hsc(shorten($syndicated,$maxLength,'...'));
-       }
-
-       /**
-         * Parse templatevar syndicate_description
-         *
-         * @param maxLength optional maximum length
-         */
-       function parse_syndicate_description($maxLength = 250, $addHighlight = 0) {
-               $syndicated = strip_tags($this->currentItem->body);
-               if ($addHighlight) {
-                       $tmp_highlight = i18n::hsc(shorten($syndicated,$maxLength,'...'));
-                       echo $this->highlightAndParse($tmp_highlight);
-               } else {
-                       echo i18n::hsc(shorten($syndicated,$maxLength,'...'));
-               }
-       }
-
-       /**
-         * Parse templatevar karmaposlink
-         *
-         * @param string text
-         */
-       function parse_karmaposlink($text = '') {
-               global $CONF;
-               $link = $CONF['ActionURL'] . '?action=votepositive&amp;itemid='.$this->currentItem->itemid;
-               echo $text ? '<a href="'.$link.'">'.$text.'</a>' : $link;
-       }
-
-       /**
-         * Parse templatevar karmaneglink
-         *
-         * @param string text
-         */
-       function parse_karmaneglink($text = '') {
-               global $CONF;
-               $link = $CONF['ActionURL'] . '?action=votenegative&amp;itemid='.$this->currentItem->itemid;
-               echo $text ? '<a href="'.$link.'">'.$text.'</a>' : $link;
-       }
-
-       /**
-         * Parse templatevar new
-         */
-       function parse_new() {
-               if (($this->lastVisit != 0) && ($this->currentItem->timestamp > $this->lastVisit))
-                       echo $this->template['NEW'];
-       }
-
-       /**
-         * Parse templatevar daylink
-         */
-       function parse_daylink() {
-               echo createArchiveLink($this->blog->getID(), i18n::strftime('%Y-%m-%d',$this->currentItem->timestamp), $this->linkparams);
-       }
-
-       /**
-         * Parse templatevar comments
-         */
-       function parse_comments($maxToShow = 0) {
-               if ($maxToShow == 0)
-                       $maxToShow = $this->blog->getMaxComments();
-
-               // add comments
-               if ($this->showComments && $this->blog->commentsEnabled()) {
-                       $comments = new COMMENTS($this->currentItem->itemid);
-                       $comments->setItemActions($this);
-                       $comments->showComments($this->template, $maxToShow, $this->currentItem->closed ? 0 : 1, $this->strHighlight);
-               }
-       }
-
-       /**
-         * Executes a plugin templatevar
-         *
-         * @param pluginName name of plugin (without the NP_)
-         *
-         * extra parameters can be added
-         */
-       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,'doTemplateVar'), $params);
-       }
-
-       /**
-         * Parse templatevar edit
-         */
-       function parse_edit() {
-               global $member, $CONF;
-               if ($this->allowEditAll || ($member->isLoggedIn() && ($member->getID() == $this->currentItem->authorid)) ) {
-                       $this->parser->parse($this->template['EDITLINK']);
-               }
-       }
-
-       /**
-         * Parse templatevar editlink
-         */
-       function parse_editlink() {
-               global $CONF;
-               echo $CONF['AdminURL'],'bookmarklet.php?action=edit&amp;itemid=',$this->currentItem->itemid;
-       }
-
-       /**
-         * Parse templatevar editpopupcode
-         */
-       function parse_editpopupcode() {
-               echo "if (event &amp;&amp; event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=yes,width=600,height=550,left=10,top=10,status=yes,resizable=yes');winbm.focus();return false;";
-       }
-
-       // helper functions
-
-       /**
-        * Parses highlighted text, with limited actions only (to prevent not fully trusted team members
-        * from hacking your weblog.
-        * 'plugin variables in items' implementation by Andy
-        */
-       function highlightAndParse(&$data) {
-               $actions = new BODYACTIONS($this->blog);
-               $parser = new PARSER($actions->getDefinedActions(), $actions);
-               $actions->setTemplate($this->template);
-               $actions->setHighlight($this->strHighlight);
-               $actions->setCurrentItem($this->currentItem);
-               //$actions->setParser($parser);
-               $parser->parse($actions->highlight($data));
-       }
-
-       /*
-       // this is the function previous to the 'plugin variables in items' implementation by Andy
-       function highlightAndParse(&$data) {
-               // allow only a limited subset of actions (do not allow includes etc, they might be evil)
-               $this->parser->actions = array('image','media','popup');
-               $tmp_highlight = $this->highlight($data);
-               $this->parser->parse($tmp_highlight);
-               $this->parser->actions = $this->getDefinedActions();
-       }
-       */
-       
-       // 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);
-       }
-
-}
-
-?>
\ No newline at end of file
+<?php\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
+ * This class is used to parse item templates\r
+ *\r
+ * @license http://nucleuscms.org/license.txt GNU General Public License\r
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
+ * @version $Id: ITEMACTIONS.php 1757 2012-04-15 09:02:32Z sakamocchi $\r
+ */\r
+class ItemActions extends BaseActions\r
+{\r
+       /**\r
+        * ItemActions::$currentItem\r
+        * item currently being handled (mysql result object, see Blog::showUsingQuery)\r
+        */\r
+       public $currentItem;\r
+       \r
+       /**\r
+        * ItemActions::$linkparams\r
+        * contains an assoc array with parameters that need to be included when\r
+        * generating links to items/archives/... (e.g. catid)\r
+        */\r
+       public $linkparams;\r
+       \r
+       /**\r
+        * ItemActions::$allowEditAll\r
+        * true when the current user is a blog admin (and thus allowed to edit all items) \r
+        */\r
+       private $allowEditAll;\r
+       \r
+       /**\r
+        * ItemActions::$lastVisit\r
+        * timestamp of last visit\r
+        */\r
+       private $lastVisit;\r
+       \r
+       /**\r
+        * ItemActions::$blog\r
+        * reference to the blog currently being displayed\r
+        */\r
+       public $blog;
+       \r
+       /**\r
+        * ItemActions::$template\r
+        * associative array with template info (part name => contents)\r
+        */\r
+       private $template;\r
+       \r
+       /**\r
+        * ItemActions::$showComments\r
+        * true when comments need to be displayed\r
+        */\r
+       private $showComments;\r
+       \r
+       /**\r
+        * ItemActions::$defined_actions\r
+        * defined actions in this class\r
+        */\r
+       static private $defined_actions = array(\r
+               'author',
+               'authorid',
+               'authorlink',
+               'blogid',\r
+               'blogurl',
+               'body',\r
+               'category',\r
+               'categorylink',\r
+               'catid',\r
+               'closed',
+               'comments',
+               'date',\r
+               'daylink',
+               'edit',
+               'editlink',
+               'editpopupcode',
+               'itemid',
+               'itemlink',\r
+               'karma',
+               'karmaneglink',
+               'karmaposlink',\r
+               'more',
+               'morelink',
+               'new',\r
+               'plugin',
+               'query',
+               'relevance',
+               'smartbody',\r
+               'syndicate_description',\r
+               'syndicate_title',\r
+               'time',\r
+               'title',\r
+       /* actions defined in BodyAction class */\r
+               'image',\r
+               'media',\r
+               'popup'\r
+       );\r
+       \r
+       /**\r
+        * ItemActions::__construct\r
+        * Enter description here ...\r
+        * @param unknown_type $blog\r
+        */\r
+       public function __construct(&$blog)\r
+       {\r
+               global $catid, $member;\r
+               \r
+               // call constructor of superclass first\r
+               parent::__construct();
+               \r
+               // extra parameters for created links\r
+               if ( $catid )\r
+               {\r
+                       $this->linkparams = array('catid' => $catid);\r
+               }\r
+               \r
+               // check if member is blog admin (and thus allowed to edit all items)\r
+               $this->allowEditAll = ($member->isLoggedIn() && $member->blogAdminRights($blog->getID()));\r
+               $this->setBlog($blog);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::getAvailableActions()\r
+        * Returns an array with the actions that are defined\r
+        * in the ItemActions class\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function getAvailableActions()\r
+       {\r
+               return array_merge(self::$defined_actions, parent::getAvailableActions());\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::setLastVisit()\r
+        * \r
+        * @param       timestamp       $lastVisit      timestamp of latest visit\r
+        * @return      void\r
+        */\r
+       public function setLastVisit($lastVisit)\r
+       {\r
+               $this->lastVisit = $lastVisit;\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::setCurrentItem()\r
+        * \r
+        * @param       object  $item   instance of Item class\r
+        * @return      void\r
+        */\r
+       public function setCurrentItem(&$item)\r
+       {\r
+               global $currentitemid;\r
+               $this->currentItem =& $item;\r
+               $currentitemid = $this->currentItem['itemid'];\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::setBlog()\r
+        * \r
+        * @param       object  &$blog  instance of Blog class\r
+        * @return      void\r
+        */\r
+       public function setBlog(&$blog)\r
+       {\r
+               $this->blog =& $blog;\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::setTemplate()\r
+        * \r
+        * @param       array   $template       array including templates\r
+        * @return      void\r
+        */\r
+       public function setTemplate($template)\r
+       {\r
+               $this->template =& $template;\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::setShowComments()\r
+        * \r
+        * @param       boolean $val    need to be displayed or not\r
+        * @return      void\r
+        */\r
+       public function setShowComments($val)\r
+       {\r
+               $this->showComments = (boolean) $val;\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_blogid()\r
+        * Parse templatevar blogid\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_blogid()\r
+       {\r
+               echo $this->blog->getID();\r
+       }\r
+\r
+       /**\r
+        * ItemActions::parse_body()\r
+        * Parse templatevar body\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_body()\r
+       {\r
+               $this->highlightAndParse($this->currentItem['body']);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_more()\r
+        * Parse templatevar more\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_more()\r
+       {\r
+               $this->highlightAndParse($this->currentItem['more']);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_itemid()\r
+        * Parse templatevar itemid\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_itemid()\r
+       {\r
+               echo $this->currentItem['itemid'];\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_category()\r
+        * Parse templatevar category\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_category()\r
+       {\r
+               echo $this->currentItem['category'];\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_categorylink()\r
+        * Parse templatevar categorylink\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_categorylink()\r
+       {\r
+               echo Link::create_link('category', array('catid' => $this->currentItem['catid'], 'name' => $this->currentItem['category']));\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_catid()\r
+        * Parse templatevar catid\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_catid()\r
+       {\r
+               echo $this->currentItem['catid'];\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_authorid()\r
+        * Parse templatevar authorid\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_authorid()\r
+       {\r
+               echo $this->currentItem['authorid'];\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_authorlink()\r
+        * Parse templatevar authorlink\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_authorlink()\r
+       {\r
+               $data = array(\r
+                               'memberid' => $this->currentItem['authorid'],\r
+                               'name' => $this->currentItem['author'],\r
+                               'extra' => $this->linkparams\r
+                       );\r
+               \r
+               echo Link::create_link('member', $data);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_query()\r
+        * Parse templatevar query\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_query()\r
+       {\r
+               echo $this->strHighlight;\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_itemlink()\r
+        * Parse templatevar itemlink\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_itemlink()\r
+       {\r
+               $data = array(\r
+                       'itemid'        => $this->currentItem['itemid'],\r
+                       'title'         => $this->currentItem['title'],\r
+                       'timestamp'     => $this->currentItem['timestamp'],\r
+                       'extra'         => $this->linkparams\r
+               );\r
+               \r
+               echo Link::create_link('item', $data);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_blogurl()\r
+        * Parse templatevar blogurl\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_blogurl()\r
+       {\r
+               echo $this->blog->getURL();\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_closed()\r
+        * Parse templatevar closed\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_closed()\r
+       {\r
+               echo $this->currentItem['closed'];\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_relevance()\r
+        * Parse templatevar relevance\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_relevance()\r
+       {\r
+               echo round($this->currentItem['score'], 2);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_title()\r
+        * Parse templatevar title\r
+        *\r
+        * @param       string  $format defines in which format the title is shown\r
+        * @return      void\r
+        */\r
+       public function parse_title($format = '')\r
+       {\r
+               if ( is_array($this->currentItem) )\r
+               {\r
+                       $itemtitle = $this->currentItem['title'];\r
+               }\r
+               switch ( $format )\r
+               {\r
+                       case 'xml':\r
+                               echo Entity::hen($itemtitle);\r
+                               break;\r
+                       case 'attribute':\r
+                               echo Entity::hsc($itemtitle);\r
+                               break;\r
+                       case 'raw':\r
+                               echo $itemtitle;\r
+                               break;\r
+                       default:\r
+                               $this->highlightAndParse($itemtitle);\r
+                               break;\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_karma()\r
+        * Parse templatevar karma\r
+        * \r
+        * @param       string  $type   type of data for karma\r
+        * @return      void\r
+        */\r
+       public function parse_karma($type = 'totalscore')\r
+       {\r
+               global $manager;\r
+               \r
+               // get karma object\r
+               $karma =& $manager->getKarma($this->currentItem['itemid']);\r
+               \r
+               switch ( $type )\r
+               {\r
+                       case 'pos':\r
+                               echo $karma->getNbPosVotes();\r
+                               break;\r
+                       case 'neg':\r
+                               echo $karma->getNbNegVotes();\r
+                               break;\r
+                       case 'votes':\r
+                               echo $karma->getNbOfVotes();\r
+                               break;\r
+                       case 'posp':\r
+                               $percentage = $karma->getNbOfVotes() ? 100 * ($karma->getNbPosVotes() / $karma->getNbOfVotes()) : 50;\r
+                               echo number_format($percentage,2), '%';\r
+                               break;\r
+                       case 'negp':\r
+                               $percentage = $karma->getNbOfVotes() ? 100 * ($karma->getNbNegVotes() / $karma->getNbOfVotes()) : 50;\r
+                               echo number_format($percentage,2), '%';\r
+                               break;\r
+                       case 'totalscore':\r
+                       default:\r
+                               echo $karma->getTotalScore();\r
+                               break;\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_author()\r
+        * Parse templatevar author\r
+        * \r
+        * @param       string  $which  key of data for author\r
+        * @return      void\r
+        */\r
+       public function parse_author($which = '')\r
+       {\r
+               switch ( $which )\r
+               {\r
+                       case 'realname':\r
+                               echo $this->currentItem['authorname'];\r
+                               break;\r
+                       case 'id':\r
+                               echo $this->currentItem['authorid'];\r
+                               break;\r
+                       case 'email':\r
+                               echo $this->currentItem['authormail'];\r
+                               break;\r
+                       case 'url':\r
+                               echo $this->currentItem['authorurl'];\r
+                               break;\r
+                       case 'name':\r
+                       default:\r
+                               echo $this->currentItem['author'];\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_smartbody()\r
+        * Parse templatevar smartbody\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_smartbody()\r
+       {\r
+               if ( !$this->currentItem['more'] )\r
+               {\r
+                       $this->highlightAndParse($this->currentItem['body']);\r
+               }\r
+               else\r
+               {\r
+                       $this->highlightAndParse($this->currentItem['more']);\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_morelink()\r
+        * Parse templatevar morelink\r
+        */\r
+       public function parse_morelink()\r
+       {\r
+               if ( $this->currentItem['more'] )\r
+               {\r
+                       $this->parser->parse($this->template['MORELINK']);\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_date()\r
+        * Parse templatevar date\r
+        *\r
+        * @param       string  $format format optional strftime format\r
+        * @return      void\r
+        */\r
+       public function parse_date($format = '')\r
+       {\r
+               if ( $format !== '' )\r
+               {\r
+                       /* do nothing */\r
+                       ;\r
+               }\r
+               else if ( !array_key_exists('FORMAT_DATE', $this->template) || $this->template['FORMAT_DATE'] === '' )\r
+               {\r
+                       /* depends on the PHP's current locale */\r
+                       $format = '%X';\r
+               }\r
+               else\r
+               {\r
+                       $format = $this->template['FORMAT_DATE'];\r
+               }\r
+               \r
+               $offset = 0;\r
+               if ( $this->blog )\r
+               {\r
+                       $offset = $this->blog->getTimeOffset() * 3600;\r
+               }\r
+               \r
+               echo i18n::formatted_datetime($format, $this->currentItem['timestamp'], $offset);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_time()\r
+        * Parse templatevar time\r
+        *\r
+        * @param       string  $format format optional strftime format\r
+        * @return      void\r
+        */\r
+       public function parse_time($format = '')\r
+       {\r
+               if ( $format !== '' )\r
+               {\r
+                       /* do nothing */\r
+                       ;\r
+               }\r
+               else if ( !array_key_exists('FORMAT_TIME', $this->template) || $this->template['FORMAT_TIME'] === '' )\r
+               {\r
+                       /* depends on the PHP's current locale */\r
+                       $format = '%x';\r
+               }\r
+               else\r
+               {\r
+                       $format = $this->template['FORMAT_TIME'];\r
+               }\r
+               echo i18n::formatted_datetime($format, $this->currentItem['timestamp']);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_syndicate_title()\r
+        * Parse templatevar syndicate_title\r
+        *\r
+        * @param       string  $maxLength      maxLength optional maximum length\r
+        * @return      string  syndicated      title\r
+        */\r
+       public function parse_syndicate_title($maxLength = 100) {\r
+               $syndicated = strip_tags($this->currentItem['title']);\r
+               echo Entity::hsc(Entity::shorten($syndicated,$maxLength,'...'));\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_syndicate_description()\r
+        * Parse templatevar syndicate_description\r
+        *\r
+        * @param       stromg  $maxLength              maxlength optional maximum length\r
+        * @param       string  $addHighlight   highlighted string\r
+        * @return      void\r
+        */\r
+       public function parse_syndicate_description($maxLength = 250, $addHighlight = 0)\r
+       {\r
+               $syndicated = strip_tags($this->currentItem['body']);\r
+               if ( $addHighlight )\r
+               {\r
+                       $tmp_highlight = Entity::hsc(Entity::shorten($syndicated,$maxLength,'...'));\r
+                       echo $this->highlightAndParse($tmp_highlight);\r
+               }\r
+               else\r
+               {\r
+                       echo Entity::hsc(Entity::shorten($syndicated,$maxLength,'...'));\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_karmaposlink()\r
+        * Parse templatevar karmaposlink\r
+        *\r
+        * @param       string  $text   text element for anchor element\r
+        * @return      void\r
+        */\r
+       public function parse_karmaposlink($text = '')\r
+       {\r
+               global $CONF;\r
+               $link = $CONF['ActionURL'] . '?action=votepositive&amp;itemid=' . $this->currentItem['itemid'];\r
+               if ( !$text )\r
+               {\r
+                       echo '<a href="'.$link.'">' . $text . '</a>';\r
+               }\r
+               else\r
+               {\r
+                       echo $link;\r
+               }\r
+               \r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_karmaneglink()\r
+        * Parse templatevar karmaneglink\r
+        *\r
+        * @param       string $text    text element for anchor element\r
+        * @return      void\r
+        */\r
+       public function parse_karmaneglink($text = '')\r
+       {\r
+               global $CONF;\r
+               $link = $CONF['ActionURL'] . '?action=votenegative&amp;itemid='.$this->currentItem['itemid'];\r
+               \r
+               if ( !$text )\r
+               {\r
+                       echo '<a href="'.$link.'">' . $text . '</a>';\r
+               }\r
+               else\r
+               {\r
+                       echo $link;\r
+               }\r
+               \r
+               return;\r
+       }\r
+\r
+       /**\r
+        * ItemActions::parse_new()\r
+        * Parse templatevar new\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_new()\r
+       {\r
+               if ( ($this->lastVisit != 0) && ($this->currentItem['timestamp'] > $this->lastVisit) )\r
+               {\r
+                       echo $this->template['NEW'];\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_daylink()\r
+        * Parse templatevar daylink\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_daylink()\r
+       {\r
+               echo Link::create_archive_link($this->blog->getID(), i18n::formatted_datetime('%Y-%m-%d', $this->currentItem['timestamp']), $this->linkparams);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_comments(\r
+        * Parse templatevar comments\r
+        * \r
+        * @param       integer $maxToShow      maximum number of comments in a display\r
+        * @return      void\r
+        */\r
+       public function parse_comments($maxToShow = 0)\r
+       {\r
+               if ( $maxToShow == 0 )\r
+               {\r
+                       $maxToShow = $this->blog->getMaxComments();\r
+               }\r
+               \r
+               // add comments\r
+               if ( $this->showComments && $this->blog->commentsEnabled() )\r
+               {\r
+                       $comments = new Comments($this->currentItem['itemid']);\r
+                       $comments->setItemActions($this);\r
+                       $comments->showComments($this->template, $maxToShow, $this->currentItem['closed'] ? 0 : 1, $this->strHighlight);\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_plugin()\r
+        * Executes a plugin templatevar\r
+        *\r
+        * @param       string  $pluginName     name of plugin (without the NP_)\r
+        * @param       extra parameters can be added\r
+        * @return      void\r
+        */\r
+       public function parse_plugin($pluginName)\r
+       {\r
+               global $manager;\r
+               \r
+               $plugin =& $manager->getPlugin("NP_{$pluginName}");\r
+               if ( !$plugin )\r
+               {\r
+                       return;\r
+               }\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,'doTemplateVar'), $params);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_edit()\r
+        * Parse templatevar edit\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_edit()\r
+       {\r
+               global $member, $CONF;\r
+               if ( $this->allowEditAll || ($member->isLoggedIn() && ($member->getID() == $this->currentItem['authorid'])) )\r
+               {\r
+                       $this->parser->parse($this->template['EDITLINK']);\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_editlink()\r
+        * Parse templatevar editlink\r
+        */\r
+       public function parse_editlink()\r
+       {\r
+               global $CONF;\r
+               echo $CONF['AdminURL'] . 'bookmarklet.php?action=edit&amp;itemid=' . $this->currentItem['itemid'];\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::parse_editpopupcode()\r
+        * Parse templatevar editpopupcode\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function parse_editpopupcode()\r
+       {\r
+               echo "if (event &amp;&amp; event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=yes,width=600,height=550,left=10,top=10,status=yes,resizable=yes');winbm.focus();return false;";\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::highlightAndParse()\r
+        * Parses highlighted text, with limited actions only (to prevent not fully trusted team members\r
+        * from hacking your weblog.\r
+        * 'plugin variables in items' implementation by Andy\r
+        * \r
+        * @param       array   $data   \r
+        * @return      void\r
+        */\r
+       public function highlightAndParse(&$data)\r
+       {\r
+               $handler = new BodyActions($this->blog);
+               $handler->setTemplate($this->template);
+               $handler->setHighlight($this->strHighlight);
+               $handler->setCurrentItem($this->currentItem);
+               \r
+               $parser = new Parser($handler);\r
+               $parser->parse($handler->highlight($data));
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::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
+        * @return      boolean\r
+        */\r
+       protected function checkCondition($field, $name='', $value = '')\r
+       {\r
+               global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
+               \r
+               $condition = 0;\r
+               switch ( $field )\r
+               {\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
+                               $item =& $manager->getItem($this->currentItem['itemid'], 1, 1);\r
+                               $t_blog =& $manager->getBlog($item['blogid']);\r
+                               $condition = ($t_blog && ($t_blog->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 '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
+        * ItemActions::ifCategory()\r
+        *  Different checks for a category\r
+        *  \r
+        * @param       string  $key    key of category\r
+        * @param       string  $value  value for key of category\r
+        * @return      boolean\r
+        */\r
+       private function ifCategory($key = '', $value = '')\r
+       {\r
+               global $blog, $catid;\r
+               \r
+               // when no parameter is defined, just check if a category is selected\r
+               if ( ($key != 'catname' && $key != 'catid') || ($value == '') )\r
+               {\r
+                       return (boolean) $blog->isValidCategory($catid);\r
+               }\r
+               \r
+               // check category name\r
+               if ( $key == 'catname' )\r
+               {\r
+                       $value = $blog->getCategoryIdFromName($value);\r
+                       if ( $value == $catid )\r
+                       {\r
+                               return (boolean) $blog->isValidCategory($catid);\r
+                       }\r
+               }\r
+               \r
+               // check category id\r
+               if ( ($key == 'catid') && ($value == $catid) )\r
+               {\r
+                       return (boolean) $blog->isValidCategory($catid);\r
+               }\r
+               return FALSE;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::ifAuthor()\r
+        * Different checks for an author\r
+        * \r
+        * @param       string  $key    key of data for author\r
+        * @param       string  $value  value of data for author\r
+        * @return      boolean correct or not\r
+        */\r
+       private function ifAuthor($key = '', $value = '')\r
+       {\r
+               global $member, $manager;\r
+               \r
+               // when no parameter is defined, just check if author is current visitor\r
+               if ( ($key != 'isadmin' && $key != 'name') || ($key == 'name' && $value == '') )\r
+               {\r
+                       return (boolean) ((integer) $member->getID() > 0 && (integer) $member->getID() == (integer) $this->currentItem['authorid']);\r
+               }\r
+               \r
+               // check author name\r
+               if ( $key == 'name' )\r
+               {\r
+                       $value = strtolower($value);\r
+                       if ( $value == strtolower($this->currentItem['author']) )\r
+                       {\r
+                               return TRUE;\r
+                       }\r
+               }\r
+               \r
+               // check if author is admin\r
+               if ( ($key == 'isadmin') )\r
+               {\r
+                       $i_author =& $manager->getMember($this->currentItem['authorid']);\r
+                       if ( $i_author->isAdmin() )\r
+                       {\r
+                               return TRUE;\r
+                       }\r
+                       return (boolean) $i_author->isBlogAdmin($this->currentItem['blogid']);\r
+               }\r
+               \r
+               return FALSE;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::ifItemCategory()\r
+        * Different checks for a category\r
+        * \r
+        * @param       string  $key    key of data for category to which item belongs\r
+        * @param       string  $value  value of data for category to which item belongs\r
+        * @return boolean      correct or not\r
+        */\r
+       private function ifItemCategory($key = '', $value='')\r
+       {\r
+               global $catid, $manager;\r
+               \r
+               $blog =& $manager->getBlog($this->currentItem['blogid']);\r
+               \r
+               // when no parameter is defined, just check if a category is selected\r
+               if ( ($key != 'catname' && $key != 'catid') || ($value == '') )\r
+               {\r
+                       return (boolean) $blog->isValidCategory($catid);\r
+               }\r
+               \r
+               $icatid = $this->currentItem['catid'];\r
+               \r
+               // check category name\r
+               if ( $key == 'catname' )\r
+               {\r
+                       $value = $blog->getCategoryIdFromName($value);\r
+                       if ( $value == $icatid )\r
+                       {\r
+                               return (boolean) $blog->isValidCategory($icatid);\r
+                       }\r
+               }\r
+               \r
+               // check category id\r
+               if ( ($key == 'catid') && ($value == $icatid) )\r
+               {\r
+                       return (boolean) $blog->isValidCategory($icatid);\r
+               }\r
+               return FALSE;\r
+       }\r
+\r
+       \r
+       /**\r
+        * ItemActions::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 correct or not\r
+        */\r
+       private function ifOnTeam($blogName = '')\r
+       {\r
+               global $blog, $member, $manager;\r
+               \r
+               // when no blog found\r
+               if ( ($blogName == '') && (!is_object($blog)) )\r
+               {\r
+                       return 0;\r
+               }\r
+               \r
+               // explicit blog selection\r
+               if ( $blogName != '' )\r
+               {\r
+                       $blogid = getBlogIDFromName($blogName);\r
+               }\r
+               \r
+               // use current blog\r
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
+               {\r
+                       $blogid = $blog->getID();\r
+               }\r
+               return (boolean) $member->teamRights($blogid);\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::ifAdmin()\r
+        * Checks if a member is admin of a blog\r
+        * \r
+        * @param       string  $blogName       name of weblog\r
+        * @return      boolean correct or not\r
+        */\r
+       private function ifAdmin($blogName = '')\r
+       {\r
+               global $blog, $member, $manager;\r
+               \r
+               // when no blog found\r
+               if ( ($blogName == '') && (!is_object($blog)) )\r
+               {\r
+                       return 0;\r
+               }\r
+               \r
+               // explicit blog selection\r
+               if ( $blogName != '' )\r
+               {\r
+                       $blogid = getBlogIDFromName($blogName);\r
+               }\r
+               \r
+               // use current blog\r
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
+               {\r
+                       $blogid = $blog->getID();\r
+               }\r
+               return (boolean) $member->isBlogAdmin($blogid);\r
+       }\r
+       \r
+       \r
+       /**\r
+        * ItemActions::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  key (and value) of plugin option\r
+        * @return      boolean correct or not\r
+        */\r
+       private function ifHasPlugin($name, $value)\r
+       {\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
+               {\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 (boolean) $condition;\r
+       }\r
+       \r
+       /**\r
+        * ItemActions::ifPlugin()\r
+        * Checks if a plugin exists and call its doIf function\r
+        * \r
+        * @param       string  $name   name of plugin\r
+        * @param       string  $key    key of plugin option\r
+        * @param       string  $value  value of plugin option\r
+        * @return      boolean callback output from plugin\r
+        */\r
+       private function ifPlugin($name, $key = '', $value = '')\r
+       {\r
+               global $manager;\r
+               \r
+               $plugin =& $manager->getPlugin("NP_{$name}");\r
+               if ( !$plugin )\r
+               {\r
+                       return;\r
+               }\r
+               $params = func_get_args();\r
+               array_shift($params);\r
+               \r
+               return (boolean) call_user_func_array(array(&$plugin, 'doIf'), $params);\r
+       }\r
+}
\ No newline at end of file