OSDN Git Service

ADD/FIX/CHANGE/REMOVE: スキン・テンプレート表示処理の改良
[nucleus-jp/nucleus-next.git] / nucleus / libs / ACTIONS.php
index 10f2318..15ea24c 100644 (file)
-<?php
-/*
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2009 The Nucleus Group
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * (see nucleus/documentation/index.html#license for more info)
- */
-/**
- * This class 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-2009 The Nucleus Group
- * @version $Id: ACTIONS.php 1624 2012-01-09 11:36:20Z sakamocchi $
- */
-
-class ACTIONS extends BaseActions {
-
-       // part of the skin currently being parsed ('index', 'item', 'archive',
-       // 'archivelist', 'member', 'search', 'error', 'imagepopup')
-       var $skintype;
-
-       // contains an assoc array with parameters that need to be included when
-       // generating links to items/archives/... (e.g. catid)
-       var $linkparams;
-
-       // reference to the skin object for which a part is being parsed
-       var $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)
-       var $formdata;
-
-       // filled out with the number of displayed items after calling one of the
-       // (other)blog/(other)searchresults skinvars.
-       var $amountfound;
-
-       /**
-        * Constructor for a new ACTIONS object
-        */
-       function ACTIONS($type) {
-               // call constructor of superclass first
-               $this->BaseActions();
-
-               $this->skintype = $type;
-
-               global $catid;
-               if ($catid)
-                       $this->linkparams = array('catid' => $catid);
-       }
-
-       /**
-        *  Set the skin
-        */
-       function setSkin(&$skin) {
-               $this->skin =& $skin;
-       }
-
-       /**
-        *  Set the parser
-        */
-       function setParser(&$parser) {
-               $this->parser =& $parser;
-       }
-
-       /**
-        *      Forms get parsedincluded now, using an extra <formdata> skinvar
-       */
-       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
-       }
-
-       /**
-        * Checks conditions for if statements
-        *
-        * @param string $field type of <%if%>
-        * @param string $name property of field
-        * @param string $value value of property
-        */
-       function checkCondition($field, $name='', $value = '') {
-               global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
-
-               $condition = 0;
-               switch($field) {
-                       case 'category':
-                               $condition = ($blog && $this->_ifCategory($name,$value));
-                               break;
-                       case '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':
-                               $condition = ($itemidnext != '');
-                               break;
-                       case 'previtem':
-                               $condition = ($itemidprev != '');
-                               break;
-                       case 'archiveprevexists':
-                               $condition = ($archiveprevexists == true);
-                               break;
-                       case 'archivenextexists':
-                               $condition = ($archivenextexists == true);
-                               break;
-                       case 'skintype':
-                               $condition = ($name == $this->skintype);
-                               break;
-                       case 'hasplugin':
-                               $condition = $this->_ifHasPlugin($name, $value);
-                               break;
-                       default:
-                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);
-                               break;
-               }
-               return $condition;
-       }
-
-       /**
-        *      hasplugin,PlugName
-        *         -> checks if plugin exists
-        *      hasplugin,PlugName,OptionName
-        *         -> checks if the option OptionName from plugin PlugName is not set to 'no'
-        *      hasplugin,PlugName,OptionName=value
-        *         -> checks if the option OptionName from plugin PlugName is set to value
-        */
-       function _ifHasPlugin($name, $value) {
-               global $manager;
-               $condition = false;
-               // (pluginInstalled method won't write a message in the actionlog on failure)
-               if ($manager->pluginInstalled('NP_'.$name)) {
-                       $plugin =& $manager->getPlugin('NP_' . $name);
-                       if ($plugin != NULL) {
-                               if ($value == "") {
-                                       $condition = true;
-                               } else {
-                                       list($name2, $value2) = i18n::explode('=', $value, 2);
-                                       if ($value2 == "" && $plugin->getOption($name2) != 'no') {
-                                               $condition = true;
-                                       } else if ($plugin->getOption($name2) == $value2) {
-                                               $condition = true;
-                                       }
-                               }
-                       }
-               }
-               return $condition;
-       }
-
-       /**
-        * Checks if a plugin exists and call its doIf function
-        */
-       function _ifPlugin($name, $key = '', $value = '') {
-               global $manager;
-
-               $plugin =& $manager->getPlugin('NP_' . $name);
-               if (!$plugin) return;
-
-               $params = func_get_args();
-               array_shift($params);
-
-               return call_user_func_array(array(&$plugin, 'doIf'), $params);
-       }
-
-       /**
-        *  Different checks for a category
-        */
-       function _ifCategory($name = '', $value='') {
-               global $blog, $catid;
-
-               // when no parameter is defined, just check if a category is selected
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))
-                       return $blog->isValidCategory($catid);
-
-               // check category name
-               if ($name == 'catname') {
-                       $value = $blog->getCategoryIdFromName($value);
-                       if ($value == $catid)
-                               return $blog->isValidCategory($catid);
-               }
-
-               // check category id
-               if (($name == 'catid') && ($value == $catid))
-                       return $blog->isValidCategory($catid);
-
-               return false;
-       }
-
-       /**
-        *  Checks if a member is on the team of a blog and return his rights
-        */
-       function _ifOnTeam($blogName = '') {
-               global $blog, $member, $manager;
-
-               // when no blog found
-               if (($blogName == '') && (!is_object($blog)))
-                       return 0;
-
-               // explicit blog selection
-               if ($blogName != '')
-                       $blogid = getBlogIDFromName($blogName);
-
-               if (($blogName == '') || !$manager->existsBlogID($blogid))
-                       // use current blog
-                       $blogid = $blog->getID();
-
-               return $member->teamRights($blogid);
-       }
-
-       /**
-        *  Checks if a member is admin of a blog
-        */
-       function _ifAdmin($blogName = '') {
-               global $blog, $member, $manager;
-
-               // when no blog found
-               if (($blogName == '') && (!is_object($blog)))
-                       return 0;
-
-               // explicit blog selection
-               if ($blogName != '')
-                       $blogid = getBlogIDFromName($blogName);
-
-               if (($blogName == '') || !$manager->existsBlogID($blogid))
-                       // use current blog
-                       $blogid = $blog->getID();
-
-               return $member->isBlogAdmin($blogid);
-       }
-       
-       /**
-        * 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)
-        */
-       function _link($url, $linktext = '')
-       {
-               $u = ENTITY::hsc($url);
-               $u = preg_replace("/&amp;amp;/",'&amp;',$u); // fix URLs that already had encoded ampersands
-               if ($linktext != '') 
-                       $l = '<a href="' . $u .'">'.ENTITY::hsc($linktext).'</a>';
-               else
-                       $l = $u;
-               return $l;
-       }
-       
-       /**
-        * 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
-        */
-       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       = intval($startpos);            // will be 0 when empty.
-               $parsed         = parse_url(serverVar('REQUEST_URI'));
-               $path           = $parsed['path'];
-               $parsed         = $parsed['query'];
-               $url            = '';
-               
-               switch ($direction) {
-                       case 'prev':
-                               if ( intval($startpos) - intval($maxresults) >= 0) {
-                                       $startpos       = intval($startpos) - intval($maxresults);
-                                       //$url          = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
-                                       switch ($this->skintype)
-                                       {
-                                               case 'index':
-                                                       $url = $path;
-                                                       break;
-                                               case 'search':
-                                                       $url = $CONF['SearchURL'];
-                                                       break;
-                                       }
-                                       $url .= '?'.alterQueryStr($parsed,'startpos',$startpos);
-                               }
-                               
-                               break;
-                       case '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
-                                       switch ($this->skintype)
-                                       {
-                                               case 'index':
-                                                       $sqlquery = $blog->getSqlBlog('', 'count');
-                                                       $url = $path;
-                                                       break;
-                                               case 'search':
-                                                       $unused_highlight = '';
-                                                       $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
-                                                       $url = $CONF['SearchURL'];
-                                                       break;
-                                       }
-                                       if ($sqlquery)
-                                               $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
-                               }
-                               
-                               if (intval($iAmountOnPage) >= intval($maxresults)) {
-                                       $startpos       = intval($startpos) + intval($maxresults);
-                                       //$url          = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
-                                       $url            .= '?'.alterQueryStr($parsed,'startpos',$startpos);
-                               }
-                               else $url = '';
-                               break;
-                       default:
-                               break;
-               } // switch($direction)
-
-               if ($url != '')
-                       echo $this->_link($url, $linktext);
-       }
-
-       /**
-        * 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
-        */
-       function _itemlink($id, $linktext = '')
-       {
-               global $CONF;
-               if ( $id )
-               {
-                       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
-        */
-       function _archivelink($id, $linktext = '')
-       {
-               global $CONF, $blog;
-               if ( $id )
-               {
-                       echo $this->_link(LINK::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
-               }
-               else
-               {
-                       $this->parse_todaylink($linktext);
-               }
-               return;
-       }
-       
-       /**
-         * Helper function that sets the category that a blog will need to use
-         *
-         * @param $blog
-         *             An object of the blog class, passed by reference (we want to make changes to it)
-         * @param $catname
-         *             The name of the category to use
-         */
-       function _setBlogCategory(&$blog, $catname) {
-               global $catid;
-               if ($catname != '')
-                       $blog->setSelectedCategoryByName($catname);
-               else
-                       $blog->setSelectedCategory($catid);
-       }
-
-       /**
-        *  Notifies the Manager that a PreBlogContent event occurs
-        */
-       function _preBlogContent($type, &$blog) {
-               global $manager;
-               $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
-       }
-
-       /**
-        *  Notifies the Manager that a PostBlogContent event occurs
-        */
-       function _postBlogContent($type, &$blog) {
-               global $manager;
-               $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
-       }
-       
-       /**
-        * Parse skinvar additemform
-        */
-       function parse_additemform() {
-               global $blog, $CONF;
-               $this->formdata = array(
-                       'adminurl' => ENTITY::hsc($CONF['AdminURL']),
-                       'catid' => $blog->getDefaultCategory()
-               );
-               $blog->InsertJavaScriptInfo();
-               $this->doForm('additemform');
-       }
-       
-       /**
-        * Parse skinvar addlink
-        * A Link that allows to open a bookmarklet to add an item
-        */
-       function parse_addlink() {
-               global $CONF, $member, $blog;
-               if ($member->isLoggedIn() && $member->isTeamMember($blog->blogid) ) {
-                       echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
-               }
-       }
-       
-       /**
-        * Parse skinvar addpopupcode
-        * Code that opens a bookmarklet in an popup window
-        */
-       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;";
-       }
-       
-       /**
-        * Parse skinvar adminurl
-        * (shortcut for admin url)      
-        */
-       function parse_adminurl() {
-               $this->parse_sitevar('adminurl');
-       }
-
-       /**
-        * Parse skinvar archive
-        */
-       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);
-
-       }
-
-       /**
-         * %archivedate(locale,date format)%
-         */
-       function parse_archivedate($locale = '-def-') {
-               global $archive;
-
-               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::strftime($format,mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
-       }
-
-       /**
-        *  Parse skinvar archivedaylist
-        */             
-       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);
-       }
-       
-       /**
-        * ACTIONS::parse_archivelink()
-        *      A link to the archives for the current blog (or for default blog)
-        *
-        * @param       String  $linktext       text for link
-        * @return      Void
-        */
-       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;
-       }
-       
-       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);
-       }
-               
-       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);
-       }
-       
-       /**
-        * Parse skinvar archivetype
-        */
-       function parse_archivetype() {
-               global $archivetype;
-               echo $archivetype;
-       }
-
-       /**
-        * Parse skinvar blog
-        */
-       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);
-       }
-       
-       /*
-       *       Parse skinvar bloglist
-       *       Shows a list of all blogs
-       *       bnametype: whether 'name' or 'shortname' is used for the link text        
-       *       orderby: order criteria
-       *       direction: order ascending or descending                  
-       */
-       function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') {
-               BLOG::showBlogList($template, $bnametype, $orderby, $direction);
-       }
-       
-       /**
-        * Parse skinvar blogsetting
-        */
-       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;
-               }
-       }
-       
-       /**
-        * Parse callback
-        */
-       function parse_callback($eventName, $type)
-       {
-               global $manager;
-               $manager->notify($eventName, array('type' => $type));
-       }
-       
-       /**
-        * Parse skinvar category
-        */
-       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;
-               }
-       }
-       
-       /**
-        * Parse categorylist
-        */
-       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);
-               }
-       }
-       
-       /**
-        * Parse skinvar charset
-        */
-       function parse_charset() {
-               echo i18n::get_current_charset();
-       }
-       
-       /**
-        * ACTIONS::parse_commentform()
-        * Parse skinvar commentform
-        * 
-        * @param       String  $destinationurl URI for redirection
-        * @return      Void
-        */
-       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;
-       }
-       
-       /**
-        * Parse skinvar comments
-        * include comments for one item         
-        */
-       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);
-               $comments->showComments($template, -1, 1, $highlight);  // shows ALL comments
-       }
-
-       /**
-        * Parse errordiv
-        */
-       function parse_errordiv() {
-               global $errormessage;
-               if ($errormessage)
-                       echo '<div class="error">', ENTITY::hsc($errormessage),'</div>';
-       }
-       
-       /**
-        * Parse skinvar errormessage
-        */
-       function parse_errormessage() {
-               global $errormessage;
-               echo $errormessage;
-       }
-       
-       /**
-        * Parse formdata
-        */
-       function parse_formdata($what) {
-               echo $this->formdata[$what];
-       }
-       
-       /**
-        * Parse ifcat
-        */
-       function parse_ifcat($text = '') {
-               if ($text == '') {
-                       // new behaviour
-                       $this->parse_if('category');
-               } else {
-                       // old behaviour
-                       global $catid, $blog;
-                       if ($blog->isValidCategory($catid))
-                               echo $text;
-               }
-       }
-
-       /**
-        * Parse skinvar image
-        */
-       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;
-               }
-       }
-       
-       /**
-        * Parse skinvar imagetext
-        */
-       function parse_imagetext() {
-               echo ENTITY::hsc(requestVar('imagetext'));
-       }
-
-       /**
-        * Parse skinvar item
-        * include one item (no comments)        
-        */
-       function parse_item($template) {
-               global $blog, $itemid, $highlight;
-               $this->_setBlogCategory($blog, '');     // need this to select default category
-               $this->_preBlogContent('item',$blog);
-               $r = $blog->showOneitem($itemid, $template, $highlight);
-               if ($r == 0)
-                       echo _ERROR_NOSUCHITEM;
-               $this->_postBlogContent('item',$blog);
-       }
-
-       /**
-        * Parse skinvar itemid
-        */
-       function parse_itemid() {
-               global $itemid;
-               echo $itemid;
-       }
-       
-       /**
-        * Parse skinvar itemlink
-        */
-       function parse_itemlink($linktext = '') {
-               global $itemid;
-               $this->_itemlink($itemid, $linktext);
-       }
-
-       /**
-        * Parse itemtitle
-        */
-       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;
-               }
-       }
-
-       /**
-        * Parse skinvar loginform
-        */
-       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);
-       }
-
-       /**
-        * ACTIONS::parse_member()
-        * Parse skinvar member
-        * (includes a member info thingie)
-        * 
-        * @param       String  $what   which memberdata is needed
-        * @return      Void
-        */
-       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
-        */
-       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;
-       }
-       
-       /**
-        * Parse skinvar nextarchive
-        */
-       function parse_nextarchive() {
-               global $archivenext;
-               echo $archivenext;
-       }
-
-       /**
-        * Parse skinvar nextitem
-        * (include itemid of next item)
-        */
-       function parse_nextitem() {
-               global $itemidnext;
-               if (isset($itemidnext)) echo (int)$itemidnext;
-       }
-
-       /**
-        * Parse skinvar nextitemtitle
-        * (include itemtitle of next item)
-        */
-       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;
-               }
-       }
-
-       /**
-        * Parse skinvar nextlink
-        */
-       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);
-       }
-
-       /**
-        * Parse skinvar nucleusbutton
-        */
-       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');
-       }
-       
-       /**
-        * Parse skinvar otherarchive
-        */     
-       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);
-       }
-       
-       /**
-        * Parse skinvar otherarchivedaylist
-        */
-       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);
-       }
-       
-       /**
-        * Parse skinvar otherarchivelist
-        */
-       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);
-       }
-               
-       /**
-        * Parse skinvar otherarchiveyearlist
-        */
-       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);
-       }       
-       
-       /**
-        * Parse skinvar otherblog
-        */
-       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);
-       }
-
-       /**
-        * Parse skinvar othersearchresults
-        */
-       function parse_othersearchresults($blogname, $template, $maxresults = 50) {
-               global $query, $amount, $manager, $startpos;
-               $b =& $manager->getBlog(getBlogIDFromName($blogname));
-               $this->_setBlogCategory($b, '');        // need this to select default category
-               $this->_preBlogContent('othersearchresults',$b);
-               $b->search($query, $template, $amount, $maxresults, $startpos);
-               $this->_postBlogContent('othersearchresults',$b);
-       }
-
-       /**
-         * Executes a plugin skinvar
-         *
-         * @param pluginName name of plugin (without the NP_)
-         *
-         * extra parameters can be added
-         */
-       function parse_plugin($pluginName) {
-               global $manager;
-
-               // should be already tested from the parser (PARSER.php)
-               // only continue when the plugin is really installed
-               /*if (!$manager->pluginInstalled('NP_' . $pluginName))
-                       return;*/
-
-               $plugin =& $manager->getPlugin('NP_' . $pluginName);
-               if (!$plugin) return;
-
-               // get arguments
-               $params = func_get_args();
-
-               // remove plugin name
-               array_shift($params);
-
-               // add skin type on front
-               array_unshift($params, $this->skintype);
-
-               call_user_func_array(array(&$plugin,'doSkinVar'), $params);
-       }
-       
-       /**
-        * Parse skinvar prevarchive
-        */
-       function parse_prevarchive() {
-               global $archiveprev;
-               echo $archiveprev;
-       }
-
-       /**
-        * Parse skinvar preview
-        */
-       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);
-       }
-
-       /*
-        * Parse skinvar previtem
-        * (include itemid of prev item)                 
-        */
-       function parse_previtem() {
-               global $itemidprev;
-               if (isset($itemidprev)) echo (int)$itemidprev;
-       }
-       
-       /**
-        * ACTIONS::parse_previtemtitle()
-        * Parse skinvar previtemtitle
-        * (include itemtitle of prev item)
-        * 
-        * @param       String  $format string format
-        * @return      String  formatted string
-        */
-       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;
-       }
-       
-       /**
-        * Parse skinvar prevlink
-        */
-       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);
-       }
-
-       /**
-        * Parse skinvar query
-        * (includes the search query)   
-        */
-       function parse_query() {
-               global $query;
-               echo ENTITY::hsc($query);
-       }
-       
-       /**
-        * Parse skinvar referer
-        */
-       function parse_referer() {
-               echo ENTITY::hsc(serverVar('HTTP_REFERER'));
-       }
-
-       /**
-        * Parse skinvar searchform
-        */
-       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');
-       }
-
-       /**
-        * Parse skinvar searchresults
-        */
-       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);
-       }
-
-       /**
-        * Parse skinvar self
-        */
-       function parse_self() {
-               global $CONF;
-               echo $CONF['Self'];
-       }
-
-       /**
-        * Parse skinvar sitevar
-        * (include a sitevar)   
-        */
-       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'];
-               }
-       }
-
-       /**
-        * Parse skinname
-        */
-       function parse_skinname() {
-               echo $this->skin->getName();
-       }
-       
-       /**
-        * Parse skintype (experimental)
-        */
-       function parse_skintype() {
-               echo $this->skintype;
-       }
-
-       /**
-        * Parse text
-        */
-       function parse_text($which) {
-               // constant($which) only available from 4.0.4 :(
-               if (defined($which)) {
-                       eval("echo $which;");
-               }
-       }
-       
-       /**
-        * Parse ticket
-        */
-       function parse_ticket() {
-               global $manager;
-               $manager->addTicketHidden();
-       }
-
-       /**
-        * 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
-        */
-       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   
-        */
-       function parse_vars() {
-               global $itemid;
-               echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
-       }
-
-       /**
-        * Parse skinvar version
-        * (include nucleus versionnumber)       
-        */
-       function parse_version() {
-               global $nucleus;
-               echo 'Nucleus CMS ' . $nucleus['version'];
-       }
-       
-       /**
-        * Parse skinvar sticky
-        */
-       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);
-       }
-
-
-}
-?>
+<?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
+ * @license http://nucleuscms.org/license.txt GNU General Public License\r
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
+ * @version $Id: ACTIONS.php 1863 2012-05-19 10:50:27Z sakamocchi $
+ */\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
+       private $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
+       private $linkparams;\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
+       private $formdata;\r
+       \r
+       // filled out with the number of displayed items after calling one of the\r
+       // (other)blog/(other)searchresults skinvars.\r
+       private $amountfound;\r
+       \r
+       /**\r
+        * Actions::$default_actions\r
+        * list of whole action names with which this class can deal\r
+        */\r
+       static private $default_actions = array(\r
+               'addlink',\r
+               'addpopupcode',\r
+               'adminurl',\r
+               'archivelink',\r
+               'bloglist',\r
+               'category',\r
+               'loginform',\r
+               'member',\r
+               'nucleusbutton',\r
+               'otherarchivedaylist',\r
+               'otherarchivelist',\r
+               'otherarchiveyearlist',\r
+               'otherblog',\r
+               'plugin',\r
+               'referer',\r
+               'searchform',\r
+               'self',\r
+               'sitevar',\r
+               'skinname',\r
+               'sticky',\r
+               'todaylink',\r
+               'version',\r
+               // deprecated (Nucleus v2.0)\r
+               /* TODO: remove this */\r
+               'ifcat'\r
+       );\r
+       \r
+       /**\r
+        * Actions::$skin_type_friendly_names\r
+        * friendly name for wrapped page types\r
+        */\r
+       static public $default_skin_types = 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
+       /**\r
+        * Actions::getAvailableSkinTypes()\r
+        * \r
+        * @static\r
+        * @param       void\r
+        * @return      array   list of friendly names for page actions\r
+        */\r
+       static public function getAvailableSkinTypes()\r
+       {\r
+               return self::$default_skin_types;\r
+       }\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
+               parent::__construct();\r
+               $this->skintype = $type;\r
+               \r
+               if ( $catid )\r
+               {\r
+                       $this->linkparams = array('catid' => $catid);\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * Actions::getAvailableActions()\r
+        * \r
+        * @param       void\r
+        * @return      array   allowed actions for the page type\r
+        */\r
+       public function getAvailableActions()\r
+       {\r
+               $extra_actions = array();\r
+               \r
+               switch ( $this->skintype )\r
+               {\r
+                       case 'index':\r
+                               $extra_actions = 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
+                               $extra_actions = 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
+                               $extra_actions = array(\r
+                                       'blog',\r
+                                       'archivelist',\r
+                                       'archivedaylist',\r
+                                       'archiveyearlist',\r
+                                       'categorylist',\r
+                                       'blogsetting'\r
+                               );\r
+                               break;\r
+                       case 'search':\r
+                               $extra_actions = 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
+                               $extra_actions = array(\r
+                                       'image',\r
+                                       // deprecated (Nucleus v2.0)\r
+                                       /* TODO: remove this */\r
+                                       'imagetext'\r
+                               );\r
+                               break;\r
+                       case 'member':\r
+                               $extra_actions = array(\r
+                                       'membermailform',\r
+                                       'blogsetting',\r
+                                       'nucleusbutton',\r
+                                       'categorylist'\r
+                               );\r
+                               break;\r
+                       case 'item':\r
+                               $extra_actions = 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
+                               $extra_actions = array(\r
+                                       'errormessage',\r
+                                       'categorylist'\r
+                               );\r
+                               break;\r
+                       default:\r
+                                       $extra_actions = 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
+                               break;\r
+               }\r
+               \r
+               $defined_actions = array_merge(self::$default_actions, $extra_actions);\r
+               \r
+               return array_merge($defined_actions, parent::getAvailableActions());\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', '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);      // 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
+       protected function checkCondition($field, $name='', $value = '')\r
+       {\r
+               global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
+               \r
+               $condition = 0;\r
+               switch ( $field )\r
+               {\r
+                       case 'category':\r
+                               $condition = ($blog && $this->ifCategory($name,$value));\r
+                               break;\r
+                       case '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
+                       case 'admin':\r
+                               $condition = $member->isLoggedIn() && $this->ifAdmin($name);\r
+                               break;\r
+                       case 'nextitem':\r
+                               $condition = ($itemidnext != '');\r
+                               break;\r
+                       case 'previtem':\r
+                               $condition = ($itemidprev != '');\r
+                               break;\r
+                       case 'archiveprevexists':\r
+                               $condition = ($archiveprevexists == true);\r
+                               break;\r
+                       case 'archivenextexists':\r
+                               $condition = ($archivenextexists == true);\r
+                               break;\r
+                       case 'skintype':\r
+                               $condition = (($name == $this->skintype) || ($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
+               else if ( $name == 'catname' )
+               {\r
+                       $value = $blog->getCategoryIdFromName($value);\r
+                       if ( $value == $catid )\r
+                       {\r
+                               return $blog->isValidCategory($catid);\r
+                       }\r
+               }\r
+               \r
+               // check category id\r
+               else if ( ($name == 'catid') && ($value == $catid) )
+               {\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           = ( in_array('path', $parsed) ) ? $parsed['path'] : '';\r
+               $parsed         = ( in_array('query', $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(DB::getValue($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_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 $manager, $blog, $highlight, $itemid;\r
+               \r
+               $template =& $manager->getTemplate($template);\r
+               $item =& $manager->getitem($itemid, 0, 0);\r
+               \r
+               // create parser object & action handler\r
+               $handler = new ItemActions($blog);\r
+               $handler->setTemplate($template);\r
+               $handler->setCurrentItem($item);\r
+               \r
+               $parser = new Parser($handler);\r
+               \r
+               $comments = new Comments($itemid);\r
+               $comments->setItemActions($handler);\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->parser->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_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