OSDN Git Service

MERGE: リビジョン1755のマージ。SkinクラスでActionsクラス以外のバックエンドクラスを利用可能に。
authorsakamocchi <o-takashi@sakamocchi.jp>
Sat, 14 Apr 2012 10:17:15 +0000 (19:17 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Sat, 14 Apr 2012 10:17:15 +0000 (19:17 +0900)
管理画面をスキン/テンプレートシステムで構成する基盤として、Actionsクラスに関係するコードをSkinクラスからActionsクラスに移動し、関連する修正を行った。これにより、SkinクラスはActionsクラス以外のバックエンドクラスを利用可能となった。

Revision 1755: CHANGE: modification to allow Skin class to utilize the
others than Actions class

Moving some codes related to Actions class into Actions class and add
some members and methods.
Actions::$default_actions
Actions::getDefinedActions()
Actions::$skin_type_friendly_names
Actions::getSkinTypeFriendlyNames()

Then adding some arguments to Skin::__construct() and
Skin::getFriendlyNames() to indicate an backend class and an event
identifier.

Add $template['friendly_names'] in Admin::action_skinoverview() and pass
it into listplug_table_skinlist() to display skin types.

http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1755

nucleus/libs/ACTIONS.php
nucleus/libs/ADMIN.php
nucleus/libs/SKIN.php
nucleus/libs/showlist.php

index e75f5c0..61e8343 100644 (file)
-<?php\r
-/**\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2012 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 contains the functions that get called by using\r
- * the special tags in the skins\r
- *\r
- * The allowed tags for a type of skinpart are defined by the\r
- * Skin::getAllowedActionsForType($type) method\r
- *\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
- * @version $Id: ACTIONS.php 1725 2012-04-07 02:21:32Z sakamocchi $\r
- */\r
-\r
-class Actions extends BaseActions\r
-{\r
-       // part of the skin currently being parsed ('index', 'item', 'archive',\r
-       // 'archivelist', 'member', 'search', 'error', 'imagepopup')\r
-       var $skintype;\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
-       // reference to the skin object for which a part is being parsed\r
-       var $skin;\r
-       \r
-       // used when including templated forms from the include/ dir. The $formdata var\r
-       // contains the values to fill out in there (assoc array name -> value)\r
-       var $formdata;\r
-       \r
-       // filled out with the number of displayed items after calling one of the\r
-       // (other)blog/(other)searchresults skinvars.\r
-       var $amountfound;\r
-       \r
-       /**\r
-        * Actions::__construct()\r
-        * Constructor for a new Actions object\r
-        * \r
-        * @param       string  $type\r
-        * @return      void\r
-        */\r
-       public function __construct($type)\r
-       {\r
-               global $catid;\r
-               \r
-               // call constructor of superclass first\r
-               $this->BaseActions();\r
-               $this->skintype = $type;\r
-               \r
-               if ( $catid )\r
-               {\r
-                       $this->linkparams = array('catid' => $catid);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::setSkin()\r
-        * Set the skin\r
-        * @param       object  $skin   an instance of Skin class\r
-        * @return      void\r
-        */\r
-       public function setSkin(&$skin)\r
-       {\r
-               $this->skin =& $skin;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::setParser()\r
-        * Set the parser\r
-        * \r
-        * @param       object  $parser an instance of Parser class\r
-        * @return      void\r
-        */\r
-       public function setParser(&$parser)\r
-       {\r
-               $this->parser =& $parser;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::doForm()\r
-        * Forms get parsedincluded now, using an extra <formdata> skinvar\r
-        *\r
-        * @param       string  $filename\r
-        * @return      void\r
-        */\r
-       public function doForm($filename)\r
-       {\r
-               global $DIR_NUCLEUS;\r
-               array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');\r
-               \r
-               $oldIncludeMode = Parser::getProperty('IncludeMode');\r
-               $oldIncludePrefix = Parser::getProperty('IncludePrefix');\r
-               Parser::setProperty('IncludeMode','normal');\r
-               Parser::setProperty('IncludePrefix','');\r
-               \r
-               $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');\r
-               Parser::setProperty('IncludeMode',$oldIncludeMode);\r
-               Parser::setProperty('IncludePrefix',$oldIncludePrefix);\r
-               \r
-               array_pop($this->parser->actions);      // errordiv\r
-               array_pop($this->parser->actions);      // callback\r
-               array_pop($this->parser->actions);      // text\r
-               array_pop($this->parser->actions);      // formdata\r
-               array_pop($this->parser->actions);      // ticket\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Actions::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 condition\r
-        */\r
-       public 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 'blogsetting':\r
-                               $condition = ($blog && ($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
+<?php
+/**
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2012 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 contains the functions that get called by using
+ * the special tags in the skins
+ *
+ * The allowed tags for a type of skinpart are defined by the
+ * Skin::getAllowedActionsForType($type) method
+ *
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
+ * @version $Id: ACTIONS.php 1755 2012-04-14 10:05:49Z sakamocchi $
+ */
+
+class Actions extends BaseActions
+{
+       // part of the skin currently being parsed ('index', 'item', 'archive',
+       // 'archivelist', 'member', 'search', 'error', 'imagepopup')
+       private $skintype;
+       
+       // contains an assoc array with parameters that need to be included when
+       // generating links to items/archives/... (e.g. catid)
+       private $linkparams;
+       
+       // reference to the skin object for which a part is being parsed
+       private $skin;
+       
+       // used when including templated forms from the include/ dir. The $formdata var
+       // contains the values to fill out in there (assoc array name -> value)
+       private $formdata;
+       
+       // filled out with the number of displayed items after calling one of the
+       // (other)blog/(other)searchresults skinvars.
+       private $amountfound;
+       
+       /**
+        * Actions::$default_actions
+        * list of whole action names with which this class can deal
+        */
+       static private $default_actions = array(
+               'addlink',
+               'addpopupcode',
+               'adminurl',
+               'archivelink',
+               'bloglist',
+               'category',
+               'charset',
+               'else',
+               'elseif',
+               'elseifnot',
+               'endif',
+               'if',
+               'ifnot',
+               'include',
+               'loginform',
+               'member',
+               'nucleusbutton',
+               'otherarchivedaylist',
+               'otherarchivelist',
+               'otherarchiveyearlist',
+               'otherblog',
+               'parsedinclude',
+               'phpinclude',
+               'plugin',
+               'referer',
+               'searchform',
+               'self',
+               'set',
+               'sitevar',
+               'skinfile',
+               'skinname',
+               'sticky',
+               'todaylink',
+               'version',
+               // deprecated (Nucleus v2.0)
+               /* TODO: remove this */
+               'ifcat'
+       );
+       
+       /**
+        * Actions::$page_type_friendly_names
+        * friendly name for wrapped page types
+        */
+       static public $skin_type_friendly_names = array(
+               'index'                 => _SKIN_PART_MAIN,
+               'item'                  => _SKIN_PART_ITEM,
+               'archivelist'   => _SKIN_PART_ALIST,
+               'archive'               => _SKIN_PART_ARCHIVE,
+               'search'                => _SKIN_PART_SEARCH,
+               'error'                 => _SKIN_PART_ERROR,
+               'member'                => _SKIN_PART_MEMBER,
+               'imagepopup'    => _SKIN_PART_POPUP
+       );
+       
+       /**
+        * Actions::getDefinedActions()
+        * 
+        * @static
+        * @param       string  $type   page type
+        * @return      array   allowed actions for the page type
+        */
+       static public function getDefinedActions($type='')
+       {
+               // extra actions specific for a certain skin type
+               $extra_actions = array();
+               
+               switch ( $type )
+               {
+                       case 'index':
+                               $extra_actions = array(
+                                       'blog',
+                                       'blogsetting',
+                                       'preview',
+                                       'additemform',
+                                       'categorylist',
+                                       'archivelist',
+                                       'archivedaylist',
+                                       'archiveyearlist',
+                                       'nextlink',
+                                       'prevlink'
+                               );
+                               break;
+                       case 'archive':
+                               $extra_actions = array(
+                                       'blog',
+                                       'archive',
+                                       'otherarchive',
+                                       'categorylist',
+                                       'archivelist',
+                                       'archivedaylist',
+                                       'archiveyearlist',
+                                       'blogsetting',
+                                       'archivedate',
+                                       'nextarchive',
+                                       'prevarchive',
+                                       'nextlink',
+                                       'prevlink',
+                                       'archivetype'
+                               );
+                               break;
+                       case 'archivelist':
+                               $extra_actions = array(
+                                       'blog',
+                                       'archivelist',
+                                       'archivedaylist',
+                                       'archiveyearlist',
+                                       'categorylist',
+                                       'blogsetting'
+                               );
+                               break;
+                       case 'search':
+                               $extra_actions = array(
+                                       'blog',
+                                       'archivelist',
+                                       'archivedaylist',
+                                       'archiveyearlist',
+                                       'categorylist',
+                                       'searchresults',
+                                       'othersearchresults',
+                                       'blogsetting',
+                                       'query',
+                                       'nextlink',
+                                       'prevlink'
+                               );
+                               break;
+                       case 'imagepopup':
+                               $extra_actions = array(
+                                       'image',
+                                       // deprecated (Nucleus v2.0)
+                                       /* TODO: remove this */
+                                       'imagetext'
+                               );
+                               break;
+                       case 'member':
+                               $extra_actions = array(
+                                       'membermailform',
+                                       'blogsetting',
+                                       'nucleusbutton',
+                                       'categorylist'
+                               );
+                               break;
+                       case 'item':
+                               $extra_actions = array(
+                                       'blog',
+                                       'item',
+                                       'comments',
+                                       'commentform',
+                                       'vars',
+                                       'blogsetting',
+                                       'nextitem',
+                                       'previtem',
+                                       'nextlink',
+                                       'prevlink',
+                                       'nextitemtitle',
+                                       'previtemtitle',
+                                       'categorylist',
+                                       'archivelist',
+                                       'archivedaylist',
+                                       'archiveyearlist',
+                                       'itemtitle',
+                                       'itemid',
+                                       'itemlink'
+                               );
+                               break;
+                       case 'error':
+                               $extra_actions = array(
+                                       'errormessage',
+                                       'categorylist'
+                               );
+                               break;
+                       default:
+                                       $extra_actions = array(
+                                               'blog',
+                                               'blogsetting',
+                                               'preview',
+                                               'additemform',
+                                               'categorylist',
+                                               'archivelist',
+                                               'archivedaylist',
+                                               'archiveyearlist',
+                                               'nextlink',
+                                               'prevlink',
+                                               'membermailform',
+                                               'nucleusbutton',
+                                               'categorylist'
+                                       );
+                               break;
+               }
+               return array_merge(self::$default_actions, $extra_actions);
+       }
+       
+       /**
+        * Actions::getSkinTypeFriendlyNames()
+        * 
+        * @static
+        * @param       void
+        * @return      array   list of friendly names for page actions
+        */
+       static public function getSkinTypeFriendlyNames()
+       {
+               return self::$skin_type_friendly_names;
+       }
+       
+       /**
+        * Actions::__construct()
+        * Constructor for a new Actions object
+        * 
+        * @param       string  $type
+        * @return      void
+        */
+       public function __construct($type)
+       {
+               global $catid;
+               
+               // call constructor of superclass first
+               $this->BaseActions();
+               $this->skintype = $type;
+               
+               if ( $catid )
+               {
+                       $this->linkparams = array('catid' => $catid);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::setSkin()
+        * Set the skin
+        * @param       object  $skin   an instance of Skin class
+        * @return      void
+        */
+       public function setSkin(&$skin)
+       {
+               $this->skin =& $skin;
+               return;
+       }
+       
+       /**
+        * Actions::setParser()
+        * Set the parser
+        * 
+        * @param       object  $parser an instance of Parser class
+        * @return      void
+        */
+       public function setParser(&$parser)
+       {
+               $this->parser =& $parser;
+               return;
+       }
+       
+       /**
+        * Actions::doForm()
+        * Forms get parsedincluded now, using an extra <formdata> skinvar
+        *
+        * @param       string  $filename
+        * @return      void
+        */
+       public function doForm($filename)
+       {
+               global $DIR_NUCLEUS;
+               array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');
+               
+               $oldIncludeMode = Parser::getProperty('IncludeMode');
+               $oldIncludePrefix = Parser::getProperty('IncludePrefix');
+               Parser::setProperty('IncludeMode','normal');
+               Parser::setProperty('IncludePrefix','');
+               
+               $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
+               Parser::setProperty('IncludeMode',$oldIncludeMode);
+               Parser::setProperty('IncludePrefix',$oldIncludePrefix);
+               
+               array_pop($this->parser->actions);      // errordiv
+               array_pop($this->parser->actions);      // callback
+               array_pop($this->parser->actions);      // text
+               array_pop($this->parser->actions);      // formdata
+               array_pop($this->parser->actions);      // ticket
+               return;
+       }
+
+       /**
+        * Actions::checkCondition()
+        * Checks conditions for if statements
+        *
+        * @param       string  $field  type of <%if%>
+        * @param       string  $name   property of field
+        * @param       string  $value  value of property
+        * @return      boolean condition
+        */
+       public 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 'blogsetting':
+                               $condition = ($blog && ($blog->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 'nextitem':\r
-                               $condition = ($itemidnext != '');\r
-                               break;\r
-                       case 'previtem':\r
-                               $condition = ($itemidprev != '');\r
-                               break;\r
-                       case 'archiveprevexists':\r
-                               $condition = ($archiveprevexists == true);\r
-                               break;\r
-                       case 'archivenextexists':\r
-                               $condition = ($archivenextexists == true);\r
-                               break;\r
-                       case 'skintype':\r
-                               $condition = (($name == $this->skintype) || ($name == requestVar('action')));\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
-        * Actions::_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  \r
-        * @return      \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 $condition;\r
-       }\r
-       \r
-       /**\r
-        * Actions::ifPlugin()\r
-        * Checks if a plugin exists and call its doIf function\r
-        * \r
-        * @param       string  $name   name of plugin\r
-        * @param       string  $key    name of plugin option\r
-        * @param       string  $value  value of plugin option\r
-        * @return      void\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
-               \r
-               $params = func_get_args();\r
-               array_shift($params);\r
-               \r
-               return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
-       }\r
-       \r
-       /**\r
-        * Actions::ifCategory()\r
-        * Different checks for a category\r
-        * \r
-        * @param       string  $name   \r
-        * @param       string  $value  \r
-        * @return      boolean \r
-        */\r
-       private function ifCategory($name = '', $value='')\r
-       {\r
-               global $blog, $catid;\r
-               \r
-               // when no parameter is defined, just check if a category is selected\r
-               if ( ($name != 'catname' && $name != 'catid') || ($value == '') )\r
-               {\r
-                       return $blog->isValidCategory($catid);\r
-               }\r
-               \r
-               // check category name\r
-               if ( $name == 'catname' )\r
-               {\r
-                       $value = $blog->getCategoryIdFromName($value);\r
-                       if ( $value == $catid )\r
-                       {\r
-                               return $blog->isValidCategory($catid);\r
-                       }\r
-               }\r
-               \r
-               // check category id\r
-               if ( ($name == 'catid') && ($value == $catid) )\r
-               {\r
-                       return $blog->isValidCategory($catid);\r
-               }\r
-               return FALSE;\r
-       }\r
-       \r
-       /**\r
-        * Actions::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      mixed\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
-               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
-               {\r
-                       // use current blog\r
-                       $blogid = $blog->getID();\r
-               }\r
-               \r
-               return $member->teamRights($blogid);\r
-       }\r
-\r
-       /**\r
-        * Actions::ifAdmin()\r
-        * Checks if a member is admin of a blog\r
-        * \r
-        * @param       string  $blogName       name of weblog\r
-        * @return      mixed\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
-               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
-               {\r
-                       // use current blog\r
-                       $blogid = $blog->getID();\r
-               }\r
-               \r
-               return $member->isBlogAdmin($blogid);\r
-       }\r
-       \r
-       /**\r
-        * Actions::link()\r
-        * returns either\r
-        *      - a raw link (html/xml encoded) when no linktext is provided\r
-        *      - a (x)html <a href... link when a text is present (text htmlencoded)\r
-        * \r
-        * @param       string  $url            URL for href attribute of anchor element\r
-        * @param       string  $linktext       content of anchor element\r
-        * @return      \r
-        */\r
-       private function link($url, $linktext = '')\r
-       {\r
-               $u = Entity::hsc($url);\r
-               // fix URLs that already had encoded ampersands\r
-               $u = preg_replace("#&amp;amp;#", '&amp;', $u);\r
-               if ( $linktext != '' )\r
-               {\r
-                       $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';\r
-               }\r
-               else\r
-               {\r
-                       $l = $u;\r
-               }\r
-               return $l;\r
-       }\r
-       \r
-       /**\r
-        * Actions::searchlink()\r
-        * Outputs a next/prev link\r
-        *\r
-        * @param $maxresults\r
-        *              The maximum amount of items shown per page (e.g. 10)\r
-        * @param $startpos\r
-        *              Current start position (requestVar('startpos'))\r
-        * @param $direction\r
-        *              either 'prev' or 'next'\r
-        * @param $linktext\r
-        *              When present, the output will be a full <a href...> link. When empty,\r
-        *              only a raw link will be outputted\r
-        */\r
-       private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')\r
-       {\r
-               global $CONF, $blog, $query, $amount;\r
-               // TODO: Move request uri to linkparams. this is ugly. sorry for that.\r
-               $startpos       = (integer) $startpos;\r
-               $parsed         = parse_url(serverVar('REQUEST_URI'));\r
-               $path           = $parsed['path'];\r
-               $parsed         = $parsed['query'];\r
-               $url            = '';\r
-               \r
-               if ( $direction == 'prev' )\r
-               {\r
-                       if ( intval($startpos) - intval($maxresults) >= 0 )\r
-                       {\r
-                               $startpos       = intval($startpos) - intval($maxresults);\r
-                               \r
-                               if ( $this->skintype == 'index' )\r
-                               {\r
-                                       $url = $path;\r
-                               }\r
-                               else if ( $this->skintype == 'search' )\r
-                               {\r
-                                       $url = $CONF['SearchURL'];\r
-                               }\r
-                               $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);\r
-                       }\r
-               }\r
-               else if ( $direction == 'next' )\r
-               {\r
-                       global $navigationItems;\r
-                       if ( !isset($navigationItems) )\r
-                       {\r
-                               $navigationItems = 0;\r
-                       }\r
-                       \r
-                       if ( $recount )\r
-                       {\r
-                               $iAmountOnPage = 0;\r
-                       }\r
-                       else \r
-                       {\r
-                               $iAmountOnPage = $this->amountfound;\r
-                       }\r
-                       \r
-                       if ( intval($navigationItems) > 0 )\r
-                       {\r
-                               $iAmountOnPage = intval($navigationItems) - intval($startpos);\r
-                       }\r
-                       elseif ( $iAmountOnPage == 0 )\r
-                       {\r
-                               /*\r
-                                * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]\r
-                                * try a count query\r
-                                */\r
-                               if ( $this->skintype == 'index' )\r
-                               {\r
-                                       $sqlquery = $blog->getSqlBlog('', 'count');\r
-                                       $url = $path;\r
-                               }\r
-                               else if ( $this->skintype == 'search' )\r
-                               {\r
-                                       $unused_highlight = '';\r
-                                       $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');\r
-                                       $url = $CONF['SearchURL'];\r
-                               }\r
-                               if ( $sqlquery )\r
-                               {\r
-                                       $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);\r
-                               }\r
-                       }\r
-                       \r
-                       $url = '';\r
-                       if ( intval($iAmountOnPage) >= intval($maxresults) )\r
-                       {\r
-                               $startpos        = intval($startpos) + intval($maxresults);\r
-                               $url            .= '?' . alterQueryStr($parsed, 'startpos', $startpos);\r
-                       }\r
-               }\r
-               \r
-               if ( $url != '' )\r
-               {\r
-                       echo $this->link($url, $linktext);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::itemlink()\r
-        * Creates an item link and if no id is given a todaylink \r
-        * \r
-        * @param       integer $id     id for link\r
-        * @param       string  $linktext       text for link\r
-        * @return      void\r
-        */\r
-       private function itemlink($id, $linktext = '')\r
-       {\r
-               global $CONF;\r
-               if ( $id != 0 )\r
-               {\r
-                       echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);\r
-               }\r
-               else\r
-               {\r
-                       $this->parse_todaylink($linktext);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::archivelink)\r
-        * Creates an archive link and if no id is given a todaylink \r
-        * \r
-        * @param       integer $id     id for link\r
-        * @param       string  $linktext       text for link\r
-        * @return      void\r
-        */\r
-       private function archivelink($id, $linktext = '')\r
-       {\r
-               global $CONF, $blog;\r
-               if ( $id != 0 )\r
-               {\r
-                       echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);\r
-               }\r
-               else\r
-               {\r
-                       $this->parse_todaylink($linktext);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions:setBlogCategory()\r
-        * Helper function that sets the category that a blog will need to use\r
-        *\r
-        * @param       string  $blog           An object of the blog class, passed by reference (we want to make changes to it)\r
-        * @param       string  $catname        The name of the category to use\r
-        * @return      void\r
-        */\r
-       private function setBlogCategory(&$blog, $catname)\r
-       {\r
-               global $catid;\r
-               if ( $catname != '' )\r
-               {\r
-                       $blog->setSelectedCategoryByName($catname);\r
-               }\r
-               else\r
-               {\r
-                       $blog->setSelectedCategory($catid);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::preBlogContent()\r
-        * Notifies the Manager that a PreBlogContent event occurs\r
-        * \r
-        * @param       string  $type   type of skin\r
-        * @param       object  $blog   an instance of Blog class\r
-        * @return      void\r
-        */\r
-       private function preBlogContent($type, &$blog)\r
-       {\r
-               global $manager;\r
-               $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Actions::postBlogContent()\r
-        * Notifies the Manager that a PostBlogContent event occurs\r
-        * \r
-        * @param       string  $type   type of skin\r
-        * @param       objecct $blog   an instance of Blog class\r
-        * @return      void\r
-        */\r
-       private function postBlogContent($type, &$blog)\r
-       {\r
-               global $manager;\r
-               $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_additemform()\r
-        * Parse skinvar additemform\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_additemform()\r
-       {\r
-               global $blog, $CONF;\r
-               $this->formdata = array(\r
-                       'adminurl'      => Entity::hsc($CONF['AdminURL']),\r
-                       'catid'         => $blog->getDefaultCategory()\r
-               );\r
-               $blog->InsertJavaScriptInfo();\r
-               $this->doForm('additemform');\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_addlink()\r
-        * Parse skinvar addlink\r
-        * A Link that allows to open a bookmarklet to add an item\r
-        */\r
-       public function parse_addlink()\r
-       {\r
-               global $CONF, $member, $blog;\r
-               if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )\r
-               {\r
-                       echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_addpopupcode()\r
-        * Parse skinvar addpopupcode\r
-        * Code that opens a bookmarklet in an popup window\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_addpopupcode()\r
-       {\r
-               echo "if (event &amp;&amp; event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');winbm.focus();return false;";\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Parse skinvar adminurl\r
-        * (shortcut for admin url)\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_adminurl()\r
-       {\r
-               $this->parse_sitevar('adminurl');\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_archive()\r
-        * Parse skinvar archive\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @return      \r
-        */\r
-       public function parse_archive($template, $category = '')\r
-       {\r
-               global $blog, $archive;\r
-               // can be used with either yyyy-mm or yyyy-mm-dd\r
-               sscanf($archive,'%d-%d-%d', $y, $m, $d);\r
-               $this->setBlogCategory($blog, $category);\r
-               $this->preBlogContent('achive',$blog);\r
-               $blog->showArchive($template, $y, $m, $d);\r
-               $this->postBlogContent('achive',$blog);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_archivedate()\r
-        * %archivedate(locale,date format)%\r
-        * \r
-        * @param       string  $locale\r
-        * @return      void\r
-        */\r
-       public function parse_archivedate($locale = '-def-')\r
-       {\r
-               global $archive;\r
-               \r
-               /* \r
-                * TODO: these lines are no meaning because there is no $template.\r
-               if ( $locale == '-def-' )\r
-               {\r
-                       setlocale(LC_TIME, $template['LOCALE']);\r
-               }\r
-               else\r
-               {\r
-                       setlocale(LC_TIME, $locale);\r
-               }\r
-                */\r
-               \r
-               // get archive date\r
-               sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
-               \r
-               // get format\r
-               $args = func_get_args();\r
-               // format can be spread over multiple parameters\r
-               if ( sizeof($args) > 1 )\r
-               {\r
-                       // take away locale\r
-                       array_shift($args);\r
-                       // implode\r
-                       $format=implode(',',$args);\r
-               }\r
-               elseif ( $d == 0 && $m !=0 )\r
-               {\r
-                       $format = '%B %Y';\r
-               }\r
-               elseif ( $m == 0 )\r
-               {\r
-                       $format = '%Y';\r
-               }\r
-               else\r
-               {\r
-                       $format = '%d %B %Y';\r
-               }\r
-               echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_archivedaylist()\r
-        * Parse skinvar archivedaylist\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @param       integer $limit          the number of items in a display\r
-        * @return      void\r
-        */\r
-       public function parse_archivedaylist($template, $category = 'all', $limit = 0)\r
-       {\r
-               global $blog;\r
-               if ( $category == 'all' )\r
-               {\r
-                       $category = '';\r
-               }\r
-               $this->preBlogContent('archivelist',$blog);\r
-               $this->setBlogCategory($blog, $category);\r
-               $blog->showArchiveList($template, 'day', $limit);\r
-               $this->postBlogContent('archivelist',$blog);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_archivelink()\r
-        * A link to the archives for the current blog (or for default blog)\r
-        * \r
-        * @param       string  $linktext       text for link\r
-        * @return      void\r
-        */\r
-       public function parse_archivelink($linktext = '')\r
-       {\r
-               global $blog, $CONF;\r
-               if ( $blog )\r
-               {\r
-                       echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);\r
-               }\r
-               else\r
-               {\r
-                       echo $this->link(Link::create_archivelist_link(), $linktext);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_archivelist()\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @param       integer $limit          the number of items in a display\r
-        * @return      void\r
-        */\r
-       public function parse_archivelist($template, $category = 'all', $limit = 0)\r
-       {\r
-               global $blog;\r
-               if ( $category == 'all' )\r
-               {\r
-                       $category = '';\r
-               }\r
-               $this->preBlogContent('archivelist',$blog);\r
-               $this->setBlogCategory($blog, $category);\r
-               $blog->showArchiveList($template, 'month', $limit);\r
-               $this->postBlogContent('archivelist',$blog);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_archiveyearlist()\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @param       integer $limit          the number of items in a display\r
-        */\r
-       public function parse_archiveyearlist($template, $category = 'all', $limit = 0)\r
-       {\r
-               global $blog;\r
-               if ( $category == 'all' )\r
-               {\r
-                       $category = '';\r
-               }\r
-               $this->preBlogContent('archivelist',$blog);\r
-               $this->setBlogCategory($blog, $category);\r
-               $blog->showArchiveList($template, 'year', $limit);\r
-               $this->postBlogContent('archivelist',$blog);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_archivetype()\r
-        * Parse skinvar archivetype\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_archivetype()\r
-       {\r
-               global $archivetype;\r
-               echo $archivetype;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_blog()\r
-        * Parse skinvar blog\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @param       mixed   $amount         the number of items in a display, in case it includes the beginning\r
-        * @param       string  $category       name of category\r
-        * @return      void\r
-        */\r
-       public function parse_blog($template, $amount = 10, $category = '')\r
-       {\r
-               global $blog, $startpos;\r
-               \r
-               list($limit, $offset) = sscanf($amount, '%d(%d)');\r
-               $this->setBlogCategory($blog, $category);\r
-               $this->preBlogContent('blog',$blog);\r
-               $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);\r
-               $this->postBlogContent('blog',$blog);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_bloglist()\r
-        * Parse skinvar bloglist\r
-        * Shows a list of all blogs\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @param       string  $bnametype      whether 'name' or 'shortname' is used for the link text\r
-        * @param       string  $orderby        order criteria\r
-        * @param       string  $direction      order ascending or descending             \r
-        * @return      void\r
-        */\r
-       public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')\r
-       {\r
-               Blog::showBlogList($template, $bnametype, $orderby, $direction);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_blogsetting()\r
-        * Parse skinvar blogsetting\r
-        * \r
-        * @param       string  $which  key of weblog settings\r
-        * @return      void\r
-        */\r
-       public function parse_blogsetting($which)\r
-       {\r
-               global $blog;\r
-               switch( $which )\r
-               {\r
-                       case 'id':\r
-                               echo Entity::hsc($blog->getID());\r
-                               break;\r
-                       case 'url':\r
-                               echo Entity::hsc($blog->getURL());\r
-                               break;\r
-                       case 'name':\r
-                               echo Entity::hsc($blog->getName());\r
-                               break;\r
-                       case 'desc':\r
-                               echo Entity::hsc($blog->getDescription());\r
-                               break;\r
-                       case 'short':\r
-                               echo Entity::hsc($blog->getShortName());\r
-                               break;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_callback()\r
-        * Parse callback\r
-        * \r
-        * @param       string  $eventName      name of event\r
-        * @param       string  $type   type of skin\r
-        * @return      void\r
-        */\r
-       public function parse_callback($eventName, $type)\r
-       {\r
-               global $manager;\r
-               $manager->notify($eventName, array('type' => $type));\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_category()\r
-        * Parse skinvar category\r
-        * \r
-        * @param       string  $type   key of category settings\r
-        * @return      void\r
-        */\r
-       public function parse_category($type = 'name')\r
-       {\r
-               global $catid, $blog;\r
-               if ( !$blog->isValidCategory($catid) )\r
-               {\r
-                       return;\r
-               }\r
-               \r
-               switch ( $type )\r
-               {\r
-                       case 'name':\r
-                               echo $blog->getCategoryName($catid);\r
-                               break;\r
-                       case 'desc':\r
-                               echo $blog->getCategoryDesc($catid);\r
-                               break;\r
-                       case 'id':\r
-                               echo $catid;\r
-                               break;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_categorylist()\r
-        * Parse categorylist\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @param       string  $blogname       name of weblog\r
-        * @return      void\r
-        */\r
-       public function parse_categorylist($template, $blogname = '')\r
-       {\r
-               global $blog, $manager;\r
-               \r
-               // when no blog found\r
-               if ( ($blogname == '') && (!is_object($blog)) )\r
-               {\r
-                       return 0;\r
-               }\r
-                       \r
-               if ( $blogname == '' )\r
-               {\r
-                       $this->preBlogContent('categorylist',$blog);\r
-                       $blog->showCategoryList($template);\r
-                       $this->postBlogContent('categorylist',$blog);\r
-               }\r
-               else\r
-               {\r
-                       $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
-                       $this->preBlogContent('categorylist',$b);\r
-                       $b->showCategoryList($template);\r
-                       $this->postBlogContent('categorylist',$b);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_charset()\r
-        * Parse skinvar charset\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_charset()\r
-       {\r
-               echo i18n::get_current_charset();\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_commentform()\r
-        * Parse skinvar commentform\r
-        * \r
-        * @param       string  $destinationurl URI for redirection\r
-        * @return      void\r
-        */\r
-       public function parse_commentform($destinationurl = '')\r
-       {\r
-               global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;\r
-               \r
-               // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)\r
-               if ( stristr($destinationurl, 'action.php') )\r
-               {\r
-                       $args = func_get_args();\r
-                       $destinationurl = $args[1];\r
-                       ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);\r
-               }\r
-               \r
-               $actionurl = $CONF['ActionURL'];\r
-               \r
-               // if item is closed, show message and do nothing\r
-               $item =& $manager->getItem($itemid,0,0);\r
-               if ( $item['closed'] || !$blog->commentsEnabled() )\r
-               {\r
-                       $this->doForm('commentform-closed');\r
-                       return;\r
-               }\r
-               \r
-               if ( !$blog->isPublic() && !$member->isLoggedIn() )\r
-               {\r
-                       $this->doForm('commentform-closedtopublic');\r
-                       return;\r
-               }\r
-               \r
-               if ( !$destinationurl )\r
-               {\r
-                       // note: createLink returns an HTML encoded URL\r
-                       $destinationurl = Link::create_link(\r
-                               'item',\r
-                               array(\r
-                                       'itemid' => $itemid,\r
-                                       'title' => $item['title'],\r
-                                       'timestamp' => $item['timestamp'],\r
-                                       'extra' => $this->linkparams\r
-                               )\r
-                       );\r
-               }\r
-               else\r
-               {\r
-                       // HTML encode URL\r
-                       $destinationurl = Entity::hsc($destinationurl);\r
-               }\r
-               \r
-               // values to prefill\r
-               $user = cookieVar($CONF['CookiePrefix'] .'comment_user');\r
-               if ( !$user )\r
-               {\r
-                       $user = postVar('user');\r
-               }\r
-               \r
-               $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');\r
-               if ( !$userid )\r
-               {\r
-                       $userid = postVar('userid');\r
-               }\r
-               \r
-               $email = cookieVar($CONF['CookiePrefix'] .'comment_email');\r
-               if (!$email)\r
-               {\r
-                       $email = postVar('email');\r
-               }\r
-               \r
-               $body = postVar('body');\r
-               \r
-               $this->formdata = array(\r
-                       'destinationurl' => $destinationurl,    // url is already HTML encoded\r
-                       'actionurl' => Entity::hsc($actionurl),\r
-                       'itemid' => $itemid,\r
-                       'user' => Entity::hsc($user),\r
-                       'userid' => Entity::hsc($userid),\r
-                       'email' => Entity::hsc($email),\r
-                       'body' => Entity::hsc($body),\r
-                       'membername' => $member->getDisplayName(),\r
-                       'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''\r
-               );\r
-               \r
-               if ( !$member->isLoggedIn() )\r
-               {\r
-                       $this->doForm('commentform-notloggedin');\r
-               }\r
-               else\r
-               {\r
-                       $this->doForm('commentform-loggedin');\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_comments()\r
-        * Parse skinvar comments\r
-        * include comments for one item\r
-        * \r
-        * @param       string  $template       name of template\r
-        * @return      void\r
-        */\r
-       public function parse_comments($template)\r
-       {\r
-               global $itemid, $manager, $blog, $highlight;\r
-               $template =& $manager->getTemplate($template);\r
-               \r
-               // create parser object & action handler\r
-               $actions = new ItemActions($blog);\r
-               $parser = new Parser($actions->getDefinedActions(),$actions);\r
-               $actions->setTemplate($template);\r
-               $actions->setParser($parser);\r
-               $item = Item::getitem($itemid, 0, 0);\r
-               $actions->setCurrentItem($item);\r
-               \r
-               $comments = new Comments($itemid);\r
-               $comments->setItemActions($actions);\r
-               // shows ALL comments\r
-               $comments->showComments($template, -1, 1, $highlight);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_errordiv()\r
-        * Parse errordiv\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_errordiv()\r
-       {\r
-               global $errormessage;\r
-               if ( $errormessage )\r
-               {\r
-                       echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_errormessage()\r
-        * Parse skinvar errormessage\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_errormessage()\r
-       {\r
-               global $errormessage;\r
-               echo $errormessage;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_formdata()\r
-        * Parse formdata\r
-        * \r
-        * @param       string  $what   key of format data\r
-        * @return      void\r
-        */\r
-       public function parse_formdata($what)\r
-       {\r
-               echo $this->formdata[$what];\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_ifcat()\r
-        * Parse ifcat\r
-        * \r
-        * @param       string  $text\r
-        * @return      void\r
-        */\r
-       public function parse_ifcat($text = '')\r
-       {\r
-               if ( $text == '' )\r
-               {\r
-                       // new behaviour\r
-                       $this->parse_if('category');\r
-               }\r
-               else\r
-               {\r
-                       // old behaviour\r
-                       global $catid, $blog;\r
-                       if ( $blog->isValidCategory($catid) )\r
-                       {\r
-                               echo $text;\r
-                       }\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_image()\r
-        * Parse skinvar image\r
-        * \r
-        * @param       string  $what   name of tag\r
-        * @return      void\r
-        */\r
-       public function parse_image($what = 'imgtag')\r
-       {\r
-               global $CONF;\r
-               \r
-               $imagetext      = Entity::hsc(requestVar('imagetext'));\r
-               $imagepopup = requestVar('imagepopup');\r
-               $width          = intRequestVar('width');\r
-               $height         = intRequestVar('height');\r
-               $fullurl        = Entity::hsc($CONF['MediaURL'] . $imagepopup);\r
-               \r
-               switch ( $what )\r
-               {\r
-                       case 'url':\r
-                               echo $fullurl;\r
-                               break;\r
-                       case 'width':\r
-                               echo $width;\r
-                               break;\r
-                       case 'height':\r
-                               echo $height;\r
-                               break;\r
-                       case 'caption':\r
-                       case 'text':\r
-                               echo $imagetext;\r
-                               break;\r
-                       case 'imgtag':\r
-                       default:\r
-                               echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";\r
-                               break;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_imagetext()\r
-        * Parse skinvar imagetext\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_imagetext()\r
-       {\r
-               $this->parse_image('imagetext');\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Actions::parse_item()\r
-        * Parse skinvar item\r
-        * include one item (no comments)\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_item($template)\r
-       {\r
-               global $blog, $itemid, $highlight;\r
-               \r
-               // need this to select default category\r
-               $this->setBlogCategory($blog, '');\r
-               $this->preBlogContent('item',$blog);\r
-               $r = $blog->showOneitem($itemid, $template, $highlight);\r
-               if ( $r == 0 )\r
-               {\r
-                       echo _ERROR_NOSUCHITEM;\r
-               }\r
-               $this->postBlogContent('item',$blog);\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Actions::parse_itemid()\r
-        * Parse skinvar itemid\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_itemid()\r
-       {\r
-               global $itemid;\r
-               echo $itemid;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parseitemlink()\r
-        * Parse skinvar itemlink\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_itemlink($linktext = '')\r
-       {\r
-               global $itemid;\r
-               $this->itemlink($itemid, $linktext);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_itemtitle()\r
-        * Parse itemtitle\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_itemtitle($format = '')\r
-       {\r
-               global $manager, $itemid;\r
-               $item =& $manager->getItem($itemid,0,0);\r
-               \r
-               switch ( $format )\r
-               {\r
-                       case 'xml':\r
-                               echo Entity::hen($item['title']);\r
-                               break;\r
-                       case 'raw':\r
-                               echo $item['title'];\r
-                               break;\r
-                       case 'attribute':\r
-                       default:\r
-                               echo Entity::hsc(strip_tags($item['title']));\r
-                               break;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_loginform()\r
-        * Parse skinvar loginform\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_loginform()\r
-       {\r
-               global $member, $CONF;\r
-               if ( !$member->isLoggedIn() )\r
-               {\r
-                       $filename = 'loginform-notloggedin';\r
-                       $this->formdata = array();\r
-               }\r
-               else\r
-               {\r
-                       $filename = 'loginform-loggedin';\r
-                       $this->formdata = array(\r
-                               'membername' => $member->getDisplayName(),\r
-                       );\r
-               }\r
-               $this->doForm($filename);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_member()\r
-        * Parse skinvar member\r
-        * (includes a member info thingie)\r
-        * \r
-        * @param       string  $what   which memberdata is needed\r
-        * @return      void\r
-        */\r
-       public function parse_member($what)\r
-       {\r
-               global $memberinfo, $member, $CONF;\r
-               \r
-               // 1. only allow the member-details-page specific variables on member pages\r
-               if ( $this->skintype == 'member' )\r
-               {\r
-                       switch( $what )\r
-                       {\r
-                               case 'name':\r
-                                       echo Entity::hsc($memberinfo->getDisplayName());\r
-                                       break;\r
-                               case 'realname':\r
-                                       echo Entity::hsc($memberinfo->getRealName());\r
-                                       break;\r
-                               case 'notes':\r
-                                       echo Entity::hsc($memberinfo->getNotes());\r
-                                       break;\r
-                               case 'url':\r
-                                       echo Entity::hsc($memberinfo->getURL());\r
-                                       break;\r
-                               case 'email':\r
-                                       echo Entity::hsc($memberinfo->getEmail());\r
-                                       break;\r
-                               case 'id':\r
-                                       echo Entity::hsc($memberinfo->getID());\r
-                                       break;\r
-                       }\r
-               }\r
-               \r
-               // 2. the next bunch of options is available everywhere, as long as the user is logged in\r
-               if ( $member->isLoggedIn() )\r
-               {\r
-                       switch( $what )\r
-                       {\r
-                               case 'yourname':\r
-                                       echo $member->getDisplayName();\r
-                                       break;\r
-                               case 'yourrealname':\r
-                                       echo $member->getRealName();\r
-                                       break;\r
-                               case 'yournotes':\r
-                                       echo $member->getNotes();\r
-                                       break;\r
-                               case 'yoururl':\r
-                                       echo $member->getURL();\r
-                                       break;\r
-                               case 'youremail':\r
-                                       echo $member->getEmail();\r
-                                       break;\r
-                               case 'yourid':\r
-                                       echo $member->getID();\r
-                                       break;\r
-                               case 'yourprofileurl':\r
-                                       if ($CONF['URLMode'] == 'pathinfo')\r
-                                               echo Link::create_member_link($member->getID());\r
-                                       else\r
-                                               echo $CONF['IndexURL'] . Link::create_member_link($member->getID());\r
-                                       break;\r
-                       }\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Link::parse_membermailform()\r
-        * Parse skinvar membermailform\r
-        * \r
-        * @param       integer $rows   the height for textarea\r
-        * @param       integer $cols   the width for textarea\r
-        * @param       string  $desturl        URI to redirect\r
-        * @return      void\r
-        */\r
-       public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')\r
-       {\r
-               global $member, $CONF, $memberid;\r
-               \r
-               if ( $desturl == '' )\r
-               {\r
-                       if ( $CONF['URLMode'] == 'pathinfo' )\r
-                       {\r
-                               $desturl = Link::create_member_link($memberid);\r
-                       }\r
-                       else\r
-                       {\r
-                               $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);\r
-                       }\r
-               }\r
-               \r
-               $message = postVar('message');\r
-               $frommail = postVar('frommail');\r
-               \r
-               $this->formdata = array(\r
-                       'url' => Entity::hsc($desturl),\r
-                       'actionurl' => Entity::hsc($CONF['ActionURL']),\r
-                       'memberid' => $memberid,\r
-                       'rows' => $rows,\r
-                       'cols' => $cols,\r
-                       'message' => Entity::hsc($message),\r
-                       'frommail' => Entity::hsc($frommail)\r
-               );\r
-               \r
-               if ( $member->isLoggedIn() )\r
-               {\r
-                       $this->doForm('membermailform-loggedin');\r
-               }\r
-               else if ( $CONF['NonmemberMail'] )\r
-               {\r
-                       $this->doForm('membermailform-notloggedin');\r
-               }\r
-               else\r
-               {\r
-                       $this->doForm('membermailform-disallowed');\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_nextarchive()\r
-        * Parse skinvar nextarchive\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_nextarchive()\r
-       {\r
-               global $archivenext;\r
-               echo $archivenext;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Parse skinvar nextitem\r
-        * (include itemid of next item)\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_nextitem()\r
-       {\r
-               global $itemidnext;\r
-               if ( isset($itemidnext) )\r
-               {\r
-                       echo (int)$itemidnext;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_nextitemtitle()\r
-        * Parse skinvar nextitemtitle\r
-        * (include itemtitle of next item)\r
-        * \r
-        * @param       string  $format format of text\r
-        * @return      void\r
-        */\r
-       public function parse_nextitemtitle($format = '')\r
-       {\r
-               global $itemtitlenext;\r
-               \r
-               switch ( $format )\r
-               {\r
-                       case 'xml':\r
-                               echo Entity::hen($itemtitlenext);\r
-                               break;\r
-                       case 'raw':\r
-                               echo $itemtitlenext;\r
-                               break;\r
-                       case 'attribute':\r
-                       default:\r
-                               echo Entity::hsc($itemtitlenext);\r
-                               break;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_nextlink()\r
-        * Parse skinvar nextlink\r
-        * \r
-        * @param       string  $linktext       text for content of anchor element\r
-        * @param       integer $amount         the amount of items in a display\r
-        * @param       integer $recount        increment from this value\r
-        * @return      void\r
-        */\r
-       public function parse_nextlink($linktext = '', $amount = 10, $recount = '')\r
-       {\r
-               global $itemidnext, $archivenext, $startpos;\r
-               if ( $this->skintype == 'item' )\r
-               {\r
-                       $this->itemlink($itemidnext, $linktext);\r
-               }\r
-               else if ( $this->skintype == 'search' || $this->skintype == 'index' )\r
-               {\r
-                       $this->searchlink($amount, $startpos, 'next', $linktext, $recount);\r
-               }\r
-               else\r
-               {\r
-                       $this->archivelink($archivenext, $linktext);\r
-               }\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Actions::parse_nucleusbutton()\r
-        * Parse skinvar nucleusbutton\r
-        * \r
-        * @param       string  $imgurl URL  for image\r
-        * @param       integer $imgwidth       width of image\r
-        * @param       integer $imgheidht      height of image\r
-        */\r
-       public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')\r
-       {\r
-               global $CONF;\r
-               if ( $imgurl == '' )\r
-               {\r
-                       $imgurl = $CONF['AdminURL'] . 'nucleus.gif';\r
-               }\r
-               else if ( Parser::getProperty('IncludeMode') == 'skindir' )\r
-               {\r
-                       // when skindit IncludeMode is used: start from skindir\r
-                       $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;\r
-               }\r
-               \r
-               $this->formdata = array(\r
-                       'imgurl' => $imgurl,\r
-                       'imgwidth' => $imgwidth,\r
-                       'imgheight' => $imgheight,\r
-               );\r
-               $this->doForm('nucleusbutton');\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_otherarchive()\r
-        * Parse skinvar otherarchive\r
-        * \r
-        * @param       string  $blogname       name of weblog\r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @return      void\r
-        */     \r
-       public function parse_otherarchive($blogname, $template, $category = '')\r
-       {\r
-               global $archive, $manager;\r
-               sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
-               $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
-               $this->setBlogCategory($b, $category);\r
-               $this->preBlogContent('otherachive',$b);\r
-               $b->showArchive($template, $y, $m, $d);\r
-               $this->postBlogContent('otherachive',$b);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_otherarchivedaylist()\r
-        * Parse skinvar otherarchivedaylist\r
-        * \r
-        * @param       string  $blogname       name of weblog\r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @param       integer $limit          the amount of items in a display\r
-        * @return      void\r
-        */\r
-       public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)\r
-       {\r
-               global $manager;\r
-               if ( $category == 'all')\r
-               {\r
-                       $category = '';\r
-               }\r
-               $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
-               $this->setBlogCategory($b, $category);\r
-               $this->preBlogContent('otherarchivelist',$b);\r
-               $b->showArchiveList($template, 'day', $limit);\r
-               $this->postBlogContent('otherarchivelist',$b);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_otherarchivelist()\r
-        * Parse skinvar otherarchivelist\r
-        * \r
-        * @param       string  $blogname       name of weblog\r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @param       integer $limit          the amount of items in a display\r
-        * @return      void\r
-        */\r
-       public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)\r
-       {\r
-               global $manager;\r
-               if ( $category == 'all' )\r
-               {\r
-                       $category = '';\r
-               }\r
-               $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
-               $this->setBlogCategory($b, $category);\r
-               $this->preBlogContent('otherarchivelist',$b);\r
-               $b->showArchiveList($template, 'month', $limit);\r
-               $this->postBlogContent('otherarchivelist',$b);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_otherarchiveyearlist()\r
-        * Parse skinvar otherarchiveyearlist\r
-        * \r
-        * @param       string  $blogname       name of weblog\r
-        * @param       string  $template       name of template\r
-        * @param       string  $category       name of category\r
-        * @limit       integer $limit          the amount of items in a display\r
-        */\r
-       public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)\r
-       {\r
-               global $manager;\r
-               if ( $category == 'all' )\r
-               {\r
-                       $category = '';\r
-               }\r
-               $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
-               $this->setBlogCategory($b, $category);\r
-               $this->preBlogContent('otherarchivelist',$b);\r
-               $b->showArchiveList($template, 'year', $limit);\r
-               $this->postBlogContent('otherarchivelist',$b);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_otherblog()\r
-        * Parse skinvar otherblog\r
-        * \r
-        * @param       string  $blogname       name of weblog\r
-        * @param       string  $template       name of template\r
-        * @param       mixed   $amount         the amount of items, in case it includes the beginning\r
-        * @param       string  $category       name of category\r
-        * @return      void\r
-        */\r
-       public function parse_otherblog($blogname, $template, $amount = 10, $category = '')\r
-       {\r
-               global $manager;\r
-               \r
-               list($limit, $offset) = sscanf($amount, '%d(%d)');\r
-               \r
-               $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
-               $this->setBlogCategory($b, $category);\r
-               $this->preBlogContent('otherblog',$b);\r
-               $this->amountfound = $b->readLog($template, $limit, $offset);\r
-               $this->postBlogContent('otherblog',$b);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_othersearchresults()\r
-        * Parse skinvar othersearchresults\r
-        * \r
-        * @param       string  $blogname       name of weblog\r
-        * @param       string  $template       name of template\r
-        * @param       integer $maxresults     the amount of results\r
-        * @return      void\r
-        */\r
-       public function parse_othersearchresults($blogname, $template, $maxresults = 50)\r
-       {\r
-               global $query, $amount, $manager, $startpos;\r
-               $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
-               // need this to select default category\r
-               $this->setBlogCategory($b, '');\r
-               $this->preBlogContent('othersearchresults',$b);\r
-               $b->search($query, $template, $amount, $maxresults, $startpos);\r
-               $this->postBlogContent('othersearchresults',$b);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_plugin()\r
-        * Executes a plugin skinvar\r
-        * extra parameters can be added\r
-        * \r
-        * @param       string  $pluginName     name of plugin (without the NP_)\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 skin type on front\r
-               array_unshift($params, $this->skintype);\r
-               \r
-               call_user_func_array(array(&$plugin,'doSkinVar'), $params);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_prevarchive()\r
-        * Parse skinvar prevarchive\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_prevarchive()\r
-       {\r
-               global $archiveprev;\r
-               echo $archiveprev;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_preview()\r
-        * Parse skinvar preview\r
-        * \r
-        * @param       string  $template       name of tempalte\r
-        * @return      void\r
-        */\r
-       public function parse_preview($template)\r
-       {\r
-               global $blog, $CONF, $manager;\r
-               \r
-               $template =& $manager->getTemplate($template);\r
-               \r
-               $row['body'] = '<span id="prevbody"></span>';\r
-               $row['title'] = '<span id="prevtitle"></span>';\r
-               $row['more'] = '<span id="prevmore"></span>';\r
-               $row['itemlink'] = '';\r
-               $row['itemid'] = 0; $row['blogid'] = $blog->getID();\r
-               \r
-               echo Template::fill($template['ITEM_HEADER'],$row);\r
-               echo Template::fill($template['ITEM'],$row);\r
-               echo Template::fill($template['ITEM_FOOTER'],$row);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_previtem()\r
-        * Parse skinvar previtem\r
-        * (include itemid of prev item)\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_previtem()\r
-       {\r
-               global $itemidprev;\r
-               if ( isset($itemidprev) )\r
-               {\r
-                       echo (integer) $itemidprev;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_previtemtitle()\r
-        * Parse skinvar previtemtitle\r
-        * (include itemtitle of prev item)\r
-        * \r
-        * @param       String  $format string format\r
-        * @return      String  formatted string\r
-        */\r
-       public function parse_previtemtitle($format = '')\r
-       {\r
-               global $itemtitleprev;\r
-               \r
-               switch ( $format )\r
-               {\r
-                       case 'xml':\r
-                               echo Entity::hen($itemtitleprev);\r
-                               break;\r
-                       case 'raw':\r
-                               echo $itemtitleprev;\r
-                               break;\r
-                       case 'attribute':\r
-                       default:\r
-                               echo Entity::hsc($itemtitleprev);\r
-                               break;\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_prevlink()\r
-        * Parse skinvar prevlink\r
-        * \r
-        * @param       string  $linktext       text as a content of anchor element\r
-        * @param       integer the amount of links\r
-        * @return      void\r
-        */\r
-       public function parse_prevlink($linktext = '', $amount = 10)\r
-       {\r
-               global $itemidprev, $archiveprev, $startpos;\r
-               \r
-               if ( $this->skintype == 'item' )\r
-               {\r
-                       $this->itemlink($itemidprev, $linktext);\r
-               }\r
-               else if ( $this->skintype == 'search' || $this->skintype == 'index' )\r
-               {\r
-                       $this->searchlink($amount, $startpos, 'prev', $linktext);\r
-               }\r
-               else\r
-               {\r
-                       $this->archivelink($archiveprev, $linktext);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_query()\r
-        * Parse skinvar query\r
-        * (includes the search query)   \r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_query()\r
-       {\r
-               global $query;\r
-               echo Entity::hsc($query);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_referer()\r
-        * Parse skinvar referer\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_referer()\r
-       {\r
-               echo Entity::hsc(serverVar('HTTP_REFERER'));\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_searchform()\r
-        * Parse skinvar searchform\r
-        * \r
-        * @param       string  $blogname       name of weblog\r
-        * @return      void\r
-        */\r
-       public function parse_searchform($blogname = '')\r
-       {\r
-               global $CONF, $manager, $maxresults;\r
-               if ( $blogname )\r
-               {\r
-                       $blog =& $manager->getBlog(getBlogIDFromName($blogname));\r
-               }\r
-               else\r
-               {\r
-                       global $blog;\r
-               }\r
-               // use default blog when no blog is selected\r
-               $this->formdata = array(\r
-                       'id'    => $blog?$blog->getID():$CONF['DefaultBlog'],\r
-                       'query' => Entity::hsc(getVar('query')),\r
-               );\r
-               $this->doForm('searchform');\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_searchresults()\r
-        * Parse skinvar searchresults\r
-        * \r
-        * @param       string  $template       name of tempalte\r
-        * @param       integer $maxresults     searched items in a display\r
-        * @return      void;\r
-        */\r
-       public function parse_searchresults($template, $maxresults = 50 )\r
-       {\r
-               global $blog, $query, $amount, $startpos;\r
-               \r
-               $this->setBlogCategory($blog, '');      // need this to select default category\r
-               $this->preBlogContent('searchresults',$blog);\r
-               $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);\r
-               $this->postBlogContent('searchresults',$blog);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_self()\r
-        * Parse skinvar self\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_self()\r
-       {\r
-               global $CONF;\r
-               echo $CONF['Self'];\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_sitevar()\r
-        * Parse skinvar sitevar\r
-        * (include a sitevar)\r
-        * \r
-        * @param       string  $which\r
-        * @return      void\r
-        */\r
-       public function parse_sitevar($which)\r
-       {\r
-               global $CONF;\r
-               switch ( $which )\r
-               {\r
-                       case 'url':\r
-                               echo $CONF['IndexURL'];\r
-                               break;\r
-                       case 'name':\r
-                               echo $CONF['SiteName'];\r
-                               break;\r
-                       case 'admin':\r
-                               echo $CONF['AdminEmail'];\r
-                               break;\r
-                       case 'adminurl':\r
-                               echo $CONF['AdminURL'];\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_skinname()\r
-        * Parse skinname\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_skinname()\r
-       {\r
-               echo $this->skin->getName();\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_skintype()\r
-        * Parse skintype (experimental)\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_skintype()\r
-       {\r
-               echo $this->skintype;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_text()\r
-        * Parse text\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_text($which)\r
-       {\r
-               // constant($which) only available from 4.0.4 :(\r
-               if ( defined($which) )\r
-               {\r
-                       eval("echo $which;");\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_ticket()\r
-        * Parse ticket\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_ticket()\r
-       {\r
-               global $manager;\r
-               $manager->addTicketHidden();\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Actions::parse_todaylink()\r
-        * Parse skinvar todaylink\r
-        * A link to the today page (depending on selected blog, etc...)\r
-        *\r
-        * @param       string  $linktext       text for link\r
-        * @return      void\r
-        */\r
-       public function parse_todaylink($linktext = '')\r
-       {\r
-               global $blog, $CONF;\r
-               if ( $blog )\r
-               {\r
-                       echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);\r
-               }\r
-               else\r
-               {\r
-                       echo $this->link($CONF['SiteUrl'], $linktext);\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Parse vars\r
-        * When commentform is not used, to include a hidden field with itemid   \r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_vars()\r
-       {\r
-               global $itemid;\r
-               echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Actions::parse_version()\r
-        * Parse skinvar version\r
-        * (include nucleus versionnumber)       \r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       public function parse_version()\r
-       {\r
-               global $nucleus;\r
-               echo 'Nucleus CMS ' . $nucleus['version'];\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Actions::parse_sticky()\r
-        * Parse skinvar sticky\r
-        * \r
-        * @param       integer $itemnumber     id of item\r
-        * @param       string  $template       name of template\r
-        * @return      void\r
-        */\r
-       public function parse_sticky($itemnumber = 0, $template = '')\r
-       {\r
-               global $manager;\r
-               \r
-               $itemnumber = intval($itemnumber);\r
-               $itemarray = array($itemnumber);\r
-               \r
-               $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));\r
-               $this->preBlogContent('sticky',$b);\r
-               $this->amountfound = $b->readLogFromList($itemarray, $template);\r
-               $this->postBlogContent('sticky',$b);\r
-               return;\r
-       }\r
-}\r
+                       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) || ($name == requestVar('action')));
+                               break;
+                       case 'hasplugin':
+                               $condition = $this->ifHasPlugin($name, $value);
+                               break;
+                       default:
+                               $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
+                               break;
+               }
+               return $condition;
+       }
+       
+       /**
+        * Actions::_ifHasPlugin()
+        *      hasplugin,PlugName
+        *         -> checks if plugin exists
+        *      hasplugin,PlugName,OptionName
+        *         -> checks if the option OptionName from plugin PlugName is not set to 'no'
+        *      hasplugin,PlugName,OptionName=value
+        *         -> checks if the option OptionName from plugin PlugName is set to value
+        *
+        * @param       string  $name   name of plugin
+        * @param       string  $value  
+        * @return      
+        */
+       private 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) = preg_split('#=#', $value, 2);
+                                       if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
+                                       {
+                                               $condition = true;
+                                       }
+                                       else if ( $plugin->getOption($name2) == $value2 )
+                                       {
+                                               $condition = true;
+                                       }
+                               }
+                       }
+               }
+               return $condition;
+       }
+       
+       /**
+        * Actions::ifPlugin()
+        * Checks if a plugin exists and call its doIf function
+        * 
+        * @param       string  $name   name of plugin
+        * @param       string  $key    name of plugin option
+        * @param       string  $value  value of plugin option
+        * @return      void
+        */
+       private 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);
+       }
+       
+       /**
+        * Actions::ifCategory()
+        * Different checks for a category
+        * 
+        * @param       string  $name   
+        * @param       string  $value  
+        * @return      boolean 
+        */
+       private 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;
+       }
+       
+       /**
+        * Actions::ifOnTeam()
+        * Checks if a member is on the team of a blog and return his rights
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      mixed
+        */
+       private 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);
+       }
+
+       /**
+        * Actions::ifAdmin()
+        * Checks if a member is admin of a blog
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      mixed
+        */
+       private 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);
+       }
+       
+       /**
+        * Actions::link()
+        * returns either
+        *      - a raw link (html/xml encoded) when no linktext is provided
+        *      - a (x)html <a href... link when a text is present (text htmlencoded)
+        * 
+        * @param       string  $url            URL for href attribute of anchor element
+        * @param       string  $linktext       content of anchor element
+        * @return      
+        */
+       private function link($url, $linktext = '')
+       {
+               $u = Entity::hsc($url);
+               // fix URLs that already had encoded ampersands
+               $u = preg_replace("#&amp;amp;#", '&amp;', $u);
+               if ( $linktext != '' )
+               {
+                       $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';
+               }
+               else
+               {
+                       $l = $u;
+               }
+               return $l;
+       }
+       
+       /**
+        * Actions::searchlink()
+        * Outputs a next/prev link
+        *
+        * @param $maxresults
+        *              The maximum amount of items shown per page (e.g. 10)
+        * @param $startpos
+        *              Current start position (requestVar('startpos'))
+        * @param $direction
+        *              either 'prev' or 'next'
+        * @param $linktext
+        *              When present, the output will be a full <a href...> link. When empty,
+        *              only a raw link will be outputted
+        */
+       private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')
+       {
+               global $CONF, $blog, $query, $amount;
+               // TODO: Move request uri to linkparams. this is ugly. sorry for that.
+               $startpos       = (integer) $startpos;
+               $parsed         = parse_url(serverVar('REQUEST_URI'));
+               $path           = $parsed['path'];
+               $parsed         = $parsed['query'];
+               $url            = '';
+               
+               if ( $direction == 'prev' )
+               {
+                       if ( intval($startpos) - intval($maxresults) >= 0 )
+                       {
+                               $startpos       = intval($startpos) - intval($maxresults);
+                               
+                               if ( $this->skintype == 'index' )
+                               {
+                                       $url = $path;
+                               }
+                               else if ( $this->skintype == 'search' )
+                               {
+                                       $url = $CONF['SearchURL'];
+                               }
+                               $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);
+                       }
+               }
+               else if ( $direction == 'next' )
+               {
+                       global $navigationItems;
+                       if ( !isset($navigationItems) )
+                       {
+                               $navigationItems = 0;
+                       }
+                       
+                       if ( $recount )
+                       {
+                               $iAmountOnPage = 0;
+                       }
+                       else 
+                       {
+                               $iAmountOnPage = $this->amountfound;
+                       }
+                       
+                       if ( intval($navigationItems) > 0 )
+                       {
+                               $iAmountOnPage = intval($navigationItems) - intval($startpos);
+                       }
+                       elseif ( $iAmountOnPage == 0 )
+                       {
+                               /*
+                                * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
+                                * try a count query
+                                */
+                               if ( $this->skintype == 'index' )
+                               {
+                                       $sqlquery = $blog->getSqlBlog('', 'count');
+                                       $url = $path;
+                               }
+                               else if ( $this->skintype == 'search' )
+                               {
+                                       $unused_highlight = '';
+                                       $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
+                                       $url = $CONF['SearchURL'];
+                               }
+                               if ( $sqlquery )
+                               {
+                                       $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
+                               }
+                       }
+                       
+                       $url = '';
+                       if ( intval($iAmountOnPage) >= intval($maxresults) )
+                       {
+                               $startpos        = intval($startpos) + intval($maxresults);
+                               $url            .= '?' . alterQueryStr($parsed, 'startpos', $startpos);
+                       }
+               }
+               
+               if ( $url != '' )
+               {
+                       echo $this->link($url, $linktext);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::itemlink()
+        * Creates an item link and if no id is given a todaylink 
+        * 
+        * @param       integer $id     id for link
+        * @param       string  $linktext       text for link
+        * @return      void
+        */
+       private function itemlink($id, $linktext = '')
+       {
+               global $CONF;
+               if ( $id != 0 )
+               {
+                       echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);
+               }
+               else
+               {
+                       $this->parse_todaylink($linktext);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::archivelink)
+        * Creates an archive link and if no id is given a todaylink 
+        * 
+        * @param       integer $id     id for link
+        * @param       string  $linktext       text for link
+        * @return      void
+        */
+       private function archivelink($id, $linktext = '')
+       {
+               global $CONF, $blog;
+               if ( $id != 0 )
+               {
+                       echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
+               }
+               else
+               {
+                       $this->parse_todaylink($linktext);
+               }
+               return;
+       }
+       
+       /**
+        * Actions:setBlogCategory()
+        * Helper function that sets the category that a blog will need to use
+        *
+        * @param       string  $blog           An object of the blog class, passed by reference (we want to make changes to it)
+        * @param       string  $catname        The name of the category to use
+        * @return      void
+        */
+       private function setBlogCategory(&$blog, $catname)
+       {
+               global $catid;
+               if ( $catname != '' )
+               {
+                       $blog->setSelectedCategoryByName($catname);
+               }
+               else
+               {
+                       $blog->setSelectedCategory($catid);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::preBlogContent()
+        * Notifies the Manager that a PreBlogContent event occurs
+        * 
+        * @param       string  $type   type of skin
+        * @param       object  $blog   an instance of Blog class
+        * @return      void
+        */
+       private function preBlogContent($type, &$blog)
+       {
+               global $manager;
+               $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
+               return;
+       }
+
+       /**
+        * Actions::postBlogContent()
+        * Notifies the Manager that a PostBlogContent event occurs
+        * 
+        * @param       string  $type   type of skin
+        * @param       objecct $blog   an instance of Blog class
+        * @return      void
+        */
+       private function postBlogContent($type, &$blog)
+       {
+               global $manager;
+               $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));
+               return;
+       }
+       
+       /**
+        * Actions::parse_additemform()
+        * Parse skinvar additemform
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_additemform()
+       {
+               global $blog, $CONF;
+               $this->formdata = array(
+                       'adminurl'      => Entity::hsc($CONF['AdminURL']),
+                       'catid'         => $blog->getDefaultCategory()
+               );
+               $blog->InsertJavaScriptInfo();
+               $this->doForm('additemform');
+               return;
+       }
+       
+       /**
+        * Actions::parse_addlink()
+        * Parse skinvar addlink
+        * A Link that allows to open a bookmarklet to add an item
+        */
+       public function parse_addlink()
+       {
+               global $CONF, $member, $blog;
+               if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )
+               {
+                       echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_addpopupcode()
+        * Parse skinvar addpopupcode
+        * Code that opens a bookmarklet in an popup window
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_addpopupcode()
+       {
+               echo "if (event &amp;&amp; event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');winbm.focus();return false;";
+               return;
+       }
+       
+       /**
+        * Parse skinvar adminurl
+        * (shortcut for admin url)
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_adminurl()
+       {
+               $this->parse_sitevar('adminurl');
+               return;
+       }
+       
+       /**
+        * Actions::parse_archive()
+        * Parse skinvar archive
+        * 
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @return      
+        */
+       public function parse_archive($template, $category = '')
+       {
+               global $blog, $archive;
+               // can be used with either yyyy-mm or yyyy-mm-dd
+               sscanf($archive,'%d-%d-%d', $y, $m, $d);
+               $this->setBlogCategory($blog, $category);
+               $this->preBlogContent('achive',$blog);
+               $blog->showArchive($template, $y, $m, $d);
+               $this->postBlogContent('achive',$blog);
+               return;
+       }
+       
+       /**
+        * Actions::parse_archivedate()
+        * %archivedate(locale,date format)%
+        * 
+        * @param       string  $locale
+        * @return      void
+        */
+       public function parse_archivedate($locale = '-def-')
+       {
+               global $archive;
+               
+               /* 
+                * TODO: these lines are no meaning because there is no $template.
+               if ( $locale == '-def-' )
+               {
+                       setlocale(LC_TIME, $template['LOCALE']);
+               }
+               else
+               {
+                       setlocale(LC_TIME, $locale);
+               }
+                */
+               
+               // get archive date
+               sscanf($archive,'%d-%d-%d',$y,$m,$d);
+               
+               // get format
+               $args = func_get_args();
+               // format can be spread over multiple parameters
+               if ( sizeof($args) > 1 )
+               {
+                       // take away locale
+                       array_shift($args);
+                       // implode
+                       $format=implode(',',$args);
+               }
+               elseif ( $d == 0 && $m !=0 )
+               {
+                       $format = '%B %Y';
+               }
+               elseif ( $m == 0 )
+               {
+                       $format = '%Y';
+               }
+               else
+               {
+                       $format = '%d %B %Y';
+               }
+               echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
+               return;
+       }
+       
+       /**
+        * Actions::parse_archivedaylist()
+        * Parse skinvar archivedaylist
+        * 
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @param       integer $limit          the number of items in a display
+        * @return      void
+        */
+       public function parse_archivedaylist($template, $category = 'all', $limit = 0)
+       {
+               global $blog;
+               if ( $category == 'all' )
+               {
+                       $category = '';
+               }
+               $this->preBlogContent('archivelist',$blog);
+               $this->setBlogCategory($blog, $category);
+               $blog->showArchiveList($template, 'day', $limit);
+               $this->postBlogContent('archivelist',$blog);
+               return;
+       }
+       
+       /**
+        * Actions::parse_archivelink()
+        * A link to the archives for the current blog (or for default blog)
+        * 
+        * @param       string  $linktext       text for link
+        * @return      void
+        */
+       public function parse_archivelink($linktext = '')
+       {
+               global $blog, $CONF;
+               if ( $blog )
+               {
+                       echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);
+               }
+               else
+               {
+                       echo $this->link(Link::create_archivelist_link(), $linktext);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_archivelist()
+        * 
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @param       integer $limit          the number of items in a display
+        * @return      void
+        */
+       public function parse_archivelist($template, $category = 'all', $limit = 0)
+       {
+               global $blog;
+               if ( $category == 'all' )
+               {
+                       $category = '';
+               }
+               $this->preBlogContent('archivelist',$blog);
+               $this->setBlogCategory($blog, $category);
+               $blog->showArchiveList($template, 'month', $limit);
+               $this->postBlogContent('archivelist',$blog);
+               return;
+       }
+       
+       /**
+        * Actions::parse_archiveyearlist()
+        * 
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @param       integer $limit          the number of items in a display
+        */
+       public function parse_archiveyearlist($template, $category = 'all', $limit = 0)
+       {
+               global $blog;
+               if ( $category == 'all' )
+               {
+                       $category = '';
+               }
+               $this->preBlogContent('archivelist',$blog);
+               $this->setBlogCategory($blog, $category);
+               $blog->showArchiveList($template, 'year', $limit);
+               $this->postBlogContent('archivelist',$blog);
+               return;
+       }
+       
+       /**
+        * Actions::parse_archivetype()
+        * Parse skinvar archivetype
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_archivetype()
+       {
+               global $archivetype;
+               echo $archivetype;
+               return;
+       }
+       
+       /**
+        * Actions::parse_blog()
+        * Parse skinvar blog
+        * 
+        * @param       string  $template       name of template
+        * @param       mixed   $amount         the number of items in a display, in case it includes the beginning
+        * @param       string  $category       name of category
+        * @return      void
+        */
+       public function parse_blog($template, $amount = 10, $category = '')
+       {
+               global $blog, $startpos;
+               
+               list($limit, $offset) = sscanf($amount, '%d(%d)');
+               $this->setBlogCategory($blog, $category);
+               $this->preBlogContent('blog',$blog);
+               $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
+               $this->postBlogContent('blog',$blog);
+               return;
+       }
+       
+       /**
+        * Actions::parse_bloglist()
+        * Parse skinvar bloglist
+        * Shows a list of all blogs
+        * 
+        * @param       string  $template       name of template
+        * @param       string  $bnametype      whether 'name' or 'shortname' is used for the link text
+        * @param       string  $orderby        order criteria
+        * @param       string  $direction      order ascending or descending             
+        * @return      void
+        */
+       public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')
+       {
+               Blog::showBlogList($template, $bnametype, $orderby, $direction);
+               return;
+       }
+       
+       /**
+        * Actions::parse_blogsetting()
+        * Parse skinvar blogsetting
+        * 
+        * @param       string  $which  key of weblog settings
+        * @return      void
+        */
+       public function parse_blogsetting($which)
+       {
+               global $blog;
+               switch( $which )
+               {
+                       case 'id':
+                               echo Entity::hsc($blog->getID());
+                               break;
+                       case 'url':
+                               echo Entity::hsc($blog->getURL());
+                               break;
+                       case 'name':
+                               echo Entity::hsc($blog->getName());
+                               break;
+                       case 'desc':
+                               echo Entity::hsc($blog->getDescription());
+                               break;
+                       case 'short':
+                               echo Entity::hsc($blog->getShortName());
+                               break;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_callback()
+        * Parse callback
+        * 
+        * @param       string  $eventName      name of event
+        * @param       string  $type   type of skin
+        * @return      void
+        */
+       public function parse_callback($eventName, $type)
+       {
+               global $manager;
+               $manager->notify($eventName, array('type' => $type));
+               return;
+       }
+       
+       /**
+        * Actions::parse_category()
+        * Parse skinvar category
+        * 
+        * @param       string  $type   key of category settings
+        * @return      void
+        */
+       public function parse_category($type = 'name')
+       {
+               global $catid, $blog;
+               if ( !$blog->isValidCategory($catid) )
+               {
+                       return;
+               }
+               
+               switch ( $type )
+               {
+                       case 'name':
+                               echo $blog->getCategoryName($catid);
+                               break;
+                       case 'desc':
+                               echo $blog->getCategoryDesc($catid);
+                               break;
+                       case 'id':
+                               echo $catid;
+                               break;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_categorylist()
+        * Parse categorylist
+        * 
+        * @param       string  $template       name of template
+        * @param       string  $blogname       name of weblog
+        * @return      void
+        */
+       public function parse_categorylist($template, $blogname = '')
+       {
+               global $blog, $manager;
+               
+               // when no blog found
+               if ( ($blogname == '') && (!is_object($blog)) )
+               {
+                       return 0;
+               }
+                       
+               if ( $blogname == '' )
+               {
+                       $this->preBlogContent('categorylist',$blog);
+                       $blog->showCategoryList($template);
+                       $this->postBlogContent('categorylist',$blog);
+               }
+               else
+               {
+                       $b =& $manager->getBlog(getBlogIDFromName($blogname));
+                       $this->preBlogContent('categorylist',$b);
+                       $b->showCategoryList($template);
+                       $this->postBlogContent('categorylist',$b);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_charset()
+        * Parse skinvar charset
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_charset()
+       {
+               echo i18n::get_current_charset();
+               return;
+       }
+       
+       /**
+        * Actions::parse_commentform()
+        * Parse skinvar commentform
+        * 
+        * @param       string  $destinationurl URI for redirection
+        * @return      void
+        */
+       public function parse_commentform($destinationurl = '')
+       {
+               global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
+               
+               // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
+               if ( stristr($destinationurl, 'action.php') )
+               {
+                       $args = func_get_args();
+                       $destinationurl = $args[1];
+                       ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
+               }
+               
+               $actionurl = $CONF['ActionURL'];
+               
+               // if item is closed, show message and do nothing
+               $item =& $manager->getItem($itemid,0,0);
+               if ( $item['closed'] || !$blog->commentsEnabled() )
+               {
+                       $this->doForm('commentform-closed');
+                       return;
+               }
+               
+               if ( !$blog->isPublic() && !$member->isLoggedIn() )
+               {
+                       $this->doForm('commentform-closedtopublic');
+                       return;
+               }
+               
+               if ( !$destinationurl )
+               {
+                       // note: createLink returns an HTML encoded URL
+                       $destinationurl = Link::create_link(
+                               'item',
+                               array(
+                                       'itemid' => $itemid,
+                                       'title' => $item['title'],
+                                       'timestamp' => $item['timestamp'],
+                                       'extra' => $this->linkparams
+                               )
+                       );
+               }
+               else
+               {
+                       // HTML encode URL
+                       $destinationurl = Entity::hsc($destinationurl);
+               }
+               
+               // values to prefill
+               $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
+               if ( !$user )
+               {
+                       $user = postVar('user');
+               }
+               
+               $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
+               if ( !$userid )
+               {
+                       $userid = postVar('userid');
+               }
+               
+               $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
+               if (!$email)
+               {
+                       $email = postVar('email');
+               }
+               
+               $body = postVar('body');
+               
+               $this->formdata = array(
+                       'destinationurl' => $destinationurl,    // url is already HTML encoded
+                       'actionurl' => Entity::hsc($actionurl),
+                       'itemid' => $itemid,
+                       'user' => Entity::hsc($user),
+                       'userid' => Entity::hsc($userid),
+                       'email' => Entity::hsc($email),
+                       'body' => Entity::hsc($body),
+                       'membername' => $member->getDisplayName(),
+                       'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
+               );
+               
+               if ( !$member->isLoggedIn() )
+               {
+                       $this->doForm('commentform-notloggedin');
+               }
+               else
+               {
+                       $this->doForm('commentform-loggedin');
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_comments()
+        * Parse skinvar comments
+        * include comments for one item
+        * 
+        * @param       string  $template       name of template
+        * @return      void
+        */
+       public function parse_comments($template)
+       {
+               global $itemid, $manager, $blog, $highlight;
+               $template =& $manager->getTemplate($template);
+               
+               // create parser object & action handler
+               $actions = new ItemActions($blog);
+               $parser = new Parser($actions->getDefinedActions(),$actions);
+               $actions->setTemplate($template);
+               $actions->setParser($parser);
+               $item = Item::getitem($itemid, 0, 0);
+               $actions->setCurrentItem($item);
+               
+               $comments = new Comments($itemid);
+               $comments->setItemActions($actions);
+               // shows ALL comments
+               $comments->showComments($template, -1, 1, $highlight);
+               return;
+       }
+       
+       /**
+        * Actions::parse_errordiv()
+        * Parse errordiv
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_errordiv()
+       {
+               global $errormessage;
+               if ( $errormessage )
+               {
+                       echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_errormessage()
+        * Parse skinvar errormessage
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_errormessage()
+       {
+               global $errormessage;
+               echo $errormessage;
+               return;
+       }
+       
+       /**
+        * Actions::parse_formdata()
+        * Parse formdata
+        * 
+        * @param       string  $what   key of format data
+        * @return      void
+        */
+       public function parse_formdata($what)
+       {
+               echo $this->formdata[$what];
+               return;
+       }
+       
+       /**
+        * Actions::parse_ifcat()
+        * Parse ifcat
+        * 
+        * @param       string  $text
+        * @return      void
+        */
+       public function parse_ifcat($text = '')
+       {
+               if ( $text == '' )
+               {
+                       // new behaviour
+                       $this->parse_if('category');
+               }
+               else
+               {
+                       // old behaviour
+                       global $catid, $blog;
+                       if ( $blog->isValidCategory($catid) )
+                       {
+                               echo $text;
+                       }
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_image()
+        * Parse skinvar image
+        * 
+        * @param       string  $what   name of tag
+        * @return      void
+        */
+       public function parse_image($what = 'imgtag')
+       {
+               global $CONF;
+               
+               $imagetext      = Entity::hsc(requestVar('imagetext'));
+               $imagepopup = requestVar('imagepopup');
+               $width          = intRequestVar('width');
+               $height         = intRequestVar('height');
+               $fullurl        = Entity::hsc($CONF['MediaURL'] . $imagepopup);
+               
+               switch ( $what )
+               {
+                       case 'url':
+                               echo $fullurl;
+                               break;
+                       case 'width':
+                               echo $width;
+                               break;
+                       case 'height':
+                               echo $height;
+                               break;
+                       case 'caption':
+                       case 'text':
+                               echo $imagetext;
+                               break;
+                       case 'imgtag':
+                       default:
+                               echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
+                               break;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_imagetext()
+        * Parse skinvar imagetext
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_imagetext()
+       {
+               $this->parse_image('imagetext');
+               return;
+       }
+
+       /**
+        * Actions::parse_item()
+        * Parse skinvar item
+        * include one item (no comments)
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_item($template)
+       {
+               global $blog, $itemid, $highlight;
+               
+               // need this to select default category
+               $this->setBlogCategory($blog, '');
+               $this->preBlogContent('item',$blog);
+               $r = $blog->showOneitem($itemid, $template, $highlight);
+               if ( $r == 0 )
+               {
+                       echo _ERROR_NOSUCHITEM;
+               }
+               $this->postBlogContent('item',$blog);
+               return;
+       }
+
+       /**
+        * Actions::parse_itemid()
+        * Parse skinvar itemid
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_itemid()
+       {
+               global $itemid;
+               echo $itemid;
+               return;
+       }
+       
+       /**
+        * Actions::parseitemlink()
+        * Parse skinvar itemlink
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_itemlink($linktext = '')
+       {
+               global $itemid;
+               $this->itemlink($itemid, $linktext);
+               return;
+       }
+       
+       /**
+        * Actions::parse_itemtitle()
+        * Parse itemtitle
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_itemtitle($format = '')
+       {
+               global $manager, $itemid;
+               $item =& $manager->getItem($itemid,0,0);
+               
+               switch ( $format )
+               {
+                       case 'xml':
+                               echo Entity::hen($item['title']);
+                               break;
+                       case 'raw':
+                               echo $item['title'];
+                               break;
+                       case 'attribute':
+                       default:
+                               echo Entity::hsc(strip_tags($item['title']));
+                               break;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_loginform()
+        * Parse skinvar loginform
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_loginform()
+       {
+               global $member, $CONF;
+               if ( !$member->isLoggedIn() )
+               {
+                       $filename = 'loginform-notloggedin';
+                       $this->formdata = array();
+               }
+               else
+               {
+                       $filename = 'loginform-loggedin';
+                       $this->formdata = array(
+                               'membername' => $member->getDisplayName(),
+                       );
+               }
+               $this->doForm($filename);
+               return;
+       }
+       
+       /**
+        * Actions::parse_member()
+        * Parse skinvar member
+        * (includes a member info thingie)
+        * 
+        * @param       string  $what   which memberdata is needed
+        * @return      void
+        */
+       public function parse_member($what)
+       {
+               global $memberinfo, $member, $CONF;
+               
+               // 1. only allow the member-details-page specific variables on member pages
+               if ( $this->skintype == 'member' )
+               {
+                       switch( $what )
+                       {
+                               case 'name':
+                                       echo Entity::hsc($memberinfo->getDisplayName());
+                                       break;
+                               case 'realname':
+                                       echo Entity::hsc($memberinfo->getRealName());
+                                       break;
+                               case 'notes':
+                                       echo Entity::hsc($memberinfo->getNotes());
+                                       break;
+                               case 'url':
+                                       echo Entity::hsc($memberinfo->getURL());
+                                       break;
+                               case 'email':
+                                       echo Entity::hsc($memberinfo->getEmail());
+                                       break;
+                               case 'id':
+                                       echo Entity::hsc($memberinfo->getID());
+                                       break;
+                       }
+               }
+               
+               // 2. the next bunch of options is available everywhere, as long as the user is logged in
+               if ( $member->isLoggedIn() )
+               {
+                       switch( $what )
+                       {
+                               case 'yourname':
+                                       echo $member->getDisplayName();
+                                       break;
+                               case 'yourrealname':
+                                       echo $member->getRealName();
+                                       break;
+                               case 'yournotes':
+                                       echo $member->getNotes();
+                                       break;
+                               case 'yoururl':
+                                       echo $member->getURL();
+                                       break;
+                               case 'youremail':
+                                       echo $member->getEmail();
+                                       break;
+                               case 'yourid':
+                                       echo $member->getID();
+                                       break;
+                               case 'yourprofileurl':
+                                       if ($CONF['URLMode'] == 'pathinfo')
+                                               echo Link::create_member_link($member->getID());
+                                       else
+                                               echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
+                                       break;
+                       }
+               }
+               return;
+       }
+       
+       /**
+        * Link::parse_membermailform()
+        * Parse skinvar membermailform
+        * 
+        * @param       integer $rows   the height for textarea
+        * @param       integer $cols   the width for textarea
+        * @param       string  $desturl        URI to redirect
+        * @return      void
+        */
+       public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
+       {
+               global $member, $CONF, $memberid;
+               
+               if ( $desturl == '' )
+               {
+                       if ( $CONF['URLMode'] == 'pathinfo' )
+                       {
+                               $desturl = Link::create_member_link($memberid);
+                       }
+                       else
+                       {
+                               $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
+                       }
+               }
+               
+               $message = postVar('message');
+               $frommail = postVar('frommail');
+               
+               $this->formdata = array(
+                       'url' => Entity::hsc($desturl),
+                       'actionurl' => Entity::hsc($CONF['ActionURL']),
+                       'memberid' => $memberid,
+                       'rows' => $rows,
+                       'cols' => $cols,
+                       'message' => Entity::hsc($message),
+                       'frommail' => Entity::hsc($frommail)
+               );
+               
+               if ( $member->isLoggedIn() )
+               {
+                       $this->doForm('membermailform-loggedin');
+               }
+               else if ( $CONF['NonmemberMail'] )
+               {
+                       $this->doForm('membermailform-notloggedin');
+               }
+               else
+               {
+                       $this->doForm('membermailform-disallowed');
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_nextarchive()
+        * Parse skinvar nextarchive
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_nextarchive()
+       {
+               global $archivenext;
+               echo $archivenext;
+               return;
+       }
+       
+       /**
+        * Parse skinvar nextitem
+        * (include itemid of next item)
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_nextitem()
+       {
+               global $itemidnext;
+               if ( isset($itemidnext) )
+               {
+                       echo (int)$itemidnext;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_nextitemtitle()
+        * Parse skinvar nextitemtitle
+        * (include itemtitle of next item)
+        * 
+        * @param       string  $format format of text
+        * @return      void
+        */
+       public function parse_nextitemtitle($format = '')
+       {
+               global $itemtitlenext;
+               
+               switch ( $format )
+               {
+                       case 'xml':
+                               echo Entity::hen($itemtitlenext);
+                               break;
+                       case 'raw':
+                               echo $itemtitlenext;
+                               break;
+                       case 'attribute':
+                       default:
+                               echo Entity::hsc($itemtitlenext);
+                               break;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_nextlink()
+        * Parse skinvar nextlink
+        * 
+        * @param       string  $linktext       text for content of anchor element
+        * @param       integer $amount         the amount of items in a display
+        * @param       integer $recount        increment from this value
+        * @return      void
+        */
+       public function parse_nextlink($linktext = '', $amount = 10, $recount = '')
+       {
+               global $itemidnext, $archivenext, $startpos;
+               if ( $this->skintype == 'item' )
+               {
+                       $this->itemlink($itemidnext, $linktext);
+               }
+               else if ( $this->skintype == 'search' || $this->skintype == 'index' )
+               {
+                       $this->searchlink($amount, $startpos, 'next', $linktext, $recount);
+               }
+               else
+               {
+                       $this->archivelink($archivenext, $linktext);
+               }
+               return;
+       }
+
+       /**
+        * Actions::parse_nucleusbutton()
+        * Parse skinvar nucleusbutton
+        * 
+        * @param       string  $imgurl URL  for image
+        * @param       integer $imgwidth       width of image
+        * @param       integer $imgheidht      height of image
+        */
+       public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')
+       {
+               global $CONF;
+               if ( $imgurl == '' )
+               {
+                       $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
+               }
+               else if ( Parser::getProperty('IncludeMode') == 'skindir' )
+               {
+                       // when skindit IncludeMode is used: start from skindir
+                       $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
+               }
+               
+               $this->formdata = array(
+                       'imgurl' => $imgurl,
+                       'imgwidth' => $imgwidth,
+                       'imgheight' => $imgheight,
+               );
+               $this->doForm('nucleusbutton');
+               return;
+       }
+       
+       /**
+        * Actions::parse_otherarchive()
+        * Parse skinvar otherarchive
+        * 
+        * @param       string  $blogname       name of weblog
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @return      void
+        */     
+       public function parse_otherarchive($blogname, $template, $category = '')
+       {
+               global $archive, $manager;
+               sscanf($archive,'%d-%d-%d',$y,$m,$d);
+               $b =& $manager->getBlog(getBlogIDFromName($blogname));
+               $this->setBlogCategory($b, $category);
+               $this->preBlogContent('otherachive',$b);
+               $b->showArchive($template, $y, $m, $d);
+               $this->postBlogContent('otherachive',$b);
+               return;
+       }
+       
+       /**
+        * Actions::parse_otherarchivedaylist()
+        * Parse skinvar otherarchivedaylist
+        * 
+        * @param       string  $blogname       name of weblog
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @param       integer $limit          the amount of items in a display
+        * @return      void
+        */
+       public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)
+       {
+               global $manager;
+               if ( $category == 'all')
+               {
+                       $category = '';
+               }
+               $b =& $manager->getBlog(getBlogIDFromName($blogname));
+               $this->setBlogCategory($b, $category);
+               $this->preBlogContent('otherarchivelist',$b);
+               $b->showArchiveList($template, 'day', $limit);
+               $this->postBlogContent('otherarchivelist',$b);
+               return;
+       }
+       
+       /**
+        * Actions::parse_otherarchivelist()
+        * Parse skinvar otherarchivelist
+        * 
+        * @param       string  $blogname       name of weblog
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @param       integer $limit          the amount of items in a display
+        * @return      void
+        */
+       public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)
+       {
+               global $manager;
+               if ( $category == 'all' )
+               {
+                       $category = '';
+               }
+               $b =& $manager->getBlog(getBlogIDFromName($blogname));
+               $this->setBlogCategory($b, $category);
+               $this->preBlogContent('otherarchivelist',$b);
+               $b->showArchiveList($template, 'month', $limit);
+               $this->postBlogContent('otherarchivelist',$b);
+               return;
+       }
+       
+       /**
+        * Actions::parse_otherarchiveyearlist()
+        * Parse skinvar otherarchiveyearlist
+        * 
+        * @param       string  $blogname       name of weblog
+        * @param       string  $template       name of template
+        * @param       string  $category       name of category
+        * @limit       integer $limit          the amount of items in a display
+        */
+       public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)
+       {
+               global $manager;
+               if ( $category == 'all' )
+               {
+                       $category = '';
+               }
+               $b =& $manager->getBlog(getBlogIDFromName($blogname));
+               $this->setBlogCategory($b, $category);
+               $this->preBlogContent('otherarchivelist',$b);
+               $b->showArchiveList($template, 'year', $limit);
+               $this->postBlogContent('otherarchivelist',$b);
+               return;
+       }
+       
+       /**
+        * Actions::parse_otherblog()
+        * Parse skinvar otherblog
+        * 
+        * @param       string  $blogname       name of weblog
+        * @param       string  $template       name of template
+        * @param       mixed   $amount         the amount of items, in case it includes the beginning
+        * @param       string  $category       name of category
+        * @return      void
+        */
+       public function parse_otherblog($blogname, $template, $amount = 10, $category = '')
+       {
+               global $manager;
+               
+               list($limit, $offset) = sscanf($amount, '%d(%d)');
+               
+               $b =& $manager->getBlog(getBlogIDFromName($blogname));
+               $this->setBlogCategory($b, $category);
+               $this->preBlogContent('otherblog',$b);
+               $this->amountfound = $b->readLog($template, $limit, $offset);
+               $this->postBlogContent('otherblog',$b);
+               return;
+       }
+       
+       /**
+        * Actions::parse_othersearchresults()
+        * Parse skinvar othersearchresults
+        * 
+        * @param       string  $blogname       name of weblog
+        * @param       string  $template       name of template
+        * @param       integer $maxresults     the amount of results
+        * @return      void
+        */
+       public function parse_othersearchresults($blogname, $template, $maxresults = 50)
+       {
+               global $query, $amount, $manager, $startpos;
+               $b =& $manager->getBlog(getBlogIDFromName($blogname));
+               // need this to select default category
+               $this->setBlogCategory($b, '');
+               $this->preBlogContent('othersearchresults',$b);
+               $b->search($query, $template, $amount, $maxresults, $startpos);
+               $this->postBlogContent('othersearchresults',$b);
+               return;
+       }
+       
+       /**
+        * Actions::parse_plugin()
+        * Executes a plugin skinvar
+        * extra parameters can be added
+        * 
+        * @param       string  $pluginName     name of plugin (without the NP_)
+        * @return      void
+        */
+       public function parse_plugin($pluginName)
+       {
+               global $manager;
+               
+               $plugin =& $manager->getPlugin('NP_' . $pluginName);
+               if ( !$plugin )
+               {
+                       return;
+               }
+               
+               // get arguments
+               $params = func_get_args();
+               
+               // remove plugin name
+               array_shift($params);
+               
+               // add skin type on front
+               array_unshift($params, $this->skintype);
+               
+               call_user_func_array(array(&$plugin,'doSkinVar'), $params);
+               return;
+       }
+       
+       /**
+        * Actions::parse_prevarchive()
+        * Parse skinvar prevarchive
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_prevarchive()
+       {
+               global $archiveprev;
+               echo $archiveprev;
+       }
+       
+       /**
+        * Actions::parse_preview()
+        * Parse skinvar preview
+        * 
+        * @param       string  $template       name of tempalte
+        * @return      void
+        */
+       public function parse_preview($template)
+       {
+               global $blog, $CONF, $manager;
+               
+               $template =& $manager->getTemplate($template);
+               
+               $row['body'] = '<span id="prevbody"></span>';
+               $row['title'] = '<span id="prevtitle"></span>';
+               $row['more'] = '<span id="prevmore"></span>';
+               $row['itemlink'] = '';
+               $row['itemid'] = 0; $row['blogid'] = $blog->getID();
+               
+               echo Template::fill($template['ITEM_HEADER'],$row);
+               echo Template::fill($template['ITEM'],$row);
+               echo Template::fill($template['ITEM_FOOTER'],$row);
+               return;
+       }
+       
+       /**
+        * Actions::parse_previtem()
+        * Parse skinvar previtem
+        * (include itemid of prev item)
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_previtem()
+       {
+               global $itemidprev;
+               if ( isset($itemidprev) )
+               {
+                       echo (integer) $itemidprev;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_previtemtitle()
+        * Parse skinvar previtemtitle
+        * (include itemtitle of prev item)
+        * 
+        * @param       String  $format string format
+        * @return      String  formatted string
+        */
+       public function parse_previtemtitle($format = '')
+       {
+               global $itemtitleprev;
+               
+               switch ( $format )
+               {
+                       case 'xml':
+                               echo Entity::hen($itemtitleprev);
+                               break;
+                       case 'raw':
+                               echo $itemtitleprev;
+                               break;
+                       case 'attribute':
+                       default:
+                               echo Entity::hsc($itemtitleprev);
+                               break;
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_prevlink()
+        * Parse skinvar prevlink
+        * 
+        * @param       string  $linktext       text as a content of anchor element
+        * @param       integer the amount of links
+        * @return      void
+        */
+       public function parse_prevlink($linktext = '', $amount = 10)
+       {
+               global $itemidprev, $archiveprev, $startpos;
+               
+               if ( $this->skintype == 'item' )
+               {
+                       $this->itemlink($itemidprev, $linktext);
+               }
+               else if ( $this->skintype == 'search' || $this->skintype == 'index' )
+               {
+                       $this->searchlink($amount, $startpos, 'prev', $linktext);
+               }
+               else
+               {
+                       $this->archivelink($archiveprev, $linktext);
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_query()
+        * Parse skinvar query
+        * (includes the search query)   
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_query()
+       {
+               global $query;
+               echo Entity::hsc($query);
+               return;
+       }
+       
+       /**
+        * Actions::parse_referer()
+        * Parse skinvar referer
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_referer()
+       {
+               echo Entity::hsc(serverVar('HTTP_REFERER'));
+               return;
+       }
+       
+       /**
+        * Actions::parse_searchform()
+        * Parse skinvar searchform
+        * 
+        * @param       string  $blogname       name of weblog
+        * @return      void
+        */
+       public function parse_searchform($blogname = '')
+       {
+               global $CONF, $manager, $maxresults;
+               if ( $blogname )
+               {
+                       $blog =& $manager->getBlog(getBlogIDFromName($blogname));
+               }
+               else
+               {
+                       global $blog;
+               }
+               // use default blog when no blog is selected
+               $this->formdata = array(
+                       'id'    => $blog?$blog->getID():$CONF['DefaultBlog'],
+                       'query' => Entity::hsc(getVar('query')),
+               );
+               $this->doForm('searchform');
+               return;
+       }
+       
+       /**
+        * Actions::parse_searchresults()
+        * Parse skinvar searchresults
+        * 
+        * @param       string  $template       name of tempalte
+        * @param       integer $maxresults     searched items in a display
+        * @return      void;
+        */
+       public function parse_searchresults($template, $maxresults = 50 )
+       {
+               global $blog, $query, $amount, $startpos;
+               
+               $this->setBlogCategory($blog, '');      // need this to select default category
+               $this->preBlogContent('searchresults',$blog);
+               $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
+               $this->postBlogContent('searchresults',$blog);
+               return;
+       }
+       
+       /**
+        * Actions::parse_self()
+        * Parse skinvar self
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_self()
+       {
+               global $CONF;
+               echo $CONF['Self'];
+               return;
+       }
+       
+       /**
+        * Actions::parse_sitevar()
+        * Parse skinvar sitevar
+        * (include a sitevar)
+        * 
+        * @param       string  $which
+        * @return      void
+        */
+       public function parse_sitevar($which)
+       {
+               global $CONF;
+               switch ( $which )
+               {
+                       case 'url':
+                               echo $CONF['IndexURL'];
+                               break;
+                       case 'name':
+                               echo $CONF['SiteName'];
+                               break;
+                       case 'admin':
+                               echo $CONF['AdminEmail'];
+                               break;
+                       case 'adminurl':
+                               echo $CONF['AdminURL'];
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_skinname()
+        * Parse skinname
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_skinname()
+       {
+               echo $this->skin->getName();
+               return;
+       }
+       
+       /**
+        * Actions::parse_skintype()
+        * Parse skintype (experimental)
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_skintype()
+       {
+               echo $this->skintype;
+               return;
+       }
+       
+       /**
+        * Actions::parse_text()
+        * Parse text
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_text($which)
+       {
+               // constant($which) only available from 4.0.4 :(
+               if ( defined($which) )
+               {
+                       eval("echo $which;");
+               }
+               return;
+       }
+       
+       /**
+        * Actions::parse_ticket()
+        * Parse ticket
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_ticket()
+       {
+               global $manager;
+               $manager->addTicketHidden();
+               return;
+       }
+
+       /**
+        * Actions::parse_todaylink()
+        * Parse skinvar todaylink
+        * A link to the today page (depending on selected blog, etc...)
+        *
+        * @param       string  $linktext       text for link
+        * @return      void
+        */
+       public function parse_todaylink($linktext = '')
+       {
+               global $blog, $CONF;
+               if ( $blog )
+               {
+                       echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
+               }
+               else
+               {
+                       echo $this->link($CONF['SiteUrl'], $linktext);
+               }
+               return;
+       }
+       
+       /**
+        * Parse vars
+        * When commentform is not used, to include a hidden field with itemid   
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_vars()
+       {
+               global $itemid;
+               echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";
+               return;
+       }
+
+       /**
+        * Actions::parse_version()
+        * Parse skinvar version
+        * (include nucleus versionnumber)       
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_version()
+       {
+               global $nucleus;
+               echo 'Nucleus CMS ' . $nucleus['version'];
+               return;
+       }
+       
+       /**
+        * Actions::parse_sticky()
+        * Parse skinvar sticky
+        * 
+        * @param       integer $itemnumber     id of item
+        * @param       string  $template       name of template
+        * @return      void
+        */
+       public function parse_sticky($itemnumber = 0, $template = '')
+       {
+               global $manager;
+               
+               $itemnumber = intval($itemnumber);
+               $itemarray = array($itemnumber);
+               
+               $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
+               $this->preBlogContent('sticky',$b);
+               $this->amountfound = $b->readLogFromList($itemarray, $template);
+               $this->postBlogContent('sticky',$b);
+               return;
+       }
+}
index 7739466..6657749 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2012 The Nucleus Group
+ * 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
@@ -13,7 +13,7 @@
  * The code for the Nucleus admin area
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2012 The Nucleus Group
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
  * @version $Id: ADMIN.php 1661 2012-02-12 11:55:39Z sakamocchi $
 
  */
@@ -4218,52 +4218,60 @@ selector();
         $this->action_templateoverview();
     }
 
-    /**
-     * @todo document this
-     */
-    function action_skinoverview() {
-        global $member, $manager;
-
-        $member->isAdmin() or $this->disallow();
-
-        $this->pagehead();
-
-        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-        echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
-
-        echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
-
-        $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
-        $template['content'] = 'skinlist';
-        $template['tabindex'] = 10;
-        showlist($query,'table',$template);
-
-        echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
-
-        ?>
-        <form method="post" action="index.php">
-        <div>
-
-        <input name="action" value="skinnew" type="hidden" />
-        <?php $manager->addTicketHidden() ?>
-        <table><tr>
-            <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
-            <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_DESC?></td>
-            <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
-        </tr><tr>
-            <td><?php echo _SKIN_CREATE?></td>
-            <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-        </tr></table>
-
-        </div>
-        </form>
-
-        <?php
-        $this->pagefoot();
-    }
+       /**
+        * Admin::action_skinoverview()
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function action_skinoverview()
+       {
+               global $member, $manager;
+               
+               $member->isAdmin() or $this->disallow();
+               
+               $this->pagehead();
+               
+               echo '<p><a href="index.php?action=manage">(' . _BACKTOMANAGE . ")</a></p>\n";
+               echo '<h2>' . _SKIN_EDIT_TITLE . "</h2>\n";
+               echo '<h3>' . _SKIN_AVAILABLE_TITLE . "</h3>\n";
+               
+               $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname;';
+               $template['content'] = 'skinlist';
+               $template['tabindex'] = 10;
+               $template['friendly_names'] = Skin::getFriendlyNames('Actions');
+               showlist($query,'table',$template);
+               
+               echo '<h3>' . _SKIN_NEW_TITLE . "</h3>\n";
+               echo "<form method=\"post\" action=\"index.php\">\n";
+               echo "<div>\n";
+               echo "<input name=\"action\" value=\"skinnew\" type=\"hidden\" />\n";
+               
+               $manager->addTicketHidden() . "\n";
+               
+               echo "<table frame=\"box\" rules=\"all\" summary=\"skinoverview\">\n";
+               echo "<tr>\n";
+               echo "<td>" . _SKIN_NAME;
+               echo help('shortnames');
+               echo "</td>\n";
+               echo "<td><input name=\"name\" tabindex=\"10010\" maxlength=\"20\" size=\"20\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo "<td>" . _SKIN_DESC . "</td>\n";
+               echo "<td><input name=\"desc\" tabindex=\"10020\" maxlength=\"200\" size=\"50\" /></td>\n";
+               echo "</tr>\n";
+               echo "<tr>\n";
+               echo '<td>' . _SKIN_CREATE . "</td>\n";
+               echo '<td><input type="submit" tabindex="10030" value="' . _SKIN_CREATE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
+               echo "</tr>\n";
+               echo "</table>\n";
+               
+               echo "</div>\n";
+               echo "</form>\n";
+               
+               $this->pagefoot();
+               return;
+       }
 
     /**
      * @todo document this
index c602467..38a1e9d 100644 (file)
-<?php\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2012 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
- * Class representing a skin\r
- *\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
- * @version $Id: SKIN.php 1727 2012-04-07 02:54:22Z sakamocchi $\r
- */\r
-\r
-if ( !function_exists('requestVar') ) \r
-{\r
-       exit;\r
-}\r
-require_once dirname(__FILE__) . '/ACTIONS.php';\r
-\r
-class Skin\r
-{\r
-       // after creating a SKIN object, evaluates to true when the skin exists\r
-       private $valid;\r
-       \r
-       // skin characteristics. Use the getXXX methods rather than accessing directly\r
-       private $id;\r
-       private $description;\r
-       private $contentType;\r
-       private $includeMode;           // either 'normal' or 'skindir'\r
-       private $includePrefix;\r
-       private $name;\r
-       \r
-       /**\r
-        * Skin::__construct()\r
-        * Constructor for a new SKIN object\r
-        * \r
-        * @param       integer $id     id of the skin\r
-        * @return      void\r
-        */\r
-       public function __construct($id)\r
-       {\r
-               $this->id = (integer) $id;\r
-               \r
-               // read skin name/description/content type\r
-               $query = "SELECT * FROM %s WHERE sdnumber=%d";\r
-               $query = sprintf($query, sql_table('skin_desc'), (integer) $this->id);\r
-               $res = sql_query($query);\r
-               $obj = sql_fetch_object($res);\r
-               $this->valid = (sql_num_rows($res) > 0);\r
-               if ( !$this->valid )\r
-               {\r
-                       return;\r
-               }\r
-               \r
-               $this->name = $obj->sdname;\r
-               $this->description = $obj->sddesc;\r
-               $this->contentType = $obj->sdtype;\r
-               $this->includeMode = $obj->sdincmode;\r
-               $this->includePrefix = $obj->sdincpref;\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getID()\r
-        * Get SKIN id\r
-        * \r
-        * @param       void\r
-        * @return      integer id for this skin instance\r
-        */\r
-       public function getID()\r
-       {\r
-               return (integer) $this->id;\r
-       }\r
-       \r
-       /**\r
-        * Skin::isValid()\r
-        * \r
-        * @param       void\r
-        * @return      boolean\r
-        */\r
-       public function isValid()\r
-       {\r
-               return (boolean) $this->valid;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getName()\r
-        * Get SKIN name\r
-        * \r
-        * @param       void\r
-        * @return      string  name of this skin instance\r
-        */\r
-       public function getName()\r
-       {\r
-               return (string) $this->name;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getDescription()\r
-        * Get SKIN description\r
-        * \r
-        * @param       void\r
-        * @return      string  description of this skin instance\r
-        */\r
-       public function getDescription()\r
-       {\r
-               return (string) $this->description;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getContentType()\r
-        * Get SKIN content type\r
-        * e.g. text/xml, text/html, application/atom+xml\r
-        * \r
-        * @param       void\r
-        * @return      string  name of this skin instance\r
-        */\r
-       public function getContentType()\r
-       {\r
-               return (string) $this->contentType;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getIncludeMode()\r
-        * Get include mode of the SKIN\r
-        * \r
-        * Returns either 'normal' or 'skindir':\r
-        * 'normal': if a all data of the skin can be found in the databse\r
-        * 'skindir': if the skin has data in the it's skin driectory\r
-        * \r
-        * @param       void\r
-        * @return      string  normal/skindir\r
-        */\r
-       public function getIncludeMode()\r
-       {\r
-               return (string) $this->includeMode;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getIncludePrefix()\r
-        * Get include prefix of the SKIN\r
-        * \r
-        * Get name of the subdirectory (with trailing slash) where\r
-        * the files of the current skin can be found (e.g. 'default/')\r
-        * \r
-        * @param       void\r
-        * @return      string  include prefix of this skin instance\r
-        */\r
-       public function getIncludePrefix()\r
-       {\r
-               return (string) $this->includePrefix;\r
-       }\r
-       \r
-       /**\r
-        * Skin::exists()\r
-        * Checks if a skin with a given shortname exists\r
-        * \r
-        * @static\r
-        * @param       string  $name   Skin short name\r
-        * @return      integer number of skins with the given ID\r
-        */\r
-       static public function exists($name)\r
-       {\r
-               $query = "SELECT COUNT(*) AS result FROM %s WHERE sdname='%s';";\r
-               $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name));\r
-               return quickQuery($query) > 0;\r
-       }\r
-       \r
-       /**\r
-        * Skin::existsID()\r
-        * Checks if a skin with a given ID exists\r
-        * \r
-        * @static\r
-        * @param       string  $id     Skin ID\r
-        * @return      integer number of skins with the given ID\r
-        */\r
-       static public function existsID($id)\r
-       {\r
-               $query = "SELECT COUNT(*) AS result FROM %s WHERE sdnumber=%d;";\r
-               $query = sprintf($query, sql_table('skin_desc'), (integer) $id);\r
-               return quickQuery($query) > 0;\r
-       }\r
-       \r
-       /**\r
-        * Skin::createFromName()\r
-        * Returns a skin given its shortname\r
-        * \r
-        * @static\r
-        * @param       string  $name   Skin shortname\r
-        * @return      object instance of Skin class\r
-        */\r
-       static public function createFromName($name)\r
-       {\r
-               return new SKIN(SKIN::getIdFromName($name));\r
-       }\r
-       \r
-       /**\r
-        * Skin::getIdFromName()\r
-        * Returns a skin ID given its shortname\r
-        * \r
-        * @static\r
-        * @param       string  $name   Skin shortname\r
-        * @return      integer Skin ID\r
-        */\r
-       static public function getIdFromName($name)\r
-       {\r
-               $query = "SELECT sdnumber FROM %s WHERE sdname='%s';";\r
-               $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name));\r
-               $res = sql_query($query);\r
-               $obj = sql_fetch_object($res);\r
-               return $obj->sdnumber;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getNameFromId()\r
-        * Returns a skin shortname given its ID\r
-        * \r
-        * @static\r
-        * @param       string  $name\r
-        * @return      string  Skin short name\r
-        */\r
-       static public function getNameFromId($id)\r
-       {\r
-               $query = "SELECT sdname AS result FROM %s WHERE sdnumber=%d;";\r
-               $query = sprintf($query, sql_table('skin_desc'), (integer) $id);\r
-               return quickQuery($query);\r
-       }\r
-       \r
-       /**\r
-        * SKIN::createNew()\r
-        * Creates a new skin, with the given characteristics.\r
-        *\r
-        * @static\r
-        * @param       String  $name   value for nucleus_skin.sdname\r
-        * @param       String  $desc   value for nucleus_skin.sddesc\r
-        * @param       String  $type   value for nucleus_skin.sdtype\r
-        * @param       String  $includeMode    value for nucleus_skin.sdinclude\r
-        * @param       String  $includePrefix  value for nucleus_skin.sdincpref\r
-        * @return      Integer ID for just inserted record\r
-        */\r
-       function createNew($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '')\r
-       {\r
-               global $manager;\r
-               \r
-               $manager->notify(\r
-                       'PreAddSkin',\r
-                       array(\r
-                               'name' => &$name,\r
-                               'description' => &$desc,\r
-                               'type' => &$type,\r
-                               'includeMode' => &$includeMode,\r
-                               'includePrefix' => &$includePrefix\r
-                       )\r
-               );\r
-               \r
-               $query = "INSERT INTO %s (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('%s', '%s', '%s', '%s', '%s');";\r
-               $sdname         = sql_real_escape_string($name);\r
-               $sddesc         = sql_real_escape_string($desc);\r
-               $sdtype         = sql_real_escape_string($type);\r
-               $sdincmode      = sql_real_escape_string($includeMode);\r
-               $sdincpref      = sql_real_escape_string($includePrefix);\r
-               $query = sprintf($query, sql_table('skin_desc'), $sdname, $sddesc, $sdtype, $sdincmode, $sdincpref);\r
-               sql_query($query);\r
-               $newid = sql_insert_id();\r
-               \r
-               $manager->notify(\r
-                       'PostAddSkin',\r
-                       array(\r
-                               'skinid'                => $newid,\r
-                               'name'                  => $name,\r
-                               'description'   => $desc,\r
-                               'type'                  => $type,\r
-                               'includeMode'   => $includeMode,\r
-                               'includePrefix' => $includePrefix\r
-                       )\r
-               );\r
-               return $newid;\r
-       }\r
-       \r
-       /**\r
-        * Skin::parse()\r
-        * Parse a SKIN\r
-        * \r
-        * @param       string  $type\r
-        * @return      void\r
-        */\r
-       public function parse($type)\r
-       {\r
-               global $currentSkinName, $manager, $CONF;\r
-               \r
-               $manager->notify('InitSkinParse',array('skin' => &$this, 'type' => $type));\r
-               \r
-               // set output type\r
-               sendContentType($this->getContentType(), 'skin');\r
-               \r
-               // set skin name as global var (so plugins can access it)\r
-               $currentSkinName = $this->getName();\r
-               $contents = $this->getContent($type);\r
-               \r
-               if ( !$contents )\r
-               {\r
-                       // use base skin if this skin does not have contents\r
-                       $defskin = new SKIN($CONF['BaseSkin']);\r
-                       $contents = $defskin->getContent($type);\r
-                       if ( !$contents )\r
-                       {\r
-                               echo _ERROR_SKIN;\r
-                               return;\r
-                       }\r
-               }\r
-               \r
-               $actions = $this->getAllowedActionsForType($type);\r
-               \r
-               $manager->notify('PreSkinParse',array('skin' => &$this, 'type' => $type, 'contents' => &$contents));\r
-               \r
-               // set IncludeMode properties of parser\r
-               Parser::setProperty('IncludeMode', $this->getIncludeMode());\r
-               Parser::setProperty('IncludePrefix', $this->getIncludePrefix());\r
-               \r
-               $handler = new Actions($type, $this);\r
-               $parser = new Parser($actions, $handler);\r
-               $handler->setParser($parser);\r
-               $handler->setSkin($this);\r
-               $parser->parse($contents);\r
-               \r
-               $manager->notify('PostSkinParse',array('skin' => &$this, 'type' => $type));\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getContent()\r
-        * Get content of the skin part from the database\r
-        * \r
-        * @param       string  $type   type of the skin (e.g. index, item, search ...)\r
-        * @return      string  content of scontent\r
-        */\r
-       function getContent($type)\r
-       {\r
-               $query = "SELECT scontent FROM %s WHERE sdesc=%d and stype='%s';";\r
-               $query = sprintf($query, sql_table('skin'), (integer) $this->id, sql_real_escape_string($type));\r
-               $res = sql_query($query);\r
-               \r
-               if ( sql_num_rows($res) == 0 )\r
-               {\r
-                       return '';\r
-               }\r
-               return sql_result($res, 0, 0);\r
-       }\r
-\r
-       /**\r
-        * SKIN::update()\r
-        * Updates the contents for one part of the skin in the database\r
-        * \r
-        * @param       string  $type type of the skin part (e.g. index, item, search ...) \r
-        * @param       string  $content new content for this skin part\r
-        * @return      void\r
-        * \r
-        */\r
-       function update($type, $content)\r
-       {\r
-               global $manager;\r
-               \r
-               $query = "SELECT sdesc FROM %s WHERE stype='%s' and sdesc=%d;";\r
-               $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id);\r
-               $res = sql_query($query);\r
-               \r
-               $skintypeexists = sql_fetch_object($res);\r
-               $skintypevalue = ($content == true);\r
-               \r
-               if( $skintypevalue && $skintypeexists )\r
-               {\r
-                       // PreUpdateSkinPart event\r
-                       $manager->notify(\r
-                               'PreUpdateSkinPart',\r
-                               array(\r
-                                       'skinid' => $this->id,\r
-                                       'type' => $type,\r
-                                       'content' => &$content\r
-                               )\r
-                       );\r
-               }\r
-               else if( $skintypevalue && !$skintypeexists )\r
-               {\r
-                       // PreAddSkinPart event\r
-                       $manager->notify(\r
-                               'PreAddSkinPart',\r
-                               array(\r
-                                       'skinid' => $this->id,\r
-                                       'type' => $type,\r
-                                       'content' => &$content\r
-                               )\r
-                       );\r
-               }\r
-               else if( !$skintypevalue && $skintypeexists )\r
-               {\r
-                       // PreDeleteSkinPart event\r
-                       $manager->notify(\r
-                               'PreDeleteSkinPart',\r
-                               array(\r
-                                       'skinid' => $this->id,\r
-                                       'type' => $type\r
-                               )\r
-                       );\r
-               }\r
-               \r
-               // delete old thingie\r
-               $query = "DELETE FROM %s WHERE stype='%s' and sdesc=%d";\r
-               $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id);\r
-               sql_query($query);\r
-               \r
-               // write new thingie\r
-               if ( $content )\r
-               {\r
-                       $query = "INSERT INTO %s (scontent, stype, sdesc) VALUE ('%s', '%s', %d)";\r
-                       $query = sprintf($query, sql_table('skin'), sql_real_escape_string($content), sql_real_escape_string($type), (integer) $this->id);\r
-                       sql_query($query);\r
-               }\r
-               \r
-               if( $skintypevalue && $skintypeexists )\r
-               {\r
-                       // PostUpdateSkinPart event\r
-                       $manager->notify(\r
-                       'PostUpdateSkinPart',\r
-                               array(\r
-                                       'skinid'        => $this->id,\r
-                                       'type'          => $type,\r
-                                       'content'       => &$content\r
-                               )\r
-                       );\r
-               }\r
-               else if( $skintypevalue && (!$skintypeexists) )\r
-               {\r
-                       // PostAddSkinPart event\r
-                       $manager->notify(\r
-                               'PostAddSkinPart',\r
-                               array(\r
-                                       'skinid'        => $this->id,\r
-                                       'type'          => $type,\r
-                                       'content'       => &$content\r
-                               )\r
-                       );\r
-               }\r
-               else if( (!$skintypevalue) && $skintypeexists )\r
-               {\r
-                       // PostDeleteSkinPart event\r
-                       $manager->notify(\r
-                               'PostDeleteSkinPart',\r
-                               array(\r
-                                       'skinid'        => $this->id,\r
-                                       'type'          => $type\r
-                               )\r
-                       );\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Skin::deleteAllParts()\r
-        * Deletes all skin parts from the database\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       function deleteAllParts()\r
-       {\r
-               $query = "DELETE FROM %s WHERE sdesc=%d;";\r
-               $query = sprintf($query, sql_table('skin'), (integer) $this->id);\r
-               sql_query($query);\r
-       }\r
-       \r
-       /**\r
-        * Skin::updateGeneralInfo()\r
-        * Updates the general information about the skin\r
-        * \r
-        * @param       string  $name                   name of the skin\r
-        * @param       string  $desc                   description of the skin\r
-        * @param       string  $type                   type of the skin\r
-        * @param       string  $includeMode    include mode of the skin\r
-        * @param       string  $includePrefix  include prefix of the skin\r
-        * @return      void\r
-        */\r
-       function updateGeneralInfo($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '')\r
-       {\r
-               $name                   = sql_real_escape_string($name);\r
-               $desc                   = sql_real_escape_string($desc);\r
-               $type                   = sql_real_escape_string($type);\r
-               $includeMode    = sql_real_escape_string($includeMode);\r
-               $includePrefix  = sql_real_escape_string($includePrefix);\r
-               \r
-               $query ="UPDATE %s SET sdname='', sddesc='%s', sdtype='%s', sdincmode='%s', sdincpref='%s' WHERE sdnumber=%d:";\r
-               $query = sprintf($query, $name, $desc, $type, $includeMode, $includePrefix, (integer) $this->id);\r
-               \r
-               sql_query($query);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getFriendlyNames()\r
-        * Get an array with the names of possible skin parts\r
-        * Used to show all possible parts of a skin in the administration backend\r
-        * \r
-        * @param       void\r
-        * @param       array   type of the skin\r
-        */\r
-       static public function getFriendlyNames()\r
-       {\r
-               $skintypes = array(\r
-                       'index'                 => _SKIN_PART_MAIN,\r
-                       'item'                  => _SKIN_PART_ITEM,\r
-                       'archivelist'   => _SKIN_PART_ALIST,\r
-                       'archive'               => _SKIN_PART_ARCHIVE,\r
-                       'search'                => _SKIN_PART_SEARCH,\r
-                       'error'                 => _SKIN_PART_ERROR,\r
-                       'member'                => _SKIN_PART_MEMBER,\r
-                       'imagepopup'    => _SKIN_PART_POPUP\r
-               );\r
-               \r
-               $query = "SELECT stype FROM " . sql_table('skin')\r
-                      . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member')";\r
-               $res = sql_query($query);\r
-               while ( $row = sql_fetch_array($res) )\r
-               {\r
-                       /* TODO: ucfirst() depends on the current locale  */\r
-                       $skintypes[strtolower($row['stype'])] = ucfirst($row['stype']);\r
-               }\r
-               return $skintypes;\r
-       }\r
-       \r
-       /**\r
-        * Skin::getAllowedActionsForType()\r
-        * Get the allowed actions for a skin type\r
-        * returns an array with the allowed actions\r
-        * \r
-        * @param       string  $type   type of the skin (e.g. index, item, search ...)\r
-        * @return      array   allowed action types\r
-        */\r
-       function getAllowedActionsForType($type)\r
-       {\r
-               global $blogid;\r
-               \r
-               // some actions that can be performed at any time, from anywhere\r
-               $defaultActions = array(\r
-                       'otherblog',\r
-                       'plugin',\r
-                       'version',\r
-                       'nucleusbutton',\r
-                       'include',\r
-                       'phpinclude',\r
-                       'parsedinclude',\r
-                       'loginform',\r
-                       'sitevar',\r
-                       'otherarchivelist',\r
-                       'otherarchivedaylist',\r
-                       'otherarchiveyearlist',\r
-                       'self',\r
-                       'adminurl',\r
-                       'todaylink',\r
-                       'archivelink',\r
-                       'member',\r
-                       'category',\r
-                       'searchform',\r
-                       'referer',\r
-                       'skinname',\r
-                       'skinfile',\r
-                       'set',\r
-                       'if',\r
-                       'else',\r
-                       'endif',\r
-                       'elseif',\r
-                       'ifnot',\r
-                       'elseifnot',\r
-                       'charset',\r
-                       'bloglist',\r
-                       'addlink',\r
-                       'addpopupcode',\r
-                       'sticky',\r
-                       // deprecated (Nucleus v2.0)\r
-                       /* TODO: remove this */\r
-                       'ifcat'\r
-               );\r
-               \r
-               // extra actions specific for a certain skin type\r
-               $extraActions = array();\r
-               \r
-               switch ( $type )\r
-               {\r
-                       case 'index':\r
-                               $extraActions = array(\r
-                                       'blog',\r
-                                       'blogsetting',\r
-                                       'preview',\r
-                                       'additemform',\r
-                                       'categorylist',\r
-                                       'archivelist',\r
-                                       'archivedaylist',\r
-                                       'archiveyearlist',\r
-                                       'nextlink',\r
-                                       'prevlink'\r
-                               );\r
-                               break;\r
-                       case 'archive':\r
-                               $extraActions = array(\r
-                                       'blog',\r
-                                       'archive',\r
-                                       'otherarchive',\r
-                                       'categorylist',\r
-                                       'archivelist',\r
-                                       'archivedaylist',\r
-                                       'archiveyearlist',\r
-                                       'blogsetting',\r
-                                       'archivedate',\r
-                                       'nextarchive',\r
-                                       'prevarchive',\r
-                                       'nextlink',\r
-                                       'prevlink',\r
-                                       'archivetype'\r
-                               );\r
-                               break;\r
-                       case 'archivelist':\r
-                               $extraActions = array(\r
-                                       'blog',\r
-                                       'archivelist',\r
-                                       'archivedaylist',\r
-                                       'archiveyearlist',\r
-                                       'categorylist',\r
-                                       'blogsetting'\r
-                               );\r
-                               break;\r
-                       case 'search':\r
-                               $extraActions = array(\r
-                                       'blog',\r
-                                       'archivelist',\r
-                                       'archivedaylist',\r
-                                       'archiveyearlist',\r
-                                       'categorylist',\r
-                                       'searchresults',\r
-                                       'othersearchresults',\r
-                                       'blogsetting',\r
-                                       'query',\r
-                                       'nextlink',\r
-                                       'prevlink'\r
-                               );\r
-                               break;\r
-                       case 'imagepopup':\r
-                               $extraActions = array(\r
-                                       'image',\r
-                                       // deprecated (Nucleus v2.0)\r
-                                       /* TODO: remove this */\r
-                                       'imagetext'\r
-                               );\r
-                               break;\r
-                       case 'member':\r
-                               $extraActions = array(\r
-                                       'membermailform',\r
-                                       'blogsetting',\r
-                                       'nucleusbutton',\r
-                                       'categorylist'\r
-                               );\r
-                               break;\r
-                       case 'item':\r
-                               $extraActions = array(\r
-                                       'blog',\r
-                                       'item',\r
-                                       'comments',\r
-                                       'commentform',\r
-                                       'vars',\r
-                                       'blogsetting',\r
-                                       'nextitem',\r
-                                       'previtem',\r
-                                       'nextlink',\r
-                                       'prevlink',\r
-                                       'nextitemtitle',\r
-                                       'previtemtitle',\r
-                                       'categorylist',\r
-                                       'archivelist',\r
-                                       'archivedaylist',\r
-                                       'archiveyearlist',\r
-                                       'itemtitle',\r
-                                       'itemid',\r
-                                       'itemlink'\r
-                               );\r
-                               break;\r
-                       case 'error':\r
-                               $extraActions = array(\r
-                                       'errormessage',\r
-                                       'categorylist'\r
-                               );\r
-                               break;\r
-                       default:\r
-                               if ( $blogid && $blogid > 0 )\r
-                               {\r
-                                       $extraActions = array(\r
-                                               'blog',\r
-                                               'blogsetting',\r
-                                               'preview',\r
-                                               'additemform',\r
-                                               'categorylist',\r
-                                               'archivelist',\r
-                                               'archivedaylist',\r
-                                               'archiveyearlist',\r
-                                               'nextlink',\r
-                                               'prevlink',\r
-                                               'membermailform',\r
-                                               'nucleusbutton',\r
-                                               'categorylist'\r
-                                       );\r
-                               }\r
-                               break;\r
-               }\r
-               return array_merge($defaultActions, $extraActions);\r
-       }\r
-}\r
+<?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)
+ */
+/**
+ * Class representing a skin
+ *
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: SKIN.php 1755 2012-04-14 10:05:49Z sakamocchi $
+ */
+
+if ( !function_exists('requestVar') ) 
+{
+       exit;
+}
+
+class Skin
+{
+       // after creating a SKIN object, evaluates to true when the skin exists
+       private $valid;
+       
+       // skin characteristics. Use the getXXX methods rather than accessing directly
+       private $id;
+       private $description;
+       private $contentType;
+       private $includeMode;           // either 'normal' or 'skindir'
+       private $includePrefix;
+       private $name;
+       
+       /* action class */
+       private $action_class;
+       private $event_identifier;
+       
+       /**
+        * Skin::__construct()
+        * Constructor for a new SKIN object
+        * 
+        * @param       integer $id                                     id of the skin
+        * @param       string  $action_class           name of class extended from BaseActions
+        * @param       string  $event_identifier       event identifier. for example, InitAdminSkinParse if AdminSkin is used
+        * @return      void
+        */
+       public function __construct($id, $action_class='Actions', $event_identifier='Skin')
+       {
+               global $DIR_LIBS;
+               
+               $this->id = (integer) $id;
+               
+               // read skin name/description/content type
+               $query = "SELECT * FROM %s WHERE sdnumber=%d";
+               $query = sprintf($query, sql_table('skin_desc'), (integer) $this->id);
+               $res = sql_query($query);
+               $obj = sql_fetch_object($res);
+               $this->valid = (sql_num_rows($res) > 0);
+               if ( !$this->valid )
+               {
+                       return;
+               }
+               
+               /*
+                * NOTE: include needed action class
+                */
+               if ( $action_class != 'Actions' )
+               {
+                       if ( !class_exists($action_class, FALSE)
+                         && (!file_exists("{$DIR_LIBS}{$action_class}.php")
+                          || !include("{$DIR_LIBS}{$action_class}.php")) )
+                       {
+                               return;
+                       }
+               }
+               else
+               {
+                       if ( !class_exists('Actions', FALSE)
+                         && (!file_exists("{$DIR_LIBS}ACTIONS.php")
+                          || !include("{$DIR_LIBS}ACTIONS.php")) )
+                       {
+                               return;
+                       }
+               }
+               
+               $this->action_class = $action_class;
+               $this->event_identifier = $event_identifier;
+               
+               $this->name = $obj->sdname;
+               $this->description = $obj->sddesc;
+               $this->contentType = $obj->sdtype;
+               $this->includeMode = $obj->sdincmode;
+               $this->includePrefix = $obj->sdincpref;
+               
+               return;
+       }
+       
+       /**
+        * Skin::getID()
+        * Get SKIN id
+        * 
+        * @param       void
+        * @return      integer id for this skin instance
+        */
+       public function getID()
+       {
+               return (integer) $this->id;
+       }
+       
+       /**
+        * Skin::isValid()
+        * 
+        * @param       void
+        * @return      boolean
+        */
+       public function isValid()
+       {
+               return (boolean) $this->valid;
+       }
+       
+       /**
+        * Skin::getName()
+        * Get SKIN name
+        * 
+        * @param       void
+        * @return      string  name of this skin instance
+        */
+       public function getName()
+       {
+               return (string) $this->name;
+       }
+       
+       /**
+        * Skin::getDescription()
+        * Get SKIN description
+        * 
+        * @param       void
+        * @return      string  description of this skin instance
+        */
+       public function getDescription()
+       {
+               return (string) $this->description;
+       }
+       
+       /**
+        * Skin::getContentType()
+        * Get SKIN content type
+        * e.g. text/xml, text/html, application/atom+xml
+        * 
+        * @param       void
+        * @return      string  name of this skin instance
+        */
+       public function getContentType()
+       {
+               return (string) $this->contentType;
+       }
+       
+       /**
+        * Skin::getIncludeMode()
+        * Get include mode of the SKIN
+        * 
+        * Returns either 'normal' or 'skindir':
+        * 'normal': if a all data of the skin can be found in the databse
+        * 'skindir': if the skin has data in the it's skin driectory
+        * 
+        * @param       void
+        * @return      string  normal/skindir
+        */
+       public function getIncludeMode()
+       {
+               return (string) $this->includeMode;
+       }
+       
+       /**
+        * Skin::getIncludePrefix()
+        * Get include prefix of the SKIN
+        * 
+        * Get name of the subdirectory (with trailing slash) where
+        * the files of the current skin can be found (e.g. 'default/')
+        * 
+        * @param       void
+        * @return      string  include prefix of this skin instance
+        */
+       public function getIncludePrefix()
+       {
+               return (string) $this->includePrefix;
+       }
+       
+       /**
+        * Skin::exists()
+        * Checks if a skin with a given shortname exists
+        * 
+        * @static
+        * @param       string  $name   Skin short name
+        * @return      integer number of skins with the given ID
+        */
+       static public function exists($name)
+       {
+               $query = "SELECT COUNT(*) AS result FROM %s WHERE sdname='%s';";
+               $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name));
+               return (quickQuery($query) > 0);
+       }
+       
+       /**
+        * Skin::existsID()
+        * Checks if a skin with a given ID exists
+        * 
+        * @static
+        * @param       string  $id     Skin ID
+        * @return      integer number of skins with the given ID
+        */
+       static public function existsID($id)
+       {
+               $query = "SELECT COUNT(*) AS result FROM %s WHERE sdnumber=%d;";
+               $query = sprintf($query, sql_table('skin_desc'), (integer) $id);
+               return (quickQuery($query) > 0);
+       }
+       
+       /**
+        * Skin::createFromName()
+        * Returns a skin given its shortname
+        * 
+        * @static
+        * @param       string  $name   Skin shortname
+        * @return      object instance of Skin class
+        */
+       static public function createFromName($name)
+       {
+               return new SKIN(SKIN::getIdFromName($name));
+       }
+       
+       /**
+        * Skin::getIdFromName()
+        * Returns a skin ID given its shortname
+        * 
+        * @static
+        * @param       string  $name   Skin shortname
+        * @return      integer Skin ID
+        */
+       static public function getIdFromName($name)
+       {
+               $query = "SELECT sdnumber FROM %s WHERE sdname='%s';";
+               $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name));
+               $res = sql_query($query);
+               $obj = sql_fetch_object($res);
+               return $obj->sdnumber;
+       }
+       
+       /**
+        * Skin::getNameFromId()
+        * Returns a skin shortname given its ID
+        * 
+        * @static
+        * @param       string  $name
+        * @return      string  Skin short name
+        */
+       static public function getNameFromId($id)
+       {
+               $query = "SELECT sdname AS result FROM %s WHERE sdnumber=%d;";
+               $query = sprintf($query, sql_table('skin_desc'), (integer) $id);
+               return quickQuery($query);
+       }
+       
+       /**
+        * SKIN::createNew()
+        * Creates a new skin, with the given characteristics.
+        *
+        * @static
+        * @param       String  $name   value for nucleus_skin.sdname
+        * @param       String  $desc   value for nucleus_skin.sddesc
+        * @param       String  $type   value for nucleus_skin.sdtype
+        * @param       String  $includeMode    value for nucleus_skin.sdinclude
+        * @param       String  $includePrefix  value for nucleus_skin.sdincpref
+        * @return      Integer ID for just inserted record
+        */
+       public function createNew($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '')
+       {
+               global $manager;
+               
+               $manager->notify(
+                       'PreAddSkin',
+                       array(
+                               'name' => &$name,
+                               'description' => &$desc,
+                               'type' => &$type,
+                               'includeMode' => &$includeMode,
+                               'includePrefix' => &$includePrefix
+                       )
+               );
+               
+               $query = "INSERT INTO %s (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('%s', '%s', '%s', '%s', '%s');";
+               $sdname         = sql_real_escape_string($name);
+               $sddesc         = sql_real_escape_string($desc);
+               $sdtype         = sql_real_escape_string($type);
+               $sdincmode      = sql_real_escape_string($includeMode);
+               $sdincpref      = sql_real_escape_string($includePrefix);
+               $query = sprintf($query, sql_table('skin_desc'), $sdname, $sddesc, $sdtype, $sdincmode, $sdincpref);
+               sql_query($query);
+               $newid = sql_insert_id();
+               
+               $manager->notify(
+                       'PostAddSkin',
+                       array(
+                               'skinid'                => $newid,
+                               'name'                  => $name,
+                               'description'   => $desc,
+                               'type'                  => $type,
+                               'includeMode'   => $includeMode,
+                               'includePrefix' => $includePrefix
+                       )
+               );
+               return $newid;
+       }
+       
+       /**
+        * Skin::parse()
+        * Parse a SKIN
+        * 
+        * @param       string  $type
+        * @return      void
+        */
+       public function parse($type)
+       {
+               global $currentSkinName, $manager, $CONF;
+               
+               $manager->notify("Init{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));
+               
+               // set output type
+               sendContentType($this->getContentType(), 'skin');
+               
+               // set skin name as global var (so plugins can access it)
+               $currentSkinName = $this->getName();
+               $contents = $this->getContent($type);
+               
+               if ( !$contents )
+               {
+                       // use base skin if this skin does not have contents
+                       $defskin = new SKIN($CONF['BaseSkin']);
+                       $contents = $defskin->getContent($type);
+                       if ( !$contents )
+                       {
+                               echo _ERROR_SKIN;
+                               return;
+                       }
+               }
+               
+               $actions = $this->getAllowedActionsForType($type);
+               
+               $manager->notify("Pre{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type, 'contents' => &$contents));
+               
+               // set IncludeMode properties of parser
+               Parser::setProperty('IncludeMode', $this->getIncludeMode());
+               Parser::setProperty('IncludePrefix', $this->getIncludePrefix());
+               
+               $action_class = $this->action_class;
+               $handler = new $action_class($type);
+               
+               $parser = new Parser($actions, $handler);
+               $handler->setParser($parser);
+               $handler->setSkin($this);
+               $parser->parse($contents);
+               
+               $manager->notify("Post{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));
+               return;
+       }
+       
+       /**
+        * Skin::getContent()
+        * Get content of the skin part from the database
+        * 
+        * @param       string  $type   type of the skin (e.g. index, item, search ...)
+        * @return      string  content of scontent
+        */
+       public function getContent($type)
+       {
+               $query = "SELECT scontent FROM %s WHERE sdesc=%d and stype='%s';";
+               $query = sprintf($query, sql_table('skin'), (integer) $this->id, sql_real_escape_string($type));
+               $res = sql_query($query);
+               
+               if ( sql_num_rows($res) == 0 )
+               {
+                       return '';
+               }
+               return sql_result($res, 0, 0);
+       }
+
+       /**
+        * SKIN::update()
+        * Updates the contents for one part of the skin in the database
+        * 
+        * @param       string  $type type of the skin part (e.g. index, item, search ...) 
+        * @param       string  $content new content for this skin part
+        * @return      void
+        * 
+        */
+       public function update($type, $content)
+       {
+               global $manager;
+               
+               $query = "SELECT sdesc FROM %s WHERE stype='%s' and sdesc=%d;";
+               $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id);
+               $res = sql_query($query);
+               
+               $skintypeexists = sql_fetch_object($res);
+               $skintypevalue = ($content == true);
+               
+               if( $skintypevalue && $skintypeexists )
+               {
+                       $data = array(
+                               'skinid'        =>  $this->id,
+                               'type'          =>  $type,
+                               'content'       => &$content
+                       );
+                       
+                       // PreUpdateSkinPart event
+                       $manager->notify("PreUpdate{{$this->event_identifier}}Part", $data);
+               }
+               else if( $skintypevalue && !$skintypeexists )
+               {
+                       $data = array(
+                               'skinid' => $this->id,
+                               'type' => $type,
+                               'content' => &$content
+                       );
+                       
+                       $manager->notify("PreAdd{$this->event_identifier}Part", $data);
+               }
+               else if( !$skintypevalue && $skintypeexists )
+               {
+                       $data = array(
+                               'skinid' => $this->id,
+                               'type' => $type
+                       );
+                       
+                       $manager->notify("PreDelete{$this->event_identifier}Part", $data);
+               }
+               
+               // delete old thingie
+               $query = "DELETE FROM %s WHERE stype='%s' and sdesc=%d";
+               $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id);
+               sql_query($query);
+               
+               // write new thingie
+               if ( $content )
+               {
+                       $query = "INSERT INTO %s (scontent, stype, sdesc) VALUE ('%s', '%s', %d)";
+                       $query = sprintf($query, sql_table('skin'), sql_real_escape_string($content), sql_real_escape_string($type), (integer) $this->id);
+                       sql_query($query);
+               }
+               
+               if( $skintypevalue && $skintypeexists )
+               {
+                       $data = array(
+                               'skinid'        => $this->id,
+                               'type'          => $type,
+                               'content'       => &$content
+                       );
+                       
+                       // PostUpdateSkinPart event
+                       $manager->notify("PostUpdate{$this->event_identifier}Part", $data);
+               }
+               else if( $skintypevalue && (!$skintypeexists) )
+               {
+                       $data = array(
+                               'skinid'        => $this->id,
+                               'type'          => $type,
+                               'content'       => &$content
+                       );
+                       
+                       // PostAddSkinPart event
+                       $manager->notify("PostAdd{$this->event_identifier}Part", $data);
+               }
+               else if( (!$skintypevalue) && $skintypeexists )
+               {
+                       $data = array(
+                               'skinid'        => $this->id,
+                               'type'          => $type
+                       );
+                       
+                       $manager->notify("PostDelete{$this->event_identifier}Part", $data);
+               }
+               return;
+       }
+       
+       /**
+        * Skin::deleteAllParts()
+        * Deletes all skin parts from the database
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function deleteAllParts()
+       {
+               $query = "DELETE FROM %s WHERE sdesc=%d;";
+               $query = sprintf($query, sql_table('skin'), (integer) $this->id);
+               sql_query($query);
+       }
+       
+       /**
+        * Skin::updateGeneralInfo()
+        * Updates the general information about the skin
+        * 
+        * @param       string  $name                   name of the skin
+        * @param       string  $desc                   description of the skin
+        * @param       string  $type                   type of the skin
+        * @param       string  $includeMode    include mode of the skin
+        * @param       string  $includePrefix  include prefix of the skin
+        * @return      void
+        */
+       public function updateGeneralInfo($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '')
+       {
+               $name                   = sql_real_escape_string($name);
+               $desc                   = sql_real_escape_string($desc);
+               $type                   = sql_real_escape_string($type);
+               $includeMode    = sql_real_escape_string($includeMode);
+               $includePrefix  = sql_real_escape_string($includePrefix);
+               
+               $query ="UPDATE %s SET sdname='', sddesc='%s', sdtype='%s', sdincmode='%s', sdincpref='%s' WHERE sdnumber=%d:";
+               $query = sprintf($query, $name, $desc, $type, $includeMode, $includePrefix, (integer) $this->id);
+               
+               sql_query($query);
+               return;
+       }
+       
+       /**
+        * Skin::getAllowedActionsForType()
+        * Get the allowed actions for a skin type
+        * returns an array with the allowed actions
+        * 
+        * @param       string  $type   type of the skin (e.g. index, item, search ...)
+        * @return      array   allowed action types
+        */
+       public function getAllowedActionsForType($type)
+       {
+               /**
+                * NOTE: static method with variable class name is supported since PHP 5.3
+                *  So now we utilize eval function.
+                */
+               $page_action_names = array();
+               eval("\$defined_actions = {$this->action_class}::getDefinedActions('{$type}');");
+               return $defined_actions;
+       }
+       
+       /**
+        * Skin::getFriendlyNames()
+        * Get an array with the names of possible skin parts
+        * Used to show all possible parts of a skin in the administration backend
+        * 
+        * @static
+        * @param       string  $action_class   name of action class (optional)
+        * @param       array   type of the skin
+        */
+       static public function getFriendlyNames($action_class='Actions')
+       {
+               global $DIR_LIBS;
+               
+               /*
+                * NOTE: include needed action class
+                */
+               if ( $action_class != 'Actions' )
+               {
+                       if ( !class_exists($action_class, FALSE)
+                         && (!file_exists("{$DIR_LIBS}{$action_class}.php")
+                          || !include("{$DIR_LIBS}{$action_class}.php")) )
+                       {
+                               return;
+                       }
+               }
+               else
+               {
+                       if ( !class_exists('Actions', FALSE)
+                         && (!file_exists("{$DIR_LIBS}ACTIONS.php")
+                          || !include("{$DIR_LIBS}ACTIONS.php")) )
+                       {
+                               return;
+                       }
+               }
+               
+               /**
+                * NOTE: static method with variable class name is supported since PHP 5.3
+                *  So now we utilize eval function.
+                */
+               eval("\$friendly_names = {$action_class}::getSkinTypeFriendlyNames();");
+               
+               $action_names = array();
+               foreach ( $friendly_names as $action_name => $friendly_name )
+               {
+                       $action_names[] = $action_name;
+               }
+               
+               $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s');";
+               $query = sprintf($query, sql_table('skin'), implode("','", $action_names));
+               $res = sql_query($query);
+               
+               while ( $row = sql_fetch_array($res) )
+               {
+                       $friendly_names[strtolower($row['stype'])] = $row['stype'];
+               }
+               return $friendly_names;
+       }
+}
index cf51766..fd954ec 100644 (file)
-<?php\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2012 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
- * Functions to create lists of things inside the admin are\r
- *\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
- * @version $Id: showlist.php 1662 2012-02-12 12:18:37Z sakamocchi $\r
- */\r
-\r
-\r
-// can take either an array of objects, or an SQL query\r
-function showlist($query, $type, $template)\r
-{\r
-       if ( is_array($query) )\r
-       {\r
-               if ( sizeof($query) == 0 )\r
-               {\r
-                       return 0;\r
-               }\r
-               \r
-               call_user_func("listplug_{$type}", $template, 'HEAD');\r
-               \r
-               foreach ( $query as $currentObj )\r
-               {\r
-                       $template['current'] = $currentObj;\r
-                       call_user_func("listplug_{$type}", $template, 'BODY');\r
-               }\r
-               \r
-               call_user_func("listplug_{$type}", $template, 'FOOT');\r
-               \r
-               return sizeof($query);\r
-       }\r
-       else\r
-       {\r
-               $res = sql_query($query);\r
-               \r
-               // don't do anything if there are no results\r
-               $numrows = sql_num_rows($res);\r
-               if ( $numrows == 0 )\r
-               {\r
-                       return 0;\r
-               }\r
-               call_user_func("listplug_{$type}", $template, 'HEAD');\r
-               \r
-               while( $template['current'] = sql_fetch_object($res) )\r
-               {\r
-                       call_user_func("listplug_{$type}", $template, 'BODY');\r
-               }\r
-               \r
-               call_user_func("listplug_{$type}", $template, 'FOOT');\r
-               \r
-               sql_free_result($res);\r
-               \r
-               // return amount of results\r
-               return $numrows;\r
-       }\r
-}\r
-\r
-function listplug_select($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<select name="' . ifset($template['name']) . '" tabindex="' . ifset($template['tabindex']) . '" ' . ifset($template['javascript']) . ">\n";\r
-                       \r
-                       // add extra row if needed\r
-                       if ( ifset($template['extra']) )\r
-                       {\r
-                               echo '<option value="', ifset($template['extraval']), '">', $template['extra'], "</option>\n";\r
-                       }\r
-                       \r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-\r
-                       echo '<option value="' . Entity::hsc($current->value) . '"';\r
-                       if ( $template['selected'] == $current->value )\r
-                       {\r
-                               echo ' selected="selected" ';\r
-                       }\r
-                       if ( isset($template['shorten']) && $template['shorten'] > 0 )\r
-                       {\r
-                               echo ' title="'. Entity::hsc($current->text).'"';\r
-                               $current->text = Entity::hsc(Entity::shorten($current->text, $template['shorten'], $template['shortenel']));\r
-                       }\r
-                       echo '>' . Entity::hsc($current->text) . "</option>\n";\r
-                       break;\r
-               case 'FOOT':\r
-                       echo '</select>';\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo "\n\n";\r
-                       echo "<table frame=\"box\" rules=\"all\" summary=\"{$template['content']}\">\n";\r
-                       echo "<thead>\n";\r
-                       echo "<tr>\n";\r
-                       // print head\r
-                       call_user_func("listplug_table_{$template['content']}" , $template, 'HEAD');\r
-                       echo "</tr>\n";\r
-                       echo "</thead>\n";\r
-                       echo "<tbody>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       // print tabletype specific thingies\r
-                       echo "<tr>\n";\r
-                       call_user_func("listplug_table_{$template['content']}" , $template,  'BODY');\r
-                       echo "</tr>\n";\r
-                       break;\r
-               case 'FOOT':\r
-                       call_user_func("listplug_table_{$template['content']}" , $template,  'FOOT');\r
-                       echo "</tbody>\n";\r
-                       echo "</table>\n";\r
-                       echo "\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_memberlist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LIST_MEMBER_NAME . "</th>\n";\r
-                       echo '<th>' . _LIST_MEMBER_RNAME . "</th>\n";\r
-                       echo '<th>' . _LIST_MEMBER_URL . "</th>\n";\r
-                       echo '<th>' . _LIST_MEMBER_ADMIN . "</th>\n";\r
-                       help('superadmin');\r
-                       echo "</th>\n";\r
-                       echo '<th>' . _LIST_MEMBER_LOGIN;\r
-                       help('canlogin');\r
-                       echo "</th>\n";\r
-                       echo '<th colspan="2">' . _LISTS_ACTIONS. "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       echo '<td>';\r
-                       $id = listplug_nextBatchId();\r
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->mnumber}\" />\n";\r
-                       echo "<label for=\"batch{$id}\">\n";\r
-                       echo '<a href="mailto:' . Entity::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->mname), "</a>\n";\r
-                       echo "</label>\n";\r
-                       echo "</td>";\r
-                       echo "<td>" . Entity::hsc($current->mrealname) . "</td>\n";\r
-                       echo '<td><a href="' . Entity::hsc($current->murl) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->murl) . "</a></td>\n";\r
-                       echo '<td>' . ($current->madmin ? _YES : _NO) . "</td>\n";\r
-                       echo '<td>' . ($current->mcanlogin ? _YES : _NO) . "</td>\n";\r
-                       echo '<td><a href="index.php?action=memberedit&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'] . '">' . _LISTS_EDIT . "</a></td>\n";\r
-                       echo '<td><a href="index.php?action=memberdelete&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'].'">' . _LISTS_DELETE . "</a></td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_teamlist($template, $type)\r
-{\r
-       global $manager;\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo "<th>" . _LIST_MEMBER_NAME . "</th>\n";\r
-                       echo "<th>" . _LIST_MEMBER_RNAME . "</th>\n";\r
-                       echo "<th>" . _LIST_TEAM_ADMIN . "</th>\n";\r
-                       help('teamadmin');\r
-                       echo "</th>\n";\r
-                       echo "<th colspan=\"2\">"._LISTS_ACTIONS."</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       \r
-                       echo '<td>';\r
-                       $id = listplug_nextBatchId();\r
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->tmember}\" />\n";\r
-                       echo '<label for="batch',$id,'">';\r
-                       echo '<a href="mailto:' . Entity::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->mname), "</a>\n";\r
-                       echo "</label>\n";\r
-                       echo "</td>";\r
-                       echo '<td>', Entity::hsc($current->mrealname), "</td>\n";\r
-                       echo '<td>', ($current->tadmin ? _YES : _NO) , "</td>\n";\r
-                       echo "<td><a href=\"index.php?action=teamdelete&amp;memberid=$current->tmember&amp;blogid={$current->tblog}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";\r
-                       \r
-                       $url = "index.php?action=teamchangeadmin&memberid={$current->tmember}&blogid={$current->tblog}";\r
-                       $url = $manager->addTicketToUrl($url);\r
-                       echo '<td><a href="' . Entity::hsc($url) . '" tabindex="' . $template['tabindex'] . '">' . _LIST_TEAM_CHADMIN . "</a></td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_pluginlist($template, $type)\r
-{\r
-       global $manager;\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_INFO . "</th>\n";\r
-                       echo '<th>' . _LISTS_DESC . "</th>\n";\r
-                       echo '<th>' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       \r
-                       $plug =& $manager->getPlugin($current->pfile);\r
-                       if ( $plug )\r
-                       {\r
-                               echo "<td>\n";\r
-                               echo '<h3>' . Entity::hsc($plug->getName()) . "</h3>\n";\r
-                               \r
-                               echo "<dl>\n";\r
-                               if ( $plug->getAuthor() )\r
-                               {\r
-                                       echo '<dt>' . _LIST_PLUGS_AUTHOR . "</dt>\n";\r
-                                       echo '<dd>' . Entity::hsc($plug->getAuthor()) , "</dd>\n";\r
-                               }\r
-                               \r
-                               if ( $plug->getVersion() )\r
-                               {\r
-                                       echo '<dt>' . _LIST_PLUGS_VER, "</dt>\n";\r
-                                       echo '<dd>' . Entity::hsc($plug->getVersion()) . "</dd>\n";\r
-                               }\r
-                               \r
-                               if ( $plug->getURL() )\r
-                               {\r
-                                       echo '<dt>' . _LIST_PLUGS_SITE . "<dt>\n";\r
-                                       echo '<dd><a href="' .  Entity::hsc($plug->getURL()) . '" tabindex="' . $template['tabindex'] . '">リンク</a></dd>' . "\n";\r
-                               }\r
-                               echo "</dl>\n";\r
-                               echo "</td>\n";\r
-                               \r
-                               echo "<td>\n";\r
-                               echo "<dl>\n";\r
-                               echo '<dt>' . _LIST_PLUGS_DESC ."</dt>\n";\r
-                               echo '<dd>' . Entity::hen($plug->getDescription()) ."</dd>\n";\r
-                               if ( sizeof($plug->getEventList()) > 0 )\r
-                               {\r
-                                       echo '<dt>' . _LIST_PLUGS_SUBS ."</dt>\n";\r
-                                       echo '<dd>' . Entity::hsc(implode(', ', $plug->getEventList())) ."</dd>\n";\r
-                               }\r
-                               \r
-                               if ( sizeof($plug->getPluginDep()) > 0 )\r
-                               {\r
-                                       echo '<dt>' . _LIST_PLUGS_DEP ."</dt>\n";\r
-                                       echo '<dd>' . Entity::hsc(implode(', ', $plug->getPluginDep())) ."</dd>\n";\r
-                               }\r
-                               \r
-                               /* check dependency */\r
-                               $req = array();\r
-                               $res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));\r
-                               while( $o = sql_fetch_object($res) )\r
-                               {\r
-                                       $preq =& $manager->getPlugin($o->pfile);\r
-                                       if ( $preq )\r
-                                       {\r
-                                               $depList = $preq->getPluginDep();\r
-                                               foreach ( $depList as $depName )\r
-                                               {\r
-                                                       if ( $current->pfile == $depName )\r
-                                                       {\r
-                                                               $req[] = $o->pfile;\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                               }\r
-                               \r
-                               if ( count($req) > 0 )\r
-                               {\r
-                                       echo '<dt>' . _LIST_PLUGS_DEPREQ . "</dt>\n";\r
-                                       echo '<dd>' . Entity::hsc(implode(', ', $req)) . "</dd>\n";\r
-                               }\r
-                               \r
-                               /* check the database to see if it is up-to-date and notice the user if not */\r
-                               if ( !$plug->subscribtionListIsUptodate() )\r
-                               {\r
-                                       echo '<dt>' . 'NOTICE:' . "</dt>\n";\r
-                                       echo '<dd>' . _LIST_PLUG_SUBS_NEEDUPDATE . "</dd>\n";\r
-                               }\r
-                               \r
-                               echo "</dl>\n";\r
-                               echo "</td>\n";\r
-                       }\r
-                       else\r
-                       {\r
-                               echo '<td colspan="2">' . sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current->pfile)) . "</td>\n";\r
-                       }\r
-                       \r
-                       echo "<td>\n";\r
-                       echo "<ul>\n";\r
-                       $current->pid = (integer) $current->pid;\r
-                       \r
-                       $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=pluginup"));\r
-                       echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" , _LIST_PLUGS_UP , "</a></li>\n";\r
-                       \r
-                       $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=plugindown"));\r
-                       echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_DOWN , "</a></li>\n";\r
-                       echo "<li><a href=\"index.php?action=plugindelete&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_UNINSTALL , "</a></li>\n";\r
-                       \r
-                       if ( $plug && ($plug->hasAdminArea() > 0) )\r
-                       {\r
-                               echo '<li><a href="' , Entity::hsc($plug->getAdminURL()) , '" tabindex="' , $template['tabindex'] , '">' , _LIST_PLUGS_ADMIN , "</a></li>\n";\r
-                       }\r
-                       \r
-                       if ( $plug && ($plug->supportsFeature('HelpPage') > 0) )\r
-                       {\r
-                               echo "<li><a href=\"index.php?action=pluginhelp&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_HELP , "</a></li>\n";\r
-                       }\r
-                       \r
-                       $query = "SELECT COUNT(*) AS result FROM %s WHERE ocontext='global' and opid=%s;";\r
-                       $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $current->pid);\r
-                       if ( quickQuery($query) > 0 )\r
-                       {\r
-                               echo "<li><a href=\"index.php?action=pluginoptions&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_OPTIONS . "</a></li>\n";\r
-                       }\r
-                       echo "</ul>\n";\r
-                       echo "</td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_plugoptionlist($template, $type)\r
-{\r
-       global $manager;\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_INFO . "</th>\n";\r
-                       echo '<th>' . _LISTS_VALUE . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       listplug_plugOptionRow($template['current']);\r
-                       break;\r
-               case 'FOOT':\r
-                       echo "<tr>\n";\r
-                       echo '<th colspan=\"2\">' . _PLUGS_SAVE . "</th>\n";\r
-                       echo "</tr>\n";\r
-                       echo "<tr>\n";\r
-                       echo "<td>" . _PLUGS_SAVE . "</td>\n";\r
-                       echo "<td><input type=\"submit\" value=\"".  _PLUGS_SAVE . "\" /></td>\n";\r
-                       echo "</tr>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_plugOptionRow($current)\r
-{\r
-       $varname = "plugoption[{$current['oid']}][{$current['contextid']}]";\r
-       \r
-       // retreive the optionmeta\r
-       $meta = NucleusPlugin::getOptionMeta($current['typeinfo']);\r
-       \r
-       // only if it is not a hidden option write the controls to the page\r
-       if ( in_array('access', $meta) && $meta['access'] == 'hidden' )\r
-       {\r
-               return;\r
-       }\r
-       \r
-       if ( !$current['description'] )\r
-       {\r
-               echo '<td>' , Entity::hsc($current['name']) . "</td>\n";\r
-       }\r
-       else\r
-       {\r
-               if ( !defined($current['description']) )\r
-               {\r
-                       echo '<td>' , Entity::hsc($current['description']) . "</td>\n";\r
-               }\r
-               else\r
-               {\r
-                       echo '<td>' , Entity::hsc(constant($current['description'])) . "</td>\n";\r
-               }\r
-       }\r
-       echo "<td>\n";\r
-       switch($current['type'])\r
-       {\r
-               case 'yesno':\r
-                       Admin::input_yesno($varname, $current['value'], 0, 'yes', 'no');\r
-                       break;\r
-               case 'password':\r
-                       echo '<input type="password" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),"\" />\n";\r
-                       break;\r
-               case 'select':\r
-                       echo '<select name="'.Entity::hsc($varname)."\">\n";\r
-                       $options = NucleusPlugin::getOptionSelectValues($current['typeinfo']);\r
-                       $options = preg_split('/\|/', $options);\r
-                       \r
-                       for ( $i=0; $i<(count($options)-1); $i+=2 )\r
-                       {\r
-                               if ($options[$i+1] == $current['value'])\r
-                               {\r
-                                       echo '<option value="' . Entity::hsc($options[$i+1]) . '" selected="selected">';\r
-                               }\r
-                               else\r
-                               {\r
-                                       echo '<option value="' . Entity::hsc($options[$i+1]) . '">';\r
-                               }\r
-                               if ( defined($options[$i]) )\r
-                               {\r
-                                       echo Entity::hsc(constant($options[$i]));\r
-                               }\r
-                               else\r
-                               {\r
-                                       echo Entity::hsc($options[$i]);\r
-                               }\r
-                               echo "</option>\n";\r
-                       }\r
-                       echo "</select>\n";\r
-                       \r
-                       break;\r
-               case 'textarea':\r
-                       //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);\r
-                       if ( array_key_exists('access', $meta) && $meta['access'] == 'readonly' )\r
-                       {\r
-                               echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\" readonly=\"readonly\">\n";\r
-                       }\r
-                       else\r
-                       {\r
-                               echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\">\n";\r
-                       }\r
-                       echo Entity::hsc($current['value']) . "\n";\r
-                       echo "</textarea>\n";\r
-                       break;\r
-               case 'text':\r
-               default:\r
-                       //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);\r
-                       echo '<input type="text" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),'"';\r
-                       if ( array_key_exists('datatype', $meta) && $meta['datatype'] == 'numerical' )\r
-                       {\r
-                               echo ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';\r
-                       }\r
-                       if ( array_key_exists('access', $current) && $meta['access'] == 'readonly')\r
-                       {\r
-                               echo ' readonly="readonly"';\r
-                       }\r
-                       echo " />\n";\r
-       }\r
-       if ( array_key_exists('extra', $current) )\r
-       {\r
-               echo $current['extra'];\r
-       }\r
-       echo "</td>\n";\r
-       \r
-       return;\r
-}\r
-\r
-function listplug_table_itemlist($template, $type)\r
-{\r
-       $cssclass = '';\r
-       \r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo "<th>"._LIST_ITEM_INFO."</th>\n";\r
-                       echo "<th>"._LIST_ITEM_CONTENT."</th>\n";\r
-                       echo "<th colspan='1'>"._LISTS_ACTIONS."</th>";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       // string -> unix timestamp\r
-                       $current->itime = strtotime($current->itime);\r
-                       \r
-                       if ( $current->idraft == 1 )\r
-                       {\r
-                               $cssclass = " class='draft'";\r
-                       }\r
-                       \r
-                       // (can't use offset time since offsets might vary between blogs)\r
-                       if ( $current->itime > $template['now'] )\r
-                       {\r
-                               $cssclass = " class='future'";\r
-                       }\r
-                       \r
-                       echo "<td{$cssclass}>\n";\r
-                       echo "<dl>\n";\r
-                       echo '<dt>' . _LIST_ITEM_BLOG . "</dt>\n";\r
-                       echo '<dd>' . Entity::hsc($current->bshortname) . "</dd>\n";\r
-                       echo '<dt>' . _LIST_ITEM_CAT . "</dt>\n";\r
-                       echo '<dd>' . Entity::hsc($current->cname) . "</dd>\n";\r
-                       echo '<dt>' . _LIST_ITEM_AUTHOR . "</dt>\n";\r
-                       echo '<dd>' . Entity::hsc($current->mname) . "</dd>\n";\r
-                       echo '<dt>' . _LIST_ITEM_DATE . "</dt>\n";\r
-                       echo '<dd>' . date("Y-m-d",$current->itime) . "</dd>\n";\r
-                       echo '<dt>' . _LIST_ITEM_TIME . "</dt>\n";\r
-                       echo '<dd>' . date("H:i",$current->itime) . "</dd>\n";\r
-                       echo "</dl>\n";\r
-                       echo "</td>\n";\r
-                       \r
-                       $id = listplug_nextBatchId();\r
-                       \r
-                       echo "<td{$cssclass}>\n";\r
-                       echo "<h3>\n";\r
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->inumber}\" />\n";\r
-                       echo "<label for=\"batch{$id}\">" . Entity::hsc(strip_tags($current->ititle)) . "</label>\n";\r
-                       echo "</h3>\n";\r
-                       \r
-                       $current->ibody = strip_tags($current->ibody);\r
-                       $current->ibody = Entity::hsc(Entity::shorten($current->ibody, 300, '...'));\r
-                       echo "<p>$current->ibody</p>\n";\r
-                       echo "</td>\n";\r
-                       \r
-                       echo "<td{$cssclass}>\n";\r
-                       echo "<ul>\n";\r
-                       echo "<li><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></li>\n";\r
-                       \r
-                       // evaluate amount of comments for the item\r
-                       $COMMENTS = new Comments($current->inumber);\r
-                       $camount = $COMMENTS->amountComments();\r
-                       if ( $camount > 0 )\r
-                       {\r
-                               echo "<li><a href=\"index.php?action=itemcommentlist&amp;itemid=$current->inumber\">( ";\r
-                               echo sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments()) . " )</a></li>\n";\r
-                       }\r
-                       else\r
-                       {\r
-                               echo '<li>' . _LIST_ITEM_NOCONTENT . "</li>\n";\r
-                       }\r
-                       \r
-                       echo "<li><a href=\"index.php?action=itemmove&amp;itemid={$current->inumber}\">" . _LISTS_MOVE . "</a></li>\n";\r
-                       echo "<li><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></li>\n";\r
-                       echo "</ul>\n";\r
-                       echo "</td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-// for batch operations: generates the index numbers for checkboxes\r
-function listplug_nextBatchId()\r
-{\r
-       static $id = 0;\r
-       return $id++;\r
-}\r
-\r
-function listplug_table_commentlist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_INFO . "</th>\n";\r
-                       echo '<th>' . _LIST_COMMENT . "</th>\n";\r
-                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->ctime = strtotime($current->ctime);   // string -> unix timestamp\r
-                       \r
-                       echo "<td>\n";\r
-                       echo "<ul>\n";\r
-                       echo '<li>' . date("Y-m-d@H:i",$current->ctime) . "</li>\n";\r
-                       if ( isset($current->mname) )\r
-                       {\r
-                               echo '<li>' . Entity::hsc($current->mname) ,' ', _LIST_COMMENTS_MEMBER . "</li>\n";\r
-                       }\r
-                       else\r
-                       {\r
-                               echo '<li>' . Entity::hsc($current->cuser) . "</li>\n";\r
-                       }\r
-                       if ( isset($current->cmail) && $current->cmail )\r
-                       {\r
-                               echo '<li>' . Entity::hsc($current->cmail) . "</li>\n";\r
-                       }\r
-                       if ( isset($current->cemail) && $current->cemail )\r
-                       {\r
-                               echo '<li>' . Entity::hsc($current->cemail) . "</li>\n";\r
-                       }\r
-                       echo "</ul>\n";\r
-                       echo "</td>\n";\r
-\r
-                       $id = listplug_nextBatchId();\r
-                       \r
-                       echo '<td>';\r
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}\" value=\"{$current->cnumber}\" />\n";\r
-                       echo "<label for=\"batch{$id}\">\n";\r
-                       $current->cbody = strip_tags($current->cbody);\r
-                       $current->cbody = Entity::hsc(Entity::shorten($current->cbody, 300, '...'));\r
-                       echo $current->cbody;\r
-                       echo '</label>';\r
-                       echo '</td>';\r
-                       \r
-                       echo '<td><a href="index.php?action=commentedit&amp;commentid=' . $current->cnumber . '">' . _LISTS_EDIT . "</a></td>\n";\r
-                       echo '<td><a href="index.php?action=commentdelete&amp;commentid=' . $current->cnumber . '">' . _LISTS_DELETE . "</a></td>\n";\r
-                       if ( $template['canAddBan'] )\r
-                       {\r
-                               echo '<td><a href="index.php?action=banlistnewfromitem&amp;itemid=' . $current->citem . '&amp;ip=' . Entity::hsc($current->cip), '" title="' . Entity::hsc($current->chost) . '">' . _LIST_COMMENT_BANIP . "</a></td>\n";\r
-                       }\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_bloglist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _NAME . "</th>\n";\r
-                       echo '<th colspan="7">' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->bname = Entity::hsc($current->bname);\r
-                       \r
-                       echo "<td title=\"blogid:{$current->bnumber} shortname:{$current->bshortname}\"><a href=\"{$current->burl}\"><img src=\"images/globe.gif\" width=\"13\" height=\"13\" alt=\"". _BLOGLIST_TT_VISIT."\" /></a>{$current->bname}</td>\n";\r
-                       echo "<td><a href=\"index.php?action=createitem&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_ADD ."\">" . _BLOGLIST_ADD . "</a></td>\n";\r
-                       echo "<td><a href=\"index.php?action=itemlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_EDIT."\">". _BLOGLIST_EDIT."</a></td>\n";\r
-                       echo "<td><a href=\"index.php?action=blogcommentlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_COMMENTS."\">". _BLOGLIST_COMMENTS."</a></td>\n";\r
-                       echo "<td><a href=\"index.php?action=bookmarklet&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_BMLET."\">". _BLOGLIST_BMLET . "</a></td>\n";\r
-                       \r
-                       if ( $current->tadmin == 1 )\r
-                       {\r
-                               echo "<td><a href=\"index.php?action=blogsettings&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_SETTINGS . "\">" . _BLOGLIST_SETTINGS . "</a></td>\n";\r
-                               echo "<td><a href=\"index.php?action=banlist&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_BANS . "\">" . _BLOGLIST_BANS . "</a></td>\n";\r
-                       }\r
-                       \r
-                       if ( $template['superadmin'] )\r
-                       {\r
-                               echo "<td><a href=\"index.php?action=deleteblog&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_DELETE."\">" ._BLOGLIST_DELETE. "</a></td>\n";\r
-                       }\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_shortblognames($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _EBLOG_SHORTNAME . "</th>\n";\r
-                       echo '<th>' . _EBLOG_NAME. "</th>";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->bshortname = Entity::hsc($current->bshortname);\r
-                       $current->bname = Entity::hsc($current->bname);\r
-                       \r
-                       echo "<td>{$current->bshortname}</td>\n";\r
-                       echo "<td>{$current->bname}</td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_shortnames($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _NAME . "</th>\n";\r
-                       echo '<th>' . _LISTS_DESC. "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->name = Entity::hsc($current->name);\r
-                       $current->description = Entity::hsc($current->description);\r
-                       \r
-                       echo "<td>{$current->name}</td>\n";\r
-                       echo "<td>{$current->description}</td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-\r
-function listplug_table_categorylist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_NAME . "</th>";\r
-                       echo '<th>' . _LISTS_DESC."</th>\n";\r
-                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $id = listplug_nextBatchId();\r
-                       \r
-                       $current = $template['current'];\r
-                       $current->cname = Entity::hsc($current->cname);\r
-                       $current->cdesc = Entity::hsc($current->cdesc);\r
-                       \r
-                       echo "<td>\n";\r
-                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->catid}\" />\n";\r
-                       echo "<label for=\"batch{$id}\">{$current->cname}</label>\n";\r
-                       echo "</td>\n";\r
-                       echo "<td>{$current->cdesc}</td>\n";\r
-                       echo "<td><a href=\"index.php?action=categoryedit&amp;blogid={$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a></td>\n";\r
-                       echo "<td><a href=\"index.php?action=categorydelete&amp;blogid={$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_templatelist($template, $type)\r
-{\r
-       global $manager;\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_NAME . "</th>\n";\r
-                       echo '<th>' . _LISTS_DESC . "</th>\n";\r
-                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->tdnumber = (integer) $current->tdnumber;\r
-                       $current->tdname = Entity::hsc($current->tdname);\r
-                       $current->tddesc = Entity::hsc($current->tddesc);\r
-                       \r
-                       $url = "index.php?action=templateclone&templateid={$current->tdnumber}";\r
-                       $url = Entity::hsc($manager->addTicketToUrl($url));\r
-                       \r
-                       echo "<td>{$current->tdname}</td>\n";\r
-                       echo "<td>{$current->tddesc}</td>\n";\r
-                       echo "<td>\n";\r
-                       echo "<a href=\"index.php?action=templateedit&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a>\n";\r
-                       echo "</td>\n";\r
-                       echo "<td>\n";\r
-                       echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";\r
-                       echo "</td>\n";\r
-                       echo "<td>\n";\r
-                       echo "<a href=\"index.php?action=templatedelete&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a>\n";\r
-                       echo "</td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_skinlist($template, $type)\r
-{\r
-       global $CONF, $DIR_SKINS, $manager;\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_NAME . "</th>\n";\r
-                       echo '<th>' . _LISTS_DESC . "</th>\n";\r
-                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->sdnumber = (integer) $current->sdnumber;\r
-                       $current->sdname = Entity::hsc($current->sdname);\r
-                       $current->sdtype = Entity::hsc($current->sdtype);\r
-                       \r
-                       echo "<td>\n";\r
-                       \r
-                       // use a special style for the default skin\r
-                       if ( $current->sdnumber == $CONF['BaseSkin'] )\r
-                       {\r
-                               echo '<h3 id="base_skin">' . $current->sdname . "</h3>\n";\r
-                       }\r
-                       else\r
-                       {\r
-                               echo '<h3>' . $current->sdname . "</h3>\n";\r
-                       }\r
-                       \r
-                       echo "<dl>\n";\r
-                       echo '<dt>' . _LISTS_TYPE . "</dt>\n";\r
-                       echo '<dd>' . $current->sdtype . "</dd>\n";\r
-                       \r
-                       echo '<dt>' . _LIST_SKINS_INCMODE . "</dt>\n";\r
-                       \r
-                       if ( $current->sdincmode == 'skindir' )\r
-                       {\r
-                               echo '<dd>' . _PARSER_INCMODE_SKINDIR . "</dd>\n";\r
-                       }\r
-                       else\r
-                       {\r
-                               echo '<dd>' . _PARSER_INCMODE_NORMAL . "</dd>\n";\r
-                       }\r
-                       \r
-                       if ( $current->sdincpref )\r
-                       {\r
-                               echo '<dt>' . _LIST_SKINS_INCPREFIX . "</dt>\n";\r
-                               echo '<dd>' . Entity::hsc($current->sdincpref) . "</dd>\n";\r
-                       }\r
-                       echo "</dl>\n";\r
-                       \r
-                       // add preview image when present\r
-                       if ( $current->sdincpref && @file_exists("{$DIR_SKINS}{$current->sdincpref}preview.png") )\r
-                       {\r
-                               echo "<p>\n";\r
-                               \r
-                               $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current->sdname);\r
-                               $has_enlargement = @file_exists($DIR_SKINS . $current->sdincpref . 'preview-large.png');\r
-                               if ( $has_enlargement )\r
-                               {\r
-                                       echo '<a href="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . "\">\n";\r
-                                       echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" />\n";\r
-                                       echo "</a><br />\n";\r
-                               }\r
-                               else\r
-                               {\r
-                                       echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" /><br />\n";\r
-                               }\r
-                               \r
-                               if ( @file_exists("{$DIR_SKINS}{$current->sdincpref}readme.html") )\r
-                               {\r
-                                       $url = $CONF['SkinsURL'] . Entity::hsc($current->sdincpref) . 'readme.html';\r
-                                       $title = sprintf(_LIST_SKIN_README, $current->sdname);\r
-                                       echo "<a href=\"{$url}\" title=\"{$title}\">" . _LIST_SKIN_README_TXT . "</a>\n";\r
-                               }\r
-                               \r
-                               echo "</p>\n";\r
-                       }\r
-                       \r
-                       echo "</td>\n";\r
-                       \r
-                       echo "<td>\n";\r
-                       echo '<p>' . Entity::hsc($current->sddesc) . "</p>\n";\r
-                       \r
-                       /* show list of defined parts */\r
-                       $query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype";\r
-                       $query = sprintf($query, sql_table('skin'), $current->sdnumber);\r
-                       $r = sql_query($query);\r
-                       \r
-                       $types = array();\r
-                       while ( $o = sql_fetch_object($r) )\r
-                       {\r
-                               array_push($types, $o->stype);\r
-                       }\r
-                       if ( sizeof($types) > 0 )\r
-                       {\r
-                               $friendlyNames = SKIN::getFriendlyNames();\r
-                               for ( $i = 0; $i < sizeof($types); $i++ )\r
-                               {\r
-                                       $type = $types[$i];\r
-                                       if ( !in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup')) )\r
-                                       {\r
-                                               $article = 'skinpartspecial';\r
-                                       }\r
-                                       else\r
-                                       {\r
-                                               $article = "skinpart{$type}";\r
-                                       }\r
-                                       $types[$i]  = "<li>\n";\r
-                                       $types[$i] .= helpHtml($article) . "\n";\r
-                                       $types[$i] .= "<a href=\"index.php?action=skinedittype&amp;skinid={$current->sdnumber}&amp;type={$type}\" tabindex=\"{$template['tabindex']}\">" . Entity::hsc($friendlyNames[$type]) . "</a>\n";\r
-                                       $types[$i] .= "</li>\n";\r
-                               }\r
-                               echo _LIST_SKINS_DEFINED;\r
-                               echo '<ul>' . implode('', $types) . "</ul>\n";\r
-                       }\r
-                       echo "</td>";\r
-                       echo "<td>\n";\r
-                       echo "<a href=\nindex.php?action=skinedit&amp;skinid={$current->sdnumber}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "</a>\n";\r
-                       echo "</td>\n";\r
-                       \r
-                       $url = "index.php?action=skinclone&skinid={$current->sdnumber}";\r
-                       $url = Entity::hsc($manager->addTicketToUrl($url));\r
-                       echo "<td>\n";\r
-                       echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";\r
-                       echo "</td>\n";\r
-                       echo "<td>\n";\r
-                       echo "<a href=\"index.php?action=skindelete&amp;skinid={$current->sdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_draftlist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_BLOG . "</th>\n";\r
-                       echo '<th>' . _LISTS_TITLE . "</th>\n";\r
-                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->bshortname = Entity::hsc($current->bshortname);\r
-                       $current->ititle = Entity::hsc(strip_tags($current->ititle));\r
-                       \r
-                       echo "<td>{$current->bshortname}</td>\n";\r
-                       echo "<td>{$current->ititle}</td>\n";\r
-                       echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";\r
-                       echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_otherdraftlist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_BLOG . "</th>\n";\r
-                       echo '<th>' . _LISTS_TITLE . "</th>\n";\r
-                       echo '<th>' . _LISTS_AUTHOR . "</th>\n";\r
-                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->bshortname = Entity::hsc($current->bshortname);\r
-                       $current->ititle = Entity::hsc(strip_tags($current->ititle));\r
-                       $current->mname = Entity::hsc($current->mname);\r
-                       \r
-                       echo "<td>{$current->bshortname}</td>\n";\r
-                       echo "<td>{$current->ititle}</td>\n";\r
-                       echo "<td>{$current->mname}</td>\n";\r
-                       echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";\r
-                       echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_actionlist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LISTS_TIME . "</th>\n";\r
-                       echo '<th>' . _LIST_ACTION_MSG . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->timestamp = Entity::hsc($current->timestamp);\r
-                       $current->message = Entity::hsc($current->message);\r
-                       \r
-                       echo "<td>{$current->timestamp}</td>\n";\r
-                       echo "<td>{$current->message}</td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
-\r
-function listplug_table_banlist($template, $type)\r
-{\r
-       switch( $type )\r
-       {\r
-               case 'HEAD':\r
-                       echo '<th>' . _LIST_BAN_IPRANGE . "</th>\n";\r
-                       echo '<th>' . _LIST_BAN_REASON."</th>\n";\r
-                       echo '<th>' . _LISTS_ACTIONS . "</th>\n";\r
-                       break;\r
-               case 'BODY':\r
-                       $current = $template['current'];\r
-                       $current->blogid = (integer) $current->blogid;\r
-                       $current->iprange = Entity::hsc($current->iprange);\r
-                       $current->reason = Entity::hsc($current->reason);\r
-                       \r
-                       echo "<td>{$current->iprange}</td>\n";\r
-                       echo "<td>{$current->reason}</td>\n";\r
-                       echo "<td><a href=\"index.php?action=banlistdelete&amp;blogid=\"{$current->blogid}&amp;iprange=\"Entity::hsc($current->iprange}\">" . _LISTS_DELETE . "</a></td>\n";\r
-                       break;\r
-       }\r
-       return;\r
-}\r
+<?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)
+ */
+/**
+ * Functions to create lists of things inside the admin are
+ *
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: showlist.php 1755 2012-04-14 10:05:49Z sakamocchi $
+ */
+
+
+// can take either an array of objects, or an SQL query
+function showlist($query, $type, $template)
+{
+       if ( is_array($query) )
+       {
+               if ( sizeof($query) == 0 )
+               {
+                       return 0;
+               }
+               
+               call_user_func("listplug_{$type}", $template, 'HEAD');
+               
+               foreach ( $query as $currentObj )
+               {
+                       $template['current'] = $currentObj;
+                       call_user_func("listplug_{$type}", $template, 'BODY');
+               }
+               
+               call_user_func("listplug_{$type}", $template, 'FOOT');
+               
+               return sizeof($query);
+       }
+       else
+       {
+               $res = sql_query($query);
+               
+               // don't do anything if there are no results
+               $numrows = sql_num_rows($res);
+               if ( $numrows == 0 )
+               {
+                       return 0;
+               }
+               call_user_func("listplug_{$type}", $template, 'HEAD');
+               
+               while( $template['current'] = sql_fetch_object($res) )
+               {
+                       call_user_func("listplug_{$type}", $template, 'BODY');
+               }
+               
+               call_user_func("listplug_{$type}", $template, 'FOOT');
+               
+               sql_free_result($res);
+               
+               // return amount of results
+               return $numrows;
+       }
+}
+
+function listplug_select($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<select name="' . ifset($template['name']) . '" tabindex="' . ifset($template['tabindex']) . '" ' . ifset($template['javascript']) . ">\n";
+                       
+                       // add extra row if needed
+                       if ( ifset($template['extra']) )
+                       {
+                               echo '<option value="', ifset($template['extraval']), '">', $template['extra'], "</option>\n";
+                       }
+                       
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+
+                       echo '<option value="' . Entity::hsc($current->value) . '"';
+                       if ( $template['selected'] == $current->value )
+                       {
+                               echo ' selected="selected" ';
+                       }
+                       if ( isset($template['shorten']) && $template['shorten'] > 0 )
+                       {
+                               echo ' title="'. Entity::hsc($current->text).'"';
+                               $current->text = Entity::hsc(Entity::shorten($current->text, $template['shorten'], $template['shortenel']));
+                       }
+                       echo '>' . Entity::hsc($current->text) . "</option>\n";
+                       break;
+               case 'FOOT':
+                       echo '</select>';
+                       break;
+       }
+       return;
+}
+
+function listplug_table($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo "\n\n";
+                       echo "<table frame=\"box\" rules=\"all\" summary=\"{$template['content']}\">\n";
+                       echo "<thead>\n";
+                       echo "<tr>\n";
+                       // print head
+                       call_user_func("listplug_table_{$template['content']}" , $template, 'HEAD');
+                       echo "</tr>\n";
+                       echo "</thead>\n";
+                       echo "<tbody>\n";
+                       break;
+               case 'BODY':
+                       // print tabletype specific thingies
+                       echo "<tr>\n";
+                       call_user_func("listplug_table_{$template['content']}" , $template,  'BODY');
+                       echo "</tr>\n";
+                       break;
+               case 'FOOT':
+                       call_user_func("listplug_table_{$template['content']}" , $template,  'FOOT');
+                       echo "</tbody>\n";
+                       echo "</table>\n";
+                       echo "\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_memberlist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LIST_MEMBER_NAME . "</th>\n";
+                       echo '<th>' . _LIST_MEMBER_RNAME . "</th>\n";
+                       echo '<th>' . _LIST_MEMBER_URL . "</th>\n";
+                       echo '<th>' . _LIST_MEMBER_ADMIN . "</th>\n";
+                       help('superadmin');
+                       echo "</th>\n";
+                       echo '<th>' . _LIST_MEMBER_LOGIN;
+                       help('canlogin');
+                       echo "</th>\n";
+                       echo '<th colspan="2">' . _LISTS_ACTIONS. "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       echo '<td>';
+                       $id = listplug_nextBatchId();
+                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->mnumber}\" />\n";
+                       echo "<label for=\"batch{$id}\">\n";
+                       echo '<a href="mailto:' . Entity::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->mname), "</a>\n";
+                       echo "</label>\n";
+                       echo "</td>";
+                       echo "<td>" . Entity::hsc($current->mrealname) . "</td>\n";
+                       echo '<td><a href="' . Entity::hsc($current->murl) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->murl) . "</a></td>\n";
+                       echo '<td>' . ($current->madmin ? _YES : _NO) . "</td>\n";
+                       echo '<td>' . ($current->mcanlogin ? _YES : _NO) . "</td>\n";
+                       echo '<td><a href="index.php?action=memberedit&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'] . '">' . _LISTS_EDIT . "</a></td>\n";
+                       echo '<td><a href="index.php?action=memberdelete&amp;memberid=$current->mnumber" tabindex="' . $template['tabindex'].'">' . _LISTS_DELETE . "</a></td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_teamlist($template, $type)
+{
+       global $manager;
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo "<th>" . _LIST_MEMBER_NAME . "</th>\n";
+                       echo "<th>" . _LIST_MEMBER_RNAME . "</th>\n";
+                       echo "<th>" . _LIST_TEAM_ADMIN . "</th>\n";
+                       help('teamadmin');
+                       echo "</th>\n";
+                       echo "<th colspan=\"2\">"._LISTS_ACTIONS."</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       
+                       echo '<td>';
+                       $id = listplug_nextBatchId();
+                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->tmember}\" />\n";
+                       echo '<label for="batch',$id,'">';
+                       echo '<a href="mailto:' . Entity::hsc($current->memail) . '" tabindex="' . $template['tabindex'] . '">' . Entity::hsc($current->mname), "</a>\n";
+                       echo "</label>\n";
+                       echo "</td>";
+                       echo '<td>', Entity::hsc($current->mrealname), "</td>\n";
+                       echo '<td>', ($current->tadmin ? _YES : _NO) , "</td>\n";
+                       echo "<td><a href=\"index.php?action=teamdelete&amp;memberid=$current->tmember&amp;blogid={$current->tblog}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
+                       
+                       $url = "index.php?action=teamchangeadmin&memberid={$current->tmember}&blogid={$current->tblog}";
+                       $url = $manager->addTicketToUrl($url);
+                       echo '<td><a href="' . Entity::hsc($url) . '" tabindex="' . $template['tabindex'] . '">' . _LIST_TEAM_CHADMIN . "</a></td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_pluginlist($template, $type)
+{
+       global $manager;
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_INFO . "</th>\n";
+                       echo '<th>' . _LISTS_DESC . "</th>\n";
+                       echo '<th>' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       
+                       $plug =& $manager->getPlugin($current->pfile);
+                       if ( $plug )
+                       {
+                               echo "<td>\n";
+                               echo '<h3>' . Entity::hsc($plug->getName()) . "</h3>\n";
+                               
+                               echo "<dl>\n";
+                               if ( $plug->getAuthor() )
+                               {
+                                       echo '<dt>' . _LIST_PLUGS_AUTHOR . "</dt>\n";
+                                       echo '<dd>' . Entity::hsc($plug->getAuthor()) , "</dd>\n";
+                               }
+                               
+                               if ( $plug->getVersion() )
+                               {
+                                       echo '<dt>' . _LIST_PLUGS_VER, "</dt>\n";
+                                       echo '<dd>' . Entity::hsc($plug->getVersion()) . "</dd>\n";
+                               }
+                               
+                               if ( $plug->getURL() )
+                               {
+                                       echo '<dt>' . _LIST_PLUGS_SITE . "<dt>\n";
+                                       echo '<dd><a href="' .  Entity::hsc($plug->getURL()) . '" tabindex="' . $template['tabindex'] . '">リンク</a></dd>' . "\n";
+                               }
+                               echo "</dl>\n";
+                               echo "</td>\n";
+                               
+                               echo "<td>\n";
+                               echo "<dl>\n";
+                               echo '<dt>' . _LIST_PLUGS_DESC ."</dt>\n";
+                               echo '<dd>' . Entity::hen($plug->getDescription()) ."</dd>\n";
+                               if ( sizeof($plug->getEventList()) > 0 )
+                               {
+                                       echo '<dt>' . _LIST_PLUGS_SUBS ."</dt>\n";
+                                       echo '<dd>' . Entity::hsc(implode(', ', $plug->getEventList())) ."</dd>\n";
+                               }
+                               
+                               if ( sizeof($plug->getPluginDep()) > 0 )
+                               {
+                                       echo '<dt>' . _LIST_PLUGS_DEP ."</dt>\n";
+                                       echo '<dd>' . Entity::hsc(implode(', ', $plug->getPluginDep())) ."</dd>\n";
+                               }
+                               
+                               /* check dependency */
+                               $req = array();
+                               $res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));
+                               while( $o = sql_fetch_object($res) )
+                               {
+                                       $preq =& $manager->getPlugin($o->pfile);
+                                       if ( $preq )
+                                       {
+                                               $depList = $preq->getPluginDep();
+                                               foreach ( $depList as $depName )
+                                               {
+                                                       if ( $current->pfile == $depName )
+                                                       {
+                                                               $req[] = $o->pfile;
+                                                       }
+                                               }
+                                       }
+                               }
+                               
+                               if ( count($req) > 0 )
+                               {
+                                       echo '<dt>' . _LIST_PLUGS_DEPREQ . "</dt>\n";
+                                       echo '<dd>' . Entity::hsc(implode(', ', $req)) . "</dd>\n";
+                               }
+                               
+                               /* check the database to see if it is up-to-date and notice the user if not */
+                               if ( !$plug->subscribtionListIsUptodate() )
+                               {
+                                       echo '<dt>' . 'NOTICE:' . "</dt>\n";
+                                       echo '<dd>' . _LIST_PLUG_SUBS_NEEDUPDATE . "</dd>\n";
+                               }
+                               
+                               echo "</dl>\n";
+                               echo "</td>\n";
+                       }
+                       else
+                       {
+                               echo '<td colspan="2">' . sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current->pfile)) . "</td>\n";
+                       }
+                       
+                       echo "<td>\n";
+                       echo "<ul>\n";
+                       $current->pid = (integer) $current->pid;
+                       
+                       $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=pluginup"));
+                       echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" , _LIST_PLUGS_UP , "</a></li>\n";
+                       
+                       $url = Entity::hsc($manager->addTicketToUrl("index.php?plugid={$current->pid}&action=plugindown"));
+                       echo "<li><a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_DOWN , "</a></li>\n";
+                       echo "<li><a href=\"index.php?action=plugindelete&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_UNINSTALL , "</a></li>\n";
+                       
+                       if ( $plug && ($plug->hasAdminArea() > 0) )
+                       {
+                               echo '<li><a href="' , Entity::hsc($plug->getAdminURL()) , '" tabindex="' , $template['tabindex'] , '">' , _LIST_PLUGS_ADMIN , "</a></li>\n";
+                       }
+                       
+                       if ( $plug && ($plug->supportsFeature('HelpPage') > 0) )
+                       {
+                               echo "<li><a href=\"index.php?action=pluginhelp&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_HELP , "</a></li>\n";
+                       }
+                       
+                       $query = "SELECT COUNT(*) AS result FROM %s WHERE ocontext='global' and opid=%s;";
+                       $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $current->pid);
+                       if ( quickQuery($query) > 0 )
+                       {
+                               echo "<li><a href=\"index.php?action=pluginoptions&amp;plugid={$current->pid}\" tabindex=\"{$template['tabindex']}\">" . _LIST_PLUGS_OPTIONS . "</a></li>\n";
+                       }
+                       echo "</ul>\n";
+                       echo "</td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_plugoptionlist($template, $type)
+{
+       global $manager;
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_INFO . "</th>\n";
+                       echo '<th>' . _LISTS_VALUE . "</th>\n";
+                       break;
+               case 'BODY':
+                       listplug_plugOptionRow($template['current']);
+                       break;
+               case 'FOOT':
+                       echo "<tr>\n";
+                       echo '<th colspan=\"2\">' . _PLUGS_SAVE . "</th>\n";
+                       echo "</tr>\n";
+                       echo "<tr>\n";
+                       echo "<td>" . _PLUGS_SAVE . "</td>\n";
+                       echo "<td><input type=\"submit\" value=\"".  _PLUGS_SAVE . "\" /></td>\n";
+                       echo "</tr>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_plugOptionRow($current)
+{
+       $varname = "plugoption[{$current['oid']}][{$current['contextid']}]";
+       
+       // retreive the optionmeta
+       $meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
+       
+       // only if it is not a hidden option write the controls to the page
+       if ( in_array('access', $meta) && $meta['access'] == 'hidden' )
+       {
+               return;
+       }
+       
+       if ( !$current['description'] )
+       {
+               echo '<td>' , Entity::hsc($current['name']) . "</td>\n";
+       }
+       else
+       {
+               if ( !defined($current['description']) )
+               {
+                       echo '<td>' , Entity::hsc($current['description']) . "</td>\n";
+               }
+               else
+               {
+                       echo '<td>' , Entity::hsc(constant($current['description'])) . "</td>\n";
+               }
+       }
+       echo "<td>\n";
+       switch($current['type'])
+       {
+               case 'yesno':
+                       Admin::input_yesno($varname, $current['value'], 0, 'yes', 'no');
+                       break;
+               case 'password':
+                       echo '<input type="password" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),"\" />\n";
+                       break;
+               case 'select':
+                       echo '<select name="'.Entity::hsc($varname)."\">\n";
+                       $options = NucleusPlugin::getOptionSelectValues($current['typeinfo']);
+                       $options = preg_split('/\|/', $options);
+                       
+                       for ( $i=0; $i<(count($options)-1); $i+=2 )
+                       {
+                               if ($options[$i+1] == $current['value'])
+                               {
+                                       echo '<option value="' . Entity::hsc($options[$i+1]) . '" selected="selected">';
+                               }
+                               else
+                               {
+                                       echo '<option value="' . Entity::hsc($options[$i+1]) . '">';
+                               }
+                               if ( defined($options[$i]) )
+                               {
+                                       echo Entity::hsc(constant($options[$i]));
+                               }
+                               else
+                               {
+                                       echo Entity::hsc($options[$i]);
+                               }
+                               echo "</option>\n";
+                       }
+                       echo "</select>\n";
+                       
+                       break;
+               case 'textarea':
+                       //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
+                       if ( array_key_exists('access', $meta) && $meta['access'] == 'readonly' )
+                       {
+                               echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\" readonly=\"readonly\">\n";
+                       }
+                       else
+                       {
+                               echo '<textarea class="pluginoption" cols="30" rows="5" name="' . Entity::hsc($varname) . "\">\n";
+                       }
+                       echo Entity::hsc($current['value']) . "\n";
+                       echo "</textarea>\n";
+                       break;
+               case 'text':
+               default:
+                       //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']);
+                       echo '<input type="text" size="40" maxlength="128" name="',Entity::hsc($varname),'" value="',Entity::hsc($current['value']),'"';
+                       if ( array_key_exists('datatype', $meta) && $meta['datatype'] == 'numerical' )
+                       {
+                               echo ' onkeyup="checkNumeric(this)" onblur="checkNumeric(this)"';
+                       }
+                       if ( array_key_exists('access', $current) && $meta['access'] == 'readonly')
+                       {
+                               echo ' readonly="readonly"';
+                       }
+                       echo " />\n";
+       }
+       if ( array_key_exists('extra', $current) )
+       {
+               echo $current['extra'];
+       }
+       echo "</td>\n";
+       
+       return;
+}
+
+function listplug_table_itemlist($template, $type)
+{
+       $cssclass = '';
+       
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo "<th>"._LIST_ITEM_INFO."</th>\n";
+                       echo "<th>"._LIST_ITEM_CONTENT."</th>\n";
+                       echo "<th colspan='1'>"._LISTS_ACTIONS."</th>";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       // string -> unix timestamp
+                       $current->itime = strtotime($current->itime);
+                       
+                       if ( $current->idraft == 1 )
+                       {
+                               $cssclass = " class='draft'";
+                       }
+                       
+                       // (can't use offset time since offsets might vary between blogs)
+                       if ( $current->itime > $template['now'] )
+                       {
+                               $cssclass = " class='future'";
+                       }
+                       
+                       echo "<td{$cssclass}>\n";
+                       echo "<dl>\n";
+                       echo '<dt>' . _LIST_ITEM_BLOG . "</dt>\n";
+                       echo '<dd>' . Entity::hsc($current->bshortname) . "</dd>\n";
+                       echo '<dt>' . _LIST_ITEM_CAT . "</dt>\n";
+                       echo '<dd>' . Entity::hsc($current->cname) . "</dd>\n";
+                       echo '<dt>' . _LIST_ITEM_AUTHOR . "</dt>\n";
+                       echo '<dd>' . Entity::hsc($current->mname) . "</dd>\n";
+                       echo '<dt>' . _LIST_ITEM_DATE . "</dt>\n";
+                       echo '<dd>' . date("Y-m-d",$current->itime) . "</dd>\n";
+                       echo '<dt>' . _LIST_ITEM_TIME . "</dt>\n";
+                       echo '<dd>' . date("H:i",$current->itime) . "</dd>\n";
+                       echo "</dl>\n";
+                       echo "</td>\n";
+                       
+                       $id = listplug_nextBatchId();
+                       
+                       echo "<td{$cssclass}>\n";
+                       echo "<h3>\n";
+                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->inumber}\" />\n";
+                       echo "<label for=\"batch{$id}\">" . Entity::hsc(strip_tags($current->ititle)) . "</label>\n";
+                       echo "</h3>\n";
+                       
+                       $current->ibody = strip_tags($current->ibody);
+                       $current->ibody = Entity::hsc(Entity::shorten($current->ibody, 300, '...'));
+                       echo "<p>$current->ibody</p>\n";
+                       echo "</td>\n";
+                       
+                       echo "<td{$cssclass}>\n";
+                       echo "<ul>\n";
+                       echo "<li><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></li>\n";
+                       
+                       // evaluate amount of comments for the item
+                       $COMMENTS = new Comments($current->inumber);
+                       $camount = $COMMENTS->amountComments();
+                       if ( $camount > 0 )
+                       {
+                               echo "<li><a href=\"index.php?action=itemcommentlist&amp;itemid=$current->inumber\">( ";
+                               echo sprintf(_LIST_ITEM_COMMENTS, $COMMENTS->amountComments()) . " )</a></li>\n";
+                       }
+                       else
+                       {
+                               echo '<li>' . _LIST_ITEM_NOCONTENT . "</li>\n";
+                       }
+                       
+                       echo "<li><a href=\"index.php?action=itemmove&amp;itemid={$current->inumber}\">" . _LISTS_MOVE . "</a></li>\n";
+                       echo "<li><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></li>\n";
+                       echo "</ul>\n";
+                       echo "</td>\n";
+                       break;
+       }
+       return;
+}
+
+// for batch operations: generates the index numbers for checkboxes
+function listplug_nextBatchId()
+{
+       static $id = 0;
+       return $id++;
+}
+
+function listplug_table_commentlist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_INFO . "</th>\n";
+                       echo '<th>' . _LIST_COMMENT . "</th>\n";
+                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->ctime = strtotime($current->ctime);   // string -> unix timestamp
+                       
+                       echo "<td>\n";
+                       echo "<ul>\n";
+                       echo '<li>' . date("Y-m-d@H:i",$current->ctime) . "</li>\n";
+                       if ( isset($current->mname) )
+                       {
+                               echo '<li>' . Entity::hsc($current->mname) ,' ', _LIST_COMMENTS_MEMBER . "</li>\n";
+                       }
+                       else
+                       {
+                               echo '<li>' . Entity::hsc($current->cuser) . "</li>\n";
+                       }
+                       if ( isset($current->cmail) && $current->cmail )
+                       {
+                               echo '<li>' . Entity::hsc($current->cmail) . "</li>\n";
+                       }
+                       if ( isset($current->cemail) && $current->cemail )
+                       {
+                               echo '<li>' . Entity::hsc($current->cemail) . "</li>\n";
+                       }
+                       echo "</ul>\n";
+                       echo "</td>\n";
+
+                       $id = listplug_nextBatchId();
+                       
+                       echo '<td>';
+                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}\" value=\"{$current->cnumber}\" />\n";
+                       echo "<label for=\"batch{$id}\">\n";
+                       $current->cbody = strip_tags($current->cbody);
+                       $current->cbody = Entity::hsc(Entity::shorten($current->cbody, 300, '...'));
+                       echo $current->cbody;
+                       echo '</label>';
+                       echo '</td>';
+                       
+                       echo '<td><a href="index.php?action=commentedit&amp;commentid=' . $current->cnumber . '">' . _LISTS_EDIT . "</a></td>\n";
+                       echo '<td><a href="index.php?action=commentdelete&amp;commentid=' . $current->cnumber . '">' . _LISTS_DELETE . "</a></td>\n";
+                       if ( $template['canAddBan'] )
+                       {
+                               echo '<td><a href="index.php?action=banlistnewfromitem&amp;itemid=' . $current->citem . '&amp;ip=' . Entity::hsc($current->cip), '" title="' . Entity::hsc($current->chost) . '">' . _LIST_COMMENT_BANIP . "</a></td>\n";
+                       }
+                       break;
+       }
+       return;
+}
+
+function listplug_table_bloglist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _NAME . "</th>\n";
+                       echo '<th colspan="7">' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->bname = Entity::hsc($current->bname);
+                       
+                       echo "<td title=\"blogid:{$current->bnumber} shortname:{$current->bshortname}\"><a href=\"{$current->burl}\"><img src=\"images/globe.gif\" width=\"13\" height=\"13\" alt=\"". _BLOGLIST_TT_VISIT."\" /></a>{$current->bname}</td>\n";
+                       echo "<td><a href=\"index.php?action=createitem&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_ADD ."\">" . _BLOGLIST_ADD . "</a></td>\n";
+                       echo "<td><a href=\"index.php?action=itemlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_EDIT."\">". _BLOGLIST_EDIT."</a></td>\n";
+                       echo "<td><a href=\"index.php?action=blogcommentlist&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_COMMENTS."\">". _BLOGLIST_COMMENTS."</a></td>\n";
+                       echo "<td><a href=\"index.php?action=bookmarklet&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_BMLET."\">". _BLOGLIST_BMLET . "</a></td>\n";
+                       
+                       if ( $current->tadmin == 1 )
+                       {
+                               echo "<td><a href=\"index.php?action=blogsettings&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_SETTINGS . "\">" . _BLOGLIST_SETTINGS . "</a></td>\n";
+                               echo "<td><a href=\"index.php?action=banlist&amp;blogid={$current->bnumber}\" title=\"" . _BLOGLIST_TT_BANS . "\">" . _BLOGLIST_BANS . "</a></td>\n";
+                       }
+                       
+                       if ( $template['superadmin'] )
+                       {
+                               echo "<td><a href=\"index.php?action=deleteblog&amp;blogid={$current->bnumber}\" title=\"". _BLOGLIST_TT_DELETE."\">" ._BLOGLIST_DELETE. "</a></td>\n";
+                       }
+                       break;
+       }
+       return;
+}
+
+function listplug_table_shortblognames($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _EBLOG_SHORTNAME . "</th>\n";
+                       echo '<th>' . _EBLOG_NAME. "</th>";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->bshortname = Entity::hsc($current->bshortname);
+                       $current->bname = Entity::hsc($current->bname);
+                       
+                       echo "<td>{$current->bshortname}</td>\n";
+                       echo "<td>{$current->bname}</td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_shortnames($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _NAME . "</th>\n";
+                       echo '<th>' . _LISTS_DESC. "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->name = Entity::hsc($current->name);
+                       $current->description = Entity::hsc($current->description);
+                       
+                       echo "<td>{$current->name}</td>\n";
+                       echo "<td>{$current->description}</td>\n";
+                       break;
+       }
+       return;
+}
+
+
+function listplug_table_categorylist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_NAME . "</th>";
+                       echo '<th>' . _LISTS_DESC."</th>\n";
+                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $id = listplug_nextBatchId();
+                       
+                       $current = $template['current'];
+                       $current->cname = Entity::hsc($current->cname);
+                       $current->cdesc = Entity::hsc($current->cdesc);
+                       
+                       echo "<td>\n";
+                       echo "<input type=\"checkbox\" id=\"batch{$id}\" name=\"batch[{$id}]\" value=\"{$current->catid}\" />\n";
+                       echo "<label for=\"batch{$id}\">{$current->cname}</label>\n";
+                       echo "</td>\n";
+                       echo "<td>{$current->cdesc}</td>\n";
+                       echo "<td><a href=\"index.php?action=categoryedit&amp;blogid={$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a></td>\n";
+                       echo "<td><a href=\"index.php?action=categorydelete&amp;blogid={$current->cblog}&amp;catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_templatelist($template, $type)
+{
+       global $manager;
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_NAME . "</th>\n";
+                       echo '<th>' . _LISTS_DESC . "</th>\n";
+                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->tdnumber = (integer) $current->tdnumber;
+                       $current->tdname = Entity::hsc($current->tdname);
+                       $current->tddesc = Entity::hsc($current->tddesc);
+                       
+                       $url = "index.php?action=templateclone&templateid={$current->tdnumber}";
+                       $url = Entity::hsc($manager->addTicketToUrl($url));
+                       
+                       echo "<td>{$current->tdname}</td>\n";
+                       echo "<td>{$current->tddesc}</td>\n";
+                       echo "<td>\n";
+                       echo "<a href=\"index.php?action=templateedit&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "</a>\n";
+                       echo "</td>\n";
+                       echo "<td>\n";
+                       echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";
+                       echo "</td>\n";
+                       echo "<td>\n";
+                       echo "<a href=\"index.php?action=templatedelete&amp;templateid={$current->tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a>\n";
+                       echo "</td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_skinlist($template, $type)
+{
+       global $CONF, $DIR_SKINS, $manager;
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_NAME . "</th>\n";
+                       echo '<th>' . _LISTS_DESC . "</th>\n";
+                       echo '<th colspan="3">' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->sdnumber = (integer) $current->sdnumber;
+                       $current->sdname = Entity::hsc($current->sdname);
+                       $current->sdtype = Entity::hsc($current->sdtype);
+                       
+                       echo "<td>\n";
+                       
+                       // use a special style for the default skin
+                       if ( $current->sdnumber == $CONF['BaseSkin'] )
+                       {
+                               echo '<h3 id="base_skin">' . $current->sdname . "</h3>\n";
+                       }
+                       else
+                       {
+                               echo '<h3>' . $current->sdname . "</h3>\n";
+                       }
+                       
+                       echo "<dl>\n";
+                       echo '<dt>' . _LISTS_TYPE . "</dt>\n";
+                       echo '<dd>' . $current->sdtype . "</dd>\n";
+                       
+                       echo '<dt>' . _LIST_SKINS_INCMODE . "</dt>\n";
+                       
+                       if ( $current->sdincmode == 'skindir' )
+                       {
+                               echo '<dd>' . _PARSER_INCMODE_SKINDIR . "</dd>\n";
+                       }
+                       else
+                       {
+                               echo '<dd>' . _PARSER_INCMODE_NORMAL . "</dd>\n";
+                       }
+                       
+                       if ( $current->sdincpref )
+                       {
+                               echo '<dt>' . _LIST_SKINS_INCPREFIX . "</dt>\n";
+                               echo '<dd>' . Entity::hsc($current->sdincpref) . "</dd>\n";
+                       }
+                       echo "</dl>\n";
+                       
+                       // add preview image when present
+                       if ( $current->sdincpref && @file_exists("{$DIR_SKINS}{$current->sdincpref}preview.png") )
+                       {
+                               echo "<p>\n";
+                               
+                               $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current->sdname);
+                               $has_enlargement = @file_exists($DIR_SKINS . $current->sdincpref . 'preview-large.png');
+                               if ( $has_enlargement )
+                               {
+                                       echo '<a href="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview-large.png" title="' . _LIST_SKIN_PREVIEW_VIEWLARGER . "\">\n";
+                                       echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" />\n";
+                                       echo "</a><br />\n";
+                               }
+                               else
+                               {
+                                       echo '<img class="skinpreview" src="',$CONF['SkinsURL'], Entity::hsc($current->sdincpref),'preview.png" width="100" height="75" alt="' . $alternatve_text . "\" /><br />\n";
+                               }
+                               
+                               if ( @file_exists("{$DIR_SKINS}{$current->sdincpref}readme.html") )
+                               {
+                                       $url = $CONF['SkinsURL'] . Entity::hsc($current->sdincpref) . 'readme.html';
+                                       $title = sprintf(_LIST_SKIN_README, $current->sdname);
+                                       echo "<a href=\"{$url}\" title=\"{$title}\">" . _LIST_SKIN_README_TXT . "</a>\n";
+                               }
+                               
+                               echo "</p>\n";
+                       }
+                       
+                       echo "</td>\n";
+                       
+                       echo "<td>\n";
+                       echo '<p>' . Entity::hsc($current->sddesc) . "</p>\n";
+                       
+                       /* show list of defined parts */
+                       $query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype";
+                       $query = sprintf($query, sql_table('skin'), $current->sdnumber);
+                       $r = sql_query($query);
+                       
+                       $types = array();
+                       while ( $o = sql_fetch_object($r) )
+                       {
+                               array_push($types, $o->stype);
+                       }
+                       if ( sizeof($types) > 0 )
+                       {
+                               for ( $i = 0; $i < sizeof($types); $i++ )
+                               {
+                                       $type = $types[$i];
+                                       if ( !array_key_exists($type, $template['friendly_names']) || $type == strtolower($template['friendly_names'][$type]) )
+                                       {
+                                               $article = 'skinpartspecial';
+                                       }
+                                       else
+                                       {
+                                               $article = "skinpart{$type}";
+                                       }
+                                       $types[$i]  = "<li>\n"
+                                                   . helpHtml($article) . "\n"
+                                                   . "<a href=\"index.php?action=skinedittype&amp;skinid={$current->sdnumber}&amp;type={$type}\" tabindex=\"{$template['tabindex']}\">"
+                                                   . Entity::hsc($template['friendly_names'][$type])
+                                                   . "</a>\n"
+                                                   . "</li>\n";
+                               }
+                               echo _LIST_SKINS_DEFINED;
+                               echo '<ul>' . implode('', $types) . "</ul>\n";
+                       }
+                       echo "</td>";
+                       echo "<td>\n";
+                       echo "<a href=\nindex.php?action=skinedit&amp;skinid={$current->sdnumber}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "</a>\n";
+                       echo "</td>\n";
+                       
+                       $url = "index.php?action=skinclone&skinid={$current->sdnumber}";
+                       $url = Entity::hsc($manager->addTicketToUrl($url));
+                       echo "<td>\n";
+                       echo "<a href=\"{$url}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_CLONE . "</a>\n";
+                       echo "</td>\n";
+                       echo "<td>\n";
+                       echo "<a href=\"index.php?action=skindelete&amp;skinid={$current->sdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "</a></td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_draftlist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_BLOG . "</th>\n";
+                       echo '<th>' . _LISTS_TITLE . "</th>\n";
+                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->bshortname = Entity::hsc($current->bshortname);
+                       $current->ititle = Entity::hsc(strip_tags($current->ititle));
+                       
+                       echo "<td>{$current->bshortname}</td>\n";
+                       echo "<td>{$current->ititle}</td>\n";
+                       echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";
+                       echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_otherdraftlist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_BLOG . "</th>\n";
+                       echo '<th>' . _LISTS_TITLE . "</th>\n";
+                       echo '<th>' . _LISTS_AUTHOR . "</th>\n";
+                       echo '<th colspan="2">' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->bshortname = Entity::hsc($current->bshortname);
+                       $current->ititle = Entity::hsc(strip_tags($current->ititle));
+                       $current->mname = Entity::hsc($current->mname);
+                       
+                       echo "<td>{$current->bshortname}</td>\n";
+                       echo "<td>{$current->ititle}</td>\n";
+                       echo "<td>{$current->mname}</td>\n";
+                       echo "<td><a href=\"index.php?action=itemedit&amp;itemid={$current->inumber}\">" . _LISTS_EDIT . "</a></td>\n";
+                       echo "<td><a href=\"index.php?action=itemdelete&amp;itemid={$current->inumber}\">" . _LISTS_DELETE . "</a></td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_actionlist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LISTS_TIME . "</th>\n";
+                       echo '<th>' . _LIST_ACTION_MSG . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->timestamp = Entity::hsc($current->timestamp);
+                       $current->message = Entity::hsc($current->message);
+                       
+                       echo "<td>{$current->timestamp}</td>\n";
+                       echo "<td>{$current->message}</td>\n";
+                       break;
+       }
+       return;
+}
+
+function listplug_table_banlist($template, $type)
+{
+       switch( $type )
+       {
+               case 'HEAD':
+                       echo '<th>' . _LIST_BAN_IPRANGE . "</th>\n";
+                       echo '<th>' . _LIST_BAN_REASON."</th>\n";
+                       echo '<th>' . _LISTS_ACTIONS . "</th>\n";
+                       break;
+               case 'BODY':
+                       $current = $template['current'];
+                       $current->blogid = (integer) $current->blogid;
+                       $current->iprange = Entity::hsc($current->iprange);
+                       $current->reason = Entity::hsc($current->reason);
+                       
+                       echo "<td>{$current->iprange}</td>\n";
+                       echo "<td>{$current->reason}</td>\n";
+                       echo "<td><a href=\"index.php?action=banlistdelete&amp;blogid=\"{$current->blogid}&amp;iprange=\"Entity::hsc($current->iprange}\">" . _LISTS_DELETE . "</a></td>\n";
+                       break;
+       }
+       return;
+}