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 1784 2012-04-22 04:28:30Z sakamocchi $
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
32 private $linkparams;
\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
43 private $amountfound;
\r
46 * Actions::$default_actions
\r
47 * list of whole action names with which this class can deal
\r
49 static private $default_actions = array(
\r
60 'otherarchivedaylist',
\r
62 'otherarchiveyearlist',
\r
73 // deprecated (Nucleus v2.0)
\r
74 /* TODO: remove this */
\r
79 * Actions::$skin_type_friendly_names
\r
80 * friendly name for wrapped page types
\r
82 static public $default_skin_types = array(
83 'index' => _SKIN_PART_MAIN,
\r
84 'item' => _SKIN_PART_ITEM,
\r
85 'archivelist' => _SKIN_PART_ALIST,
\r
86 'archive' => _SKIN_PART_ARCHIVE,
\r
87 'search' => _SKIN_PART_SEARCH,
\r
88 'error' => _SKIN_PART_ERROR,
\r
89 'member' => _SKIN_PART_MEMBER,
\r
90 'imagepopup' => _SKIN_PART_POPUP
\r
94 * Actions::getDefinedActions()
\r
97 * @param string $type page type
\r
98 * @return array allowed actions for the page type
\r
100 static public function getDefinedActions($type='')
\r
102 $extra_actions = array();
\r
107 $extra_actions = array(
\r
121 $extra_actions = array(
\r
138 case 'archivelist':
\r
139 $extra_actions = array(
\r
149 $extra_actions = array(
\r
156 'othersearchresults',
\r
164 $extra_actions = array(
\r
166 // deprecated (Nucleus v2.0)
\r
167 /* TODO: remove this */
\r
172 $extra_actions = array(
\r
180 $extra_actions = array(
\r
203 $extra_actions = array(
\r
209 $extra_actions = array(
\r
227 $defined_actions = array_merge(self::$default_actions, $extra_actions);
229 return array_merge($defined_actions, parent::getDefinedActions());
233 * Actions::getDefaultSkinTypes()
237 * @return array list of friendly names for page actions
\r
239 static public function getDefaultSkinTypes()
241 return self::$default_skin_types;
245 * Actions::__construct()
\r
246 * Constructor for a new Actions object
\r
248 * @param string $type
\r
251 public function __construct($type)
\r
255 // call constructor of superclass first
\r
256 parent::__construct();
258 $this->skintype = $type;
\r
262 $this->linkparams = array('catid' => $catid);
\r
268 * Actions::setSkin()
\r
270 * @param object $skin an instance of Skin class
\r
273 public function setSkin(&$skin)
\r
275 $this->skin =& $skin;
\r
280 * Actions::setParser()
\r
283 * @param object $parser an instance of Parser class
\r
286 public function setParser(&$parser)
\r
288 $this->parser =& $parser;
\r
293 * Actions::doForm()
\r
294 * Forms get parsedincluded now, using an extra <formdata> skinvar
\r
296 * @param string $filename
\r
299 public function doForm($filename)
\r
301 global $DIR_NUCLEUS;
\r
302 array_push($this->parser->actions,'formdata', 'callback','errordiv','ticket');
\r
304 $oldIncludeMode = Parser::getProperty('IncludeMode');
\r
305 $oldIncludePrefix = Parser::getProperty('IncludePrefix');
\r
306 Parser::setProperty('IncludeMode','normal');
\r
307 Parser::setProperty('IncludePrefix','');
\r
309 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
\r
310 Parser::setProperty('IncludeMode',$oldIncludeMode);
\r
311 Parser::setProperty('IncludePrefix',$oldIncludePrefix);
\r
313 array_pop($this->parser->actions); // errordiv
\r
314 array_pop($this->parser->actions); // callback
\r
315 array_pop($this->parser->actions); // formdata
\r
316 array_pop($this->parser->actions); // ticket
\r
321 * Actions::checkCondition()
\r
322 * Checks conditions for if statements
\r
324 * @param string $field type of <%if%>
\r
325 * @param string $name property of field
\r
326 * @param string $value value of property
\r
327 * @return boolean condition
\r
329 protected function checkCondition($field, $name='', $value = '')
\r
331 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
\r
337 $condition = ($blog && $this->ifCategory($name,$value));
\r
339 case 'blogsetting':
\r
340 $condition = ($blog && ($blog->getSetting($name) == $value));
\r
343 $condition = $member->isLoggedIn();
\r
346 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
\r
349 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
\r
352 $condition = ($itemidnext != '');
\r
355 $condition = ($itemidprev != '');
\r
357 case 'archiveprevexists':
\r
358 $condition = ($archiveprevexists == true);
\r
360 case 'archivenextexists':
\r
361 $condition = ($archivenextexists == true);
\r
364 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
\r
367 $condition = $this->ifHasPlugin($name, $value);
\r
370 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
\r
377 * Actions::_ifHasPlugin()
\r
378 * hasplugin,PlugName
\r
379 * -> checks if plugin exists
\r
380 * hasplugin,PlugName,OptionName
\r
381 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
\r
382 * hasplugin,PlugName,OptionName=value
\r
383 * -> checks if the option OptionName from plugin PlugName is set to value
\r
385 * @param string $name name of plugin
\r
386 * @param string $value
\r
389 private function ifHasPlugin($name, $value)
\r
392 $condition = false;
\r
393 // (pluginInstalled method won't write a message in the actionlog on failure)
\r
394 if ( $manager->pluginInstalled("NP_{$name}") )
\r
396 $plugin =& $manager->getPlugin("NP_{$name}");
\r
397 if ( $plugin != NULL )
\r
399 if ( $value == "" )
\r
405 list($name2, $value2) = preg_split('#=#', $value, 2);
\r
406 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
\r
410 else if ( $plugin->getOption($name2) == $value2 )
\r
421 * Actions::ifPlugin()
\r
422 * Checks if a plugin exists and call its doIf function
\r
424 * @param string $name name of plugin
\r
425 * @param string $key name of plugin option
\r
426 * @param string $value value of plugin option
\r
429 private function ifPlugin($name, $key = '', $value = '')
\r
433 $plugin =& $manager->getPlugin("NP_{$name}");
\r
439 $params = func_get_args();
\r
440 array_shift($params);
\r
442 return call_user_func_array(array(&$plugin, 'doIf'), $params);
\r
446 * Actions::ifCategory()
\r
447 * Different checks for a category
\r
449 * @param string $name
\r
450 * @param string $value
\r
453 private function ifCategory($name = '', $value='')
\r
455 global $blog, $catid;
\r
457 // when no parameter is defined, just check if a category is selected
\r
458 if ( ($name != 'catname' && $name != 'catid') || ($value == '') )
\r
460 return $blog->isValidCategory($catid);
\r
463 // check category name
\r
464 if ( $name == 'catname' )
\r
466 $value = $blog->getCategoryIdFromName($value);
\r
467 if ( $value == $catid )
\r
469 return $blog->isValidCategory($catid);
\r
473 // check category id
\r
474 if ( ($name == 'catid') && ($value == $catid) )
\r
476 return $blog->isValidCategory($catid);
\r
482 * Actions::ifOnTeam()
\r
483 * Checks if a member is on the team of a blog and return his rights
\r
485 * @param string $blogName name of weblog
\r
488 private function ifOnTeam($blogName = '')
\r
490 global $blog, $member, $manager;
\r
492 // when no blog found
\r
493 if ( ($blogName == '') && !is_object($blog) )
\r
498 // explicit blog selection
\r
499 if ( $blogName != '' )
\r
501 $blogid = getBlogIDFromName($blogName);
\r
504 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
\r
506 // use current blog
\r
507 $blogid = $blog->getID();
\r
510 return $member->teamRights($blogid);
\r
514 * Actions::ifAdmin()
\r
515 * Checks if a member is admin of a blog
\r
517 * @param string $blogName name of weblog
\r
520 private function ifAdmin($blogName = '')
\r
522 global $blog, $member, $manager;
\r
524 // when no blog found
\r
525 if ( ($blogName == '') && (!is_object($blog)) )
\r
530 // explicit blog selection
\r
531 if ( $blogName != '' )
\r
533 $blogid = getBlogIDFromName($blogName);
\r
536 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
\r
538 // use current blog
\r
539 $blogid = $blog->getID();
\r
542 return $member->isBlogAdmin($blogid);
\r
548 * - a raw link (html/xml encoded) when no linktext is provided
\r
549 * - a (x)html <a href... link when a text is present (text htmlencoded)
\r
551 * @param string $url URL for href attribute of anchor element
\r
552 * @param string $linktext content of anchor element
\r
555 private function link($url, $linktext = '')
\r
557 $u = Entity::hsc($url);
\r
558 // fix URLs that already had encoded ampersands
\r
559 $u = preg_replace("#&amp;#", '&', $u);
\r
560 if ( $linktext != '' )
\r
562 $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';
\r
572 * Actions::searchlink()
\r
573 * Outputs a next/prev link
\r
575 * @param $maxresults
\r
576 * The maximum amount of items shown per page (e.g. 10)
\r
578 * Current start position (requestVar('startpos'))
\r
579 * @param $direction
\r
580 * either 'prev' or 'next'
\r
582 * When present, the output will be a full <a href...> link. When empty,
\r
583 * only a raw link will be outputted
\r
585 private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')
\r
587 global $CONF, $blog, $query, $amount;
\r
588 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
\r
589 $startpos = (integer) $startpos;
\r
590 $parsed = parse_url(serverVar('REQUEST_URI'));
\r
591 $path = $parsed['path'];
\r
592 $parsed = $parsed['query'];
\r
595 if ( $direction == 'prev' )
\r
597 if ( intval($startpos) - intval($maxresults) >= 0 )
\r
599 $startpos = intval($startpos) - intval($maxresults);
\r
601 if ( $this->skintype == 'index' )
\r
605 else if ( $this->skintype == 'search' )
\r
607 $url = $CONF['SearchURL'];
\r
609 $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);
\r
612 else if ( $direction == 'next' )
\r
614 global $navigationItems;
\r
615 if ( !isset($navigationItems) )
\r
617 $navigationItems = 0;
\r
622 $iAmountOnPage = 0;
\r
626 $iAmountOnPage = $this->amountfound;
\r
629 if ( intval($navigationItems) > 0 )
\r
631 $iAmountOnPage = intval($navigationItems) - intval($startpos);
\r
633 elseif ( $iAmountOnPage == 0 )
\r
636 * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
\r
637 * try a count query
\r
639 if ( $this->skintype == 'index' )
\r
641 $sqlquery = $blog->getSqlBlog('', 'count');
\r
644 else if ( $this->skintype == 'search' )
\r
646 $unused_highlight = '';
\r
647 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
\r
648 $url = $CONF['SearchURL'];
\r
652 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
\r
657 if ( intval($iAmountOnPage) >= intval($maxresults) )
\r
659 $startpos = intval($startpos) + intval($maxresults);
\r
660 $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos);
\r
666 echo $this->link($url, $linktext);
\r
672 * Actions::itemlink()
\r
673 * Creates an item link and if no id is given a todaylink
\r
675 * @param integer $id id for link
\r
676 * @param string $linktext text for link
\r
679 private function itemlink($id, $linktext = '')
\r
684 echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);
\r
688 $this->parse_todaylink($linktext);
\r
694 * Actions::archivelink)
\r
695 * Creates an archive link and if no id is given a todaylink
\r
697 * @param integer $id id for link
\r
698 * @param string $linktext text for link
\r
701 private function archivelink($id, $linktext = '')
\r
703 global $CONF, $blog;
\r
706 echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
\r
710 $this->parse_todaylink($linktext);
\r
716 * Actions:setBlogCategory()
\r
717 * Helper function that sets the category that a blog will need to use
\r
719 * @param string $blog An object of the blog class, passed by reference (we want to make changes to it)
\r
720 * @param string $catname The name of the category to use
\r
723 private function setBlogCategory(&$blog, $catname)
\r
726 if ( $catname != '' )
\r
728 $blog->setSelectedCategoryByName($catname);
\r
732 $blog->setSelectedCategory($catid);
\r
738 * Actions::preBlogContent()
\r
739 * Notifies the Manager that a PreBlogContent event occurs
\r
741 * @param string $type type of skin
\r
742 * @param object $blog an instance of Blog class
\r
745 private function preBlogContent($type, &$blog)
\r
748 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
\r
753 * Actions::postBlogContent()
\r
754 * Notifies the Manager that a PostBlogContent event occurs
\r
756 * @param string $type type of skin
\r
757 * @param objecct $blog an instance of Blog class
\r
760 private function postBlogContent($type, &$blog)
\r
763 $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));
\r
768 * Actions::parse_additemform()
\r
769 * Parse skinvar additemform
\r
774 public function parse_additemform()
\r
776 global $blog, $CONF;
\r
777 $this->formdata = array(
\r
778 'adminurl' => Entity::hsc($CONF['AdminURL']),
\r
779 'catid' => $blog->getDefaultCategory()
\r
781 $blog->InsertJavaScriptInfo();
\r
782 $this->doForm('additemform');
\r
787 * Actions::parse_addlink()
\r
788 * Parse skinvar addlink
\r
789 * A Link that allows to open a bookmarklet to add an item
\r
791 public function parse_addlink()
\r
793 global $CONF, $member, $blog;
\r
794 if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )
\r
796 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
\r
802 * Actions::parse_addpopupcode()
\r
803 * Parse skinvar addpopupcode
\r
804 * Code that opens a bookmarklet in an popup window
\r
809 public function parse_addpopupcode()
\r
811 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
816 * Parse skinvar adminurl
\r
817 * (shortcut for admin url)
\r
822 public function parse_adminurl()
\r
824 $this->parse_sitevar('adminurl');
\r
829 * Actions::parse_archive()
\r
830 * Parse skinvar archive
\r
832 * @param string $template name of template
\r
833 * @param string $category name of category
\r
836 public function parse_archive($template, $category = '')
\r
838 global $blog, $archive;
\r
839 // can be used with either yyyy-mm or yyyy-mm-dd
\r
840 sscanf($archive,'%d-%d-%d', $y, $m, $d);
\r
841 $this->setBlogCategory($blog, $category);
\r
842 $this->preBlogContent('achive',$blog);
\r
843 $blog->showArchive($template, $y, $m, $d);
\r
844 $this->postBlogContent('achive',$blog);
\r
849 * Actions::parse_archivedate()
\r
850 * %archivedate(locale,date format)%
\r
852 * @param string $locale
\r
855 public function parse_archivedate($locale = '-def-')
\r
860 * TODO: these lines are no meaning because there is no $template.
\r
861 if ( $locale == '-def-' )
\r
863 setlocale(LC_TIME, $template['LOCALE']);
\r
867 setlocale(LC_TIME, $locale);
\r
871 // get archive date
\r
872 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
875 $args = func_get_args();
\r
876 // format can be spread over multiple parameters
\r
877 if ( sizeof($args) > 1 )
\r
879 // take away locale
\r
880 array_shift($args);
\r
882 $format=implode(',',$args);
\r
884 elseif ( $d == 0 && $m !=0 )
\r
894 $format = '%d %B %Y';
\r
896 echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
\r
901 * Actions::parse_archivedaylist()
\r
902 * Parse skinvar archivedaylist
\r
904 * @param string $template name of template
\r
905 * @param string $category name of category
\r
906 * @param integer $limit the number of items in a display
\r
909 public function parse_archivedaylist($template, $category = 'all', $limit = 0)
\r
912 if ( $category == 'all' )
\r
916 $this->preBlogContent('archivelist',$blog);
\r
917 $this->setBlogCategory($blog, $category);
\r
918 $blog->showArchiveList($template, 'day', $limit);
\r
919 $this->postBlogContent('archivelist',$blog);
\r
924 * Actions::parse_archivelink()
\r
925 * A link to the archives for the current blog (or for default blog)
\r
927 * @param string $linktext text for link
\r
930 public function parse_archivelink($linktext = '')
\r
932 global $blog, $CONF;
\r
935 echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);
\r
939 echo $this->link(Link::create_archivelist_link(), $linktext);
\r
945 * Actions::parse_archivelist()
\r
947 * @param string $template name of template
\r
948 * @param string $category name of category
\r
949 * @param integer $limit the number of items in a display
\r
952 public function parse_archivelist($template, $category = 'all', $limit = 0)
\r
955 if ( $category == 'all' )
\r
959 $this->preBlogContent('archivelist',$blog);
\r
960 $this->setBlogCategory($blog, $category);
\r
961 $blog->showArchiveList($template, 'month', $limit);
\r
962 $this->postBlogContent('archivelist',$blog);
\r
967 * Actions::parse_archiveyearlist()
\r
969 * @param string $template name of template
\r
970 * @param string $category name of category
\r
971 * @param integer $limit the number of items in a display
\r
973 public function parse_archiveyearlist($template, $category = 'all', $limit = 0)
\r
976 if ( $category == 'all' )
\r
980 $this->preBlogContent('archivelist',$blog);
\r
981 $this->setBlogCategory($blog, $category);
\r
982 $blog->showArchiveList($template, 'year', $limit);
\r
983 $this->postBlogContent('archivelist',$blog);
\r
988 * Actions::parse_archivetype()
\r
989 * Parse skinvar archivetype
\r
994 public function parse_archivetype()
\r
996 global $archivetype;
\r
1002 * Actions::parse_blog()
\r
1003 * Parse skinvar blog
\r
1005 * @param string $template name of template
\r
1006 * @param mixed $amount the number of items in a display, in case it includes the beginning
\r
1007 * @param string $category name of category
\r
1010 public function parse_blog($template, $amount = 10, $category = '')
\r
1012 global $blog, $startpos;
\r
1014 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
1015 $this->setBlogCategory($blog, $category);
\r
1016 $this->preBlogContent('blog',$blog);
\r
1017 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
\r
1018 $this->postBlogContent('blog',$blog);
\r
1023 * Actions::parse_bloglist()
\r
1024 * Parse skinvar bloglist
\r
1025 * Shows a list of all blogs
\r
1027 * @param string $template name of template
\r
1028 * @param string $bnametype whether 'name' or 'shortname' is used for the link text
\r
1029 * @param string $orderby order criteria
\r
1030 * @param string $direction order ascending or descending
\r
1033 public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')
\r
1035 Blog::showBlogList($template, $bnametype, $orderby, $direction);
\r
1040 * Actions::parse_blogsetting()
\r
1041 * Parse skinvar blogsetting
\r
1043 * @param string $which key of weblog settings
\r
1046 public function parse_blogsetting($which)
\r
1052 echo Entity::hsc($blog->getID());
\r
1055 echo Entity::hsc($blog->getURL());
\r
1058 echo Entity::hsc($blog->getName());
\r
1061 echo Entity::hsc($blog->getDescription());
\r
1064 echo Entity::hsc($blog->getShortName());
\r
1071 * Actions::parse_callback()
\r
1074 * @param string $eventName name of event
\r
1075 * @param string $type type of skin
\r
1078 public function parse_callback($eventName, $type)
\r
1081 $manager->notify($eventName, array('type' => $type));
\r
1086 * Actions::parse_category()
\r
1087 * Parse skinvar category
\r
1089 * @param string $type key of category settings
\r
1092 public function parse_category($type = 'name')
\r
1094 global $catid, $blog;
\r
1095 if ( !$blog->isValidCategory($catid) )
\r
1103 echo $blog->getCategoryName($catid);
\r
1106 echo $blog->getCategoryDesc($catid);
\r
1116 * Actions::parse_categorylist()
\r
1117 * Parse categorylist
\r
1119 * @param string $template name of template
\r
1120 * @param string $blogname name of weblog
\r
1123 public function parse_categorylist($template, $blogname = '')
\r
1125 global $blog, $manager;
\r
1127 // when no blog found
\r
1128 if ( ($blogname == '') && (!is_object($blog)) )
\r
1133 if ( $blogname == '' )
\r
1135 $this->preBlogContent('categorylist',$blog);
\r
1136 $blog->showCategoryList($template);
\r
1137 $this->postBlogContent('categorylist',$blog);
\r
1141 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1142 $this->preBlogContent('categorylist',$b);
\r
1143 $b->showCategoryList($template);
\r
1144 $this->postBlogContent('categorylist',$b);
\r
1150 * Actions::parse_charset()
\r
1151 * Parse skinvar charset
\r
1156 public function parse_charset()
\r
1158 echo i18n::get_current_charset();
\r
1163 * Actions::parse_commentform()
\r
1164 * Parse skinvar commentform
\r
1166 * @param string $destinationurl URI for redirection
\r
1169 public function parse_commentform($destinationurl = '')
\r
1171 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
\r
1173 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
\r
1174 if ( stristr($destinationurl, 'action.php') )
\r
1176 $args = func_get_args();
\r
1177 $destinationurl = $args[1];
\r
1178 ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
\r
1181 $actionurl = $CONF['ActionURL'];
\r
1183 // if item is closed, show message and do nothing
\r
1184 $item =& $manager->getItem($itemid,0,0);
\r
1185 if ( $item['closed'] || !$blog->commentsEnabled() )
\r
1187 $this->doForm('commentform-closed');
\r
1191 if ( !$blog->isPublic() && !$member->isLoggedIn() )
\r
1193 $this->doForm('commentform-closedtopublic');
\r
1197 if ( !$destinationurl )
\r
1199 // note: createLink returns an HTML encoded URL
\r
1200 $destinationurl = Link::create_link(
\r
1203 'itemid' => $itemid,
\r
1204 'title' => $item['title'],
\r
1205 'timestamp' => $item['timestamp'],
\r
1206 'extra' => $this->linkparams
\r
1212 // HTML encode URL
\r
1213 $destinationurl = Entity::hsc($destinationurl);
\r
1216 // values to prefill
\r
1217 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
\r
1220 $user = postVar('user');
\r
1223 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
\r
1226 $userid = postVar('userid');
\r
1229 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
\r
1232 $email = postVar('email');
\r
1235 $body = postVar('body');
\r
1237 $this->formdata = array(
\r
1238 'destinationurl' => $destinationurl, // url is already HTML encoded
\r
1239 'actionurl' => Entity::hsc($actionurl),
\r
1240 'itemid' => $itemid,
\r
1241 'user' => Entity::hsc($user),
\r
1242 'userid' => Entity::hsc($userid),
\r
1243 'email' => Entity::hsc($email),
\r
1244 'body' => Entity::hsc($body),
\r
1245 'membername' => $member->getDisplayName(),
\r
1246 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
\r
1249 if ( !$member->isLoggedIn() )
\r
1251 $this->doForm('commentform-notloggedin');
\r
1255 $this->doForm('commentform-loggedin');
\r
1261 * Actions::parse_comments()
\r
1262 * Parse skinvar comments
\r
1263 * include comments for one item
\r
1265 * @param string $template name of template
\r
1268 public function parse_comments($template)
\r
1270 global $itemid, $manager, $blog, $highlight;
\r
1271 $template =& $manager->getTemplate($template);
\r
1273 // create parser object & action handler
\r
1274 $actions = new ItemActions($blog);
\r
1275 $parser = new Parser($actions->getDefinedActions(),$actions);
\r
1276 $actions->setTemplate($template);
\r
1277 $actions->setParser($parser);
\r
1278 $item = Item::getitem($itemid, 0, 0);
\r
1279 $actions->setCurrentItem($item);
\r
1281 $comments = new Comments($itemid);
\r
1282 $comments->setItemActions($actions);
\r
1283 // shows ALL comments
\r
1284 $comments->showComments($template, -1, 1, $highlight);
\r
1289 * Actions::parse_errordiv()
\r
1295 public function parse_errordiv()
\r
1297 global $errormessage;
\r
1298 if ( $errormessage )
\r
1300 echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";
\r
1306 * Actions::parse_errormessage()
\r
1307 * Parse skinvar errormessage
\r
1312 public function parse_errormessage()
\r
1314 global $errormessage;
\r
1315 echo $errormessage;
\r
1320 * Actions::parse_formdata()
\r
1323 * @param string $what key of format data
\r
1326 public function parse_formdata($what)
\r
1328 echo $this->formdata[$what];
\r
1333 * Actions::parse_ifcat()
\r
1336 * @param string $text
\r
1339 public function parse_ifcat($text = '')
\r
1341 if ( $text == '' )
\r
1344 $this->parse_if('category');
\r
1349 global $catid, $blog;
\r
1350 if ( $blog->isValidCategory($catid) )
\r
1359 * Actions::parse_image()
\r
1360 * Parse skinvar image
\r
1362 * @param string $what name of tag
\r
1365 public function parse_image($what = 'imgtag')
\r
1369 $imagetext = Entity::hsc(requestVar('imagetext'));
\r
1370 $imagepopup = requestVar('imagepopup');
\r
1371 $width = intRequestVar('width');
\r
1372 $height = intRequestVar('height');
\r
1373 $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup);
\r
1392 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
\r
1399 * Actions::parse_imagetext()
\r
1400 * Parse skinvar imagetext
\r
1405 public function parse_imagetext()
\r
1407 $this->parse_image('imagetext');
\r
1412 * Actions::parse_item()
\r
1413 * Parse skinvar item
\r
1414 * include one item (no comments)
\r
1419 public function parse_item($template)
\r
1421 global $blog, $itemid, $highlight;
\r
1423 // need this to select default category
\r
1424 $this->setBlogCategory($blog, '');
\r
1425 $this->preBlogContent('item',$blog);
\r
1426 $r = $blog->showOneitem($itemid, $template, $highlight);
\r
1429 echo _ERROR_NOSUCHITEM;
\r
1431 $this->postBlogContent('item',$blog);
\r
1436 * Actions::parse_itemid()
\r
1437 * Parse skinvar itemid
\r
1442 public function parse_itemid()
\r
1450 * Actions::parseitemlink()
\r
1451 * Parse skinvar itemlink
\r
1456 public function parse_itemlink($linktext = '')
\r
1459 $this->itemlink($itemid, $linktext);
\r
1464 * Actions::parse_itemtitle()
\r
1470 public function parse_itemtitle($format = '')
\r
1472 global $manager, $itemid;
\r
1473 $item =& $manager->getItem($itemid,0,0);
\r
1475 switch ( $format )
\r
1478 echo Entity::hen($item['title']);
\r
1481 echo $item['title'];
\r
1485 echo Entity::hsc(strip_tags($item['title']));
\r
1492 * Actions::parse_loginform()
\r
1493 * Parse skinvar loginform
\r
1498 public function parse_loginform()
\r
1500 global $member, $CONF;
\r
1501 if ( !$member->isLoggedIn() )
\r
1503 $filename = 'loginform-notloggedin';
\r
1504 $this->formdata = array();
\r
1508 $filename = 'loginform-loggedin';
\r
1509 $this->formdata = array(
\r
1510 'membername' => $member->getDisplayName(),
\r
1513 $this->doForm($filename);
\r
1518 * Actions::parse_member()
\r
1519 * Parse skinvar member
\r
1520 * (includes a member info thingie)
\r
1522 * @param string $what which memberdata is needed
\r
1525 public function parse_member($what)
\r
1527 global $memberinfo, $member, $CONF;
\r
1529 // 1. only allow the member-details-page specific variables on member pages
\r
1530 if ( $this->skintype == 'member' )
\r
1535 echo Entity::hsc($memberinfo->getDisplayName());
\r
1538 echo Entity::hsc($memberinfo->getRealName());
\r
1541 echo Entity::hsc($memberinfo->getNotes());
\r
1544 echo Entity::hsc($memberinfo->getURL());
\r
1547 echo Entity::hsc($memberinfo->getEmail());
\r
1550 echo Entity::hsc($memberinfo->getID());
\r
1555 // 2. the next bunch of options is available everywhere, as long as the user is logged in
\r
1556 if ( $member->isLoggedIn() )
\r
1561 echo $member->getDisplayName();
\r
1563 case 'yourrealname':
\r
1564 echo $member->getRealName();
\r
1567 echo $member->getNotes();
\r
1570 echo $member->getURL();
\r
1573 echo $member->getEmail();
\r
1576 echo $member->getID();
\r
1578 case 'yourprofileurl':
\r
1579 if ($CONF['URLMode'] == 'pathinfo')
\r
1580 echo Link::create_member_link($member->getID());
\r
1582 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
\r
1590 * Link::parse_membermailform()
\r
1591 * Parse skinvar membermailform
\r
1593 * @param integer $rows the height for textarea
\r
1594 * @param integer $cols the width for textarea
\r
1595 * @param string $desturl URI to redirect
\r
1598 public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
\r
1600 global $member, $CONF, $memberid;
\r
1602 if ( $desturl == '' )
\r
1604 if ( $CONF['URLMode'] == 'pathinfo' )
\r
1606 $desturl = Link::create_member_link($memberid);
\r
1610 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
\r
1614 $message = postVar('message');
\r
1615 $frommail = postVar('frommail');
\r
1617 $this->formdata = array(
\r
1618 'url' => Entity::hsc($desturl),
\r
1619 'actionurl' => Entity::hsc($CONF['ActionURL']),
\r
1620 'memberid' => $memberid,
\r
1623 'message' => Entity::hsc($message),
\r
1624 'frommail' => Entity::hsc($frommail)
\r
1627 if ( $member->isLoggedIn() )
\r
1629 $this->doForm('membermailform-loggedin');
\r
1631 else if ( $CONF['NonmemberMail'] )
\r
1633 $this->doForm('membermailform-notloggedin');
\r
1637 $this->doForm('membermailform-disallowed');
\r
1643 * Actions::parse_nextarchive()
\r
1644 * Parse skinvar nextarchive
\r
1649 public function parse_nextarchive()
\r
1651 global $archivenext;
\r
1652 echo $archivenext;
\r
1657 * Parse skinvar nextitem
\r
1658 * (include itemid of next item)
\r
1663 public function parse_nextitem()
\r
1665 global $itemidnext;
\r
1666 if ( isset($itemidnext) )
\r
1668 echo (int)$itemidnext;
\r
1674 * Actions::parse_nextitemtitle()
\r
1675 * Parse skinvar nextitemtitle
\r
1676 * (include itemtitle of next item)
\r
1678 * @param string $format format of text
\r
1681 public function parse_nextitemtitle($format = '')
\r
1683 global $itemtitlenext;
\r
1685 switch ( $format )
\r
1688 echo Entity::hen($itemtitlenext);
\r
1691 echo $itemtitlenext;
\r
1695 echo Entity::hsc($itemtitlenext);
\r
1702 * Actions::parse_nextlink()
\r
1703 * Parse skinvar nextlink
\r
1705 * @param string $linktext text for content of anchor element
\r
1706 * @param integer $amount the amount of items in a display
\r
1707 * @param integer $recount increment from this value
\r
1710 public function parse_nextlink($linktext = '', $amount = 10, $recount = '')
\r
1712 global $itemidnext, $archivenext, $startpos;
\r
1713 if ( $this->skintype == 'item' )
\r
1715 $this->itemlink($itemidnext, $linktext);
\r
1717 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
\r
1719 $this->searchlink($amount, $startpos, 'next', $linktext, $recount);
\r
1723 $this->archivelink($archivenext, $linktext);
\r
1729 * Actions::parse_nucleusbutton()
\r
1730 * Parse skinvar nucleusbutton
\r
1732 * @param string $imgurl URL for image
\r
1733 * @param integer $imgwidth width of image
\r
1734 * @param integer $imgheidht height of image
\r
1736 public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')
\r
1739 if ( $imgurl == '' )
\r
1741 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
\r
1743 else if ( Parser::getProperty('IncludeMode') == 'skindir' )
\r
1745 // when skindit IncludeMode is used: start from skindir
\r
1746 $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
\r
1749 $this->formdata = array(
\r
1750 'imgurl' => $imgurl,
\r
1751 'imgwidth' => $imgwidth,
\r
1752 'imgheight' => $imgheight,
\r
1754 $this->doForm('nucleusbutton');
\r
1759 * Actions::parse_otherarchive()
\r
1760 * Parse skinvar otherarchive
\r
1762 * @param string $blogname name of weblog
\r
1763 * @param string $template name of template
\r
1764 * @param string $category name of category
\r
1767 public function parse_otherarchive($blogname, $template, $category = '')
\r
1769 global $archive, $manager;
\r
1770 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
1771 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1772 $this->setBlogCategory($b, $category);
\r
1773 $this->preBlogContent('otherachive',$b);
\r
1774 $b->showArchive($template, $y, $m, $d);
\r
1775 $this->postBlogContent('otherachive',$b);
\r
1780 * Actions::parse_otherarchivedaylist()
\r
1781 * Parse skinvar otherarchivedaylist
\r
1783 * @param string $blogname name of weblog
\r
1784 * @param string $template name of template
\r
1785 * @param string $category name of category
\r
1786 * @param integer $limit the amount of items in a display
\r
1789 public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)
\r
1792 if ( $category == 'all')
\r
1796 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1797 $this->setBlogCategory($b, $category);
\r
1798 $this->preBlogContent('otherarchivelist',$b);
\r
1799 $b->showArchiveList($template, 'day', $limit);
\r
1800 $this->postBlogContent('otherarchivelist',$b);
\r
1805 * Actions::parse_otherarchivelist()
\r
1806 * Parse skinvar otherarchivelist
\r
1808 * @param string $blogname name of weblog
\r
1809 * @param string $template name of template
\r
1810 * @param string $category name of category
\r
1811 * @param integer $limit the amount of items in a display
\r
1814 public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)
\r
1817 if ( $category == 'all' )
\r
1821 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1822 $this->setBlogCategory($b, $category);
\r
1823 $this->preBlogContent('otherarchivelist',$b);
\r
1824 $b->showArchiveList($template, 'month', $limit);
\r
1825 $this->postBlogContent('otherarchivelist',$b);
\r
1830 * Actions::parse_otherarchiveyearlist()
\r
1831 * Parse skinvar otherarchiveyearlist
\r
1833 * @param string $blogname name of weblog
\r
1834 * @param string $template name of template
\r
1835 * @param string $category name of category
\r
1836 * @limit integer $limit the amount of items in a display
\r
1838 public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)
\r
1841 if ( $category == 'all' )
\r
1845 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1846 $this->setBlogCategory($b, $category);
\r
1847 $this->preBlogContent('otherarchivelist',$b);
\r
1848 $b->showArchiveList($template, 'year', $limit);
\r
1849 $this->postBlogContent('otherarchivelist',$b);
\r
1854 * Actions::parse_otherblog()
\r
1855 * Parse skinvar otherblog
\r
1857 * @param string $blogname name of weblog
\r
1858 * @param string $template name of template
\r
1859 * @param mixed $amount the amount of items, in case it includes the beginning
\r
1860 * @param string $category name of category
\r
1863 public function parse_otherblog($blogname, $template, $amount = 10, $category = '')
\r
1867 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
1869 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1870 $this->setBlogCategory($b, $category);
\r
1871 $this->preBlogContent('otherblog',$b);
\r
1872 $this->amountfound = $b->readLog($template, $limit, $offset);
\r
1873 $this->postBlogContent('otherblog',$b);
\r
1878 * Actions::parse_othersearchresults()
\r
1879 * Parse skinvar othersearchresults
\r
1881 * @param string $blogname name of weblog
\r
1882 * @param string $template name of template
\r
1883 * @param integer $maxresults the amount of results
\r
1886 public function parse_othersearchresults($blogname, $template, $maxresults = 50)
\r
1888 global $query, $amount, $manager, $startpos;
\r
1889 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1890 // need this to select default category
\r
1891 $this->setBlogCategory($b, '');
\r
1892 $this->preBlogContent('othersearchresults',$b);
\r
1893 $b->search($query, $template, $amount, $maxresults, $startpos);
\r
1894 $this->postBlogContent('othersearchresults',$b);
\r
1899 * Actions::parse_plugin()
\r
1900 * Executes a plugin skinvar
\r
1901 * extra parameters can be added
\r
1903 * @param string $pluginName name of plugin (without the NP_)
\r
1906 public function parse_plugin($pluginName)
\r
1910 $plugin =& $manager->getPlugin('NP_' . $pluginName);
\r
1917 $params = func_get_args();
\r
1919 // remove plugin name
\r
1920 array_shift($params);
\r
1922 // add skin type on front
\r
1923 array_unshift($params, $this->skintype);
\r
1925 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
\r
1930 * Actions::parse_prevarchive()
\r
1931 * Parse skinvar prevarchive
\r
1936 public function parse_prevarchive()
\r
1938 global $archiveprev;
\r
1939 echo $archiveprev;
\r
1943 * Actions::parse_preview()
\r
1944 * Parse skinvar preview
\r
1946 * @param string $template name of tempalte
\r
1949 public function parse_preview($template)
\r
1951 global $blog, $CONF, $manager;
\r
1953 $template =& $manager->getTemplate($template);
\r
1955 $row['body'] = '<span id="prevbody"></span>';
\r
1956 $row['title'] = '<span id="prevtitle"></span>';
\r
1957 $row['more'] = '<span id="prevmore"></span>';
\r
1958 $row['itemlink'] = '';
\r
1959 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
\r
1961 echo Template::fill($template['ITEM_HEADER'],$row);
\r
1962 echo Template::fill($template['ITEM'],$row);
\r
1963 echo Template::fill($template['ITEM_FOOTER'],$row);
\r
1968 * Actions::parse_previtem()
\r
1969 * Parse skinvar previtem
\r
1970 * (include itemid of prev item)
\r
1975 public function parse_previtem()
\r
1977 global $itemidprev;
\r
1978 if ( isset($itemidprev) )
\r
1980 echo (integer) $itemidprev;
\r
1986 * Actions::parse_previtemtitle()
\r
1987 * Parse skinvar previtemtitle
\r
1988 * (include itemtitle of prev item)
\r
1990 * @param String $format string format
\r
1991 * @return String formatted string
\r
1993 public function parse_previtemtitle($format = '')
\r
1995 global $itemtitleprev;
\r
1997 switch ( $format )
\r
2000 echo Entity::hen($itemtitleprev);
\r
2003 echo $itemtitleprev;
\r
2007 echo Entity::hsc($itemtitleprev);
\r
2014 * Actions::parse_prevlink()
\r
2015 * Parse skinvar prevlink
\r
2017 * @param string $linktext text as a content of anchor element
\r
2018 * @param integer the amount of links
\r
2021 public function parse_prevlink($linktext = '', $amount = 10)
\r
2023 global $itemidprev, $archiveprev, $startpos;
\r
2025 if ( $this->skintype == 'item' )
\r
2027 $this->itemlink($itemidprev, $linktext);
\r
2029 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
\r
2031 $this->searchlink($amount, $startpos, 'prev', $linktext);
\r
2035 $this->archivelink($archiveprev, $linktext);
\r
2041 * Actions::parse_query()
\r
2042 * Parse skinvar query
\r
2043 * (includes the search query)
\r
2048 public function parse_query()
\r
2051 echo Entity::hsc($query);
\r
2056 * Actions::parse_referer()
\r
2057 * Parse skinvar referer
\r
2062 public function parse_referer()
\r
2064 echo Entity::hsc(serverVar('HTTP_REFERER'));
\r
2069 * Actions::parse_searchform()
\r
2070 * Parse skinvar searchform
\r
2072 * @param string $blogname name of weblog
\r
2075 public function parse_searchform($blogname = '')
\r
2077 global $CONF, $manager, $maxresults;
\r
2080 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
\r
2086 // use default blog when no blog is selected
\r
2087 $this->formdata = array(
\r
2088 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
\r
2089 'query' => Entity::hsc(getVar('query')),
\r
2091 $this->doForm('searchform');
\r
2096 * Actions::parse_searchresults()
\r
2097 * Parse skinvar searchresults
\r
2099 * @param string $template name of tempalte
\r
2100 * @param integer $maxresults searched items in a display
\r
2103 public function parse_searchresults($template, $maxresults = 50 )
\r
2105 global $blog, $query, $amount, $startpos;
\r
2107 $this->setBlogCategory($blog, ''); // need this to select default category
\r
2108 $this->preBlogContent('searchresults',$blog);
\r
2109 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
\r
2110 $this->postBlogContent('searchresults',$blog);
\r
2115 * Actions::parse_self()
\r
2116 * Parse skinvar self
\r
2121 public function parse_self()
\r
2124 echo $CONF['Self'];
\r
2129 * Actions::parse_sitevar()
\r
2130 * Parse skinvar sitevar
\r
2131 * (include a sitevar)
\r
2133 * @param string $which
\r
2136 public function parse_sitevar($which)
\r
2142 echo $CONF['IndexURL'];
\r
2145 echo $CONF['SiteName'];
\r
2148 echo $CONF['AdminEmail'];
\r
2151 echo $CONF['AdminURL'];
\r
2157 * Actions::parse_skinname()
\r
2163 public function parse_skinname()
\r
2165 echo $this->skin->getName();
\r
2170 * Actions::parse_skintype()
\r
2171 * Parse skintype (experimental)
\r
2176 public function parse_skintype()
\r
2178 echo $this->skintype;
\r
2183 * Actions::parse_ticket()
\r
2189 public function parse_ticket()
\r
2192 $manager->addTicketHidden();
\r
2197 * Actions::parse_todaylink()
\r
2198 * Parse skinvar todaylink
\r
2199 * A link to the today page (depending on selected blog, etc...)
\r
2201 * @param string $linktext text for link
\r
2204 public function parse_todaylink($linktext = '')
\r
2206 global $blog, $CONF;
\r
2209 echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
\r
2213 echo $this->link($CONF['SiteUrl'], $linktext);
\r
2220 * When commentform is not used, to include a hidden field with itemid
\r
2225 public function parse_vars()
\r
2228 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";
\r
2233 * Actions::parse_version()
\r
2234 * Parse skinvar version
\r
2235 * (include nucleus versionnumber)
\r
2240 public function parse_version()
\r
2243 echo 'Nucleus CMS ' . $nucleus['version'];
\r
2248 * Actions::parse_sticky()
\r
2249 * Parse skinvar sticky
\r
2251 * @param integer $itemnumber id of item
\r
2252 * @param string $template name of template
\r
2255 public function parse_sticky($itemnumber = 0, $template = '')
\r
2259 $itemnumber = intval($itemnumber);
\r
2260 $itemarray = array($itemnumber);
\r
2262 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
\r
2263 $this->preBlogContent('sticky',$b);
\r
2264 $this->amountfound = $b->readLogFromList($itemarray, $template);
\r
2265 $this->postBlogContent('sticky',$b);
\r