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.9 2007-05-10 08:12:51 kimitake Exp $
22 * @version $NucleusJP: ACTIONS.php,v 1.8 2007/04/19 06:05:55 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
38 // used when including templated forms from the include/ dir. The $formdata var
39 // contains the values to fill out in there (assoc array name -> value)
42 // filled out with the number of displayed items after calling one of the
43 // (other)blog/(other)searchresults skinvars.
47 * Constructor for a new ACTIONS object
49 function ACTIONS($type) {
50 // call constructor of superclass first
53 $this->skintype = $type;
57 $this->linkparams = array('catid' => $catid);
63 function setSkin(&$skin) {
70 function setParser(&$parser) {
71 $this->parser =& $parser;
75 * Forms get parsedincluded now, using an extra <formdata> skinvar
77 function doForm($filename) {
79 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');
80 $oldIncludeMode = PARSER::getProperty('IncludeMode');
81 $oldIncludePrefix = PARSER::getProperty('IncludePrefix');
82 PARSER::setProperty('IncludeMode','normal');
83 PARSER::setProperty('IncludePrefix','');
84 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
85 PARSER::setProperty('IncludeMode',$oldIncludeMode);
86 PARSER::setProperty('IncludePrefix',$oldIncludePrefix);
87 array_pop($this->parser->actions); // errordiv
88 array_pop($this->parser->actions); // callback
89 array_pop($this->parser->actions); // text
90 array_pop($this->parser->actions); // formdata
91 array_pop($this->parser->actions); // ticket
95 * Checks conditions for if statements
97 * @param string $field type of <%if%>
98 * @param string $name property of field
99 * @param string $value value of property
101 function checkCondition($field, $name='', $value = '') {
102 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
107 $condition = ($blog && $this->_ifCategory($name,$value));
110 $condition = ($blog && ($blog->getSetting($name) == $value));
113 $condition = $member->isLoggedIn();
116 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
119 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
122 $condition = ($itemidnext != '');
125 $condition = ($itemidprev != '');
127 case 'archiveprevexists':
128 $condition = ($archiveprevexists == true);
130 case 'archivenextexists':
131 $condition = ($archivenextexists == true);
134 $condition = ($name == $this->skintype);
137 $condition = $this->_ifHasPlugin($name, $value);
140 $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);
148 * -> checks if plugin exists
149 * hasplugin,PlugName,OptionName
150 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
151 * hasplugin,PlugName,OptionName=value
152 * -> checks if the option OptionName from plugin PlugName is set to value
154 function _ifHasPlugin($name, $value) {
157 // (pluginInstalled method won't write a message in the actionlog on failure)
158 if ($manager->pluginInstalled('NP_'.$name)) {
159 $plugin =& $manager->getPlugin('NP_' . $name);
160 if ($plugin != NULL) {
164 list($name2, $value2) = explode('=', $value, 2);
165 if ($value2 == "" && $plugin->getOption($name2) != 'no') {
167 } else if ($plugin->getOption($name2) == $value2) {
177 * Checks if a plugin exists and call its doIf function
179 function _ifPlugin($name, $key = '', $value = '') {
182 $plugin =& $manager->getPlugin('NP_' . $name);
183 if (!$plugin) return;
185 $params = func_get_args();
186 array_shift($params);
188 return call_user_func_array(array(&$plugin, 'doIf'), $params);
192 * Different checks for a category
194 function _ifCategory($name = '', $value='') {
195 global $blog, $catid;
197 // when no parameter is defined, just check if a category is selected
198 if (($name != 'catname' && $name != 'catid') || ($value == ''))
199 return $blog->isValidCategory($catid);
201 // check category name
202 if ($name == 'catname') {
203 $value = $blog->getCategoryIdFromName($value);
204 if ($value == $catid)
205 return $blog->isValidCategory($catid);
209 if (($name == 'catid') && ($value == $catid))
210 return $blog->isValidCategory($catid);
216 * Checks if a member is on the team of a blog and return his rights
218 function _ifOnTeam($blogName = '') {
219 global $blog, $member, $manager;
221 // when no blog found
222 if (($blogName == '') && (!is_object($blog)))
225 // explicit blog selection
227 $blogid = getBlogIDFromName($blogName);
229 if (($blogName == '') || !$manager->existsBlogID($blogid))
231 $blogid = $blog->getID();
233 return $member->teamRights($blogid);
237 * Checks if a member is admin of a blog
239 function _ifAdmin($blogName = '') {
240 global $blog, $member, $manager;
242 // when no blog found
243 if (($blogName == '') && (!is_object($blog)))
246 // explicit blog selection
248 $blogid = getBlogIDFromName($blogName);
250 if (($blogName == '') || !$manager->existsBlogID($blogid))
252 $blogid = $blog->getID();
254 return $member->isBlogAdmin($blogid);
259 * - a raw link (html/xml encoded) when no linktext is provided
260 * - a (x)html <a href... link when a text is present (text htmlencoded)
262 function _link($url, $linktext = '')
264 $u = htmlspecialchars($url);
265 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands
267 $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>';
274 * Outputs a next/prev link
277 * The maximum amount of items shown per page (e.g. 10)
279 * Current start position (requestVar('startpos'))
281 * either 'prev' or 'next'
283 * When present, the output will be a full <a href...> link. When empty,
284 * only a raw link will be outputted
286 function _searchlink($maxresults, $startpos, $direction, $linktext = '') {
287 global $CONF, $blog, $query, $amount;
288 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
289 $startpos = intval($startpos); // will be 0 when empty.
290 $parsed = parse_url(serverVar('REQUEST_URI'));
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);
302 $iAmountOnPage = $this->amountfound;
303 if ($iAmountOnPage == 0)
305 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
307 switch ($this->skintype)
310 $sqlquery = $blog->getSqlBlog('', 'count');
313 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
317 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
319 if (intval($iAmountOnPage) >= intval($maxresults)) {
320 $startpos = intval($startpos) + intval($maxresults);
321 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
326 } // switch($direction)
329 echo $this->_link($url, $linktext);
333 * Creates an item link and if no id is given a todaylink
335 function _itemlink($id, $linktext = '') {
338 echo $this->_link(createItemLink($id, $this->linkparams), $linktext);
340 $this->parse_todaylink($linktext);
344 * Creates an archive link and if no id is given a todaylink
346 function _archivelink($id, $linktext = '') {
349 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);
351 $this->parse_todaylink($linktext);
355 * Helper function that sets the category that a blog will need to use
358 * An object of the blog class, passed by reference (we want to make changes to it)
360 * The name of the category to use
362 function _setBlogCategory(&$blog, $catname) {
365 $blog->setSelectedCategoryByName($catname);
367 $blog->setSelectedCategory($catid);
371 * Notifies the Manager that a PreBlogContent event occurs
373 function _preBlogContent($type, &$blog) {
375 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
379 * Notifies the Manager that a PostBlogContent event occurs
381 function _postBlogContent($type, &$blog) {
383 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
387 * Parse skinvar additemform
389 function parse_additemform() {
391 $this->formdata = array(
392 'adminurl' => htmlspecialchars($CONF['AdminURL'],ENT_QUOTES),
393 'catid' => $blog->getDefaultCategory()
395 $blog->InsertJavaScriptInfo();
396 $this->doForm('additemform');
400 * Parse skinvar adminurl
401 * (shortcut for admin url)
403 function parse_adminurl() {
404 $this->parse_sitevar('adminurl');
408 * Parse skinvar archive
410 function parse_archive($template, $category = '') {
411 global $blog, $archive;
412 // can be used with either yyyy-mm or yyyy-mm-dd
413 sscanf($archive,'%d-%d-%d',$y,$m,$d);
414 $this->_setBlogCategory($blog, $category);
415 $this->_preBlogContent('achive',$blog);
416 $blog->showArchive($template, $y, $m, $d);
417 $this->_postBlogContent('achive',$blog);
422 * %archivedate(locale,date format)%
424 function parse_archivedate($locale = '-def-') {
427 if ($locale == '-def-')
428 setlocale(LC_TIME,$template['LOCALE']);
430 setlocale(LC_TIME,$locale);
433 sscanf($archive,'%d-%d-%d',$y,$m,$d);
436 $args = func_get_args();
437 // format can be spread over multiple parameters
438 if (sizeof($args) > 1) {
442 $format=implode(',',$args);
446 $format = '%d %B %Y';
449 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));
453 * Parse skinvar archivedaylist
455 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
457 if ($category == 'all') $category = '';
458 $this->_preBlogContent('archivelist',$blog);
459 $this->_setBlogCategory($blog, $category);
460 $blog->showArchiveList($template, 'day', $limit);
461 $this->_postBlogContent('archivelist',$blog);
465 * A link to the archives for the current blog (or for default blog)
467 function parse_archivelink($linktext = '') {
470 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);
472 echo $this->_link(createArchiveListLink(), $linktext);
475 function parse_archivelist($template, $category = 'all', $limit = 0) {
477 if ($category == 'all') $category = '';
478 $this->_preBlogContent('archivelist',$blog);
479 $this->_setBlogCategory($blog, $category);
480 $blog->showArchiveList($template, 'month', $limit);
481 $this->_postBlogContent('archivelist',$blog);
485 * Parse skinvar archivetype
487 function parse_archivetype() {
495 function parse_blog($template, $amount = 10, $category = '') {
496 global $blog, $startpos;
498 list($limit, $offset) = sscanf($amount, '%d(%d)');
499 $this->_setBlogCategory($blog, $category);
500 $this->_preBlogContent('blog',$blog);
501 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
502 $this->_postBlogContent('blog',$blog);
506 * Parse skinvar bloglist
507 * Shows a list of all blogs
508 * bnametype: whether 'name' or 'shortname' is used for the link text
510 function parse_bloglist($template, $bnametype = '') {
511 BLOG::showBlogList($template, $bnametype);
515 * Parse skinvar blogsetting
517 function parse_blogsetting($which) {
521 echo htmlspecialchars($blog->getID(),ENT_QUOTES);
524 echo htmlspecialchars($blog->getURL(),ENT_QUOTES);
527 echo htmlspecialchars($blog->getName(),ENT_QUOTES);
530 echo htmlspecialchars($blog->getDescription(),ENT_QUOTES);
533 echo htmlspecialchars($blog->getShortName(),ENT_QUOTES);
541 function parse_callback($eventName, $type)
544 $manager->notify($eventName, array('type' => $type));
548 * Parse skinvar category
550 function parse_category($type = 'name') {
551 global $catid, $blog;
552 if (!$blog->isValidCategory($catid))
557 echo $blog->getCategoryName($catid);
560 echo $blog->getCategoryDesc($catid);
571 function parse_categorylist($template, $blogname = '') {
572 global $blog, $manager;
574 if ($blogname == '') {
575 $this->_preBlogContent('categorylist',$blog);
576 $blog->showCategoryList($template);
577 $this->_postBlogContent('categorylist',$blog);
579 $b =& $manager->getBlog(getBlogIDFromName($blogname));
580 $this->_preBlogContent('categorylist',$b);
581 $b->showCategoryList($template);
582 $this->_postBlogContent('categorylist',$b);
587 * Parse skinvar charset
589 function parse_charset() {
594 * Parse skinvar commentform
596 function parse_commentform($destinationurl = '') {
597 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
599 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
600 if (stristr($destinationurl, 'action.php')) {
601 $args = func_get_args();
602 $destinationurl = $args[1];
603 ACTIONLOG::add(WARNING,'actionurl is not longer a parameter on commentform skinvars. Moved to be a global setting instead.');
606 $actionurl = $CONF['ActionURL'];
608 // if item is closed, show message and do nothing
609 $item =& $manager->getItem($itemid,0,0);
610 if ($item['closed'] || !$blog->commentsEnabled()) {
611 $this->doForm('commentform-closed');
615 if (!$destinationurl)
617 $destinationurl = createLink(
621 'title' => $item['title'],
622 'timestamp' => $item['timestamp'],
623 'extra' => $this->linkparams
627 // note: createLink returns an HTML encoded URL
630 $destinationurl = htmlspecialchars($destinationurl,ENT_QUOTES);
634 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
635 if (!$user) $user = postVar('user');
636 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
637 if (!$userid) $userid = postVar('userid');
638 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
640 $email = postVar('email');
642 $body = postVar('body');
644 $this->formdata = array(
645 'destinationurl' => $destinationurl, // url is already HTML encoded
646 'actionurl' => htmlspecialchars($actionurl,ENT_QUOTES),
648 'user' => htmlspecialchars($user,ENT_QUOTES),
649 'userid' => htmlspecialchars($userid,ENT_QUOTES),
650 'email' => htmlspecialchars($email,ENT_QUOTES),
651 'body' => htmlspecialchars($body,ENT_QUOTES),
652 'membername' => $member->getDisplayName(),
653 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
656 if (!$member->isLoggedIn()) {
657 $this->doForm('commentform-notloggedin');
659 $this->doForm('commentform-loggedin');
664 * Parse skinvar comments
665 * include comments for one item
667 function parse_comments($template) {
668 global $itemid, $manager, $blog, $highlight;
669 $template =& $manager->getTemplate($template);
671 // create parser object & action handler
672 $actions =& new ITEMACTIONS($blog);
673 $parser =& new PARSER($actions->getDefinedActions(),$actions);
674 $actions->setTemplate($template);
675 $actions->setParser($parser);
676 $item = ITEM::getitem($itemid, 0, 0);
677 $actions->setCurrentItem($item);
679 $comments =& new COMMENTS($itemid);
680 $comments->setItemActions($actions);
681 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
687 function parse_errordiv() {
688 global $errormessage;
690 echo '<div class="error">', htmlspecialchars($errormessage),'</div>';
694 * Parse skinvar errormessage
696 function parse_errormessage() {
697 global $errormessage;
704 function parse_formdata($what) {
705 echo $this->formdata[$what];
711 function parse_ifcat($text = '') {
714 $this->parse_if('category');
717 global $catid, $blog;
718 if ($blog->isValidCategory($catid))
724 * Parse skinvar image
726 function parse_image($what = 'imgtag') {
729 $imagetext = htmlspecialchars(requestVar('imagetext'));
730 $imagepopup = requestVar('imagepopup');
731 $width = intRequestVar('width');
732 $height = intRequestVar('height');
733 $fullurl = htmlspecialchars($CONF['MediaURL'] . $imagepopup);
752 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
758 * Parse skinvar imagetext
760 function parse_imagetext() {
761 echo htmlspecialchars(requestVar('imagetext'),ENT_QUOTES);
766 * include one item (no comments)
768 function parse_item($template) {
769 global $blog, $itemid, $highlight;
770 $this->_setBlogCategory($blog, ''); // need this to select default category
771 $this->_preBlogContent('item',$blog);
772 $r = $blog->showOneitem($itemid, $template, $highlight);
774 echo _ERROR_NOSUCHITEM;
775 $this->_postBlogContent('item',$blog);
779 * Parse skinvar itemid
781 function parse_itemid() {
787 * Parse skinvar itemlink
789 function parse_itemlink($linktext = '') {
791 $this->_itemlink($itemid, $linktext);
797 function parse_itemtitle($format = '') {
798 global $manager, $itemid;
799 $item =& $manager->getItem($itemid,0,0);
803 echo stringToXML ($item['title']);
806 echo stringToAttribute ($item['title']);
812 echo htmlspecialchars(strip_tags($item['title']),ENT_QUOTES);
818 * Parse skinvar loginform
820 function parse_loginform() {
821 global $member, $CONF;
822 if (!$member->isLoggedIn()) {
823 $filename = 'loginform-notloggedin';
824 $this->formdata = array();
826 $filename = 'loginform-loggedin';
827 $this->formdata = array(
828 'membername' => $member->getDisplayName(),
831 $this->doForm($filename);
835 * Parse skinvar member
836 * (includes a member info thingie)
838 function parse_member($what) {
839 global $memberinfo, $member;
841 // 1. only allow the member-details-page specific variables on member pages
842 if ($this->skintype == 'member') {
846 echo htmlspecialchars($memberinfo->getDisplayName(),ENT_QUOTES);
849 echo htmlspecialchars($memberinfo->getRealName(),ENT_QUOTES);
852 echo htmlspecialchars($memberinfo->getNotes(),ENT_QUOTES);
855 echo htmlspecialchars($memberinfo->getURL(),ENT_QUOTES);
858 echo htmlspecialchars($memberinfo->getEmail(),ENT_QUOTES);
861 echo htmlspecialchars($memberinfo->getID(),ENT_QUOTES);
866 // 2. the next bunch of options is available everywhere, as long as the user is logged in
867 if ($member->isLoggedIn())
871 echo $member->getDisplayName();
874 echo $member->getRealName();
877 echo $member->getNotes();
880 echo $member->getURL();
883 echo $member->getEmail();
886 echo $member->getID();
894 * Parse skinvar membermailform
896 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {
897 global $member, $CONF, $memberid;
899 if ($desturl == '') {
900 if ($CONF['URLMode'] == 'pathinfo')
901 $desturl = createMemberLink($memberid);
903 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);
906 $message = postVar('message');
907 $frommail = postVar('frommail');
909 $this->formdata = array(
910 'url' => htmlspecialchars($desturl),
911 'actionurl' => htmlspecialchars($CONF['ActionURL'],ENT_QUOTES),
912 'memberid' => $memberid,
915 'message' => htmlspecialchars($message,ENT_QUOTES),
916 'frommail' => htmlspecialchars($frommail,ENT_QUOTES)
918 if ($member->isLoggedIn()) {
919 $this->doForm('membermailform-loggedin');
920 } else if ($CONF['NonmemberMail']) {
921 $this->doForm('membermailform-notloggedin');
923 $this->doForm('membermailform-disallowed');
929 * Parse skinvar nextarchive
931 function parse_nextarchive() {
937 * Parse skinvar nextitem
938 * (include itemid of next item)
940 function parse_nextitem() {
942 if (isset($itemidnext)) echo (int)$itemidnext;
946 * Parse skinvar nextitemtitle
947 * (include itemtitle of next item)
949 function parse_nextitemtitle($format = '') {
950 global $itemtitlenext;
954 echo stringToXML ($itemtitlenext);
957 echo stringToAttribute ($itemtitlenext);
963 echo htmlspecialchars($itemtitlenext,ENT_QUOTES);
969 * Parse skinvar nextlink
971 function parse_nextlink($linktext = '', $amount = 10) {
972 global $itemidnext, $archivenext, $startpos;
973 if ($this->skintype == 'item')
974 $this->_itemlink($itemidnext, $linktext);
975 else if ($this->skintype == 'search' || $this->skintype == 'index')
976 $this->_searchlink($amount, $startpos, 'next', $linktext);
978 $this->_archivelink($archivenext, $linktext);
982 * Parse skinvar nucleusbutton
984 function parse_nucleusbutton($imgurl = '',
989 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
990 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){
991 // when skindit IncludeMode is used: start from skindir
992 $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;
995 $this->formdata = array(
997 'imgwidth' => $imgwidth,
998 'imgheight' => $imgheight,
1000 $this->doForm('nucleusbutton');
1004 * Parse skinvar otherarchive
1006 function parse_otherarchive($blogname, $template, $category = '') {
1007 global $archive, $manager;
1008 sscanf($archive,'%d-%d-%d',$y,$m,$d);
1009 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1010 $this->_setBlogCategory($b, $category);
1011 $this->_preBlogContent('otherachive',$b);
1012 $b->showArchive($template, $y, $m, $d);
1013 $this->_postBlogContent('otherachive',$b);
1017 * Parse skinvar otherarchivedaylist
1019 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
1021 if ($category == 'all') $category = '';
1022 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1023 $this->_setBlogCategory($b, $category);
1024 $this->_preBlogContent('otherarchivelist',$b);
1025 $b->showArchiveList($template, 'day', $limit);
1026 $this->_postBlogContent('otherarchivelist',$b);
1030 * Parse skinvar otherarchivelist
1032 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
1034 if ($category == 'all') $category = '';
1035 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1036 $this->_setBlogCategory($b, $category);
1037 $this->_preBlogContent('otherarchivelist',$b);
1038 $b->showArchiveList($template, 'month', $limit);
1039 $this->_postBlogContent('otherarchivelist',$b);
1043 * Parse skinvar otherblog
1045 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
1048 list($limit, $offset) = sscanf($amount, '%d(%d)');
1050 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1051 $this->_setBlogCategory($b, $category);
1052 $this->_preBlogContent('otherblog',$b);
1053 $this->amountfound = $b->readLog($template, $limit, $offset);
1054 $this->_postBlogContent('otherblog',$b);
1058 * Parse skinvar othersearchresults
1060 function parse_othersearchresults($blogname, $template, $maxresults = 50) {
1061 global $query, $amount, $manager, $startpos;
1062 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1063 $this->_setBlogCategory($b, ''); // need this to select default category
1064 $this->_preBlogContent('othersearchresults',$b);
1065 $b->search($query, $template, $amount, $maxresults, $startpos);
1066 $this->_postBlogContent('othersearchresults',$b);
1070 * Executes a plugin skinvar
1072 * @param pluginName name of plugin (without the NP_)
1074 * extra parameters can be added
1076 function parse_plugin($pluginName) {
1079 // only continue when the plugin is really installed
1080 if (!$manager->pluginInstalled('NP_' . $pluginName))
1083 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1084 if (!$plugin) return;
1087 $params = func_get_args();
1089 // remove plugin name
1090 array_shift($params);
1092 // add skin type on front
1093 array_unshift($params, $this->skintype);
1095 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1099 * Parse skinvar prevarchive
1101 function parse_prevarchive() {
1102 global $archiveprev;
1107 * Parse skinvar preview
1109 function parse_preview($template) {
1110 global $blog, $CONF, $manager;
1112 $template =& $manager->getTemplate($template);
1113 $row['body'] = '<span id="prevbody"></span>';
1114 $row['title'] = '<span id="prevtitle"></span>';
1115 $row['more'] = '<span id="prevmore"></span>';
1116 $row['itemlink'] = '';
1117 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1118 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);
1119 echo TEMPLATE::fill($template['ITEM'],$row);
1120 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);
1124 * Parse skinvar previtem
1125 * (include itemid of prev item)
1127 function parse_previtem() {
1129 if (isset($itemidprev)) echo (int)$itemidprev;
1133 * Parse skinvar previtemtitle
1134 * (include itemtitle of prev item)
1136 function parse_previtemtitle($format = '') {
1137 global $itemtitleprev;
1141 echo stringToXML ($itemtitleprev);
1144 echo stringToAttribute ($itemtitleprev);
1147 echo $itemtitleprev;
1150 echo htmlspecialchars($itemtitleprev,ENT_QUOTES);
1156 * Parse skinvar prevlink
1158 function parse_prevlink($linktext = '', $amount = 10) {
1159 global $itemidprev, $archiveprev, $startpos;
1161 if ($this->skintype == 'item')
1162 $this->_itemlink($itemidprev, $linktext);
1163 else if ($this->skintype == 'search' || $this->skintype == 'index')
1164 $this->_searchlink($amount, $startpos, 'prev', $linktext);
1166 $this->_archivelink($archiveprev, $linktext);
1170 * Parse skinvar query
1171 * (includes the search query)
1173 function parse_query() {
1175 echo htmlspecialchars($query,ENT_QUOTES);
1179 * Parse skinvar referer
1181 function parse_referer() {
1182 echo htmlspecialchars(serverVar('HTTP_REFERER'),ENT_QUOTES);
1186 * Parse skinvar searchform
1188 function parse_searchform($blogname = '') {
1189 global $CONF, $manager, $maxresults;
1191 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
1195 // use default blog when no blog is selected
1196 $this->formdata = array(
1197 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
1198 'query' => htmlspecialchars(getVar('query'),ENT_QUOTES),
1200 $this->doForm('searchform');
1204 * Parse skinvar searchresults
1206 function parse_searchresults($template, $maxresults = 50 ) {
1207 global $blog, $query, $amount, $startpos;
1209 $this->_setBlogCategory($blog, ''); // need this to select default category
1210 $this->_preBlogContent('searchresults',$blog);
1211 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
1212 $this->_postBlogContent('searchresults',$blog);
1216 * Parse skinvar self
1218 function parse_self() {
1224 * Parse skinvar sitevar
1225 * (include a sitevar)
1227 function parse_sitevar($which) {
1231 echo $CONF['IndexURL'];
1234 echo $CONF['SiteName'];
1237 echo $CONF['AdminEmail'];
1240 echo $CONF['AdminURL'];
1247 function parse_skinname() {
1248 echo $this->skin->getName();
1252 * Parse skintype (experimental)
1254 function parse_skintype() {
1255 echo $this->skintype;
1261 function parse_text($which) {
1262 // constant($which) only available from 4.0.4 :(
1263 if (defined($which)) {
1264 eval("echo $which;");
1271 function parse_ticket() {
1273 $manager->addTicketHidden();
1277 * Parse skinvar todaylink
1278 * A link to the today page (depending on selected blog, etc...)
1280 function parse_todaylink($linktext = '') {
1281 global $blog, $CONF;
1283 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);
1285 echo $this->_link($CONF['SiteUrl'], $linktext);
1290 * When commentform is not used, to include a hidden field with itemid
1292 function parse_vars() {
1294 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
1298 * Parse skinvar version
1299 * (include nucleus versionnumber)
1301 function parse_version() {
1303 echo 'Nucleus CMS ' . $nucleus['version'];