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 $
\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
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(
\r
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);
\r
229 return array_merge($defined_actions, parent::getDefinedActions());
\r
233 * Actions::getDefaultSkinTypes()
\r
237 * @return array list of friendly names for page actions
\r
239 static public function getDefaultSkinTypes()
\r
241 return self::$default_skin_types;
\r
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();
\r
257 $this->skintype = $type;
\r
261 $this->linkparams = array('catid' => $catid);
\r
267 * Actions::setSkin()
\r
269 * @param object $skin an instance of Skin class
\r
272 public function setSkin(&$skin)
\r
274 $this->skin =& $skin;
\r
279 * Actions::setParser()
\r
282 * @param object $parser an instance of Parser class
\r
285 public function setParser(&$parser)
\r
287 $this->parser =& $parser;
\r
292 * Actions::doForm()
\r
293 * Forms get parsedincluded now, using an extra <formdata> skinvar
\r
295 * @param string $filename
\r
298 public function doForm($filename)
\r
300 global $DIR_NUCLEUS;
\r
301 array_push($this->parser->actions,'formdata', 'callback','errordiv','ticket');
\r
303 $oldIncludeMode = Parser::getProperty('IncludeMode');
\r
304 $oldIncludePrefix = Parser::getProperty('IncludePrefix');
\r
305 Parser::setProperty('IncludeMode','normal');
\r
306 Parser::setProperty('IncludePrefix','');
\r
308 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
\r
309 Parser::setProperty('IncludeMode',$oldIncludeMode);
\r
310 Parser::setProperty('IncludePrefix',$oldIncludePrefix);
\r
312 array_pop($this->parser->actions); // errordiv
\r
313 array_pop($this->parser->actions); // callback
\r
314 array_pop($this->parser->actions); // formdata
\r
315 array_pop($this->parser->actions); // ticket
\r
320 * Actions::checkCondition()
\r
321 * Checks conditions for if statements
\r
323 * @param string $field type of <%if%>
\r
324 * @param string $name property of field
\r
325 * @param string $value value of property
\r
326 * @return boolean condition
\r
328 protected function checkCondition($field, $name='', $value = '')
\r
330 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
\r
336 $condition = ($blog && $this->ifCategory($name,$value));
\r
338 case 'blogsetting':
\r
339 $condition = ($blog && ($blog->getSetting($name) == $value));
\r
342 $condition = $member->isLoggedIn();
\r
345 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
\r
348 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
\r
351 $condition = ($itemidnext != '');
\r
354 $condition = ($itemidprev != '');
\r
356 case 'archiveprevexists':
\r
357 $condition = ($archiveprevexists == true);
\r
359 case 'archivenextexists':
\r
360 $condition = ($archivenextexists == true);
\r
363 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
\r
366 $condition = $this->ifHasPlugin($name, $value);
\r
369 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
\r
376 * Actions::_ifHasPlugin()
\r
377 * hasplugin,PlugName
\r
378 * -> checks if plugin exists
\r
379 * hasplugin,PlugName,OptionName
\r
380 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
\r
381 * hasplugin,PlugName,OptionName=value
\r
382 * -> checks if the option OptionName from plugin PlugName is set to value
\r
384 * @param string $name name of plugin
\r
385 * @param string $value
\r
388 private function ifHasPlugin($name, $value)
\r
391 $condition = false;
\r
392 // (pluginInstalled method won't write a message in the actionlog on failure)
\r
393 if ( $manager->pluginInstalled("NP_{$name}") )
\r
395 $plugin =& $manager->getPlugin("NP_{$name}");
\r
396 if ( $plugin != NULL )
\r
398 if ( $value == "" )
\r
404 list($name2, $value2) = preg_split('#=#', $value, 2);
\r
405 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
\r
409 else if ( $plugin->getOption($name2) == $value2 )
\r
420 * Actions::ifPlugin()
\r
421 * Checks if a plugin exists and call its doIf function
\r
423 * @param string $name name of plugin
\r
424 * @param string $key name of plugin option
\r
425 * @param string $value value of plugin option
\r
428 private function ifPlugin($name, $key = '', $value = '')
\r
432 $plugin =& $manager->getPlugin("NP_{$name}");
\r
438 $params = func_get_args();
\r
439 array_shift($params);
\r
441 return call_user_func_array(array(&$plugin, 'doIf'), $params);
\r
445 * Actions::ifCategory()
\r
446 * Different checks for a category
\r
448 * @param string $name
\r
449 * @param string $value
\r
452 private function ifCategory($name = '', $value='')
\r
454 global $blog, $catid;
\r
456 // when no parameter is defined, just check if a category is selected
\r
457 if ( ($name != 'catname' && $name != 'catid') || ($value == '') )
\r
459 return $blog->isValidCategory($catid);
\r
462 // check category name
\r
463 if ( $name == 'catname' )
\r
465 $value = $blog->getCategoryIdFromName($value);
\r
466 if ( $value == $catid )
\r
468 return $blog->isValidCategory($catid);
\r
472 // check category id
\r
473 if ( ($name == 'catid') && ($value == $catid) )
\r
475 return $blog->isValidCategory($catid);
\r
481 * Actions::ifOnTeam()
\r
482 * Checks if a member is on the team of a blog and return his rights
\r
484 * @param string $blogName name of weblog
\r
487 private function ifOnTeam($blogName = '')
\r
489 global $blog, $member, $manager;
\r
491 // when no blog found
\r
492 if ( ($blogName == '') && !is_object($blog) )
\r
497 // explicit blog selection
\r
498 if ( $blogName != '' )
\r
500 $blogid = getBlogIDFromName($blogName);
\r
503 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
\r
505 // use current blog
\r
506 $blogid = $blog->getID();
\r
509 return $member->teamRights($blogid);
\r
513 * Actions::ifAdmin()
\r
514 * Checks if a member is admin of a blog
\r
516 * @param string $blogName name of weblog
\r
519 private function ifAdmin($blogName = '')
\r
521 global $blog, $member, $manager;
\r
523 // when no blog found
\r
524 if ( ($blogName == '') && (!is_object($blog)) )
\r
529 // explicit blog selection
\r
530 if ( $blogName != '' )
\r
532 $blogid = getBlogIDFromName($blogName);
\r
535 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
\r
537 // use current blog
\r
538 $blogid = $blog->getID();
\r
541 return $member->isBlogAdmin($blogid);
\r
547 * - a raw link (html/xml encoded) when no linktext is provided
\r
548 * - a (x)html <a href... link when a text is present (text htmlencoded)
\r
550 * @param string $url URL for href attribute of anchor element
\r
551 * @param string $linktext content of anchor element
\r
554 private function link($url, $linktext = '')
\r
556 $u = Entity::hsc($url);
\r
557 // fix URLs that already had encoded ampersands
\r
558 $u = preg_replace("#&amp;#", '&', $u);
\r
559 if ( $linktext != '' )
\r
561 $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';
\r
571 * Actions::searchlink()
\r
572 * Outputs a next/prev link
\r
574 * @param $maxresults
\r
575 * The maximum amount of items shown per page (e.g. 10)
\r
577 * Current start position (requestVar('startpos'))
\r
578 * @param $direction
\r
579 * either 'prev' or 'next'
\r
581 * When present, the output will be a full <a href...> link. When empty,
\r
582 * only a raw link will be outputted
\r
584 private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')
\r
586 global $CONF, $blog, $query, $amount;
\r
587 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
\r
588 $startpos = (integer) $startpos;
\r
589 $parsed = parse_url(serverVar('REQUEST_URI'));
\r
590 $path = $parsed['path'];
\r
591 $parsed = $parsed['query'];
\r
594 if ( $direction == 'prev' )
\r
596 if ( intval($startpos) - intval($maxresults) >= 0 )
\r
598 $startpos = intval($startpos) - intval($maxresults);
\r
600 if ( $this->skintype == 'index' )
\r
604 else if ( $this->skintype == 'search' )
\r
606 $url = $CONF['SearchURL'];
\r
608 $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);
\r
611 else if ( $direction == 'next' )
\r
613 global $navigationItems;
\r
614 if ( !isset($navigationItems) )
\r
616 $navigationItems = 0;
\r
621 $iAmountOnPage = 0;
\r
625 $iAmountOnPage = $this->amountfound;
\r
628 if ( intval($navigationItems) > 0 )
\r
630 $iAmountOnPage = intval($navigationItems) - intval($startpos);
\r
632 elseif ( $iAmountOnPage == 0 )
\r
635 * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
\r
636 * try a count query
\r
638 if ( $this->skintype == 'index' )
\r
640 $sqlquery = $blog->getSqlBlog('', 'count');
\r
643 else if ( $this->skintype == 'search' )
\r
645 $unused_highlight = '';
\r
646 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
\r
647 $url = $CONF['SearchURL'];
\r
651 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
\r
656 if ( intval($iAmountOnPage) >= intval($maxresults) )
\r
658 $startpos = intval($startpos) + intval($maxresults);
\r
659 $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos);
\r
665 echo $this->link($url, $linktext);
\r
671 * Actions::itemlink()
\r
672 * Creates an item link and if no id is given a todaylink
\r
674 * @param integer $id id for link
\r
675 * @param string $linktext text for link
\r
678 private function itemlink($id, $linktext = '')
\r
683 echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);
\r
687 $this->parse_todaylink($linktext);
\r
693 * Actions::archivelink)
\r
694 * Creates an archive link and if no id is given a todaylink
\r
696 * @param integer $id id for link
\r
697 * @param string $linktext text for link
\r
700 private function archivelink($id, $linktext = '')
\r
702 global $CONF, $blog;
\r
705 echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);
\r
709 $this->parse_todaylink($linktext);
\r
715 * Actions:setBlogCategory()
\r
716 * Helper function that sets the category that a blog will need to use
\r
718 * @param string $blog An object of the blog class, passed by reference (we want to make changes to it)
\r
719 * @param string $catname The name of the category to use
\r
722 private function setBlogCategory(&$blog, $catname)
\r
725 if ( $catname != '' )
\r
727 $blog->setSelectedCategoryByName($catname);
\r
731 $blog->setSelectedCategory($catid);
\r
737 * Actions::preBlogContent()
\r
738 * Notifies the Manager that a PreBlogContent event occurs
\r
740 * @param string $type type of skin
\r
741 * @param object $blog an instance of Blog class
\r
744 private function preBlogContent($type, &$blog)
\r
747 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
\r
752 * Actions::postBlogContent()
\r
753 * Notifies the Manager that a PostBlogContent event occurs
\r
755 * @param string $type type of skin
\r
756 * @param objecct $blog an instance of Blog class
\r
759 private function postBlogContent($type, &$blog)
\r
762 $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));
\r
767 * Actions::parse_additemform()
\r
768 * Parse skinvar additemform
\r
773 public function parse_additemform()
\r
775 global $blog, $CONF;
\r
776 $this->formdata = array(
\r
777 'adminurl' => Entity::hsc($CONF['AdminURL']),
\r
778 'catid' => $blog->getDefaultCategory()
\r
780 $blog->InsertJavaScriptInfo();
\r
781 $this->doForm('additemform');
\r
786 * Actions::parse_addlink()
\r
787 * Parse skinvar addlink
\r
788 * A Link that allows to open a bookmarklet to add an item
\r
790 public function parse_addlink()
\r
792 global $CONF, $member, $blog;
\r
793 if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )
\r
795 echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;
\r
801 * Actions::parse_addpopupcode()
\r
802 * Parse skinvar addpopupcode
\r
803 * Code that opens a bookmarklet in an popup window
\r
808 public function parse_addpopupcode()
\r
810 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
815 * Parse skinvar adminurl
\r
816 * (shortcut for admin url)
\r
821 public function parse_adminurl()
\r
823 $this->parse_sitevar('adminurl');
\r
828 * Actions::parse_archive()
\r
829 * Parse skinvar archive
\r
831 * @param string $template name of template
\r
832 * @param string $category name of category
\r
835 public function parse_archive($template, $category = '')
\r
837 global $blog, $archive;
\r
838 // can be used with either yyyy-mm or yyyy-mm-dd
\r
839 sscanf($archive,'%d-%d-%d', $y, $m, $d);
\r
840 $this->setBlogCategory($blog, $category);
\r
841 $this->preBlogContent('achive',$blog);
\r
842 $blog->showArchive($template, $y, $m, $d);
\r
843 $this->postBlogContent('achive',$blog);
\r
848 * Actions::parse_archivedate()
\r
849 * %archivedate(locale,date format)%
\r
851 * @param string $locale
\r
854 public function parse_archivedate($locale = '-def-')
\r
859 * TODO: these lines are no meaning because there is no $template.
\r
860 if ( $locale == '-def-' )
\r
862 setlocale(LC_TIME, $template['LOCALE']);
\r
866 setlocale(LC_TIME, $locale);
\r
870 // get archive date
\r
871 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
874 $args = func_get_args();
\r
875 // format can be spread over multiple parameters
\r
876 if ( sizeof($args) > 1 )
\r
878 // take away locale
\r
879 array_shift($args);
\r
881 $format=implode(',',$args);
\r
883 elseif ( $d == 0 && $m !=0 )
\r
893 $format = '%d %B %Y';
\r
895 echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
\r
900 * Actions::parse_archivedaylist()
\r
901 * Parse skinvar archivedaylist
\r
903 * @param string $template name of template
\r
904 * @param string $category name of category
\r
905 * @param integer $limit the number of items in a display
\r
908 public function parse_archivedaylist($template, $category = 'all', $limit = 0)
\r
911 if ( $category == 'all' )
\r
915 $this->preBlogContent('archivelist',$blog);
\r
916 $this->setBlogCategory($blog, $category);
\r
917 $blog->showArchiveList($template, 'day', $limit);
\r
918 $this->postBlogContent('archivelist',$blog);
\r
923 * Actions::parse_archivelink()
\r
924 * A link to the archives for the current blog (or for default blog)
\r
926 * @param string $linktext text for link
\r
929 public function parse_archivelink($linktext = '')
\r
931 global $blog, $CONF;
\r
934 echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);
\r
938 echo $this->link(Link::create_archivelist_link(), $linktext);
\r
944 * Actions::parse_archivelist()
\r
946 * @param string $template name of template
\r
947 * @param string $category name of category
\r
948 * @param integer $limit the number of items in a display
\r
951 public function parse_archivelist($template, $category = 'all', $limit = 0)
\r
954 if ( $category == 'all' )
\r
958 $this->preBlogContent('archivelist',$blog);
\r
959 $this->setBlogCategory($blog, $category);
\r
960 $blog->showArchiveList($template, 'month', $limit);
\r
961 $this->postBlogContent('archivelist',$blog);
\r
966 * Actions::parse_archiveyearlist()
\r
968 * @param string $template name of template
\r
969 * @param string $category name of category
\r
970 * @param integer $limit the number of items in a display
\r
972 public function parse_archiveyearlist($template, $category = 'all', $limit = 0)
\r
975 if ( $category == 'all' )
\r
979 $this->preBlogContent('archivelist',$blog);
\r
980 $this->setBlogCategory($blog, $category);
\r
981 $blog->showArchiveList($template, 'year', $limit);
\r
982 $this->postBlogContent('archivelist',$blog);
\r
987 * Actions::parse_archivetype()
\r
988 * Parse skinvar archivetype
\r
993 public function parse_archivetype()
\r
995 global $archivetype;
\r
1001 * Actions::parse_blog()
\r
1002 * Parse skinvar blog
\r
1004 * @param string $template name of template
\r
1005 * @param mixed $amount the number of items in a display, in case it includes the beginning
\r
1006 * @param string $category name of category
\r
1009 public function parse_blog($template, $amount = 10, $category = '')
\r
1011 global $blog, $startpos;
\r
1013 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
1014 $this->setBlogCategory($blog, $category);
\r
1015 $this->preBlogContent('blog',$blog);
\r
1016 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
\r
1017 $this->postBlogContent('blog',$blog);
\r
1022 * Actions::parse_bloglist()
\r
1023 * Parse skinvar bloglist
\r
1024 * Shows a list of all blogs
\r
1026 * @param string $template name of template
\r
1027 * @param string $bnametype whether 'name' or 'shortname' is used for the link text
\r
1028 * @param string $orderby order criteria
\r
1029 * @param string $direction order ascending or descending
\r
1032 public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')
\r
1034 Blog::showBlogList($template, $bnametype, $orderby, $direction);
\r
1039 * Actions::parse_blogsetting()
\r
1040 * Parse skinvar blogsetting
\r
1042 * @param string $which key of weblog settings
\r
1045 public function parse_blogsetting($which)
\r
1051 echo Entity::hsc($blog->getID());
\r
1054 echo Entity::hsc($blog->getURL());
\r
1057 echo Entity::hsc($blog->getName());
\r
1060 echo Entity::hsc($blog->getDescription());
\r
1063 echo Entity::hsc($blog->getShortName());
\r
1070 * Actions::parse_callback()
\r
1073 * @param string $eventName name of event
\r
1074 * @param string $type type of skin
\r
1077 public function parse_callback($eventName, $type)
\r
1080 $manager->notify($eventName, array('type' => $type));
\r
1085 * Actions::parse_category()
\r
1086 * Parse skinvar category
\r
1088 * @param string $type key of category settings
\r
1091 public function parse_category($type = 'name')
\r
1093 global $catid, $blog;
\r
1094 if ( !$blog->isValidCategory($catid) )
\r
1102 echo $blog->getCategoryName($catid);
\r
1105 echo $blog->getCategoryDesc($catid);
\r
1115 * Actions::parse_categorylist()
\r
1116 * Parse categorylist
\r
1118 * @param string $template name of template
\r
1119 * @param string $blogname name of weblog
\r
1122 public function parse_categorylist($template, $blogname = '')
\r
1124 global $blog, $manager;
\r
1126 // when no blog found
\r
1127 if ( ($blogname == '') && (!is_object($blog)) )
\r
1132 if ( $blogname == '' )
\r
1134 $this->preBlogContent('categorylist',$blog);
\r
1135 $blog->showCategoryList($template);
\r
1136 $this->postBlogContent('categorylist',$blog);
\r
1140 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1141 $this->preBlogContent('categorylist',$b);
\r
1142 $b->showCategoryList($template);
\r
1143 $this->postBlogContent('categorylist',$b);
\r
1149 * Actions::parse_charset()
\r
1150 * Parse skinvar charset
\r
1155 public function parse_charset()
\r
1157 echo i18n::get_current_charset();
\r
1162 * Actions::parse_commentform()
\r
1163 * Parse skinvar commentform
\r
1165 * @param string $destinationurl URI for redirection
\r
1168 public function parse_commentform($destinationurl = '')
\r
1170 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
\r
1172 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
\r
1173 if ( stristr($destinationurl, 'action.php') )
\r
1175 $args = func_get_args();
\r
1176 $destinationurl = $args[1];
\r
1177 ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);
\r
1180 $actionurl = $CONF['ActionURL'];
\r
1182 // if item is closed, show message and do nothing
\r
1183 $item =& $manager->getItem($itemid,0,0);
\r
1184 if ( $item['closed'] || !$blog->commentsEnabled() )
\r
1186 $this->doForm('commentform-closed');
\r
1190 if ( !$blog->isPublic() && !$member->isLoggedIn() )
\r
1192 $this->doForm('commentform-closedtopublic');
\r
1196 if ( !$destinationurl )
\r
1198 // note: createLink returns an HTML encoded URL
\r
1199 $destinationurl = Link::create_link(
\r
1202 'itemid' => $itemid,
\r
1203 'title' => $item['title'],
\r
1204 'timestamp' => $item['timestamp'],
\r
1205 'extra' => $this->linkparams
\r
1211 // HTML encode URL
\r
1212 $destinationurl = Entity::hsc($destinationurl);
\r
1215 // values to prefill
\r
1216 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
\r
1219 $user = postVar('user');
\r
1222 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
\r
1225 $userid = postVar('userid');
\r
1228 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
\r
1231 $email = postVar('email');
\r
1234 $body = postVar('body');
\r
1236 $this->formdata = array(
\r
1237 'destinationurl' => $destinationurl, // url is already HTML encoded
\r
1238 'actionurl' => Entity::hsc($actionurl),
\r
1239 'itemid' => $itemid,
\r
1240 'user' => Entity::hsc($user),
\r
1241 'userid' => Entity::hsc($userid),
\r
1242 'email' => Entity::hsc($email),
\r
1243 'body' => Entity::hsc($body),
\r
1244 'membername' => $member->getDisplayName(),
\r
1245 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
\r
1248 if ( !$member->isLoggedIn() )
\r
1250 $this->doForm('commentform-notloggedin');
\r
1254 $this->doForm('commentform-loggedin');
\r
1260 * Actions::parse_comments()
\r
1261 * Parse skinvar comments
\r
1262 * include comments for one item
\r
1264 * @param string $template name of template
\r
1267 public function parse_comments($template)
\r
1269 global $itemid, $manager, $blog, $highlight;
\r
1270 $template =& $manager->getTemplate($template);
\r
1272 // create parser object & action handler
\r
1273 $handler = new ItemActions($blog);
\r
1274 $parser = new Parser($handler->getDefinedActions(),$handler);
\r
1275 $handler->setTemplate($template);
\r
1276 $handler->setParser($parser);
\r
1277 $item = Item::getitem($itemid, 0, 0);
\r
1278 $handler->setCurrentItem($item);
\r
1280 $comments = new Comments($itemid);
\r
1281 $comments->setItemActions($handler);
\r
1282 // shows ALL comments
\r
1283 $comments->showComments($template, -1, 1, $highlight);
\r
1288 * Actions::parse_errordiv()
\r
1294 public function parse_errordiv()
\r
1296 global $errormessage;
\r
1297 if ( $errormessage )
\r
1299 echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";
\r
1305 * Actions::parse_errormessage()
\r
1306 * Parse skinvar errormessage
\r
1311 public function parse_errormessage()
\r
1313 global $errormessage;
\r
1314 echo $errormessage;
\r
1319 * Actions::parse_formdata()
\r
1322 * @param string $what key of format data
\r
1325 public function parse_formdata($what)
\r
1327 echo $this->formdata[$what];
\r
1332 * Actions::parse_ifcat()
\r
1335 * @param string $text
\r
1338 public function parse_ifcat($text = '')
\r
1340 if ( $text == '' )
\r
1343 $this->parse_if('category');
\r
1348 global $catid, $blog;
\r
1349 if ( $blog->isValidCategory($catid) )
\r
1358 * Actions::parse_image()
\r
1359 * Parse skinvar image
\r
1361 * @param string $what name of tag
\r
1364 public function parse_image($what = 'imgtag')
\r
1368 $imagetext = Entity::hsc(requestVar('imagetext'));
\r
1369 $imagepopup = requestVar('imagepopup');
\r
1370 $width = intRequestVar('width');
\r
1371 $height = intRequestVar('height');
\r
1372 $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup);
\r
1391 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";
\r
1398 * Actions::parse_imagetext()
\r
1399 * Parse skinvar imagetext
\r
1404 public function parse_imagetext()
\r
1406 $this->parse_image('imagetext');
\r
1411 * Actions::parse_item()
\r
1412 * Parse skinvar item
\r
1413 * include one item (no comments)
\r
1418 public function parse_item($template)
\r
1420 global $blog, $itemid, $highlight;
\r
1422 // need this to select default category
\r
1423 $this->setBlogCategory($blog, '');
\r
1424 $this->preBlogContent('item',$blog);
\r
1425 $r = $blog->showOneitem($itemid, $template, $highlight);
\r
1428 echo _ERROR_NOSUCHITEM;
\r
1430 $this->postBlogContent('item',$blog);
\r
1435 * Actions::parse_itemid()
\r
1436 * Parse skinvar itemid
\r
1441 public function parse_itemid()
\r
1449 * Actions::parseitemlink()
\r
1450 * Parse skinvar itemlink
\r
1455 public function parse_itemlink($linktext = '')
\r
1458 $this->itemlink($itemid, $linktext);
\r
1463 * Actions::parse_itemtitle()
\r
1469 public function parse_itemtitle($format = '')
\r
1471 global $manager, $itemid;
\r
1472 $item =& $manager->getItem($itemid,0,0);
\r
1474 switch ( $format )
\r
1477 echo Entity::hen($item['title']);
\r
1480 echo $item['title'];
\r
1484 echo Entity::hsc(strip_tags($item['title']));
\r
1491 * Actions::parse_loginform()
\r
1492 * Parse skinvar loginform
\r
1497 public function parse_loginform()
\r
1499 global $member, $CONF;
\r
1500 if ( !$member->isLoggedIn() )
\r
1502 $filename = 'loginform-notloggedin';
\r
1503 $this->formdata = array();
\r
1507 $filename = 'loginform-loggedin';
\r
1508 $this->formdata = array(
\r
1509 'membername' => $member->getDisplayName(),
\r
1512 $this->doForm($filename);
\r
1517 * Actions::parse_member()
\r
1518 * Parse skinvar member
\r
1519 * (includes a member info thingie)
\r
1521 * @param string $what which memberdata is needed
\r
1524 public function parse_member($what)
\r
1526 global $memberinfo, $member, $CONF;
\r
1528 // 1. only allow the member-details-page specific variables on member pages
\r
1529 if ( $this->skintype == 'member' )
\r
1534 echo Entity::hsc($memberinfo->getDisplayName());
\r
1537 echo Entity::hsc($memberinfo->getRealName());
\r
1540 echo Entity::hsc($memberinfo->getNotes());
\r
1543 echo Entity::hsc($memberinfo->getURL());
\r
1546 echo Entity::hsc($memberinfo->getEmail());
\r
1549 echo Entity::hsc($memberinfo->getID());
\r
1554 // 2. the next bunch of options is available everywhere, as long as the user is logged in
\r
1555 if ( $member->isLoggedIn() )
\r
1560 echo $member->getDisplayName();
\r
1562 case 'yourrealname':
\r
1563 echo $member->getRealName();
\r
1566 echo $member->getNotes();
\r
1569 echo $member->getURL();
\r
1572 echo $member->getEmail();
\r
1575 echo $member->getID();
\r
1577 case 'yourprofileurl':
\r
1578 if ($CONF['URLMode'] == 'pathinfo')
\r
1579 echo Link::create_member_link($member->getID());
\r
1581 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
\r
1589 * Link::parse_membermailform()
\r
1590 * Parse skinvar membermailform
\r
1592 * @param integer $rows the height for textarea
\r
1593 * @param integer $cols the width for textarea
\r
1594 * @param string $desturl URI to redirect
\r
1597 public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')
\r
1599 global $member, $CONF, $memberid;
\r
1601 if ( $desturl == '' )
\r
1603 if ( $CONF['URLMode'] == 'pathinfo' )
\r
1605 $desturl = Link::create_member_link($memberid);
\r
1609 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);
\r
1613 $message = postVar('message');
\r
1614 $frommail = postVar('frommail');
\r
1616 $this->formdata = array(
\r
1617 'url' => Entity::hsc($desturl),
\r
1618 'actionurl' => Entity::hsc($CONF['ActionURL']),
\r
1619 'memberid' => $memberid,
\r
1622 'message' => Entity::hsc($message),
\r
1623 'frommail' => Entity::hsc($frommail)
\r
1626 if ( $member->isLoggedIn() )
\r
1628 $this->doForm('membermailform-loggedin');
\r
1630 else if ( $CONF['NonmemberMail'] )
\r
1632 $this->doForm('membermailform-notloggedin');
\r
1636 $this->doForm('membermailform-disallowed');
\r
1642 * Actions::parse_nextarchive()
\r
1643 * Parse skinvar nextarchive
\r
1648 public function parse_nextarchive()
\r
1650 global $archivenext;
\r
1651 echo $archivenext;
\r
1656 * Parse skinvar nextitem
\r
1657 * (include itemid of next item)
\r
1662 public function parse_nextitem()
\r
1664 global $itemidnext;
\r
1665 if ( isset($itemidnext) )
\r
1667 echo (int)$itemidnext;
\r
1673 * Actions::parse_nextitemtitle()
\r
1674 * Parse skinvar nextitemtitle
\r
1675 * (include itemtitle of next item)
\r
1677 * @param string $format format of text
\r
1680 public function parse_nextitemtitle($format = '')
\r
1682 global $itemtitlenext;
\r
1684 switch ( $format )
\r
1687 echo Entity::hen($itemtitlenext);
\r
1690 echo $itemtitlenext;
\r
1694 echo Entity::hsc($itemtitlenext);
\r
1701 * Actions::parse_nextlink()
\r
1702 * Parse skinvar nextlink
\r
1704 * @param string $linktext text for content of anchor element
\r
1705 * @param integer $amount the amount of items in a display
\r
1706 * @param integer $recount increment from this value
\r
1709 public function parse_nextlink($linktext = '', $amount = 10, $recount = '')
\r
1711 global $itemidnext, $archivenext, $startpos;
\r
1712 if ( $this->skintype == 'item' )
\r
1714 $this->itemlink($itemidnext, $linktext);
\r
1716 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
\r
1718 $this->searchlink($amount, $startpos, 'next', $linktext, $recount);
\r
1722 $this->archivelink($archivenext, $linktext);
\r
1728 * Actions::parse_nucleusbutton()
\r
1729 * Parse skinvar nucleusbutton
\r
1731 * @param string $imgurl URL for image
\r
1732 * @param integer $imgwidth width of image
\r
1733 * @param integer $imgheidht height of image
\r
1735 public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')
\r
1738 if ( $imgurl == '' )
\r
1740 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
\r
1742 else if ( Parser::getProperty('IncludeMode') == 'skindir' )
\r
1744 // when skindit IncludeMode is used: start from skindir
\r
1745 $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;
\r
1748 $this->formdata = array(
\r
1749 'imgurl' => $imgurl,
\r
1750 'imgwidth' => $imgwidth,
\r
1751 'imgheight' => $imgheight,
\r
1753 $this->doForm('nucleusbutton');
\r
1758 * Actions::parse_otherarchive()
\r
1759 * Parse skinvar otherarchive
\r
1761 * @param string $blogname name of weblog
\r
1762 * @param string $template name of template
\r
1763 * @param string $category name of category
\r
1766 public function parse_otherarchive($blogname, $template, $category = '')
\r
1768 global $archive, $manager;
\r
1769 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\r
1770 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1771 $this->setBlogCategory($b, $category);
\r
1772 $this->preBlogContent('otherachive',$b);
\r
1773 $b->showArchive($template, $y, $m, $d);
\r
1774 $this->postBlogContent('otherachive',$b);
\r
1779 * Actions::parse_otherarchivedaylist()
\r
1780 * Parse skinvar otherarchivedaylist
\r
1782 * @param string $blogname name of weblog
\r
1783 * @param string $template name of template
\r
1784 * @param string $category name of category
\r
1785 * @param integer $limit the amount of items in a display
\r
1788 public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)
\r
1791 if ( $category == 'all')
\r
1795 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1796 $this->setBlogCategory($b, $category);
\r
1797 $this->preBlogContent('otherarchivelist',$b);
\r
1798 $b->showArchiveList($template, 'day', $limit);
\r
1799 $this->postBlogContent('otherarchivelist',$b);
\r
1804 * Actions::parse_otherarchivelist()
\r
1805 * Parse skinvar otherarchivelist
\r
1807 * @param string $blogname name of weblog
\r
1808 * @param string $template name of template
\r
1809 * @param string $category name of category
\r
1810 * @param integer $limit the amount of items in a display
\r
1813 public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)
\r
1816 if ( $category == 'all' )
\r
1820 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1821 $this->setBlogCategory($b, $category);
\r
1822 $this->preBlogContent('otherarchivelist',$b);
\r
1823 $b->showArchiveList($template, 'month', $limit);
\r
1824 $this->postBlogContent('otherarchivelist',$b);
\r
1829 * Actions::parse_otherarchiveyearlist()
\r
1830 * Parse skinvar otherarchiveyearlist
\r
1832 * @param string $blogname name of weblog
\r
1833 * @param string $template name of template
\r
1834 * @param string $category name of category
\r
1835 * @limit integer $limit the amount of items in a display
\r
1837 public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)
\r
1840 if ( $category == 'all' )
\r
1844 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1845 $this->setBlogCategory($b, $category);
\r
1846 $this->preBlogContent('otherarchivelist',$b);
\r
1847 $b->showArchiveList($template, 'year', $limit);
\r
1848 $this->postBlogContent('otherarchivelist',$b);
\r
1853 * Actions::parse_otherblog()
\r
1854 * Parse skinvar otherblog
\r
1856 * @param string $blogname name of weblog
\r
1857 * @param string $template name of template
\r
1858 * @param mixed $amount the amount of items, in case it includes the beginning
\r
1859 * @param string $category name of category
\r
1862 public function parse_otherblog($blogname, $template, $amount = 10, $category = '')
\r
1866 list($limit, $offset) = sscanf($amount, '%d(%d)');
\r
1868 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1869 $this->setBlogCategory($b, $category);
\r
1870 $this->preBlogContent('otherblog',$b);
\r
1871 $this->amountfound = $b->readLog($template, $limit, $offset);
\r
1872 $this->postBlogContent('otherblog',$b);
\r
1877 * Actions::parse_othersearchresults()
\r
1878 * Parse skinvar othersearchresults
\r
1880 * @param string $blogname name of weblog
\r
1881 * @param string $template name of template
\r
1882 * @param integer $maxresults the amount of results
\r
1885 public function parse_othersearchresults($blogname, $template, $maxresults = 50)
\r
1887 global $query, $amount, $manager, $startpos;
\r
1888 $b =& $manager->getBlog(getBlogIDFromName($blogname));
\r
1889 // need this to select default category
\r
1890 $this->setBlogCategory($b, '');
\r
1891 $this->preBlogContent('othersearchresults',$b);
\r
1892 $b->search($query, $template, $amount, $maxresults, $startpos);
\r
1893 $this->postBlogContent('othersearchresults',$b);
\r
1898 * Actions::parse_plugin()
\r
1899 * Executes a plugin skinvar
\r
1900 * extra parameters can be added
\r
1902 * @param string $pluginName name of plugin (without the NP_)
\r
1905 public function parse_plugin($pluginName)
\r
1909 $plugin =& $manager->getPlugin('NP_' . $pluginName);
\r
1916 $params = func_get_args();
\r
1918 // remove plugin name
\r
1919 array_shift($params);
\r
1921 // add skin type on front
\r
1922 array_unshift($params, $this->skintype);
\r
1924 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
\r
1929 * Actions::parse_prevarchive()
\r
1930 * Parse skinvar prevarchive
\r
1935 public function parse_prevarchive()
\r
1937 global $archiveprev;
\r
1938 echo $archiveprev;
\r
1942 * Actions::parse_preview()
\r
1943 * Parse skinvar preview
\r
1945 * @param string $template name of tempalte
\r
1948 public function parse_preview($template)
\r
1950 global $blog, $CONF, $manager;
\r
1952 $template =& $manager->getTemplate($template);
\r
1954 $row['body'] = '<span id="prevbody"></span>';
\r
1955 $row['title'] = '<span id="prevtitle"></span>';
\r
1956 $row['more'] = '<span id="prevmore"></span>';
\r
1957 $row['itemlink'] = '';
\r
1958 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
\r
1960 echo Template::fill($template['ITEM_HEADER'],$row);
\r
1961 echo Template::fill($template['ITEM'],$row);
\r
1962 echo Template::fill($template['ITEM_FOOTER'],$row);
\r
1967 * Actions::parse_previtem()
\r
1968 * Parse skinvar previtem
\r
1969 * (include itemid of prev item)
\r
1974 public function parse_previtem()
\r
1976 global $itemidprev;
\r
1977 if ( isset($itemidprev) )
\r
1979 echo (integer) $itemidprev;
\r
1985 * Actions::parse_previtemtitle()
\r
1986 * Parse skinvar previtemtitle
\r
1987 * (include itemtitle of prev item)
\r
1989 * @param String $format string format
\r
1990 * @return String formatted string
\r
1992 public function parse_previtemtitle($format = '')
\r
1994 global $itemtitleprev;
\r
1996 switch ( $format )
\r
1999 echo Entity::hen($itemtitleprev);
\r
2002 echo $itemtitleprev;
\r
2006 echo Entity::hsc($itemtitleprev);
\r
2013 * Actions::parse_prevlink()
\r
2014 * Parse skinvar prevlink
\r
2016 * @param string $linktext text as a content of anchor element
\r
2017 * @param integer the amount of links
\r
2020 public function parse_prevlink($linktext = '', $amount = 10)
\r
2022 global $itemidprev, $archiveprev, $startpos;
\r
2024 if ( $this->skintype == 'item' )
\r
2026 $this->itemlink($itemidprev, $linktext);
\r
2028 else if ( $this->skintype == 'search' || $this->skintype == 'index' )
\r
2030 $this->searchlink($amount, $startpos, 'prev', $linktext);
\r
2034 $this->archivelink($archiveprev, $linktext);
\r
2040 * Actions::parse_query()
\r
2041 * Parse skinvar query
\r
2042 * (includes the search query)
\r
2047 public function parse_query()
\r
2050 echo Entity::hsc($query);
\r
2055 * Actions::parse_referer()
\r
2056 * Parse skinvar referer
\r
2061 public function parse_referer()
\r
2063 echo Entity::hsc(serverVar('HTTP_REFERER'));
\r
2068 * Actions::parse_searchform()
\r
2069 * Parse skinvar searchform
\r
2071 * @param string $blogname name of weblog
\r
2074 public function parse_searchform($blogname = '')
\r
2076 global $CONF, $manager, $maxresults;
\r
2079 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
\r
2085 // use default blog when no blog is selected
\r
2086 $this->formdata = array(
\r
2087 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
\r
2088 'query' => Entity::hsc(getVar('query')),
\r
2090 $this->doForm('searchform');
\r
2095 * Actions::parse_searchresults()
\r
2096 * Parse skinvar searchresults
\r
2098 * @param string $template name of tempalte
\r
2099 * @param integer $maxresults searched items in a display
\r
2102 public function parse_searchresults($template, $maxresults = 50 )
\r
2104 global $blog, $query, $amount, $startpos;
\r
2106 $this->setBlogCategory($blog, ''); // need this to select default category
\r
2107 $this->preBlogContent('searchresults',$blog);
\r
2108 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
\r
2109 $this->postBlogContent('searchresults',$blog);
\r
2114 * Actions::parse_self()
\r
2115 * Parse skinvar self
\r
2120 public function parse_self()
\r
2123 echo $CONF['Self'];
\r
2128 * Actions::parse_sitevar()
\r
2129 * Parse skinvar sitevar
\r
2130 * (include a sitevar)
\r
2132 * @param string $which
\r
2135 public function parse_sitevar($which)
\r
2141 echo $CONF['IndexURL'];
\r
2144 echo $CONF['SiteName'];
\r
2147 echo $CONF['AdminEmail'];
\r
2150 echo $CONF['AdminURL'];
\r
2156 * Actions::parse_skinname()
\r
2162 public function parse_skinname()
\r
2164 echo $this->skin->getName();
\r
2169 * Actions::parse_skintype()
\r
2170 * Parse skintype (experimental)
\r
2175 public function parse_skintype()
\r
2177 echo $this->skintype;
\r
2182 * Actions::parse_ticket()
\r
2188 public function parse_ticket()
\r
2191 $manager->addTicketHidden();
\r
2196 * Actions::parse_todaylink()
\r
2197 * Parse skinvar todaylink
\r
2198 * A link to the today page (depending on selected blog, etc...)
\r
2200 * @param string $linktext text for link
\r
2203 public function parse_todaylink($linktext = '')
\r
2205 global $blog, $CONF;
\r
2208 echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);
\r
2212 echo $this->link($CONF['SiteUrl'], $linktext);
\r
2219 * When commentform is not used, to include a hidden field with itemid
\r
2224 public function parse_vars()
\r
2227 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";
\r
2232 * Actions::parse_version()
\r
2233 * Parse skinvar version
\r
2234 * (include nucleus versionnumber)
\r
2239 public function parse_version()
\r
2242 echo 'Nucleus CMS ' . $nucleus['version'];
\r
2247 * Actions::parse_sticky()
\r
2248 * Parse skinvar sticky
\r
2250 * @param integer $itemnumber id of item
\r
2251 * @param string $template name of template
\r
2254 public function parse_sticky($itemnumber = 0, $template = '')
\r
2258 $itemnumber = intval($itemnumber);
\r
2259 $itemarray = array($itemnumber);
\r
2261 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
\r
2262 $this->preBlogContent('sticky',$b);
\r
2263 $this->amountfound = $b->readLogFromList($itemarray, $template);
\r
2264 $this->postBlogContent('sticky',$b);
\r