3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2012 The Nucleus Group
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
10 * (see nucleus/documentation/index.html#license for more info)
\r
13 * This class contains the functions that get called by using
\r
14 * the special tags in the skins
\r
16 * The allowed tags for a type of skinpart are defined by the
\r
17 * Skin::getAllowedActionsForType($type) method
\r
19 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
20 * @copyright Copyright (C) 2002-2012 The Nucleus Group
\r
21 * @version $Id: ACTIONS.php 1721 2012-03-31 10:18:25Z sakamocchi $
\r
24 class Actions extends BaseActions
\r
26 // part of the skin currently being parsed ('index', 'item', 'archive',
\r
27 // 'archivelist', 'member', 'search', 'error', 'imagepopup')
\r
30 // contains an assoc array with parameters that need to be included when
\r
31 // generating links to items/archives/... (e.g. catid)
\r
34 // reference to the skin object for which a part is being parsed
\r
37 // used when including templated forms from the include/ dir. The $formdata var
\r
38 // contains the values to fill out in there (assoc array name -> value)
\r
41 // filled out with the number of displayed items after calling one of the
\r
42 // (other)blog/(other)searchresults skinvars.
\r
46 * Constructor for a new Actions object
\r
48 function Actions($type) {
\r
49 // call constructor of superclass first
\r
50 $this->BaseActions();
\r
52 $this->skintype = $type;
\r
56 $this->linkparams = array('catid' => $catid);
\r
62 function setSkin(&$skin) {
\r
63 $this->skin =& $skin;
\r
69 function setParser(&$parser) {
\r
70 $this->parser =& $parser;
\r
74 * Forms get parsedincluded now, using an extra <formdata> skinvar
\r
76 function doForm($filename) {
\r
77 global $DIR_NUCLEUS;
\r
78 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');
\r
79 $oldIncludeMode = Parser::getProperty('IncludeMode');
\r
80 $oldIncludePrefix = Parser::getProperty('IncludePrefix');
\r
81 Parser::setProperty('IncludeMode','normal');
\r
82 Parser::setProperty('IncludePrefix','');
\r
83 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
\r
84 Parser::setProperty('IncludeMode',$oldIncludeMode);
\r
85 Parser::setProperty('IncludePrefix',$oldIncludePrefix);
\r
86 array_pop($this->parser->actions); // errordiv
\r
87 array_pop($this->parser->actions); // callback
\r
88 array_pop($this->parser->actions); // text
\r
89 array_pop($this->parser->actions); // formdata
\r
90 array_pop($this->parser->actions); // ticket
\r
94 * Checks conditions for if statements
\r
96 * @param string $field type of <%if%>
\r
97 * @param string $name property of field
\r
98 * @param string $value value of property
\r
100 function checkCondition($field, $name='', $value = '') {
\r
101 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
\r
106 $condition = ($blog && $this->_ifCategory($name,$value));
\r
108 case 'blogsetting':
\r
109 $condition = ($blog && ($blog->getSetting($name) == $value));
\r
112 $condition = $member->isLoggedIn();
\r
115 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
\r
118 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
\r
121 $condition = ($itemidnext != '');
\r
124 $condition = ($itemidprev != '');
\r
126 case 'archiveprevexists':
\r
127 $condition = ($archiveprevexists == true);
\r
129 case 'archivenextexists':
\r
130 $condition = ($archivenextexists == true);
\r
133 $condition = ($name == $this->skintype);
\r
136 $condition = $this->_ifHasPlugin($name, $value);
\r
139 $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);
\r
146 * hasplugin,PlugName
\r
147 * -> checks if plugin exists
\r
148 * hasplugin,PlugName,OptionName
\r
149 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
\r
150 * hasplugin,PlugName,OptionName=value
\r
151 * -> checks if the option OptionName from plugin PlugName is set to value
\r
153 function _ifHasPlugin($name, $value) {
\r
155 $condition = false;
\r
156 // (pluginInstalled method won't write a message in the actionlog on failure)
\r
157 if ($manager->pluginInstalled('NP_'.$name)) {
\r
158 $plugin =& $manager->getPlugin('NP_' . $name);
\r
159 if ($plugin != NULL) {
\r
160 if ($value == "") {
\r
163 list($name2, $value2) = i18n::explode('=', $value, 2);
\r
164 if ($value2 == "" && $plugin->getOption($name2) != 'no') {
\r
166 } else if ($plugin->getOption($name2) == $value2) {
\r
176 * Checks if a plugin exists and call its doIf function
\r
178 function _ifPlugin($name, $key = '', $value = '') {
\r
181 $plugin =& $manager->getPlugin('NP_' . $name);
\r
182 if (!$plugin) return;
\r
184 $params = func_get_args();
\r
185 array_shift($params);
\r
187 return call_user_func_array(array(&$plugin, 'doIf'), $params);
\r
191 * Different checks for a category
\r
193 function _ifCategory($name = '', $value='') {
\r
194 global $blog, $catid;
\r
196 // when no parameter is defined, just check if a category is selected
\r
197 if (($name != 'catname' && $name != 'catid') || ($value == ''))
\r
198 return $blog->isValidCategory($catid);
\r
200 // check category name
\r
201 if ($name == 'catname') {
\r
202 $value = $blog->getCategoryIdFromName($value);
\r
203 if ($value == $catid)
\r
204 return $blog->isValidCategory($catid);
\r
207 // check category id
\r
208 if (($name == 'catid') && ($value == $catid))
\r
209 return $blog->isValidCategory($catid);
\r
215 * Checks if a member is on the team of a blog and return his rights
\r
217 function _ifOnTeam($blogName = '') {
\r
218 global $blog, $member, $manager;
\r
220 // when no blog found
\r
221 if (($blogName == '') && (!is_object($blog)))
\r
224 // explicit blog selection
\r
225 if ($blogName != '')
\r
226 $blogid = getBlogIDFromName($blogName);
\r
228 if (($blogName == '') || !$manager->existsBlogID($blogid))
\r
229 // use current blog
\r
230 $blogid = $blog->getID();
\r
232 return $member->teamRights($blogid);
\r
236 * Checks if a member is admin of a blog
\r
238 function _ifAdmin($blogName = '') {
\r
239 global $blog, $member, $manager;
\r
241 // when no blog found
\r
242 if (($blogName == '') && (!is_object($blog)))
\r
245 // explicit blog selection
\r
246 if ($blogName != '')
\r
247 $blogid = getBlogIDFromName($blogName);
\r
249 if (($blogName == '') || !$manager->existsBlogID($blogid))
\r
250 // use current blog
\r
251 $blogid = $blog->getID();
\r
253 return $member->isBlogAdmin($blogid);
\r
258 * - a raw link (html/xml encoded) when no linktext is provided
\r
259 * - a (x)html <a href... link when a text is present (text htmlencoded)
\r
261 function _link($url, $linktext = '')
\r
263 $u = Entity::hsc($url);
\r
264 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands
\r
265 if ($linktext != '')
\r
266 $l = '<a href="' . $u .'">'.Entity::hsc($linktext).'</a>';
\r
273 * Outputs a next/prev link
\r
275 * @param $maxresults
\r
276 * The maximum amount of items shown per page (e.g. 10)
\r
278 * Current start position (requestVar('startpos'))
\r
279 * @param $direction
\r
280 * either 'prev' or 'next'
\r
282 * When present, the output will be a full <a href...> link. When empty,
\r
283 * only a raw link will be outputted
\r
285 function _searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '') {
\r
286 global $CONF, $blog, $query, $amount;
\r
287 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
\r
288 $startpos = intval($startpos); // will be 0 when empty.
\r
289 $parsed = parse_url(serverVar('REQUEST_URI'));
\r
290 $path = $parsed['path'];
\r
291 $parsed = $parsed['query'];
\r
294 switch ($direction) {
\r
296 if ( intval($startpos) - intval($maxresults) >= 0) {
\r
297 $startpos = intval($startpos) - intval($maxresults);
\r
298 //$url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
\r
299 switch ($this->skintype)
\r
305 $url = $CONF['SearchURL'];
\r
308 $url .= '?'.alterQueryStr($parsed,'startpos',$startpos);
\r
313 global $navigationItems;
\r
314 if (!isset($navigationItems)) $navigationItems = 0;
\r
317 $iAmountOnPage = 0;
\r
319 $iAmountOnPage = $this->amountfound;
\r
321 if (intval($navigationItems) > 0) {
\r
322 $iAmountOnPage = intval($navigationItems) - intval($startpos);
\r
324 elseif ($iAmountOnPage == 0)
\r
326 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
\r
327 // try a count query
\r
328 switch ($this->skintype)
\r
331 $sqlquery = $blog->getSqlBlog('', 'count');
\r
335 $unused_highlight = '';
\r
336 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
\r
337 $url = $CONF['SearchURL'];
\r
341 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
\r
344 if (intval($iAmountOnPage) >= intval($maxresults)) {
\r
345 $startpos = intval($startpos) + intval($maxresults);
\r
346 //$url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
\r
347 $url .= '?'.alterQueryStr($parsed,'startpos',$startpos);
\r
353 } // switch($direction)
\r
356 echo $this->_link($url, $linktext);
\r
360 * Actions::_itemlink()
\r
361 * Creates an item link and if no id is given a todaylink
\r
363 * @param Integer $id id for link
\r
364 * @param String $linktext text for link
\r
367 function _itemlink($id, $linktext = '')
\r
372 echo $this->_link(Link::create_item_link($id, $this->linkparams), $linktext);
\r
376 $this->parse_todaylink($linktext);
\r
382 * Actions::_archivelink)
\r
383 * Creates an archive link and if no id is given a todaylink
\r
385 * @param Integer $id id for link
\r
386 * @param String $linktext text for link
\r
389 function _archivelink($id, $linktext = '')
\r
391 global $CONF, $blog;
\r
394 echo $this->_link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
\r
398 $this->parse_todaylink($linktext);
\r
404 * Helper function that sets the category that a blog will need to use
\r
407 * An object of the blog class, passed by reference (we want to make changes to it)
\r
409 * The name of the category to use
\r
411 function _setBlogCategory(&$blog, $catname) {
\r
413 if ($catname != '')
\r
414 $blog->setSelectedCategoryByName($catname);
\r
416 $blog->setSelectedCategory($catid);
\r
420 * Notifies the Manager that a PreBlogContent event occurs
\r
422 function _preBlogContent($type, &$blog) {
\r
424 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
\r
428 * Notifies the Manager that a PostBlogContent event occurs
\r
430 function _postBlogContent($type, &$blog) {
\r
432 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
\r
436 * Parse skinvar additemform
\r
438 function parse_additemform() {
\r
439 global $blog, $CONF;
\r
440 $this->formdata = array(
\r
441 'adminurl' => Entity::hsc($CONF['AdminURL']),
\r
442 'catid' => $blog->getDefaultCategory()
\r
444 $blog->InsertJavaScriptInfo();
\r
445 $this->doForm('additemform');
\r
449 * Parse skinvar addlink
\r
450 * A Link that allows to open a bookmarklet to add an item
\r
452 function parse_addlink() {
\r
453 global $CONF, $member, $blog;
\r
454 if ($member->isLoggedIn() && $member->isTeamMember($blog->blogid) ) {
\r
455 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
\r
460 * Parse skinvar addpopupcode
\r
461 * Code that opens a bookmarklet in an popup window
\r
463 function parse_addpopupcode() {
\r
464 echo "if (event && event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');winbm.focus();return false;";
\r
468 * Parse skinvar adminurl
\r
469 * (shortcut for admin url)
\r
471 function parse_adminurl() {
\r
472 $this->parse_sitevar('adminurl');
\r
476 * Parse skinvar archive
\r
478 function parse_archive($template, $category = '') {
\r
479 global $blog, $archive;
\r
480 // can be used with either yyyy-mm or yyyy-mm-dd
\r
481 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
482 $this->_setBlogCategory($blog, $category);
\r
483 $this->_preBlogContent('achive',$blog);
\r
484 $blog->showArchive($template, $y, $m, $d);
\r
485 $this->_postBlogContent('achive',$blog);
\r
490 * Actions::parse_archivedate()
\r
491 * %archivedate(locale,date format)%
\r
493 * @paramstring $locale
\r
497 function parse_archivedate($locale = '-def-')
\r
502 * these lines are no meaning because there is no $template.
\r
504 if ( $locale == '-def-' )
\r
506 setlocale(LC_TIME,$template['LOCALE']);
\r
510 setlocale(LC_TIME,$locale);
\r
513 // get archive date
\r
514 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
517 $args = func_get_args();
\r
518 // format can be spread over multiple parameters
\r
519 if ( sizeof($args) > 1 )
\r
521 // take away locale
\r
522 array_shift($args);
\r
524 $format=implode(',',$args);
\r
526 elseif ( $d == 0 && $m !=0 )
\r
536 $format = '%d %B %Y';
\r
538 echo i18n::formatted_timedate($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
\r
543 * Parse skinvar archivedaylist
\r
545 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
\r
547 if ($category == 'all') $category = '';
\r
548 $this->_preBlogContent('archivelist',$blog);
\r
549 $this->_setBlogCategory($blog, $category);
\r
550 $blog->showArchiveList($template, 'day', $limit);
\r
551 $this->_postBlogContent('archivelist',$blog);
\r
555 * Actions::parse_archivelink()
\r
556 * A link to the archives for the current blog (or for default blog)
\r
558 * @param String $linktext text for link
\r
561 function parse_archivelink($linktext = '')
\r
563 global $blog, $CONF;
\r
566 echo $this->_link(Link::create_archivelist_link($blog->getID(),$this->linkparams), $linktext);
\r
570 echo $this->_link(Link::create_archivelist_link(), $linktext);
\r
575 function parse_archivelist($template, $category = 'all', $limit = 0) {
\r
577 if ($category == 'all') $category = '';
\r
578 $this->_preBlogContent('archivelist',$blog);
\r
579 $this->_setBlogCategory($blog, $category);
\r
580 $blog->showArchiveList($template, 'month', $limit);
\r
581 $this->_postBlogContent('archivelist',$blog);
\r
584 function parse_archiveyearlist($template, $category = 'all', $limit = 0) {
\r
586 if ($category == 'all') $category = '';
\r
587 $this->_preBlogContent('archivelist',$blog);
\r
588 $this->_setBlogCategory($blog, $category);
\r
589 $blog->showArchiveList($template, 'year', $limit);
\r
590 $this->_postBlogContent('archivelist',$blog);
\r
594 * Parse skinvar archivetype
\r
596 function parse_archivetype() {
\r
597 global $archivetype;
\r
602 * Parse skinvar blog
\r
604 function parse_blog($template, $amount = 10, $category = '') {
\r
605 global $blog, $startpos;
\r
607 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
608 $this->_setBlogCategory($blog, $category);
\r
609 $this->_preBlogContent('blog',$blog);
\r
610 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
\r
611 $this->_postBlogContent('blog',$blog);
\r
615 * Parse skinvar bloglist
\r
616 * Shows a list of all blogs
\r
617 * bnametype: whether 'name' or 'shortname' is used for the link text
\r
618 * orderby: order criteria
\r
619 * direction: order ascending or descending
\r
621 function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') {
\r
622 Blog::showBlogList($template, $bnametype, $orderby, $direction);
\r
626 * Parse skinvar blogsetting
\r
628 function parse_blogsetting($which) {
\r
632 echo Entity::hsc($blog->getID());
\r
635 echo Entity::hsc($blog->getURL());
\r
638 echo Entity::hsc($blog->getName());
\r
641 echo Entity::hsc($blog->getDescription());
\r
644 echo Entity::hsc($blog->getShortName());
\r
652 function parse_callback($eventName, $type)
\r
655 $manager->notify($eventName, array('type' => $type));
\r
659 * Parse skinvar category
\r
661 function parse_category($type = 'name') {
\r
662 global $catid, $blog;
\r
663 if (!$blog->isValidCategory($catid))
\r
668 echo $blog->getCategoryName($catid);
\r
671 echo $blog->getCategoryDesc($catid);
\r
680 * Parse categorylist
\r
682 function parse_categorylist($template, $blogname = '') {
\r
683 global $blog, $manager;
\r
685 // when no blog found
\r
686 if (($blogname == '') && (!is_object($blog)))
\r
689 if ($blogname == '') {
\r
690 $this->_preBlogContent('categorylist',$blog);
\r
691 $blog->showCategoryList($template);
\r
692 $this->_postBlogContent('categorylist',$blog);
\r
694 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
695 $this->_preBlogContent('categorylist',$b);
\r
696 $b->showCategoryList($template);
\r
697 $this->_postBlogContent('categorylist',$b);
\r
702 * Parse skinvar charset
\r
704 function parse_charset() {
\r
705 echo i18n::get_current_charset();
\r
709 * Actions::parse_commentform()
\r
710 * Parse skinvar commentform
\r
712 * @param String $destinationurl URI for redirection
\r
715 function parse_commentform($destinationurl = '')
\r
717 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
\r
719 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
\r
720 if ( stristr($destinationurl, 'action.php') )
\r
722 $args = func_get_args();
\r
723 $destinationurl = $args[1];
\r
724 ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
\r
727 $actionurl = $CONF['ActionURL'];
\r
729 // if item is closed, show message and do nothing
\r
730 $item =& $manager->getItem($itemid,0,0);
\r
731 if ( $item['closed'] || !$blog->commentsEnabled() )
\r
733 $this->doForm('commentform-closed');
\r
737 if ( !$blog->isPublic() && !$member->isLoggedIn() )
\r
739 $this->doForm('commentform-closedtopublic');
\r
743 if ( !$destinationurl )
\r
745 // note: createLink returns an HTML encoded URL
\r
746 $destinationurl = Link::create_link(
\r
749 'itemid' => $itemid,
\r
750 'title' => $item['title'],
\r
751 'timestamp' => $item['timestamp'],
\r
752 'extra' => $this->linkparams
\r
759 $destinationurl = Entity::hsc($destinationurl);
\r
762 // values to prefill
\r
763 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
\r
766 $user = postVar('user');
\r
769 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
\r
772 $userid = postVar('userid');
\r
775 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
\r
778 $email = postVar('email');
\r
781 $body = postVar('body');
\r
783 $this->formdata = array(
\r
784 'destinationurl' => $destinationurl, // url is already HTML encoded
\r
785 'actionurl' => Entity::hsc($actionurl),
\r
786 'itemid' => $itemid,
\r
787 'user' => Entity::hsc($user),
\r
788 'userid' => Entity::hsc($userid),
\r
789 'email' => Entity::hsc($email),
\r
790 'body' => Entity::hsc($body),
\r
791 'membername' => $member->getDisplayName(),
\r
792 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
\r
795 if ( !$member->isLoggedIn() )
\r
797 $this->doForm('commentform-notloggedin');
\r
801 $this->doForm('commentform-loggedin');
\r
807 * Parse skinvar comments
\r
808 * include comments for one item
\r
810 function parse_comments($template) {
\r
811 global $itemid, $manager, $blog, $highlight;
\r
812 $template =& $manager->getTemplate($template);
\r
814 // create parser object & action handler
\r
815 $actions = new ItemActions($blog);
\r
816 $parser = new Parser($actions->getDefinedActions(),$actions);
\r
817 $actions->setTemplate($template);
\r
818 $actions->setParser($parser);
\r
819 $item = Item::getitem($itemid, 0, 0);
\r
820 $actions->setCurrentItem($item);
\r
822 $comments = new Comments($itemid);
\r
823 $comments->setItemActions($actions);
\r
824 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
\r
830 function parse_errordiv() {
\r
831 global $errormessage;
\r
833 echo '<div class="error">', Entity::hsc($errormessage),'</div>';
\r
837 * Parse skinvar errormessage
\r
839 function parse_errormessage() {
\r
840 global $errormessage;
\r
841 echo $errormessage;
\r
847 function parse_formdata($what) {
\r
848 echo $this->formdata[$what];
\r
854 function parse_ifcat($text = '') {
\r
857 $this->parse_if('category');
\r
860 global $catid, $blog;
\r
861 if ($blog->isValidCategory($catid))
\r
867 * Parse skinvar image
\r
869 function parse_image($what = 'imgtag') {
\r
872 $imagetext = Entity::hsc(requestVar('imagetext'));
\r
873 $imagepopup = requestVar('imagepopup');
\r
874 $width = intRequestVar('width');
\r
875 $height = intRequestVar('height');
\r
876 $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup);
\r
895 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
\r
901 * Parse skinvar imagetext
\r
903 function parse_imagetext() {
\r
904 echo Entity::hsc(requestVar('imagetext'));
\r
908 * Parse skinvar item
\r
909 * include one item (no comments)
\r
911 function parse_item($template) {
\r
912 global $blog, $itemid, $highlight;
\r
913 $this->_setBlogCategory($blog, ''); // need this to select default category
\r
914 $this->_preBlogContent('item',$blog);
\r
915 $r = $blog->showOneitem($itemid, $template, $highlight);
\r
917 echo _ERROR_NOSUCHITEM;
\r
918 $this->_postBlogContent('item',$blog);
\r
922 * Parse skinvar itemid
\r
924 function parse_itemid() {
\r
930 * Parse skinvar itemlink
\r
932 function parse_itemlink($linktext = '') {
\r
934 $this->_itemlink($itemid, $linktext);
\r
940 function parse_itemtitle($format = '') {
\r
941 global $manager, $itemid;
\r
942 $item =& $manager->getItem($itemid,0,0);
\r
946 echo Entity::hen($item['title']);
\r
949 echo $item['title'];
\r
953 echo Entity::hsc(strip_tags($item['title']));
\r
959 * Parse skinvar loginform
\r
961 function parse_loginform() {
\r
962 global $member, $CONF;
\r
963 if (!$member->isLoggedIn()) {
\r
964 $filename = 'loginform-notloggedin';
\r
965 $this->formdata = array();
\r
967 $filename = 'loginform-loggedin';
\r
968 $this->formdata = array(
\r
969 'membername' => $member->getDisplayName(),
\r
972 $this->doForm($filename);
\r
976 * Actions::parse_member()
\r
977 * Parse skinvar member
\r
978 * (includes a member info thingie)
\r
980 * @param String $what which memberdata is needed
\r
983 function parse_member($what)
\r
985 global $memberinfo, $member, $CONF;
\r
987 // 1. only allow the member-details-page specific variables on member pages
\r
988 if ($this->skintype == 'member')
\r
993 echo Entity::hsc($memberinfo->getDisplayName());
\r
996 echo Entity::hsc($memberinfo->getRealName());
\r
999 echo Entity::hsc($memberinfo->getNotes());
\r
1002 echo Entity::hsc($memberinfo->getURL());
\r
1005 echo Entity::hsc($memberinfo->getEmail());
\r
1008 echo Entity::hsc($memberinfo->getID());
\r
1013 // 2. the next bunch of options is available everywhere, as long as the user is logged in
\r
1014 if ( $member->isLoggedIn() )
\r
1019 echo $member->getDisplayName();
\r
1021 case 'yourrealname':
\r
1022 echo $member->getRealName();
\r
1025 echo $member->getNotes();
\r
1028 echo $member->getURL();
\r
1031 echo $member->getEmail();
\r
1034 echo $member->getID();
\r
1036 case 'yourprofileurl':
\r
1037 if ($CONF['URLMode'] == 'pathinfo')
\r
1038 echo Link::create_member_link($member->getID());
\r
1040 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
\r
1048 * Link::parse_membermailform()
\r
1049 * Parse skinvar membermailform
\r
1051 * @param Integer $rows the height for textarea
\r
1052 * @param Integer $cols the width for textarea
\r
1053 * @param String $desturl URI to redirect
\r
1056 function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
\r
1058 global $member, $CONF, $memberid;
\r
1060 if ( $desturl == '' )
\r
1062 if ( $CONF['URLMode'] == 'pathinfo' )
\r
1064 $desturl = Link::create_member_link($memberid);
\r
1068 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
\r
1072 $message = postVar('message');
\r
1073 $frommail = postVar('frommail');
\r
1075 $this->formdata = array(
\r
1076 'url' => Entity::hsc($desturl),
\r
1077 'actionurl' => Entity::hsc($CONF['ActionURL']),
\r
1078 'memberid' => $memberid,
\r
1081 'message' => Entity::hsc($message),
\r
1082 'frommail' => Entity::hsc($frommail)
\r
1085 if ( $member->isLoggedIn() )
\r
1087 $this->doForm('membermailform-loggedin');
\r
1089 else if ( $CONF['NonmemberMail'] )
\r
1091 $this->doForm('membermailform-notloggedin');
\r
1095 $this->doForm('membermailform-disallowed');
\r
1101 * Parse skinvar nextarchive
\r
1103 function parse_nextarchive() {
\r
1104 global $archivenext;
\r
1105 echo $archivenext;
\r
1109 * Parse skinvar nextitem
\r
1110 * (include itemid of next item)
\r
1112 function parse_nextitem() {
\r
1113 global $itemidnext;
\r
1114 if (isset($itemidnext)) echo (int)$itemidnext;
\r
1118 * Parse skinvar nextitemtitle
\r
1119 * (include itemtitle of next item)
\r
1121 function parse_nextitemtitle($format = '') {
\r
1122 global $itemtitlenext;
\r
1124 switch ( $format )
\r
1127 echo Entity::hen($itemtitlenext);
\r
1130 echo $itemtitlenext;
\r
1134 echo Entity::hsc($itemtitlenext);
\r
1140 * Parse skinvar nextlink
\r
1142 function parse_nextlink($linktext = '', $amount = 10, $recount = '') {
\r
1143 global $itemidnext, $archivenext, $startpos;
\r
1144 if ($this->skintype == 'item')
\r
1145 $this->_itemlink($itemidnext, $linktext);
\r
1146 else if ($this->skintype == 'search' || $this->skintype == 'index')
\r
1147 $this->_searchlink($amount, $startpos, 'next', $linktext, $recount);
\r
1149 $this->_archivelink($archivenext, $linktext);
\r
1153 * Parse skinvar nucleusbutton
\r
1155 function parse_nucleusbutton($imgurl = '',
\r
1157 $imgheight = '31') {
\r
1159 if ($imgurl == '') {
\r
1160 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
\r
1161 } else if (Parser::getProperty('IncludeMode') == 'skindir'){
\r
1162 // when skindit IncludeMode is used: start from skindir
\r
1163 $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
\r
1166 $this->formdata = array(
\r
1167 'imgurl' => $imgurl,
\r
1168 'imgwidth' => $imgwidth,
\r
1169 'imgheight' => $imgheight,
\r
1171 $this->doForm('nucleusbutton');
\r
1175 * Parse skinvar otherarchive
\r
1177 function parse_otherarchive($blogname, $template, $category = '') {
\r
1178 global $archive, $manager;
\r
1179 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
1180 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1181 $this->_setBlogCategory($b, $category);
\r
1182 $this->_preBlogContent('otherachive',$b);
\r
1183 $b->showArchive($template, $y, $m, $d);
\r
1184 $this->_postBlogContent('otherachive',$b);
\r
1188 * Parse skinvar otherarchivedaylist
\r
1190 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
\r
1192 if ($category == 'all') $category = '';
\r
1193 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1194 $this->_setBlogCategory($b, $category);
\r
1195 $this->_preBlogContent('otherarchivelist',$b);
\r
1196 $b->showArchiveList($template, 'day', $limit);
\r
1197 $this->_postBlogContent('otherarchivelist',$b);
\r
1201 * Parse skinvar otherarchivelist
\r
1203 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
\r
1205 if ($category == 'all') $category = '';
\r
1206 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1207 $this->_setBlogCategory($b, $category);
\r
1208 $this->_preBlogContent('otherarchivelist',$b);
\r
1209 $b->showArchiveList($template, 'month', $limit);
\r
1210 $this->_postBlogContent('otherarchivelist',$b);
\r
1214 * Parse skinvar otherarchiveyearlist
\r
1216 function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) {
\r
1218 if ($category == 'all') $category = '';
\r
1219 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1220 $this->_setBlogCategory($b, $category);
\r
1221 $this->_preBlogContent('otherarchivelist',$b);
\r
1222 $b->showArchiveList($template, 'year', $limit);
\r
1223 $this->_postBlogContent('otherarchivelist',$b);
\r
1227 * Parse skinvar otherblog
\r
1229 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
\r
1232 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
1234 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1235 $this->_setBlogCategory($b, $category);
\r
1236 $this->_preBlogContent('otherblog',$b);
\r
1237 $this->amountfound = $b->readLog($template, $limit, $offset);
\r
1238 $this->_postBlogContent('otherblog',$b);
\r
1242 * Parse skinvar othersearchresults
\r
1244 function parse_othersearchresults($blogname, $template, $maxresults = 50) {
\r
1245 global $query, $amount, $manager, $startpos;
\r
1246 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1247 $this->_setBlogCategory($b, ''); // need this to select default category
\r
1248 $this->_preBlogContent('othersearchresults',$b);
\r
1249 $b->search($query, $template, $amount, $maxresults, $startpos);
\r
1250 $this->_postBlogContent('othersearchresults',$b);
\r
1254 * Executes a plugin skinvar
\r
1256 * @param pluginName name of plugin (without the NP_)
\r
1258 * extra parameters can be added
\r
1260 function parse_plugin($pluginName) {
\r
1263 // should be already tested from the parser (PARSER.php)
\r
1264 // only continue when the plugin is really installed
\r
1265 /*if (!$manager->pluginInstalled('NP_' . $pluginName))
\r
1268 $plugin =& $manager->getPlugin('NP_' . $pluginName);
\r
1269 if (!$plugin) return;
\r
1272 $params = func_get_args();
\r
1274 // remove plugin name
\r
1275 array_shift($params);
\r
1277 // add skin type on front
\r
1278 array_unshift($params, $this->skintype);
\r
1280 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
\r
1284 * Parse skinvar prevarchive
\r
1286 function parse_prevarchive() {
\r
1287 global $archiveprev;
\r
1288 echo $archiveprev;
\r
1292 * Parse skinvar preview
\r
1294 function parse_preview($template) {
\r
1295 global $blog, $CONF, $manager;
\r
1297 $template =& $manager->getTemplate($template);
\r
1298 $row['body'] = '<span id="prevbody"></span>';
\r
1299 $row['title'] = '<span id="prevtitle"></span>';
\r
1300 $row['more'] = '<span id="prevmore"></span>';
\r
1301 $row['itemlink'] = '';
\r
1302 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
\r
1303 echo Template::fill($template['ITEM_HEADER'],$row);
\r
1304 echo Template::fill($template['ITEM'],$row);
\r
1305 echo Template::fill($template['ITEM_FOOTER'],$row);
\r
1309 * Parse skinvar previtem
\r
1310 * (include itemid of prev item)
\r
1312 function parse_previtem() {
\r
1313 global $itemidprev;
\r
1314 if (isset($itemidprev)) echo (int)$itemidprev;
\r
1318 * Actions::parse_previtemtitle()
\r
1319 * Parse skinvar previtemtitle
\r
1320 * (include itemtitle of prev item)
\r
1322 * @param String $format string format
\r
1323 * @return String formatted string
\r
1325 function parse_previtemtitle($format = '')
\r
1327 global $itemtitleprev;
\r
1329 switch ( $format )
\r
1332 echo Entity::hen($itemtitleprev);
\r
1335 echo $itemtitleprev;
\r
1339 echo Entity::hsc($itemtitleprev);
\r
1346 * Parse skinvar prevlink
\r
1348 function parse_prevlink($linktext = '', $amount = 10) {
\r
1349 global $itemidprev, $archiveprev, $startpos;
\r
1351 if ($this->skintype == 'item')
\r
1352 $this->_itemlink($itemidprev, $linktext);
\r
1353 else if ($this->skintype == 'search' || $this->skintype == 'index')
\r
1354 $this->_searchlink($amount, $startpos, 'prev', $linktext);
\r
1356 $this->_archivelink($archiveprev, $linktext);
\r
1360 * Parse skinvar query
\r
1361 * (includes the search query)
\r
1363 function parse_query() {
\r
1365 echo Entity::hsc($query);
\r
1369 * Parse skinvar referer
\r
1371 function parse_referer() {
\r
1372 echo Entity::hsc(serverVar('HTTP_REFERER'));
\r
1376 * Parse skinvar searchform
\r
1378 function parse_searchform($blogname = '') {
\r
1379 global $CONF, $manager, $maxresults;
\r
1381 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1385 // use default blog when no blog is selected
\r
1386 $this->formdata = array(
\r
1387 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
\r
1388 'query' => Entity::hsc(getVar('query')),
\r
1390 $this->doForm('searchform');
\r
1394 * Parse skinvar searchresults
\r
1396 function parse_searchresults($template, $maxresults = 50 ) {
\r
1397 global $blog, $query, $amount, $startpos;
\r
1399 $this->_setBlogCategory($blog, ''); // need this to select default category
\r
1400 $this->_preBlogContent('searchresults',$blog);
\r
1401 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
\r
1402 $this->_postBlogContent('searchresults',$blog);
\r
1406 * Parse skinvar self
\r
1408 function parse_self() {
\r
1410 echo $CONF['Self'];
\r
1414 * Parse skinvar sitevar
\r
1415 * (include a sitevar)
\r
1417 function parse_sitevar($which) {
\r
1421 echo $CONF['IndexURL'];
\r
1424 echo $CONF['SiteName'];
\r
1427 echo $CONF['AdminEmail'];
\r
1430 echo $CONF['AdminURL'];
\r
1437 function parse_skinname() {
\r
1438 echo $this->skin->getName();
\r
1442 * Parse skintype (experimental)
\r
1444 function parse_skintype() {
\r
1445 echo $this->skintype;
\r
1451 function parse_text($which) {
\r
1452 // constant($which) only available from 4.0.4 :(
\r
1453 if (defined($which)) {
\r
1454 eval("echo $which;");
\r
1461 function parse_ticket() {
\r
1463 $manager->addTicketHidden();
\r
1467 * Actions::parse_todaylink()
\r
1468 * Parse skinvar todaylink
\r
1469 * A link to the today page (depending on selected blog, etc...)
\r
1471 * @param String $linktext text for link
\r
1474 function parse_todaylink($linktext = '')
\r
1476 global $blog, $CONF;
\r
1479 echo $this->_link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
\r
1483 echo $this->_link($CONF['SiteUrl'], $linktext);
\r
1490 * When commentform is not used, to include a hidden field with itemid
\r
1492 function parse_vars() {
\r
1494 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
\r
1498 * Parse skinvar version
\r
1499 * (include nucleus versionnumber)
\r
1501 function parse_version() {
\r
1503 echo 'Nucleus CMS ' . $nucleus['version'];
\r
1507 * Parse skinvar sticky
\r
1509 function parse_sticky($itemnumber = 0, $template = '') {
\r
1512 $itemnumber = intval($itemnumber);
\r
1513 $itemarray = array($itemnumber);
\r
1515 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
\r
1516 $this->_preBlogContent('sticky',$b);
\r
1517 $this->amountfound = $b->readLogFromList($itemarray, $template);
\r
1518 $this->_postBlogContent('sticky',$b);
\r