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
19 * @version $Id: ACTIONS.php 1863 2012-05-19 10:50:27Z sakamocchi $
21 * @version $Id: ACTIONS.php 1886 2012-06-17 08:27:27Z sakamocchi $
22 >>>>>>> skinnable-master
25 class Actions extends BaseActions
27 // part of the skin currently being parsed ('index', 'item', 'archive',
28 // 'archivelist', 'member', 'search', 'error', 'imagepopup')
31 // contains an assoc array with parameters that need to be included when
32 // generating links to items/archives/... (e.g. catid)
35 // used when including templated forms from the include/ dir. The $formdata var
36 // contains the values to fill out in there (assoc array name -> value)
39 // filled out with the number of displayed items after calling one of the
40 // (other)blog/(other)searchresults skinvars.
44 * Actions::$default_actions
45 * list of whole action names with which this class can deal
47 static private $default_actions = array(
57 'otherarchivedaylist',
59 'otherarchiveyearlist',
70 // deprecated (Nucleus v2.0)
71 /* TODO: remove this */
77 * Actions::$skin_type_friendly_names
78 * friendly name for wrapped page types
80 static public $default_skin_types = array(
82 * Actions::$normal_skin_types
83 * friendly name for wrapped page types
85 static public $normal_skin_types = array(
86 >>>>>>> skinnable-master
87 'index' => _SKIN_PART_MAIN,
88 'item' => _SKIN_PART_ITEM,
89 'archivelist' => _SKIN_PART_ALIST,
90 'archive' => _SKIN_PART_ARCHIVE,
91 'search' => _SKIN_PART_SEARCH,
92 'error' => _SKIN_PART_ERROR,
93 'member' => _SKIN_PART_MEMBER,
94 'imagepopup' => _SKIN_PART_POPUP
99 * Actions::getAvailableSkinTypes()
101 * Actions::getNormalSkinTypes()
102 >>>>>>> skinnable-master
106 * @return array list of friendly names for page actions
109 static public function getAvailableSkinTypes()
111 return self::$default_skin_types;
113 static public function getNormalSkinTypes()
115 return self::$normal_skin_types;
116 >>>>>>> skinnable-master
120 * Actions::__construct()
121 * Constructor for a new Actions object
123 * @param string $type
126 public function __construct($type)
130 // call constructor of superclass first
131 parent::__construct();
132 $this->skintype = $type;
136 $this->linkparams = array('catid' => $catid);
142 * Actions::getAvailableActions()
145 * @return array allowed actions for the page type
147 public function getAvailableActions()
149 $extra_actions = array();
151 switch ( $this->skintype )
154 $extra_actions = array(
168 $extra_actions = array(
186 $extra_actions = array(
196 $extra_actions = array(
203 'othersearchresults',
211 $extra_actions = array(
213 // deprecated (Nucleus v2.0)
214 /* TODO: remove this */
219 $extra_actions = array(
227 $extra_actions = array(
250 $extra_actions = array(
256 $extra_actions = array(
274 $defined_actions = array_merge(self::$default_actions, $extra_actions);
276 return array_merge($defined_actions, parent::getAvailableActions());
281 * Forms get parsedincluded now, using an extra <formdata> skinvar
283 * @param string $filename
286 public function doForm($filename)
289 array_push($this->parser->actions,'formdata', 'callback','errordiv','ticket');
291 $oldIncludeMode = Parser::getProperty('IncludeMode');
292 $oldIncludePrefix = Parser::getProperty('IncludePrefix');
293 Parser::setProperty('IncludeMode','normal');
294 Parser::setProperty('IncludePrefix','');
296 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
297 Parser::setProperty('IncludeMode',$oldIncludeMode);
298 Parser::setProperty('IncludePrefix',$oldIncludePrefix);
300 array_pop($this->parser->actions); // errordiv
301 array_pop($this->parser->actions); // callback
302 array_pop($this->parser->actions); // formdata
303 array_pop($this->parser->actions); // ticket
308 * Actions::checkCondition()
309 * Checks conditions for if statements
311 * @param string $field type of <%if%>
312 * @param string $name property of field
313 * @param string $value value of property
314 * @return boolean condition
316 protected function checkCondition($field, $name='', $value = '')
318 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
324 $condition = ($blog && $this->ifCategory($name,$value));
327 $condition = ($blog && ($blog->getSetting($name) == $value));
330 $condition = $member->isLoggedIn();
333 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
336 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
339 $condition = ($itemidnext != '');
342 $condition = ($itemidprev != '');
344 case 'archiveprevexists':
345 $condition = ($archiveprevexists == true);
347 case 'archivenextexists':
348 $condition = ($archivenextexists == true);
351 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
354 $condition = $this->ifHasPlugin($name, $value);
357 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
364 * Actions::_ifHasPlugin()
366 * -> checks if plugin exists
367 * hasplugin,PlugName,OptionName
368 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
369 * hasplugin,PlugName,OptionName=value
370 * -> checks if the option OptionName from plugin PlugName is set to value
372 * @param string $name name of plugin
373 * @param string $value
376 private function ifHasPlugin($name, $value)
380 // (pluginInstalled method won't write a message in the actionlog on failure)
381 if ( $manager->pluginInstalled("NP_{$name}") )
383 $plugin =& $manager->getPlugin("NP_{$name}");
384 if ( $plugin != NULL )
392 list($name2, $value2) = preg_split('#=#', $value, 2);
393 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
397 else if ( $plugin->getOption($name2) == $value2 )
408 * Actions::ifPlugin()
409 * Checks if a plugin exists and call its doIf function
411 * @param string $name name of plugin
412 * @param string $key name of plugin option
413 * @param string $value value of plugin option
416 private function ifPlugin($name, $key = '', $value = '')
420 $plugin =& $manager->getPlugin("NP_{$name}");
426 $params = func_get_args();
427 array_shift($params);
430 return call_user_func_array(array(&$plugin, 'doIf'), $params);
432 return call_user_func_array(array($plugin, 'doIf'), $params);
433 >>>>>>> skinnable-master
437 * Actions::ifCategory()
438 * Different checks for a category
440 * @param string $name
441 * @param string $value
444 private function ifCategory($name = '', $value='')
446 global $blog, $catid;
448 // when no parameter is defined, just check if a category is selected
449 if ( ($name != 'catname' && $name != 'catid') || ($value == '') )
451 return $blog->isValidCategory($catid);
453 // check category name
454 else if ( $name == 'catname' )
456 $value = $blog->getCategoryIdFromName($value);
457 if ( $value == $catid )
459 return $blog->isValidCategory($catid);
463 else if ( ($name == 'catid') && ($value == $catid) )
465 return $blog->isValidCategory($catid);
471 * Actions::ifOnTeam()
472 * Checks if a member is on the team of a blog and return his rights
474 * @param string $blogName name of weblog
477 private function ifOnTeam($blogName = '')
479 global $blog, $member, $manager;
481 // when no blog found
482 if ( ($blogName == '') && !is_object($blog) )
487 // explicit blog selection
488 if ( $blogName != '' )
490 $blogid = getBlogIDFromName($blogName);
493 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
496 $blogid = $blog->getID();
499 return $member->teamRights($blogid);
504 * Checks if a member is admin of a blog
506 * @param string $blogName name of weblog
509 private function ifAdmin($blogName = '')
511 global $blog, $member, $manager;
513 // when no blog found
514 if ( ($blogName == '') && (!is_object($blog)) )
519 // explicit blog selection
520 if ( $blogName != '' )
522 $blogid = getBlogIDFromName($blogName);
525 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
528 $blogid = $blog->getID();
531 return $member->isBlogAdmin($blogid);
537 * - a raw link (html/xml encoded) when no linktext is provided
538 * - a (x)html <a href... link when a text is present (text htmlencoded)
540 * @param string $url URL for href attribute of anchor element
541 * @param string $linktext content of anchor element
544 private function link($url, $linktext = '')
546 $u = Entity::hsc($url);
547 // fix URLs that already had encoded ampersands
548 $u = preg_replace("#&amp;#", '&', $u);
549 if ( $linktext != '' )
551 $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';
561 * Actions::searchlink()
562 * Outputs a next/prev link
565 * The maximum amount of items shown per page (e.g. 10)
567 * Current start position (requestVar('startpos'))
569 * either 'prev' or 'next'
571 * When present, the output will be a full <a href...> link. When empty,
572 * only a raw link will be outputted
574 private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')
576 global $CONF, $blog, $query, $amount;
577 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
578 $startpos = (integer) $startpos;
579 $parsed = parse_url(serverVar('REQUEST_URI'));
581 $path = $parsed['path'];
582 $parsed = $parsed['query'];
584 $path = ( in_array('path', $parsed) ) ? $parsed['path'] : '';
585 $parsed = ( in_array('query', $parsed) ) ? $parsed['query'] : '';
586 >>>>>>> skinnable-master
589 if ( $direction == 'prev' )
591 if ( intval($startpos) - intval($maxresults) >= 0 )
593 $startpos = intval($startpos) - intval($maxresults);
595 if ( $this->skintype == 'index' )
599 else if ( $this->skintype == 'search' )
601 $url = $CONF['SearchURL'];
603 $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);
606 else if ( $direction == 'next' )
608 global $navigationItems;
609 if ( !isset($navigationItems) )
611 $navigationItems = 0;
620 $iAmountOnPage = $this->amountfound;
623 if ( intval($navigationItems) > 0 )
625 $iAmountOnPage = intval($navigationItems) - intval($startpos);
627 elseif ( $iAmountOnPage == 0 )
630 * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
633 if ( $this->skintype == 'index' )
635 $sqlquery = $blog->getSqlBlog('', 'count');
638 else if ( $this->skintype == 'search' )
640 $unused_highlight = '';
641 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
642 $url = $CONF['SearchURL'];
646 $iAmountOnPage = intval(DB::getValue($sqlquery)) - intval($startpos);
651 if ( intval($iAmountOnPage) >= intval($maxresults) )
653 $startpos = intval($startpos) + intval($maxresults);
654 $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos);
660 echo $this->link($url, $linktext);
666 * Actions::itemlink()
667 * Creates an item link and if no id is given a todaylink
669 * @param integer $id id for link
670 * @param string $linktext text for link
673 private function itemlink($id, $linktext = '')
678 echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);
682 $this->parse_todaylink($linktext);
688 * Actions::archivelink)
689 * Creates an archive link and if no id is given a todaylink
691 * @param integer $id id for link
692 * @param string $linktext text for link
695 private function archivelink($id, $linktext = '')
700 echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
704 $this->parse_todaylink($linktext);
710 * Actions:setBlogCategory()
711 * Helper function that sets the category that a blog will need to use
713 * @param string $blog An object of the blog class, passed by reference (we want to make changes to it)
714 * @param string $catname The name of the category to use
717 private function setBlogCategory(&$blog, $catname)
720 if ( $catname != '' )
722 $blog->setSelectedCategoryByName($catname);
726 $blog->setSelectedCategory($catid);
732 * Actions::preBlogContent()
733 * Notifies the Manager that a PreBlogContent event occurs
735 * @param string $type type of skin
736 * @param object $blog an instance of Blog class
739 private function preBlogContent($type, &$blog)
743 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
745 $data = array('blog' => &$blog, 'type' => $type);
746 $manager->notify('PreBlogContent', $data);
747 >>>>>>> skinnable-master
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)
763 $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));
765 $data = array('blog' => &$blog, 'type' => $type);
766 $manager->notify('PostBlogContent', $data);
767 >>>>>>> skinnable-master
772 * Actions::parse_additemform()
773 * Parse skinvar additemform
778 public function parse_additemform()
781 $this->formdata = array(
782 'adminurl' => Entity::hsc($CONF['AdminURL']),
783 'catid' => $blog->getDefaultCategory()
785 $blog->InsertJavaScriptInfo();
786 $this->doForm('additemform');
791 * Actions::parse_addlink()
792 * Parse skinvar addlink
793 * A Link that allows to open a bookmarklet to add an item
795 public function parse_addlink()
797 global $CONF, $member, $blog;
798 if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )
800 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
806 * Actions::parse_addpopupcode()
807 * Parse skinvar addpopupcode
808 * Code that opens a bookmarklet in an popup window
813 public function parse_addpopupcode()
815 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;";
820 * Parse skinvar adminurl
821 * (shortcut for admin url)
826 public function parse_adminurl()
828 $this->parse_sitevar('adminurl');
833 * Actions::parse_archive()
834 * Parse skinvar archive
836 * @param string $template name of template
837 * @param string $category name of category
840 public function parse_archive($template, $category = '')
842 global $blog, $archive;
843 // can be used with either yyyy-mm or yyyy-mm-dd
844 sscanf($archive,'%d-%d-%d', $y, $m, $d);
845 $this->setBlogCategory($blog, $category);
846 $this->preBlogContent('achive',$blog);
847 $blog->showArchive($template, $y, $m, $d);
848 $this->postBlogContent('achive',$blog);
853 * Actions::parse_archivedate()
854 * %archivedate(locale,date format)%
857 * @param string $locale
860 public function parse_archivedate($locale = '-def-')
865 * TODO: these lines are no meaning because there is no $template.
866 if ( $locale == '-def-' )
868 setlocale(LC_TIME, $template['LOCALE']);
872 setlocale(LC_TIME, $locale);
877 * @param deprecated $locale
880 public function parse_archivedate($locale='')
884 >>>>>>> skinnable-master
886 sscanf($archive,'%d-%d-%d',$y,$m,$d);
889 $args = func_get_args();
890 // format can be spread over multiple parameters
891 if ( sizeof($args) > 1 )
896 $format=implode(',',$args);
898 elseif ( $d == 0 && $m !=0 )
908 $format = '%d %B %Y';
910 echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
915 * Actions::parse_archivedaylist()
916 * Parse skinvar archivedaylist
918 * @param string $template name of template
919 * @param string $category name of category
920 * @param integer $limit the number of items in a display
923 public function parse_archivedaylist($template, $category = 'all', $limit = 0)
926 if ( $category == 'all' )
930 $this->preBlogContent('archivelist',$blog);
931 $this->setBlogCategory($blog, $category);
932 $blog->showArchiveList($template, 'day', $limit);
933 $this->postBlogContent('archivelist',$blog);
938 * Actions::parse_archivelink()
939 * A link to the archives for the current blog (or for default blog)
941 * @param string $linktext text for link
944 public function parse_archivelink($linktext = '')
949 echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);
953 echo $this->link(Link::create_archivelist_link(), $linktext);
959 * Actions::parse_archivelist()
961 * @param string $template name of template
962 * @param string $category name of category
963 * @param integer $limit the number of items in a display
966 public function parse_archivelist($template, $category = 'all', $limit = 0)
969 if ( $category == 'all' )
973 $this->preBlogContent('archivelist',$blog);
974 $this->setBlogCategory($blog, $category);
975 $blog->showArchiveList($template, 'month', $limit);
976 $this->postBlogContent('archivelist',$blog);
981 * Actions::parse_archiveyearlist()
983 * @param string $template name of template
984 * @param string $category name of category
985 * @param integer $limit the number of items in a display
987 public function parse_archiveyearlist($template, $category = 'all', $limit = 0)
990 if ( $category == 'all' )
994 $this->preBlogContent('archivelist',$blog);
995 $this->setBlogCategory($blog, $category);
996 $blog->showArchiveList($template, 'year', $limit);
997 $this->postBlogContent('archivelist',$blog);
1002 * Actions::parse_archivetype()
1003 * Parse skinvar archivetype
1008 public function parse_archivetype()
1010 global $archivetype;
1016 * Actions::parse_blog()
1017 * Parse skinvar blog
1019 * @param string $template name of template
1020 * @param mixed $amount the number of items in a display, in case it includes the beginning
1021 * @param string $category name of category
1024 public function parse_blog($template, $amount = 10, $category = '')
1026 global $blog, $startpos;
1028 list($limit, $offset) = sscanf($amount, '%d(%d)');
1029 $this->setBlogCategory($blog, $category);
1030 $this->preBlogContent('blog',$blog);
1031 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
1032 $this->postBlogContent('blog',$blog);
1037 * Actions::parse_bloglist()
1038 * Parse skinvar bloglist
1039 * Shows a list of all blogs
1041 * @param string $template name of template
1042 * @param string $bnametype whether 'name' or 'shortname' is used for the link text
1043 * @param string $orderby order criteria
1044 * @param string $direction order ascending or descending
1047 public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')
1049 Blog::showBlogList($template, $bnametype, $orderby, $direction);
1054 * Actions::parse_blogsetting()
1055 * Parse skinvar blogsetting
1057 * @param string $which key of weblog settings
1060 public function parse_blogsetting($which)
1066 echo Entity::hsc($blog->getID());
1069 echo Entity::hsc($blog->getURL());
1072 echo Entity::hsc($blog->getName());
1075 echo Entity::hsc($blog->getDescription());
1078 echo Entity::hsc($blog->getShortName());
1085 * Actions::parse_callback()
1088 * @param string $eventName name of event
1089 * @param string $type type of skin
1092 public function parse_callback($eventName, $type)
1096 $manager->notify($eventName, array('type' => $type));
1098 $data = array('type' => $type);
1099 $manager->notify($eventName, $data);
1100 >>>>>>> skinnable-master
1105 * Actions::parse_category()
1106 * Parse skinvar category
1108 * @param string $type key of category settings
1111 public function parse_category($type = 'name')
1113 global $catid, $blog;
1114 if ( !$blog->isValidCategory($catid) )
1122 echo $blog->getCategoryName($catid);
1125 echo $blog->getCategoryDesc($catid);
1135 * Actions::parse_categorylist()
1136 * Parse categorylist
1138 * @param string $template name of template
1139 * @param string $blogname name of weblog
1142 public function parse_categorylist($template, $blogname = '')
1144 global $blog, $manager;
1146 // when no blog found
1147 if ( ($blogname == '') && (!is_object($blog)) )
1152 if ( $blogname == '' )
1154 $this->preBlogContent('categorylist',$blog);
1155 $blog->showCategoryList($template);
1156 $this->postBlogContent('categorylist',$blog);
1160 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1161 $this->preBlogContent('categorylist',$b);
1162 $b->showCategoryList($template);
1163 $this->postBlogContent('categorylist',$b);
1169 * Actions::parse_commentform()
1170 * Parse skinvar commentform
1172 * @param string $destinationurl URI for redirection
1175 public function parse_commentform($destinationurl = '')
1177 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
1179 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
1180 if ( stristr($destinationurl, 'action.php') )
1182 $args = func_get_args();
1183 $destinationurl = $args[1];
1184 ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
1187 $actionurl = $CONF['ActionURL'];
1189 // if item is closed, show message and do nothing
1190 $item =& $manager->getItem($itemid,0,0);
1191 if ( $item['closed'] || !$blog->commentsEnabled() )
1193 $this->doForm('commentform-closed');
1197 if ( !$blog->isPublic() && !$member->isLoggedIn() )
1199 $this->doForm('commentform-closedtopublic');
1203 if ( !$destinationurl )
1205 // note: createLink returns an HTML encoded URL
1206 $destinationurl = Link::create_link(
1209 'itemid' => $itemid,
1210 'title' => $item['title'],
1211 'timestamp' => $item['timestamp'],
1212 'extra' => $this->linkparams
1219 $destinationurl = Entity::hsc($destinationurl);
1222 // values to prefill
1223 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
1226 $user = postVar('user');
1229 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
1232 $userid = postVar('userid');
1235 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
1238 $email = postVar('email');
1241 $body = postVar('body');
1243 $this->formdata = array(
1244 'destinationurl' => $destinationurl, // url is already HTML encoded
1245 'actionurl' => Entity::hsc($actionurl),
1246 'itemid' => $itemid,
1247 'user' => Entity::hsc($user),
1248 'userid' => Entity::hsc($userid),
1249 'email' => Entity::hsc($email),
1250 'body' => Entity::hsc($body),
1251 'membername' => $member->getDisplayName(),
1252 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
1255 if ( !$member->isLoggedIn() )
1257 $this->doForm('commentform-notloggedin');
1261 $this->doForm('commentform-loggedin');
1267 * Actions::parse_comments()
1268 * Parse skinvar comments
1269 * include comments for one item
1271 * @param string $template name of template
1274 public function parse_comments($template)
1276 global $manager, $blog, $highlight, $itemid;
1278 $template =& $manager->getTemplate($template);
1280 $item =& $manager->getItem($itemid, 0, 0);
1282 $item =& $manager->getitem($itemid, 0, 0);
1283 >>>>>>> skinnable-master
1285 // create parser object & action handler
1286 $handler = new ItemActions($blog);
1287 $handler->setTemplate($template);
1288 $handler->setCurrentItem($item);
1290 $parser = new Parser($handler);
1292 $comments = new Comments($itemid);
1293 $comments->setItemActions($handler);
1294 // shows ALL comments
1295 $comments->showComments($template, -1, 1, $highlight);
1300 * Actions::parse_errordiv()
1306 public function parse_errordiv()
1308 global $errormessage;
1309 if ( $errormessage )
1311 echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";
1317 * Actions::parse_errormessage()
1318 * Parse skinvar errormessage
1323 public function parse_errormessage()
1325 global $errormessage;
1331 * Actions::parse_formdata()
1334 * @param string $what key of format data
1337 public function parse_formdata($what)
1339 echo $this->formdata[$what];
1344 * Actions::parse_ifcat()
1347 * @param string $text
1350 public function parse_ifcat($text = '')
1355 $this->parse_if('category');
1360 global $catid, $blog;
1361 if ( $blog->isValidCategory($catid) )
1370 * Actions::parse_image()
1371 * Parse skinvar image
1373 * @param string $what name of tag
1376 public function parse_image($what = 'imgtag')
1380 $imagetext = Entity::hsc(requestVar('imagetext'));
1381 $imagepopup = requestVar('imagepopup');
1382 $width = intRequestVar('width');
1383 $height = intRequestVar('height');
1384 $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup);
1403 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
1410 * Actions::parse_imagetext()
1411 * Parse skinvar imagetext
1416 public function parse_imagetext()
1418 $this->parse_image('imagetext');
1423 * Actions::parse_item()
1424 * Parse skinvar item
1425 * include one item (no comments)
1430 public function parse_item($template)
1432 global $blog, $itemid, $highlight;
1434 // need this to select default category
1435 $this->setBlogCategory($blog, '');
1436 $this->preBlogContent('item',$blog);
1437 $r = $blog->showOneitem($itemid, $template, $highlight);
1440 echo _ERROR_NOSUCHITEM;
1442 $this->postBlogContent('item',$blog);
1447 * Actions::parse_itemid()
1448 * Parse skinvar itemid
1453 public function parse_itemid()
1461 * Actions::parseitemlink()
1462 * Parse skinvar itemlink
1467 public function parse_itemlink($linktext = '')
1470 $this->itemlink($itemid, $linktext);
1475 * Actions::parse_itemtitle()
1481 public function parse_itemtitle($format = '')
1483 global $manager, $itemid;
1485 $item =& $manager->getItem($itemid,0,0);
1487 $item =& $manager->getItem($itemid, 1, 1);
1488 >>>>>>> skinnable-master
1493 echo Entity::hen($item['title']);
1496 echo $item['title'];
1500 echo Entity::hsc(strip_tags($item['title']));
1507 * Actions::parse_loginform()
1508 * Parse skinvar loginform
1513 public function parse_loginform()
1515 global $member, $CONF;
1516 if ( !$member->isLoggedIn() )
1518 $filename = 'loginform-notloggedin';
1519 $this->formdata = array();
1523 $filename = 'loginform-loggedin';
1524 $this->formdata = array(
1525 'membername' => $member->getDisplayName(),
1528 $this->doForm($filename);
1533 * Actions::parse_member()
1534 * Parse skinvar member
1535 * (includes a member info thingie)
1537 * @param string $what which memberdata is needed
1540 public function parse_member($what)
1542 global $memberinfo, $member, $CONF;
1544 // 1. only allow the member-details-page specific variables on member pages
1545 if ( $this->skintype == 'member' )
1550 echo Entity::hsc($memberinfo->getDisplayName());
1553 echo Entity::hsc($memberinfo->getRealName());
1556 echo Entity::hsc($memberinfo->getNotes());
1559 echo Entity::hsc($memberinfo->getURL());
1562 echo Entity::hsc($memberinfo->getEmail());
1565 echo Entity::hsc($memberinfo->getID());
1570 // 2. the next bunch of options is available everywhere, as long as the user is logged in
1571 if ( $member->isLoggedIn() )
1576 echo $member->getDisplayName();
1578 case 'yourrealname':
1579 echo $member->getRealName();
1582 echo $member->getNotes();
1585 echo $member->getURL();
1588 echo $member->getEmail();
1591 echo $member->getID();
1593 case 'yourprofileurl':
1594 if ($CONF['URLMode'] == 'pathinfo')
1595 echo Link::create_member_link($member->getID());
1597 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
1605 * Link::parse_membermailform()
1606 * Parse skinvar membermailform
1608 * @param integer $rows the height for textarea
1609 * @param integer $cols the width for textarea
1610 * @param string $desturl URI to redirect
1613 public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
1615 global $member, $CONF, $memberid;
1617 if ( $desturl == '' )
1619 if ( $CONF['URLMode'] == 'pathinfo' )
1621 $desturl = Link::create_member_link($memberid);
1625 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
1629 $message = postVar('message');
1630 $frommail = postVar('frommail');
1632 $this->formdata = array(
1633 'url' => Entity::hsc($desturl),
1634 'actionurl' => Entity::hsc($CONF['ActionURL']),
1635 'memberid' => $memberid,
1638 'message' => Entity::hsc($message),
1639 'frommail' => Entity::hsc($frommail)
1642 if ( $member->isLoggedIn() )
1644 $this->doForm('membermailform-loggedin');
1646 else if ( $CONF['NonmemberMail'] )
1648 $this->doForm('membermailform-notloggedin');
1652 $this->doForm('membermailform-disallowed');
1658 * Actions::parse_nextarchive()
1659 * Parse skinvar nextarchive
1664 public function parse_nextarchive()
1666 global $archivenext;
1672 * Parse skinvar nextitem
1673 * (include itemid of next item)
1678 public function parse_nextitem()
1681 if ( isset($itemidnext) )
1683 echo (int)$itemidnext;
1689 * Actions::parse_nextitemtitle()
1690 * Parse skinvar nextitemtitle
1691 * (include itemtitle of next item)
1693 * @param string $format format of text
1696 public function parse_nextitemtitle($format = '')
1698 global $itemtitlenext;
1703 echo Entity::hen($itemtitlenext);
1706 echo $itemtitlenext;
1710 echo Entity::hsc($itemtitlenext);
1717 * Actions::parse_nextlink()
1718 * Parse skinvar nextlink
1720 * @param string $linktext text for content of anchor element
1721 * @param integer $amount the amount of items in a display
1722 * @param integer $recount increment from this value
1725 public function parse_nextlink($linktext = '', $amount = 10, $recount = '')
1727 global $itemidnext, $archivenext, $startpos;
1728 if ( $this->skintype == 'item' )
1730 $this->itemlink($itemidnext, $linktext);
1732 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
1734 $this->searchlink($amount, $startpos, 'next', $linktext, $recount);
1738 $this->archivelink($archivenext, $linktext);
1744 * Actions::parse_nucleusbutton()
1745 * Parse skinvar nucleusbutton
1747 * @param string $imgurl URL for image
1748 * @param integer $imgwidth width of image
1749 * @param integer $imgheidht height of image
1751 public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')
1754 if ( $imgurl == '' )
1756 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
1758 else if ( Parser::getProperty('IncludeMode') == 'skindir' )
1760 // when skindit IncludeMode is used: start from skindir
1761 $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
1764 $this->formdata = array(
1765 'imgurl' => $imgurl,
1766 'imgwidth' => $imgwidth,
1767 'imgheight' => $imgheight,
1769 $this->doForm('nucleusbutton');
1774 * Actions::parse_otherarchive()
1775 * Parse skinvar otherarchive
1777 * @param string $blogname name of weblog
1778 * @param string $template name of template
1779 * @param string $category name of category
1782 public function parse_otherarchive($blogname, $template, $category = '')
1784 global $archive, $manager;
1785 sscanf($archive,'%d-%d-%d',$y,$m,$d);
1786 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1787 $this->setBlogCategory($b, $category);
1788 $this->preBlogContent('otherachive',$b);
1789 $b->showArchive($template, $y, $m, $d);
1790 $this->postBlogContent('otherachive',$b);
1795 * Actions::parse_otherarchivedaylist()
1796 * Parse skinvar otherarchivedaylist
1798 * @param string $blogname name of weblog
1799 * @param string $template name of template
1800 * @param string $category name of category
1801 * @param integer $limit the amount of items in a display
1804 public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)
1807 if ( $category == 'all')
1811 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1812 $this->setBlogCategory($b, $category);
1813 $this->preBlogContent('otherarchivelist',$b);
1814 $b->showArchiveList($template, 'day', $limit);
1815 $this->postBlogContent('otherarchivelist',$b);
1820 * Actions::parse_otherarchivelist()
1821 * Parse skinvar otherarchivelist
1823 * @param string $blogname name of weblog
1824 * @param string $template name of template
1825 * @param string $category name of category
1826 * @param integer $limit the amount of items in a display
1829 public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)
1832 if ( $category == 'all' )
1836 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1837 $this->setBlogCategory($b, $category);
1838 $this->preBlogContent('otherarchivelist',$b);
1839 $b->showArchiveList($template, 'month', $limit);
1840 $this->postBlogContent('otherarchivelist',$b);
1845 * Actions::parse_otherarchiveyearlist()
1846 * Parse skinvar otherarchiveyearlist
1848 * @param string $blogname name of weblog
1849 * @param string $template name of template
1850 * @param string $category name of category
1851 * @limit integer $limit the amount of items in a display
1853 public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)
1856 if ( $category == 'all' )
1860 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1861 $this->setBlogCategory($b, $category);
1862 $this->preBlogContent('otherarchivelist',$b);
1863 $b->showArchiveList($template, 'year', $limit);
1864 $this->postBlogContent('otherarchivelist',$b);
1869 * Actions::parse_otherblog()
1870 * Parse skinvar otherblog
1872 * @param string $blogname name of weblog
1873 * @param string $template name of template
1874 * @param mixed $amount the amount of items, in case it includes the beginning
1875 * @param string $category name of category
1878 public function parse_otherblog($blogname, $template, $amount = 10, $category = '')
1882 list($limit, $offset) = sscanf($amount, '%d(%d)');
1884 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1885 $this->setBlogCategory($b, $category);
1886 $this->preBlogContent('otherblog',$b);
1887 $this->amountfound = $b->readLog($template, $limit, $offset);
1888 $this->postBlogContent('otherblog',$b);
1893 * Actions::parse_othersearchresults()
1894 * Parse skinvar othersearchresults
1896 * @param string $blogname name of weblog
1897 * @param string $template name of template
1898 * @param integer $maxresults the amount of results
1901 public function parse_othersearchresults($blogname, $template, $maxresults = 50)
1903 global $query, $amount, $manager, $startpos;
1904 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1905 // need this to select default category
1906 $this->setBlogCategory($b, '');
1907 $this->preBlogContent('othersearchresults',$b);
1908 $b->search($query, $template, $amount, $maxresults, $startpos);
1909 $this->postBlogContent('othersearchresults',$b);
1914 * Actions::parse_plugin()
1915 * Executes a plugin skinvar
1916 * extra parameters can be added
1918 * @param string $pluginName name of plugin (without the NP_)
1921 public function parse_plugin($pluginName)
1925 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1932 $params = func_get_args();
1934 // remove plugin name
1935 array_shift($params);
1937 // add skin type on front
1938 array_unshift($params, $this->skintype);
1941 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1943 call_user_func_array(array($plugin,'doSkinVar'), $params);
1944 >>>>>>> skinnable-master
1949 * Actions::parse_prevarchive()
1950 * Parse skinvar prevarchive
1955 public function parse_prevarchive()
1957 global $archiveprev;
1962 * Actions::parse_preview()
1963 * Parse skinvar preview
1965 * @param string $template name of tempalte
1968 public function parse_preview($template)
1970 global $blog, $CONF, $manager;
1972 $template =& $manager->getTemplate($template);
1974 $row['body'] = '<span id="prevbody"></span>';
1975 $row['title'] = '<span id="prevtitle"></span>';
1976 $row['more'] = '<span id="prevmore"></span>';
1977 $row['itemlink'] = '';
1978 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1980 echo Template::fill($template['ITEM_HEADER'],$row);
1981 echo Template::fill($template['ITEM'],$row);
1982 echo Template::fill($template['ITEM_FOOTER'],$row);
1987 * Actions::parse_previtem()
1988 * Parse skinvar previtem
1989 * (include itemid of prev item)
1994 public function parse_previtem()
1997 if ( isset($itemidprev) )
1999 echo (integer) $itemidprev;
2005 * Actions::parse_previtemtitle()
2006 * Parse skinvar previtemtitle
2007 * (include itemtitle of prev item)
2009 * @param String $format string format
2010 * @return String formatted string
2012 public function parse_previtemtitle($format = '')
2014 global $itemtitleprev;
2019 echo Entity::hen($itemtitleprev);
2022 echo $itemtitleprev;
2026 echo Entity::hsc($itemtitleprev);
2033 * Actions::parse_prevlink()
2034 * Parse skinvar prevlink
2036 * @param string $linktext text as a content of anchor element
2037 * @param integer the amount of links
2040 public function parse_prevlink($linktext = '', $amount = 10)
2042 global $itemidprev, $archiveprev, $startpos;
2044 if ( $this->skintype == 'item' )
2046 $this->itemlink($itemidprev, $linktext);
2048 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
2050 $this->searchlink($amount, $startpos, 'prev', $linktext);
2054 $this->archivelink($archiveprev, $linktext);
2060 * Actions::parse_query()
2061 * Parse skinvar query
2062 * (includes the search query)
2067 public function parse_query()
2070 echo Entity::hsc($query);
2075 * Actions::parse_referer()
2076 * Parse skinvar referer
2081 public function parse_referer()
2083 echo Entity::hsc(serverVar('HTTP_REFERER'));
2088 * Actions::parse_searchform()
2089 * Parse skinvar searchform
2091 * @param string $blogname name of weblog
2094 public function parse_searchform($blogname = '')
2096 global $CONF, $manager, $maxresults;
2099 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
2105 // use default blog when no blog is selected
2106 $this->formdata = array(
2107 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
2108 'query' => Entity::hsc(getVar('query')),
2110 $this->doForm('searchform');
2115 * Actions::parse_searchresults()
2116 * Parse skinvar searchresults
2118 * @param string $template name of tempalte
2119 * @param integer $maxresults searched items in a display
2122 public function parse_searchresults($template, $maxresults = 50 )
2124 global $blog, $query, $amount, $startpos;
2126 $this->setBlogCategory($blog, ''); // need this to select default category
2127 $this->preBlogContent('searchresults',$blog);
2128 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
2129 $this->postBlogContent('searchresults',$blog);
2134 * Actions::parse_self()
2135 * Parse skinvar self
2140 public function parse_self()
2148 * Actions::parse_sitevar()
2149 * Parse skinvar sitevar
2150 * (include a sitevar)
2152 * @param string $which
2155 public function parse_sitevar($which)
2161 echo $CONF['IndexURL'];
2164 echo $CONF['SiteName'];
2167 echo $CONF['AdminEmail'];
2170 echo $CONF['AdminURL'];
2176 * Actions::parse_skinname()
2182 public function parse_skinname()
2184 echo $this->parser->skin->getName();
2189 * Actions::parse_skintype()
2190 * Parse skintype (experimental)
2195 public function parse_skintype()
2197 echo $this->skintype;
2202 * Actions::parse_ticket()
2208 public function parse_ticket()
2211 $manager->addTicketHidden();
2216 * Actions::parse_todaylink()
2217 * Parse skinvar todaylink
2218 * A link to the today page (depending on selected blog, etc...)
2220 * @param string $linktext text for link
2223 public function parse_todaylink($linktext = '')
2225 global $blog, $CONF;
2228 echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
2232 echo $this->link($CONF['SiteUrl'], $linktext);
2239 * When commentform is not used, to include a hidden field with itemid
2244 public function parse_vars()
2247 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";
2252 * Actions::parse_version()
2253 * Parse skinvar version
2254 * (include nucleus versionnumber)
2259 public function parse_version()
2262 echo 'Nucleus CMS ' . $nucleus['version'];
2267 * Actions::parse_sticky()
2268 * Parse skinvar sticky
2270 * @param integer $itemnumber id of item
2271 * @param string $template name of template
2275 public function parse_sticky($itemnumber = 0, $template = '')
2279 $itemnumber = intval($itemnumber);
2280 $itemarray = array($itemnumber);
2282 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
2283 $this->preBlogContent('sticky',$b);
2284 $this->amountfound = $b->readLogFromList($itemarray, $template);
2285 $this->postBlogContent('sticky',$b);
2287 public function parse_sticky($itemid = 0, $template = '')
2291 $itemid = (integer) $itemid;
2292 $itemarray = array($itemid);
2294 $item =& $manager->getItem($post['itemid'], 1, 1);
2295 $blog =& $manager->getBlog($item['blogid']);
2297 $this->preBlogContent('sticky', $blog);
2298 $this->amountfound = $blog->readLogFromList($itemarray, $template);
2299 $this->postBlogContent('sticky', $blog);
2300 >>>>>>> skinnable-master