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 1725 2012-04-07 02:21:32Z 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 * Actions::__construct()
\r
47 * Constructor for a new Actions object
\r
49 * @param string $type
\r
52 public function __construct($type)
\r
56 // call constructor of superclass first
\r
57 $this->BaseActions();
\r
58 $this->skintype = $type;
\r
62 $this->linkparams = array('catid' => $catid);
\r
68 * Actions::setSkin()
\r
70 * @param object $skin an instance of Skin class
\r
73 public function setSkin(&$skin)
\r
75 $this->skin =& $skin;
\r
80 * Actions::setParser()
\r
83 * @param object $parser an instance of Parser class
\r
86 public function setParser(&$parser)
\r
88 $this->parser =& $parser;
\r
94 * Forms get parsedincluded now, using an extra <formdata> skinvar
\r
96 * @param string $filename
\r
99 public function doForm($filename)
\r
101 global $DIR_NUCLEUS;
\r
102 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');
\r
104 $oldIncludeMode = Parser::getProperty('IncludeMode');
\r
105 $oldIncludePrefix = Parser::getProperty('IncludePrefix');
\r
106 Parser::setProperty('IncludeMode','normal');
\r
107 Parser::setProperty('IncludePrefix','');
\r
109 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
\r
110 Parser::setProperty('IncludeMode',$oldIncludeMode);
\r
111 Parser::setProperty('IncludePrefix',$oldIncludePrefix);
\r
113 array_pop($this->parser->actions); // errordiv
\r
114 array_pop($this->parser->actions); // callback
\r
115 array_pop($this->parser->actions); // text
\r
116 array_pop($this->parser->actions); // formdata
\r
117 array_pop($this->parser->actions); // ticket
\r
122 * Actions::checkCondition()
\r
123 * Checks conditions for if statements
\r
125 * @param string $field type of <%if%>
\r
126 * @param string $name property of field
\r
127 * @param string $value value of property
\r
128 * @return boolean condition
\r
130 public function checkCondition($field, $name='', $value = '')
\r
132 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
\r
138 $condition = ($blog && $this->ifCategory($name,$value));
\r
140 case 'blogsetting':
\r
141 $condition = ($blog && ($blog->getSetting($name) == $value));
\r
144 $condition = $member->isLoggedIn();
\r
147 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
\r
150 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
153 $condition = ($itemidnext != '');
\r
156 $condition = ($itemidprev != '');
\r
158 case 'archiveprevexists':
\r
159 $condition = ($archiveprevexists == true);
\r
161 case 'archivenextexists':
\r
162 $condition = ($archivenextexists == true);
\r
165 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
\r
168 $condition = $this->ifHasPlugin($name, $value);
\r
171 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
\r
178 * Actions::_ifHasPlugin()
\r
179 * hasplugin,PlugName
\r
180 * -> checks if plugin exists
\r
181 * hasplugin,PlugName,OptionName
\r
182 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
\r
183 * hasplugin,PlugName,OptionName=value
\r
184 * -> checks if the option OptionName from plugin PlugName is set to value
\r
186 * @param string $name name of plugin
\r
187 * @param string $value
\r
190 private function ifHasPlugin($name, $value)
\r
193 $condition = false;
\r
194 // (pluginInstalled method won't write a message in the actionlog on failure)
\r
195 if ( $manager->pluginInstalled("NP_{$name}") )
\r
197 $plugin =& $manager->getPlugin("NP_{$name}");
\r
198 if ( $plugin != NULL )
\r
200 if ( $value == "" )
\r
206 list($name2, $value2) = preg_split('#=#', $value, 2);
\r
207 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
\r
211 else if ( $plugin->getOption($name2) == $value2 )
\r
222 * Actions::ifPlugin()
\r
223 * Checks if a plugin exists and call its doIf function
\r
225 * @param string $name name of plugin
\r
226 * @param string $key name of plugin option
\r
227 * @param string $value value of plugin option
\r
230 private function ifPlugin($name, $key = '', $value = '')
\r
234 $plugin =& $manager->getPlugin("NP_{$name}");
\r
240 $params = func_get_args();
\r
241 array_shift($params);
\r
243 return call_user_func_array(array(&$plugin, 'doIf'), $params);
\r
247 * Actions::ifCategory()
\r
248 * Different checks for a category
\r
250 * @param string $name
\r
251 * @param string $value
\r
254 private function ifCategory($name = '', $value='')
\r
256 global $blog, $catid;
\r
258 // when no parameter is defined, just check if a category is selected
\r
259 if ( ($name != 'catname' && $name != 'catid') || ($value == '') )
\r
261 return $blog->isValidCategory($catid);
\r
264 // check category name
\r
265 if ( $name == 'catname' )
\r
267 $value = $blog->getCategoryIdFromName($value);
\r
268 if ( $value == $catid )
\r
270 return $blog->isValidCategory($catid);
\r
274 // check category id
\r
275 if ( ($name == 'catid') && ($value == $catid) )
\r
277 return $blog->isValidCategory($catid);
\r
283 * Actions::ifOnTeam()
\r
284 * Checks if a member is on the team of a blog and return his rights
\r
286 * @param string $blogName name of weblog
\r
289 private function ifOnTeam($blogName = '')
\r
291 global $blog, $member, $manager;
\r
293 // when no blog found
\r
294 if ( ($blogName == '') && !is_object($blog) )
\r
299 // explicit blog selection
\r
300 if ( $blogName != '' )
\r
302 $blogid = getBlogIDFromName($blogName);
\r
305 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
\r
307 // use current blog
\r
308 $blogid = $blog->getID();
\r
311 return $member->teamRights($blogid);
\r
315 * Actions::ifAdmin()
\r
316 * Checks if a member is admin of a blog
\r
318 * @param string $blogName name of weblog
\r
321 private function ifAdmin($blogName = '')
\r
323 global $blog, $member, $manager;
\r
325 // when no blog found
\r
326 if ( ($blogName == '') && (!is_object($blog)) )
\r
331 // explicit blog selection
\r
332 if ( $blogName != '' )
\r
334 $blogid = getBlogIDFromName($blogName);
\r
337 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
\r
339 // use current blog
\r
340 $blogid = $blog->getID();
\r
343 return $member->isBlogAdmin($blogid);
\r
349 * - a raw link (html/xml encoded) when no linktext is provided
\r
350 * - a (x)html <a href... link when a text is present (text htmlencoded)
\r
352 * @param string $url URL for href attribute of anchor element
\r
353 * @param string $linktext content of anchor element
\r
356 private function link($url, $linktext = '')
\r
358 $u = Entity::hsc($url);
\r
359 // fix URLs that already had encoded ampersands
\r
360 $u = preg_replace("#&amp;#", '&', $u);
\r
361 if ( $linktext != '' )
\r
363 $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';
\r
373 * Actions::searchlink()
\r
374 * Outputs a next/prev link
\r
376 * @param $maxresults
\r
377 * The maximum amount of items shown per page (e.g. 10)
\r
379 * Current start position (requestVar('startpos'))
\r
380 * @param $direction
\r
381 * either 'prev' or 'next'
\r
383 * When present, the output will be a full <a href...> link. When empty,
\r
384 * only a raw link will be outputted
\r
386 private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')
\r
388 global $CONF, $blog, $query, $amount;
\r
389 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
\r
390 $startpos = (integer) $startpos;
\r
391 $parsed = parse_url(serverVar('REQUEST_URI'));
\r
392 $path = $parsed['path'];
\r
393 $parsed = $parsed['query'];
\r
396 if ( $direction == 'prev' )
\r
398 if ( intval($startpos) - intval($maxresults) >= 0 )
\r
400 $startpos = intval($startpos) - intval($maxresults);
\r
402 if ( $this->skintype == 'index' )
\r
406 else if ( $this->skintype == 'search' )
\r
408 $url = $CONF['SearchURL'];
\r
410 $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);
\r
413 else if ( $direction == 'next' )
\r
415 global $navigationItems;
\r
416 if ( !isset($navigationItems) )
\r
418 $navigationItems = 0;
\r
423 $iAmountOnPage = 0;
\r
427 $iAmountOnPage = $this->amountfound;
\r
430 if ( intval($navigationItems) > 0 )
\r
432 $iAmountOnPage = intval($navigationItems) - intval($startpos);
\r
434 elseif ( $iAmountOnPage == 0 )
\r
437 * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
\r
438 * try a count query
\r
440 if ( $this->skintype == 'index' )
\r
442 $sqlquery = $blog->getSqlBlog('', 'count');
\r
445 else if ( $this->skintype == 'search' )
\r
447 $unused_highlight = '';
\r
448 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
\r
449 $url = $CONF['SearchURL'];
\r
453 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
\r
458 if ( intval($iAmountOnPage) >= intval($maxresults) )
\r
460 $startpos = intval($startpos) + intval($maxresults);
\r
461 $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos);
\r
467 echo $this->link($url, $linktext);
\r
473 * Actions::itemlink()
\r
474 * Creates an item link and if no id is given a todaylink
\r
476 * @param integer $id id for link
\r
477 * @param string $linktext text for link
\r
480 private function itemlink($id, $linktext = '')
\r
485 echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);
\r
489 $this->parse_todaylink($linktext);
\r
495 * Actions::archivelink)
\r
496 * Creates an archive link and if no id is given a todaylink
\r
498 * @param integer $id id for link
\r
499 * @param string $linktext text for link
\r
502 private function archivelink($id, $linktext = '')
\r
504 global $CONF, $blog;
\r
507 echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
\r
511 $this->parse_todaylink($linktext);
\r
517 * Actions:setBlogCategory()
\r
518 * Helper function that sets the category that a blog will need to use
\r
520 * @param string $blog An object of the blog class, passed by reference (we want to make changes to it)
\r
521 * @param string $catname The name of the category to use
\r
524 private function setBlogCategory(&$blog, $catname)
\r
527 if ( $catname != '' )
\r
529 $blog->setSelectedCategoryByName($catname);
\r
533 $blog->setSelectedCategory($catid);
\r
539 * Actions::preBlogContent()
\r
540 * Notifies the Manager that a PreBlogContent event occurs
\r
542 * @param string $type type of skin
\r
543 * @param object $blog an instance of Blog class
\r
546 private function preBlogContent($type, &$blog)
\r
549 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
\r
554 * Actions::postBlogContent()
\r
555 * Notifies the Manager that a PostBlogContent event occurs
\r
557 * @param string $type type of skin
\r
558 * @param objecct $blog an instance of Blog class
\r
561 private function postBlogContent($type, &$blog)
\r
564 $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));
\r
569 * Actions::parse_additemform()
\r
570 * Parse skinvar additemform
\r
575 public function parse_additemform()
\r
577 global $blog, $CONF;
\r
578 $this->formdata = array(
\r
579 'adminurl' => Entity::hsc($CONF['AdminURL']),
\r
580 'catid' => $blog->getDefaultCategory()
\r
582 $blog->InsertJavaScriptInfo();
\r
583 $this->doForm('additemform');
\r
588 * Actions::parse_addlink()
\r
589 * Parse skinvar addlink
\r
590 * A Link that allows to open a bookmarklet to add an item
\r
592 public function parse_addlink()
\r
594 global $CONF, $member, $blog;
\r
595 if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )
\r
597 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
\r
603 * Actions::parse_addpopupcode()
\r
604 * Parse skinvar addpopupcode
\r
605 * Code that opens a bookmarklet in an popup window
\r
610 public function parse_addpopupcode()
\r
612 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
617 * Parse skinvar adminurl
\r
618 * (shortcut for admin url)
\r
623 public function parse_adminurl()
\r
625 $this->parse_sitevar('adminurl');
\r
630 * Actions::parse_archive()
\r
631 * Parse skinvar archive
\r
633 * @param string $template name of template
\r
634 * @param string $category name of category
\r
637 public function parse_archive($template, $category = '')
\r
639 global $blog, $archive;
\r
640 // can be used with either yyyy-mm or yyyy-mm-dd
\r
641 sscanf($archive,'%d-%d-%d', $y, $m, $d);
\r
642 $this->setBlogCategory($blog, $category);
\r
643 $this->preBlogContent('achive',$blog);
\r
644 $blog->showArchive($template, $y, $m, $d);
\r
645 $this->postBlogContent('achive',$blog);
\r
650 * Actions::parse_archivedate()
\r
651 * %archivedate(locale,date format)%
\r
653 * @param string $locale
\r
656 public function parse_archivedate($locale = '-def-')
\r
661 * TODO: these lines are no meaning because there is no $template.
\r
662 if ( $locale == '-def-' )
\r
664 setlocale(LC_TIME, $template['LOCALE']);
\r
668 setlocale(LC_TIME, $locale);
\r
672 // get archive date
\r
673 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
676 $args = func_get_args();
\r
677 // format can be spread over multiple parameters
\r
678 if ( sizeof($args) > 1 )
\r
680 // take away locale
\r
681 array_shift($args);
\r
683 $format=implode(',',$args);
\r
685 elseif ( $d == 0 && $m !=0 )
\r
695 $format = '%d %B %Y';
\r
697 echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
\r
702 * Actions::parse_archivedaylist()
\r
703 * Parse skinvar archivedaylist
\r
705 * @param string $template name of template
\r
706 * @param string $category name of category
\r
707 * @param integer $limit the number of items in a display
\r
710 public function parse_archivedaylist($template, $category = 'all', $limit = 0)
\r
713 if ( $category == 'all' )
\r
717 $this->preBlogContent('archivelist',$blog);
\r
718 $this->setBlogCategory($blog, $category);
\r
719 $blog->showArchiveList($template, 'day', $limit);
\r
720 $this->postBlogContent('archivelist',$blog);
\r
725 * Actions::parse_archivelink()
\r
726 * A link to the archives for the current blog (or for default blog)
\r
728 * @param string $linktext text for link
\r
731 public function parse_archivelink($linktext = '')
\r
733 global $blog, $CONF;
\r
736 echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);
\r
740 echo $this->link(Link::create_archivelist_link(), $linktext);
\r
746 * Actions::parse_archivelist()
\r
748 * @param string $template name of template
\r
749 * @param string $category name of category
\r
750 * @param integer $limit the number of items in a display
\r
753 public function parse_archivelist($template, $category = 'all', $limit = 0)
\r
756 if ( $category == 'all' )
\r
760 $this->preBlogContent('archivelist',$blog);
\r
761 $this->setBlogCategory($blog, $category);
\r
762 $blog->showArchiveList($template, 'month', $limit);
\r
763 $this->postBlogContent('archivelist',$blog);
\r
768 * Actions::parse_archiveyearlist()
\r
770 * @param string $template name of template
\r
771 * @param string $category name of category
\r
772 * @param integer $limit the number of items in a display
\r
774 public function parse_archiveyearlist($template, $category = 'all', $limit = 0)
\r
777 if ( $category == 'all' )
\r
781 $this->preBlogContent('archivelist',$blog);
\r
782 $this->setBlogCategory($blog, $category);
\r
783 $blog->showArchiveList($template, 'year', $limit);
\r
784 $this->postBlogContent('archivelist',$blog);
\r
789 * Actions::parse_archivetype()
\r
790 * Parse skinvar archivetype
\r
795 public function parse_archivetype()
\r
797 global $archivetype;
\r
803 * Actions::parse_blog()
\r
804 * Parse skinvar blog
\r
806 * @param string $template name of template
\r
807 * @param mixed $amount the number of items in a display, in case it includes the beginning
\r
808 * @param string $category name of category
\r
811 public function parse_blog($template, $amount = 10, $category = '')
\r
813 global $blog, $startpos;
\r
815 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
816 $this->setBlogCategory($blog, $category);
\r
817 $this->preBlogContent('blog',$blog);
\r
818 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
\r
819 $this->postBlogContent('blog',$blog);
\r
824 * Actions::parse_bloglist()
\r
825 * Parse skinvar bloglist
\r
826 * Shows a list of all blogs
\r
828 * @param string $template name of template
\r
829 * @param string $bnametype whether 'name' or 'shortname' is used for the link text
\r
830 * @param string $orderby order criteria
\r
831 * @param string $direction order ascending or descending
\r
834 public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')
\r
836 Blog::showBlogList($template, $bnametype, $orderby, $direction);
\r
841 * Actions::parse_blogsetting()
\r
842 * Parse skinvar blogsetting
\r
844 * @param string $which key of weblog settings
\r
847 public function parse_blogsetting($which)
\r
853 echo Entity::hsc($blog->getID());
\r
856 echo Entity::hsc($blog->getURL());
\r
859 echo Entity::hsc($blog->getName());
\r
862 echo Entity::hsc($blog->getDescription());
\r
865 echo Entity::hsc($blog->getShortName());
\r
872 * Actions::parse_callback()
\r
875 * @param string $eventName name of event
\r
876 * @param string $type type of skin
\r
879 public function parse_callback($eventName, $type)
\r
882 $manager->notify($eventName, array('type' => $type));
\r
887 * Actions::parse_category()
\r
888 * Parse skinvar category
\r
890 * @param string $type key of category settings
\r
893 public function parse_category($type = 'name')
\r
895 global $catid, $blog;
\r
896 if ( !$blog->isValidCategory($catid) )
\r
904 echo $blog->getCategoryName($catid);
\r
907 echo $blog->getCategoryDesc($catid);
\r
917 * Actions::parse_categorylist()
\r
918 * Parse categorylist
\r
920 * @param string $template name of template
\r
921 * @param string $blogname name of weblog
\r
924 public function parse_categorylist($template, $blogname = '')
\r
926 global $blog, $manager;
\r
928 // when no blog found
\r
929 if ( ($blogname == '') && (!is_object($blog)) )
\r
934 if ( $blogname == '' )
\r
936 $this->preBlogContent('categorylist',$blog);
\r
937 $blog->showCategoryList($template);
\r
938 $this->postBlogContent('categorylist',$blog);
\r
942 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
943 $this->preBlogContent('categorylist',$b);
\r
944 $b->showCategoryList($template);
\r
945 $this->postBlogContent('categorylist',$b);
\r
951 * Actions::parse_charset()
\r
952 * Parse skinvar charset
\r
957 public function parse_charset()
\r
959 echo i18n::get_current_charset();
\r
964 * Actions::parse_commentform()
\r
965 * Parse skinvar commentform
\r
967 * @param string $destinationurl URI for redirection
\r
970 public function parse_commentform($destinationurl = '')
\r
972 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
\r
974 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
\r
975 if ( stristr($destinationurl, 'action.php') )
\r
977 $args = func_get_args();
\r
978 $destinationurl = $args[1];
\r
979 ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
\r
982 $actionurl = $CONF['ActionURL'];
\r
984 // if item is closed, show message and do nothing
\r
985 $item =& $manager->getItem($itemid,0,0);
\r
986 if ( $item['closed'] || !$blog->commentsEnabled() )
\r
988 $this->doForm('commentform-closed');
\r
992 if ( !$blog->isPublic() && !$member->isLoggedIn() )
\r
994 $this->doForm('commentform-closedtopublic');
\r
998 if ( !$destinationurl )
\r
1000 // note: createLink returns an HTML encoded URL
\r
1001 $destinationurl = Link::create_link(
\r
1004 'itemid' => $itemid,
\r
1005 'title' => $item['title'],
\r
1006 'timestamp' => $item['timestamp'],
\r
1007 'extra' => $this->linkparams
\r
1013 // HTML encode URL
\r
1014 $destinationurl = Entity::hsc($destinationurl);
\r
1017 // values to prefill
\r
1018 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
\r
1021 $user = postVar('user');
\r
1024 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
\r
1027 $userid = postVar('userid');
\r
1030 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
\r
1033 $email = postVar('email');
\r
1036 $body = postVar('body');
\r
1038 $this->formdata = array(
\r
1039 'destinationurl' => $destinationurl, // url is already HTML encoded
\r
1040 'actionurl' => Entity::hsc($actionurl),
\r
1041 'itemid' => $itemid,
\r
1042 'user' => Entity::hsc($user),
\r
1043 'userid' => Entity::hsc($userid),
\r
1044 'email' => Entity::hsc($email),
\r
1045 'body' => Entity::hsc($body),
\r
1046 'membername' => $member->getDisplayName(),
\r
1047 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
\r
1050 if ( !$member->isLoggedIn() )
\r
1052 $this->doForm('commentform-notloggedin');
\r
1056 $this->doForm('commentform-loggedin');
\r
1062 * Actions::parse_comments()
\r
1063 * Parse skinvar comments
\r
1064 * include comments for one item
\r
1066 * @param string $template name of template
\r
1069 public function parse_comments($template)
\r
1071 global $itemid, $manager, $blog, $highlight;
\r
1072 $template =& $manager->getTemplate($template);
\r
1074 // create parser object & action handler
\r
1075 $actions = new ItemActions($blog);
\r
1076 $parser = new Parser($actions->getDefinedActions(),$actions);
\r
1077 $actions->setTemplate($template);
\r
1078 $actions->setParser($parser);
\r
1079 $item = Item::getitem($itemid, 0, 0);
\r
1080 $actions->setCurrentItem($item);
\r
1082 $comments = new Comments($itemid);
\r
1083 $comments->setItemActions($actions);
\r
1084 // shows ALL comments
\r
1085 $comments->showComments($template, -1, 1, $highlight);
\r
1090 * Actions::parse_errordiv()
\r
1096 public function parse_errordiv()
\r
1098 global $errormessage;
\r
1099 if ( $errormessage )
\r
1101 echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";
\r
1107 * Actions::parse_errormessage()
\r
1108 * Parse skinvar errormessage
\r
1113 public function parse_errormessage()
\r
1115 global $errormessage;
\r
1116 echo $errormessage;
\r
1121 * Actions::parse_formdata()
\r
1124 * @param string $what key of format data
\r
1127 public function parse_formdata($what)
\r
1129 echo $this->formdata[$what];
\r
1134 * Actions::parse_ifcat()
\r
1137 * @param string $text
\r
1140 public function parse_ifcat($text = '')
\r
1142 if ( $text == '' )
\r
1145 $this->parse_if('category');
\r
1150 global $catid, $blog;
\r
1151 if ( $blog->isValidCategory($catid) )
\r
1160 * Actions::parse_image()
\r
1161 * Parse skinvar image
\r
1163 * @param string $what name of tag
\r
1166 public function parse_image($what = 'imgtag')
\r
1170 $imagetext = Entity::hsc(requestVar('imagetext'));
\r
1171 $imagepopup = requestVar('imagepopup');
\r
1172 $width = intRequestVar('width');
\r
1173 $height = intRequestVar('height');
\r
1174 $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup);
\r
1193 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
\r
1200 * Actions::parse_imagetext()
\r
1201 * Parse skinvar imagetext
\r
1206 public function parse_imagetext()
\r
1208 $this->parse_image('imagetext');
\r
1213 * Actions::parse_item()
\r
1214 * Parse skinvar item
\r
1215 * include one item (no comments)
\r
1220 public function parse_item($template)
\r
1222 global $blog, $itemid, $highlight;
\r
1224 // need this to select default category
\r
1225 $this->setBlogCategory($blog, '');
\r
1226 $this->preBlogContent('item',$blog);
\r
1227 $r = $blog->showOneitem($itemid, $template, $highlight);
\r
1230 echo _ERROR_NOSUCHITEM;
\r
1232 $this->postBlogContent('item',$blog);
\r
1237 * Actions::parse_itemid()
\r
1238 * Parse skinvar itemid
\r
1243 public function parse_itemid()
\r
1251 * Actions::parseitemlink()
\r
1252 * Parse skinvar itemlink
\r
1257 public function parse_itemlink($linktext = '')
\r
1260 $this->itemlink($itemid, $linktext);
\r
1265 * Actions::parse_itemtitle()
\r
1271 public function parse_itemtitle($format = '')
\r
1273 global $manager, $itemid;
\r
1274 $item =& $manager->getItem($itemid,0,0);
\r
1276 switch ( $format )
\r
1279 echo Entity::hen($item['title']);
\r
1282 echo $item['title'];
\r
1286 echo Entity::hsc(strip_tags($item['title']));
\r
1293 * Actions::parse_loginform()
\r
1294 * Parse skinvar loginform
\r
1299 public function parse_loginform()
\r
1301 global $member, $CONF;
\r
1302 if ( !$member->isLoggedIn() )
\r
1304 $filename = 'loginform-notloggedin';
\r
1305 $this->formdata = array();
\r
1309 $filename = 'loginform-loggedin';
\r
1310 $this->formdata = array(
\r
1311 'membername' => $member->getDisplayName(),
\r
1314 $this->doForm($filename);
\r
1319 * Actions::parse_member()
\r
1320 * Parse skinvar member
\r
1321 * (includes a member info thingie)
\r
1323 * @param string $what which memberdata is needed
\r
1326 public function parse_member($what)
\r
1328 global $memberinfo, $member, $CONF;
\r
1330 // 1. only allow the member-details-page specific variables on member pages
\r
1331 if ( $this->skintype == 'member' )
\r
1336 echo Entity::hsc($memberinfo->getDisplayName());
\r
1339 echo Entity::hsc($memberinfo->getRealName());
\r
1342 echo Entity::hsc($memberinfo->getNotes());
\r
1345 echo Entity::hsc($memberinfo->getURL());
\r
1348 echo Entity::hsc($memberinfo->getEmail());
\r
1351 echo Entity::hsc($memberinfo->getID());
\r
1356 // 2. the next bunch of options is available everywhere, as long as the user is logged in
\r
1357 if ( $member->isLoggedIn() )
\r
1362 echo $member->getDisplayName();
\r
1364 case 'yourrealname':
\r
1365 echo $member->getRealName();
\r
1368 echo $member->getNotes();
\r
1371 echo $member->getURL();
\r
1374 echo $member->getEmail();
\r
1377 echo $member->getID();
\r
1379 case 'yourprofileurl':
\r
1380 if ($CONF['URLMode'] == 'pathinfo')
\r
1381 echo Link::create_member_link($member->getID());
\r
1383 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
\r
1391 * Link::parse_membermailform()
\r
1392 * Parse skinvar membermailform
\r
1394 * @param integer $rows the height for textarea
\r
1395 * @param integer $cols the width for textarea
\r
1396 * @param string $desturl URI to redirect
\r
1399 public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
\r
1401 global $member, $CONF, $memberid;
\r
1403 if ( $desturl == '' )
\r
1405 if ( $CONF['URLMode'] == 'pathinfo' )
\r
1407 $desturl = Link::create_member_link($memberid);
\r
1411 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
\r
1415 $message = postVar('message');
\r
1416 $frommail = postVar('frommail');
\r
1418 $this->formdata = array(
\r
1419 'url' => Entity::hsc($desturl),
\r
1420 'actionurl' => Entity::hsc($CONF['ActionURL']),
\r
1421 'memberid' => $memberid,
\r
1424 'message' => Entity::hsc($message),
\r
1425 'frommail' => Entity::hsc($frommail)
\r
1428 if ( $member->isLoggedIn() )
\r
1430 $this->doForm('membermailform-loggedin');
\r
1432 else if ( $CONF['NonmemberMail'] )
\r
1434 $this->doForm('membermailform-notloggedin');
\r
1438 $this->doForm('membermailform-disallowed');
\r
1444 * Actions::parse_nextarchive()
\r
1445 * Parse skinvar nextarchive
\r
1450 public function parse_nextarchive()
\r
1452 global $archivenext;
\r
1453 echo $archivenext;
\r
1458 * Parse skinvar nextitem
\r
1459 * (include itemid of next item)
\r
1464 public function parse_nextitem()
\r
1466 global $itemidnext;
\r
1467 if ( isset($itemidnext) )
\r
1469 echo (int)$itemidnext;
\r
1475 * Actions::parse_nextitemtitle()
\r
1476 * Parse skinvar nextitemtitle
\r
1477 * (include itemtitle of next item)
\r
1479 * @param string $format format of text
\r
1482 public function parse_nextitemtitle($format = '')
\r
1484 global $itemtitlenext;
\r
1486 switch ( $format )
\r
1489 echo Entity::hen($itemtitlenext);
\r
1492 echo $itemtitlenext;
\r
1496 echo Entity::hsc($itemtitlenext);
\r
1503 * Actions::parse_nextlink()
\r
1504 * Parse skinvar nextlink
\r
1506 * @param string $linktext text for content of anchor element
\r
1507 * @param integer $amount the amount of items in a display
\r
1508 * @param integer $recount increment from this value
\r
1511 public function parse_nextlink($linktext = '', $amount = 10, $recount = '')
\r
1513 global $itemidnext, $archivenext, $startpos;
\r
1514 if ( $this->skintype == 'item' )
\r
1516 $this->itemlink($itemidnext, $linktext);
\r
1518 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
\r
1520 $this->searchlink($amount, $startpos, 'next', $linktext, $recount);
\r
1524 $this->archivelink($archivenext, $linktext);
\r
1530 * Actions::parse_nucleusbutton()
\r
1531 * Parse skinvar nucleusbutton
\r
1533 * @param string $imgurl URL for image
\r
1534 * @param integer $imgwidth width of image
\r
1535 * @param integer $imgheidht height of image
\r
1537 public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')
\r
1540 if ( $imgurl == '' )
\r
1542 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
\r
1544 else if ( Parser::getProperty('IncludeMode') == 'skindir' )
\r
1546 // when skindit IncludeMode is used: start from skindir
\r
1547 $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
\r
1550 $this->formdata = array(
\r
1551 'imgurl' => $imgurl,
\r
1552 'imgwidth' => $imgwidth,
\r
1553 'imgheight' => $imgheight,
\r
1555 $this->doForm('nucleusbutton');
\r
1560 * Actions::parse_otherarchive()
\r
1561 * Parse skinvar otherarchive
\r
1563 * @param string $blogname name of weblog
\r
1564 * @param string $template name of template
\r
1565 * @param string $category name of category
\r
1568 public function parse_otherarchive($blogname, $template, $category = '')
\r
1570 global $archive, $manager;
\r
1571 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
1572 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1573 $this->setBlogCategory($b, $category);
\r
1574 $this->preBlogContent('otherachive',$b);
\r
1575 $b->showArchive($template, $y, $m, $d);
\r
1576 $this->postBlogContent('otherachive',$b);
\r
1581 * Actions::parse_otherarchivedaylist()
\r
1582 * Parse skinvar otherarchivedaylist
\r
1584 * @param string $blogname name of weblog
\r
1585 * @param string $template name of template
\r
1586 * @param string $category name of category
\r
1587 * @param integer $limit the amount of items in a display
\r
1590 public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)
\r
1593 if ( $category == 'all')
\r
1597 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1598 $this->setBlogCategory($b, $category);
\r
1599 $this->preBlogContent('otherarchivelist',$b);
\r
1600 $b->showArchiveList($template, 'day', $limit);
\r
1601 $this->postBlogContent('otherarchivelist',$b);
\r
1606 * Actions::parse_otherarchivelist()
\r
1607 * Parse skinvar otherarchivelist
\r
1609 * @param string $blogname name of weblog
\r
1610 * @param string $template name of template
\r
1611 * @param string $category name of category
\r
1612 * @param integer $limit the amount of items in a display
\r
1615 public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)
\r
1618 if ( $category == 'all' )
\r
1622 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1623 $this->setBlogCategory($b, $category);
\r
1624 $this->preBlogContent('otherarchivelist',$b);
\r
1625 $b->showArchiveList($template, 'month', $limit);
\r
1626 $this->postBlogContent('otherarchivelist',$b);
\r
1631 * Actions::parse_otherarchiveyearlist()
\r
1632 * Parse skinvar otherarchiveyearlist
\r
1634 * @param string $blogname name of weblog
\r
1635 * @param string $template name of template
\r
1636 * @param string $category name of category
\r
1637 * @limit integer $limit the amount of items in a display
\r
1639 public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)
\r
1642 if ( $category == 'all' )
\r
1646 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1647 $this->setBlogCategory($b, $category);
\r
1648 $this->preBlogContent('otherarchivelist',$b);
\r
1649 $b->showArchiveList($template, 'year', $limit);
\r
1650 $this->postBlogContent('otherarchivelist',$b);
\r
1655 * Actions::parse_otherblog()
\r
1656 * Parse skinvar otherblog
\r
1658 * @param string $blogname name of weblog
\r
1659 * @param string $template name of template
\r
1660 * @param mixed $amount the amount of items, in case it includes the beginning
\r
1661 * @param string $category name of category
\r
1664 public function parse_otherblog($blogname, $template, $amount = 10, $category = '')
\r
1668 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
1670 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1671 $this->setBlogCategory($b, $category);
\r
1672 $this->preBlogContent('otherblog',$b);
\r
1673 $this->amountfound = $b->readLog($template, $limit, $offset);
\r
1674 $this->postBlogContent('otherblog',$b);
\r
1679 * Actions::parse_othersearchresults()
\r
1680 * Parse skinvar othersearchresults
\r
1682 * @param string $blogname name of weblog
\r
1683 * @param string $template name of template
\r
1684 * @param integer $maxresults the amount of results
\r
1687 public function parse_othersearchresults($blogname, $template, $maxresults = 50)
\r
1689 global $query, $amount, $manager, $startpos;
\r
1690 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1691 // need this to select default category
\r
1692 $this->setBlogCategory($b, '');
\r
1693 $this->preBlogContent('othersearchresults',$b);
\r
1694 $b->search($query, $template, $amount, $maxresults, $startpos);
\r
1695 $this->postBlogContent('othersearchresults',$b);
\r
1700 * Actions::parse_plugin()
\r
1701 * Executes a plugin skinvar
\r
1702 * extra parameters can be added
\r
1704 * @param string $pluginName name of plugin (without the NP_)
\r
1707 public function parse_plugin($pluginName)
\r
1711 $plugin =& $manager->getPlugin('NP_' . $pluginName);
\r
1718 $params = func_get_args();
\r
1720 // remove plugin name
\r
1721 array_shift($params);
\r
1723 // add skin type on front
\r
1724 array_unshift($params, $this->skintype);
\r
1726 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
\r
1731 * Actions::parse_prevarchive()
\r
1732 * Parse skinvar prevarchive
\r
1737 public function parse_prevarchive()
\r
1739 global $archiveprev;
\r
1740 echo $archiveprev;
\r
1744 * Actions::parse_preview()
\r
1745 * Parse skinvar preview
\r
1747 * @param string $template name of tempalte
\r
1750 public function parse_preview($template)
\r
1752 global $blog, $CONF, $manager;
\r
1754 $template =& $manager->getTemplate($template);
\r
1756 $row['body'] = '<span id="prevbody"></span>';
\r
1757 $row['title'] = '<span id="prevtitle"></span>';
\r
1758 $row['more'] = '<span id="prevmore"></span>';
\r
1759 $row['itemlink'] = '';
\r
1760 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
\r
1762 echo Template::fill($template['ITEM_HEADER'],$row);
\r
1763 echo Template::fill($template['ITEM'],$row);
\r
1764 echo Template::fill($template['ITEM_FOOTER'],$row);
\r
1769 * Actions::parse_previtem()
\r
1770 * Parse skinvar previtem
\r
1771 * (include itemid of prev item)
\r
1776 public function parse_previtem()
\r
1778 global $itemidprev;
\r
1779 if ( isset($itemidprev) )
\r
1781 echo (integer) $itemidprev;
\r
1787 * Actions::parse_previtemtitle()
\r
1788 * Parse skinvar previtemtitle
\r
1789 * (include itemtitle of prev item)
\r
1791 * @param String $format string format
\r
1792 * @return String formatted string
\r
1794 public function parse_previtemtitle($format = '')
\r
1796 global $itemtitleprev;
\r
1798 switch ( $format )
\r
1801 echo Entity::hen($itemtitleprev);
\r
1804 echo $itemtitleprev;
\r
1808 echo Entity::hsc($itemtitleprev);
\r
1815 * Actions::parse_prevlink()
\r
1816 * Parse skinvar prevlink
\r
1818 * @param string $linktext text as a content of anchor element
\r
1819 * @param integer the amount of links
\r
1822 public function parse_prevlink($linktext = '', $amount = 10)
\r
1824 global $itemidprev, $archiveprev, $startpos;
\r
1826 if ( $this->skintype == 'item' )
\r
1828 $this->itemlink($itemidprev, $linktext);
\r
1830 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
\r
1832 $this->searchlink($amount, $startpos, 'prev', $linktext);
\r
1836 $this->archivelink($archiveprev, $linktext);
\r
1842 * Actions::parse_query()
\r
1843 * Parse skinvar query
\r
1844 * (includes the search query)
\r
1849 public function parse_query()
\r
1852 echo Entity::hsc($query);
\r
1857 * Actions::parse_referer()
\r
1858 * Parse skinvar referer
\r
1863 public function parse_referer()
\r
1865 echo Entity::hsc(serverVar('HTTP_REFERER'));
\r
1870 * Actions::parse_searchform()
\r
1871 * Parse skinvar searchform
\r
1873 * @param string $blogname name of weblog
\r
1876 public function parse_searchform($blogname = '')
\r
1878 global $CONF, $manager, $maxresults;
\r
1881 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1887 // use default blog when no blog is selected
\r
1888 $this->formdata = array(
\r
1889 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
\r
1890 'query' => Entity::hsc(getVar('query')),
\r
1892 $this->doForm('searchform');
\r
1897 * Actions::parse_searchresults()
\r
1898 * Parse skinvar searchresults
\r
1900 * @param string $template name of tempalte
\r
1901 * @param integer $maxresults searched items in a display
\r
1904 public function parse_searchresults($template, $maxresults = 50 )
\r
1906 global $blog, $query, $amount, $startpos;
\r
1908 $this->setBlogCategory($blog, ''); // need this to select default category
\r
1909 $this->preBlogContent('searchresults',$blog);
\r
1910 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
\r
1911 $this->postBlogContent('searchresults',$blog);
\r
1916 * Actions::parse_self()
\r
1917 * Parse skinvar self
\r
1922 public function parse_self()
\r
1925 echo $CONF['Self'];
\r
1930 * Actions::parse_sitevar()
\r
1931 * Parse skinvar sitevar
\r
1932 * (include a sitevar)
\r
1934 * @param string $which
\r
1937 public function parse_sitevar($which)
\r
1943 echo $CONF['IndexURL'];
\r
1946 echo $CONF['SiteName'];
\r
1949 echo $CONF['AdminEmail'];
\r
1952 echo $CONF['AdminURL'];
\r
1958 * Actions::parse_skinname()
\r
1964 public function parse_skinname()
\r
1966 echo $this->skin->getName();
\r
1971 * Actions::parse_skintype()
\r
1972 * Parse skintype (experimental)
\r
1977 public function parse_skintype()
\r
1979 echo $this->skintype;
\r
1984 * Actions::parse_text()
\r
1990 public function parse_text($which)
\r
1992 // constant($which) only available from 4.0.4 :(
\r
1993 if ( defined($which) )
\r
1995 eval("echo $which;");
\r
2001 * Actions::parse_ticket()
\r
2007 public function parse_ticket()
\r
2010 $manager->addTicketHidden();
\r
2015 * Actions::parse_todaylink()
\r
2016 * Parse skinvar todaylink
\r
2017 * A link to the today page (depending on selected blog, etc...)
\r
2019 * @param string $linktext text for link
\r
2022 public function parse_todaylink($linktext = '')
\r
2024 global $blog, $CONF;
\r
2027 echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
\r
2031 echo $this->link($CONF['SiteUrl'], $linktext);
\r
2038 * When commentform is not used, to include a hidden field with itemid
\r
2043 public function parse_vars()
\r
2046 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";
\r
2051 * Actions::parse_version()
\r
2052 * Parse skinvar version
\r
2053 * (include nucleus versionnumber)
\r
2058 public function parse_version()
\r
2061 echo 'Nucleus CMS ' . $nucleus['version'];
\r
2066 * Actions::parse_sticky()
\r
2067 * Parse skinvar sticky
\r
2069 * @param integer $itemnumber id of item
\r
2070 * @param string $template name of template
\r
2073 public function parse_sticky($itemnumber = 0, $template = '')
\r
2077 $itemnumber = intval($itemnumber);
\r
2078 $itemarray = array($itemnumber);
\r
2080 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
\r
2081 $this->preBlogContent('sticky',$b);
\r
2082 $this->amountfound = $b->readLogFromList($itemarray, $template);
\r
2083 $this->postBlogContent('sticky',$b);
\r