OSDN Git Service

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