3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2007 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-2007 The Nucleus Group
21 * @version $Id: ACTIONS.php,v 1.5 2007-02-26 23:42:01 kmorimatsu Exp $
22 * @version $NucleusJP: ACTIONS.php,v 1.4 2007/02/04 06:28:45 kimitake Exp $
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 // reference to the skin object for which a part is being parsed
39 // used when including templated forms from the include/ dir. The $formdata var
40 // contains the values to fill out in there (assoc array name -> value)
44 // filled out with the number of displayed items after calling one of the
46 // (other)blog/(other)searchresults skinvars.
50 function ACTIONS($type) {
51 // call constructor of superclass first
54 $this->skintype = $type;
58 $this->linkparams = array('catid' => $catid);
61 function setSkin(&$skin) {
65 function setParser(&$parser) {
66 $this->parser =& $parser;
70 * Forms get parsedincluded now, using an extra <formdata> skinvar
72 function doForm($filename) {
74 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');
75 $oldIncludeMode = PARSER::getProperty('IncludeMode');
76 $oldIncludePrefix = PARSER::getProperty('IncludePrefix');
77 PARSER::setProperty('IncludeMode','normal');
78 PARSER::setProperty('IncludePrefix','');
79 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
80 PARSER::setProperty('IncludeMode',$oldIncludeMode);
81 PARSER::setProperty('IncludePrefix',$oldIncludePrefix);
82 array_pop($this->parser->actions); // errordiv
83 array_pop($this->parser->actions); // callback
84 array_pop($this->parser->actions); // text
85 array_pop($this->parser->actions); // formdata
86 array_pop($this->parser->actions); // ticket
90 * Checks conditions for if statements
92 * @param string $field type of <%if%>
93 * @param string $name property of field
94 * @param string $value value of property
96 function checkCondition($field, $name='', $value = '') {
97 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager;
102 $condition = ($blog && $this->_ifCategory($name,$value));
105 $condition = ($blog && ($blog->getSetting($name) == $value));
108 $condition = $member->isLoggedIn();
111 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
114 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
117 $condition = ($itemidnext != '');
120 $condition = ($itemidprev != '');
123 $condition = ($name == $this->skintype);
126 $condition = $this->_ifHasPlugin($name, $value);
129 $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);
137 * -> checks if plugin exists
138 * hasplugin,PlugName,OptionName
139 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
140 * hasplugin,PlugName,OptionName=value
141 * -> checks if the option OptionName from plugin PlugName is set to value
143 function _ifHasPlugin($name, $value) {
146 // (pluginInstalled method won't write a message in the actionlog on failure)
147 if ($manager->pluginInstalled('NP_'.$name)) {
148 $plugin =& $manager->getPlugin('NP_' . $name);
149 if ($plugin != NULL) {
153 list($name2, $value2) = explode('=', $value, 2);
154 if ($value2 == "" && $plugin->getOption($name2) != 'no') {
156 } else if ($plugin->getOption($name2) == $value2) {
165 function _ifPlugin($name, $key = '', $value = '') {
168 $plugin =& $manager->getPlugin('NP_' . $name);
169 if (!$plugin) return;
171 $params = func_get_args();
172 array_shift($params);
174 return call_user_func_array(array(&$plugin, 'doIf'), $params);
177 function _ifCategory($name = '', $value='') {
178 global $blog, $catid;
180 // when no parameter is defined, just check if a category is selected
181 if (($name != 'catname' && $name != 'catid') || ($value == ''))
182 return $blog->isValidCategory($catid);
184 // check category name
185 if ($name == 'catname') {
186 $value = $blog->getCategoryIdFromName($value);
187 if ($value == $catid)
188 return $blog->isValidCategory($catid);
192 if (($name == 'catid') && ($value == $catid))
193 return $blog->isValidCategory($catid);
198 function _ifOnTeam($blogName = '') {
199 global $blog, $member, $manager;
201 // when no blog found
202 if (($blogName == '') && (!is_object($blog)))
205 // explicit blog selection
207 $blogid = getBlogIDFromName($blogName);
209 if (($blogName == '') || !$manager->existsBlogID($blogid))
211 $blogid = $blog->getID();
213 return $member->teamRights($blogid);
216 function _ifAdmin($blogName = '') {
217 global $blog, $member, $manager;
219 // when no blog found
220 if (($blogName == '') && (!is_object($blog)))
223 // explicit blog selection
225 $blogid = getBlogIDFromName($blogName);
227 if (($blogName == '') || !$manager->existsBlogID($blogid))
229 $blogid = $blog->getID();
231 return $member->isBlogAdmin($blogid);
236 * - a raw link (html/xml encoded) when no linktext is provided
237 * - a (x)html <a href... link when a text is present (text htmlencoded)
239 function _link($url, $linktext = '')
241 $u = htmlspecialchars($url);
242 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands
244 $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>';
251 * Outputs a next/prev link
254 * The maximum amount of items shown per page (e.g. 10)
256 * Current start position (requestVar('startpos'))
258 * either 'prev' or 'next'
260 * When present, the output will be a full <a href...> link. When empty,
261 * only a raw link will be outputted
263 function _searchlink($maxresults, $startpos, $direction, $linktext = '') {
264 global $CONF, $blog, $query, $amount;
265 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
266 $startpos = intval($startpos); // will be 0 when empty.
267 $parsed = parse_url(serverVar('REQUEST_URI'));
268 $parsed = $parsed['query'];
271 switch ($direction) {
273 if ( intval($startpos) - intval($maxresults) >= 0) {
274 $startpos = intval($startpos) - intval($maxresults);
275 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
279 $iAmountOnPage = $this->amountfound;
280 if ($iAmountOnPage == 0)
282 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
284 switch ($this->skintype)
287 $sqlquery = $blog->getSqlBlog('', 'count');
290 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
294 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
296 if (intval($iAmountOnPage) >= intval($maxresults)) {
297 $startpos = intval($startpos) + intval($maxresults);
298 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
303 } // switch($direction)
306 echo $this->_link($url, $linktext);
309 function _itemlink($id, $linktext = '') {
312 echo $this->_link(createItemLink($id, $this->linkparams), $linktext);
314 $this->parse_todaylink($linktext);
317 function _archivelink($id, $linktext = '') {
320 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);
322 $this->parse_todaylink($linktext);
326 * Helper function that sets the category that a blog will need to use
329 * An object of the blog class, passed by reference (we want to make changes to it)
331 * The name of the category to use
333 function _setBlogCategory(&$blog, $catname) {
336 $blog->setSelectedCategoryByName($catname);
338 $blog->setSelectedCategory($catid);
341 function _preBlogContent($type, &$blog) {
343 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
346 function _postBlogContent($type, &$blog) {
348 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
352 * Parse skinvar additemform
354 function parse_additemform() {
356 $this->formdata = array(
357 'adminurl' => htmlspecialchars($CONF['AdminURL']),
358 'catid' => $blog->getDefaultCategory()
360 $blog->InsertJavaScriptInfo();
361 $this->doForm('additemform');
365 * Parse skinvar adminurl
366 * (shortcut for admin url)
368 function parse_adminurl() {
369 $this->parse_sitevar('adminurl');
373 * Parse skinvar archive
375 function parse_archive($template, $category = '') {
376 global $blog, $archive;
377 // can be used with either yyyy-mm or yyyy-mm-dd
378 sscanf($archive,'%d-%d-%d',$y,$m,$d);
379 $this->_setBlogCategory($blog, $category);
380 $this->_preBlogContent('achive',$blog);
381 $blog->showArchive($template, $y, $m, $d);
382 $this->_postBlogContent('achive',$blog);
387 * %archivedate(locale,date format)%
389 function parse_archivedate($locale = '-def-') {
392 if ($locale == '-def-')
393 setlocale(LC_TIME,$template['LOCALE']);
395 setlocale(LC_TIME,$locale);
398 sscanf($archive,'%d-%d-%d',$y,$m,$d);
401 $args = func_get_args();
402 // format can be spread over multiple parameters
403 if (sizeof($args) > 1) {
407 $format=implode(',',$args);
411 $format = '%d %B %Y';
414 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));
417 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
419 if ($category == 'all') $category = '';
420 $this->_preBlogContent('archivelist',$blog);
421 $this->_setBlogCategory($blog, $category);
422 $blog->showArchiveList($template, 'day', $limit);
423 $this->_postBlogContent('archivelist',$blog);
427 * A link to the archives for the current blog (or for default blog)
429 function parse_archivelink($linktext = '') {
432 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);
434 echo $this->_link(createArchiveListLink(), $linktext);
437 function parse_archivelist($template, $category = 'all', $limit = 0) {
439 if ($category == 'all') $category = '';
440 $this->_preBlogContent('archivelist',$blog);
441 $this->_setBlogCategory($blog, $category);
442 $blog->showArchiveList($template, 'month', $limit);
443 $this->_postBlogContent('archivelist',$blog);
447 * Parse skinvar archivetype
449 function parse_archivetype() {
457 function parse_blog($template, $amount = 10, $category = '') {
458 global $blog, $startpos;
460 list($limit, $offset) = sscanf($amount, '%d(%d)');
461 $this->_setBlogCategory($blog, $category);
462 $this->_preBlogContent('blog',$blog);
463 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
464 $this->_postBlogContent('blog',$blog);
468 * Parse skinvar bloglist
469 * Shows a list of all blogs
470 * bnametype: whether 'name' or 'shortname' is used for the link text
472 function parse_bloglist($template, $bnametype = '') {
473 BLOG::showBlogList($template, $bnametype);
477 * Parse skinvar blogsetting
479 function parse_blogsetting($which) {
483 echo htmlspecialchars($blog->getID());
486 echo htmlspecialchars($blog->getURL());
489 echo htmlspecialchars($blog->getName());
492 echo htmlspecialchars($blog->getDescription());
495 echo htmlspecialchars($blog->getShortName());
503 function parse_callback($eventName, $type)
506 $manager->notify($eventName, array('type' => $type));
510 * Parse skinvar category
512 function parse_category($type = 'name') {
513 global $catid, $blog;
514 if (!$blog->isValidCategory($catid))
519 echo $blog->getCategoryName($catid);
522 echo $blog->getCategoryDesc($catid);
533 function parse_categorylist($template, $blogname = '') {
534 global $blog, $manager;
536 if ($blogname == '') {
537 $this->_preBlogContent('categorylist',$blog);
538 $blog->showCategoryList($template);
539 $this->_postBlogContent('categorylist',$blog);
541 $b =& $manager->getBlog(getBlogIDFromName($blogname));
542 $this->_preBlogContent('categorylist',$b);
543 $b->showCategoryList($template);
544 $this->_postBlogContent('categorylist',$b);
549 * Parse skinvar charset
551 function parse_charset() {
556 * Parse skinvar commentform
558 function parse_commentform($destinationurl = '') {
559 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
561 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
562 if (stristr($destinationurl, 'action.php')) {
563 $args = func_get_args();
564 $destinationurl = $args[1];
565 ACTIONLOG::add(WARNING,'actionurl is not longer a parameter on commentform skinvars. Moved to be a global setting instead.');
568 $actionurl = $CONF['ActionURL'];
570 // if item is closed, show message and do nothing
571 $item =& $manager->getItem($itemid,0,0);
572 if ($item['closed'] || !$blog->commentsEnabled()) {
573 $this->doForm('commentform-closed');
577 if (!$destinationurl)
579 $destinationurl = createLink(
583 'title' => $item['title'],
584 'timestamp' => $item['timestamp'],
585 'extra' => $this->linkparams
589 // note: createLink returns an HTML encoded URL
592 $destinationurl = htmlspecialchars($destinationurl);
596 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
597 if (!$user) $user = postVar('user');
598 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
599 if (!$userid) $userid = postVar('userid');
600 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
602 $email = postVar('email');
604 $body = postVar('body');
606 $this->formdata = array(
607 'destinationurl' => $destinationurl, // url is already HTML encoded
608 'actionurl' => htmlspecialchars($actionurl),
610 'user' => htmlspecialchars($user),
611 'userid' => htmlspecialchars($userid),
612 'email' => htmlspecialchars($email),
613 'body' => htmlspecialchars($body),
614 'membername' => $member->getDisplayName(),
615 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
618 if (!$member->isLoggedIn()) {
619 $this->doForm('commentform-notloggedin');
621 $this->doForm('commentform-loggedin');
626 * Parse skinvar comments
627 * include comments for one item
629 function parse_comments($template) {
630 global $itemid, $manager, $blog, $highlight;
631 $template =& $manager->getTemplate($template);
633 // create parser object & action handler
634 $actions =& new ITEMACTIONS($blog);
635 $parser =& new PARSER($actions->getDefinedActions(),$actions);
636 $actions->setTemplate($template);
637 $actions->setParser($parser);
638 $item = ITEM::getitem($itemid, 0, 0);
639 $actions->setCurrentItem($item);
641 $comments =& new COMMENTS($itemid);
642 $comments->setItemActions($actions);
643 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
649 function parse_errordiv() {
650 global $errormessage;
652 echo '<div class="error">', htmlspecialchars($errormessage),'</div>';
656 * Parse skinvar errormessage
658 function parse_errormessage() {
659 global $errormessage;
666 function parse_formdata($what) {
667 echo $this->formdata[$what];
673 function parse_ifcat($text = '') {
676 $this->parse_if('category');
679 global $catid, $blog;
680 if ($blog->isValidCategory($catid))
686 * Parse skinvar image
688 function parse_image($what = 'imgtag') {
691 $imagetext = htmlspecialchars(requestVar('imagetext'));
692 $imagepopup = requestVar('imagepopup');
693 $width = intRequestVar('width');
694 $height = intRequestVar('height');
695 $fullurl = htmlspecialchars($CONF['MediaURL'] . $imagepopup);
714 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
720 * Parse skinvar imagetext
722 function parse_imagetext() {
723 echo htmlspecialchars(requestVar('imagetext'));
728 * include one item (no comments)
730 function parse_item($template) {
731 global $blog, $itemid, $highlight;
732 $this->_setBlogCategory($blog, ''); // need this to select default category
733 $this->_preBlogContent('item',$blog);
734 $r = $blog->showOneitem($itemid, $template, $highlight);
736 echo _ERROR_NOSUCHITEM;
737 $this->_postBlogContent('item',$blog);
741 * Parse skinvar itemid
743 function parse_itemid() {
749 * Parse skinvar itemlink
751 function parse_itemlink($linktext = '') {
753 $this->_itemlink($itemid, $linktext);
759 function parse_itemtitle($format = '') {
760 global $manager, $itemid;
761 $item =& $manager->getItem($itemid,0,0);
765 echo stringToXML ($item['title']);
768 echo stringToAttribute ($item['title']);
774 echo htmlspecialchars(strip_tags($item['title']));
780 * Parse skinvar loginform
782 function parse_loginform() {
783 global $member, $CONF;
784 if (!$member->isLoggedIn()) {
785 $filename = 'loginform-notloggedin';
786 $this->formdata = array();
788 $filename = 'loginform-loggedin';
789 $this->formdata = array(
790 'membername' => $member->getDisplayName(),
793 $this->doForm($filename);
797 * Parse skinvar member
798 * (includes a member info thingie)
800 function parse_member($what) {
801 global $memberinfo, $member;
803 // 1. only allow the member-details-page specific variables on member pages
804 if ($this->skintype == 'member') {
808 echo htmlspecialchars($memberinfo->getDisplayName());
811 echo htmlspecialchars($memberinfo->getRealName());
814 echo htmlspecialchars($memberinfo->getNotes());
817 echo htmlspecialchars($memberinfo->getURL());
820 echo htmlspecialchars($memberinfo->getEmail());
823 echo htmlspecialchars($memberinfo->getID());
828 // 2. the next bunch of options is available everywhere, as long as the user is logged in
829 if ($member->isLoggedIn())
833 echo $member->getDisplayName();
836 echo $member->getRealName();
839 echo $member->getNotes();
842 echo $member->getURL();
845 echo $member->getEmail();
848 echo $member->getID();
856 * Parse skinvar membermailform
858 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {
859 global $member, $CONF, $memberid;
861 if ($desturl == '') {
862 if ($CONF['URLMode'] == 'pathinfo')
863 $desturl = createMemberLink($memberid);
865 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);
868 $message = postVar('message');
869 $frommail = postVar('frommail');
871 $this->formdata = array(
872 'url' => htmlspecialchars($desturl),
873 'actionurl' => htmlspecialchars($CONF['ActionURL']),
874 'memberid' => $memberid,
877 'message' => htmlspecialchars($message),
878 'frommail' => htmlspecialchars($frommail)
880 if ($member->isLoggedIn()) {
881 $this->doForm('membermailform-loggedin');
882 } else if ($CONF['NonmemberMail']) {
883 $this->doForm('membermailform-notloggedin');
885 $this->doForm('membermailform-disallowed');
891 * Parse skinvar nextarchive
893 function parse_nextarchive() {
899 * Parse skinvar nextitem
900 * (include itemid of next item)
902 function parse_nextitem() {
908 * Parse skinvar nextitemtitle
909 * (include itemtitle of next item)
911 function parse_nextitemtitle($format = '') {
912 global $itemtitlenext;
916 echo stringToXML ($itemtitlenext);
919 echo stringToAttribute ($itemtitlenext);
925 echo htmlspecialchars($itemtitlenext);
931 * Parse skinvar nextlink
933 function parse_nextlink($linktext = '', $amount = 10) {
934 global $itemidnext, $archivenext, $startpos;
935 if ($this->skintype == 'item')
936 $this->_itemlink($itemidnext, $linktext);
937 else if ($this->skintype == 'search' || $this->skintype == 'index')
938 $this->_searchlink($amount, $startpos, 'next', $linktext);
940 $this->_archivelink($archivenext, $linktext);
944 * Parse skinvar nucleusbutton
946 function parse_nucleusbutton($imgurl = '',
951 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
952 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){
953 // when skindit IncludeMode is used: start from skindir
954 $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;
957 $this->formdata = array(
959 'imgwidth' => $imgwidth,
960 'imgheight' => $imgheight,
962 $this->doForm('nucleusbutton');
965 function parse_otherarchive($blogname, $template, $category = '') {
966 global $archive, $manager;
967 sscanf($archive,'%d-%d-%d',$y,$m,$d);
968 $b =& $manager->getBlog(getBlogIDFromName($blogname));
969 $this->_setBlogCategory($b, $category);
970 $this->_preBlogContent('otherachive',$b);
971 $b->showArchive($template, $y, $m, $d);
972 $this->_postBlogContent('otherachive',$b);
976 * Parse skinvar otherarchivedaylist
978 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
980 if ($category == 'all') $category = '';
981 $b =& $manager->getBlog(getBlogIDFromName($blogname));
982 $this->_setBlogCategory($b, $category);
983 $this->_preBlogContent('otherarchivelist',$b);
984 $b->showArchiveList($template, 'day', $limit);
985 $this->_postBlogContent('otherarchivelist',$b);
989 * Parse skinvar otherarchivelist
991 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
993 if ($category == 'all') $category = '';
994 $b =& $manager->getBlog(getBlogIDFromName($blogname));
995 $this->_setBlogCategory($b, $category);
996 $this->_preBlogContent('otherarchivelist',$b);
997 $b->showArchiveList($template, 'month', $limit);
998 $this->_postBlogContent('otherarchivelist',$b);
1002 * Parse skinvar otherblog
1004 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
1007 list($limit, $offset) = sscanf($amount, '%d(%d)');
1009 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1010 $this->_setBlogCategory($b, $category);
1011 $this->_preBlogContent('otherblog',$b);
1012 $this->amountfound = $b->readLog($template, $limit, $offset);
1013 $this->_postBlogContent('otherblog',$b);
1017 * Parse skinvar othersearchresults
1019 function parse_othersearchresults($blogname, $template, $maxresults = 50) {
1020 global $query, $amount, $manager, $startpos;
1021 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1022 $this->_setBlogCategory($b, ''); // need this to select default category
1023 $this->_preBlogContent('othersearchresults',$b);
1024 $b->search($query, $template, $amount, $maxresults, $startpos);
1025 $this->_postBlogContent('othersearchresults',$b);
1029 * Executes a plugin skinvar
1031 * @param pluginName name of plugin (without the NP_)
1033 * extra parameters can be added
1035 function parse_plugin($pluginName) {
1038 // only continue when the plugin is really installed
1039 if (!$manager->pluginInstalled('NP_' . $pluginName))
1042 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1043 if (!$plugin) return;
1046 $params = func_get_args();
1048 // remove plugin name
1049 array_shift($params);
1051 // add skin type on front
1052 array_unshift($params, $this->skintype);
1054 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1058 * Parse skinvar prevarchive
1060 function parse_prevarchive() {
1061 global $archiveprev;
1066 * Parse skinvar preview
1068 function parse_preview($template) {
1069 global $blog, $CONF, $manager;
1071 $template =& $manager->getTemplate($template);
1072 $row['body'] = '<span id="prevbody"></span>';
1073 $row['title'] = '<span id="prevtitle"></span>';
1074 $row['more'] = '<span id="prevmore"></span>';
1075 $row['itemlink'] = '';
1076 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1077 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);
1078 echo TEMPLATE::fill($template['ITEM'],$row);
1079 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);
1083 * Parse skinvar previtem
1084 * (include itemid of prev item)
1086 function parse_previtem() {
1092 * Parse skinvar previtemtitle
1093 * (include itemtitle of prev item)
1095 function parse_previtemtitle($format = '') {
1096 global $itemtitleprev;
1100 echo stringToXML ($itemtitleprev);
1103 echo stringToAttribute ($itemtitleprev);
1106 echo $itemtitleprev;
1109 echo htmlspecialchars($itemtitleprev);
1115 * Parse skinvar prevlink
1117 function parse_prevlink($linktext = '', $amount = 10) {
1118 global $itemidprev, $archiveprev, $startpos;
1120 if ($this->skintype == 'item')
1121 $this->_itemlink($itemidprev, $linktext);
1122 else if ($this->skintype == 'search' || $this->skintype == 'index')
1123 $this->_searchlink($amount, $startpos, 'prev', $linktext);
1125 $this->_archivelink($archiveprev, $linktext);
1129 * Parse skinvar query
1130 * (includes the search query)
1132 function parse_query() {
1134 echo htmlspecialchars($query);
1138 * Parse skinvar referer
1140 function parse_referer() {
1141 echo htmlspecialchars(serverVar('HTTP_REFERER'));
1145 * Parse skinvar searchform
1147 function parse_searchform($blogname = '') {
1148 global $CONF, $manager, $maxresults;
1150 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
1154 // use default blog when no blog is selected
1155 $this->formdata = array(
1156 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
1157 'query' => htmlspecialchars(getVar('query')),
1159 $this->doForm('searchform');
1163 * Parse skinvar searchresults
1165 function parse_searchresults($template, $maxresults = 50 ) {
1166 global $blog, $query, $amount, $startpos;
1168 $this->_setBlogCategory($blog, ''); // need this to select default category
1169 $this->_preBlogContent('searchresults',$blog);
1170 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
1171 $this->_postBlogContent('searchresults',$blog);
1175 * Parse skinvar self
1177 function parse_self() {
1183 * Parse skinvar sitevar
1184 * (include a sitevar)
1186 function parse_sitevar($which) {
1190 echo $CONF['IndexURL'];
1193 echo $CONF['SiteName'];
1196 echo $CONF['AdminEmail'];
1199 echo $CONF['AdminURL'];
1206 function parse_skinname() {
1207 echo $this->skin->getName();
1213 function parse_text($which) {
1214 // constant($which) only available from 4.0.4 :(
1215 if (defined($which)) {
1216 eval("echo $which;");
1223 function parse_ticket() {
1225 $manager->addTicketHidden();
1229 * Parse skinvar todaylink
1230 * A link to the today page (depending on selected blog, etc...)
1232 function parse_todaylink($linktext = '') {
1233 global $blog, $CONF;
1235 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);
1237 echo $this->_link($CONF['SiteUrl'], $linktext);
1242 * When commentform is not used, to include a hidden field with itemid
1244 function parse_vars() {
1246 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
1250 * Parse skinvar version
1251 * (include nucleus versionnumber)
1253 function parse_version() {
1255 echo 'Nucleus CMS ' . $nucleus['version'];