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 * Creates an item link and if no id is given a todaylink
362 function _itemlink($id, $linktext = '') {
365 echo $this->_link(createItemLink($id, $this->linkparams), $linktext);
367 $this->parse_todaylink($linktext);
371 * Creates an archive link and if no id is given a todaylink
373 function _archivelink($id, $linktext = '') {
376 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);
378 $this->parse_todaylink($linktext);
382 * Helper function that sets the category that a blog will need to use
385 * An object of the blog class, passed by reference (we want to make changes to it)
387 * The name of the category to use
389 function _setBlogCategory(&$blog, $catname) {
392 $blog->setSelectedCategoryByName($catname);
394 $blog->setSelectedCategory($catid);
398 * Notifies the Manager that a PreBlogContent event occurs
400 function _preBlogContent($type, &$blog) {
402 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
406 * Notifies the Manager that a PostBlogContent event occurs
408 function _postBlogContent($type, &$blog) {
410 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
414 * Parse skinvar additemform
416 function parse_additemform() {
418 $this->formdata = array(
419 'adminurl' => ENTITY::hsc($CONF['AdminURL']),
420 'catid' => $blog->getDefaultCategory()
422 $blog->InsertJavaScriptInfo();
423 $this->doForm('additemform');
427 * Parse skinvar addlink
428 * A Link that allows to open a bookmarklet to add an item
430 function parse_addlink() {
431 global $CONF, $member, $blog;
432 if ($member->isLoggedIn() && $member->isTeamMember($blog->blogid) ) {
433 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
438 * Parse skinvar addpopupcode
439 * Code that opens a bookmarklet in an popup window
441 function parse_addpopupcode() {
442 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;";
446 * Parse skinvar adminurl
447 * (shortcut for admin url)
449 function parse_adminurl() {
450 $this->parse_sitevar('adminurl');
454 * Parse skinvar archive
456 function parse_archive($template, $category = '') {
457 global $blog, $archive;
458 // can be used with either yyyy-mm or yyyy-mm-dd
459 sscanf($archive,'%d-%d-%d',$y,$m,$d);
460 $this->_setBlogCategory($blog, $category);
461 $this->_preBlogContent('achive',$blog);
462 $blog->showArchive($template, $y, $m, $d);
463 $this->_postBlogContent('achive',$blog);
468 * %archivedate(locale,date format)%
470 function parse_archivedate($locale = '-def-') {
473 if ($locale == '-def-')
474 setlocale(LC_TIME,$template['LOCALE']);
476 setlocale(LC_TIME,$locale);
479 sscanf($archive,'%d-%d-%d',$y,$m,$d);
482 $args = func_get_args();
483 // format can be spread over multiple parameters
484 if (sizeof($args) > 1) {
488 $format=implode(',',$args);
489 } elseif ($d == 0 && $m !=0) {
494 $format = '%d %B %Y';
497 echo i18n::strftime($format,mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
501 * Parse skinvar archivedaylist
503 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
505 if ($category == 'all') $category = '';
506 $this->_preBlogContent('archivelist',$blog);
507 $this->_setBlogCategory($blog, $category);
508 $blog->showArchiveList($template, 'day', $limit);
509 $this->_postBlogContent('archivelist',$blog);
513 * A link to the archives for the current blog (or for default blog)
515 function parse_archivelink($linktext = '') {
518 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);
520 echo $this->_link(createArchiveListLink(), $linktext);
523 function parse_archivelist($template, $category = 'all', $limit = 0) {
525 if ($category == 'all') $category = '';
526 $this->_preBlogContent('archivelist',$blog);
527 $this->_setBlogCategory($blog, $category);
528 $blog->showArchiveList($template, 'month', $limit);
529 $this->_postBlogContent('archivelist',$blog);
532 function parse_archiveyearlist($template, $category = 'all', $limit = 0) {
534 if ($category == 'all') $category = '';
535 $this->_preBlogContent('archivelist',$blog);
536 $this->_setBlogCategory($blog, $category);
537 $blog->showArchiveList($template, 'year', $limit);
538 $this->_postBlogContent('archivelist',$blog);
542 * Parse skinvar archivetype
544 function parse_archivetype() {
552 function parse_blog($template, $amount = 10, $category = '') {
553 global $blog, $startpos;
555 list($limit, $offset) = sscanf($amount, '%d(%d)');
556 $this->_setBlogCategory($blog, $category);
557 $this->_preBlogContent('blog',$blog);
558 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
559 $this->_postBlogContent('blog',$blog);
563 * Parse skinvar bloglist
564 * Shows a list of all blogs
565 * bnametype: whether 'name' or 'shortname' is used for the link text
566 * orderby: order criteria
567 * direction: order ascending or descending
569 function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') {
570 BLOG::showBlogList($template, $bnametype, $orderby, $direction);
574 * Parse skinvar blogsetting
576 function parse_blogsetting($which) {
580 echo ENTITY::hsc($blog->getID());
583 echo ENTITY::hsc($blog->getURL());
586 echo ENTITY::hsc($blog->getName());
589 echo ENTITY::hsc($blog->getDescription());
592 echo ENTITY::hsc($blog->getShortName());
600 function parse_callback($eventName, $type)
603 $manager->notify($eventName, array('type' => $type));
607 * Parse skinvar category
609 function parse_category($type = 'name') {
610 global $catid, $blog;
611 if (!$blog->isValidCategory($catid))
616 echo $blog->getCategoryName($catid);
619 echo $blog->getCategoryDesc($catid);
630 function parse_categorylist($template, $blogname = '') {
631 global $blog, $manager;
633 // when no blog found
634 if (($blogname == '') && (!is_object($blog)))
637 if ($blogname == '') {
638 $this->_preBlogContent('categorylist',$blog);
639 $blog->showCategoryList($template);
640 $this->_postBlogContent('categorylist',$blog);
642 $b =& $manager->getBlog(getBlogIDFromName($blogname));
643 $this->_preBlogContent('categorylist',$b);
644 $b->showCategoryList($template);
645 $this->_postBlogContent('categorylist',$b);
650 * Parse skinvar charset
652 function parse_charset() {
653 echo i18n::get_current_charset();
657 * Parse skinvar commentform
659 function parse_commentform($destinationurl = '') {
660 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
662 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
663 if (stristr($destinationurl, 'action.php')) {
664 $args = func_get_args();
665 $destinationurl = $args[1];
666 ACTIONLOG::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
669 $actionurl = $CONF['ActionURL'];
671 // if item is closed, show message and do nothing
672 $item =& $manager->getItem($itemid,0,0);
673 if ($item['closed'] || !$blog->commentsEnabled()) {
674 $this->doForm('commentform-closed');
678 if (!$blog->isPublic() && !$member->isLoggedIn()) {
679 $this->doForm('commentform-closedtopublic');
683 if (!$destinationurl)
685 $destinationurl = createLink(
689 'title' => $item['title'],
690 'timestamp' => $item['timestamp'],
691 'extra' => $this->linkparams
695 // note: createLink returns an HTML encoded URL
698 $destinationurl = ENTITY::hsc($destinationurl);
702 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
703 if (!$user) $user = postVar('user');
704 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
705 if (!$userid) $userid = postVar('userid');
706 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
708 $email = postVar('email');
710 $body = postVar('body');
712 $this->formdata = array(
713 'destinationurl' => $destinationurl, // url is already HTML encoded
714 'actionurl' => ENTITY::hsc($actionurl),
716 'user' => ENTITY::hsc($user),
717 'userid' => ENTITY::hsc($userid),
718 'email' => ENTITY::hsc($email),
719 'body' => ENTITY::hsc($body),
720 'membername' => $member->getDisplayName(),
721 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
724 if (!$member->isLoggedIn()) {
725 $this->doForm('commentform-notloggedin');
727 $this->doForm('commentform-loggedin');
732 * Parse skinvar comments
733 * include comments for one item
735 function parse_comments($template) {
736 global $itemid, $manager, $blog, $highlight;
737 $template =& $manager->getTemplate($template);
739 // create parser object & action handler
740 $actions = new ITEMACTIONS($blog);
741 $parser = new PARSER($actions->getDefinedActions(),$actions);
742 $actions->setTemplate($template);
743 $actions->setParser($parser);
744 $item = ITEM::getitem($itemid, 0, 0);
745 $actions->setCurrentItem($item);
747 $comments = new COMMENTS($itemid);
748 $comments->setItemActions($actions);
749 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
755 function parse_errordiv() {
756 global $errormessage;
758 echo '<div class="error">', ENTITY::hsc($errormessage),'</div>';
762 * Parse skinvar errormessage
764 function parse_errormessage() {
765 global $errormessage;
772 function parse_formdata($what) {
773 echo $this->formdata[$what];
779 function parse_ifcat($text = '') {
782 $this->parse_if('category');
785 global $catid, $blog;
786 if ($blog->isValidCategory($catid))
792 * Parse skinvar image
794 function parse_image($what = 'imgtag') {
797 $imagetext = ENTITY::hsc(requestVar('imagetext'));
798 $imagepopup = requestVar('imagepopup');
799 $width = intRequestVar('width');
800 $height = intRequestVar('height');
801 $fullurl = ENTITY::hsc($CONF['MediaURL'] . $imagepopup);
820 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
826 * Parse skinvar imagetext
828 function parse_imagetext() {
829 echo ENTITY::hsc(requestVar('imagetext'));
834 * include one item (no comments)
836 function parse_item($template) {
837 global $blog, $itemid, $highlight;
838 $this->_setBlogCategory($blog, ''); // need this to select default category
839 $this->_preBlogContent('item',$blog);
840 $r = $blog->showOneitem($itemid, $template, $highlight);
842 echo _ERROR_NOSUCHITEM;
843 $this->_postBlogContent('item',$blog);
847 * Parse skinvar itemid
849 function parse_itemid() {
855 * Parse skinvar itemlink
857 function parse_itemlink($linktext = '') {
859 $this->_itemlink($itemid, $linktext);
865 function parse_itemtitle($format = '') {
866 global $manager, $itemid;
867 $item =& $manager->getItem($itemid,0,0);
871 echo stringToXML ($item['title']);
874 echo stringToAttribute ($item['title']);
880 echo ENTITY::hsc(strip_tags($item['title']));
886 * Parse skinvar loginform
888 function parse_loginform() {
889 global $member, $CONF;
890 if (!$member->isLoggedIn()) {
891 $filename = 'loginform-notloggedin';
892 $this->formdata = array();
894 $filename = 'loginform-loggedin';
895 $this->formdata = array(
896 'membername' => $member->getDisplayName(),
899 $this->doForm($filename);
903 * Parse skinvar member
904 * (includes a member info thingie)
906 function parse_member($what) {
907 global $memberinfo, $member, $CONF;
909 // 1. only allow the member-details-page specific variables on member pages
910 if ($this->skintype == 'member') {
914 echo ENTITY::hsc($memberinfo->getDisplayName());
917 echo ENTITY::hsc($memberinfo->getRealName());
920 echo ENTITY::hsc($memberinfo->getNotes());
923 echo ENTITY::hsc($memberinfo->getURL());
926 echo ENTITY::hsc($memberinfo->getEmail());
929 echo ENTITY::hsc($memberinfo->getID());
934 // 2. the next bunch of options is available everywhere, as long as the user is logged in
935 if ($member->isLoggedIn())
939 echo $member->getDisplayName();
942 echo $member->getRealName();
945 echo $member->getNotes();
948 echo $member->getURL();
951 echo $member->getEmail();
954 echo $member->getID();
956 case 'yourprofileurl':
957 if ($CONF['URLMode'] == 'pathinfo')
958 echo createMemberLink($member->getID());
960 echo $CONF['IndexURL'] . createMemberLink($member->getID());
968 * Parse skinvar membermailform
970 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {
971 global $member, $CONF, $memberid;
973 if ($desturl == '') {
974 if ($CONF['URLMode'] == 'pathinfo')
975 $desturl = createMemberLink($memberid);
977 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);
980 $message = postVar('message');
981 $frommail = postVar('frommail');
983 $this->formdata = array(
984 'url' => ENTITY::hsc($desturl),
985 'actionurl' => ENTITY::hsc($CONF['ActionURL']),
986 'memberid' => $memberid,
989 'message' => ENTITY::hsc($message),
990 'frommail' => ENTITY::hsc($frommail)
992 if ($member->isLoggedIn()) {
993 $this->doForm('membermailform-loggedin');
994 } else if ($CONF['NonmemberMail']) {
995 $this->doForm('membermailform-notloggedin');
997 $this->doForm('membermailform-disallowed');
1003 * Parse skinvar nextarchive
1005 function parse_nextarchive() {
1006 global $archivenext;
1011 * Parse skinvar nextitem
1012 * (include itemid of next item)
1014 function parse_nextitem() {
1016 if (isset($itemidnext)) echo (int)$itemidnext;
1020 * Parse skinvar nextitemtitle
1021 * (include itemtitle of next item)
1023 function parse_nextitemtitle($format = '') {
1024 global $itemtitlenext;
1028 echo stringToXML ($itemtitlenext);
1031 echo stringToAttribute ($itemtitlenext);
1034 echo $itemtitlenext;
1037 echo ENTITY::hsc($itemtitlenext);
1043 * Parse skinvar nextlink
1045 function parse_nextlink($linktext = '', $amount = 10, $recount = '') {
1046 global $itemidnext, $archivenext, $startpos;
1047 if ($this->skintype == 'item')
1048 $this->_itemlink($itemidnext, $linktext);
1049 else if ($this->skintype == 'search' || $this->skintype == 'index')
1050 $this->_searchlink($amount, $startpos, 'next', $linktext, $recount);
1052 $this->_archivelink($archivenext, $linktext);
1056 * Parse skinvar nucleusbutton
1058 function parse_nucleusbutton($imgurl = '',
1060 $imgheight = '31') {
1062 if ($imgurl == '') {
1063 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
1064 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){
1065 // when skindit IncludeMode is used: start from skindir
1066 $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;
1069 $this->formdata = array(
1070 'imgurl' => $imgurl,
1071 'imgwidth' => $imgwidth,
1072 'imgheight' => $imgheight,
1074 $this->doForm('nucleusbutton');
1078 * Parse skinvar otherarchive
1080 function parse_otherarchive($blogname, $template, $category = '') {
1081 global $archive, $manager;
1082 sscanf($archive,'%d-%d-%d',$y,$m,$d);
1083 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1084 $this->_setBlogCategory($b, $category);
1085 $this->_preBlogContent('otherachive',$b);
1086 $b->showArchive($template, $y, $m, $d);
1087 $this->_postBlogContent('otherachive',$b);
1091 * Parse skinvar otherarchivedaylist
1093 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
1095 if ($category == 'all') $category = '';
1096 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1097 $this->_setBlogCategory($b, $category);
1098 $this->_preBlogContent('otherarchivelist',$b);
1099 $b->showArchiveList($template, 'day', $limit);
1100 $this->_postBlogContent('otherarchivelist',$b);
1104 * Parse skinvar otherarchivelist
1106 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
1108 if ($category == 'all') $category = '';
1109 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1110 $this->_setBlogCategory($b, $category);
1111 $this->_preBlogContent('otherarchivelist',$b);
1112 $b->showArchiveList($template, 'month', $limit);
1113 $this->_postBlogContent('otherarchivelist',$b);
1117 * Parse skinvar otherarchiveyearlist
1119 function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) {
1121 if ($category == 'all') $category = '';
1122 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1123 $this->_setBlogCategory($b, $category);
1124 $this->_preBlogContent('otherarchivelist',$b);
1125 $b->showArchiveList($template, 'year', $limit);
1126 $this->_postBlogContent('otherarchivelist',$b);
1130 * Parse skinvar otherblog
1132 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
1135 list($limit, $offset) = sscanf($amount, '%d(%d)');
1137 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1138 $this->_setBlogCategory($b, $category);
1139 $this->_preBlogContent('otherblog',$b);
1140 $this->amountfound = $b->readLog($template, $limit, $offset);
1141 $this->_postBlogContent('otherblog',$b);
1145 * Parse skinvar othersearchresults
1147 function parse_othersearchresults($blogname, $template, $maxresults = 50) {
1148 global $query, $amount, $manager, $startpos;
1149 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1150 $this->_setBlogCategory($b, ''); // need this to select default category
1151 $this->_preBlogContent('othersearchresults',$b);
1152 $b->search($query, $template, $amount, $maxresults, $startpos);
1153 $this->_postBlogContent('othersearchresults',$b);
1157 * Executes a plugin skinvar
1159 * @param pluginName name of plugin (without the NP_)
1161 * extra parameters can be added
1163 function parse_plugin($pluginName) {
1166 // should be already tested from the parser (PARSER.php)
1167 // only continue when the plugin is really installed
1168 /*if (!$manager->pluginInstalled('NP_' . $pluginName))
1171 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1172 if (!$plugin) return;
1175 $params = func_get_args();
1177 // remove plugin name
1178 array_shift($params);
1180 // add skin type on front
1181 array_unshift($params, $this->skintype);
1183 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1187 * Parse skinvar prevarchive
1189 function parse_prevarchive() {
1190 global $archiveprev;
1195 * Parse skinvar preview
1197 function parse_preview($template) {
1198 global $blog, $CONF, $manager;
1200 $template =& $manager->getTemplate($template);
1201 $row['body'] = '<span id="prevbody"></span>';
1202 $row['title'] = '<span id="prevtitle"></span>';
1203 $row['more'] = '<span id="prevmore"></span>';
1204 $row['itemlink'] = '';
1205 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1206 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);
1207 echo TEMPLATE::fill($template['ITEM'],$row);
1208 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);
1212 * Parse skinvar previtem
1213 * (include itemid of prev item)
1215 function parse_previtem() {
1217 if (isset($itemidprev)) echo (int)$itemidprev;
1221 * Parse skinvar previtemtitle
1222 * (include itemtitle of prev item)
1224 function parse_previtemtitle($format = '') {
1225 global $itemtitleprev;
1229 echo stringToXML ($itemtitleprev);
1232 echo stringToAttribute ($itemtitleprev);
1235 echo $itemtitleprev;
1238 echo ENTITY::hsc($itemtitleprev);
1244 * Parse skinvar prevlink
1246 function parse_prevlink($linktext = '', $amount = 10) {
1247 global $itemidprev, $archiveprev, $startpos;
1249 if ($this->skintype == 'item')
1250 $this->_itemlink($itemidprev, $linktext);
1251 else if ($this->skintype == 'search' || $this->skintype == 'index')
1252 $this->_searchlink($amount, $startpos, 'prev', $linktext);
1254 $this->_archivelink($archiveprev, $linktext);
1258 * Parse skinvar query
1259 * (includes the search query)
1261 function parse_query() {
1263 echo ENTITY::hsc($query);
1267 * Parse skinvar referer
1269 function parse_referer() {
1270 echo ENTITY::hsc(serverVar('HTTP_REFERER'));
1274 * Parse skinvar searchform
1276 function parse_searchform($blogname = '') {
1277 global $CONF, $manager, $maxresults;
1279 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
1283 // use default blog when no blog is selected
1284 $this->formdata = array(
1285 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
1286 'query' => ENTITY::hsc(getVar('query')),
1288 $this->doForm('searchform');
1292 * Parse skinvar searchresults
1294 function parse_searchresults($template, $maxresults = 50 ) {
1295 global $blog, $query, $amount, $startpos;
1297 $this->_setBlogCategory($blog, ''); // need this to select default category
1298 $this->_preBlogContent('searchresults',$blog);
1299 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
1300 $this->_postBlogContent('searchresults',$blog);
1304 * Parse skinvar self
1306 function parse_self() {
1312 * Parse skinvar sitevar
1313 * (include a sitevar)
1315 function parse_sitevar($which) {
1319 echo $CONF['IndexURL'];
1322 echo $CONF['SiteName'];
1325 echo $CONF['AdminEmail'];
1328 echo $CONF['AdminURL'];
1335 function parse_skinname() {
1336 echo $this->skin->getName();
1340 * Parse skintype (experimental)
1342 function parse_skintype() {
1343 echo $this->skintype;
1349 function parse_text($which) {
1350 // constant($which) only available from 4.0.4 :(
1351 if (defined($which)) {
1352 eval("echo $which;");
1359 function parse_ticket() {
1361 $manager->addTicketHidden();
1365 * Parse skinvar todaylink
1366 * A link to the today page (depending on selected blog, etc...)
1368 function parse_todaylink($linktext = '') {
1369 global $blog, $CONF;
1371 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);
1373 echo $this->_link($CONF['SiteUrl'], $linktext);
1378 * When commentform is not used, to include a hidden field with itemid
1380 function parse_vars() {
1382 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
1386 * Parse skinvar version
1387 * (include nucleus versionnumber)
1389 function parse_version() {
1391 echo 'Nucleus CMS ' . $nucleus['version'];
1395 * Parse skinvar sticky
1397 function parse_sticky($itemnumber = 0, $template = '') {
1400 $itemnumber = intval($itemnumber);
1401 $itemarray = array($itemnumber);
1403 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
1404 $this->_preBlogContent('sticky',$b);
1405 $this->amountfound = $b->readLogFromList($itemarray, $template);
1406 $this->_postBlogContent('sticky',$b);