OSDN Git Service

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