3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2012 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * This class contains the functions that get called by using
14 * the special tags in the skins
16 * @license http://nucleuscms.org/license.txt GNU General Public License
17 * @copyright Copyright (C) 2002-2012 The Nucleus Group
18 * @version $Id: ACTIONS.php 1886 2012-06-17 08:27:27Z sakamocchi $
21 class Actions extends BaseActions
23 // part of the skin currently being parsed ('index', 'item', 'archive',
24 // 'archivelist', 'member', 'search', 'error', 'imagepopup')
27 // contains an assoc array with parameters that need to be included when
28 // generating links to items/archives/... (e.g. catid)
31 // used when including templated forms from the include/ dir. The $formdata var
32 // contains the values to fill out in there (assoc array name -> value)
35 // filled out with the number of displayed items after calling one of the
36 // (other)blog/(other)searchresults skinvars.
40 * Actions::$default_actions
41 * list of whole action names with which this class can deal
43 static private $default_actions = array(
53 'otherarchivedaylist',
55 'otherarchiveyearlist',
66 // deprecated (Nucleus v2.0)
67 /* TODO: remove this */
72 * Actions::$normal_skin_types
73 * friendly name for wrapped page types
75 static public $normal_skin_types = array(
76 'index' => _SKIN_PART_MAIN,
77 'item' => _SKIN_PART_ITEM,
78 'archivelist' => _SKIN_PART_ALIST,
79 'archive' => _SKIN_PART_ARCHIVE,
80 'search' => _SKIN_PART_SEARCH,
81 'error' => _SKIN_PART_ERROR,
82 'member' => _SKIN_PART_MEMBER,
83 'imagepopup' => _SKIN_PART_POPUP
87 * Actions::getNormalSkinTypes()
91 * @return array list of friendly names for page actions
93 static public function getNormalSkinTypes()
95 return self::$normal_skin_types;
99 * Actions::__construct()
100 * Constructor for a new Actions object
102 * @param string $type
105 public function __construct($type)
109 // call constructor of superclass first
110 parent::__construct();
111 $this->skintype = $type;
115 $this->linkparams = array('catid' => $catid);
121 * Actions::getAvailableActions()
124 * @return array allowed actions for the page type
126 public function getAvailableActions()
128 $extra_actions = array();
130 switch ( $this->skintype )
133 $extra_actions = array(
147 $extra_actions = array(
165 $extra_actions = array(
175 $extra_actions = array(
182 'othersearchresults',
190 $extra_actions = array(
192 // deprecated (Nucleus v2.0)
193 /* TODO: remove this */
198 $extra_actions = array(
206 $extra_actions = array(
229 $extra_actions = array(
235 $extra_actions = array(
253 $defined_actions = array_merge(self::$default_actions, $extra_actions);
255 return array_merge($defined_actions, parent::getAvailableActions());
260 * Forms get parsedincluded now, using an extra <formdata> skinvar
262 * @param string $filename
265 public function doForm($filename)
268 array_push($this->parser->actions,'formdata', 'callback','errordiv','ticket');
270 $oldIncludeMode = Parser::getProperty('IncludeMode');
271 $oldIncludePrefix = Parser::getProperty('IncludePrefix');
272 Parser::setProperty('IncludeMode','normal');
273 Parser::setProperty('IncludePrefix','');
275 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
276 Parser::setProperty('IncludeMode',$oldIncludeMode);
277 Parser::setProperty('IncludePrefix',$oldIncludePrefix);
279 array_pop($this->parser->actions); // errordiv
280 array_pop($this->parser->actions); // callback
281 array_pop($this->parser->actions); // formdata
282 array_pop($this->parser->actions); // ticket
287 * Actions::checkCondition()
288 * Checks conditions for if statements
290 * @param string $field type of <%if%>
291 * @param string $name property of field
292 * @param string $value value of property
293 * @return boolean condition
295 protected function checkCondition($field, $name='', $value = '')
297 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
303 $condition = ($blog && $this->ifCategory($name,$value));
306 $condition = ($blog && ($blog->getSetting($name) == $value));
309 $condition = $member->isLoggedIn();
312 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
315 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
318 $condition = ($itemidnext != '');
321 $condition = ($itemidprev != '');
323 case 'archiveprevexists':
324 $condition = ($archiveprevexists == true);
326 case 'archivenextexists':
327 $condition = ($archivenextexists == true);
330 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
333 $condition = $this->ifHasPlugin($name, $value);
336 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
343 * Actions::_ifHasPlugin()
345 * -> checks if plugin exists
346 * hasplugin,PlugName,OptionName
347 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
348 * hasplugin,PlugName,OptionName=value
349 * -> checks if the option OptionName from plugin PlugName is set to value
351 * @param string $name name of plugin
352 * @param string $value
355 private function ifHasPlugin($name, $value)
359 // (pluginInstalled method won't write a message in the actionlog on failure)
360 if ( $manager->pluginInstalled("NP_{$name}") )
362 $plugin =& $manager->getPlugin("NP_{$name}");
363 if ( $plugin != NULL )
371 list($name2, $value2) = preg_split('#=#', $value, 2);
372 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
376 else if ( $plugin->getOption($name2) == $value2 )
387 * Actions::ifPlugin()
388 * Checks if a plugin exists and call its doIf function
390 * @param string $name name of plugin
391 * @param string $key name of plugin option
392 * @param string $value value of plugin option
395 private function ifPlugin($name, $key = '', $value = '')
399 $plugin =& $manager->getPlugin("NP_{$name}");
405 $params = func_get_args();
406 array_shift($params);
408 return call_user_func_array(array(&$plugin, 'doIf'), $params);
412 * Actions::ifCategory()
413 * Different checks for a category
415 * @param string $name
416 * @param string $value
419 private function ifCategory($name = '', $value='')
421 global $blog, $catid;
423 // when no parameter is defined, just check if a category is selected
424 if ( ($name != 'catname' && $name != 'catid') || ($value == '') )
426 return $blog->isValidCategory($catid);
428 // check category name
429 else if ( $name == 'catname' )
431 $value = $blog->getCategoryIdFromName($value);
432 if ( $value == $catid )
434 return $blog->isValidCategory($catid);
438 else if ( ($name == 'catid') && ($value == $catid) )
440 return $blog->isValidCategory($catid);
446 * Actions::ifOnTeam()
447 * Checks if a member is on the team of a blog and return his rights
449 * @param string $blogName name of weblog
452 private function ifOnTeam($blogName = '')
454 global $blog, $member, $manager;
456 // when no blog found
457 if ( ($blogName == '') && !is_object($blog) )
462 // explicit blog selection
463 if ( $blogName != '' )
465 $blogid = getBlogIDFromName($blogName);
468 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
471 $blogid = $blog->getID();
474 return $member->teamRights($blogid);
479 * Checks if a member is admin of a blog
481 * @param string $blogName name of weblog
484 private function ifAdmin($blogName = '')
486 global $blog, $member, $manager;
488 // when no blog found
489 if ( ($blogName == '') && (!is_object($blog)) )
494 // explicit blog selection
495 if ( $blogName != '' )
497 $blogid = getBlogIDFromName($blogName);
500 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
503 $blogid = $blog->getID();
506 return $member->isBlogAdmin($blogid);
512 * - a raw link (html/xml encoded) when no linktext is provided
513 * - a (x)html <a href... link when a text is present (text htmlencoded)
515 * @param string $url URL for href attribute of anchor element
516 * @param string $linktext content of anchor element
519 private function link($url, $linktext = '')
521 $u = Entity::hsc($url);
522 // fix URLs that already had encoded ampersands
523 $u = preg_replace("#&amp;#", '&', $u);
524 if ( $linktext != '' )
526 $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';
536 * Actions::searchlink()
537 * Outputs a next/prev link
540 * The maximum amount of items shown per page (e.g. 10)
542 * Current start position (requestVar('startpos'))
544 * either 'prev' or 'next'
546 * When present, the output will be a full <a href...> link. When empty,
547 * only a raw link will be outputted
549 private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')
551 global $CONF, $blog, $query, $amount;
552 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
553 $startpos = (integer) $startpos;
554 $parsed = parse_url(serverVar('REQUEST_URI'));
555 $path = ( in_array('path', $parsed) ) ? $parsed['path'] : '';
556 $parsed = ( in_array('query', $parsed) ) ? $parsed['query'] : '';
559 if ( $direction == 'prev' )
561 if ( intval($startpos) - intval($maxresults) >= 0 )
563 $startpos = intval($startpos) - intval($maxresults);
565 if ( $this->skintype == 'index' )
569 else if ( $this->skintype == 'search' )
571 $url = $CONF['SearchURL'];
573 $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);
576 else if ( $direction == 'next' )
578 global $navigationItems;
579 if ( !isset($navigationItems) )
581 $navigationItems = 0;
590 $iAmountOnPage = $this->amountfound;
593 if ( intval($navigationItems) > 0 )
595 $iAmountOnPage = intval($navigationItems) - intval($startpos);
597 elseif ( $iAmountOnPage == 0 )
600 * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
603 if ( $this->skintype == 'index' )
605 $sqlquery = $blog->getSqlBlog('', 'count');
608 else if ( $this->skintype == 'search' )
610 $unused_highlight = '';
611 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
612 $url = $CONF['SearchURL'];
616 $iAmountOnPage = intval(DB::getValue($sqlquery)) - intval($startpos);
621 if ( intval($iAmountOnPage) >= intval($maxresults) )
623 $startpos = intval($startpos) + intval($maxresults);
624 $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos);
630 echo $this->link($url, $linktext);
636 * Actions::itemlink()
637 * Creates an item link and if no id is given a todaylink
639 * @param integer $id id for link
640 * @param string $linktext text for link
643 private function itemlink($id, $linktext = '')
648 echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);
652 $this->parse_todaylink($linktext);
658 * Actions::archivelink)
659 * Creates an archive link and if no id is given a todaylink
661 * @param integer $id id for link
662 * @param string $linktext text for link
665 private function archivelink($id, $linktext = '')
670 echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
674 $this->parse_todaylink($linktext);
680 * Actions:setBlogCategory()
681 * Helper function that sets the category that a blog will need to use
683 * @param string $blog An object of the blog class, passed by reference (we want to make changes to it)
684 * @param string $catname The name of the category to use
687 private function setBlogCategory(&$blog, $catname)
690 if ( $catname != '' )
692 $blog->setSelectedCategoryByName($catname);
696 $blog->setSelectedCategory($catid);
702 * Actions::preBlogContent()
703 * Notifies the Manager that a PreBlogContent event occurs
705 * @param string $type type of skin
706 * @param object $blog an instance of Blog class
709 private function preBlogContent($type, $blog)
712 $data = array('blog' => $blog, 'type' => $type);
713 $manager->notify('PreBlogContent', $data);
718 * Actions::postBlogContent()
719 * Notifies the Manager that a PostBlogContent event occurs
721 * @param string $type type of skin
722 * @param objecct $blog an instance of Blog class
725 private function postBlogContent($type, $blog)
728 $data = array('blog' => $blog, 'type' => $type);
729 $manager->notify('PostBlogContent', $data);
734 * Actions::parse_additemform()
735 * Parse skinvar additemform
740 public function parse_additemform()
743 $this->formdata = array(
744 'adminurl' => Entity::hsc($CONF['AdminURL']),
745 'catid' => $blog->getDefaultCategory()
747 $blog->InsertJavaScriptInfo();
748 $this->doForm('additemform');
753 * Actions::parse_addlink()
754 * Parse skinvar addlink
755 * A Link that allows to open a bookmarklet to add an item
757 public function parse_addlink()
759 global $CONF, $member, $blog;
760 if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )
762 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
768 * Actions::parse_addpopupcode()
769 * Parse skinvar addpopupcode
770 * Code that opens a bookmarklet in an popup window
775 public function parse_addpopupcode()
777 echo "if (event && 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;";
782 * Parse skinvar adminurl
783 * (shortcut for admin url)
788 public function parse_adminurl()
790 $this->parse_sitevar('adminurl');
795 * Actions::parse_archive()
796 * Parse skinvar archive
798 * @param string $template name of template
799 * @param string $category name of category
802 public function parse_archive($template, $category = '')
804 global $blog, $archive;
805 // can be used with either yyyy-mm or yyyy-mm-dd
806 sscanf($archive,'%d-%d-%d', $y, $m, $d);
807 $this->setBlogCategory($blog, $category);
808 $this->preBlogContent('achive',$blog);
809 $blog->showArchive($template, $y, $m, $d);
810 $this->postBlogContent('achive',$blog);
815 * Actions::parse_archivedate()
816 * %archivedate(locale,date format)%
818 * @param string $locale
821 public function parse_archivedate($locale = '-def-')
826 * TODO: these lines are no meaning because there is no $template.
827 if ( $locale == '-def-' )
829 setlocale(LC_TIME, $template['LOCALE']);
833 setlocale(LC_TIME, $locale);
838 sscanf($archive,'%d-%d-%d',$y,$m,$d);
841 $args = func_get_args();
842 // format can be spread over multiple parameters
843 if ( sizeof($args) > 1 )
848 $format=implode(',',$args);
850 elseif ( $d == 0 && $m !=0 )
860 $format = '%d %B %Y';
862 echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
867 * Actions::parse_archivedaylist()
868 * Parse skinvar archivedaylist
870 * @param string $template name of template
871 * @param string $category name of category
872 * @param integer $limit the number of items in a display
875 public function parse_archivedaylist($template, $category = 'all', $limit = 0)
878 if ( $category == 'all' )
882 $this->preBlogContent('archivelist',$blog);
883 $this->setBlogCategory($blog, $category);
884 $blog->showArchiveList($template, 'day', $limit);
885 $this->postBlogContent('archivelist',$blog);
890 * Actions::parse_archivelink()
891 * A link to the archives for the current blog (or for default blog)
893 * @param string $linktext text for link
896 public function parse_archivelink($linktext = '')
901 echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);
905 echo $this->link(Link::create_archivelist_link(), $linktext);
911 * Actions::parse_archivelist()
913 * @param string $template name of template
914 * @param string $category name of category
915 * @param integer $limit the number of items in a display
918 public function parse_archivelist($template, $category = 'all', $limit = 0)
921 if ( $category == 'all' )
925 $this->preBlogContent('archivelist',$blog);
926 $this->setBlogCategory($blog, $category);
927 $blog->showArchiveList($template, 'month', $limit);
928 $this->postBlogContent('archivelist',$blog);
933 * Actions::parse_archiveyearlist()
935 * @param string $template name of template
936 * @param string $category name of category
937 * @param integer $limit the number of items in a display
939 public function parse_archiveyearlist($template, $category = 'all', $limit = 0)
942 if ( $category == 'all' )
946 $this->preBlogContent('archivelist',$blog);
947 $this->setBlogCategory($blog, $category);
948 $blog->showArchiveList($template, 'year', $limit);
949 $this->postBlogContent('archivelist',$blog);
954 * Actions::parse_archivetype()
955 * Parse skinvar archivetype
960 public function parse_archivetype()
968 * Actions::parse_blog()
971 * @param string $template name of template
972 * @param mixed $amount the number of items in a display, in case it includes the beginning
973 * @param string $category name of category
976 public function parse_blog($template, $amount = 10, $category = '')
978 global $blog, $startpos;
979 list($limit, $offset) = sscanf($amount, '%d(%d)');
980 $this->setBlogCategory($blog, $category);
981 $this->preBlogContent('blog',$blog);
982 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
983 $this->parse_benchmark();
984 $this->postBlogContent('blog',$blog);
989 * Actions::parse_bloglist()
990 * Parse skinvar bloglist
991 * Shows a list of all blogs
993 * @param string $template name of template
994 * @param string $bnametype whether 'name' or 'shortname' is used for the link text
995 * @param string $orderby order criteria
996 * @param string $direction order ascending or descending
999 public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')
1001 Blog::showBlogList($template, $bnametype, $orderby, $direction);
1006 * Actions::parse_blogsetting()
1007 * Parse skinvar blogsetting
1009 * @param string $which key of weblog settings
1012 public function parse_blogsetting($which)
1018 echo Entity::hsc($blog->getID());
1021 echo Entity::hsc($blog->getURL());
1024 echo Entity::hsc($blog->getName());
1027 echo Entity::hsc($blog->getDescription());
1030 echo Entity::hsc($blog->getShortName());
1037 * Actions::parse_callback()
1040 * @param string $eventName name of event
1041 * @param string $type type of skin
1044 public function parse_callback($eventName, $type)
1047 $data = array('type' => $type);
1048 $manager->notify($eventName, $data);
1053 * Actions::parse_category()
1054 * Parse skinvar category
1056 * @param string $type key of category settings
1059 public function parse_category($type = 'name')
1061 global $catid, $blog;
1062 if ( !$blog->isValidCategory($catid) )
1070 echo $blog->getCategoryName($catid);
1073 echo $blog->getCategoryDesc($catid);
1083 * Actions::parse_categorylist()
1084 * Parse categorylist
1086 * @param string $template name of template
1087 * @param string $blogname name of weblog
1090 public function parse_categorylist($template, $blogname = '')
1092 global $blog, $manager;
1094 // when no blog found
1095 if ( ($blogname == '') && (!is_object($blog)) )
1100 if ( $blogname == '' )
1102 $this->preBlogContent('categorylist',$blog);
1103 $blog->showCategoryList($template);
1104 $this->postBlogContent('categorylist',$blog);
1108 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1109 $this->preBlogContent('categorylist',$b);
1110 $b->showCategoryList($template);
1111 $this->postBlogContent('categorylist',$b);
1117 * Actions::parse_commentform()
1118 * Parse skinvar commentform
1120 * @param string $destinationurl URI for redirection
1123 public function parse_commentform($destinationurl = '')
1125 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
1127 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
1128 if ( stristr($destinationurl, 'action.php') )
1130 $args = func_get_args();
1131 $destinationurl = $args[1];
1132 ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
1135 $actionurl = $CONF['ActionURL'];
1137 // if item is closed, show message and do nothing
1138 $item =& $manager->getItem($itemid,0,0);
1139 if ( $item['closed'] || !$blog->commentsEnabled() )
1141 $this->doForm('commentform-closed');
1145 if ( !$blog->isPublic() && !$member->isLoggedIn() )
1147 $this->doForm('commentform-closedtopublic');
1151 if ( !$destinationurl )
1153 // note: createLink returns an HTML encoded URL
1154 $destinationurl = Link::create_link(
1157 'itemid' => $itemid,
1158 'title' => $item['title'],
1159 'timestamp' => $item['timestamp'],
1160 'extra' => $this->linkparams
1167 $destinationurl = Entity::hsc($destinationurl);
1170 // values to prefill
1171 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
1174 $user = postVar('user');
1177 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
1180 $userid = postVar('userid');
1183 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
1186 $email = postVar('email');
1189 $body = postVar('body');
1191 $this->formdata = array(
1192 'destinationurl' => $destinationurl, // url is already HTML encoded
1193 'actionurl' => Entity::hsc($actionurl),
1194 'itemid' => $itemid,
1195 'user' => Entity::hsc($user),
1196 'userid' => Entity::hsc($userid),
1197 'email' => Entity::hsc($email),
1198 'body' => Entity::hsc($body),
1199 'membername' => $member->getDisplayName(),
1200 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
1203 if ( !$member->isLoggedIn() )
1205 $this->doForm('commentform-notloggedin');
1209 $this->doForm('commentform-loggedin');
1215 * Actions::parse_comments()
1216 * Parse skinvar comments
1217 * include comments for one item
1219 * @param string $template name of template
1222 public function parse_comments($template)
1224 global $manager, $blog, $highlight, $itemid;
1226 $template =& $manager->getTemplate($template);
1227 $item =& $manager->getitem($itemid, 0, 0);
1229 // create parser object & action handler
1230 $handler = new ItemActions($blog);
1231 $handler->setTemplate($template);
1232 $handler->setCurrentItem($item);
1234 $parser = new Parser($handler);
1236 $comments = new Comments($itemid);
1237 $comments->setItemActions($handler);
1238 // shows ALL comments
1239 $comments->showComments($template, -1, 1, $highlight);
1244 * Actions::parse_errordiv()
1250 public function parse_errordiv()
1252 global $errormessage;
1253 if ( $errormessage )
1255 echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";
1261 * Actions::parse_errormessage()
1262 * Parse skinvar errormessage
1267 public function parse_errormessage()
1269 global $errormessage;
1275 * Actions::parse_formdata()
1278 * @param string $what key of format data
1281 public function parse_formdata($what)
1283 echo $this->formdata[$what];
1288 * Actions::parse_ifcat()
1291 * @param string $text
1294 public function parse_ifcat($text = '')
1299 $this->parse_if('category');
1304 global $catid, $blog;
1305 if ( $blog->isValidCategory($catid) )
1314 * Actions::parse_image()
1315 * Parse skinvar image
1317 * @param string $what name of tag
1320 public function parse_image($what = 'imgtag')
1324 $imagetext = Entity::hsc(requestVar('imagetext'));
1325 $imagepopup = requestVar('imagepopup');
1326 $width = intRequestVar('width');
1327 $height = intRequestVar('height');
1328 $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup);
1347 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
1354 * Actions::parse_imagetext()
1355 * Parse skinvar imagetext
1360 public function parse_imagetext()
1362 $this->parse_image('imagetext');
1367 * Actions::parse_item()
1368 * Parse skinvar item
1369 * include one item (no comments)
1374 public function parse_item($template)
1376 global $blog, $itemid, $highlight;
1378 // need this to select default category
1379 $this->setBlogCategory($blog, '');
1380 $this->preBlogContent('item',$blog);
1381 $r = $blog->showOneitem($itemid, $template, $highlight);
1384 echo _ERROR_NOSUCHITEM;
1386 $this->postBlogContent('item',$blog);
1391 * Actions::parse_itemid()
1392 * Parse skinvar itemid
1397 public function parse_itemid()
1405 * Actions::parseitemlink()
1406 * Parse skinvar itemlink
1411 public function parse_itemlink($linktext = '')
1414 $this->itemlink($itemid, $linktext);
1419 * Actions::parse_itemtitle()
1425 public function parse_itemtitle($format = '')
1427 global $manager, $itemid;
1428 $item =& $manager->getItem($itemid, 1, 1);
1433 echo Entity::hen($item['title']);
1436 echo $item['title'];
1440 echo Entity::hsc(strip_tags($item['title']));
1447 * Actions::parse_loginform()
1448 * Parse skinvar loginform
1453 public function parse_loginform()
1455 global $member, $CONF;
1456 if ( !$member->isLoggedIn() )
1458 $filename = 'loginform-notloggedin';
1459 $this->formdata = array();
1463 $filename = 'loginform-loggedin';
1464 $this->formdata = array(
1465 'membername' => $member->getDisplayName(),
1468 $this->doForm($filename);
1473 * Actions::parse_member()
1474 * Parse skinvar member
1475 * (includes a member info thingie)
1477 * @param string $what which memberdata is needed
1480 public function parse_member($what)
1482 global $memberinfo, $member, $CONF;
1484 // 1. only allow the member-details-page specific variables on member pages
1485 if ( $this->skintype == 'member' )
1490 echo Entity::hsc($memberinfo->getDisplayName());
1493 echo Entity::hsc($memberinfo->getRealName());
1496 echo Entity::hsc($memberinfo->getNotes());
1499 echo Entity::hsc($memberinfo->getURL());
1502 echo Entity::hsc($memberinfo->getEmail());
1505 echo Entity::hsc($memberinfo->getID());
1510 // 2. the next bunch of options is available everywhere, as long as the user is logged in
1511 if ( $member->isLoggedIn() )
1516 echo $member->getDisplayName();
1518 case 'yourrealname':
1519 echo $member->getRealName();
1522 echo $member->getNotes();
1525 echo $member->getURL();
1528 echo $member->getEmail();
1531 echo $member->getID();
1533 case 'yourprofileurl':
1534 if ($CONF['URLMode'] == 'pathinfo')
1535 echo Link::create_member_link($member->getID());
1537 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
1545 * Link::parse_membermailform()
1546 * Parse skinvar membermailform
1548 * @param integer $rows the height for textarea
1549 * @param integer $cols the width for textarea
1550 * @param string $desturl URI to redirect
1553 public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
1555 global $member, $CONF, $memberid;
1557 if ( $desturl == '' )
1559 if ( $CONF['URLMode'] == 'pathinfo' )
1561 $desturl = Link::create_member_link($memberid);
1565 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
1569 $message = postVar('message');
1570 $frommail = postVar('frommail');
1572 $this->formdata = array(
1573 'url' => Entity::hsc($desturl),
1574 'actionurl' => Entity::hsc($CONF['ActionURL']),
1575 'memberid' => $memberid,
1578 'message' => Entity::hsc($message),
1579 'frommail' => Entity::hsc($frommail)
1582 if ( $member->isLoggedIn() )
1584 $this->doForm('membermailform-loggedin');
1586 else if ( $CONF['NonmemberMail'] )
1588 $this->doForm('membermailform-notloggedin');
1592 $this->doForm('membermailform-disallowed');
1598 * Actions::parse_nextarchive()
1599 * Parse skinvar nextarchive
1604 public function parse_nextarchive()
1606 global $archivenext;
1612 * Parse skinvar nextitem
1613 * (include itemid of next item)
1618 public function parse_nextitem()
1621 if ( isset($itemidnext) )
1623 echo (int)$itemidnext;
1629 * Actions::parse_nextitemtitle()
1630 * Parse skinvar nextitemtitle
1631 * (include itemtitle of next item)
1633 * @param string $format format of text
1636 public function parse_nextitemtitle($format = '')
1638 global $itemtitlenext;
1643 echo Entity::hen($itemtitlenext);
1646 echo $itemtitlenext;
1650 echo Entity::hsc($itemtitlenext);
1657 * Actions::parse_nextlink()
1658 * Parse skinvar nextlink
1660 * @param string $linktext text for content of anchor element
1661 * @param integer $amount the amount of items in a display
1662 * @param integer $recount increment from this value
1665 public function parse_nextlink($linktext = '', $amount = 10, $recount = '')
1667 global $itemidnext, $archivenext, $startpos;
1668 if ( $this->skintype == 'item' )
1670 $this->itemlink($itemidnext, $linktext);
1672 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
1674 $this->searchlink($amount, $startpos, 'next', $linktext, $recount);
1678 $this->archivelink($archivenext, $linktext);
1684 * Actions::parse_nucleusbutton()
1685 * Parse skinvar nucleusbutton
1687 * @param string $imgurl URL for image
1688 * @param integer $imgwidth width of image
1689 * @param integer $imgheidht height of image
1691 public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')
1694 if ( $imgurl == '' )
1696 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
1698 else if ( Parser::getProperty('IncludeMode') == 'skindir' )
1700 // when skindit IncludeMode is used: start from skindir
1701 $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
1704 $this->formdata = array(
1705 'imgurl' => $imgurl,
1706 'imgwidth' => $imgwidth,
1707 'imgheight' => $imgheight,
1709 $this->doForm('nucleusbutton');
1714 * Actions::parse_otherarchive()
1715 * Parse skinvar otherarchive
1717 * @param string $blogname name of weblog
1718 * @param string $template name of template
1719 * @param string $category name of category
1722 public function parse_otherarchive($blogname, $template, $category = '')
1724 global $archive, $manager;
1725 sscanf($archive,'%d-%d-%d',$y,$m,$d);
1726 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1727 $this->setBlogCategory($b, $category);
1728 $this->preBlogContent('otherachive',$b);
1729 $b->showArchive($template, $y, $m, $d);
1730 $this->postBlogContent('otherachive',$b);
1735 * Actions::parse_otherarchivedaylist()
1736 * Parse skinvar otherarchivedaylist
1738 * @param string $blogname name of weblog
1739 * @param string $template name of template
1740 * @param string $category name of category
1741 * @param integer $limit the amount of items in a display
1744 public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)
1747 if ( $category == 'all')
1751 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1752 $this->setBlogCategory($b, $category);
1753 $this->preBlogContent('otherarchivelist',$b);
1754 $b->showArchiveList($template, 'day', $limit);
1755 $this->postBlogContent('otherarchivelist',$b);
1760 * Actions::parse_otherarchivelist()
1761 * Parse skinvar otherarchivelist
1763 * @param string $blogname name of weblog
1764 * @param string $template name of template
1765 * @param string $category name of category
1766 * @param integer $limit the amount of items in a display
1769 public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)
1772 if ( $category == 'all' )
1776 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1777 $this->setBlogCategory($b, $category);
1778 $this->preBlogContent('otherarchivelist',$b);
1779 $b->showArchiveList($template, 'month', $limit);
1780 $this->postBlogContent('otherarchivelist',$b);
1785 * Actions::parse_otherarchiveyearlist()
1786 * Parse skinvar otherarchiveyearlist
1788 * @param string $blogname name of weblog
1789 * @param string $template name of template
1790 * @param string $category name of category
1791 * @limit integer $limit the amount of items in a display
1793 public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)
1796 if ( $category == 'all' )
1800 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1801 $this->setBlogCategory($b, $category);
1802 $this->preBlogContent('otherarchivelist',$b);
1803 $b->showArchiveList($template, 'year', $limit);
1804 $this->postBlogContent('otherarchivelist',$b);
1809 * Actions::parse_otherblog()
1810 * Parse skinvar otherblog
1812 * @param string $blogname name of weblog
1813 * @param string $template name of template
1814 * @param mixed $amount the amount of items, in case it includes the beginning
1815 * @param string $category name of category
1818 public function parse_otherblog($blogname, $template, $amount = 10, $category = '')
1822 list($limit, $offset) = sscanf($amount, '%d(%d)');
1824 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1825 $this->setBlogCategory($b, $category);
1826 $this->preBlogContent('otherblog',$b);
1827 $this->amountfound = $b->readLog($template, $limit, $offset);
1828 $this->postBlogContent('otherblog',$b);
1833 * Actions::parse_othersearchresults()
1834 * Parse skinvar othersearchresults
1836 * @param string $blogname name of weblog
1837 * @param string $template name of template
1838 * @param integer $maxresults the amount of results
1841 public function parse_othersearchresults($blogname, $template, $maxresults = 50)
1843 global $query, $amount, $manager, $startpos;
1844 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1845 // need this to select default category
1846 $this->setBlogCategory($b, '');
1847 $this->preBlogContent('othersearchresults',$b);
1848 $b->search($query, $template, $amount, $maxresults, $startpos);
1849 $this->postBlogContent('othersearchresults',$b);
1854 * Actions::parse_plugin()
1855 * Executes a plugin skinvar
1856 * extra parameters can be added
1858 * @param string $pluginName name of plugin (without the NP_)
1861 public function parse_plugin($pluginName)
1865 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1872 $params = func_get_args();
1874 // remove plugin name
1875 array_shift($params);
1877 // add skin type on front
1878 array_unshift($params, $this->skintype);
1880 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1885 * Actions::parse_prevarchive()
1886 * Parse skinvar prevarchive
1891 public function parse_prevarchive()
1893 global $archiveprev;
1898 * Actions::parse_preview()
1899 * Parse skinvar preview
1901 * @param string $template name of tempalte
1904 public function parse_preview($template)
1906 global $blog, $CONF, $manager;
1908 $template =& $manager->getTemplate($template);
1910 $row['body'] = '<span id="prevbody"></span>';
1911 $row['title'] = '<span id="prevtitle"></span>';
1912 $row['more'] = '<span id="prevmore"></span>';
1913 $row['itemlink'] = '';
1914 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1916 echo Template::fill($template['ITEM_HEADER'],$row);
1917 echo Template::fill($template['ITEM'],$row);
1918 echo Template::fill($template['ITEM_FOOTER'],$row);
1923 * Actions::parse_previtem()
1924 * Parse skinvar previtem
1925 * (include itemid of prev item)
1930 public function parse_previtem()
1933 if ( isset($itemidprev) )
1935 echo (integer) $itemidprev;
1941 * Actions::parse_previtemtitle()
1942 * Parse skinvar previtemtitle
1943 * (include itemtitle of prev item)
1945 * @param String $format string format
1946 * @return String formatted string
1948 public function parse_previtemtitle($format = '')
1950 global $itemtitleprev;
1955 echo Entity::hen($itemtitleprev);
1958 echo $itemtitleprev;
1962 echo Entity::hsc($itemtitleprev);
1969 * Actions::parse_prevlink()
1970 * Parse skinvar prevlink
1972 * @param string $linktext text as a content of anchor element
1973 * @param integer the amount of links
1976 public function parse_prevlink($linktext = '', $amount = 10)
1978 global $itemidprev, $archiveprev, $startpos;
1980 if ( $this->skintype == 'item' )
1982 $this->itemlink($itemidprev, $linktext);
1984 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
1986 $this->searchlink($amount, $startpos, 'prev', $linktext);
1990 $this->archivelink($archiveprev, $linktext);
1996 * Actions::parse_query()
1997 * Parse skinvar query
1998 * (includes the search query)
2003 public function parse_query()
2006 echo Entity::hsc($query);
2011 * Actions::parse_referer()
2012 * Parse skinvar referer
2017 public function parse_referer()
2019 echo Entity::hsc(serverVar('HTTP_REFERER'));
2024 * Actions::parse_searchform()
2025 * Parse skinvar searchform
2027 * @param string $blogname name of weblog
2030 public function parse_searchform($blogname = '')
2032 global $CONF, $manager, $maxresults;
2035 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
2041 // use default blog when no blog is selected
2042 $this->formdata = array(
2043 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
2044 'query' => Entity::hsc(getVar('query')),
2046 $this->doForm('searchform');
2051 * Actions::parse_searchresults()
2052 * Parse skinvar searchresults
2054 * @param string $template name of tempalte
2055 * @param integer $maxresults searched items in a display
2058 public function parse_searchresults($template, $maxresults = 50 )
2060 global $blog, $query, $amount, $startpos;
2062 $this->setBlogCategory($blog, ''); // need this to select default category
2063 $this->preBlogContent('searchresults',$blog);
2064 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
2065 $this->postBlogContent('searchresults',$blog);
2070 * Actions::parse_self()
2071 * Parse skinvar self
2076 public function parse_self()
2084 * Actions::parse_sitevar()
2085 * Parse skinvar sitevar
2086 * (include a sitevar)
2088 * @param string $which
2091 public function parse_sitevar($which)
2097 echo $CONF['IndexURL'];
2100 echo $CONF['SiteName'];
2103 echo $CONF['AdminEmail'];
2106 echo $CONF['AdminURL'];
2112 * Actions::parse_skinname()
2118 public function parse_skinname()
2120 echo $this->parser->skin->getName();
2125 * Actions::parse_skintype()
2126 * Parse skintype (experimental)
2131 public function parse_skintype()
2133 echo $this->skintype;
2138 * Actions::parse_ticket()
2144 public function parse_ticket()
2147 $manager->addTicketHidden();
2152 * Actions::parse_todaylink()
2153 * Parse skinvar todaylink
2154 * A link to the today page (depending on selected blog, etc...)
2156 * @param string $linktext text for link
2159 public function parse_todaylink($linktext = '')
2161 global $blog, $CONF;
2164 echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
2168 echo $this->link($CONF['SiteUrl'], $linktext);
2175 * When commentform is not used, to include a hidden field with itemid
2180 public function parse_vars()
2183 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";
2188 * Actions::parse_version()
2189 * Parse skinvar version
2190 * (include nucleus versionnumber)
2195 public function parse_version()
2198 echo 'Nucleus CMS ' . $nucleus['version'];
2203 * Actions::parse_sticky()
2204 * Parse skinvar sticky
2206 * @param integer $itemnumber id of item
2207 * @param string $template name of template
2210 public function parse_sticky($itemid = 0, $template = '')
2214 $itemid = (integer) $itemid;
2215 $itemarray = array($itemid);
2217 $item =& $manager->getItem($post['itemid'], 1, 1);
2218 $blog =& $manager->getBlog($item['blogid']);
2220 $this->preBlogContent('sticky', $blog);
2221 $this->amountfound = $blog->readLogFromList($itemarray, $template);
2222 $this->postBlogContent('sticky', $blog);