OSDN Git Service

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