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 * The allowed tags for a type of skinpart are defined by the
17 * Skin::getAllowedActionsForType($type) method
19 * @license http://nucleuscms.org/license.txt GNU General Public License
20 * @copyright Copyright (C) 2002-2012 The Nucleus Group
21 * @version $Id: ACTIONS.php 1784 2012-04-22 04:28:30Z sakamocchi $
24 class Actions extends BaseActions
26 // part of the skin currently being parsed ('index', 'item', 'archive',
27 // 'archivelist', 'member', 'search', 'error', 'imagepopup')
30 // contains an assoc array with parameters that need to be included when
31 // generating links to items/archives/... (e.g. catid)
34 // reference to the skin object for which a part is being parsed
37 // used when including templated forms from the include/ dir. The $formdata var
38 // contains the values to fill out in there (assoc array name -> value)
41 // filled out with the number of displayed items after calling one of the
42 // (other)blog/(other)searchresults skinvars.
46 * Actions::$default_actions
47 * list of whole action names with which this class can deal
49 static private $default_actions = array(
60 'otherarchivedaylist',
62 'otherarchiveyearlist',
73 // deprecated (Nucleus v2.0)
74 /* TODO: remove this */
79 * Actions::$skin_type_friendly_names
80 * friendly name for wrapped page types
82 static public $default_skin_types = array(
83 'index' => _SKIN_PART_MAIN,
84 'item' => _SKIN_PART_ITEM,
85 'archivelist' => _SKIN_PART_ALIST,
86 'archive' => _SKIN_PART_ARCHIVE,
87 'search' => _SKIN_PART_SEARCH,
88 'error' => _SKIN_PART_ERROR,
89 'member' => _SKIN_PART_MEMBER,
90 'imagepopup' => _SKIN_PART_POPUP
94 * Actions::getDefinedActions()
97 * @param string $type page type
98 * @return array allowed actions for the page type
100 static public function getDefinedActions($type='')
102 $extra_actions = array();
107 $extra_actions = array(
121 $extra_actions = array(
139 $extra_actions = array(
149 $extra_actions = array(
156 'othersearchresults',
164 $extra_actions = array(
166 // deprecated (Nucleus v2.0)
167 /* TODO: remove this */
172 $extra_actions = array(
180 $extra_actions = array(
203 $extra_actions = array(
209 $extra_actions = array(
227 $defined_actions = array_merge(self::$default_actions, $extra_actions);
229 return array_merge($defined_actions, parent::getDefinedActions());
233 * Actions::getDefaultSkinTypes()
237 * @return array list of friendly names for page actions
239 static public function getDefaultSkinTypes()
241 return self::$default_skin_types;
245 * Actions::__construct()
246 * Constructor for a new Actions object
248 * @param string $type
251 public function __construct($type)
255 // call constructor of superclass first
256 parent::__construct();
257 $this->skintype = $type;
261 $this->linkparams = array('catid' => $catid);
269 * @param object $skin an instance of Skin class
272 public function setSkin(&$skin)
274 $this->skin =& $skin;
279 * Actions::setParser()
282 * @param object $parser an instance of Parser class
285 public function setParser(&$parser)
287 $this->parser =& $parser;
293 * Forms get parsedincluded now, using an extra <formdata> skinvar
295 * @param string $filename
298 public function doForm($filename)
301 array_push($this->parser->actions,'formdata', 'callback','errordiv','ticket');
303 $oldIncludeMode = Parser::getProperty('IncludeMode');
304 $oldIncludePrefix = Parser::getProperty('IncludePrefix');
305 Parser::setProperty('IncludeMode','normal');
306 Parser::setProperty('IncludePrefix','');
308 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
309 Parser::setProperty('IncludeMode',$oldIncludeMode);
310 Parser::setProperty('IncludePrefix',$oldIncludePrefix);
312 array_pop($this->parser->actions); // errordiv
313 array_pop($this->parser->actions); // callback
314 array_pop($this->parser->actions); // formdata
315 array_pop($this->parser->actions); // ticket
320 * Actions::checkCondition()
321 * Checks conditions for if statements
323 * @param string $field type of <%if%>
324 * @param string $name property of field
325 * @param string $value value of property
326 * @return boolean condition
328 protected function checkCondition($field, $name='', $value = '')
330 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
336 $condition = ($blog && $this->ifCategory($name,$value));
339 $condition = ($blog && ($blog->getSetting($name) == $value));
342 $condition = $member->isLoggedIn();
345 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
348 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
351 $condition = ($itemidnext != '');
354 $condition = ($itemidprev != '');
356 case 'archiveprevexists':
357 $condition = ($archiveprevexists == true);
359 case 'archivenextexists':
360 $condition = ($archivenextexists == true);
363 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
366 $condition = $this->ifHasPlugin($name, $value);
369 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
376 * Actions::_ifHasPlugin()
378 * -> checks if plugin exists
379 * hasplugin,PlugName,OptionName
380 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
381 * hasplugin,PlugName,OptionName=value
382 * -> checks if the option OptionName from plugin PlugName is set to value
384 * @param string $name name of plugin
385 * @param string $value
388 private function ifHasPlugin($name, $value)
392 // (pluginInstalled method won't write a message in the actionlog on failure)
393 if ( $manager->pluginInstalled("NP_{$name}") )
395 $plugin =& $manager->getPlugin("NP_{$name}");
396 if ( $plugin != NULL )
404 list($name2, $value2) = preg_split('#=#', $value, 2);
405 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
409 else if ( $plugin->getOption($name2) == $value2 )
420 * Actions::ifPlugin()
421 * Checks if a plugin exists and call its doIf function
423 * @param string $name name of plugin
424 * @param string $key name of plugin option
425 * @param string $value value of plugin option
428 private function ifPlugin($name, $key = '', $value = '')
432 $plugin =& $manager->getPlugin("NP_{$name}");
438 $params = func_get_args();
439 array_shift($params);
441 return call_user_func_array(array(&$plugin, 'doIf'), $params);
445 * Actions::ifCategory()
446 * Different checks for a category
448 * @param string $name
449 * @param string $value
452 private function ifCategory($name = '', $value='')
454 global $blog, $catid;
456 // when no parameter is defined, just check if a category is selected
457 if ( ($name != 'catname' && $name != 'catid') || ($value == '') )
459 return $blog->isValidCategory($catid);
462 // check category name
463 if ( $name == 'catname' )
465 $value = $blog->getCategoryIdFromName($value);
466 if ( $value == $catid )
468 return $blog->isValidCategory($catid);
473 if ( ($name == 'catid') && ($value == $catid) )
475 return $blog->isValidCategory($catid);
481 * Actions::ifOnTeam()
482 * Checks if a member is on the team of a blog and return his rights
484 * @param string $blogName name of weblog
487 private function ifOnTeam($blogName = '')
489 global $blog, $member, $manager;
491 // when no blog found
492 if ( ($blogName == '') && !is_object($blog) )
497 // explicit blog selection
498 if ( $blogName != '' )
500 $blogid = getBlogIDFromName($blogName);
503 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
506 $blogid = $blog->getID();
509 return $member->teamRights($blogid);
514 * Checks if a member is admin of a blog
516 * @param string $blogName name of weblog
519 private function ifAdmin($blogName = '')
521 global $blog, $member, $manager;
523 // when no blog found
524 if ( ($blogName == '') && (!is_object($blog)) )
529 // explicit blog selection
530 if ( $blogName != '' )
532 $blogid = getBlogIDFromName($blogName);
535 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
538 $blogid = $blog->getID();
541 return $member->isBlogAdmin($blogid);
547 * - a raw link (html/xml encoded) when no linktext is provided
548 * - a (x)html <a href... link when a text is present (text htmlencoded)
550 * @param string $url URL for href attribute of anchor element
551 * @param string $linktext content of anchor element
554 private function link($url, $linktext = '')
556 $u = Entity::hsc($url);
557 // fix URLs that already had encoded ampersands
558 $u = preg_replace("#&amp;#", '&', $u);
559 if ( $linktext != '' )
561 $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';
571 * Actions::searchlink()
572 * Outputs a next/prev link
575 * The maximum amount of items shown per page (e.g. 10)
577 * Current start position (requestVar('startpos'))
579 * either 'prev' or 'next'
581 * When present, the output will be a full <a href...> link. When empty,
582 * only a raw link will be outputted
584 private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')
586 global $CONF, $blog, $query, $amount;
587 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
588 $startpos = (integer) $startpos;
589 $parsed = parse_url(serverVar('REQUEST_URI'));
590 $path = $parsed['path'];
591 $parsed = $parsed['query'];
594 if ( $direction == 'prev' )
596 if ( intval($startpos) - intval($maxresults) >= 0 )
598 $startpos = intval($startpos) - intval($maxresults);
600 if ( $this->skintype == 'index' )
604 else if ( $this->skintype == 'search' )
606 $url = $CONF['SearchURL'];
608 $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);
611 else if ( $direction == 'next' )
613 global $navigationItems;
614 if ( !isset($navigationItems) )
616 $navigationItems = 0;
625 $iAmountOnPage = $this->amountfound;
628 if ( intval($navigationItems) > 0 )
630 $iAmountOnPage = intval($navigationItems) - intval($startpos);
632 elseif ( $iAmountOnPage == 0 )
635 * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
638 if ( $this->skintype == 'index' )
640 $sqlquery = $blog->getSqlBlog('', 'count');
643 else if ( $this->skintype == 'search' )
645 $unused_highlight = '';
646 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
647 $url = $CONF['SearchURL'];
651 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
656 if ( intval($iAmountOnPage) >= intval($maxresults) )
658 $startpos = intval($startpos) + intval($maxresults);
659 $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos);
665 echo $this->link($url, $linktext);
671 * Actions::itemlink()
672 * Creates an item link and if no id is given a todaylink
674 * @param integer $id id for link
675 * @param string $linktext text for link
678 private function itemlink($id, $linktext = '')
683 echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);
687 $this->parse_todaylink($linktext);
693 * Actions::archivelink)
694 * Creates an archive link and if no id is given a todaylink
696 * @param integer $id id for link
697 * @param string $linktext text for link
700 private function archivelink($id, $linktext = '')
705 echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
709 $this->parse_todaylink($linktext);
715 * Actions:setBlogCategory()
716 * Helper function that sets the category that a blog will need to use
718 * @param string $blog An object of the blog class, passed by reference (we want to make changes to it)
719 * @param string $catname The name of the category to use
722 private function setBlogCategory(&$blog, $catname)
725 if ( $catname != '' )
727 $blog->setSelectedCategoryByName($catname);
731 $blog->setSelectedCategory($catid);
737 * Actions::preBlogContent()
738 * Notifies the Manager that a PreBlogContent event occurs
740 * @param string $type type of skin
741 * @param object $blog an instance of Blog class
744 private function preBlogContent($type, &$blog)
747 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
752 * Actions::postBlogContent()
753 * Notifies the Manager that a PostBlogContent event occurs
755 * @param string $type type of skin
756 * @param objecct $blog an instance of Blog class
759 private function postBlogContent($type, &$blog)
762 $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));
767 * Actions::parse_additemform()
768 * Parse skinvar additemform
773 public function parse_additemform()
776 $this->formdata = array(
777 'adminurl' => Entity::hsc($CONF['AdminURL']),
778 'catid' => $blog->getDefaultCategory()
780 $blog->InsertJavaScriptInfo();
781 $this->doForm('additemform');
786 * Actions::parse_addlink()
787 * Parse skinvar addlink
788 * A Link that allows to open a bookmarklet to add an item
790 public function parse_addlink()
792 global $CONF, $member, $blog;
793 if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )
795 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
801 * Actions::parse_addpopupcode()
802 * Parse skinvar addpopupcode
803 * Code that opens a bookmarklet in an popup window
808 public function parse_addpopupcode()
810 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;";
815 * Parse skinvar adminurl
816 * (shortcut for admin url)
821 public function parse_adminurl()
823 $this->parse_sitevar('adminurl');
828 * Actions::parse_archive()
829 * Parse skinvar archive
831 * @param string $template name of template
832 * @param string $category name of category
835 public function parse_archive($template, $category = '')
837 global $blog, $archive;
838 // can be used with either yyyy-mm or yyyy-mm-dd
839 sscanf($archive,'%d-%d-%d', $y, $m, $d);
840 $this->setBlogCategory($blog, $category);
841 $this->preBlogContent('achive',$blog);
842 $blog->showArchive($template, $y, $m, $d);
843 $this->postBlogContent('achive',$blog);
848 * Actions::parse_archivedate()
849 * %archivedate(locale,date format)%
851 * @param string $locale
854 public function parse_archivedate($locale = '-def-')
859 * TODO: these lines are no meaning because there is no $template.
860 if ( $locale == '-def-' )
862 setlocale(LC_TIME, $template['LOCALE']);
866 setlocale(LC_TIME, $locale);
871 sscanf($archive,'%d-%d-%d',$y,$m,$d);
874 $args = func_get_args();
875 // format can be spread over multiple parameters
876 if ( sizeof($args) > 1 )
881 $format=implode(',',$args);
883 elseif ( $d == 0 && $m !=0 )
893 $format = '%d %B %Y';
895 echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
900 * Actions::parse_archivedaylist()
901 * Parse skinvar archivedaylist
903 * @param string $template name of template
904 * @param string $category name of category
905 * @param integer $limit the number of items in a display
908 public function parse_archivedaylist($template, $category = 'all', $limit = 0)
911 if ( $category == 'all' )
915 $this->preBlogContent('archivelist',$blog);
916 $this->setBlogCategory($blog, $category);
917 $blog->showArchiveList($template, 'day', $limit);
918 $this->postBlogContent('archivelist',$blog);
923 * Actions::parse_archivelink()
924 * A link to the archives for the current blog (or for default blog)
926 * @param string $linktext text for link
929 public function parse_archivelink($linktext = '')
934 echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);
938 echo $this->link(Link::create_archivelist_link(), $linktext);
944 * Actions::parse_archivelist()
946 * @param string $template name of template
947 * @param string $category name of category
948 * @param integer $limit the number of items in a display
951 public function parse_archivelist($template, $category = 'all', $limit = 0)
954 if ( $category == 'all' )
958 $this->preBlogContent('archivelist',$blog);
959 $this->setBlogCategory($blog, $category);
960 $blog->showArchiveList($template, 'month', $limit);
961 $this->postBlogContent('archivelist',$blog);
966 * Actions::parse_archiveyearlist()
968 * @param string $template name of template
969 * @param string $category name of category
970 * @param integer $limit the number of items in a display
972 public function parse_archiveyearlist($template, $category = 'all', $limit = 0)
975 if ( $category == 'all' )
979 $this->preBlogContent('archivelist',$blog);
980 $this->setBlogCategory($blog, $category);
981 $blog->showArchiveList($template, 'year', $limit);
982 $this->postBlogContent('archivelist',$blog);
987 * Actions::parse_archivetype()
988 * Parse skinvar archivetype
993 public function parse_archivetype()
1001 * Actions::parse_blog()
1002 * Parse skinvar blog
1004 * @param string $template name of template
1005 * @param mixed $amount the number of items in a display, in case it includes the beginning
1006 * @param string $category name of category
1009 public function parse_blog($template, $amount = 10, $category = '')
1011 global $blog, $startpos;
1013 list($limit, $offset) = sscanf($amount, '%d(%d)');
1014 $this->setBlogCategory($blog, $category);
1015 $this->preBlogContent('blog',$blog);
1016 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
1017 $this->postBlogContent('blog',$blog);
1022 * Actions::parse_bloglist()
1023 * Parse skinvar bloglist
1024 * Shows a list of all blogs
1026 * @param string $template name of template
1027 * @param string $bnametype whether 'name' or 'shortname' is used for the link text
1028 * @param string $orderby order criteria
1029 * @param string $direction order ascending or descending
1032 public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')
1034 Blog::showBlogList($template, $bnametype, $orderby, $direction);
1039 * Actions::parse_blogsetting()
1040 * Parse skinvar blogsetting
1042 * @param string $which key of weblog settings
1045 public function parse_blogsetting($which)
1051 echo Entity::hsc($blog->getID());
1054 echo Entity::hsc($blog->getURL());
1057 echo Entity::hsc($blog->getName());
1060 echo Entity::hsc($blog->getDescription());
1063 echo Entity::hsc($blog->getShortName());
1070 * Actions::parse_callback()
1073 * @param string $eventName name of event
1074 * @param string $type type of skin
1077 public function parse_callback($eventName, $type)
1080 $manager->notify($eventName, array('type' => $type));
1085 * Actions::parse_category()
1086 * Parse skinvar category
1088 * @param string $type key of category settings
1091 public function parse_category($type = 'name')
1093 global $catid, $blog;
1094 if ( !$blog->isValidCategory($catid) )
1102 echo $blog->getCategoryName($catid);
1105 echo $blog->getCategoryDesc($catid);
1115 * Actions::parse_categorylist()
1116 * Parse categorylist
1118 * @param string $template name of template
1119 * @param string $blogname name of weblog
1122 public function parse_categorylist($template, $blogname = '')
1124 global $blog, $manager;
1126 // when no blog found
1127 if ( ($blogname == '') && (!is_object($blog)) )
1132 if ( $blogname == '' )
1134 $this->preBlogContent('categorylist',$blog);
1135 $blog->showCategoryList($template);
1136 $this->postBlogContent('categorylist',$blog);
1140 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1141 $this->preBlogContent('categorylist',$b);
1142 $b->showCategoryList($template);
1143 $this->postBlogContent('categorylist',$b);
1149 * Actions::parse_charset()
1150 * Parse skinvar charset
1155 public function parse_charset()
1157 echo i18n::get_current_charset();
1162 * Actions::parse_commentform()
1163 * Parse skinvar commentform
1165 * @param string $destinationurl URI for redirection
1168 public function parse_commentform($destinationurl = '')
1170 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
1172 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
1173 if ( stristr($destinationurl, 'action.php') )
1175 $args = func_get_args();
1176 $destinationurl = $args[1];
1177 ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
1180 $actionurl = $CONF['ActionURL'];
1182 // if item is closed, show message and do nothing
1183 $item =& $manager->getItem($itemid,0,0);
1184 if ( $item['closed'] || !$blog->commentsEnabled() )
1186 $this->doForm('commentform-closed');
1190 if ( !$blog->isPublic() && !$member->isLoggedIn() )
1192 $this->doForm('commentform-closedtopublic');
1196 if ( !$destinationurl )
1198 // note: createLink returns an HTML encoded URL
1199 $destinationurl = Link::create_link(
1202 'itemid' => $itemid,
1203 'title' => $item['title'],
1204 'timestamp' => $item['timestamp'],
1205 'extra' => $this->linkparams
1212 $destinationurl = Entity::hsc($destinationurl);
1215 // values to prefill
1216 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
1219 $user = postVar('user');
1222 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
1225 $userid = postVar('userid');
1228 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
1231 $email = postVar('email');
1234 $body = postVar('body');
1236 $this->formdata = array(
1237 'destinationurl' => $destinationurl, // url is already HTML encoded
1238 'actionurl' => Entity::hsc($actionurl),
1239 'itemid' => $itemid,
1240 'user' => Entity::hsc($user),
1241 'userid' => Entity::hsc($userid),
1242 'email' => Entity::hsc($email),
1243 'body' => Entity::hsc($body),
1244 'membername' => $member->getDisplayName(),
1245 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
1248 if ( !$member->isLoggedIn() )
1250 $this->doForm('commentform-notloggedin');
1254 $this->doForm('commentform-loggedin');
1260 * Actions::parse_comments()
1261 * Parse skinvar comments
1262 * include comments for one item
1264 * @param string $template name of template
1267 public function parse_comments($template)
1269 global $itemid, $manager, $blog, $highlight;
1270 $template =& $manager->getTemplate($template);
1272 // create parser object & action handler
1273 $actions = new ItemActions($blog);
1274 $parser = new Parser($actions->getDefinedActions(),$actions);
1275 $actions->setTemplate($template);
1276 $actions->setParser($parser);
1277 $item = Item::getitem($itemid, 0, 0);
1278 $actions->setCurrentItem($item);
1280 $comments = new Comments($itemid);
1281 $comments->setItemActions($actions);
1282 // shows ALL comments
1283 $comments->showComments($template, -1, 1, $highlight);
1288 * Actions::parse_errordiv()
1294 public function parse_errordiv()
1296 global $errormessage;
1297 if ( $errormessage )
1299 echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";
1305 * Actions::parse_errormessage()
1306 * Parse skinvar errormessage
1311 public function parse_errormessage()
1313 global $errormessage;
1319 * Actions::parse_formdata()
1322 * @param string $what key of format data
1325 public function parse_formdata($what)
1327 echo $this->formdata[$what];
1332 * Actions::parse_ifcat()
1335 * @param string $text
1338 public function parse_ifcat($text = '')
1343 $this->parse_if('category');
1348 global $catid, $blog;
1349 if ( $blog->isValidCategory($catid) )
1358 * Actions::parse_image()
1359 * Parse skinvar image
1361 * @param string $what name of tag
1364 public function parse_image($what = 'imgtag')
1368 $imagetext = Entity::hsc(requestVar('imagetext'));
1369 $imagepopup = requestVar('imagepopup');
1370 $width = intRequestVar('width');
1371 $height = intRequestVar('height');
1372 $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup);
1391 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
1398 * Actions::parse_imagetext()
1399 * Parse skinvar imagetext
1404 public function parse_imagetext()
1406 $this->parse_image('imagetext');
1411 * Actions::parse_item()
1412 * Parse skinvar item
1413 * include one item (no comments)
1418 public function parse_item($template)
1420 global $blog, $itemid, $highlight;
1422 // need this to select default category
1423 $this->setBlogCategory($blog, '');
1424 $this->preBlogContent('item',$blog);
1425 $r = $blog->showOneitem($itemid, $template, $highlight);
1428 echo _ERROR_NOSUCHITEM;
1430 $this->postBlogContent('item',$blog);
1435 * Actions::parse_itemid()
1436 * Parse skinvar itemid
1441 public function parse_itemid()
1449 * Actions::parseitemlink()
1450 * Parse skinvar itemlink
1455 public function parse_itemlink($linktext = '')
1458 $this->itemlink($itemid, $linktext);
1463 * Actions::parse_itemtitle()
1469 public function parse_itemtitle($format = '')
1471 global $manager, $itemid;
1472 $item =& $manager->getItem($itemid,0,0);
1477 echo Entity::hen($item['title']);
1480 echo $item['title'];
1484 echo Entity::hsc(strip_tags($item['title']));
1491 * Actions::parse_loginform()
1492 * Parse skinvar loginform
1497 public function parse_loginform()
1499 global $member, $CONF;
1500 if ( !$member->isLoggedIn() )
1502 $filename = 'loginform-notloggedin';
1503 $this->formdata = array();
1507 $filename = 'loginform-loggedin';
1508 $this->formdata = array(
1509 'membername' => $member->getDisplayName(),
1512 $this->doForm($filename);
1517 * Actions::parse_member()
1518 * Parse skinvar member
1519 * (includes a member info thingie)
1521 * @param string $what which memberdata is needed
1524 public function parse_member($what)
1526 global $memberinfo, $member, $CONF;
1528 // 1. only allow the member-details-page specific variables on member pages
1529 if ( $this->skintype == 'member' )
1534 echo Entity::hsc($memberinfo->getDisplayName());
1537 echo Entity::hsc($memberinfo->getRealName());
1540 echo Entity::hsc($memberinfo->getNotes());
1543 echo Entity::hsc($memberinfo->getURL());
1546 echo Entity::hsc($memberinfo->getEmail());
1549 echo Entity::hsc($memberinfo->getID());
1554 // 2. the next bunch of options is available everywhere, as long as the user is logged in
1555 if ( $member->isLoggedIn() )
1560 echo $member->getDisplayName();
1562 case 'yourrealname':
1563 echo $member->getRealName();
1566 echo $member->getNotes();
1569 echo $member->getURL();
1572 echo $member->getEmail();
1575 echo $member->getID();
1577 case 'yourprofileurl':
1578 if ($CONF['URLMode'] == 'pathinfo')
1579 echo Link::create_member_link($member->getID());
1581 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
1589 * Link::parse_membermailform()
1590 * Parse skinvar membermailform
1592 * @param integer $rows the height for textarea
1593 * @param integer $cols the width for textarea
1594 * @param string $desturl URI to redirect
1597 public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
1599 global $member, $CONF, $memberid;
1601 if ( $desturl == '' )
1603 if ( $CONF['URLMode'] == 'pathinfo' )
1605 $desturl = Link::create_member_link($memberid);
1609 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
1613 $message = postVar('message');
1614 $frommail = postVar('frommail');
1616 $this->formdata = array(
1617 'url' => Entity::hsc($desturl),
1618 'actionurl' => Entity::hsc($CONF['ActionURL']),
1619 'memberid' => $memberid,
1622 'message' => Entity::hsc($message),
1623 'frommail' => Entity::hsc($frommail)
1626 if ( $member->isLoggedIn() )
1628 $this->doForm('membermailform-loggedin');
1630 else if ( $CONF['NonmemberMail'] )
1632 $this->doForm('membermailform-notloggedin');
1636 $this->doForm('membermailform-disallowed');
1642 * Actions::parse_nextarchive()
1643 * Parse skinvar nextarchive
1648 public function parse_nextarchive()
1650 global $archivenext;
1656 * Parse skinvar nextitem
1657 * (include itemid of next item)
1662 public function parse_nextitem()
1665 if ( isset($itemidnext) )
1667 echo (int)$itemidnext;
1673 * Actions::parse_nextitemtitle()
1674 * Parse skinvar nextitemtitle
1675 * (include itemtitle of next item)
1677 * @param string $format format of text
1680 public function parse_nextitemtitle($format = '')
1682 global $itemtitlenext;
1687 echo Entity::hen($itemtitlenext);
1690 echo $itemtitlenext;
1694 echo Entity::hsc($itemtitlenext);
1701 * Actions::parse_nextlink()
1702 * Parse skinvar nextlink
1704 * @param string $linktext text for content of anchor element
1705 * @param integer $amount the amount of items in a display
1706 * @param integer $recount increment from this value
1709 public function parse_nextlink($linktext = '', $amount = 10, $recount = '')
1711 global $itemidnext, $archivenext, $startpos;
1712 if ( $this->skintype == 'item' )
1714 $this->itemlink($itemidnext, $linktext);
1716 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
1718 $this->searchlink($amount, $startpos, 'next', $linktext, $recount);
1722 $this->archivelink($archivenext, $linktext);
1728 * Actions::parse_nucleusbutton()
1729 * Parse skinvar nucleusbutton
1731 * @param string $imgurl URL for image
1732 * @param integer $imgwidth width of image
1733 * @param integer $imgheidht height of image
1735 public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')
1738 if ( $imgurl == '' )
1740 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
1742 else if ( Parser::getProperty('IncludeMode') == 'skindir' )
1744 // when skindit IncludeMode is used: start from skindir
1745 $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
1748 $this->formdata = array(
1749 'imgurl' => $imgurl,
1750 'imgwidth' => $imgwidth,
1751 'imgheight' => $imgheight,
1753 $this->doForm('nucleusbutton');
1758 * Actions::parse_otherarchive()
1759 * Parse skinvar otherarchive
1761 * @param string $blogname name of weblog
1762 * @param string $template name of template
1763 * @param string $category name of category
1766 public function parse_otherarchive($blogname, $template, $category = '')
1768 global $archive, $manager;
1769 sscanf($archive,'%d-%d-%d',$y,$m,$d);
1770 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1771 $this->setBlogCategory($b, $category);
1772 $this->preBlogContent('otherachive',$b);
1773 $b->showArchive($template, $y, $m, $d);
1774 $this->postBlogContent('otherachive',$b);
1779 * Actions::parse_otherarchivedaylist()
1780 * Parse skinvar otherarchivedaylist
1782 * @param string $blogname name of weblog
1783 * @param string $template name of template
1784 * @param string $category name of category
1785 * @param integer $limit the amount of items in a display
1788 public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)
1791 if ( $category == 'all')
1795 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1796 $this->setBlogCategory($b, $category);
1797 $this->preBlogContent('otherarchivelist',$b);
1798 $b->showArchiveList($template, 'day', $limit);
1799 $this->postBlogContent('otherarchivelist',$b);
1804 * Actions::parse_otherarchivelist()
1805 * Parse skinvar otherarchivelist
1807 * @param string $blogname name of weblog
1808 * @param string $template name of template
1809 * @param string $category name of category
1810 * @param integer $limit the amount of items in a display
1813 public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)
1816 if ( $category == 'all' )
1820 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1821 $this->setBlogCategory($b, $category);
1822 $this->preBlogContent('otherarchivelist',$b);
1823 $b->showArchiveList($template, 'month', $limit);
1824 $this->postBlogContent('otherarchivelist',$b);
1829 * Actions::parse_otherarchiveyearlist()
1830 * Parse skinvar otherarchiveyearlist
1832 * @param string $blogname name of weblog
1833 * @param string $template name of template
1834 * @param string $category name of category
1835 * @limit integer $limit the amount of items in a display
1837 public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)
1840 if ( $category == 'all' )
1844 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1845 $this->setBlogCategory($b, $category);
1846 $this->preBlogContent('otherarchivelist',$b);
1847 $b->showArchiveList($template, 'year', $limit);
1848 $this->postBlogContent('otherarchivelist',$b);
1853 * Actions::parse_otherblog()
1854 * Parse skinvar otherblog
1856 * @param string $blogname name of weblog
1857 * @param string $template name of template
1858 * @param mixed $amount the amount of items, in case it includes the beginning
1859 * @param string $category name of category
1862 public function parse_otherblog($blogname, $template, $amount = 10, $category = '')
1866 list($limit, $offset) = sscanf($amount, '%d(%d)');
1868 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1869 $this->setBlogCategory($b, $category);
1870 $this->preBlogContent('otherblog',$b);
1871 $this->amountfound = $b->readLog($template, $limit, $offset);
1872 $this->postBlogContent('otherblog',$b);
1877 * Actions::parse_othersearchresults()
1878 * Parse skinvar othersearchresults
1880 * @param string $blogname name of weblog
1881 * @param string $template name of template
1882 * @param integer $maxresults the amount of results
1885 public function parse_othersearchresults($blogname, $template, $maxresults = 50)
1887 global $query, $amount, $manager, $startpos;
1888 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1889 // need this to select default category
1890 $this->setBlogCategory($b, '');
1891 $this->preBlogContent('othersearchresults',$b);
1892 $b->search($query, $template, $amount, $maxresults, $startpos);
1893 $this->postBlogContent('othersearchresults',$b);
1898 * Actions::parse_plugin()
1899 * Executes a plugin skinvar
1900 * extra parameters can be added
1902 * @param string $pluginName name of plugin (without the NP_)
1905 public function parse_plugin($pluginName)
1909 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1916 $params = func_get_args();
1918 // remove plugin name
1919 array_shift($params);
1921 // add skin type on front
1922 array_unshift($params, $this->skintype);
1924 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1929 * Actions::parse_prevarchive()
1930 * Parse skinvar prevarchive
1935 public function parse_prevarchive()
1937 global $archiveprev;
1942 * Actions::parse_preview()
1943 * Parse skinvar preview
1945 * @param string $template name of tempalte
1948 public function parse_preview($template)
1950 global $blog, $CONF, $manager;
1952 $template =& $manager->getTemplate($template);
1954 $row['body'] = '<span id="prevbody"></span>';
1955 $row['title'] = '<span id="prevtitle"></span>';
1956 $row['more'] = '<span id="prevmore"></span>';
1957 $row['itemlink'] = '';
1958 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1960 echo Template::fill($template['ITEM_HEADER'],$row);
1961 echo Template::fill($template['ITEM'],$row);
1962 echo Template::fill($template['ITEM_FOOTER'],$row);
1967 * Actions::parse_previtem()
1968 * Parse skinvar previtem
1969 * (include itemid of prev item)
1974 public function parse_previtem()
1977 if ( isset($itemidprev) )
1979 echo (integer) $itemidprev;
1985 * Actions::parse_previtemtitle()
1986 * Parse skinvar previtemtitle
1987 * (include itemtitle of prev item)
1989 * @param String $format string format
1990 * @return String formatted string
1992 public function parse_previtemtitle($format = '')
1994 global $itemtitleprev;
1999 echo Entity::hen($itemtitleprev);
2002 echo $itemtitleprev;
2006 echo Entity::hsc($itemtitleprev);
2013 * Actions::parse_prevlink()
2014 * Parse skinvar prevlink
2016 * @param string $linktext text as a content of anchor element
2017 * @param integer the amount of links
2020 public function parse_prevlink($linktext = '', $amount = 10)
2022 global $itemidprev, $archiveprev, $startpos;
2024 if ( $this->skintype == 'item' )
2026 $this->itemlink($itemidprev, $linktext);
2028 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
2030 $this->searchlink($amount, $startpos, 'prev', $linktext);
2034 $this->archivelink($archiveprev, $linktext);
2040 * Actions::parse_query()
2041 * Parse skinvar query
2042 * (includes the search query)
2047 public function parse_query()
2050 echo Entity::hsc($query);
2055 * Actions::parse_referer()
2056 * Parse skinvar referer
2061 public function parse_referer()
2063 echo Entity::hsc(serverVar('HTTP_REFERER'));
2068 * Actions::parse_searchform()
2069 * Parse skinvar searchform
2071 * @param string $blogname name of weblog
2074 public function parse_searchform($blogname = '')
2076 global $CONF, $manager, $maxresults;
2079 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
2085 // use default blog when no blog is selected
2086 $this->formdata = array(
2087 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
2088 'query' => Entity::hsc(getVar('query')),
2090 $this->doForm('searchform');
2095 * Actions::parse_searchresults()
2096 * Parse skinvar searchresults
2098 * @param string $template name of tempalte
2099 * @param integer $maxresults searched items in a display
2102 public function parse_searchresults($template, $maxresults = 50 )
2104 global $blog, $query, $amount, $startpos;
2106 $this->setBlogCategory($blog, ''); // need this to select default category
2107 $this->preBlogContent('searchresults',$blog);
2108 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
2109 $this->postBlogContent('searchresults',$blog);
2114 * Actions::parse_self()
2115 * Parse skinvar self
2120 public function parse_self()
2128 * Actions::parse_sitevar()
2129 * Parse skinvar sitevar
2130 * (include a sitevar)
2132 * @param string $which
2135 public function parse_sitevar($which)
2141 echo $CONF['IndexURL'];
2144 echo $CONF['SiteName'];
2147 echo $CONF['AdminEmail'];
2150 echo $CONF['AdminURL'];
2156 * Actions::parse_skinname()
2162 public function parse_skinname()
2164 echo $this->skin->getName();
2169 * Actions::parse_skintype()
2170 * Parse skintype (experimental)
2175 public function parse_skintype()
2177 echo $this->skintype;
2182 * Actions::parse_ticket()
2188 public function parse_ticket()
2191 $manager->addTicketHidden();
2196 * Actions::parse_todaylink()
2197 * Parse skinvar todaylink
2198 * A link to the today page (depending on selected blog, etc...)
2200 * @param string $linktext text for link
2203 public function parse_todaylink($linktext = '')
2205 global $blog, $CONF;
2208 echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
2212 echo $this->link($CONF['SiteUrl'], $linktext);
2219 * When commentform is not used, to include a hidden field with itemid
2224 public function parse_vars()
2227 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";
2232 * Actions::parse_version()
2233 * Parse skinvar version
2234 * (include nucleus versionnumber)
2239 public function parse_version()
2242 echo 'Nucleus CMS ' . $nucleus['version'];
2247 * Actions::parse_sticky()
2248 * Parse skinvar sticky
2250 * @param integer $itemnumber id of item
2251 * @param string $template name of template
2254 public function parse_sticky($itemnumber = 0, $template = '')
2258 $itemnumber = intval($itemnumber);
2259 $itemarray = array($itemnumber);
2261 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
2262 $this->preBlogContent('sticky',$b);
2263 $this->amountfound = $b->readLogFromList($itemarray, $template);
2264 $this->postBlogContent('sticky',$b);