<?php\r
/*\r
* Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2012 The Nucleus Group\r
+ * Copyright (C) 2002-2009 The Nucleus Group\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
* This class is used to parse item templates\r
*\r
* @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
- * @version $Id: ITEMACTIONS.php 1699 2012-03-10 15:46:32Z sakamocchi $\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
- // contains an assoc array with parameters that need to be included when\r
- // generating links to items/archives/... (e.g. catid)\r
- var $linkparams;\r
-\r
- // true when the current user is a blog admin (and thus allowed to edit all items)\r
- var $allowEditAll;\r
-\r
- // timestamp of last visit\r
- var $lastVisit;\r
-\r
- // item currently being handled (mysql result object, see Blog::showUsingQuery)\r
- var $currentItem;\r
-\r
- // reference to the blog currently being displayed\r
- var $blog;\r
-\r
- // associative array with template info (part name => contents)\r
- var $template;\r
-\r
- // true when comments need to be displayed\r
- var $showComments;\r
-\r
- function __construct(&$blog) {\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',
+ 'syndicate_description',
+ 'syndicate_title',
+ 'time',
+ 'title',
+ /* actions defined in BodyAction class */
+ 'image',\r
+ 'media',
+ '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
// call constructor of superclass first\r
- $this->BaseActions();\r
-\r
+ parent::__construct();
+ \r
// extra parameters for created links\r
- global $catid;\r
- if ($catid)\r
+ if ( $catid )\r
+ {\r
$this->linkparams = array('catid' => $catid);\r
-\r
+ }\r
+ \r
// check if member is blog admin (and thus allowed to edit all items)\r
- global $member;\r
$this->allowEditAll = ($member->isLoggedIn() && $member->blogAdminRights($blog->getID()));\r
$this->setBlog($blog);\r
+ return;\r
}\r
-\r
+ \r
/**\r
- * Returns an array with the actions that are defined\r
- * in the ItemActions class\r
- */\r
- function getDefinedActions() {\r
- return array(\r
- 'blogid',\r
- 'title',\r
- 'body',\r
- 'more',\r
- 'smartbody',\r
- 'itemid',\r
- 'morelink',\r
- 'category',\r
- 'categorylink',\r
- 'author',\r
- 'authorid',\r
- 'authorlink',\r
- 'catid',\r
- 'karma',\r
- 'date',\r
- 'time',\r
- 'query',\r
- 'itemlink',\r
- 'blogurl',\r
- 'closed',\r
- 'syndicate_title',\r
- 'syndicate_description',\r
- 'karmaposlink',\r
- 'karmaneglink',\r
- 'new',\r
- 'image',\r
- 'popup',\r
- 'media',\r
- 'daylink',\r
- 'query',\r
- 'include',\r
- 'phpinclude',\r
- 'parsedinclude',\r
- 'skinfile',\r
- 'set',\r
- 'plugin',\r
- 'edit',\r
- 'editlink',\r
- 'editpopupcode',\r
- 'comments',\r
- 'relevance',\r
- 'if',\r
- 'else',\r
- 'endif',\r
- 'elseif',\r
- 'ifnot',\r
- 'elseifnot'\r
- );\r
+ * ItemActions::getDefinedActions()\r
+ * Returns an array with the actions that are defined\r
+ * in the ItemActions class\r
+ * \r
+ * @static
+ * @param void\r
+ * @return void\r
+ */\r
+ static public function getDefinedActions()
+ {\r
+ return array_merge(self::$defined_actions, parent::getDefinedActions());
}\r
-\r
- function setLastVisit($lastVisit) {\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
- function setParser(&$parser) {\r
+ \r
+ /**\r
+ * ItemActions::setParser()\r
+ * \r
+ * @param object &$parser instance of Parser class\r
+ * @return void\r
+ */\r
+ public function setParser(&$parser)\r
+ {\r
$this->parser =& $parser;\r
+ return;\r
}\r
-\r
- function setCurrentItem(&$item) {\r
- $this->currentItem =& $item;\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
- function setBlog(&$blog) {\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
- function setTemplate($template) {\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
- function setShowComments($val) {\r
- $this->showComments = $val;\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
- // methods used by parser to insert content\r
-\r
-\r
+ \r
/**\r
+ * ItemActions::parse_blogid()\r
* Parse templatevar blogid\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_blogid() {\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
- function parse_body() {\r
+ public function parse_body()\r
+ {\r
$this->highlightAndParse($this->currentItem->body);\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_more()\r
* Parse templatevar more\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_more() {\r
+ public function parse_more()\r
+ {\r
$this->highlightAndParse($this->currentItem->more);\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_itemid()\r
* Parse templatevar itemid\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_itemid() {\r
+ public function parse_itemid()\r
+ {\r
echo $this->currentItem->itemid;\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_category()\r
* Parse templatevar category\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_category() {\r
+ public function parse_category()\r
+ {\r
echo $this->currentItem->category;\r
+ return;\r
}\r
-\r
+ \r
/**\r
* ItemActions::parse_categorylink()\r
* Parse templatevar categorylink\r
* \r
- * @param Void\r
- * @return Void\r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_categorylink()\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
/**\r
+ * ItemActions::parse_catid()\r
* Parse templatevar catid\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_catid() {\r
+ public function parse_catid()\r
+ {\r
echo $this->currentItem->catid;\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_authorid()\r
* Parse templatevar authorid\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_authorid() {\r
+ public function parse_authorid()\r
+ {\r
echo $this->currentItem->authorid;\r
+ return;\r
}\r
-\r
+ \r
/**\r
* ItemActions::parse_authorlink()\r
* Parse templatevar authorlink\r
* \r
- * @param Void\r
- * @return Void\r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_authorlink()\r
+ public function parse_authorlink()\r
{\r
- echo Link::create_link(\r
- 'member',\r
- array(\r
+ $data = array(\r
'memberid' => $this->currentItem->authorid,\r
'name' => $this->currentItem->author,\r
'extra' => $this->linkparams\r
- )\r
- );\r
+ );\r
+ \r
+ echo Link::create_link('member', $data);\r
return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_query()\r
* Parse templatevar query\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_query() {\r
+ public function parse_query()\r
+ {\r
echo $this->strHighlight;\r
+ return;\r
}\r
-\r
+ \r
/**\r
* ItemActions::parse_itemlink()\r
* Parse templatevar itemlink\r
* \r
- * @param Void\r
- * @return Void\r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_itemlink()\r
+ public function parse_itemlink()\r
{\r
- echo Link::create_link(\r
- 'item',\r
- array(\r
- 'itemid' => $this->currentItem->itemid,\r
- 'title' => $this->currentItem->title,\r
- 'timestamp' => $this->currentItem->timestamp,\r
- 'extra' => $this->linkparams\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
- function parse_blogurl() {\r
+ public function parse_blogurl()\r
+ {\r
echo $this->blog->getURL();\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_closed()\r
* Parse templatevar closed\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_closed() {\r
+ public function parse_closed()\r
+ {\r
echo $this->currentItem->closed;\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_relevance()\r
* Parse templatevar relevance\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_relevance() {\r
+ public function parse_relevance()\r
+ {\r
echo round($this->currentItem->score,2);\r
+ return;\r
}\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
+ * @param string $format defines in which format the title is shown\r
+ * @return void\r
*/\r
- function parse_title($format = '')\r
+ public function parse_title($format = '')\r
{\r
if ( is_array($this->currentItem) )\r
{\r
}\r
return;\r
}\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
- function parse_karma($type = 'totalscore') {\r
+ public function parse_karma($type = 'totalscore')\r
+ {\r
global $manager;\r
-\r
+ \r
// get karma object\r
$karma =& $manager->getKarma($this->currentItem->itemid);\r
-\r
- switch($type) {\r
+ \r
+ switch ( $type )\r
+ {\r
case 'pos':\r
echo $karma->getNbPosVotes();\r
break;\r
echo $karma->getTotalScore();\r
break;\r
}\r
-\r
+ return;\r
}\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
- function parse_author($which = '') {\r
- switch($which)\r
+ public function parse_author($which = '')\r
+ {\r
+ switch ( $which )\r
{\r
case 'realname':\r
echo $this->currentItem->authorname;\r
default:\r
echo $this->currentItem->author;\r
}\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_smartbody()\r
* Parse templatevar smartbody\r
+ * \r
+ * @param void\r
+ * @return void\r
*/\r
- function parse_smartbody() {\r
- if (!$this->currentItem->more) {\r
+ public function parse_smartbody()\r
+ {\r
+ if ( !$this->currentItem->more )\r
+ {\r
$this->highlightAndParse($this->currentItem->body);\r
- } else {\r
+ }\r
+ else\r
+ {\r
$this->highlightAndParse($this->currentItem->more);\r
}\r
+ return;\r
}\r
-\r
+ \r
/**\r
+ * ItemActions::parse_morelink()\r
* Parse templatevar morelink\r
*/\r
- function parse_morelink() {\r
- if ($this->currentItem->more)\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
* @param string $format format optional strftime format\r
* @return void\r
*/\r
- function parse_date($format = '')\r
+ public function parse_date($format = '')\r
{\r
if ( $format !== '' )\r
{\r
* ItemActions::parse_time()\r
* Parse templatevar time\r
*\r
- * @param string $format format optional strftime format\r
+ * @param string $format format optional strftime format\r
* @return void\r
- * \r
*/\r
- function parse_time($format = '')\r
+ public function parse_time($format = '')\r
{\r
if ( $format !== '' )\r
{\r
echo i18n::formatted_datetime($format, $this->currentItem->timestamp);\r
return;\r
}\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
+ * @param string $maxLength maxLength optional maximum length\r
+ * @return string syndicated title\r
*/\r
- function parse_syndicate_title($maxLength = 100) {\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
* 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
+ * @param stromg $maxLength maxlength optional maximum length\r
+ * @param string $addHighlight highlighted string\r
+ * @return void\r
*/\r
- function parse_syndicate_description($maxLength = 250, $addHighlight = 0)\r
+ public function parse_syndicate_description($maxLength = 250, $addHighlight = 0)\r
{\r
$syndicated = strip_tags($this->currentItem->body);\r
if ( $addHighlight )\r
}\r
\r
/**\r
- * Parse templatevar karmaposlink\r
- *\r
- * @param string text\r
- */\r
- function parse_karmaposlink($text = '') {\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&itemid='.$this->currentItem->itemid;\r
- echo $text ? '<a href="'.$link.'">'.$text.'</a>' : $link;\r
+ $link = $CONF['ActionURL'] . '?action=votepositive&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
/**\r
- * Parse templatevar karmaneglink\r
- *\r
- * @param string text\r
- */\r
- function parse_karmaneglink($text = '') {\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&itemid='.$this->currentItem->itemid;\r
- echo $text ? '<a href="'.$link.'">'.$text.'</a>' : $link;\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
- * Parse templatevar new\r
- */\r
- function parse_new() {\r
- if (($this->lastVisit != 0) && ($this->currentItem->timestamp > $this->lastVisit))\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
+ * @param void\r
+ * @return void\r
*/\r
- function parse_daylink()\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
+ 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
- * Parse templatevar comments\r
- */\r
- function parse_comments($maxToShow = 0) {\r
- if ($maxToShow == 0)\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
+ \r
// add comments\r
- if ($this->showComments && $this->blog->commentsEnabled()) {\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
/**\r
- * Executes a plugin templatevar\r
- *\r
- * @param pluginName name of plugin (without the NP_)\r
- *\r
- * extra parameters can be added\r
- */\r
- function parse_plugin($pluginName) {\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
- // 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
- $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
- if (!$plugin) return;\r
-\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
+ \r
// remove plugin name\r
array_shift($params);\r
-\r
+ \r
// add item reference (array_unshift didn't work)\r
$params = array_merge(array(&$this->currentItem),$params);\r
-\r
+ \r
call_user_func_array(array(&$plugin,'doTemplateVar'), $params);\r
+ return;\r
}\r
-\r
+ \r
/**\r
- * Parse templatevar edit\r
- */\r
- function parse_edit() {\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
+ 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
/**\r
- * Parse templatevar editlink\r
- */\r
- function parse_editlink() {\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&itemid=',$this->currentItem->itemid;\r
+ echo $CONF['AdminURL'] . 'bookmarklet.php?action=edit&itemid=' . $this->currentItem->itemid;\r
+ return;\r
}\r
-\r
+ \r
/**\r
- * Parse templatevar editpopupcode\r
- */\r
- function parse_editpopupcode() {\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 && 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
- // helper functions\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
- function highlightAndParse(&$data) {\r
+ public function highlightAndParse(&$data)\r
+ {\r
$actions = new BodyActions($this->blog);\r
$parser = new Parser($actions->getDefinedActions(), $actions);\r
$actions->setTemplate($this->template);\r
$actions->setHighlight($this->strHighlight);\r
$actions->setCurrentItem($this->currentItem);\r
- //$actions->setParser($parser);\r
$parser->parse($actions->highlight($data));\r
+ return;\r
}\r
-\r
- /*\r
- // this is the function previous to the 'plugin variables in items' implementation by Andy\r
- function highlightAndParse(&$data) {\r
- // allow only a limited subset of actions (do not allow includes etc, they might be evil)\r
- $this->parser->actions = array('image','media','popup');\r
- $tmp_highlight = $this->highlight($data);\r
- $this->parser->parse($tmp_highlight);\r
- $this->parser->actions = $this->getDefinedActions();\r
- }\r
- */\r
- \r
- // function to enable if-else-elseif-elseifnot-ifnot-endif to item template fields\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
+ * @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
- function checkCondition($field, $name='', $value = '') {\r
+ private function checkCondition($field, $name='', $value = '')\r
+ {\r
global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
-\r
+ \r
$condition = 0;\r
- switch($field) {\r
+ switch ( $field )\r
+ {\r
case 'category':\r
- $condition = ($blog && $this->_ifCategory($name,$value));\r
+ $condition = ($blog && $this->ifCategory($name,$value));\r
break;\r
case 'itemcategory':\r
- $condition = ($this->_ifItemCategory($name,$value));\r
+ $condition = ($this->ifItemCategory($name,$value));\r
break;\r
case 'blogsetting':\r
$condition = ($blog && ($blog->getSetting($name) == $value));\r
$condition = $member->isLoggedIn();\r
break;\r
case 'onteam':\r
- $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);\r
+ $condition = $member->isLoggedIn() && $this->ifOnTeam($name);\r
break;\r
case 'admin':\r
- $condition = $member->isLoggedIn() && $this->_ifAdmin($name);\r
+ $condition = $member->isLoggedIn() && $this->ifAdmin($name);\r
break;\r
case 'author':\r
- $condition = ($this->_ifAuthor($name,$value));\r
- break;\r
-/* case 'nextitem':\r
- $condition = ($itemidnext != '');\r
- break;\r
- case 'previtem':\r
- $condition = ($itemidprev != '');\r
- break;\r
- case 'archiveprevexists':\r
- $condition = ($archiveprevexists == true);\r
+ $condition = ($this->ifAuthor($name,$value));\r
break;\r
- case 'archivenextexists':\r
- $condition = ($archivenextexists == true);\r
- break; \r
- case 'skintype':\r
- $condition = ($name == $this->skintype);\r
- break; */\r
case 'hasplugin':\r
- $condition = $this->_ifHasPlugin($name, $value);\r
+ $condition = $this->ifHasPlugin($name, $value);\r
break;\r
default:\r
- $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);\r
+ $condition = $manager->pluginInstalled('NP_' . $field) && $this->ifPlugin($field, $name, $value);\r
break;\r
}\r
return $condition;\r
} \r
\r
/**\r
+ * 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
- function _ifCategory($name = '', $value='') {\r
+ private function ifCategory($key = '', $value = '')\r
+ {\r
global $blog, $catid;\r
-\r
+ \r
// when no parameter is defined, just check if a category is selected\r
- if (($name != 'catname' && $name != 'catid') || ($value == ''))\r
- return $blog->isValidCategory($catid);\r
-\r
+ if ( ($key != 'catname' && $key != 'catid') || ($value == '') )\r
+ {\r
+ return (boolean) $blog->isValidCategory($catid);\r
+ }\r
+ \r
// check category name\r
- if ($name == 'catname') {\r
+ if ( $key == 'catname' )\r
+ {\r
$value = $blog->getCategoryIdFromName($value);\r
- if ($value == $catid)\r
- return $blog->isValidCategory($catid);\r
+ if ( $value == $catid )\r
+ {\r
+ return (boolean) $blog->isValidCategory($catid);\r
+ }\r
}\r
-\r
+ \r
// check category id\r
- if (($name == 'catid') && ($value == $catid))\r
- return $blog->isValidCategory($catid);\r
-\r
- return false;\r
+ if ( ($key == 'catid') && ($value == $catid) )\r
+ {\r
+ return (boolean) $blog->isValidCategory($catid);\r
+ }\r
+ return FALSE;\r
}\r
\r
- \r
/**\r
- * Different checks for an author\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
- function _ifAuthor($name = '', $value='') {\r
+ private function ifAuthor($key = '', $value = '')\r
+ {\r
global $member, $manager;\r
\r
$b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));\r
-\r
+ \r
// when no parameter is defined, just check if author is current visitor\r
- if (($name != 'isadmin' && $name != 'name') || ($name == 'name' && $value == '')) {\r
- return (intval($member->getID()) > 0 && intval($member->getID()) == intval($this->currentItem->authorid));\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
+ \r
// check author name\r
- if ($name == 'name') {\r
+ if ( $key == 'name' )\r
+ {\r
$value = strtolower($value);\r
- if ($value == strtolower($this->currentItem->author))\r
- return true;\r
+ if ( $value == strtolower($this->currentItem->author) )\r
+ {\r
+ return TRUE;\r
+ }\r
}\r
-\r
+ \r
// check if author is admin\r
- if (($name == 'isadmin')) { \r
+ if ( ($key == 'isadmin') )\r
+ {\r
$aid = intval($this->currentItem->authorid);\r
$blogid = intval($b->getID()); \r
$amember =& $manager->getMember($aid);\r
- if ($amember->isAdmin())\r
- return true;\r
- \r
- return $amember->isBlogAdmin($blogid);\r
+ if ( $amember->isAdmin() )\r
+ {\r
+ return TRUE;\r
+ }\r
+ return (boolean) $amember->isBlogAdmin($blogid);\r
}\r
-\r
- return false;\r
+ \r
+ return FALSE;\r
}\r
\r
/**\r
- * Different checks for a category\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
- function _ifItemCategory($name = '', $value='') {\r
+ private function ifItemCategory($key = '', $value='')\r
+ {\r
global $catid, $manager;\r
\r
$b =& $manager->getBlog(getBlogIDFromItemID($this->currentItem->itemid));\r
-\r
+ \r
// when no parameter is defined, just check if a category is selected\r
- if (($name != 'catname' && $name != 'catid') || ($value == ''))\r
- return $b->isValidCategory($catid);\r
- \r
+ if ( ($key != 'catname' && $key != 'catid') || ($value == '') )\r
+ {\r
+ return (boolean) $b->isValidCategory($catid);\r
+ }\r
+ \r
$icatid = $this->currentItem->catid;\r
- //$icategory = $this->currentItem->category;\r
-\r
+ \r
// check category name\r
- if ($name == 'catname') {\r
+ if ( $key == 'catname' )\r
+ {\r
$value = $b->getCategoryIdFromName($value);\r
- if ($value == $icatid)\r
- return $b->isValidCategory($icatid);\r
+ if ( $value == $icatid )\r
+ {\r
+ return (boolean) $b->isValidCategory($icatid);\r
+ }\r
}\r
-\r
+ \r
// check category id\r
- if (($name == 'catid') && ($value == $icatid))\r
- return $b->isValidCategory($icatid);\r
-\r
- return false;\r
+ if ( ($key == 'catid') && ($value == $icatid) )\r
+ {\r
+ return (boolean) $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
+ * 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
- function _ifOnTeam($blogName = '') {\r
+ private function ifOnTeam($blogName = '')\r
+ {\r
global $blog, $member, $manager;\r
-\r
+ \r
// when no blog found\r
- if (($blogName == '') && (!is_object($blog)))\r
+ if ( ($blogName == '') && (!is_object($blog)) )\r
+ {\r
return 0;\r
-\r
+ }\r
+ \r
// explicit blog selection\r
- if ($blogName != '')\r
+ if ( $blogName != '' )\r
+ {\r
$blogid = getBlogIDFromName($blogName);\r
-\r
- if (($blogName == '') || !$manager->existsBlogID($blogid))\r
- // use current blog\r
+ }\r
+ \r
+ // use current blog\r
+ if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
+ {\r
$blogid = $blog->getID();\r
-\r
- return $member->teamRights($blogid);\r
+ }\r
+ return (boolean) $member->teamRights($blogid);\r
}\r
-\r
+ \r
/**\r
- * Checks if a member is admin of a blog\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
- function _ifAdmin($blogName = '') {\r
+ private function ifAdmin($blogName = '')\r
+ {\r
global $blog, $member, $manager;\r
-\r
+ \r
// when no blog found\r
- if (($blogName == '') && (!is_object($blog)))\r
+ if ( ($blogName == '') && (!is_object($blog)) )\r
+ {\r
return 0;\r
-\r
+ }\r
+ \r
// explicit blog selection\r
- if ($blogName != '')\r
+ if ( $blogName != '' )\r
+ {\r
$blogid = getBlogIDFromName($blogName);\r
-\r
- if (($blogName == '') || !$manager->existsBlogID($blogid))\r
- // use current blog\r
+ }\r
+ \r
+ // use current blog\r
+ if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
+ {\r
$blogid = $blog->getID();\r
-\r
- return $member->isBlogAdmin($blogid);\r
+ }\r
+ return (boolean) $member->isBlogAdmin($blogid);\r
}\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
- function _ifHasPlugin($name, $value) {\r
+ private function ifHasPlugin($name, $value)\r
+ {\r
global $manager;\r
- $condition = false;\r
+ $condition = FALSE;\r
// (pluginInstalled method won't write a message in the actionlog on failure)\r
- if ($manager->pluginInstalled('NP_'.$name)) {\r
+ if ( $manager->pluginInstalled("NP_{$name}"))\r
+ {\r
$plugin =& $manager->getPlugin('NP_' . $name);\r
- if ($plugin != NULL) {\r
- if ($value == "") {\r
- $condition = true;\r
- } else {\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
- $condition = true;\r
- } else if ($plugin->getOption($name2) == $value2) {\r
- $condition = true;\r
+ if ( $value2 == "" && $plugin->getOption($name2) != 'no' )\r
+ {\r
+ $condition = TRUE;\r
+ }\r
+ else if ( $plugin->getOption($name2) == $value2 )\r
+ {\r
+ $condition = TRUE;\r
}\r
}\r
}\r
}\r
- return $condition;\r
+ return (boolean) $condition;\r
}\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
- function _ifPlugin($name, $key = '', $value = '') {\r
+ private function ifPlugin($name, $key = '', $value = '')\r
+ {\r
global $manager;\r
-\r
- $plugin =& $manager->getPlugin('NP_' . $name);\r
- if (!$plugin) return;\r
-\r
+ \r
+ $plugin =& $manager->getPlugin("NP_{$name}");\r
+ if ( !$plugin )\r
+ {\r
+ return;\r
+ }\r
$params = func_get_args();\r
array_shift($params);\r
-\r
- return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
+ \r
+ return (boolean) call_user_func_array(array(&$plugin, 'doIf'), $params);\r
}\r
-\r
-}\r
-\r
-?>\r
+}
\ No newline at end of file