00001 <?php 00002 /* 00003 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 00004 * Copyright (C) 2002-2007 The Nucleus Group 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * (see nucleus/documentation/index.html#license for more info) 00011 */ 00025 class ACTIONS extends BaseActions { 00026 00027 // part of the skin currently being parsed ('index', 'item', 'archive', 00028 // 'archivelist', 'member', 'search', 'error', 'imagepopup') 00029 var $skintype; 00030 00031 // contains an assoc array with parameters that need to be included when 00032 // generating links to items/archives/... (e.g. catid) 00033 var $linkparams; 00034 00035 // reference to the skin object for which a part is being parsed 00036 var $skin; 00037 00038 // used when including templated forms from the include/ dir. The $formdata var 00039 // contains the values to fill out in there (assoc array name -> value) 00040 var $formdata; 00041 00042 // filled out with the number of displayed items after calling one of the 00043 // (other)blog/(other)searchresults skinvars. 00044 var $amountfound; 00045 00049 function ACTIONS($type) { 00050 // call constructor of superclass first 00051 $this->BaseActions(); 00052 00053 $this->skintype = $type; 00054 00055 global $catid; 00056 if ($catid) 00057 $this->linkparams = array('catid' => $catid); 00058 } 00059 00063 function setSkin(&$skin) { 00064 $this->skin =& $skin; 00065 } 00066 00070 function setParser(&$parser) { 00071 $this->parser =& $parser; 00072 } 00073 00077 function doForm($filename) { 00078 global $DIR_NUCLEUS; 00079 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket'); 00080 $oldIncludeMode = PARSER::getProperty('IncludeMode'); 00081 $oldIncludePrefix = PARSER::getProperty('IncludePrefix'); 00082 PARSER::setProperty('IncludeMode','normal'); 00083 PARSER::setProperty('IncludePrefix',''); 00084 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template'); 00085 PARSER::setProperty('IncludeMode',$oldIncludeMode); 00086 PARSER::setProperty('IncludePrefix',$oldIncludePrefix); 00087 array_pop($this->parser->actions); // errordiv 00088 array_pop($this->parser->actions); // callback 00089 array_pop($this->parser->actions); // text 00090 array_pop($this->parser->actions); // formdata 00091 array_pop($this->parser->actions); // ticket 00092 } 00093 00101 function checkCondition($field, $name='', $value = '') { 00102 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists; 00103 00104 $condition = 0; 00105 switch($field) { 00106 case 'category': 00107 $condition = ($blog && $this->_ifCategory($name,$value)); 00108 break; 00109 case 'blogsetting': 00110 $condition = ($blog && ($blog->getSetting($name) == $value)); 00111 break; 00112 case 'loggedin': 00113 $condition = $member->isLoggedIn(); 00114 break; 00115 case 'onteam': 00116 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name); 00117 break; 00118 case 'admin': 00119 $condition = $member->isLoggedIn() && $this->_ifAdmin($name); 00120 break; 00121 case 'nextitem': 00122 $condition = ($itemidnext != ''); 00123 break; 00124 case 'previtem': 00125 $condition = ($itemidprev != ''); 00126 break; 00127 case 'archiveprevexists': 00128 $condition = ($archiveprevexists == true); 00129 break; 00130 case 'archivenextexists': 00131 $condition = ($archivenextexists == true); 00132 break; 00133 case 'skintype': 00134 $condition = ($name == $this->skintype); 00135 break; 00136 case 'hasplugin': 00137 $condition = $this->_ifHasPlugin($name, $value); 00138 break; 00139 default: 00140 $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value); 00141 break; 00142 } 00143 return $condition; 00144 } 00145 00154 function _ifHasPlugin($name, $value) { 00155 global $manager; 00156 $condition = false; 00157 // (pluginInstalled method won't write a message in the actionlog on failure) 00158 if ($manager->pluginInstalled('NP_'.$name)) { 00159 $plugin =& $manager->getPlugin('NP_' . $name); 00160 if ($plugin != NULL) { 00161 if ($value == "") { 00162 $condition = true; 00163 } else { 00164 list($name2, $value2) = explode('=', $value, 2); 00165 if ($value2 == "" && $plugin->getOption($name2) != 'no') { 00166 $condition = true; 00167 } else if ($plugin->getOption($name2) == $value2) { 00168 $condition = true; 00169 } 00170 } 00171 } 00172 } 00173 return $condition; 00174 } 00175 00179 function _ifPlugin($name, $key = '', $value = '') { 00180 global $manager; 00181 00182 $plugin =& $manager->getPlugin('NP_' . $name); 00183 if (!$plugin) return; 00184 00185 $params = func_get_args(); 00186 array_shift($params); 00187 00188 return call_user_func_array(array(&$plugin, 'doIf'), $params); 00189 } 00190 00194 function _ifCategory($name = '', $value='') { 00195 global $blog, $catid; 00196 00197 // when no parameter is defined, just check if a category is selected 00198 if (($name != 'catname' && $name != 'catid') || ($value == '')) 00199 return $blog->isValidCategory($catid); 00200 00201 // check category name 00202 if ($name == 'catname') { 00203 $value = $blog->getCategoryIdFromName($value); 00204 if ($value == $catid) 00205 return $blog->isValidCategory($catid); 00206 } 00207 00208 // check category id 00209 if (($name == 'catid') && ($value == $catid)) 00210 return $blog->isValidCategory($catid); 00211 00212 return false; 00213 } 00214 00218 function _ifOnTeam($blogName = '') { 00219 global $blog, $member, $manager; 00220 00221 // when no blog found 00222 if (($blogName == '') && (!is_object($blog))) 00223 return 0; 00224 00225 // explicit blog selection 00226 if ($blogName != '') 00227 $blogid = getBlogIDFromName($blogName); 00228 00229 if (($blogName == '') || !$manager->existsBlogID($blogid)) 00230 // use current blog 00231 $blogid = $blog->getID(); 00232 00233 return $member->teamRights($blogid); 00234 } 00235 00239 function _ifAdmin($blogName = '') { 00240 global $blog, $member, $manager; 00241 00242 // when no blog found 00243 if (($blogName == '') && (!is_object($blog))) 00244 return 0; 00245 00246 // explicit blog selection 00247 if ($blogName != '') 00248 $blogid = getBlogIDFromName($blogName); 00249 00250 if (($blogName == '') || !$manager->existsBlogID($blogid)) 00251 // use current blog 00252 $blogid = $blog->getID(); 00253 00254 return $member->isBlogAdmin($blogid); 00255 } 00256 00262 function _link($url, $linktext = '') 00263 { 00264 $u = htmlspecialchars($url); 00265 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands 00266 if ($linktext != '') 00267 $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>'; 00268 else 00269 $l = $u; 00270 return $l; 00271 } 00272 00286 function _searchlink($maxresults, $startpos, $direction, $linktext = '') { 00287 global $CONF, $blog, $query, $amount; 00288 // TODO: Move request uri to linkparams. this is ugly. sorry for that. 00289 $startpos = intval($startpos); // will be 0 when empty. 00290 $parsed = parse_url(serverVar('REQUEST_URI')); 00291 $parsed = $parsed['query']; 00292 $url = ''; 00293 00294 switch ($direction) { 00295 case 'prev': 00296 if ( intval($startpos) - intval($maxresults) >= 0) { 00297 $startpos = intval($startpos) - intval($maxresults); 00298 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos); 00299 } 00300 break; 00301 case 'next': 00302 $iAmountOnPage = $this->amountfound; 00303 if ($iAmountOnPage == 0) 00304 { 00305 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%] 00306 // try a count query 00307 switch ($this->skintype) 00308 { 00309 case 'index': 00310 $sqlquery = $blog->getSqlBlog('', 'count'); 00311 break; 00312 case 'search': 00313 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count'); 00314 break; 00315 } 00316 if ($sqlquery) 00317 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos); 00318 } 00319 if (intval($iAmountOnPage) >= intval($maxresults)) { 00320 $startpos = intval($startpos) + intval($maxresults); 00321 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos); 00322 } 00323 break; 00324 default: 00325 break; 00326 } // switch($direction) 00327 00328 if ($url != '') 00329 echo $this->_link($url, $linktext); 00330 } 00331 00335 function _itemlink($id, $linktext = '') { 00336 global $CONF; 00337 if ($id) 00338 echo $this->_link(createItemLink($id, $this->linkparams), $linktext); 00339 else 00340 $this->parse_todaylink($linktext); 00341 } 00342 00346 function _archivelink($id, $linktext = '') { 00347 global $CONF, $blog; 00348 if ($id) 00349 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext); 00350 else 00351 $this->parse_todaylink($linktext); 00352 } 00353 00362 function _setBlogCategory(&$blog, $catname) { 00363 global $catid; 00364 if ($catname != '') 00365 $blog->setSelectedCategoryByName($catname); 00366 else 00367 $blog->setSelectedCategory($catid); 00368 } 00369 00373 function _preBlogContent($type, &$blog) { 00374 global $manager; 00375 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type)); 00376 } 00377 00381 function _postBlogContent($type, &$blog) { 00382 global $manager; 00383 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type)); 00384 } 00385 00389 function parse_additemform() { 00390 global $blog, $CONF; 00391 $this->formdata = array( 00392 'adminurl' => htmlspecialchars($CONF['AdminURL'],ENT_QUOTES), 00393 'catid' => $blog->getDefaultCategory() 00394 ); 00395 $blog->InsertJavaScriptInfo(); 00396 $this->doForm('additemform'); 00397 } 00398 00403 function parse_adminurl() { 00404 $this->parse_sitevar('adminurl'); 00405 } 00406 00410 function parse_archive($template, $category = '') { 00411 global $blog, $archive; 00412 // can be used with either yyyy-mm or yyyy-mm-dd 00413 sscanf($archive,'%d-%d-%d',$y,$m,$d); 00414 $this->_setBlogCategory($blog, $category); 00415 $this->_preBlogContent('achive',$blog); 00416 $blog->showArchive($template, $y, $m, $d); 00417 $this->_postBlogContent('achive',$blog); 00418 00419 } 00420 00424 function parse_archivedate($locale = '-def-') { 00425 global $archive; 00426 00427 if ($locale == '-def-') 00428 setlocale(LC_TIME,$template['LOCALE']); 00429 else 00430 setlocale(LC_TIME,$locale); 00431 00432 // get archive date 00433 sscanf($archive,'%d-%d-%d',$y,$m,$d); 00434 00435 // get format 00436 $args = func_get_args(); 00437 // format can be spread over multiple parameters 00438 if (sizeof($args) > 1) { 00439 // take away locale 00440 array_shift($args); 00441 // implode 00442 $format=implode(',',$args); 00443 } elseif ($d == 0) { 00444 $format = '%B %Y'; 00445 } else { 00446 $format = '%d %B %Y'; 00447 } 00448 00449 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y)); 00450 } 00451 00455 function parse_archivedaylist($template, $category = 'all', $limit = 0) { 00456 global $blog; 00457 if ($category == 'all') $category = ''; 00458 $this->_preBlogContent('archivelist',$blog); 00459 $this->_setBlogCategory($blog, $category); 00460 $blog->showArchiveList($template, 'day', $limit); 00461 $this->_postBlogContent('archivelist',$blog); 00462 } 00463 00467 function parse_archivelink($linktext = '') { 00468 global $blog, $CONF; 00469 if ($blog) 00470 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext); 00471 else 00472 echo $this->_link(createArchiveListLink(), $linktext); 00473 } 00474 00475 function parse_archivelist($template, $category = 'all', $limit = 0) { 00476 global $blog; 00477 if ($category == 'all') $category = ''; 00478 $this->_preBlogContent('archivelist',$blog); 00479 $this->_setBlogCategory($blog, $category); 00480 $blog->showArchiveList($template, 'month', $limit); 00481 $this->_postBlogContent('archivelist',$blog); 00482 } 00483 00487 function parse_archivetype() { 00488 global $archivetype; 00489 echo $archivetype; 00490 } 00491 00495 function parse_blog($template, $amount = 10, $category = '') { 00496 global $blog, $startpos; 00497 00498 list($limit, $offset) = sscanf($amount, '%d(%d)'); 00499 $this->_setBlogCategory($blog, $category); 00500 $this->_preBlogContent('blog',$blog); 00501 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos); 00502 $this->_postBlogContent('blog',$blog); 00503 } 00504 00505 /* 00506 * Parse skinvar bloglist 00507 * Shows a list of all blogs 00508 * bnametype: whether 'name' or 'shortname' is used for the link text 00509 */ 00510 function parse_bloglist($template, $bnametype = '') { 00511 BLOG::showBlogList($template, $bnametype); 00512 } 00513 00517 function parse_blogsetting($which) { 00518 global $blog; 00519 switch($which) { 00520 case 'id': 00521 echo htmlspecialchars($blog->getID(),ENT_QUOTES); 00522 break; 00523 case 'url': 00524 echo htmlspecialchars($blog->getURL(),ENT_QUOTES); 00525 break; 00526 case 'name': 00527 echo htmlspecialchars($blog->getName(),ENT_QUOTES); 00528 break; 00529 case 'desc': 00530 echo htmlspecialchars($blog->getDescription(),ENT_QUOTES); 00531 break; 00532 case 'short': 00533 echo htmlspecialchars($blog->getShortName(),ENT_QUOTES); 00534 break; 00535 } 00536 } 00537 00541 function parse_callback($eventName, $type) 00542 { 00543 global $manager; 00544 $manager->notify($eventName, array('type' => $type)); 00545 } 00546 00550 function parse_category($type = 'name') { 00551 global $catid, $blog; 00552 if (!$blog->isValidCategory($catid)) 00553 return; 00554 00555 switch($type) { 00556 case 'name': 00557 echo $blog->getCategoryName($catid); 00558 break; 00559 case 'desc': 00560 echo $blog->getCategoryDesc($catid); 00561 break; 00562 case 'id': 00563 echo $catid; 00564 break; 00565 } 00566 } 00567 00571 function parse_categorylist($template, $blogname = '') { 00572 global $blog, $manager; 00573 00574 if ($blogname == '') { 00575 $this->_preBlogContent('categorylist',$blog); 00576 $blog->showCategoryList($template); 00577 $this->_postBlogContent('categorylist',$blog); 00578 } else { 00579 $b =& $manager->getBlog(getBlogIDFromName($blogname)); 00580 $this->_preBlogContent('categorylist',$b); 00581 $b->showCategoryList($template); 00582 $this->_postBlogContent('categorylist',$b); 00583 } 00584 } 00585 00589 function parse_charset() { 00590 echo _CHARSET; 00591 } 00592 00596 function parse_commentform($destinationurl = '') { 00597 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage; 00598 00599 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0) 00600 if (stristr($destinationurl, 'action.php')) { 00601 $args = func_get_args(); 00602 $destinationurl = $args[1]; 00603 ACTIONLOG::add(WARNING,'actionurl is not longer a parameter on commentform skinvars. Moved to be a global setting instead.'); 00604 } 00605 00606 $actionurl = $CONF['ActionURL']; 00607 00608 // if item is closed, show message and do nothing 00609 $item =& $manager->getItem($itemid,0,0); 00610 if ($item['closed'] || !$blog->commentsEnabled()) { 00611 $this->doForm('commentform-closed'); 00612 return; 00613 } 00614 00615 if (!$destinationurl) 00616 { 00617 $destinationurl = createLink( 00618 'item', 00619 array( 00620 'itemid' => $itemid, 00621 'title' => $item['title'], 00622 'timestamp' => $item['timestamp'], 00623 'extra' => $this->linkparams 00624 ) 00625 ); 00626 00627 // note: createLink returns an HTML encoded URL 00628 } else { 00629 // HTML encode URL 00630 $destinationurl = htmlspecialchars($destinationurl,ENT_QUOTES); 00631 } 00632 00633 // values to prefill 00634 $user = cookieVar($CONF['CookiePrefix'] .'comment_user'); 00635 if (!$user) $user = postVar('user'); 00636 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid'); 00637 if (!$userid) $userid = postVar('userid'); 00638 $email = cookieVar($CONF['CookiePrefix'] .'comment_email'); 00639 if (!$email) { 00640 $email = postVar('email'); 00641 } 00642 $body = postVar('body'); 00643 00644 $this->formdata = array( 00645 'destinationurl' => $destinationurl, // url is already HTML encoded 00646 'actionurl' => htmlspecialchars($actionurl,ENT_QUOTES), 00647 'itemid' => $itemid, 00648 'user' => htmlspecialchars($user,ENT_QUOTES), 00649 'userid' => htmlspecialchars($userid,ENT_QUOTES), 00650 'email' => htmlspecialchars($email,ENT_QUOTES), 00651 'body' => htmlspecialchars($body,ENT_QUOTES), 00652 'membername' => $member->getDisplayName(), 00653 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':'' 00654 ); 00655 00656 if (!$member->isLoggedIn()) { 00657 $this->doForm('commentform-notloggedin'); 00658 } else { 00659 $this->doForm('commentform-loggedin'); 00660 } 00661 } 00662 00667 function parse_comments($template) { 00668 global $itemid, $manager, $blog, $highlight; 00669 $template =& $manager->getTemplate($template); 00670 00671 // create parser object & action handler 00672 $actions =& new ITEMACTIONS($blog); 00673 $parser =& new PARSER($actions->getDefinedActions(),$actions); 00674 $actions->setTemplate($template); 00675 $actions->setParser($parser); 00676 $item = ITEM::getitem($itemid, 0, 0); 00677 $actions->setCurrentItem($item); 00678 00679 $comments =& new COMMENTS($itemid); 00680 $comments->setItemActions($actions); 00681 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments 00682 } 00683 00687 function parse_errordiv() { 00688 global $errormessage; 00689 if ($errormessage) 00690 echo '<div class="error">', htmlspecialchars($errormessage),'</div>'; 00691 } 00692 00696 function parse_errormessage() { 00697 global $errormessage; 00698 echo $errormessage; 00699 } 00700 00704 function parse_formdata($what) { 00705 echo $this->formdata[$what]; 00706 } 00707 00711 function parse_ifcat($text = '') { 00712 if ($text == '') { 00713 // new behaviour 00714 $this->parse_if('category'); 00715 } else { 00716 // old behaviour 00717 global $catid, $blog; 00718 if ($blog->isValidCategory($catid)) 00719 echo $text; 00720 } 00721 } 00722 00726 function parse_image($what = 'imgtag') { 00727 global $CONF; 00728 00729 $imagetext = htmlspecialchars(requestVar('imagetext')); 00730 $imagepopup = requestVar('imagepopup'); 00731 $width = intRequestVar('width'); 00732 $height = intRequestVar('height'); 00733 $fullurl = htmlspecialchars($CONF['MediaURL'] . $imagepopup); 00734 00735 switch($what) 00736 { 00737 case 'url': 00738 echo $fullurl; 00739 break; 00740 case 'width': 00741 echo $width; 00742 break; 00743 case 'height': 00744 echo $height; 00745 break; 00746 case 'caption': 00747 case 'text': 00748 echo $imagetext; 00749 break; 00750 case 'imgtag': 00751 default: 00752 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />"; 00753 break; 00754 } 00755 } 00756 00760 function parse_imagetext() { 00761 echo htmlspecialchars(requestVar('imagetext'),ENT_QUOTES); 00762 } 00763 00768 function parse_item($template) { 00769 global $blog, $itemid, $highlight; 00770 $this->_setBlogCategory($blog, ''); // need this to select default category 00771 $this->_preBlogContent('item',$blog); 00772 $r = $blog->showOneitem($itemid, $template, $highlight); 00773 if ($r == 0) 00774 echo _ERROR_NOSUCHITEM; 00775 $this->_postBlogContent('item',$blog); 00776 } 00777 00781 function parse_itemid() { 00782 global $itemid; 00783 echo $itemid; 00784 } 00785 00789 function parse_itemlink($linktext = '') { 00790 global $itemid; 00791 $this->_itemlink($itemid, $linktext); 00792 } 00793 00797 function parse_itemtitle($format = '') { 00798 global $manager, $itemid; 00799 $item =& $manager->getItem($itemid,0,0); 00800 00801 switch ($format) { 00802 case 'xml': 00803 echo stringToXML ($item['title']); 00804 break; 00805 case 'attribute': 00806 echo stringToAttribute ($item['title']); 00807 break; 00808 case 'raw': 00809 echo $item['title']; 00810 break; 00811 default: 00812 echo htmlspecialchars(strip_tags($item['title']),ENT_QUOTES); 00813 break; 00814 } 00815 } 00816 00820 function parse_loginform() { 00821 global $member, $CONF; 00822 if (!$member->isLoggedIn()) { 00823 $filename = 'loginform-notloggedin'; 00824 $this->formdata = array(); 00825 } else { 00826 $filename = 'loginform-loggedin'; 00827 $this->formdata = array( 00828 'membername' => $member->getDisplayName(), 00829 ); 00830 } 00831 $this->doForm($filename); 00832 } 00833 00838 function parse_member($what) { 00839 global $memberinfo, $member; 00840 00841 // 1. only allow the member-details-page specific variables on member pages 00842 if ($this->skintype == 'member') { 00843 00844 switch($what) { 00845 case 'name': 00846 echo htmlspecialchars($memberinfo->getDisplayName(),ENT_QUOTES); 00847 break; 00848 case 'realname': 00849 echo htmlspecialchars($memberinfo->getRealName(),ENT_QUOTES); 00850 break; 00851 case 'notes': 00852 echo htmlspecialchars($memberinfo->getNotes(),ENT_QUOTES); 00853 break; 00854 case 'url': 00855 echo htmlspecialchars($memberinfo->getURL(),ENT_QUOTES); 00856 break; 00857 case 'email': 00858 echo htmlspecialchars($memberinfo->getEmail(),ENT_QUOTES); 00859 break; 00860 case 'id': 00861 echo htmlspecialchars($memberinfo->getID(),ENT_QUOTES); 00862 break; 00863 } 00864 } 00865 00866 // 2. the next bunch of options is available everywhere, as long as the user is logged in 00867 if ($member->isLoggedIn()) 00868 { 00869 switch($what) { 00870 case 'yourname': 00871 echo $member->getDisplayName(); 00872 break; 00873 case 'yourrealname': 00874 echo $member->getRealName(); 00875 break; 00876 case 'yournotes': 00877 echo $member->getNotes(); 00878 break; 00879 case 'yoururl': 00880 echo $member->getURL(); 00881 break; 00882 case 'youremail': 00883 echo $member->getEmail(); 00884 break; 00885 case 'yourid': 00886 echo $member->getID(); 00887 break; 00888 } 00889 } 00890 00891 } 00892 00896 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') { 00897 global $member, $CONF, $memberid; 00898 00899 if ($desturl == '') { 00900 if ($CONF['URLMode'] == 'pathinfo') 00901 $desturl = createMemberLink($memberid); 00902 else 00903 $desturl = $CONF['IndexURL'] . createMemberLink($memberid); 00904 } 00905 00906 $message = postVar('message'); 00907 $frommail = postVar('frommail'); 00908 00909 $this->formdata = array( 00910 'url' => htmlspecialchars($desturl), 00911 'actionurl' => htmlspecialchars($CONF['ActionURL'],ENT_QUOTES), 00912 'memberid' => $memberid, 00913 'rows' => $rows, 00914 'cols' => $cols, 00915 'message' => htmlspecialchars($message,ENT_QUOTES), 00916 'frommail' => htmlspecialchars($frommail,ENT_QUOTES) 00917 ); 00918 if ($member->isLoggedIn()) { 00919 $this->doForm('membermailform-loggedin'); 00920 } else if ($CONF['NonmemberMail']) { 00921 $this->doForm('membermailform-notloggedin'); 00922 } else { 00923 $this->doForm('membermailform-disallowed'); 00924 } 00925 00926 } 00927 00931 function parse_nextarchive() { 00932 global $archivenext; 00933 echo $archivenext; 00934 } 00935 00940 function parse_nextitem() { 00941 global $itemidnext; 00942 if (isset($itemidnext)) echo (int)$itemidnext; 00943 } 00944 00949 function parse_nextitemtitle($format = '') { 00950 global $itemtitlenext; 00951 00952 switch ($format) { 00953 case 'xml': 00954 echo stringToXML ($itemtitlenext); 00955 break; 00956 case 'attribute': 00957 echo stringToAttribute ($itemtitlenext); 00958 break; 00959 case 'raw': 00960 echo $itemtitlenext; 00961 break; 00962 default: 00963 echo htmlspecialchars($itemtitlenext,ENT_QUOTES); 00964 break; 00965 } 00966 } 00967 00971 function parse_nextlink($linktext = '', $amount = 10) { 00972 global $itemidnext, $archivenext, $startpos; 00973 if ($this->skintype == 'item') 00974 $this->_itemlink($itemidnext, $linktext); 00975 else if ($this->skintype == 'search' || $this->skintype == 'index') 00976 $this->_searchlink($amount, $startpos, 'next', $linktext); 00977 else 00978 $this->_archivelink($archivenext, $linktext); 00979 } 00980 00984 function parse_nucleusbutton($imgurl = '', 00985 $imgwidth = '85', 00986 $imgheight = '31') { 00987 global $CONF; 00988 if ($imgurl == '') { 00989 $imgurl = $CONF['AdminURL'] . 'nucleus.gif'; 00990 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){ 00991 // when skindit IncludeMode is used: start from skindir 00992 $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl; 00993 } 00994 00995 $this->formdata = array( 00996 'imgurl' => $imgurl, 00997 'imgwidth' => $imgwidth, 00998 'imgheight' => $imgheight, 00999 ); 01000 $this->doForm('nucleusbutton'); 01001 } 01002 01006 function parse_otherarchive($blogname, $template, $category = '') { 01007 global $archive, $manager; 01008 sscanf($archive,'%d-%d-%d',$y,$m,$d); 01009 $b =& $manager->getBlog(getBlogIDFromName($blogname)); 01010 $this->_setBlogCategory($b, $category); 01011 $this->_preBlogContent('otherachive',$b); 01012 $b->showArchive($template, $y, $m, $d); 01013 $this->_postBlogContent('otherachive',$b); 01014 } 01015 01019 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) { 01020 global $manager; 01021 if ($category == 'all') $category = ''; 01022 $b =& $manager->getBlog(getBlogIDFromName($blogname)); 01023 $this->_setBlogCategory($b, $category); 01024 $this->_preBlogContent('otherarchivelist',$b); 01025 $b->showArchiveList($template, 'day', $limit); 01026 $this->_postBlogContent('otherarchivelist',$b); 01027 } 01028 01032 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) { 01033 global $manager; 01034 if ($category == 'all') $category = ''; 01035 $b =& $manager->getBlog(getBlogIDFromName($blogname)); 01036 $this->_setBlogCategory($b, $category); 01037 $this->_preBlogContent('otherarchivelist',$b); 01038 $b->showArchiveList($template, 'month', $limit); 01039 $this->_postBlogContent('otherarchivelist',$b); 01040 } 01041 01045 function parse_otherblog($blogname, $template, $amount = 10, $category = '') { 01046 global $manager; 01047 01048 list($limit, $offset) = sscanf($amount, '%d(%d)'); 01049 01050 $b =& $manager->getBlog(getBlogIDFromName($blogname)); 01051 $this->_setBlogCategory($b, $category); 01052 $this->_preBlogContent('otherblog',$b); 01053 $this->amountfound = $b->readLog($template, $limit, $offset); 01054 $this->_postBlogContent('otherblog',$b); 01055 } 01056 01060 function parse_othersearchresults($blogname, $template, $maxresults = 50) { 01061 global $query, $amount, $manager, $startpos; 01062 $b =& $manager->getBlog(getBlogIDFromName($blogname)); 01063 $this->_setBlogCategory($b, ''); // need this to select default category 01064 $this->_preBlogContent('othersearchresults',$b); 01065 $b->search($query, $template, $amount, $maxresults, $startpos); 01066 $this->_postBlogContent('othersearchresults',$b); 01067 } 01068 01076 function parse_plugin($pluginName) { 01077 global $manager; 01078 01079 // only continue when the plugin is really installed 01080 if (!$manager->pluginInstalled('NP_' . $pluginName)) 01081 return; 01082 01083 $plugin =& $manager->getPlugin('NP_' . $pluginName); 01084 if (!$plugin) return; 01085 01086 // get arguments 01087 $params = func_get_args(); 01088 01089 // remove plugin name 01090 array_shift($params); 01091 01092 // add skin type on front 01093 array_unshift($params, $this->skintype); 01094 01095 call_user_func_array(array(&$plugin,'doSkinVar'), $params); 01096 } 01097 01101 function parse_prevarchive() { 01102 global $archiveprev; 01103 echo $archiveprev; 01104 } 01105 01109 function parse_preview($template) { 01110 global $blog, $CONF, $manager; 01111 01112 $template =& $manager->getTemplate($template); 01113 $row['body'] = '<span id="prevbody"></span>'; 01114 $row['title'] = '<span id="prevtitle"></span>'; 01115 $row['more'] = '<span id="prevmore"></span>'; 01116 $row['itemlink'] = ''; 01117 $row['itemid'] = 0; $row['blogid'] = $blog->getID(); 01118 echo TEMPLATE::fill($template['ITEM_HEADER'],$row); 01119 echo TEMPLATE::fill($template['ITEM'],$row); 01120 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row); 01121 } 01122 01123 /* 01124 * Parse skinvar previtem 01125 * (include itemid of prev item) 01126 */ 01127 function parse_previtem() { 01128 global $itemidprev; 01129 if (isset($itemidprev)) echo (int)$itemidprev; 01130 } 01131 01136 function parse_previtemtitle($format = '') { 01137 global $itemtitleprev; 01138 01139 switch ($format) { 01140 case 'xml': 01141 echo stringToXML ($itemtitleprev); 01142 break; 01143 case 'attribute': 01144 echo stringToAttribute ($itemtitleprev); 01145 break; 01146 case 'raw': 01147 echo $itemtitleprev; 01148 break; 01149 default: 01150 echo htmlspecialchars($itemtitleprev,ENT_QUOTES); 01151 break; 01152 } 01153 } 01154 01158 function parse_prevlink($linktext = '', $amount = 10) { 01159 global $itemidprev, $archiveprev, $startpos; 01160 01161 if ($this->skintype == 'item') 01162 $this->_itemlink($itemidprev, $linktext); 01163 else if ($this->skintype == 'search' || $this->skintype == 'index') 01164 $this->_searchlink($amount, $startpos, 'prev', $linktext); 01165 else 01166 $this->_archivelink($archiveprev, $linktext); 01167 } 01168 01173 function parse_query() { 01174 global $query; 01175 echo htmlspecialchars($query,ENT_QUOTES); 01176 } 01177 01181 function parse_referer() { 01182 echo htmlspecialchars(serverVar('HTTP_REFERER'),ENT_QUOTES); 01183 } 01184 01188 function parse_searchform($blogname = '') { 01189 global $CONF, $manager, $maxresults; 01190 if ($blogname) { 01191 $blog =& $manager->getBlog(getBlogIDFromName($blogname)); 01192 } else { 01193 global $blog; 01194 } 01195 // use default blog when no blog is selected 01196 $this->formdata = array( 01197 'id' => $blog?$blog->getID():$CONF['DefaultBlog'], 01198 'query' => htmlspecialchars(getVar('query'),ENT_QUOTES), 01199 ); 01200 $this->doForm('searchform'); 01201 } 01202 01206 function parse_searchresults($template, $maxresults = 50 ) { 01207 global $blog, $query, $amount, $startpos; 01208 01209 $this->_setBlogCategory($blog, ''); // need this to select default category 01210 $this->_preBlogContent('searchresults',$blog); 01211 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos); 01212 $this->_postBlogContent('searchresults',$blog); 01213 } 01214 01218 function parse_self() { 01219 global $CONF; 01220 echo $CONF['Self']; 01221 } 01222 01227 function parse_sitevar($which) { 01228 global $CONF; 01229 switch($which) { 01230 case 'url': 01231 echo $CONF['IndexURL']; 01232 break; 01233 case 'name': 01234 echo $CONF['SiteName']; 01235 break; 01236 case 'admin': 01237 echo $CONF['AdminEmail']; 01238 break; 01239 case 'adminurl': 01240 echo $CONF['AdminURL']; 01241 } 01242 } 01243 01247 function parse_skinname() { 01248 echo $this->skin->getName(); 01249 } 01250 01254 function parse_skintype() { 01255 echo $this->skintype; 01256 } 01257 01261 function parse_text($which) { 01262 // constant($which) only available from 4.0.4 :( 01263 if (defined($which)) { 01264 eval("echo $which;"); 01265 } 01266 } 01267 01271 function parse_ticket() { 01272 global $manager; 01273 $manager->addTicketHidden(); 01274 } 01275 01280 function parse_todaylink($linktext = '') { 01281 global $blog, $CONF; 01282 if ($blog) 01283 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext); 01284 else 01285 echo $this->_link($CONF['SiteUrl'], $linktext); 01286 } 01287 01292 function parse_vars() { 01293 global $itemid; 01294 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />'; 01295 } 01296 01301 function parse_version() { 01302 global $nucleus; 01303 echo 'Nucleus CMS ' . $nucleus['version']; 01304 } 01305 01306 } 01307 ?>