OSDN Git Service

Merge remote branch 'nucleus-next/master' into skinnable-master
[nucleus-jp/nucleus-next.git] / nucleus / libs / ACTIONS.php
1 <?php\r
2 /**\r
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
4  * Copyright (C) 2002-2012 The Nucleus Group\r
5  *\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
11  */\r
12 /**\r
13  * This class contains the functions that get called by using\r
14  * the special tags in the skins\r
15  *\r
16  * The allowed tags for a type of skinpart are defined by the\r
17  * Skin::getAllowedActionsForType($type) method\r
18  *\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
22  */\r
23 \r
24 class Actions extends BaseActions\r
25 {\r
26         // part of the skin currently being parsed ('index', 'item', 'archive',\r
27         // 'archivelist', 'member', 'search', 'error', 'imagepopup')\r
28         var $skintype;\r
29         \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         var $linkparams;\r
33         \r
34         // reference to the skin object for which a part is being parsed\r
35         var $skin;\r
36         \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
39         var $formdata;\r
40         \r
41         // filled out with the number of displayed items after calling one of the\r
42         // (other)blog/(other)searchresults skinvars.\r
43         var $amountfound;\r
44         \r
45         /**\r
46          * AdminActions::$page_action_names\r
47          * list of whole action names with which this class can deal\r
48          */\r
49         static private $page_action_names = array(\r
50                 'otherblog',\r
51                 'plugin',\r
52                 'version',\r
53                 'nucleusbutton',\r
54                 'include',\r
55                 'phpinclude',\r
56                 'parsedinclude',\r
57                 'loginform',\r
58                 'sitevar',\r
59                 'otherarchivelist',\r
60                 'otherarchivedaylist',\r
61                 'otherarchiveyearlist',\r
62                 'self',\r
63                 'adminurl',\r
64                 'todaylink',\r
65                 'archivelink',\r
66                 'member',\r
67                 'category',\r
68                 'searchform',\r
69                 'referer',\r
70                 'skinname',\r
71                 'skinfile',\r
72                 'set',\r
73                 'if',\r
74                 'else',\r
75                 'endif',\r
76                 'elseif',\r
77                 'ifnot',\r
78                 'elseifnot',\r
79                 'charset',\r
80                 'bloglist',\r
81                 'addlink',\r
82                 'addpopupcode',\r
83                 'sticky',\r
84                 // deprecated (Nucleus v2.0)\r
85                 /* TODO: remove this */\r
86                 'ifcat'\r
87         );\r
88         \r
89         /**\r
90          * Actions::$page_type_friendly_names\r
91          * friendly name for wrapped page types\r
92          */\r
93         static public $page_type_friendly_names = array(\r
94                 'index'                 => _SKIN_PART_MAIN,\r
95                 'item'                  => _SKIN_PART_ITEM,\r
96                 'archivelist'   => _SKIN_PART_ALIST,\r
97                 'archive'               => _SKIN_PART_ARCHIVE,\r
98                 'search'                => _SKIN_PART_SEARCH,\r
99                 'error'                 => _SKIN_PART_ERROR,\r
100                 'member'                => _SKIN_PART_MEMBER,\r
101                 'imagepopup'    => _SKIN_PART_POPUP\r
102         );\r
103         \r
104         /**\r
105          * Actions::get_allowed_actions_for_type()\r
106          * \r
107          * @static\r
108          * @param       string  $type   page type\r
109          * @return      array   allowed actions for the page type\r
110          */\r
111         static public function get_allowed_actions_for_type($type)\r
112         {\r
113                 $default_actions = array(\r
114                         'addlink',\r
115                         'addpopupcode',\r
116                         'adminurl',\r
117                         'archivelink',\r
118                         'bloglist',\r
119                         'category',\r
120                         'charset',\r
121                         'else',\r
122                         'elseif',\r
123                         'elseifnot',\r
124                         'endif',\r
125                         'if',\r
126                         'ifnot',\r
127                         'include',\r
128                         'loginform',\r
129                         'member',\r
130                         'nucleusbutton',\r
131                         'otherarchivedaylist',\r
132                         'otherarchivelist',\r
133                         'otherarchiveyearlist',\r
134                         'otherblog',\r
135                         'parsedinclude',\r
136                         'phpinclude',\r
137                         'plugin',\r
138                         'referer',\r
139                         'searchform',\r
140                         'self',\r
141                         'set',\r
142                         'sitevar',\r
143                         'skinfile',\r
144                         'skinname',\r
145                         'sticky',\r
146                         'todaylink',\r
147                         'version',\r
148                         // deprecated (Nucleus v2.0)\r
149                         'ifcat'\r
150                 );\r
151                 \r
152                 // extra actions specific for a certain skin type\r
153                 $extra_actions = array();\r
154                 \r
155                 switch ( $type )\r
156                 {\r
157                         case 'index':\r
158                                 $extra_actions = array(\r
159                                         'blog',\r
160                                         'blogsetting',\r
161                                         'preview',\r
162                                         'additemform',\r
163                                         'categorylist',\r
164                                         'archivelist',\r
165                                         'archivedaylist',\r
166                                         'archiveyearlist',\r
167                                         'nextlink',\r
168                                         'prevlink'\r
169                                 );\r
170                                 break;\r
171                         case 'archive':\r
172                                 $extra_actions = array(\r
173                                         'blog',\r
174                                         'archive',\r
175                                         'otherarchive',\r
176                                         'categorylist',\r
177                                         'archivelist',\r
178                                         'archivedaylist',\r
179                                         'archiveyearlist',\r
180                                         'blogsetting',\r
181                                         'archivedate',\r
182                                         'nextarchive',\r
183                                         'prevarchive',\r
184                                         'nextlink',\r
185                                         'prevlink',\r
186                                         'archivetype'\r
187                                 );\r
188                                 break;\r
189                         case 'archivelist':\r
190                                 $extra_actions = array(\r
191                                         'blog',\r
192                                         'archivelist',\r
193                                         'archivedaylist',\r
194                                         'archiveyearlist',\r
195                                         'categorylist',\r
196                                         'blogsetting'\r
197                                 );\r
198                                 break;\r
199                         case 'search':\r
200                                 $extra_actions = array(\r
201                                         'blog',\r
202                                         'archivelist',\r
203                                         'archivedaylist',\r
204                                         'archiveyearlist',\r
205                                         'categorylist',\r
206                                         'searchresults',\r
207                                         'othersearchresults',\r
208                                         'blogsetting',\r
209                                         'query',\r
210                                         'nextlink',\r
211                                         'prevlink'\r
212                                 );\r
213                                 break;\r
214                         case 'imagepopup':\r
215                                 $extra_actions = array(\r
216                                         'image',\r
217                                         // deprecated (Nucleus v2.0)\r
218                                         /* TODO: remove this */\r
219                                         'imagetext'\r
220                                 );\r
221                                 break;\r
222                         case 'member':\r
223                                 $extra_actions = array(\r
224                                         'membermailform',\r
225                                         'blogsetting',\r
226                                         'nucleusbutton',\r
227                                         'categorylist'\r
228                                 );\r
229                                 break;\r
230                         case 'item':\r
231                                 $extra_actions = array(\r
232                                         'blog',\r
233                                         'item',\r
234                                         'comments',\r
235                                         'commentform',\r
236                                         'vars',\r
237                                         'blogsetting',\r
238                                         'nextitem',\r
239                                         'previtem',\r
240                                         'nextlink',\r
241                                         'prevlink',\r
242                                         'nextitemtitle',\r
243                                         'previtemtitle',\r
244                                         'categorylist',\r
245                                         'archivelist',\r
246                                         'archivedaylist',\r
247                                         'archiveyearlist',\r
248                                         'itemtitle',\r
249                                         'itemid',\r
250                                         'itemlink'\r
251                                 );\r
252                                 break;\r
253                         case 'error':\r
254                                 $extra_actions = array(\r
255                                         'errormessage',\r
256                                         'categorylist'\r
257                                 );\r
258                                 break;\r
259                         default:\r
260                                         $extra_actions = array(\r
261                                                 'blog',\r
262                                                 'blogsetting',\r
263                                                 'preview',\r
264                                                 'additemform',\r
265                                                 'categorylist',\r
266                                                 'archivelist',\r
267                                                 'archivedaylist',\r
268                                                 'archiveyearlist',\r
269                                                 'nextlink',\r
270                                                 'prevlink',\r
271                                                 'membermailform',\r
272                                                 'nucleusbutton',\r
273                                                 'categorylist'\r
274                                         );\r
275                                 break;\r
276                 }\r
277                 return array_merge($default_actions, $extra_actions);\r
278         }\r
279         \r
280         /**\r
281          * AdminActions::get_page_action_names()\r
282          * \r
283          * @static\r
284          * @param       void\r
285          * @return      array   list of page action names\r
286          */\r
287         static public function get_page_action_names()\r
288         {\r
289                 return self::$page_action_names;\r
290         }\r
291         \r
292         /**\r
293          * Actions::get_page_type_friendly_names()\r
294          * \r
295          * @static\r
296          * @param       void\r
297          * @return      array   list of friendly names for page actions\r
298          */\r
299         static public function get_page_type_friendly_names()\r
300         {\r
301                 return self::$page_type_friendly_names;\r
302         }\r
303         \r
304         /**\r
305          * Actions::__construct()\r
306          * Constructor for a new Actions object\r
307          * \r
308          * @param       string  $type\r
309          * @return      void\r
310          */\r
311         public function __construct($type)\r
312         {\r
313                 global $catid;\r
314                 \r
315                 // call constructor of superclass first\r
316                 $this->BaseActions();\r
317                 $this->skintype = $type;\r
318                 \r
319                 if ( $catid )\r
320                 {\r
321                         $this->linkparams = array('catid' => $catid);\r
322                 }\r
323                 return;\r
324         }\r
325         \r
326         /**\r
327          * Actions::setSkin()\r
328          * Set the skin\r
329          * @param       object  $skin   an instance of Skin class\r
330          * @return      void\r
331          */\r
332         public function setSkin(&$skin)\r
333         {\r
334                 $this->skin =& $skin;\r
335                 return;\r
336         }\r
337         \r
338         /**\r
339          * Actions::setParser()\r
340          * Set the parser\r
341          * \r
342          * @param       object  $parser an instance of Parser class\r
343          * @return      void\r
344          */\r
345         public function setParser(&$parser)\r
346         {\r
347                 $this->parser =& $parser;\r
348                 return;\r
349         }\r
350         \r
351         /**\r
352          * Actions::doForm()\r
353          * Forms get parsedincluded now, using an extra <formdata> skinvar\r
354          *\r
355          * @param       string  $filename\r
356          * @return      void\r
357          */\r
358         public function doForm($filename)\r
359         {\r
360                 global $DIR_NUCLEUS;\r
361                 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');\r
362                 \r
363                 $oldIncludeMode = Parser::getProperty('IncludeMode');\r
364                 $oldIncludePrefix = Parser::getProperty('IncludePrefix');\r
365                 Parser::setProperty('IncludeMode','normal');\r
366                 Parser::setProperty('IncludePrefix','');\r
367                 \r
368                 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');\r
369                 Parser::setProperty('IncludeMode',$oldIncludeMode);\r
370                 Parser::setProperty('IncludePrefix',$oldIncludePrefix);\r
371                 \r
372                 array_pop($this->parser->actions);      // errordiv\r
373                 array_pop($this->parser->actions);      // callback\r
374                 array_pop($this->parser->actions);      // text\r
375                 array_pop($this->parser->actions);      // formdata\r
376                 array_pop($this->parser->actions);      // ticket\r
377                 return;\r
378         }\r
379 \r
380         /**\r
381          * Actions::checkCondition()\r
382          * Checks conditions for if statements\r
383          *\r
384          * @param       string  $field  type of <%if%>\r
385          * @param       string  $name   property of field\r
386          * @param       string  $value  value of property\r
387          * @return      boolean condition\r
388          */\r
389         public function checkCondition($field, $name='', $value = '')\r
390         {\r
391                 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
392                 \r
393                 $condition = 0;\r
394                 switch ( $field )\r
395                 {\r
396                         case 'category':\r
397                                 $condition = ($blog && $this->ifCategory($name,$value));\r
398                                 break;\r
399                         case 'blogsetting':\r
400                                 $condition = ($blog && ($blog->getSetting($name) == $value));\r
401                                 break;\r
402                         case 'loggedin':\r
403                                 $condition = $member->isLoggedIn();\r
404                                 break;\r
405                         case 'onteam':\r
406                                 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);\r
407                                 break;\r
408                         case 'admin':
409                                 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
410                                 break;
411                         case 'nextitem':\r
412                                 $condition = ($itemidnext != '');\r
413                                 break;\r
414                         case 'previtem':\r
415                                 $condition = ($itemidprev != '');\r
416                                 break;\r
417                         case 'archiveprevexists':\r
418                                 $condition = ($archiveprevexists == true);\r
419                                 break;\r
420                         case 'archivenextexists':\r
421                                 $condition = ($archivenextexists == true);\r
422                                 break;\r
423                         case 'skintype':\r
424                                 $condition = (($name == $this->skintype) || ($name == requestVar('action')));\r
425                                 break;\r
426                         case 'hasplugin':\r
427                                 $condition = $this->ifHasPlugin($name, $value);\r
428                                 break;\r
429                         default:\r
430                                 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);\r
431                                 break;\r
432                 }\r
433                 return $condition;\r
434         }\r
435         \r
436         /**\r
437          * Actions::_ifHasPlugin()\r
438          *      hasplugin,PlugName\r
439          *         -> checks if plugin exists\r
440          *      hasplugin,PlugName,OptionName\r
441          *         -> checks if the option OptionName from plugin PlugName is not set to 'no'\r
442          *      hasplugin,PlugName,OptionName=value\r
443          *         -> checks if the option OptionName from plugin PlugName is set to value\r
444          *\r
445          * @param       string  $name   name of plugin\r
446          * @param       string  $value  \r
447          * @return      \r
448          */\r
449         private function ifHasPlugin($name, $value)\r
450         {\r
451                 global $manager;\r
452                 $condition = false;\r
453                 // (pluginInstalled method won't write a message in the actionlog on failure)\r
454                 if ( $manager->pluginInstalled("NP_{$name}") )\r
455                 {\r
456                         $plugin =& $manager->getPlugin("NP_{$name}");\r
457                         if ( $plugin != NULL )\r
458                         {\r
459                                 if ( $value == "" )\r
460                                 {\r
461                                         $condition = true;\r
462                                 }\r
463                                 else\r
464                                 {\r
465                                         list($name2, $value2) = preg_split('#=#', $value, 2);\r
466                                         if ( $value2 == "" && $plugin->getOption($name2) != 'no' )\r
467                                         {\r
468                                                 $condition = true;\r
469                                         }\r
470                                         else if ( $plugin->getOption($name2) == $value2 )\r
471                                         {\r
472                                                 $condition = true;\r
473                                         }\r
474                                 }\r
475                         }\r
476                 }\r
477                 return $condition;\r
478         }\r
479         \r
480         /**\r
481          * Actions::ifPlugin()\r
482          * Checks if a plugin exists and call its doIf function\r
483          * \r
484          * @param       string  $name   name of plugin\r
485          * @param       string  $key    name of plugin option\r
486          * @param       string  $value  value of plugin option\r
487          * @return      void\r
488          */\r
489         private function ifPlugin($name, $key = '', $value = '')\r
490         {\r
491                 global $manager;\r
492                 \r
493                 $plugin =& $manager->getPlugin("NP_{$name}");\r
494                 if ( !$plugin )\r
495                 {\r
496                         return;\r
497                 }\r
498                 \r
499                 $params = func_get_args();\r
500                 array_shift($params);\r
501                 \r
502                 return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
503         }\r
504         \r
505         /**\r
506          * Actions::ifCategory()\r
507          * Different checks for a category\r
508          * \r
509          * @param       string  $name   \r
510          * @param       string  $value  \r
511          * @return      boolean \r
512          */\r
513         private function ifCategory($name = '', $value='')\r
514         {\r
515                 global $blog, $catid;\r
516                 \r
517                 // when no parameter is defined, just check if a category is selected\r
518                 if ( ($name != 'catname' && $name != 'catid') || ($value == '') )\r
519                 {\r
520                         return $blog->isValidCategory($catid);\r
521                 }\r
522                 \r
523                 // check category name\r
524                 if ( $name == 'catname' )\r
525                 {\r
526                         $value = $blog->getCategoryIdFromName($value);\r
527                         if ( $value == $catid )\r
528                         {\r
529                                 return $blog->isValidCategory($catid);\r
530                         }\r
531                 }\r
532                 \r
533                 // check category id\r
534                 if ( ($name == 'catid') && ($value == $catid) )\r
535                 {\r
536                         return $blog->isValidCategory($catid);\r
537                 }\r
538                 return FALSE;\r
539         }\r
540         \r
541         /**\r
542          * Actions::ifOnTeam()\r
543          * Checks if a member is on the team of a blog and return his rights\r
544          * \r
545          * @param       string  $blogName       name of weblog\r
546          * @return      mixed\r
547          */\r
548         private function ifOnTeam($blogName = '')\r
549         {\r
550                 global $blog, $member, $manager;\r
551                 \r
552                 // when no blog found\r
553                 if ( ($blogName == '') && !is_object($blog) )\r
554                 {\r
555                         return 0;\r
556                 }\r
557                 \r
558                 // explicit blog selection\r
559                 if ( $blogName != '' )\r
560                 {\r
561                         $blogid = getBlogIDFromName($blogName);\r
562                 }\r
563                 \r
564                 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
565                 {\r
566                         // use current blog\r
567                         $blogid = $blog->getID();\r
568                 }\r
569                 \r
570                 return $member->teamRights($blogid);\r
571         }\r
572 \r
573         /**\r
574          * Actions::ifAdmin()\r
575          * Checks if a member is admin of a blog\r
576          * \r
577          * @param       string  $blogName       name of weblog\r
578          * @return      mixed\r
579          */\r
580         private function ifAdmin($blogName = '')\r
581         {\r
582                 global $blog, $member, $manager;\r
583                 \r
584                 // when no blog found\r
585                 if ( ($blogName == '') && (!is_object($blog)) )\r
586                 {\r
587                         return 0;\r
588                 }\r
589                 \r
590                 // explicit blog selection\r
591                 if ( $blogName != '' )\r
592                 {\r
593                         $blogid = getBlogIDFromName($blogName);\r
594                 }\r
595                 \r
596                 if ( ($blogName == '') || !$manager->existsBlogID($blogid) )\r
597                 {\r
598                         // use current blog\r
599                         $blogid = $blog->getID();\r
600                 }\r
601                 \r
602                 return $member->isBlogAdmin($blogid);\r
603         }\r
604         \r
605         /**\r
606          * Actions::link()\r
607          * returns either\r
608          *      - a raw link (html/xml encoded) when no linktext is provided\r
609          *      - a (x)html <a href... link when a text is present (text htmlencoded)\r
610          * \r
611          * @param       string  $url            URL for href attribute of anchor element\r
612          * @param       string  $linktext       content of anchor element\r
613          * @return      \r
614          */\r
615         private function link($url, $linktext = '')\r
616         {\r
617                 $u = Entity::hsc($url);\r
618                 // fix URLs that already had encoded ampersands\r
619                 $u = preg_replace("#&amp;amp;#", '&amp;', $u);\r
620                 if ( $linktext != '' )\r
621                 {\r
622                         $l = '<a href="' . $u .'">' . Entity::hsc($linktext) . '</a>';\r
623                 }\r
624                 else\r
625                 {\r
626                         $l = $u;\r
627                 }\r
628                 return $l;\r
629         }\r
630         \r
631         /**\r
632          * Actions::searchlink()\r
633          * Outputs a next/prev link\r
634          *\r
635          * @param $maxresults\r
636          *              The maximum amount of items shown per page (e.g. 10)\r
637          * @param $startpos\r
638          *              Current start position (requestVar('startpos'))\r
639          * @param $direction\r
640          *              either 'prev' or 'next'\r
641          * @param $linktext\r
642          *              When present, the output will be a full <a href...> link. When empty,\r
643          *              only a raw link will be outputted\r
644          */\r
645         private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '')\r
646         {\r
647                 global $CONF, $blog, $query, $amount;\r
648                 // TODO: Move request uri to linkparams. this is ugly. sorry for that.\r
649                 $startpos       = (integer) $startpos;\r
650                 $parsed         = parse_url(serverVar('REQUEST_URI'));\r
651                 $path           = $parsed['path'];\r
652                 $parsed         = $parsed['query'];\r
653                 $url            = '';\r
654                 \r
655                 if ( $direction == 'prev' )\r
656                 {\r
657                         if ( intval($startpos) - intval($maxresults) >= 0 )\r
658                         {\r
659                                 $startpos       = intval($startpos) - intval($maxresults);\r
660                                 \r
661                                 if ( $this->skintype == 'index' )\r
662                                 {\r
663                                         $url = $path;\r
664                                 }\r
665                                 else if ( $this->skintype == 'search' )\r
666                                 {\r
667                                         $url = $CONF['SearchURL'];\r
668                                 }\r
669                                 $url .= '?' . alterQueryStr($parsed,'startpos',$startpos);\r
670                         }\r
671                 }\r
672                 else if ( $direction == 'next' )\r
673                 {\r
674                         global $navigationItems;\r
675                         if ( !isset($navigationItems) )\r
676                         {\r
677                                 $navigationItems = 0;\r
678                         }\r
679                         \r
680                         if ( $recount )\r
681                         {\r
682                                 $iAmountOnPage = 0;\r
683                         }\r
684                         else \r
685                         {\r
686                                 $iAmountOnPage = $this->amountfound;\r
687                         }\r
688                         \r
689                         if ( intval($navigationItems) > 0 )\r
690                         {\r
691                                 $iAmountOnPage = intval($navigationItems) - intval($startpos);\r
692                         }\r
693                         elseif ( $iAmountOnPage == 0 )\r
694                         {\r
695                                 /*\r
696                                  * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]\r
697                                  * try a count query\r
698                                  */\r
699                                 if ( $this->skintype == 'index' )\r
700                                 {\r
701                                         $sqlquery = $blog->getSqlBlog('', 'count');\r
702                                         $url = $path;\r
703                                 }\r
704                                 else if ( $this->skintype == 'search' )\r
705                                 {\r
706                                         $unused_highlight = '';\r
707                                         $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');\r
708                                         $url = $CONF['SearchURL'];\r
709                                 }\r
710                                 if ( $sqlquery )\r
711                                 {\r
712                                         $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);\r
713                                 }\r
714                         }\r
715                         \r
716                         $url = '';\r
717                         if ( intval($iAmountOnPage) >= intval($maxresults) )\r
718                         {\r
719                                 $startpos        = intval($startpos) + intval($maxresults);\r
720                                 $url            .= '?' . alterQueryStr($parsed, 'startpos', $startpos);\r
721                         }\r
722                 }\r
723                 \r
724                 if ( $url != '' )\r
725                 {\r
726                         echo $this->link($url, $linktext);\r
727                 }\r
728                 return;\r
729         }\r
730         \r
731         /**\r
732          * Actions::itemlink()\r
733          * Creates an item link and if no id is given a todaylink \r
734          * \r
735          * @param       integer $id     id for link\r
736          * @param       string  $linktext       text for link\r
737          * @return      void\r
738          */\r
739         private function itemlink($id, $linktext = '')\r
740         {\r
741                 global $CONF;\r
742                 if ( $id != 0 )\r
743                 {\r
744                         echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext);\r
745                 }\r
746                 else\r
747                 {\r
748                         $this->parse_todaylink($linktext);\r
749                 }\r
750                 return;\r
751         }\r
752         \r
753         /**\r
754          * Actions::archivelink)\r
755          * Creates an archive link and if no id is given a todaylink \r
756          * \r
757          * @param       integer $id     id for link\r
758          * @param       string  $linktext       text for link\r
759          * @return      void\r
760          */\r
761         private function archivelink($id, $linktext = '')\r
762         {\r
763                 global $CONF, $blog;\r
764                 if ( $id != 0 )\r
765                 {\r
766                         echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);\r
767                 }\r
768                 else\r
769                 {\r
770                         $this->parse_todaylink($linktext);\r
771                 }\r
772                 return;\r
773         }\r
774         \r
775         /**\r
776          * Actions:setBlogCategory()\r
777          * Helper function that sets the category that a blog will need to use\r
778          *\r
779          * @param       string  $blog           An object of the blog class, passed by reference (we want to make changes to it)\r
780          * @param       string  $catname        The name of the category to use\r
781          * @return      void\r
782          */\r
783         private function setBlogCategory(&$blog, $catname)\r
784         {\r
785                 global $catid;\r
786                 if ( $catname != '' )\r
787                 {\r
788                         $blog->setSelectedCategoryByName($catname);\r
789                 }\r
790                 else\r
791                 {\r
792                         $blog->setSelectedCategory($catid);\r
793                 }\r
794                 return;\r
795         }\r
796         \r
797         /**\r
798          * Actions::preBlogContent()\r
799          * Notifies the Manager that a PreBlogContent event occurs\r
800          * \r
801          * @param       string  $type   type of skin\r
802          * @param       object  $blog   an instance of Blog class\r
803          * @return      void\r
804          */\r
805         private function preBlogContent($type, &$blog)\r
806         {\r
807                 global $manager;\r
808                 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));\r
809                 return;\r
810         }\r
811 \r
812         /**\r
813          * Actions::postBlogContent()\r
814          * Notifies the Manager that a PostBlogContent event occurs\r
815          * \r
816          * @param       string  $type   type of skin\r
817          * @param       objecct $blog   an instance of Blog class\r
818          * @return      void\r
819          */\r
820         private function postBlogContent($type, &$blog)\r
821         {\r
822                 global $manager;\r
823                 $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type));\r
824                 return;\r
825         }\r
826         \r
827         /**\r
828          * Actions::parse_additemform()\r
829          * Parse skinvar additemform\r
830          * \r
831          * @param       void\r
832          * @return      void\r
833          */\r
834         public function parse_additemform()\r
835         {\r
836                 global $blog, $CONF;\r
837                 $this->formdata = array(\r
838                         'adminurl'      => Entity::hsc($CONF['AdminURL']),\r
839                         'catid'         => $blog->getDefaultCategory()\r
840                 );\r
841                 $blog->InsertJavaScriptInfo();\r
842                 $this->doForm('additemform');\r
843                 return;\r
844         }\r
845         \r
846         /**\r
847          * Actions::parse_addlink()\r
848          * Parse skinvar addlink\r
849          * A Link that allows to open a bookmarklet to add an item\r
850          */\r
851         public function parse_addlink()\r
852         {\r
853                 global $CONF, $member, $blog;\r
854                 if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) )\r
855                 {\r
856                         echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;\r
857                 }\r
858                 return;\r
859         }\r
860         \r
861         /**\r
862          * Actions::parse_addpopupcode()\r
863          * Parse skinvar addpopupcode\r
864          * Code that opens a bookmarklet in an popup window\r
865          * \r
866          * @param       void\r
867          * @return      void\r
868          */\r
869         public function parse_addpopupcode()\r
870         {\r
871                 echo "if (event &amp;&amp; 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
872                 return;\r
873         }\r
874         \r
875         /**\r
876          * Parse skinvar adminurl\r
877          * (shortcut for admin url)\r
878          * \r
879          * @param       void\r
880          * @return      void\r
881          */\r
882         public function parse_adminurl()\r
883         {\r
884                 $this->parse_sitevar('adminurl');\r
885                 return;\r
886         }\r
887         \r
888         /**\r
889          * Actions::parse_archive()\r
890          * Parse skinvar archive\r
891          * \r
892          * @param       string  $template       name of template\r
893          * @param       string  $category       name of category\r
894          * @return      \r
895          */\r
896         public function parse_archive($template, $category = '')\r
897         {\r
898                 global $blog, $archive;\r
899                 // can be used with either yyyy-mm or yyyy-mm-dd\r
900                 sscanf($archive,'%d-%d-%d', $y, $m, $d);\r
901                 $this->setBlogCategory($blog, $category);\r
902                 $this->preBlogContent('achive',$blog);\r
903                 $blog->showArchive($template, $y, $m, $d);\r
904                 $this->postBlogContent('achive',$blog);\r
905                 return;\r
906         }\r
907         \r
908         /**\r
909          * Actions::parse_archivedate()\r
910          * %archivedate(locale,date format)%\r
911          * \r
912          * @param       string  $locale\r
913          * @return      void\r
914          */\r
915         public function parse_archivedate($locale = '-def-')\r
916         {\r
917                 global $archive;\r
918                 \r
919                 /* \r
920                  * TODO: these lines are no meaning because there is no $template.\r
921                 if ( $locale == '-def-' )\r
922                 {\r
923                         setlocale(LC_TIME, $template['LOCALE']);\r
924                 }\r
925                 else\r
926                 {\r
927                         setlocale(LC_TIME, $locale);\r
928                 }\r
929                  */\r
930                 \r
931                 // get archive date\r
932                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
933                 \r
934                 // get format\r
935                 $args = func_get_args();\r
936                 // format can be spread over multiple parameters\r
937                 if ( sizeof($args) > 1 )\r
938                 {\r
939                         // take away locale\r
940                         array_shift($args);\r
941                         // implode\r
942                         $format=implode(',',$args);\r
943                 }\r
944                 elseif ( $d == 0 && $m !=0 )\r
945                 {\r
946                         $format = '%B %Y';\r
947                 }\r
948                 elseif ( $m == 0 )\r
949                 {\r
950                         $format = '%Y';\r
951                 }\r
952                 else\r
953                 {\r
954                         $format = '%d %B %Y';\r
955                 }\r
956                 echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));\r
957                 return;\r
958         }\r
959         \r
960         /**\r
961          * Actions::parse_archivedaylist()\r
962          * Parse skinvar archivedaylist\r
963          * \r
964          * @param       string  $template       name of template\r
965          * @param       string  $category       name of category\r
966          * @param       integer $limit          the number of items in a display\r
967          * @return      void\r
968          */\r
969         public function parse_archivedaylist($template, $category = 'all', $limit = 0)\r
970         {\r
971                 global $blog;\r
972                 if ( $category == 'all' )\r
973                 {\r
974                         $category = '';\r
975                 }\r
976                 $this->preBlogContent('archivelist',$blog);\r
977                 $this->setBlogCategory($blog, $category);\r
978                 $blog->showArchiveList($template, 'day', $limit);\r
979                 $this->postBlogContent('archivelist',$blog);\r
980                 return;\r
981         }\r
982         \r
983         /**\r
984          * Actions::parse_archivelink()\r
985          * A link to the archives for the current blog (or for default blog)\r
986          * \r
987          * @param       string  $linktext       text for link\r
988          * @return      void\r
989          */\r
990         public function parse_archivelink($linktext = '')\r
991         {\r
992                 global $blog, $CONF;\r
993                 if ( $blog )\r
994                 {\r
995                         echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext);\r
996                 }\r
997                 else\r
998                 {\r
999                         echo $this->link(Link::create_archivelist_link(), $linktext);\r
1000                 }\r
1001                 return;\r
1002         }\r
1003         \r
1004         /**\r
1005          * Actions::parse_archivelist()\r
1006          * \r
1007          * @param       string  $template       name of template\r
1008          * @param       string  $category       name of category\r
1009          * @param       integer $limit          the number of items in a display\r
1010          * @return      void\r
1011          */\r
1012         public function parse_archivelist($template, $category = 'all', $limit = 0)\r
1013         {\r
1014                 global $blog;\r
1015                 if ( $category == 'all' )\r
1016                 {\r
1017                         $category = '';\r
1018                 }\r
1019                 $this->preBlogContent('archivelist',$blog);\r
1020                 $this->setBlogCategory($blog, $category);\r
1021                 $blog->showArchiveList($template, 'month', $limit);\r
1022                 $this->postBlogContent('archivelist',$blog);\r
1023                 return;\r
1024         }\r
1025         \r
1026         /**\r
1027          * Actions::parse_archiveyearlist()\r
1028          * \r
1029          * @param       string  $template       name of template\r
1030          * @param       string  $category       name of category\r
1031          * @param       integer $limit          the number of items in a display\r
1032          */\r
1033         public function parse_archiveyearlist($template, $category = 'all', $limit = 0)\r
1034         {\r
1035                 global $blog;\r
1036                 if ( $category == 'all' )\r
1037                 {\r
1038                         $category = '';\r
1039                 }\r
1040                 $this->preBlogContent('archivelist',$blog);\r
1041                 $this->setBlogCategory($blog, $category);\r
1042                 $blog->showArchiveList($template, 'year', $limit);\r
1043                 $this->postBlogContent('archivelist',$blog);\r
1044                 return;\r
1045         }\r
1046         \r
1047         /**\r
1048          * Actions::parse_archivetype()\r
1049          * Parse skinvar archivetype\r
1050          * \r
1051          * @param       void\r
1052          * @return      void\r
1053          */\r
1054         public function parse_archivetype()\r
1055         {\r
1056                 global $archivetype;\r
1057                 echo $archivetype;\r
1058                 return;\r
1059         }\r
1060         \r
1061         /**\r
1062          * Actions::parse_blog()\r
1063          * Parse skinvar blog\r
1064          * \r
1065          * @param       string  $template       name of template\r
1066          * @param       mixed   $amount         the number of items in a display, in case it includes the beginning\r
1067          * @param       string  $category       name of category\r
1068          * @return      void\r
1069          */\r
1070         public function parse_blog($template, $amount = 10, $category = '')\r
1071         {\r
1072                 global $blog, $startpos;\r
1073                 \r
1074                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
1075                 $this->setBlogCategory($blog, $category);\r
1076                 $this->preBlogContent('blog',$blog);\r
1077                 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);\r
1078                 $this->postBlogContent('blog',$blog);\r
1079                 return;\r
1080         }\r
1081         \r
1082         /**\r
1083          * Actions::parse_bloglist()\r
1084          * Parse skinvar bloglist\r
1085          * Shows a list of all blogs\r
1086          * \r
1087          * @param       string  $template       name of template\r
1088          * @param       string  $bnametype      whether 'name' or 'shortname' is used for the link text\r
1089          * @param       string  $orderby        order criteria\r
1090          * @param       string  $direction      order ascending or descending             \r
1091          * @return      void\r
1092          */\r
1093         public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc')\r
1094         {\r
1095                 Blog::showBlogList($template, $bnametype, $orderby, $direction);\r
1096                 return;\r
1097         }\r
1098         \r
1099         /**\r
1100          * Actions::parse_blogsetting()\r
1101          * Parse skinvar blogsetting\r
1102          * \r
1103          * @param       string  $which  key of weblog settings\r
1104          * @return      void\r
1105          */\r
1106         public function parse_blogsetting($which)\r
1107         {\r
1108                 global $blog;\r
1109                 switch( $which )\r
1110                 {\r
1111                         case 'id':\r
1112                                 echo Entity::hsc($blog->getID());\r
1113                                 break;\r
1114                         case 'url':\r
1115                                 echo Entity::hsc($blog->getURL());\r
1116                                 break;\r
1117                         case 'name':\r
1118                                 echo Entity::hsc($blog->getName());\r
1119                                 break;\r
1120                         case 'desc':\r
1121                                 echo Entity::hsc($blog->getDescription());\r
1122                                 break;\r
1123                         case 'short':\r
1124                                 echo Entity::hsc($blog->getShortName());\r
1125                                 break;\r
1126                 }\r
1127                 return;\r
1128         }\r
1129         \r
1130         /**\r
1131          * Actions::parse_callback()\r
1132          * Parse callback\r
1133          * \r
1134          * @param       string  $eventName      name of event\r
1135          * @param       string  $type   type of skin\r
1136          * @return      void\r
1137          */\r
1138         public function parse_callback($eventName, $type)\r
1139         {\r
1140                 global $manager;\r
1141                 $manager->notify($eventName, array('type' => $type));\r
1142                 return;\r
1143         }\r
1144         \r
1145         /**\r
1146          * Actions::parse_category()\r
1147          * Parse skinvar category\r
1148          * \r
1149          * @param       string  $type   key of category settings\r
1150          * @return      void\r
1151          */\r
1152         public function parse_category($type = 'name')\r
1153         {\r
1154                 global $catid, $blog;\r
1155                 if ( !$blog->isValidCategory($catid) )\r
1156                 {\r
1157                         return;\r
1158                 }\r
1159                 \r
1160                 switch ( $type )\r
1161                 {\r
1162                         case 'name':\r
1163                                 echo $blog->getCategoryName($catid);\r
1164                                 break;\r
1165                         case 'desc':\r
1166                                 echo $blog->getCategoryDesc($catid);\r
1167                                 break;\r
1168                         case 'id':\r
1169                                 echo $catid;\r
1170                                 break;\r
1171                 }\r
1172                 return;\r
1173         }\r
1174         \r
1175         /**\r
1176          * Actions::parse_categorylist()\r
1177          * Parse categorylist\r
1178          * \r
1179          * @param       string  $template       name of template\r
1180          * @param       string  $blogname       name of weblog\r
1181          * @return      void\r
1182          */\r
1183         public function parse_categorylist($template, $blogname = '')\r
1184         {\r
1185                 global $blog, $manager;\r
1186                 \r
1187                 // when no blog found\r
1188                 if ( ($blogname == '') && (!is_object($blog)) )\r
1189                 {\r
1190                         return 0;\r
1191                 }\r
1192                         \r
1193                 if ( $blogname == '' )\r
1194                 {\r
1195                         $this->preBlogContent('categorylist',$blog);\r
1196                         $blog->showCategoryList($template);\r
1197                         $this->postBlogContent('categorylist',$blog);\r
1198                 }\r
1199                 else\r
1200                 {\r
1201                         $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1202                         $this->preBlogContent('categorylist',$b);\r
1203                         $b->showCategoryList($template);\r
1204                         $this->postBlogContent('categorylist',$b);\r
1205                 }\r
1206                 return;\r
1207         }\r
1208         \r
1209         /**\r
1210          * Actions::parse_charset()\r
1211          * Parse skinvar charset\r
1212          * \r
1213          * @param       void\r
1214          * @return      void\r
1215          */\r
1216         public function parse_charset()\r
1217         {\r
1218                 echo i18n::get_current_charset();\r
1219                 return;\r
1220         }\r
1221         \r
1222         /**\r
1223          * Actions::parse_commentform()\r
1224          * Parse skinvar commentform\r
1225          * \r
1226          * @param       string  $destinationurl URI for redirection\r
1227          * @return      void\r
1228          */\r
1229         public function parse_commentform($destinationurl = '')\r
1230         {\r
1231                 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;\r
1232                 \r
1233                 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)\r
1234                 if ( stristr($destinationurl, 'action.php') )\r
1235                 {\r
1236                         $args = func_get_args();\r
1237                         $destinationurl = $args[1];\r
1238                         ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);\r
1239                 }\r
1240                 \r
1241                 $actionurl = $CONF['ActionURL'];\r
1242                 \r
1243                 // if item is closed, show message and do nothing\r
1244                 $item =& $manager->getItem($itemid,0,0);\r
1245                 if ( $item['closed'] || !$blog->commentsEnabled() )\r
1246                 {\r
1247                         $this->doForm('commentform-closed');\r
1248                         return;\r
1249                 }\r
1250                 \r
1251                 if ( !$blog->isPublic() && !$member->isLoggedIn() )\r
1252                 {\r
1253                         $this->doForm('commentform-closedtopublic');\r
1254                         return;\r
1255                 }\r
1256                 \r
1257                 if ( !$destinationurl )\r
1258                 {\r
1259                         // note: createLink returns an HTML encoded URL\r
1260                         $destinationurl = Link::create_link(\r
1261                                 'item',\r
1262                                 array(\r
1263                                         'itemid' => $itemid,\r
1264                                         'title' => $item['title'],\r
1265                                         'timestamp' => $item['timestamp'],\r
1266                                         'extra' => $this->linkparams\r
1267                                 )\r
1268                         );\r
1269                 }\r
1270                 else\r
1271                 {\r
1272                         // HTML encode URL\r
1273                         $destinationurl = Entity::hsc($destinationurl);\r
1274                 }\r
1275                 \r
1276                 // values to prefill\r
1277                 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');\r
1278                 if ( !$user )\r
1279                 {\r
1280                         $user = postVar('user');\r
1281                 }\r
1282                 \r
1283                 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');\r
1284                 if ( !$userid )\r
1285                 {\r
1286                         $userid = postVar('userid');\r
1287                 }\r
1288                 \r
1289                 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');\r
1290                 if (!$email)\r
1291                 {\r
1292                         $email = postVar('email');\r
1293                 }\r
1294                 \r
1295                 $body = postVar('body');\r
1296                 \r
1297                 $this->formdata = array(\r
1298                         'destinationurl' => $destinationurl,    // url is already HTML encoded\r
1299                         'actionurl' => Entity::hsc($actionurl),\r
1300                         'itemid' => $itemid,\r
1301                         'user' => Entity::hsc($user),\r
1302                         'userid' => Entity::hsc($userid),\r
1303                         'email' => Entity::hsc($email),\r
1304                         'body' => Entity::hsc($body),\r
1305                         'membername' => $member->getDisplayName(),\r
1306                         'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''\r
1307                 );\r
1308                 \r
1309                 if ( !$member->isLoggedIn() )\r
1310                 {\r
1311                         $this->doForm('commentform-notloggedin');\r
1312                 }\r
1313                 else\r
1314                 {\r
1315                         $this->doForm('commentform-loggedin');\r
1316                 }\r
1317                 return;\r
1318         }\r
1319         \r
1320         /**\r
1321          * Actions::parse_comments()\r
1322          * Parse skinvar comments\r
1323          * include comments for one item\r
1324          * \r
1325          * @param       string  $template       name of template\r
1326          * @return      void\r
1327          */\r
1328         public function parse_comments($template)\r
1329         {\r
1330                 global $itemid, $manager, $blog, $highlight;\r
1331                 $template =& $manager->getTemplate($template);\r
1332                 \r
1333                 // create parser object & action handler\r
1334                 $actions = new ItemActions($blog);\r
1335                 $parser = new Parser($actions->getDefinedActions(),$actions);\r
1336                 $actions->setTemplate($template);\r
1337                 $actions->setParser($parser);\r
1338                 $item = Item::getitem($itemid, 0, 0);\r
1339                 $actions->setCurrentItem($item);\r
1340                 \r
1341                 $comments = new Comments($itemid);\r
1342                 $comments->setItemActions($actions);\r
1343                 // shows ALL comments\r
1344                 $comments->showComments($template, -1, 1, $highlight);\r
1345                 return;\r
1346         }\r
1347         \r
1348         /**\r
1349          * Actions::parse_errordiv()\r
1350          * Parse errordiv\r
1351          * \r
1352          * @param       void\r
1353          * @return      void\r
1354          */\r
1355         public function parse_errordiv()\r
1356         {\r
1357                 global $errormessage;\r
1358                 if ( $errormessage )\r
1359                 {\r
1360                         echo '<div class="error">' . Entity::hsc($errormessage) . "</div>\n";\r
1361                 }\r
1362                 return;\r
1363         }\r
1364         \r
1365         /**\r
1366          * Actions::parse_errormessage()\r
1367          * Parse skinvar errormessage\r
1368          * \r
1369          * @param       void\r
1370          * @return      void\r
1371          */\r
1372         public function parse_errormessage()\r
1373         {\r
1374                 global $errormessage;\r
1375                 echo $errormessage;\r
1376                 return;\r
1377         }\r
1378         \r
1379         /**\r
1380          * Actions::parse_formdata()\r
1381          * Parse formdata\r
1382          * \r
1383          * @param       string  $what   key of format data\r
1384          * @return      void\r
1385          */\r
1386         public function parse_formdata($what)\r
1387         {\r
1388                 echo $this->formdata[$what];\r
1389                 return;\r
1390         }\r
1391         \r
1392         /**\r
1393          * Actions::parse_ifcat()\r
1394          * Parse ifcat\r
1395          * \r
1396          * @param       string  $text\r
1397          * @return      void\r
1398          */\r
1399         public function parse_ifcat($text = '')\r
1400         {\r
1401                 if ( $text == '' )\r
1402                 {\r
1403                         // new behaviour\r
1404                         $this->parse_if('category');\r
1405                 }\r
1406                 else\r
1407                 {\r
1408                         // old behaviour\r
1409                         global $catid, $blog;\r
1410                         if ( $blog->isValidCategory($catid) )\r
1411                         {\r
1412                                 echo $text;\r
1413                         }\r
1414                 }\r
1415                 return;\r
1416         }\r
1417         \r
1418         /**\r
1419          * Actions::parse_image()\r
1420          * Parse skinvar image\r
1421          * \r
1422          * @param       string  $what   name of tag\r
1423          * @return      void\r
1424          */\r
1425         public function parse_image($what = 'imgtag')\r
1426         {\r
1427                 global $CONF;\r
1428                 \r
1429                 $imagetext      = Entity::hsc(requestVar('imagetext'));\r
1430                 $imagepopup = requestVar('imagepopup');\r
1431                 $width          = intRequestVar('width');\r
1432                 $height         = intRequestVar('height');\r
1433                 $fullurl        = Entity::hsc($CONF['MediaURL'] . $imagepopup);\r
1434                 \r
1435                 switch ( $what )\r
1436                 {\r
1437                         case 'url':\r
1438                                 echo $fullurl;\r
1439                                 break;\r
1440                         case 'width':\r
1441                                 echo $width;\r
1442                                 break;\r
1443                         case 'height':\r
1444                                 echo $height;\r
1445                                 break;\r
1446                         case 'caption':\r
1447                         case 'text':\r
1448                                 echo $imagetext;\r
1449                                 break;\r
1450                         case 'imgtag':\r
1451                         default:\r
1452                                 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";\r
1453                                 break;\r
1454                 }\r
1455                 return;\r
1456         }\r
1457         \r
1458         /**\r
1459          * Actions::parse_imagetext()\r
1460          * Parse skinvar imagetext\r
1461          * \r
1462          * @param       void\r
1463          * @return      void\r
1464          */\r
1465         public function parse_imagetext()\r
1466         {\r
1467                 $this->parse_image('imagetext');\r
1468                 return;\r
1469         }\r
1470 \r
1471         /**\r
1472          * Actions::parse_item()\r
1473          * Parse skinvar item\r
1474          * include one item (no comments)\r
1475          * \r
1476          * @param       void\r
1477          * @return      void\r
1478          */\r
1479         public function parse_item($template)\r
1480         {\r
1481                 global $blog, $itemid, $highlight;\r
1482                 \r
1483                 // need this to select default category\r
1484                 $this->setBlogCategory($blog, '');\r
1485                 $this->preBlogContent('item',$blog);\r
1486                 $r = $blog->showOneitem($itemid, $template, $highlight);\r
1487                 if ( $r == 0 )\r
1488                 {\r
1489                         echo _ERROR_NOSUCHITEM;\r
1490                 }\r
1491                 $this->postBlogContent('item',$blog);\r
1492                 return;\r
1493         }\r
1494 \r
1495         /**\r
1496          * Actions::parse_itemid()\r
1497          * Parse skinvar itemid\r
1498          * \r
1499          * @param       void\r
1500          * @return      void\r
1501          */\r
1502         public function parse_itemid()\r
1503         {\r
1504                 global $itemid;\r
1505                 echo $itemid;\r
1506                 return;\r
1507         }\r
1508         \r
1509         /**\r
1510          * Actions::parseitemlink()\r
1511          * Parse skinvar itemlink\r
1512          * \r
1513          * @param       void\r
1514          * @return      void\r
1515          */\r
1516         public function parse_itemlink($linktext = '')\r
1517         {\r
1518                 global $itemid;\r
1519                 $this->itemlink($itemid, $linktext);\r
1520                 return;\r
1521         }\r
1522         \r
1523         /**\r
1524          * Actions::parse_itemtitle()\r
1525          * Parse itemtitle\r
1526          * \r
1527          * @param       void\r
1528          * @return      void\r
1529          */\r
1530         public function parse_itemtitle($format = '')\r
1531         {\r
1532                 global $manager, $itemid;\r
1533                 $item =& $manager->getItem($itemid,0,0);\r
1534                 \r
1535                 switch ( $format )\r
1536                 {\r
1537                         case 'xml':\r
1538                                 echo Entity::hen($item['title']);\r
1539                                 break;\r
1540                         case 'raw':\r
1541                                 echo $item['title'];\r
1542                                 break;\r
1543                         case 'attribute':\r
1544                         default:\r
1545                                 echo Entity::hsc(strip_tags($item['title']));\r
1546                                 break;\r
1547                 }\r
1548                 return;\r
1549         }\r
1550         \r
1551         /**\r
1552          * Actions::parse_loginform()\r
1553          * Parse skinvar loginform\r
1554          * \r
1555          * @param       void\r
1556          * @return      void\r
1557          */\r
1558         public function parse_loginform()\r
1559         {\r
1560                 global $member, $CONF;\r
1561                 if ( !$member->isLoggedIn() )\r
1562                 {\r
1563                         $filename = 'loginform-notloggedin';\r
1564                         $this->formdata = array();\r
1565                 }\r
1566                 else\r
1567                 {\r
1568                         $filename = 'loginform-loggedin';\r
1569                         $this->formdata = array(\r
1570                                 'membername' => $member->getDisplayName(),\r
1571                         );\r
1572                 }\r
1573                 $this->doForm($filename);\r
1574                 return;\r
1575         }\r
1576         \r
1577         /**\r
1578          * Actions::parse_member()\r
1579          * Parse skinvar member\r
1580          * (includes a member info thingie)\r
1581          * \r
1582          * @param       string  $what   which memberdata is needed\r
1583          * @return      void\r
1584          */\r
1585         public function parse_member($what)\r
1586         {\r
1587                 global $memberinfo, $member, $CONF;\r
1588                 \r
1589                 // 1. only allow the member-details-page specific variables on member pages\r
1590                 if ( $this->skintype == 'member' )\r
1591                 {\r
1592                         switch( $what )\r
1593                         {\r
1594                                 case 'name':\r
1595                                         echo Entity::hsc($memberinfo->getDisplayName());\r
1596                                         break;\r
1597                                 case 'realname':\r
1598                                         echo Entity::hsc($memberinfo->getRealName());\r
1599                                         break;\r
1600                                 case 'notes':\r
1601                                         echo Entity::hsc($memberinfo->getNotes());\r
1602                                         break;\r
1603                                 case 'url':\r
1604                                         echo Entity::hsc($memberinfo->getURL());\r
1605                                         break;\r
1606                                 case 'email':\r
1607                                         echo Entity::hsc($memberinfo->getEmail());\r
1608                                         break;\r
1609                                 case 'id':\r
1610                                         echo Entity::hsc($memberinfo->getID());\r
1611                                         break;\r
1612                         }\r
1613                 }\r
1614                 \r
1615                 // 2. the next bunch of options is available everywhere, as long as the user is logged in\r
1616                 if ( $member->isLoggedIn() )\r
1617                 {\r
1618                         switch( $what )\r
1619                         {\r
1620                                 case 'yourname':\r
1621                                         echo $member->getDisplayName();\r
1622                                         break;\r
1623                                 case 'yourrealname':\r
1624                                         echo $member->getRealName();\r
1625                                         break;\r
1626                                 case 'yournotes':\r
1627                                         echo $member->getNotes();\r
1628                                         break;\r
1629                                 case 'yoururl':\r
1630                                         echo $member->getURL();\r
1631                                         break;\r
1632                                 case 'youremail':\r
1633                                         echo $member->getEmail();\r
1634                                         break;\r
1635                                 case 'yourid':\r
1636                                         echo $member->getID();\r
1637                                         break;\r
1638                                 case 'yourprofileurl':\r
1639                                         if ($CONF['URLMode'] == 'pathinfo')\r
1640                                                 echo Link::create_member_link($member->getID());\r
1641                                         else\r
1642                                                 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());\r
1643                                         break;\r
1644                         }\r
1645                 }\r
1646                 return;\r
1647         }\r
1648         \r
1649         /**\r
1650          * Link::parse_membermailform()\r
1651          * Parse skinvar membermailform\r
1652          * \r
1653          * @param       integer $rows   the height for textarea\r
1654          * @param       integer $cols   the width for textarea\r
1655          * @param       string  $desturl        URI to redirect\r
1656          * @return      void\r
1657          */\r
1658         public function parse_membermailform($rows = 10, $cols = 40, $desturl = '')\r
1659         {\r
1660                 global $member, $CONF, $memberid;\r
1661                 \r
1662                 if ( $desturl == '' )\r
1663                 {\r
1664                         if ( $CONF['URLMode'] == 'pathinfo' )\r
1665                         {\r
1666                                 $desturl = Link::create_member_link($memberid);\r
1667                         }\r
1668                         else\r
1669                         {\r
1670                                 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);\r
1671                         }\r
1672                 }\r
1673                 \r
1674                 $message = postVar('message');\r
1675                 $frommail = postVar('frommail');\r
1676                 \r
1677                 $this->formdata = array(\r
1678                         'url' => Entity::hsc($desturl),\r
1679                         'actionurl' => Entity::hsc($CONF['ActionURL']),\r
1680                         'memberid' => $memberid,\r
1681                         'rows' => $rows,\r
1682                         'cols' => $cols,\r
1683                         'message' => Entity::hsc($message),\r
1684                         'frommail' => Entity::hsc($frommail)\r
1685                 );\r
1686                 \r
1687                 if ( $member->isLoggedIn() )\r
1688                 {\r
1689                         $this->doForm('membermailform-loggedin');\r
1690                 }\r
1691                 else if ( $CONF['NonmemberMail'] )\r
1692                 {\r
1693                         $this->doForm('membermailform-notloggedin');\r
1694                 }\r
1695                 else\r
1696                 {\r
1697                         $this->doForm('membermailform-disallowed');\r
1698                 }\r
1699                 return;\r
1700         }\r
1701         \r
1702         /**\r
1703          * Actions::parse_nextarchive()\r
1704          * Parse skinvar nextarchive\r
1705          * \r
1706          * @param       void\r
1707          * @return      void\r
1708          */\r
1709         public function parse_nextarchive()\r
1710         {\r
1711                 global $archivenext;\r
1712                 echo $archivenext;\r
1713                 return;\r
1714         }\r
1715         \r
1716         /**\r
1717          * Parse skinvar nextitem\r
1718          * (include itemid of next item)\r
1719          * \r
1720          * @param       void\r
1721          * @return      void\r
1722          */\r
1723         public function parse_nextitem()\r
1724         {\r
1725                 global $itemidnext;\r
1726                 if ( isset($itemidnext) )\r
1727                 {\r
1728                         echo (int)$itemidnext;\r
1729                 }\r
1730                 return;\r
1731         }\r
1732         \r
1733         /**\r
1734          * Actions::parse_nextitemtitle()\r
1735          * Parse skinvar nextitemtitle\r
1736          * (include itemtitle of next item)\r
1737          * \r
1738          * @param       string  $format format of text\r
1739          * @return      void\r
1740          */\r
1741         public function parse_nextitemtitle($format = '')\r
1742         {\r
1743                 global $itemtitlenext;\r
1744                 \r
1745                 switch ( $format )\r
1746                 {\r
1747                         case 'xml':\r
1748                                 echo Entity::hen($itemtitlenext);\r
1749                                 break;\r
1750                         case 'raw':\r
1751                                 echo $itemtitlenext;\r
1752                                 break;\r
1753                         case 'attribute':\r
1754                         default:\r
1755                                 echo Entity::hsc($itemtitlenext);\r
1756                                 break;\r
1757                 }\r
1758                 return;\r
1759         }\r
1760         \r
1761         /**\r
1762          * Actions::parse_nextlink()\r
1763          * Parse skinvar nextlink\r
1764          * \r
1765          * @param       string  $linktext       text for content of anchor element\r
1766          * @param       integer $amount         the amount of items in a display\r
1767          * @param       integer $recount        increment from this value\r
1768          * @return      void\r
1769          */\r
1770         public function parse_nextlink($linktext = '', $amount = 10, $recount = '')\r
1771         {\r
1772                 global $itemidnext, $archivenext, $startpos;\r
1773                 if ( $this->skintype == 'item' )\r
1774                 {\r
1775                         $this->itemlink($itemidnext, $linktext);\r
1776                 }\r
1777                 else if ( $this->skintype == 'search' || $this->skintype == 'index' )\r
1778                 {\r
1779                         $this->searchlink($amount, $startpos, 'next', $linktext, $recount);\r
1780                 }\r
1781                 else\r
1782                 {\r
1783                         $this->archivelink($archivenext, $linktext);\r
1784                 }\r
1785                 return;\r
1786         }\r
1787 \r
1788         /**\r
1789          * Actions::parse_nucleusbutton()\r
1790          * Parse skinvar nucleusbutton\r
1791          * \r
1792          * @param       string  $imgurl URL  for image\r
1793          * @param       integer $imgwidth       width of image\r
1794          * @param       integer $imgheidht      height of image\r
1795          */\r
1796         public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31')\r
1797         {\r
1798                 global $CONF;\r
1799                 if ( $imgurl == '' )\r
1800                 {\r
1801                         $imgurl = $CONF['AdminURL'] . 'nucleus.gif';\r
1802                 }\r
1803                 else if ( Parser::getProperty('IncludeMode') == 'skindir' )\r
1804                 {\r
1805                         // when skindit IncludeMode is used: start from skindir\r
1806                         $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;\r
1807                 }\r
1808                 \r
1809                 $this->formdata = array(\r
1810                         'imgurl' => $imgurl,\r
1811                         'imgwidth' => $imgwidth,\r
1812                         'imgheight' => $imgheight,\r
1813                 );\r
1814                 $this->doForm('nucleusbutton');\r
1815                 return;\r
1816         }\r
1817         \r
1818         /**\r
1819          * Actions::parse_otherarchive()\r
1820          * Parse skinvar otherarchive\r
1821          * \r
1822          * @param       string  $blogname       name of weblog\r
1823          * @param       string  $template       name of template\r
1824          * @param       string  $category       name of category\r
1825          * @return      void\r
1826          */     \r
1827         public function parse_otherarchive($blogname, $template, $category = '')\r
1828         {\r
1829                 global $archive, $manager;\r
1830                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
1831                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1832                 $this->setBlogCategory($b, $category);\r
1833                 $this->preBlogContent('otherachive',$b);\r
1834                 $b->showArchive($template, $y, $m, $d);\r
1835                 $this->postBlogContent('otherachive',$b);\r
1836                 return;\r
1837         }\r
1838         \r
1839         /**\r
1840          * Actions::parse_otherarchivedaylist()\r
1841          * Parse skinvar otherarchivedaylist\r
1842          * \r
1843          * @param       string  $blogname       name of weblog\r
1844          * @param       string  $template       name of template\r
1845          * @param       string  $category       name of category\r
1846          * @param       integer $limit          the amount of items in a display\r
1847          * @return      void\r
1848          */\r
1849         public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0)\r
1850         {\r
1851                 global $manager;\r
1852                 if ( $category == 'all')\r
1853                 {\r
1854                         $category = '';\r
1855                 }\r
1856                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1857                 $this->setBlogCategory($b, $category);\r
1858                 $this->preBlogContent('otherarchivelist',$b);\r
1859                 $b->showArchiveList($template, 'day', $limit);\r
1860                 $this->postBlogContent('otherarchivelist',$b);\r
1861                 return;\r
1862         }\r
1863         \r
1864         /**\r
1865          * Actions::parse_otherarchivelist()\r
1866          * Parse skinvar otherarchivelist\r
1867          * \r
1868          * @param       string  $blogname       name of weblog\r
1869          * @param       string  $template       name of template\r
1870          * @param       string  $category       name of category\r
1871          * @param       integer $limit          the amount of items in a display\r
1872          * @return      void\r
1873          */\r
1874         public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0)\r
1875         {\r
1876                 global $manager;\r
1877                 if ( $category == 'all' )\r
1878                 {\r
1879                         $category = '';\r
1880                 }\r
1881                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1882                 $this->setBlogCategory($b, $category);\r
1883                 $this->preBlogContent('otherarchivelist',$b);\r
1884                 $b->showArchiveList($template, 'month', $limit);\r
1885                 $this->postBlogContent('otherarchivelist',$b);\r
1886                 return;\r
1887         }\r
1888         \r
1889         /**\r
1890          * Actions::parse_otherarchiveyearlist()\r
1891          * Parse skinvar otherarchiveyearlist\r
1892          * \r
1893          * @param       string  $blogname       name of weblog\r
1894          * @param       string  $template       name of template\r
1895          * @param       string  $category       name of category\r
1896          * @limit       integer $limit          the amount of items in a display\r
1897          */\r
1898         public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0)\r
1899         {\r
1900                 global $manager;\r
1901                 if ( $category == 'all' )\r
1902                 {\r
1903                         $category = '';\r
1904                 }\r
1905                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1906                 $this->setBlogCategory($b, $category);\r
1907                 $this->preBlogContent('otherarchivelist',$b);\r
1908                 $b->showArchiveList($template, 'year', $limit);\r
1909                 $this->postBlogContent('otherarchivelist',$b);\r
1910                 return;\r
1911         }\r
1912         \r
1913         /**\r
1914          * Actions::parse_otherblog()\r
1915          * Parse skinvar otherblog\r
1916          * \r
1917          * @param       string  $blogname       name of weblog\r
1918          * @param       string  $template       name of template\r
1919          * @param       mixed   $amount         the amount of items, in case it includes the beginning\r
1920          * @param       string  $category       name of category\r
1921          * @return      void\r
1922          */\r
1923         public function parse_otherblog($blogname, $template, $amount = 10, $category = '')\r
1924         {\r
1925                 global $manager;\r
1926                 \r
1927                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
1928                 \r
1929                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1930                 $this->setBlogCategory($b, $category);\r
1931                 $this->preBlogContent('otherblog',$b);\r
1932                 $this->amountfound = $b->readLog($template, $limit, $offset);\r
1933                 $this->postBlogContent('otherblog',$b);\r
1934                 return;\r
1935         }\r
1936         \r
1937         /**\r
1938          * Actions::parse_othersearchresults()\r
1939          * Parse skinvar othersearchresults\r
1940          * \r
1941          * @param       string  $blogname       name of weblog\r
1942          * @param       string  $template       name of template\r
1943          * @param       integer $maxresults     the amount of results\r
1944          * @return      void\r
1945          */\r
1946         public function parse_othersearchresults($blogname, $template, $maxresults = 50)\r
1947         {\r
1948                 global $query, $amount, $manager, $startpos;\r
1949                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1950                 // need this to select default category\r
1951                 $this->setBlogCategory($b, '');\r
1952                 $this->preBlogContent('othersearchresults',$b);\r
1953                 $b->search($query, $template, $amount, $maxresults, $startpos);\r
1954                 $this->postBlogContent('othersearchresults',$b);\r
1955                 return;\r
1956         }\r
1957         \r
1958         /**\r
1959          * Actions::parse_plugin()\r
1960          * Executes a plugin skinvar\r
1961          * extra parameters can be added\r
1962          * \r
1963          * @param       string  $pluginName     name of plugin (without the NP_)\r
1964          * @return      void\r
1965          */\r
1966         public function parse_plugin($pluginName)\r
1967         {\r
1968                 global $manager;\r
1969                 \r
1970                 $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
1971                 if ( !$plugin )\r
1972                 {\r
1973                         return;\r
1974                 }\r
1975                 \r
1976                 // get arguments\r
1977                 $params = func_get_args();\r
1978                 \r
1979                 // remove plugin name\r
1980                 array_shift($params);\r
1981                 \r
1982                 // add skin type on front\r
1983                 array_unshift($params, $this->skintype);\r
1984                 \r
1985                 call_user_func_array(array(&$plugin,'doSkinVar'), $params);\r
1986                 return;\r
1987         }\r
1988         \r
1989         /**\r
1990          * Actions::parse_prevarchive()\r
1991          * Parse skinvar prevarchive\r
1992          * \r
1993          * @param       void\r
1994          * @return      void\r
1995          */\r
1996         public function parse_prevarchive()\r
1997         {\r
1998                 global $archiveprev;\r
1999                 echo $archiveprev;\r
2000         }\r
2001         \r
2002         /**\r
2003          * Actions::parse_preview()\r
2004          * Parse skinvar preview\r
2005          * \r
2006          * @param       string  $template       name of tempalte\r
2007          * @return      void\r
2008          */\r
2009         public function parse_preview($template)\r
2010         {\r
2011                 global $blog, $CONF, $manager;\r
2012                 \r
2013                 $template =& $manager->getTemplate($template);\r
2014                 \r
2015                 $row['body'] = '<span id="prevbody"></span>';\r
2016                 $row['title'] = '<span id="prevtitle"></span>';\r
2017                 $row['more'] = '<span id="prevmore"></span>';\r
2018                 $row['itemlink'] = '';\r
2019                 $row['itemid'] = 0; $row['blogid'] = $blog->getID();\r
2020                 \r
2021                 echo Template::fill($template['ITEM_HEADER'],$row);\r
2022                 echo Template::fill($template['ITEM'],$row);\r
2023                 echo Template::fill($template['ITEM_FOOTER'],$row);\r
2024                 return;\r
2025         }\r
2026         \r
2027         /**\r
2028          * Actions::parse_previtem()\r
2029          * Parse skinvar previtem\r
2030          * (include itemid of prev item)\r
2031          * \r
2032          * @param       void\r
2033          * @return      void\r
2034          */\r
2035         public function parse_previtem()\r
2036         {\r
2037                 global $itemidprev;\r
2038                 if ( isset($itemidprev) )\r
2039                 {\r
2040                         echo (integer) $itemidprev;\r
2041                 }\r
2042                 return;\r
2043         }\r
2044         \r
2045         /**\r
2046          * Actions::parse_previtemtitle()\r
2047          * Parse skinvar previtemtitle\r
2048          * (include itemtitle of prev item)\r
2049          * \r
2050          * @param       String  $format string format\r
2051          * @return      String  formatted string\r
2052          */\r
2053         public function parse_previtemtitle($format = '')\r
2054         {\r
2055                 global $itemtitleprev;\r
2056                 \r
2057                 switch ( $format )\r
2058                 {\r
2059                         case 'xml':\r
2060                                 echo Entity::hen($itemtitleprev);\r
2061                                 break;\r
2062                         case 'raw':\r
2063                                 echo $itemtitleprev;\r
2064                                 break;\r
2065                         case 'attribute':\r
2066                         default:\r
2067                                 echo Entity::hsc($itemtitleprev);\r
2068                                 break;\r
2069                 }\r
2070                 return;\r
2071         }\r
2072         \r
2073         /**\r
2074          * Actions::parse_prevlink()\r
2075          * Parse skinvar prevlink\r
2076          * \r
2077          * @param       string  $linktext       text as a content of anchor element\r
2078          * @param       integer the amount of links\r
2079          * @return      void\r
2080          */\r
2081         public function parse_prevlink($linktext = '', $amount = 10)\r
2082         {\r
2083                 global $itemidprev, $archiveprev, $startpos;\r
2084                 \r
2085                 if ( $this->skintype == 'item' )\r
2086                 {\r
2087                         $this->itemlink($itemidprev, $linktext);\r
2088                 }\r
2089                 else if ( $this->skintype == 'search' || $this->skintype == 'index' )\r
2090                 {\r
2091                         $this->searchlink($amount, $startpos, 'prev', $linktext);\r
2092                 }\r
2093                 else\r
2094                 {\r
2095                         $this->archivelink($archiveprev, $linktext);\r
2096                 }\r
2097                 return;\r
2098         }\r
2099         \r
2100         /**\r
2101          * Actions::parse_query()\r
2102          * Parse skinvar query\r
2103          * (includes the search query)   \r
2104          * \r
2105          * @param       void\r
2106          * @return      void\r
2107          */\r
2108         public function parse_query()\r
2109         {\r
2110                 global $query;\r
2111                 echo Entity::hsc($query);\r
2112                 return;\r
2113         }\r
2114         \r
2115         /**\r
2116          * Actions::parse_referer()\r
2117          * Parse skinvar referer\r
2118          * \r
2119          * @param       void\r
2120          * @return      void\r
2121          */\r
2122         public function parse_referer()\r
2123         {\r
2124                 echo Entity::hsc(serverVar('HTTP_REFERER'));\r
2125                 return;\r
2126         }\r
2127         \r
2128         /**\r
2129          * Actions::parse_searchform()\r
2130          * Parse skinvar searchform\r
2131          * \r
2132          * @param       string  $blogname       name of weblog\r
2133          * @return      void\r
2134          */\r
2135         public function parse_searchform($blogname = '')\r
2136         {\r
2137                 global $CONF, $manager, $maxresults;\r
2138                 if ( $blogname )\r
2139                 {\r
2140                         $blog =& $manager->getBlog(getBlogIDFromName($blogname));\r
2141                 }\r
2142                 else\r
2143                 {\r
2144                         global $blog;\r
2145                 }\r
2146                 // use default blog when no blog is selected\r
2147                 $this->formdata = array(\r
2148                         'id'    => $blog?$blog->getID():$CONF['DefaultBlog'],\r
2149                         'query' => Entity::hsc(getVar('query')),\r
2150                 );\r
2151                 $this->doForm('searchform');\r
2152                 return;\r
2153         }\r
2154         \r
2155         /**\r
2156          * Actions::parse_searchresults()\r
2157          * Parse skinvar searchresults\r
2158          * \r
2159          * @param       string  $template       name of tempalte\r
2160          * @param       integer $maxresults     searched items in a display\r
2161          * @return      void;\r
2162          */\r
2163         public function parse_searchresults($template, $maxresults = 50 )\r
2164         {\r
2165                 global $blog, $query, $amount, $startpos;\r
2166                 \r
2167                 $this->setBlogCategory($blog, '');      // need this to select default category\r
2168                 $this->preBlogContent('searchresults',$blog);\r
2169                 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);\r
2170                 $this->postBlogContent('searchresults',$blog);\r
2171                 return;\r
2172         }\r
2173         \r
2174         /**\r
2175          * Actions::parse_self()\r
2176          * Parse skinvar self\r
2177          * \r
2178          * @param       void\r
2179          * @return      void\r
2180          */\r
2181         public function parse_self()\r
2182         {\r
2183                 global $CONF;\r
2184                 echo $CONF['Self'];\r
2185                 return;\r
2186         }\r
2187         \r
2188         /**\r
2189          * Actions::parse_sitevar()\r
2190          * Parse skinvar sitevar\r
2191          * (include a sitevar)\r
2192          * \r
2193          * @param       string  $which\r
2194          * @return      void\r
2195          */\r
2196         public function parse_sitevar($which)\r
2197         {\r
2198                 global $CONF;\r
2199                 switch ( $which )\r
2200                 {\r
2201                         case 'url':\r
2202                                 echo $CONF['IndexURL'];\r
2203                                 break;\r
2204                         case 'name':\r
2205                                 echo $CONF['SiteName'];\r
2206                                 break;\r
2207                         case 'admin':\r
2208                                 echo $CONF['AdminEmail'];\r
2209                                 break;\r
2210                         case 'adminurl':\r
2211                                 echo $CONF['AdminURL'];\r
2212                 }\r
2213                 return;\r
2214         }\r
2215         \r
2216         /**\r
2217          * Actions::parse_skinname()\r
2218          * Parse skinname\r
2219          * \r
2220          * @param       void\r
2221          * @return      void\r
2222          */\r
2223         public function parse_skinname()\r
2224         {\r
2225                 echo $this->skin->getName();\r
2226                 return;\r
2227         }\r
2228         \r
2229         /**\r
2230          * Actions::parse_skintype()\r
2231          * Parse skintype (experimental)\r
2232          * \r
2233          * @param       void\r
2234          * @return      void\r
2235          */\r
2236         public function parse_skintype()\r
2237         {\r
2238                 echo $this->skintype;\r
2239                 return;\r
2240         }\r
2241         \r
2242         /**\r
2243          * Actions::parse_text()\r
2244          * Parse text\r
2245          * \r
2246          * @param       void\r
2247          * @return      void\r
2248          */\r
2249         public function parse_text($which)\r
2250         {\r
2251                 // constant($which) only available from 4.0.4 :(\r
2252                 if ( defined($which) )\r
2253                 {\r
2254                         eval("echo $which;");\r
2255                 }\r
2256                 return;\r
2257         }\r
2258         \r
2259         /**\r
2260          * Actions::parse_ticket()\r
2261          * Parse ticket\r
2262          * \r
2263          * @param       void\r
2264          * @return      void\r
2265          */\r
2266         public function parse_ticket()\r
2267         {\r
2268                 global $manager;\r
2269                 $manager->addTicketHidden();\r
2270                 return;\r
2271         }\r
2272 \r
2273         /**\r
2274          * Actions::parse_todaylink()\r
2275          * Parse skinvar todaylink\r
2276          * A link to the today page (depending on selected blog, etc...)\r
2277          *\r
2278          * @param       string  $linktext       text for link\r
2279          * @return      void\r
2280          */\r
2281         public function parse_todaylink($linktext = '')\r
2282         {\r
2283                 global $blog, $CONF;\r
2284                 if ( $blog )\r
2285                 {\r
2286                         echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);\r
2287                 }\r
2288                 else\r
2289                 {\r
2290                         echo $this->link($CONF['SiteUrl'], $linktext);\r
2291                 }\r
2292                 return;\r
2293         }\r
2294         \r
2295         /**\r
2296          * Parse vars\r
2297          * When commentform is not used, to include a hidden field with itemid   \r
2298          * \r
2299          * @param       void\r
2300          * @return      void\r
2301          */\r
2302         public function parse_vars()\r
2303         {\r
2304                 global $itemid;\r
2305                 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />' . "\n";\r
2306                 return;\r
2307         }\r
2308 \r
2309         /**\r
2310          * Actions::parse_version()\r
2311          * Parse skinvar version\r
2312          * (include nucleus versionnumber)       \r
2313          * \r
2314          * @param       void\r
2315          * @return      void\r
2316          */\r
2317         public function parse_version()\r
2318         {\r
2319                 global $nucleus;\r
2320                 echo 'Nucleus CMS ' . $nucleus['version'];\r
2321                 return;\r
2322         }\r
2323         \r
2324         /**\r
2325          * Actions::parse_sticky()\r
2326          * Parse skinvar sticky\r
2327          * \r
2328          * @param       integer $itemnumber     id of item\r
2329          * @param       string  $template       name of template\r
2330          * @return      void\r
2331          */\r
2332         public function parse_sticky($itemnumber = 0, $template = '')\r
2333         {\r
2334                 global $manager;\r
2335                 \r
2336                 $itemnumber = intval($itemnumber);\r
2337                 $itemarray = array($itemnumber);\r
2338                 \r
2339                 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));\r
2340                 $this->preBlogContent('sticky',$b);\r
2341                 $this->amountfound = $b->readLogFromList($itemarray, $template);\r
2342                 $this->postBlogContent('sticky',$b);\r
2343                 return;\r
2344         }\r
2345 }\r