OSDN Git Service

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