3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2011 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-2011 The Nucleus Group
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->blogAdminRights($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 = '', $recount = '') {
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 $path = $parsed['path'];
291 $parsed = parse_url(serverVar('REQUEST_URI'));
292 $parsed = $parsed['query'];
295 switch ($direction) {
297 if ( intval($startpos) - intval($maxresults) >= 0) {
298 $startpos = intval($startpos) - intval($maxresults);
299 //$url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
300 switch ($this->skintype)
306 $url = $CONF['SearchURL'];
309 $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');
334 $unused_highlight = '';
335 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
336 $url = $CONF['SearchURL'];
340 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
342 if (intval($iAmountOnPage) >= intval($maxresults)) {
343 $startpos = intval($startpos) + intval($maxresults);
344 //$url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
345 $url .= '?'.alterQueryStr($parsed,'startpos',$startpos);
351 } // switch($direction)
354 echo $this->_link($url, $linktext);
358 * Creates an item link and if no id is given a todaylink
360 function _itemlink($id, $linktext = '') {
363 echo $this->_link(createItemLink($id, $this->linkparams), $linktext);
365 $this->parse_todaylink($linktext);
369 * Creates an archive link and if no id is given a todaylink
371 function _archivelink($id, $linktext = '') {
374 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);
376 $this->parse_todaylink($linktext);
380 * Helper function that sets the category that a blog will need to use
383 * An object of the blog class, passed by reference (we want to make changes to it)
385 * The name of the category to use
387 function _setBlogCategory(&$blog, $catname) {
390 $blog->setSelectedCategoryByName($catname);
392 $blog->setSelectedCategory($catid);
396 * Notifies the Manager that a PreBlogContent event occurs
398 function _preBlogContent($type, &$blog) {
400 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
404 * Notifies the Manager that a PostBlogContent event occurs
406 function _postBlogContent($type, &$blog) {
408 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
412 * Parse skinvar additemform
414 function parse_additemform() {
416 $this->formdata = array(
417 'adminurl' => htmlspecialchars($CONF['AdminURL'],ENT_QUOTES),
418 'catid' => $blog->getDefaultCategory()
420 $blog->InsertJavaScriptInfo();
421 $this->doForm('additemform');
425 * Parse skinvar addlink
426 * A Link that allows to open a bookmarklet to add an item
428 function parse_addlink() {
429 global $CONF, $member, $blog;
430 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
434 * Parse skinvar addpopupcode
435 * Code that opens a bookmarklet in an popup window
437 function parse_addpopupcode() {
438 echo "if (event && event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=no,width=710,height=550,left=10,top=10,status=no,resizable=yes');winbm.focus();return false;";
442 * Parse skinvar adminurl
443 * (shortcut for admin url)
445 function parse_adminurl() {
446 $this->parse_sitevar('adminurl');
450 * Parse skinvar archive
452 function parse_archive($template, $category = '') {
453 global $blog, $archive;
454 // can be used with either yyyy-mm or yyyy-mm-dd
455 sscanf($archive,'%d-%d-%d',$y,$m,$d);
456 $this->_setBlogCategory($blog, $category);
457 $this->_preBlogContent('achive',$blog);
458 $blog->showArchive($template, $y, $m, $d);
459 $this->_postBlogContent('achive',$blog);
464 * %archivedate(locale,date format)%
466 function parse_archivedate($locale = '-def-') {
469 if ($locale == '-def-')
470 setlocale(LC_TIME,$template['LOCALE']);
472 setlocale(LC_TIME,$locale);
475 sscanf($archive,'%d-%d-%d',$y,$m,$d);
478 $args = func_get_args();
479 // format can be spread over multiple parameters
480 if (sizeof($args) > 1) {
484 $format=implode(',',$args);
485 } elseif ($d == 0 && $m !=0) {
490 $format = '%d %B %Y';
493 echo strftimejp($format,mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
497 * Parse skinvar archivedaylist
499 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
501 if ($category == 'all') $category = '';
502 $this->_preBlogContent('archivelist',$blog);
503 $this->_setBlogCategory($blog, $category);
504 $blog->showArchiveList($template, 'day', $limit);
505 $this->_postBlogContent('archivelist',$blog);
509 * A link to the archives for the current blog (or for default blog)
511 function parse_archivelink($linktext = '') {
514 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);
516 echo $this->_link(createArchiveListLink(), $linktext);
519 function parse_archivelist($template, $category = 'all', $limit = 0) {
521 if ($category == 'all') $category = '';
522 $this->_preBlogContent('archivelist',$blog);
523 $this->_setBlogCategory($blog, $category);
524 $blog->showArchiveList($template, 'month', $limit);
525 $this->_postBlogContent('archivelist',$blog);
528 function parse_archiveyearlist($template, $category = 'all', $limit = 0) {
530 if ($category == 'all') $category = '';
531 $this->_preBlogContent('archivelist',$blog);
532 $this->_setBlogCategory($blog, $category);
533 $blog->showArchiveList($template, 'year', $limit);
534 $this->_postBlogContent('archivelist',$blog);
538 * Parse skinvar archivetype
540 function parse_archivetype() {
548 function parse_blog($template, $amount = 10, $category = '') {
549 global $blog, $startpos;
551 list($limit, $offset) = sscanf($amount, '%d(%d)');
552 $this->_setBlogCategory($blog, $category);
553 $this->_preBlogContent('blog',$blog);
554 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
555 $this->_postBlogContent('blog',$blog);
559 * Parse skinvar bloglist
560 * Shows a list of all blogs
561 * bnametype: whether 'name' or 'shortname' is used for the link text
562 * orderby: order criteria
563 * direction: order ascending or descending
565 function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') {
566 BLOG::showBlogList($template, $bnametype, $orderby, $direction);
570 * Parse skinvar blogsetting
572 function parse_blogsetting($which) {
576 echo htmlspecialchars($blog->getID(),ENT_QUOTES);
579 echo htmlspecialchars($blog->getURL(),ENT_QUOTES);
582 echo htmlspecialchars($blog->getName(),ENT_QUOTES);
585 echo htmlspecialchars($blog->getDescription(),ENT_QUOTES);
588 echo htmlspecialchars($blog->getShortName(),ENT_QUOTES);
596 function parse_callback($eventName, $type)
599 $manager->notify($eventName, array('type' => $type));
603 * Parse skinvar category
605 function parse_category($type = 'name') {
606 global $catid, $blog;
607 if (!$blog->isValidCategory($catid))
612 echo $blog->getCategoryName($catid);
615 echo $blog->getCategoryDesc($catid);
626 function parse_categorylist($template, $blogname = '') {
627 global $blog, $manager;
629 // when no blog found
630 if (($blogName == '') && (!is_object($blog)))
633 if ($blogname == '') {
634 $this->_preBlogContent('categorylist',$blog);
635 $blog->showCategoryList($template);
636 $this->_postBlogContent('categorylist',$blog);
638 $b =& $manager->getBlog(getBlogIDFromName($blogname));
639 $this->_preBlogContent('categorylist',$b);
640 $b->showCategoryList($template);
641 $this->_postBlogContent('categorylist',$b);
646 * Parse skinvar charset
648 function parse_charset() {
653 * Parse skinvar commentform
655 function parse_commentform($destinationurl = '') {
656 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
658 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
659 if (stristr($destinationurl, 'action.php')) {
660 $args = func_get_args();
661 $destinationurl = $args[1];
662 ACTIONLOG::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
665 $actionurl = $CONF['ActionURL'];
667 // if item is closed, show message and do nothing
668 $item =& $manager->getItem($itemid,0,0);
669 if ($item['closed'] || !$blog->commentsEnabled()) {
670 $this->doForm('commentform-closed');
674 if (!$blog->isPublic() && !$member->isLoggedIn()) {
675 $this->doForm('commentform-closedtopublic');
679 if (!$destinationurl)
681 $destinationurl = createLink(
685 'title' => $item['title'],
686 'timestamp' => $item['timestamp'],
687 'extra' => $this->linkparams
691 // note: createLink returns an HTML encoded URL
694 $destinationurl = htmlspecialchars($destinationurl,ENT_QUOTES);
698 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
699 if (!$user) $user = postVar('user');
700 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
701 if (!$userid) $userid = postVar('userid');
702 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
704 $email = postVar('email');
706 $body = postVar('body');
708 $this->formdata = array(
709 'destinationurl' => $destinationurl, // url is already HTML encoded
710 'actionurl' => htmlspecialchars($actionurl,ENT_QUOTES),
712 'user' => htmlspecialchars($user,ENT_QUOTES),
713 'userid' => htmlspecialchars($userid,ENT_QUOTES),
714 'email' => htmlspecialchars($email,ENT_QUOTES),
715 'body' => htmlspecialchars($body,ENT_QUOTES),
716 'membername' => $member->getDisplayName(),
717 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
720 if (!$member->isLoggedIn()) {
721 $this->doForm('commentform-notloggedin');
723 $this->doForm('commentform-loggedin');
728 * Parse skinvar comments
729 * include comments for one item
731 function parse_comments($template) {
732 global $itemid, $manager, $blog, $highlight;
733 $template =& $manager->getTemplate($template);
735 // create parser object & action handler
736 $actions =& new ITEMACTIONS($blog);
737 $parser =& new PARSER($actions->getDefinedActions(),$actions);
738 $actions->setTemplate($template);
739 $actions->setParser($parser);
740 $item = ITEM::getitem($itemid, 0, 0);
741 $actions->setCurrentItem($item);
743 $comments =& new COMMENTS($itemid);
744 $comments->setItemActions($actions);
745 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
751 function parse_errordiv() {
752 global $errormessage;
754 echo '<div class="error">', htmlspecialchars($errormessage),'</div>';
758 * Parse skinvar errormessage
760 function parse_errormessage() {
761 global $errormessage;
768 function parse_formdata($what) {
769 echo $this->formdata[$what];
775 function parse_ifcat($text = '') {
778 $this->parse_if('category');
781 global $catid, $blog;
782 if ($blog->isValidCategory($catid))
788 * Parse skinvar image
790 function parse_image($what = 'imgtag') {
793 $imagetext = htmlspecialchars(requestVar('imagetext'));
794 $imagepopup = requestVar('imagepopup');
795 $width = intRequestVar('width');
796 $height = intRequestVar('height');
797 $fullurl = htmlspecialchars($CONF['MediaURL'] . $imagepopup);
816 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
822 * Parse skinvar imagetext
824 function parse_imagetext() {
825 echo htmlspecialchars(requestVar('imagetext'),ENT_QUOTES);
830 * include one item (no comments)
832 function parse_item($template) {
833 global $blog, $itemid, $highlight;
834 $this->_setBlogCategory($blog, ''); // need this to select default category
835 $this->_preBlogContent('item',$blog);
836 $r = $blog->showOneitem($itemid, $template, $highlight);
838 echo _ERROR_NOSUCHITEM;
839 $this->_postBlogContent('item',$blog);
843 * Parse skinvar itemid
845 function parse_itemid() {
851 * Parse skinvar itemlink
853 function parse_itemlink($linktext = '') {
855 $this->_itemlink($itemid, $linktext);
861 function parse_itemtitle($format = '') {
862 global $manager, $itemid;
863 $item =& $manager->getItem($itemid,0,0);
867 echo stringToXML ($item['title']);
870 echo stringToAttribute ($item['title']);
876 echo htmlspecialchars(strip_tags($item['title']),ENT_QUOTES);
882 * Parse skinvar loginform
884 function parse_loginform() {
885 global $member, $CONF;
886 if (!$member->isLoggedIn()) {
887 $filename = 'loginform-notloggedin';
888 $this->formdata = array();
890 $filename = 'loginform-loggedin';
891 $this->formdata = array(
892 'membername' => $member->getDisplayName(),
895 $this->doForm($filename);
899 * Parse skinvar member
900 * (includes a member info thingie)
902 function parse_member($what) {
903 global $memberinfo, $member, $CONF;
905 // 1. only allow the member-details-page specific variables on member pages
906 if ($this->skintype == 'member') {
910 echo htmlspecialchars($memberinfo->getDisplayName(),ENT_QUOTES);
913 echo htmlspecialchars($memberinfo->getRealName(),ENT_QUOTES);
916 echo htmlspecialchars($memberinfo->getNotes(),ENT_QUOTES);
919 echo htmlspecialchars($memberinfo->getURL(),ENT_QUOTES);
922 echo htmlspecialchars($memberinfo->getEmail(),ENT_QUOTES);
925 echo htmlspecialchars($memberinfo->getID(),ENT_QUOTES);
930 // 2. the next bunch of options is available everywhere, as long as the user is logged in
931 if ($member->isLoggedIn())
935 echo $member->getDisplayName();
938 echo $member->getRealName();
941 echo $member->getNotes();
944 echo $member->getURL();
947 echo $member->getEmail();
950 echo $member->getID();
952 case 'yourprofileurl':
953 if ($CONF['URLMode'] == 'pathinfo')
954 echo createMemberLink($member->getID());
956 echo $CONF['IndexURL'] . createMemberLink($member->getID());
963 * Parse skinvar membermailform
965 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {
966 global $member, $CONF, $memberid;
968 if ($desturl == '') {
969 if ($CONF['URLMode'] == 'pathinfo')
970 $desturl = createMemberLink($memberid);
972 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);
975 $message = postVar('message');
976 $frommail = postVar('frommail');
978 $this->formdata = array(
979 'url' => htmlspecialchars($desturl),
980 'actionurl' => htmlspecialchars($CONF['ActionURL'],ENT_QUOTES),
981 'memberid' => $memberid,
984 'message' => htmlspecialchars($message,ENT_QUOTES),
985 'frommail' => htmlspecialchars($frommail,ENT_QUOTES)
987 if ($member->isLoggedIn()) {
988 $this->doForm('membermailform-loggedin');
989 } else if ($CONF['NonmemberMail']) {
990 $this->doForm('membermailform-notloggedin');
992 $this->doForm('membermailform-disallowed');
998 * Parse skinvar nextarchive
1000 function parse_nextarchive() {
1001 global $archivenext;
1006 * Parse skinvar nextitem
1007 * (include itemid of next item)
1009 function parse_nextitem() {
1011 if (isset($itemidnext)) echo (int)$itemidnext;
1015 * Parse skinvar nextitemtitle
1016 * (include itemtitle of next item)
1018 function parse_nextitemtitle($format = '') {
1019 global $itemtitlenext;
1023 echo stringToXML ($itemtitlenext);
1026 echo stringToAttribute ($itemtitlenext);
1029 echo $itemtitlenext;
1032 echo htmlspecialchars($itemtitlenext,ENT_QUOTES);
1038 * Parse skinvar nextlink
1040 function parse_nextlink($linktext = '', $amount = 10, $recount = '') {
1041 global $itemidnext, $archivenext, $startpos;
1042 if ($this->skintype == 'item')
1043 $this->_itemlink($itemidnext, $linktext);
1044 else if ($this->skintype == 'search' || $this->skintype == 'index')
1045 $this->_searchlink($amount, $startpos, 'next', $linktext, $recount);
1047 $this->_archivelink($archivenext, $linktext);
1051 * Parse skinvar nucleusbutton
1053 function parse_nucleusbutton($imgurl = '',
1055 $imgheight = '31') {
1057 if ($imgurl == '') {
1058 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
1059 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){
1060 // when skindit IncludeMode is used: start from skindir
1061 $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;
1064 $this->formdata = array(
1065 'imgurl' => $imgurl,
1066 'imgwidth' => $imgwidth,
1067 'imgheight' => $imgheight,
1069 $this->doForm('nucleusbutton');
1073 * Parse skinvar otherarchive
1075 function parse_otherarchive($blogname, $template, $category = '') {
1076 global $archive, $manager;
1077 sscanf($archive,'%d-%d-%d',$y,$m,$d);
1078 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1079 $this->_setBlogCategory($b, $category);
1080 $this->_preBlogContent('otherachive',$b);
1081 $b->showArchive($template, $y, $m, $d);
1082 $this->_postBlogContent('otherachive',$b);
1086 * Parse skinvar otherarchivedaylist
1088 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
1090 if ($category == 'all') $category = '';
1091 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1092 $this->_setBlogCategory($b, $category);
1093 $this->_preBlogContent('otherarchivelist',$b);
1094 $b->showArchiveList($template, 'day', $limit);
1095 $this->_postBlogContent('otherarchivelist',$b);
1099 * Parse skinvar otherarchivelist
1101 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
1103 if ($category == 'all') $category = '';
1104 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1105 $this->_setBlogCategory($b, $category);
1106 $this->_preBlogContent('otherarchivelist',$b);
1107 $b->showArchiveList($template, 'month', $limit);
1108 $this->_postBlogContent('otherarchivelist',$b);
1112 * Parse skinvar otherarchiveyearlist
1114 function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) {
1116 if ($category == 'all') $category = '';
1117 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1118 $this->_setBlogCategory($b, $category);
1119 $this->_preBlogContent('otherarchivelist',$b);
1120 $b->showArchiveList($template, 'year', $limit);
1121 $this->_postBlogContent('otherarchivelist',$b);
1125 * Parse skinvar otherblog
1127 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
1130 list($limit, $offset) = sscanf($amount, '%d(%d)');
1132 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1133 $this->_setBlogCategory($b, $category);
1134 $this->_preBlogContent('otherblog',$b);
1135 $this->amountfound = $b->readLog($template, $limit, $offset);
1136 $this->_postBlogContent('otherblog',$b);
1140 * Parse skinvar othersearchresults
1142 function parse_othersearchresults($blogname, $template, $maxresults = 50) {
1143 global $query, $amount, $manager, $startpos;
1144 $b =& $manager->getBlog(getBlogIDFromName($blogname));
1145 $this->_setBlogCategory($b, ''); // need this to select default category
1146 $this->_preBlogContent('othersearchresults',$b);
1147 $b->search($query, $template, $amount, $maxresults, $startpos);
1148 $this->_postBlogContent('othersearchresults',$b);
1152 * Executes a plugin skinvar
1154 * @param pluginName name of plugin (without the NP_)
1156 * extra parameters can be added
1158 function parse_plugin($pluginName) {
1161 // should be already tested from the parser (PARSER.php)
1162 // only continue when the plugin is really installed
1163 /*if (!$manager->pluginInstalled('NP_' . $pluginName))
1166 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1167 if (!$plugin) return;
1170 $params = func_get_args();
1172 // remove plugin name
1173 array_shift($params);
1175 // add skin type on front
1176 array_unshift($params, $this->skintype);
1178 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1182 * Parse skinvar prevarchive
1184 function parse_prevarchive() {
1185 global $archiveprev;
1190 * Parse skinvar preview
1192 function parse_preview($template) {
1193 global $blog, $CONF, $manager;
1195 $template =& $manager->getTemplate($template);
1196 $row['body'] = '<span id="prevbody"></span>';
1197 $row['title'] = '<span id="prevtitle"></span>';
1198 $row['more'] = '<span id="prevmore"></span>';
1199 $row['itemlink'] = '';
1200 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1201 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);
1202 echo TEMPLATE::fill($template['ITEM'],$row);
1203 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);
1207 * Parse skinvar previtem
1208 * (include itemid of prev item)
1210 function parse_previtem() {
1212 if (isset($itemidprev)) echo (int)$itemidprev;
1216 * Parse skinvar previtemtitle
1217 * (include itemtitle of prev item)
1219 function parse_previtemtitle($format = '') {
1220 global $itemtitleprev;
1224 echo stringToXML ($itemtitleprev);
1227 echo stringToAttribute ($itemtitleprev);
1230 echo $itemtitleprev;
1233 echo htmlspecialchars($itemtitleprev,ENT_QUOTES);
1239 * Parse skinvar prevlink
1241 function parse_prevlink($linktext = '', $amount = 10) {
1242 global $itemidprev, $archiveprev, $startpos;
1244 if ($this->skintype == 'item')
1245 $this->_itemlink($itemidprev, $linktext);
1246 else if ($this->skintype == 'search' || $this->skintype == 'index')
1247 $this->_searchlink($amount, $startpos, 'prev', $linktext);
1249 $this->_archivelink($archiveprev, $linktext);
1253 * Parse skinvar query
1254 * (includes the search query)
1256 function parse_query() {
1258 echo htmlspecialchars($query,ENT_QUOTES);
1262 * Parse skinvar referer
1264 function parse_referer() {
1265 echo htmlspecialchars(serverVar('HTTP_REFERER'),ENT_QUOTES);
1269 * Parse skinvar searchform
1271 function parse_searchform($blogname = '') {
1272 global $CONF, $manager, $maxresults;
1274 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
1278 // use default blog when no blog is selected
1279 $this->formdata = array(
1280 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
1281 'query' => htmlspecialchars(getVar('query'),ENT_QUOTES),
1283 $this->doForm('searchform');
1287 * Parse skinvar searchresults
1289 function parse_searchresults($template, $maxresults = 50 ) {
1290 global $blog, $query, $amount, $startpos;
1292 $this->_setBlogCategory($blog, ''); // need this to select default category
1293 $this->_preBlogContent('searchresults',$blog);
1294 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
1295 $this->_postBlogContent('searchresults',$blog);
1299 * Parse skinvar self
1301 function parse_self() {
1307 * Parse skinvar sitevar
1308 * (include a sitevar)
1310 function parse_sitevar($which) {
1314 echo $CONF['IndexURL'];
1317 echo $CONF['SiteName'];
1320 echo $CONF['AdminEmail'];
1323 echo $CONF['AdminURL'];
1330 function parse_skinname() {
1331 echo $this->skin->getName();
1335 * Parse skintype (experimental)
1337 function parse_skintype() {
1338 echo $this->skintype;
1344 function parse_text($which) {
1345 // constant($which) only available from 4.0.4 :(
1346 if (defined($which)) {
1347 eval("echo $which;");
1354 function parse_ticket() {
1356 $manager->addTicketHidden();
1360 * Parse skinvar todaylink
1361 * A link to the today page (depending on selected blog, etc...)
1363 function parse_todaylink($linktext = '') {
1364 global $blog, $CONF;
1366 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);
1368 echo $this->_link($CONF['SiteUrl'], $linktext);
1373 * When commentform is not used, to include a hidden field with itemid
1375 function parse_vars() {
1377 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
1381 * Parse skinvar version
1382 * (include nucleus versionnumber)
1384 function parse_version() {
1386 echo 'Nucleus CMS ' . $nucleus['version'];
1390 * Parse skinvar sticky
1392 function parse_sticky($itemnumber = 0, $template = '') {
1395 $itemnumber = intval($itemnumber);
1396 $itemarray = array($itemnumber);
1398 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
1399 $this->_preBlogContent('sticky',$b);
1400 $this->amountfound = $b->readLogFromList($itemarray, $template);
1401 $this->_postBlogContent('sticky',$b);