OSDN Git Service

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