OSDN Git Service

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