3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2009 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-2009 The Nucleus Group
21 * @version $Id: ACTIONS.php 1624 2012-01-09 11:36:20Z 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 * Constructor for a new ACTIONS object
48 function ACTIONS($type) {
49 // call constructor of superclass first
52 $this->skintype = $type;
56 $this->linkparams = array('catid' => $catid);
62 function setSkin(&$skin) {
69 function setParser(&$parser) {
70 $this->parser =& $parser;
74 * Forms get parsedincluded now, using an extra <formdata> skinvar
76 function doForm($filename) {
78 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');
79 $oldIncludeMode = PARSER::getProperty('IncludeMode');
80 $oldIncludePrefix = PARSER::getProperty('IncludePrefix');
81 PARSER::setProperty('IncludeMode','normal');
82 PARSER::setProperty('IncludePrefix','');
83 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
84 PARSER::setProperty('IncludeMode',$oldIncludeMode);
85 PARSER::setProperty('IncludePrefix',$oldIncludePrefix);
86 array_pop($this->parser->actions); // errordiv
87 array_pop($this->parser->actions); // callback
88 array_pop($this->parser->actions); // text
89 array_pop($this->parser->actions); // formdata
90 array_pop($this->parser->actions); // ticket
94 * Checks conditions for if statements
96 * @param string $field type of <%if%>
97 * @param string $name property of field
98 * @param string $value value of property
100 function checkCondition($field, $name='', $value = '') {
101 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
106 $condition = ($blog && $this->_ifCategory($name,$value));
109 $condition = ($blog && ($blog->getSetting($name) == $value));
112 $condition = $member->isLoggedIn();
115 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
118 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
121 $condition = ($itemidnext != '');
124 $condition = ($itemidprev != '');
126 case 'archiveprevexists':
127 $condition = ($archiveprevexists == true);
129 case 'archivenextexists':
130 $condition = ($archivenextexists == true);
133 $condition = ($name == $this->skintype);
136 $condition = $this->_ifHasPlugin($name, $value);
139 $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);
147 * -> checks if plugin exists
148 * hasplugin,PlugName,OptionName
149 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
150 * hasplugin,PlugName,OptionName=value
151 * -> checks if the option OptionName from plugin PlugName is set to value
153 function _ifHasPlugin($name, $value) {
156 // (pluginInstalled method won't write a message in the actionlog on failure)
157 if ($manager->pluginInstalled('NP_'.$name)) {
158 $plugin =& $manager->getPlugin('NP_' . $name);
159 if ($plugin != NULL) {
163 list($name2, $value2) = i18n::explode('=', $value, 2);
164 if ($value2 == "" && $plugin->getOption($name2) != 'no') {
166 } else if ($plugin->getOption($name2) == $value2) {
176 * Checks if a plugin exists and call its doIf function
178 function _ifPlugin($name, $key = '', $value = '') {
181 $plugin =& $manager->getPlugin('NP_' . $name);
182 if (!$plugin) return;
184 $params = func_get_args();
185 array_shift($params);
187 return call_user_func_array(array(&$plugin, 'doIf'), $params);
191 * Different checks for a category
193 function _ifCategory($name = '', $value='') {
194 global $blog, $catid;
196 // when no parameter is defined, just check if a category is selected
197 if (($name != 'catname' && $name != 'catid') || ($value == ''))
198 return $blog->isValidCategory($catid);
200 // check category name
201 if ($name == 'catname') {
202 $value = $blog->getCategoryIdFromName($value);
203 if ($value == $catid)
204 return $blog->isValidCategory($catid);
208 if (($name == 'catid') && ($value == $catid))
209 return $blog->isValidCategory($catid);
215 * Checks if a member is on the team of a blog and return his rights
217 function _ifOnTeam($blogName = '') {
218 global $blog, $member, $manager;
220 // when no blog found
221 if (($blogName == '') && (!is_object($blog)))
224 // explicit blog selection
226 $blogid = getBlogIDFromName($blogName);
228 if (($blogName == '') || !$manager->existsBlogID($blogid))
230 $blogid = $blog->getID();
232 return $member->teamRights($blogid);
236 * Checks if a member is admin of a blog
238 function _ifAdmin($blogName = '') {
239 global $blog, $member, $manager;
241 // when no blog found
242 if (($blogName == '') && (!is_object($blog)))
245 // explicit blog selection
247 $blogid = getBlogIDFromName($blogName);
249 if (($blogName == '') || !$manager->existsBlogID($blogid))
251 $blogid = $blog->getID();
253 return $member->isBlogAdmin($blogid);
258 * - a raw link (html/xml encoded) when no linktext is provided
259 * - a (x)html <a href... link when a text is present (text htmlencoded)
261 function _link($url, $linktext = '')
263 $u = ENTITY::hsc($url);
264 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands
266 $l = '<a href="' . $u .'">'.ENTITY::hsc($linktext).'</a>';
273 * Outputs a next/prev link
276 * The maximum amount of items shown per page (e.g. 10)
278 * Current start position (requestVar('startpos'))
280 * either 'prev' or 'next'
282 * When present, the output will be a full <a href...> link. When empty,
283 * only a raw link will be outputted
285 function _searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '') {
286 global $CONF, $blog, $query, $amount;
287 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
288 $startpos = intval($startpos); // will be 0 when empty.
289 $parsed = parse_url(serverVar('REQUEST_URI'));
290 $path = $parsed['path'];
291 $parsed = $parsed['query'];
294 switch ($direction) {
296 if ( intval($startpos) - intval($maxresults) >= 0) {
297 $startpos = intval($startpos) - intval($maxresults);
298 //$url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
299 switch ($this->skintype)
305 $url = $CONF['SearchURL'];
308 $url .= '?'.alterQueryStr($parsed,'startpos',$startpos);
313 global $navigationItems;
314 if (!isset($navigationItems)) $navigationItems = 0;
319 $iAmountOnPage = $this->amountfound;
321 if (intval($navigationItems) > 0) {
322 $iAmountOnPage = intval($navigationItems) - intval($startpos);
324 elseif ($iAmountOnPage == 0)
326 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
328 switch ($this->skintype)
331 $sqlquery = $blog->getSqlBlog('', 'count');
335 $unused_highlight = '';
336 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
337 $url = $CONF['SearchURL'];
341 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
344 if (intval($iAmountOnPage) >= intval($maxresults)) {
345 $startpos = intval($startpos) + intval($maxresults);
346 //$url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
347 $url .= '?'.alterQueryStr($parsed,'startpos',$startpos);
353 } // switch($direction)
356 echo $this->_link($url, $linktext);
360 * ACTIONS::_itemlink()
361 * Creates an item link and if no id is given a todaylink
363 * @param Integer $id id for link
364 * @param String $linktext text for link
367 function _itemlink($id, $linktext = '')
372 echo $this->_link(LINK::create_item_link($id, $this->linkparams), $linktext);
376 $this->parse_todaylink($linktext);
382 * ACTIONS::_archivelink)
383 * Creates an archive link and if no id is given a todaylink
385 * @param Integer $id id for link
386 * @param String $linktext text for link
389 function _archivelink($id, $linktext = '')
394 echo $this->_link(LINK::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
398 $this->parse_todaylink($linktext);
404 * Helper function that sets the category that a blog will need to use
407 * An object of the blog class, passed by reference (we want to make changes to it)
409 * The name of the category to use
411 function _setBlogCategory(&$blog, $catname) {
414 $blog->setSelectedCategoryByName($catname);
416 $blog->setSelectedCategory($catid);
420 * Notifies the Manager that a PreBlogContent event occurs
422 function _preBlogContent($type, &$blog) {
424 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
428 * Notifies the Manager that a PostBlogContent event occurs
430 function _postBlogContent($type, &$blog) {
432 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
436 * Parse skinvar additemform
438 function parse_additemform() {
440 $this->formdata = array(
441 'adminurl' => ENTITY::hsc($CONF['AdminURL']),
442 'catid' => $blog->getDefaultCategory()
444 $blog->InsertJavaScriptInfo();
445 $this->doForm('additemform');
449 * Parse skinvar addlink
450 * A Link that allows to open a bookmarklet to add an item
452 function parse_addlink() {
453 global $CONF, $member, $blog;
454 if ($member->isLoggedIn() && $member->isTeamMember($blog->blogid) ) {
455 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
460 * Parse skinvar addpopupcode
461 * Code that opens a bookmarklet in an popup window
463 function parse_addpopupcode() {
464 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;";
468 * Parse skinvar adminurl
469 * (shortcut for admin url)
471 function parse_adminurl() {
472 $this->parse_sitevar('adminurl');
476 * Parse skinvar archive
478 function parse_archive($template, $category = '') {
479 global $blog, $archive;
480 // can be used with either yyyy-mm or yyyy-mm-dd
481 sscanf($archive,'%d-%d-%d',$y,$m,$d);
482 $this->_setBlogCategory($blog, $category);
483 $this->_preBlogContent('achive',$blog);
484 $blog->showArchive($template, $y, $m, $d);
485 $this->_postBlogContent('achive',$blog);
490 * %archivedate(locale,date format)%
492 function parse_archivedate($locale = '-def-') {
495 if ($locale == '-def-')
496 setlocale(LC_TIME,$template['LOCALE']);
498 setlocale(LC_TIME,$locale);
501 sscanf($archive,'%d-%d-%d',$y,$m,$d);
504 $args = func_get_args();
505 // format can be spread over multiple parameters
506 if (sizeof($args) > 1) {
510 $format=implode(',',$args);
511 } elseif ($d == 0 && $m !=0) {
516 $format = '%d %B %Y';
519 echo i18n::strftime($format,mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
523 * Parse skinvar archivedaylist
525 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
527 if ($category == 'all') $category = '';
528 $this->_preBlogContent('archivelist',$blog);
529 $this->_setBlogCategory($blog, $category);
530 $blog->showArchiveList($template, 'day', $limit);
531 $this->_postBlogContent('archivelist',$blog);
535 * ACTIONS::parse_archivelink()
536 * A link to the archives for the current blog (or for default blog)
538 * @param String $linktext text for link
541 function parse_archivelink($linktext = '')
546 echo $this->_link(LINK::create_archivelist_link($blog->getID(),$this->linkparams), $linktext);
550 echo $this->_link(LINK::create_archivelist_link(), $linktext);
555 function parse_archivelist($template, $category = 'all', $limit = 0) {
557 if ($category == 'all') $category = '';
558 $this->_preBlogContent('archivelist',$blog);
559 $this->_setBlogCategory($blog, $category);
560 $blog->showArchiveList($template, 'month', $limit);
561 $this->_postBlogContent('archivelist',$blog);
564 function parse_archiveyearlist($template, $category = 'all', $limit = 0) {
566 if ($category == 'all') $category = '';
567 $this->_preBlogContent('archivelist',$blog);
568 $this->_setBlogCategory($blog, $category);
569 $blog->showArchiveList($template, 'year', $limit);
570 $this->_postBlogContent('archivelist',$blog);
574 * Parse skinvar archivetype
576 function parse_archivetype() {
584 function parse_blog($template, $amount = 10, $category = '') {
585 global $blog, $startpos;
587 list($limit, $offset) = sscanf($amount, '%d(%d)');
588 $this->_setBlogCategory($blog, $category);
589 $this->_preBlogContent('blog',$blog);
590 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
591 $this->_postBlogContent('blog',$blog);
595 * Parse skinvar bloglist
596 * Shows a list of all blogs
597 * bnametype: whether 'name' or 'shortname' is used for the link text
598 * orderby: order criteria
599 * direction: order ascending or descending
601 function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') {
602 BLOG::showBlogList($template, $bnametype, $orderby, $direction);
606 * Parse skinvar blogsetting
608 function parse_blogsetting($which) {
612 echo ENTITY::hsc($blog->getID());
615 echo ENTITY::hsc($blog->getURL());
618 echo ENTITY::hsc($blog->getName());
621 echo ENTITY::hsc($blog->getDescription());
624 echo ENTITY::hsc($blog->getShortName());
632 function parse_callback($eventName, $type)
635 $manager->notify($eventName, array('type' => $type));
639 * Parse skinvar category
641 function parse_category($type = 'name') {
642 global $catid, $blog;
643 if (!$blog->isValidCategory($catid))
648 echo $blog->getCategoryName($catid);
651 echo $blog->getCategoryDesc($catid);
662 function parse_categorylist($template, $blogname = '') {
663 global $blog, $manager;
665 // when no blog found
666 if (($blogname == '') && (!is_object($blog)))
669 if ($blogname == '') {
670 $this->_preBlogContent('categorylist',$blog);
671 $blog->showCategoryList($template);
672 $this->_postBlogContent('categorylist',$blog);
674 $b =& $manager->getBlog(getBlogIDFromName($blogname));
675 $this->_preBlogContent('categorylist',$b);
676 $b->showCategoryList($template);
677 $this->_postBlogContent('categorylist',$b);
682 * Parse skinvar charset
684 function parse_charset() {
685 echo i18n::get_current_charset();
689 * ACTIONS::parse_commentform()
690 * Parse skinvar commentform
692 * @param String $destinationurl URI for redirection
695 function parse_commentform($destinationurl = '')
697 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
699 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
700 if ( stristr($destinationurl, 'action.php') )
702 $args = func_get_args();
703 $destinationurl = $args[1];
704 ACTIONLOG::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
707 $actionurl = $CONF['ActionURL'];
709 // if item is closed, show message and do nothing
710 $item =& $manager->getItem($itemid,0,0);
711 if ( $item['closed'] || !$blog->commentsEnabled() )
713 $this->doForm('commentform-closed');
717 if ( !$blog->isPublic() && !$member->isLoggedIn() )
719 $this->doForm('commentform-closedtopublic');
723 if ( !$destinationurl )
725 // note: createLink returns an HTML encoded URL
726 $destinationurl = LINK::create_link(
730 'title' => $item['title'],
731 'timestamp' => $item['timestamp'],
732 'extra' => $this->linkparams
739 $destinationurl = ENTITY::hsc($destinationurl);
743 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
746 $user = postVar('user');
749 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
752 $userid = postVar('userid');
755 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
758 $email = postVar('email');
761 $body = postVar('body');
763 $this->formdata = array(
764 'destinationurl' => $destinationurl, // url is already HTML encoded
765 'actionurl' => ENTITY::hsc($actionurl),
767 'user' => ENTITY::hsc($user),
768 'userid' => ENTITY::hsc($userid),
769 'email' => ENTITY::hsc($email),
770 'body' => ENTITY::hsc($body),
771 'membername' => $member->getDisplayName(),
772 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
775 if ( !$member->isLoggedIn() )
777 $this->doForm('commentform-notloggedin');
781 $this->doForm('commentform-loggedin');
787 * Parse skinvar comments
788 * include comments for one item
790 function parse_comments($template) {
791 global $itemid, $manager, $blog, $highlight;
792 $template =& $manager->getTemplate($template);
794 // create parser object & action handler
795 $actions = new ITEMACTIONS($blog);
796 $parser = new PARSER($actions->getDefinedActions(),$actions);
797 $actions->setTemplate($template);
798 $actions->setParser($parser);
799 $item = ITEM::getitem($itemid, 0, 0);
800 $actions->setCurrentItem($item);
802 $comments = new COMMENTS($itemid);
803 $comments->setItemActions($actions);
804 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
810 function parse_errordiv() {
811 global $errormessage;
813 echo '<div class="error">', ENTITY::hsc($errormessage),'</div>';
817 * Parse skinvar errormessage
819 function parse_errormessage() {
820 global $errormessage;
827 function parse_formdata($what) {
828 echo $this->formdata[$what];
834 function parse_ifcat($text = '') {
837 $this->parse_if('category');
840 global $catid, $blog;
841 if ($blog->isValidCategory($catid))
847 * Parse skinvar image
849 function parse_image($what = 'imgtag') {
852 $imagetext = ENTITY::hsc(requestVar('imagetext'));
853 $imagepopup = requestVar('imagepopup');
854 $width = intRequestVar('width');
855 $height = intRequestVar('height');
856 $fullurl = ENTITY::hsc($CONF['MediaURL'] . $imagepopup);
875 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
881 * Parse skinvar imagetext
883 function parse_imagetext() {
884 echo ENTITY::hsc(requestVar('imagetext'));
889 * include one item (no comments)
891 function parse_item($template) {
892 global $blog, $itemid, $highlight;
893 $this->_setBlogCategory($blog, ''); // need this to select default category
894 $this->_preBlogContent('item',$blog);
895 $r = $blog->showOneitem($itemid, $template, $highlight);
897 echo _ERROR_NOSUCHITEM;
898 $this->_postBlogContent('item',$blog);
902 * Parse skinvar itemid
904 function parse_itemid() {
910 * Parse skinvar itemlink
912 function parse_itemlink($linktext = '') {
914 $this->_itemlink($itemid, $linktext);
920 function parse_itemtitle($format = '') {
921 global $manager, $itemid;
922 $item =& $manager->getItem($itemid,0,0);
926 echo ENTITY::hen($item['title']);
933 echo ENTITY::hsc(strip_tags($item['title']));
939 * Parse skinvar loginform
941 function parse_loginform() {
942 global $member, $CONF;
943 if (!$member->isLoggedIn()) {
944 $filename = 'loginform-notloggedin';
945 $this->formdata = array();
947 $filename = 'loginform-loggedin';
948 $this->formdata = array(
949 'membername' => $member->getDisplayName(),
952 $this->doForm($filename);
956 * ACTIONS::parse_member()
957 * Parse skinvar member
958 * (includes a member info thingie)
960 * @param String $what which memberdata is needed
963 function parse_member($what)
965 global $memberinfo, $member, $CONF;
967 // 1. only allow the member-details-page specific variables on member pages
968 if ($this->skintype == 'member')
973 echo ENTITY::hsc($memberinfo->getDisplayName());
976 echo ENTITY::hsc($memberinfo->getRealName());
979 echo ENTITY::hsc($memberinfo->getNotes());
982 echo ENTITY::hsc($memberinfo->getURL());
985 echo ENTITY::hsc($memberinfo->getEmail());
988 echo ENTITY::hsc($memberinfo->getID());
993 // 2. the next bunch of options is available everywhere, as long as the user is logged in
994 if ( $member->isLoggedIn() )
999 echo $member->getDisplayName();
1001 case 'yourrealname':
1002 echo $member->getRealName();
1005 echo $member->getNotes();
1008 echo $member->getURL();
1011 echo $member->getEmail();
1014 echo $member->getID();
1016 case 'yourprofileurl':
1017 if ($CONF['URLMode'] == 'pathinfo')
1018 echo LINK::create_member_link($member->getID());
1020 echo $CONF['IndexURL'] . LINK::create_member_link($member->getID());
1028 * LINK::parse_membermailform()
1029 * Parse skinvar membermailform
1031 * @param Integer $rows the height for textarea
1032 * @param Integer $cols the width for textarea
1033 * @param String $desturl URI to redirect
1036 function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
1038 global $member, $CONF, $memberid;
1040 if ( $desturl == '' )
1042 if ( $CONF['URLMode'] == 'pathinfo' )
1044 $desturl = LINK::create_member_link($memberid);
1048 $desturl = $CONF['IndexURL'] . LINK::create_member_link($memberid);
1052 $message = postVar('message');
1053 $frommail = postVar('frommail');
1055 $this->formdata = array(
1056 'url' => ENTITY::hsc($desturl),
1057 'actionurl' => ENTITY::hsc($CONF['ActionURL']),
1058 'memberid' => $memberid,
1061 'message' => ENTITY::hsc($message),
1062 'frommail' => ENTITY::hsc($frommail)
1065 if ( $member->isLoggedIn() )
1067 $this->doForm('membermailform-loggedin');
1069 else if ( $CONF['NonmemberMail'] )
1071 $this->doForm('membermailform-notloggedin');
1075 $this->doForm('membermailform-disallowed');
1081 * Parse skinvar nextarchive
1083 function parse_nextarchive() {
1084 global $archivenext;
1089 * Parse skinvar nextitem
1090 * (include itemid of next item)
1092 function parse_nextitem() {
1094 if (isset($itemidnext)) echo (int)$itemidnext;
1098 * Parse skinvar nextitemtitle
1099 * (include itemtitle of next item)
1101 function parse_nextitemtitle($format = '') {
1102 global $itemtitlenext;
1107 echo ENTITY::hen($itemtitlenext);
1110 echo $itemtitlenext;
1114 echo ENTITY::hsc($itemtitlenext);
1120 * Parse skinvar nextlink
1122 function parse_nextlink($linktext = '', $amount = 10, $recount = '') {
1123 global $itemidnext, $archivenext, $startpos;
1124 if ($this->skintype == 'item')
1125 $this->_itemlink($itemidnext, $linktext);
1126 else if ($this->skintype == 'search' || $this->skintype == 'index')
1127 $this->_searchlink($amount, $startpos, 'next', $linktext, $recount);
1129 $this->_archivelink($archivenext, $linktext);
1133 * Parse skinvar nucleusbutton
1135 function parse_nucleusbutton($imgurl = '',
1137 $imgheight = '31') {
1139 if ($imgurl == '') {
1140 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
1141 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){
1142 // when skindit IncludeMode is used: start from skindir
1143 $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;
1146 $this->formdata = array(
1147 'imgurl' => $imgurl,
1148 'imgwidth' => $imgwidth,
1149 'imgheight' => $imgheight,
1151 $this->doForm('nucleusbutton');
1155 * Parse skinvar otherarchive
1157 function parse_otherarchive($blogname, $template, $category = '') {
1158 global $archive, $manager;
1159 sscanf($archive,'%d-%d-%d',$y,$m,$d);
1160 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1161 $this->_setBlogCategory($b, $category);
1162 $this->_preBlogContent('otherachive',$b);
1163 $b->showArchive($template, $y, $m, $d);
1164 $this->_postBlogContent('otherachive',$b);
1168 * Parse skinvar otherarchivedaylist
1170 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
1172 if ($category == 'all') $category = '';
1173 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1174 $this->_setBlogCategory($b, $category);
1175 $this->_preBlogContent('otherarchivelist',$b);
1176 $b->showArchiveList($template, 'day', $limit);
1177 $this->_postBlogContent('otherarchivelist',$b);
1181 * Parse skinvar otherarchivelist
1183 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
1185 if ($category == 'all') $category = '';
1186 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1187 $this->_setBlogCategory($b, $category);
1188 $this->_preBlogContent('otherarchivelist',$b);
1189 $b->showArchiveList($template, 'month', $limit);
1190 $this->_postBlogContent('otherarchivelist',$b);
1194 * Parse skinvar otherarchiveyearlist
1196 function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) {
1198 if ($category == 'all') $category = '';
1199 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1200 $this->_setBlogCategory($b, $category);
1201 $this->_preBlogContent('otherarchivelist',$b);
1202 $b->showArchiveList($template, 'year', $limit);
1203 $this->_postBlogContent('otherarchivelist',$b);
1207 * Parse skinvar otherblog
1209 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
1212 list($limit, $offset) = sscanf($amount, '%d(%d)');
1214 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1215 $this->_setBlogCategory($b, $category);
1216 $this->_preBlogContent('otherblog',$b);
1217 $this->amountfound = $b->readLog($template, $limit, $offset);
1218 $this->_postBlogContent('otherblog',$b);
1222 * Parse skinvar othersearchresults
1224 function parse_othersearchresults($blogname, $template, $maxresults = 50) {
1225 global $query, $amount, $manager, $startpos;
1226 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1227 $this->_setBlogCategory($b, ''); // need this to select default category
1228 $this->_preBlogContent('othersearchresults',$b);
1229 $b->search($query, $template, $amount, $maxresults, $startpos);
1230 $this->_postBlogContent('othersearchresults',$b);
1234 * Executes a plugin skinvar
1236 * @param pluginName name of plugin (without the NP_)
1238 * extra parameters can be added
1240 function parse_plugin($pluginName) {
1243 // should be already tested from the parser (PARSER.php)
1244 // only continue when the plugin is really installed
1245 /*if (!$manager->pluginInstalled('NP_' . $pluginName))
1248 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1249 if (!$plugin) return;
1252 $params = func_get_args();
1254 // remove plugin name
1255 array_shift($params);
1257 // add skin type on front
1258 array_unshift($params, $this->skintype);
1260 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1264 * Parse skinvar prevarchive
1266 function parse_prevarchive() {
1267 global $archiveprev;
1272 * Parse skinvar preview
1274 function parse_preview($template) {
1275 global $blog, $CONF, $manager;
1277 $template =& $manager->getTemplate($template);
1278 $row['body'] = '<span id="prevbody"></span>';
1279 $row['title'] = '<span id="prevtitle"></span>';
1280 $row['more'] = '<span id="prevmore"></span>';
1281 $row['itemlink'] = '';
1282 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1283 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);
1284 echo TEMPLATE::fill($template['ITEM'],$row);
1285 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);
1289 * Parse skinvar previtem
1290 * (include itemid of prev item)
1292 function parse_previtem() {
1294 if (isset($itemidprev)) echo (int)$itemidprev;
1298 * ACTIONS::parse_previtemtitle()
1299 * Parse skinvar previtemtitle
1300 * (include itemtitle of prev item)
1302 * @param String $format string format
1303 * @return String formatted string
1305 function parse_previtemtitle($format = '')
1307 global $itemtitleprev;
1312 echo ENTITY::hen($itemtitleprev);
1315 echo $itemtitleprev;
1319 echo ENTITY::hsc($itemtitleprev);
1326 * Parse skinvar prevlink
1328 function parse_prevlink($linktext = '', $amount = 10) {
1329 global $itemidprev, $archiveprev, $startpos;
1331 if ($this->skintype == 'item')
1332 $this->_itemlink($itemidprev, $linktext);
1333 else if ($this->skintype == 'search' || $this->skintype == 'index')
1334 $this->_searchlink($amount, $startpos, 'prev', $linktext);
1336 $this->_archivelink($archiveprev, $linktext);
1340 * Parse skinvar query
1341 * (includes the search query)
1343 function parse_query() {
1345 echo ENTITY::hsc($query);
1349 * Parse skinvar referer
1351 function parse_referer() {
1352 echo ENTITY::hsc(serverVar('HTTP_REFERER'));
1356 * Parse skinvar searchform
1358 function parse_searchform($blogname = '') {
1359 global $CONF, $manager, $maxresults;
1361 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
1365 // use default blog when no blog is selected
1366 $this->formdata = array(
1367 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
1368 'query' => ENTITY::hsc(getVar('query')),
1370 $this->doForm('searchform');
1374 * Parse skinvar searchresults
1376 function parse_searchresults($template, $maxresults = 50 ) {
1377 global $blog, $query, $amount, $startpos;
1379 $this->_setBlogCategory($blog, ''); // need this to select default category
1380 $this->_preBlogContent('searchresults',$blog);
1381 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
1382 $this->_postBlogContent('searchresults',$blog);
1386 * Parse skinvar self
1388 function parse_self() {
1394 * Parse skinvar sitevar
1395 * (include a sitevar)
1397 function parse_sitevar($which) {
1401 echo $CONF['IndexURL'];
1404 echo $CONF['SiteName'];
1407 echo $CONF['AdminEmail'];
1410 echo $CONF['AdminURL'];
1417 function parse_skinname() {
1418 echo $this->skin->getName();
1422 * Parse skintype (experimental)
1424 function parse_skintype() {
1425 echo $this->skintype;
1431 function parse_text($which) {
1432 // constant($which) only available from 4.0.4 :(
1433 if (defined($which)) {
1434 eval("echo $which;");
1441 function parse_ticket() {
1443 $manager->addTicketHidden();
1447 * ACTIONS::parse_todaylink()
1448 * Parse skinvar todaylink
1449 * A link to the today page (depending on selected blog, etc...)
1451 * @param String $linktext text for link
1454 function parse_todaylink($linktext = '')
1456 global $blog, $CONF;
1459 echo $this->_link(LINK::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
1463 echo $this->_link($CONF['SiteUrl'], $linktext);
1470 * When commentform is not used, to include a hidden field with itemid
1472 function parse_vars() {
1474 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
1478 * Parse skinvar version
1479 * (include nucleus versionnumber)
1481 function parse_version() {
1483 echo 'Nucleus CMS ' . $nucleus['version'];
1487 * Parse skinvar sticky
1489 function parse_sticky($itemnumber = 0, $template = '') {
1492 $itemnumber = intval($itemnumber);
1493 $itemarray = array($itemnumber);
1495 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
1496 $this->_preBlogContent('sticky',$b);
1497 $this->amountfound = $b->readLogFromList($itemarray, $template);
1498 $this->_postBlogContent('sticky',$b);