OSDN Git Service

コピーライト表示部分の年度変更
[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 1721 2012-03-31 10:18:25Z 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          * Constructor for a new Actions object\r
47          */\r
48         function Actions($type) {\r
49                 // call constructor of superclass first\r
50                 $this->BaseActions();\r
51 \r
52                 $this->skintype = $type;\r
53 \r
54                 global $catid;\r
55                 if ($catid)\r
56                         $this->linkparams = array('catid' => $catid);\r
57         }\r
58 \r
59         /**\r
60          *  Set the skin\r
61          */\r
62         function setSkin(&$skin) {\r
63                 $this->skin =& $skin;\r
64         }\r
65 \r
66         /**\r
67          *  Set the parser\r
68          */\r
69         function setParser(&$parser) {\r
70                 $this->parser =& $parser;\r
71         }\r
72 \r
73         /**\r
74          *      Forms get parsedincluded now, using an extra <formdata> skinvar\r
75         */\r
76         function doForm($filename) {\r
77                 global $DIR_NUCLEUS;\r
78                 array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');\r
79                 $oldIncludeMode = Parser::getProperty('IncludeMode');\r
80                 $oldIncludePrefix = Parser::getProperty('IncludePrefix');\r
81                 Parser::setProperty('IncludeMode','normal');\r
82                 Parser::setProperty('IncludePrefix','');\r
83                 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');\r
84                 Parser::setProperty('IncludeMode',$oldIncludeMode);\r
85                 Parser::setProperty('IncludePrefix',$oldIncludePrefix);\r
86                 array_pop($this->parser->actions);              // errordiv\r
87                 array_pop($this->parser->actions);              // callback\r
88                 array_pop($this->parser->actions);              // text\r
89                 array_pop($this->parser->actions);              // formdata\r
90                 array_pop($this->parser->actions);              // ticket\r
91         }\r
92 \r
93         /**\r
94          * Checks conditions for if statements\r
95          *\r
96          * @param string $field type of <%if%>\r
97          * @param string $name property of field\r
98          * @param string $value value of property\r
99          */\r
100         function checkCondition($field, $name='', $value = '') {\r
101                 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
102 \r
103                 $condition = 0;\r
104                 switch($field) {\r
105                         case 'category':\r
106                                 $condition = ($blog && $this->_ifCategory($name,$value));\r
107                                 break;\r
108                         case 'blogsetting':\r
109                                 $condition = ($blog && ($blog->getSetting($name) == $value));\r
110                                 break;\r
111                         case 'loggedin':\r
112                                 $condition = $member->isLoggedIn();\r
113                                 break;\r
114                         case 'onteam':\r
115                                 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);\r
116                                 break;\r
117                         case 'admin':\r
118                                 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);\r
119                                 break;\r
120                         case 'nextitem':\r
121                                 $condition = ($itemidnext != '');\r
122                                 break;\r
123                         case 'previtem':\r
124                                 $condition = ($itemidprev != '');\r
125                                 break;\r
126                         case 'archiveprevexists':\r
127                                 $condition = ($archiveprevexists == true);\r
128                                 break;\r
129                         case 'archivenextexists':\r
130                                 $condition = ($archivenextexists == true);\r
131                                 break;\r
132                         case 'skintype':\r
133                                 $condition = ($name == $this->skintype);\r
134                                 break;\r
135                         case 'hasplugin':\r
136                                 $condition = $this->_ifHasPlugin($name, $value);\r
137                                 break;\r
138                         default:\r
139                                 $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);\r
140                                 break;\r
141                 }\r
142                 return $condition;\r
143         }\r
144 \r
145         /**\r
146          *      hasplugin,PlugName\r
147          *         -> checks if plugin exists\r
148          *      hasplugin,PlugName,OptionName\r
149          *         -> checks if the option OptionName from plugin PlugName is not set to 'no'\r
150          *      hasplugin,PlugName,OptionName=value\r
151          *         -> checks if the option OptionName from plugin PlugName is set to value\r
152          */\r
153         function _ifHasPlugin($name, $value) {\r
154                 global $manager;\r
155                 $condition = false;\r
156                 // (pluginInstalled method won't write a message in the actionlog on failure)\r
157                 if ($manager->pluginInstalled('NP_'.$name)) {\r
158                         $plugin =& $manager->getPlugin('NP_' . $name);\r
159                         if ($plugin != NULL) {\r
160                                 if ($value == "") {\r
161                                         $condition = true;\r
162                                 } else {\r
163                                         list($name2, $value2) = i18n::explode('=', $value, 2);\r
164                                         if ($value2 == "" && $plugin->getOption($name2) != 'no') {\r
165                                                 $condition = true;\r
166                                         } else if ($plugin->getOption($name2) == $value2) {\r
167                                                 $condition = true;\r
168                                         }\r
169                                 }\r
170                         }\r
171                 }\r
172                 return $condition;\r
173         }\r
174 \r
175         /**\r
176          * Checks if a plugin exists and call its doIf function\r
177          */\r
178         function _ifPlugin($name, $key = '', $value = '') {\r
179                 global $manager;\r
180 \r
181                 $plugin =& $manager->getPlugin('NP_' . $name);\r
182                 if (!$plugin) return;\r
183 \r
184                 $params = func_get_args();\r
185                 array_shift($params);\r
186 \r
187                 return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
188         }\r
189 \r
190         /**\r
191          *  Different checks for a category\r
192          */\r
193         function _ifCategory($name = '', $value='') {\r
194                 global $blog, $catid;\r
195 \r
196                 // when no parameter is defined, just check if a category is selected\r
197                 if (($name != 'catname' && $name != 'catid') || ($value == ''))\r
198                         return $blog->isValidCategory($catid);\r
199 \r
200                 // check category name\r
201                 if ($name == 'catname') {\r
202                         $value = $blog->getCategoryIdFromName($value);\r
203                         if ($value == $catid)\r
204                                 return $blog->isValidCategory($catid);\r
205                 }\r
206 \r
207                 // check category id\r
208                 if (($name == 'catid') && ($value == $catid))\r
209                         return $blog->isValidCategory($catid);\r
210 \r
211                 return false;\r
212         }\r
213 \r
214         /**\r
215          *  Checks if a member is on the team of a blog and return his rights\r
216          */\r
217         function _ifOnTeam($blogName = '') {\r
218                 global $blog, $member, $manager;\r
219 \r
220                 // when no blog found\r
221                 if (($blogName == '') && (!is_object($blog)))\r
222                         return 0;\r
223 \r
224                 // explicit blog selection\r
225                 if ($blogName != '')\r
226                         $blogid = getBlogIDFromName($blogName);\r
227 \r
228                 if (($blogName == '') || !$manager->existsBlogID($blogid))\r
229                         // use current blog\r
230                         $blogid = $blog->getID();\r
231 \r
232                 return $member->teamRights($blogid);\r
233         }\r
234 \r
235         /**\r
236          *  Checks if a member is admin of a blog\r
237          */\r
238         function _ifAdmin($blogName = '') {\r
239                 global $blog, $member, $manager;\r
240 \r
241                 // when no blog found\r
242                 if (($blogName == '') && (!is_object($blog)))\r
243                         return 0;\r
244 \r
245                 // explicit blog selection\r
246                 if ($blogName != '')\r
247                         $blogid = getBlogIDFromName($blogName);\r
248 \r
249                 if (($blogName == '') || !$manager->existsBlogID($blogid))\r
250                         // use current blog\r
251                         $blogid = $blog->getID();\r
252 \r
253                 return $member->isBlogAdmin($blogid);\r
254         }\r
255         \r
256         /**\r
257          * returns either\r
258          *              - a raw link (html/xml encoded) when no linktext is provided\r
259          *              - a (x)html <a href... link when a text is present (text htmlencoded)\r
260          */\r
261         function _link($url, $linktext = '')\r
262         {\r
263                 $u = Entity::hsc($url);\r
264                 $u = preg_replace("/&amp;amp;/",'&amp;',$u); // fix URLs that already had encoded ampersands\r
265                 if ($linktext != '') \r
266                         $l = '<a href="' . $u .'">'.Entity::hsc($linktext).'</a>';\r
267                 else\r
268                         $l = $u;\r
269                 return $l;\r
270         }\r
271         \r
272         /**\r
273          * Outputs a next/prev link\r
274          *\r
275          * @param $maxresults\r
276          *              The maximum amount of items shown per page (e.g. 10)\r
277          * @param $startpos\r
278          *              Current start position (requestVar('startpos'))\r
279          * @param $direction\r
280          *              either 'prev' or 'next'\r
281          * @param $linktext\r
282          *              When present, the output will be a full <a href...> link. When empty,\r
283          *              only a raw link will be outputted\r
284          */\r
285         function _searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '') {\r
286                 global $CONF, $blog, $query, $amount;\r
287                 // TODO: Move request uri to linkparams. this is ugly. sorry for that.\r
288                 $startpos       = intval($startpos);            // will be 0 when empty.\r
289                 $parsed         = parse_url(serverVar('REQUEST_URI'));\r
290                 $path           = $parsed['path'];\r
291                 $parsed         = $parsed['query'];\r
292                 $url            = '';\r
293                 \r
294                 switch ($direction) {\r
295                         case 'prev':\r
296                                 if ( intval($startpos) - intval($maxresults) >= 0) {\r
297                                         $startpos       = intval($startpos) - intval($maxresults);\r
298                                         //$url          = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);\r
299                                         switch ($this->skintype)\r
300                                         {\r
301                                                 case 'index':\r
302                                                         $url = $path;\r
303                                                         break;\r
304                                                 case 'search':\r
305                                                         $url = $CONF['SearchURL'];\r
306                                                         break;\r
307                                         }\r
308                                         $url .= '?'.alterQueryStr($parsed,'startpos',$startpos);\r
309                                 }\r
310                                 \r
311                                 break;\r
312                         case 'next':\r
313                                 global $navigationItems;\r
314                                 if (!isset($navigationItems)) $navigationItems = 0;\r
315                                 \r
316                                 if ($recount)\r
317                                         $iAmountOnPage = 0;\r
318                                 else \r
319                                         $iAmountOnPage = $this->amountfound;\r
320                                 \r
321                                 if (intval($navigationItems) > 0) {\r
322                                         $iAmountOnPage = intval($navigationItems) - intval($startpos);\r
323                                 }\r
324                                 elseif ($iAmountOnPage == 0)\r
325                                 {\r
326                                         // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]\r
327                                         // try a count query\r
328                                         switch ($this->skintype)\r
329                                         {\r
330                                                 case 'index':\r
331                                                         $sqlquery = $blog->getSqlBlog('', 'count');\r
332                                                         $url = $path;\r
333                                                         break;\r
334                                                 case 'search':\r
335                                                         $unused_highlight = '';\r
336                                                         $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');\r
337                                                         $url = $CONF['SearchURL'];\r
338                                                         break;\r
339                                         }\r
340                                         if ($sqlquery)\r
341                                                 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);\r
342                                 }\r
343                                 \r
344                                 if (intval($iAmountOnPage) >= intval($maxresults)) {\r
345                                         $startpos       = intval($startpos) + intval($maxresults);\r
346                                         //$url          = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);\r
347                                         $url            .= '?'.alterQueryStr($parsed,'startpos',$startpos);\r
348                                 }\r
349                                 else $url = '';\r
350                                 break;\r
351                         default:\r
352                                 break;\r
353                 } // switch($direction)\r
354 \r
355                 if ($url != '')\r
356                         echo $this->_link($url, $linktext);\r
357         }\r
358 \r
359         /**\r
360          * Actions::_itemlink()\r
361          * Creates an item link and if no id is given a todaylink \r
362          * \r
363          * @param       Integer $id     id for link\r
364          * @param       String  $linktext       text for link\r
365          * @return      Void\r
366          */\r
367         function _itemlink($id, $linktext = '')\r
368         {\r
369                 global $CONF;\r
370                 if ( $id )\r
371                 {\r
372                         echo $this->_link(Link::create_item_link($id, $this->linkparams), $linktext);\r
373                 }\r
374                 else\r
375                 {\r
376                         $this->parse_todaylink($linktext);\r
377                 }\r
378                 return;\r
379         }\r
380         \r
381         /**\r
382          * Actions::_archivelink)\r
383          * Creates an archive link and if no id is given a todaylink \r
384          * \r
385          * @param       Integer $id     id for link\r
386          * @param       String  $linktext       text for link\r
387          * @return      Void\r
388          */\r
389         function _archivelink($id, $linktext = '')\r
390         {\r
391                 global $CONF, $blog;\r
392                 if ( $id )\r
393                 {\r
394                         echo $this->_link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext);\r
395                 }\r
396                 else\r
397                 {\r
398                         $this->parse_todaylink($linktext);\r
399                 }\r
400                 return;\r
401         }\r
402         \r
403         /**\r
404           * Helper function that sets the category that a blog will need to use\r
405           *\r
406           * @param $blog\r
407           *             An object of the blog class, passed by reference (we want to make changes to it)\r
408           * @param $catname\r
409           *             The name of the category to use\r
410           */\r
411         function _setBlogCategory(&$blog, $catname) {\r
412                 global $catid;\r
413                 if ($catname != '')\r
414                         $blog->setSelectedCategoryByName($catname);\r
415                 else\r
416                         $blog->setSelectedCategory($catid);\r
417         }\r
418 \r
419         /**\r
420          *  Notifies the Manager that a PreBlogContent event occurs\r
421          */\r
422         function _preBlogContent($type, &$blog) {\r
423                 global $manager;\r
424                 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));\r
425         }\r
426 \r
427         /**\r
428          *  Notifies the Manager that a PostBlogContent event occurs\r
429          */\r
430         function _postBlogContent($type, &$blog) {\r
431                 global $manager;\r
432                 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));\r
433         }\r
434         \r
435         /**\r
436          * Parse skinvar additemform\r
437          */\r
438         function parse_additemform() {\r
439                 global $blog, $CONF;\r
440                 $this->formdata = array(\r
441                         'adminurl' => Entity::hsc($CONF['AdminURL']),\r
442                         'catid' => $blog->getDefaultCategory()\r
443                 );\r
444                 $blog->InsertJavaScriptInfo();\r
445                 $this->doForm('additemform');\r
446         }\r
447         \r
448         /**\r
449          * Parse skinvar addlink\r
450          * A Link that allows to open a bookmarklet to add an item\r
451          */\r
452         function parse_addlink() {\r
453                 global $CONF, $member, $blog;\r
454                 if ($member->isLoggedIn() && $member->isTeamMember($blog->blogid) ) {\r
455                         echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid;\r
456                 }\r
457         }\r
458         \r
459         /**\r
460          * Parse skinvar addpopupcode\r
461          * Code that opens a bookmarklet in an popup window\r
462          */\r
463         function parse_addpopupcode() {\r
464                 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
465         }\r
466         \r
467         /**\r
468          * Parse skinvar adminurl\r
469          * (shortcut for admin url)      \r
470          */\r
471         function parse_adminurl() {\r
472                 $this->parse_sitevar('adminurl');\r
473         }\r
474 \r
475         /**\r
476          * Parse skinvar archive\r
477          */\r
478         function parse_archive($template, $category = '') {\r
479                 global $blog, $archive;\r
480                 // can be used with either yyyy-mm or yyyy-mm-dd\r
481                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
482                 $this->_setBlogCategory($blog, $category);\r
483                 $this->_preBlogContent('achive',$blog);\r
484                 $blog->showArchive($template, $y, $m, $d);\r
485                 $this->_postBlogContent('achive',$blog);\r
486 \r
487         }\r
488 \r
489         /**\r
490          * Actions::parse_archivedate()\r
491          * %archivedate(locale,date format)%\r
492          * \r
493          * @paramstring $locale\r
494          * @return      void\r
495          * \r
496           */\r
497         function parse_archivedate($locale = '-def-')\r
498         {\r
499                 global $archive;\r
500                 \r
501                 /* \r
502                  * these lines are no meaning because there is no $template.\r
503                  */\r
504                 if ( $locale == '-def-' )\r
505                 {\r
506                         setlocale(LC_TIME,$template['LOCALE']);\r
507                 }\r
508                 else\r
509                 {\r
510                         setlocale(LC_TIME,$locale);\r
511                 }\r
512                 \r
513                 // get archive date\r
514                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
515                 \r
516                 // get format\r
517                 $args = func_get_args();\r
518                 // format can be spread over multiple parameters\r
519                 if ( sizeof($args) > 1 )\r
520                 {\r
521                         // take away locale\r
522                         array_shift($args);\r
523                         // implode\r
524                         $format=implode(',',$args);\r
525                 }\r
526                 elseif ( $d == 0 && $m !=0 )\r
527                 {\r
528                         $format = '%B %Y';\r
529                 }\r
530                 elseif ( $m == 0 )\r
531                 {\r
532                         $format = '%Y';\r
533                 }\r
534                 else\r
535                 {\r
536                         $format = '%d %B %Y';\r
537                 }\r
538                 echo i18n::formatted_timedate($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y));\r
539                 return;\r
540         }\r
541 \r
542         /**\r
543          *  Parse skinvar archivedaylist\r
544          */             \r
545         function parse_archivedaylist($template, $category = 'all', $limit = 0) {\r
546                 global $blog;\r
547                 if ($category == 'all') $category = '';\r
548                 $this->_preBlogContent('archivelist',$blog);\r
549                 $this->_setBlogCategory($blog, $category);\r
550                 $blog->showArchiveList($template, 'day', $limit);\r
551                 $this->_postBlogContent('archivelist',$blog);\r
552         }\r
553         \r
554         /**\r
555          * Actions::parse_archivelink()\r
556          *      A link to the archives for the current blog (or for default blog)\r
557          *\r
558          * @param       String  $linktext       text for link\r
559          * @return      Void\r
560          */\r
561         function parse_archivelink($linktext = '')\r
562         {\r
563                 global $blog, $CONF;\r
564                 if ( $blog )\r
565                 {\r
566                         echo $this->_link(Link::create_archivelist_link($blog->getID(),$this->linkparams), $linktext);\r
567                 }\r
568                 else\r
569                 {\r
570                         echo $this->_link(Link::create_archivelist_link(), $linktext);\r
571                 }\r
572                 return;\r
573         }\r
574         \r
575         function parse_archivelist($template, $category = 'all', $limit = 0) {\r
576                 global $blog;\r
577                 if ($category == 'all') $category = '';\r
578                 $this->_preBlogContent('archivelist',$blog);\r
579                 $this->_setBlogCategory($blog, $category);\r
580                 $blog->showArchiveList($template, 'month', $limit);\r
581                 $this->_postBlogContent('archivelist',$blog);\r
582         }\r
583                 \r
584         function parse_archiveyearlist($template, $category = 'all', $limit = 0) {\r
585                 global $blog;\r
586                 if ($category == 'all') $category = '';\r
587                 $this->_preBlogContent('archivelist',$blog);\r
588                 $this->_setBlogCategory($blog, $category);\r
589                 $blog->showArchiveList($template, 'year', $limit);\r
590                 $this->_postBlogContent('archivelist',$blog);\r
591         }\r
592         \r
593         /**\r
594          * Parse skinvar archivetype\r
595          */\r
596         function parse_archivetype() {\r
597                 global $archivetype;\r
598                 echo $archivetype;\r
599         }\r
600 \r
601         /**\r
602          * Parse skinvar blog\r
603          */\r
604         function parse_blog($template, $amount = 10, $category = '') {\r
605                 global $blog, $startpos;\r
606 \r
607                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
608                 $this->_setBlogCategory($blog, $category);\r
609                 $this->_preBlogContent('blog',$blog);\r
610                 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);\r
611                 $this->_postBlogContent('blog',$blog);\r
612         }\r
613         \r
614         /*\r
615         *       Parse skinvar bloglist\r
616         *       Shows a list of all blogs\r
617         *       bnametype: whether 'name' or 'shortname' is used for the link text        \r
618         *       orderby: order criteria\r
619         *       direction: order ascending or descending                  \r
620         */\r
621         function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') {\r
622                 Blog::showBlogList($template, $bnametype, $orderby, $direction);\r
623         }\r
624         \r
625         /**\r
626          * Parse skinvar blogsetting\r
627          */\r
628         function parse_blogsetting($which) {\r
629                 global $blog;\r
630                 switch($which) {\r
631                         case 'id':\r
632                                 echo Entity::hsc($blog->getID());\r
633                                 break;\r
634                         case 'url':\r
635                                 echo Entity::hsc($blog->getURL());\r
636                                 break;\r
637                         case 'name':\r
638                                 echo Entity::hsc($blog->getName());\r
639                                 break;\r
640                         case 'desc':\r
641                                 echo Entity::hsc($blog->getDescription());\r
642                                 break;\r
643                         case 'short':\r
644                                 echo Entity::hsc($blog->getShortName());\r
645                                 break;\r
646                 }\r
647         }\r
648         \r
649         /**\r
650          * Parse callback\r
651          */\r
652         function parse_callback($eventName, $type)\r
653         {\r
654                 global $manager;\r
655                 $manager->notify($eventName, array('type' => $type));\r
656         }\r
657         \r
658         /**\r
659          * Parse skinvar category\r
660          */\r
661         function parse_category($type = 'name') {\r
662                 global $catid, $blog;\r
663                 if (!$blog->isValidCategory($catid))\r
664                         return;\r
665 \r
666                 switch($type) {\r
667                         case 'name':\r
668                                 echo $blog->getCategoryName($catid);\r
669                                 break;\r
670                         case 'desc':\r
671                                 echo $blog->getCategoryDesc($catid);\r
672                                 break;\r
673                         case 'id':\r
674                                 echo $catid;\r
675                                 break;\r
676                 }\r
677         }\r
678         \r
679         /**\r
680          * Parse categorylist\r
681          */\r
682         function parse_categorylist($template, $blogname = '') {\r
683                 global $blog, $manager;\r
684 \r
685                 // when no blog found\r
686                 if (($blogname == '') && (!is_object($blog)))\r
687                         return 0;\r
688                         \r
689                 if ($blogname == '') {\r
690                         $this->_preBlogContent('categorylist',$blog);\r
691                         $blog->showCategoryList($template);\r
692                         $this->_postBlogContent('categorylist',$blog);\r
693                 } else {\r
694                         $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
695                         $this->_preBlogContent('categorylist',$b);\r
696                         $b->showCategoryList($template);\r
697                         $this->_postBlogContent('categorylist',$b);\r
698                 }\r
699         }\r
700         \r
701         /**\r
702          * Parse skinvar charset\r
703          */\r
704         function parse_charset() {\r
705                 echo i18n::get_current_charset();\r
706         }\r
707         \r
708         /**\r
709          * Actions::parse_commentform()\r
710          * Parse skinvar commentform\r
711          * \r
712          * @param       String  $destinationurl URI for redirection\r
713          * @return      Void\r
714          */\r
715         function parse_commentform($destinationurl = '')\r
716         {\r
717                 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;\r
718                 \r
719                 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)\r
720                 if ( stristr($destinationurl, 'action.php') )\r
721                 {\r
722                         $args = func_get_args();\r
723                         $destinationurl = $args[1];\r
724                         ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER);\r
725                 }\r
726                 \r
727                 $actionurl = $CONF['ActionURL'];\r
728                 \r
729                 // if item is closed, show message and do nothing\r
730                 $item =& $manager->getItem($itemid,0,0);\r
731                 if ( $item['closed'] || !$blog->commentsEnabled() )\r
732                 {\r
733                         $this->doForm('commentform-closed');\r
734                         return;\r
735                 }\r
736                 \r
737                 if ( !$blog->isPublic() && !$member->isLoggedIn() )\r
738                 {\r
739                         $this->doForm('commentform-closedtopublic');\r
740                         return;\r
741                 }\r
742                 \r
743                 if ( !$destinationurl )\r
744                 {\r
745                         // note: createLink returns an HTML encoded URL\r
746                         $destinationurl = Link::create_link(\r
747                                 'item',\r
748                                 array(\r
749                                         'itemid' => $itemid,\r
750                                         'title' => $item['title'],\r
751                                         'timestamp' => $item['timestamp'],\r
752                                         'extra' => $this->linkparams\r
753                                 )\r
754                         );\r
755                 }\r
756                 else\r
757                 {\r
758                         // HTML encode URL\r
759                         $destinationurl = Entity::hsc($destinationurl);\r
760                 }\r
761                 \r
762                 // values to prefill\r
763                 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');\r
764                 if ( !$user )\r
765                 {\r
766                         $user = postVar('user');\r
767                 }\r
768                 \r
769                 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');\r
770                 if ( !$userid )\r
771                 {\r
772                         $userid = postVar('userid');\r
773                 }\r
774                 \r
775                 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');\r
776                 if (!$email)\r
777                 {\r
778                         $email = postVar('email');\r
779                 }\r
780                 \r
781                 $body = postVar('body');\r
782                 \r
783                 $this->formdata = array(\r
784                         'destinationurl' => $destinationurl,    // url is already HTML encoded\r
785                         'actionurl' => Entity::hsc($actionurl),\r
786                         'itemid' => $itemid,\r
787                         'user' => Entity::hsc($user),\r
788                         'userid' => Entity::hsc($userid),\r
789                         'email' => Entity::hsc($email),\r
790                         'body' => Entity::hsc($body),\r
791                         'membername' => $member->getDisplayName(),\r
792                         'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''\r
793                 );\r
794                 \r
795                 if ( !$member->isLoggedIn() )\r
796                 {\r
797                         $this->doForm('commentform-notloggedin');\r
798                 }\r
799                 else\r
800                 {\r
801                         $this->doForm('commentform-loggedin');\r
802                 }\r
803                 return;\r
804         }\r
805         \r
806         /**\r
807          * Parse skinvar comments\r
808          * include comments for one item         \r
809          */\r
810         function parse_comments($template) {\r
811                 global $itemid, $manager, $blog, $highlight;\r
812                 $template =& $manager->getTemplate($template);\r
813 \r
814                 // create parser object & action handler\r
815                 $actions = new ItemActions($blog);\r
816                 $parser = new Parser($actions->getDefinedActions(),$actions);\r
817                 $actions->setTemplate($template);\r
818                 $actions->setParser($parser);\r
819                 $item = Item::getitem($itemid, 0, 0);\r
820                 $actions->setCurrentItem($item);\r
821 \r
822                 $comments = new Comments($itemid);\r
823                 $comments->setItemActions($actions);\r
824                 $comments->showComments($template, -1, 1, $highlight);  // shows ALL comments\r
825         }\r
826 \r
827         /**\r
828          * Parse errordiv\r
829          */\r
830         function parse_errordiv() {\r
831                 global $errormessage;\r
832                 if ($errormessage)\r
833                         echo '<div class="error">', Entity::hsc($errormessage),'</div>';\r
834         }\r
835         \r
836         /**\r
837          * Parse skinvar errormessage\r
838          */\r
839         function parse_errormessage() {\r
840                 global $errormessage;\r
841                 echo $errormessage;\r
842         }\r
843         \r
844         /**\r
845          * Parse formdata\r
846          */\r
847         function parse_formdata($what) {\r
848                 echo $this->formdata[$what];\r
849         }\r
850         \r
851         /**\r
852          * Parse ifcat\r
853          */\r
854         function parse_ifcat($text = '') {\r
855                 if ($text == '') {\r
856                         // new behaviour\r
857                         $this->parse_if('category');\r
858                 } else {\r
859                         // old behaviour\r
860                         global $catid, $blog;\r
861                         if ($blog->isValidCategory($catid))\r
862                                 echo $text;\r
863                 }\r
864         }\r
865 \r
866         /**\r
867          * Parse skinvar image\r
868          */\r
869         function parse_image($what = 'imgtag') {\r
870                 global $CONF;\r
871 \r
872                 $imagetext      = Entity::hsc(requestVar('imagetext'));\r
873                 $imagepopup = requestVar('imagepopup');\r
874                 $width          = intRequestVar('width');\r
875                 $height         = intRequestVar('height');\r
876                 $fullurl        = Entity::hsc($CONF['MediaURL'] . $imagepopup);\r
877 \r
878                 switch($what)\r
879                 {\r
880                         case 'url':\r
881                                 echo $fullurl;\r
882                                 break;\r
883                         case 'width':\r
884                                 echo $width;\r
885                                 break;\r
886                         case 'height':\r
887                                 echo $height;\r
888                                 break;\r
889                         case 'caption':\r
890                         case 'text':\r
891                                 echo $imagetext;\r
892                                 break;\r
893                         case 'imgtag':\r
894                         default:\r
895                                 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";\r
896                                 break;\r
897                 }\r
898         }\r
899         \r
900         /**\r
901          * Parse skinvar imagetext\r
902          */\r
903         function parse_imagetext() {\r
904                 echo Entity::hsc(requestVar('imagetext'));\r
905         }\r
906 \r
907         /**\r
908          * Parse skinvar item\r
909          * include one item (no comments)        \r
910          */\r
911         function parse_item($template) {\r
912                 global $blog, $itemid, $highlight;\r
913                 $this->_setBlogCategory($blog, '');     // need this to select default category\r
914                 $this->_preBlogContent('item',$blog);\r
915                 $r = $blog->showOneitem($itemid, $template, $highlight);\r
916                 if ($r == 0)\r
917                         echo _ERROR_NOSUCHITEM;\r
918                 $this->_postBlogContent('item',$blog);\r
919         }\r
920 \r
921         /**\r
922          * Parse skinvar itemid\r
923          */\r
924         function parse_itemid() {\r
925                 global $itemid;\r
926                 echo $itemid;\r
927         }\r
928         \r
929         /**\r
930          * Parse skinvar itemlink\r
931          */\r
932         function parse_itemlink($linktext = '') {\r
933                 global $itemid;\r
934                 $this->_itemlink($itemid, $linktext);\r
935         }\r
936 \r
937         /**\r
938          * Parse itemtitle\r
939          */\r
940         function parse_itemtitle($format = '') {\r
941                 global $manager, $itemid;\r
942                 $item =& $manager->getItem($itemid,0,0);\r
943 \r
944                 switch ($format) {\r
945                         case 'xml':\r
946                                 echo Entity::hen($item['title']);\r
947                                 break;\r
948                         case 'raw':\r
949                                 echo $item['title'];\r
950                                 break;\r
951                         case 'attribute':\r
952                         default:\r
953                                 echo Entity::hsc(strip_tags($item['title']));\r
954                                 break;\r
955                 }\r
956         }\r
957 \r
958         /**\r
959          * Parse skinvar loginform\r
960          */\r
961         function parse_loginform() {\r
962                 global $member, $CONF;\r
963                 if (!$member->isLoggedIn()) {\r
964                         $filename = 'loginform-notloggedin';\r
965                         $this->formdata = array();\r
966                 } else {\r
967                         $filename = 'loginform-loggedin';\r
968                         $this->formdata = array(\r
969                                 'membername' => $member->getDisplayName(),\r
970                         );\r
971                 }\r
972                 $this->doForm($filename);\r
973         }\r
974 \r
975         /**\r
976          * Actions::parse_member()\r
977          * Parse skinvar member\r
978          * (includes a member info thingie)\r
979          * \r
980          * @param       String  $what   which memberdata is needed\r
981          * @return      Void\r
982          */\r
983         function parse_member($what)\r
984         {\r
985                 global $memberinfo, $member, $CONF;\r
986                 \r
987                 // 1. only allow the member-details-page specific variables on member pages\r
988                 if ($this->skintype == 'member')\r
989                 {\r
990                         switch( $what )\r
991                         {\r
992                                 case 'name':\r
993                                         echo Entity::hsc($memberinfo->getDisplayName());\r
994                                         break;\r
995                                 case 'realname':\r
996                                         echo Entity::hsc($memberinfo->getRealName());\r
997                                         break;\r
998                                 case 'notes':\r
999                                         echo Entity::hsc($memberinfo->getNotes());\r
1000                                         break;\r
1001                                 case 'url':\r
1002                                         echo Entity::hsc($memberinfo->getURL());\r
1003                                         break;\r
1004                                 case 'email':\r
1005                                         echo Entity::hsc($memberinfo->getEmail());\r
1006                                         break;\r
1007                                 case 'id':\r
1008                                         echo Entity::hsc($memberinfo->getID());\r
1009                                         break;\r
1010                         }\r
1011                 }\r
1012                 \r
1013                 // 2. the next bunch of options is available everywhere, as long as the user is logged in\r
1014                 if ( $member->isLoggedIn() )\r
1015                 {\r
1016                         switch( $what )\r
1017                         {\r
1018                                 case 'yourname':\r
1019                                         echo $member->getDisplayName();\r
1020                                         break;\r
1021                                 case 'yourrealname':\r
1022                                         echo $member->getRealName();\r
1023                                         break;\r
1024                                 case 'yournotes':\r
1025                                         echo $member->getNotes();\r
1026                                         break;\r
1027                                 case 'yoururl':\r
1028                                         echo $member->getURL();\r
1029                                         break;\r
1030                                 case 'youremail':\r
1031                                         echo $member->getEmail();\r
1032                                         break;\r
1033                                 case 'yourid':\r
1034                                         echo $member->getID();\r
1035                                         break;\r
1036                                 case 'yourprofileurl':\r
1037                                         if ($CONF['URLMode'] == 'pathinfo')\r
1038                                                 echo Link::create_member_link($member->getID());\r
1039                                         else\r
1040                                                 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());\r
1041                                         break;\r
1042                         }\r
1043                 }\r
1044                 return;\r
1045         }\r
1046 \r
1047         /**\r
1048          * Link::parse_membermailform()\r
1049          * Parse skinvar membermailform\r
1050          * \r
1051          * @param       Integer $rows   the height for textarea\r
1052          * @param       Integer $cols   the width for textarea\r
1053          * @param       String  $desturl        URI to redirect\r
1054          * @return      Void\r
1055          */\r
1056         function parse_membermailform($rows = 10, $cols = 40, $desturl = '')\r
1057         {\r
1058                 global $member, $CONF, $memberid;\r
1059                 \r
1060                 if ( $desturl == '' )\r
1061                 {\r
1062                         if ( $CONF['URLMode'] == 'pathinfo' )\r
1063                         {\r
1064                                 $desturl = Link::create_member_link($memberid);\r
1065                         }\r
1066                         else\r
1067                         {\r
1068                                 $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid);\r
1069                         }\r
1070                 }\r
1071                 \r
1072                 $message = postVar('message');\r
1073                 $frommail = postVar('frommail');\r
1074                 \r
1075                 $this->formdata = array(\r
1076                         'url' => Entity::hsc($desturl),\r
1077                         'actionurl' => Entity::hsc($CONF['ActionURL']),\r
1078                         'memberid' => $memberid,\r
1079                         'rows' => $rows,\r
1080                         'cols' => $cols,\r
1081                         'message' => Entity::hsc($message),\r
1082                         'frommail' => Entity::hsc($frommail)\r
1083                 );\r
1084                 \r
1085                 if ( $member->isLoggedIn() )\r
1086                 {\r
1087                         $this->doForm('membermailform-loggedin');\r
1088                 }\r
1089                 else if ( $CONF['NonmemberMail'] )\r
1090                 {\r
1091                         $this->doForm('membermailform-notloggedin');\r
1092                 }\r
1093                 else\r
1094                 {\r
1095                         $this->doForm('membermailform-disallowed');\r
1096                 }\r
1097                 return;\r
1098         }\r
1099         \r
1100         /**\r
1101          * Parse skinvar nextarchive\r
1102          */\r
1103         function parse_nextarchive() {\r
1104                 global $archivenext;\r
1105                 echo $archivenext;\r
1106         }\r
1107 \r
1108         /**\r
1109          * Parse skinvar nextitem\r
1110          * (include itemid of next item)\r
1111          */\r
1112         function parse_nextitem() {\r
1113                 global $itemidnext;\r
1114                 if (isset($itemidnext)) echo (int)$itemidnext;\r
1115         }\r
1116 \r
1117         /**\r
1118          * Parse skinvar nextitemtitle\r
1119          * (include itemtitle of next item)\r
1120          */\r
1121         function parse_nextitemtitle($format = '') {\r
1122                 global $itemtitlenext;\r
1123 \r
1124                 switch ( $format )\r
1125                 {\r
1126                         case 'xml':\r
1127                                 echo Entity::hen($itemtitlenext);\r
1128                                 break;\r
1129                         case 'raw':\r
1130                                 echo $itemtitlenext;\r
1131                                 break;\r
1132                         case 'attribute':\r
1133                         default:\r
1134                                 echo Entity::hsc($itemtitlenext);\r
1135                                 break;\r
1136                 }\r
1137         }\r
1138 \r
1139         /**\r
1140          * Parse skinvar nextlink\r
1141          */\r
1142         function parse_nextlink($linktext = '', $amount = 10, $recount = '') {\r
1143                 global $itemidnext, $archivenext, $startpos;\r
1144                 if ($this->skintype == 'item')\r
1145                         $this->_itemlink($itemidnext, $linktext);\r
1146                 else if ($this->skintype == 'search' || $this->skintype == 'index')\r
1147                         $this->_searchlink($amount, $startpos, 'next', $linktext, $recount);\r
1148                 else\r
1149                         $this->_archivelink($archivenext, $linktext);\r
1150         }\r
1151 \r
1152         /**\r
1153          * Parse skinvar nucleusbutton\r
1154          */\r
1155         function parse_nucleusbutton($imgurl = '',\r
1156                                                                  $imgwidth = '85',\r
1157                                                                  $imgheight = '31') {\r
1158                 global $CONF;\r
1159                 if ($imgurl == '') {\r
1160                         $imgurl = $CONF['AdminURL'] . 'nucleus.gif';\r
1161                 } else if (Parser::getProperty('IncludeMode') == 'skindir'){\r
1162                         // when skindit IncludeMode is used: start from skindir\r
1163                         $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl;\r
1164                 }\r
1165 \r
1166                 $this->formdata = array(\r
1167                         'imgurl' => $imgurl,\r
1168                         'imgwidth' => $imgwidth,\r
1169                         'imgheight' => $imgheight,\r
1170                 );\r
1171                 $this->doForm('nucleusbutton');\r
1172         }\r
1173         \r
1174         /**\r
1175          * Parse skinvar otherarchive\r
1176          */     \r
1177         function parse_otherarchive($blogname, $template, $category = '') {\r
1178                 global $archive, $manager;\r
1179                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
1180                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1181                 $this->_setBlogCategory($b, $category);\r
1182                 $this->_preBlogContent('otherachive',$b);\r
1183                 $b->showArchive($template, $y, $m, $d);\r
1184                 $this->_postBlogContent('otherachive',$b);\r
1185         }\r
1186         \r
1187         /**\r
1188          * Parse skinvar otherarchivedaylist\r
1189          */\r
1190         function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {\r
1191                 global $manager;\r
1192                 if ($category == 'all') $category = '';\r
1193                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1194                 $this->_setBlogCategory($b, $category);\r
1195                 $this->_preBlogContent('otherarchivelist',$b);\r
1196                 $b->showArchiveList($template, 'day', $limit);\r
1197                 $this->_postBlogContent('otherarchivelist',$b);\r
1198         }\r
1199         \r
1200         /**\r
1201          * Parse skinvar otherarchivelist\r
1202          */\r
1203         function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {\r
1204                 global $manager;\r
1205                 if ($category == 'all') $category = '';\r
1206                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1207                 $this->_setBlogCategory($b, $category);\r
1208                 $this->_preBlogContent('otherarchivelist',$b);\r
1209                 $b->showArchiveList($template, 'month', $limit);\r
1210                 $this->_postBlogContent('otherarchivelist',$b);\r
1211         }\r
1212                 \r
1213         /**\r
1214          * Parse skinvar otherarchiveyearlist\r
1215          */\r
1216         function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) {\r
1217                 global $manager;\r
1218                 if ($category == 'all') $category = '';\r
1219                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1220                 $this->_setBlogCategory($b, $category);\r
1221                 $this->_preBlogContent('otherarchivelist',$b);\r
1222                 $b->showArchiveList($template, 'year', $limit);\r
1223                 $this->_postBlogContent('otherarchivelist',$b);\r
1224         }       \r
1225         \r
1226         /**\r
1227          * Parse skinvar otherblog\r
1228          */\r
1229         function parse_otherblog($blogname, $template, $amount = 10, $category = '') {\r
1230                 global $manager;\r
1231 \r
1232                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
1233 \r
1234                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1235                 $this->_setBlogCategory($b, $category);\r
1236                 $this->_preBlogContent('otherblog',$b);\r
1237                 $this->amountfound = $b->readLog($template, $limit, $offset);\r
1238                 $this->_postBlogContent('otherblog',$b);\r
1239         }\r
1240 \r
1241         /**\r
1242          * Parse skinvar othersearchresults\r
1243          */\r
1244         function parse_othersearchresults($blogname, $template, $maxresults = 50) {\r
1245                 global $query, $amount, $manager, $startpos;\r
1246                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
1247                 $this->_setBlogCategory($b, '');        // need this to select default category\r
1248                 $this->_preBlogContent('othersearchresults',$b);\r
1249                 $b->search($query, $template, $amount, $maxresults, $startpos);\r
1250                 $this->_postBlogContent('othersearchresults',$b);\r
1251         }\r
1252 \r
1253         /**\r
1254           * Executes a plugin skinvar\r
1255           *\r
1256           * @param pluginName name of plugin (without the NP_)\r
1257           *\r
1258           * extra parameters can be added\r
1259           */\r
1260         function parse_plugin($pluginName) {\r
1261                 global $manager;\r
1262 \r
1263                 // should be already tested from the parser (PARSER.php)\r
1264                 // only continue when the plugin is really installed\r
1265                 /*if (!$manager->pluginInstalled('NP_' . $pluginName))\r
1266                         return;*/\r
1267 \r
1268                 $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
1269                 if (!$plugin) return;\r
1270 \r
1271                 // get arguments\r
1272                 $params = func_get_args();\r
1273 \r
1274                 // remove plugin name\r
1275                 array_shift($params);\r
1276 \r
1277                 // add skin type on front\r
1278                 array_unshift($params, $this->skintype);\r
1279 \r
1280                 call_user_func_array(array(&$plugin,'doSkinVar'), $params);\r
1281         }\r
1282         \r
1283         /**\r
1284          * Parse skinvar prevarchive\r
1285          */\r
1286         function parse_prevarchive() {\r
1287                 global $archiveprev;\r
1288                 echo $archiveprev;\r
1289         }\r
1290 \r
1291         /**\r
1292          * Parse skinvar preview\r
1293          */\r
1294         function parse_preview($template) {\r
1295                 global $blog, $CONF, $manager;\r
1296 \r
1297                 $template =& $manager->getTemplate($template);\r
1298                 $row['body'] = '<span id="prevbody"></span>';\r
1299                 $row['title'] = '<span id="prevtitle"></span>';\r
1300                 $row['more'] = '<span id="prevmore"></span>';\r
1301                 $row['itemlink'] = '';\r
1302                 $row['itemid'] = 0; $row['blogid'] = $blog->getID();\r
1303                 echo Template::fill($template['ITEM_HEADER'],$row);\r
1304                 echo Template::fill($template['ITEM'],$row);\r
1305                 echo Template::fill($template['ITEM_FOOTER'],$row);\r
1306         }\r
1307 \r
1308         /*\r
1309          * Parse skinvar previtem\r
1310          * (include itemid of prev item)                 \r
1311          */\r
1312         function parse_previtem() {\r
1313                 global $itemidprev;\r
1314                 if (isset($itemidprev)) echo (int)$itemidprev;\r
1315         }\r
1316         \r
1317         /**\r
1318          * Actions::parse_previtemtitle()\r
1319          * Parse skinvar previtemtitle\r
1320          * (include itemtitle of prev item)\r
1321          * \r
1322          * @param       String  $format string format\r
1323          * @return      String  formatted string\r
1324          */\r
1325         function parse_previtemtitle($format = '')\r
1326         {\r
1327                 global $itemtitleprev;\r
1328                 \r
1329                 switch ( $format )\r
1330                 {\r
1331                         case 'xml':\r
1332                                 echo Entity::hen($itemtitleprev);\r
1333                                 break;\r
1334                         case 'raw':\r
1335                                 echo $itemtitleprev;\r
1336                                 break;\r
1337                         case 'attribute':\r
1338                         default:\r
1339                                 echo Entity::hsc($itemtitleprev);\r
1340                                 break;\r
1341                 }\r
1342                 return;\r
1343         }\r
1344         \r
1345         /**\r
1346          * Parse skinvar prevlink\r
1347          */\r
1348         function parse_prevlink($linktext = '', $amount = 10) {\r
1349                 global $itemidprev, $archiveprev, $startpos;\r
1350 \r
1351                 if ($this->skintype == 'item')\r
1352                         $this->_itemlink($itemidprev, $linktext);\r
1353                 else if ($this->skintype == 'search' || $this->skintype == 'index')\r
1354                         $this->_searchlink($amount, $startpos, 'prev', $linktext);\r
1355                 else\r
1356                         $this->_archivelink($archiveprev, $linktext);\r
1357         }\r
1358 \r
1359         /**\r
1360          * Parse skinvar query\r
1361          * (includes the search query)   \r
1362          */\r
1363         function parse_query() {\r
1364                 global $query;\r
1365                 echo Entity::hsc($query);\r
1366         }\r
1367         \r
1368         /**\r
1369          * Parse skinvar referer\r
1370          */\r
1371         function parse_referer() {\r
1372                 echo Entity::hsc(serverVar('HTTP_REFERER'));\r
1373         }\r
1374 \r
1375         /**\r
1376          * Parse skinvar searchform\r
1377          */\r
1378         function parse_searchform($blogname = '') {\r
1379                 global $CONF, $manager, $maxresults;\r
1380                 if ($blogname) {\r
1381                         $blog =& $manager->getBlog(getBlogIDFromName($blogname));\r
1382                 } else {\r
1383                         global $blog;\r
1384                 }\r
1385                 // use default blog when no blog is selected\r
1386                 $this->formdata = array(\r
1387                         'id' => $blog?$blog->getID():$CONF['DefaultBlog'],\r
1388                         'query' => Entity::hsc(getVar('query')),\r
1389                 );\r
1390                 $this->doForm('searchform');\r
1391         }\r
1392 \r
1393         /**\r
1394          * Parse skinvar searchresults\r
1395          */\r
1396         function parse_searchresults($template, $maxresults = 50 ) {\r
1397                 global $blog, $query, $amount, $startpos;\r
1398 \r
1399                 $this->_setBlogCategory($blog, '');     // need this to select default category\r
1400                 $this->_preBlogContent('searchresults',$blog);\r
1401                 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);\r
1402                 $this->_postBlogContent('searchresults',$blog);\r
1403         }\r
1404 \r
1405         /**\r
1406          * Parse skinvar self\r
1407          */\r
1408         function parse_self() {\r
1409                 global $CONF;\r
1410                 echo $CONF['Self'];\r
1411         }\r
1412 \r
1413         /**\r
1414          * Parse skinvar sitevar\r
1415          * (include a sitevar)   \r
1416          */\r
1417         function parse_sitevar($which) {\r
1418                 global $CONF;\r
1419                 switch($which) {\r
1420                         case 'url':\r
1421                                 echo $CONF['IndexURL'];\r
1422                                 break;\r
1423                         case 'name':\r
1424                                 echo $CONF['SiteName'];\r
1425                                 break;\r
1426                         case 'admin':\r
1427                                 echo $CONF['AdminEmail'];\r
1428                                 break;\r
1429                         case 'adminurl':\r
1430                                 echo $CONF['AdminURL'];\r
1431                 }\r
1432         }\r
1433 \r
1434         /**\r
1435          * Parse skinname\r
1436          */\r
1437         function parse_skinname() {\r
1438                 echo $this->skin->getName();\r
1439         }\r
1440         \r
1441         /**\r
1442          * Parse skintype (experimental)\r
1443          */\r
1444         function parse_skintype() {\r
1445                 echo $this->skintype;\r
1446         }\r
1447 \r
1448         /**\r
1449          * Parse text\r
1450          */\r
1451         function parse_text($which) {\r
1452                 // constant($which) only available from 4.0.4 :(\r
1453                 if (defined($which)) {\r
1454                         eval("echo $which;");\r
1455                 }\r
1456         }\r
1457         \r
1458         /**\r
1459          * Parse ticket\r
1460          */\r
1461         function parse_ticket() {\r
1462                 global $manager;\r
1463                 $manager->addTicketHidden();\r
1464         }\r
1465 \r
1466         /**\r
1467          * Actions::parse_todaylink()\r
1468          * Parse skinvar todaylink\r
1469          * A link to the today page (depending on selected blog, etc...)\r
1470          *\r
1471          * @param       String  $linktext       text for link\r
1472          * @return      Void\r
1473          */\r
1474         function parse_todaylink($linktext = '')\r
1475         {\r
1476                 global $blog, $CONF;\r
1477                 if ( $blog )\r
1478                 {\r
1479                         echo $this->_link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext);\r
1480                 }\r
1481                 else\r
1482                 {\r
1483                         echo $this->_link($CONF['SiteUrl'], $linktext);\r
1484                 }\r
1485                 return;\r
1486         }\r
1487         \r
1488         /**\r
1489          * Parse vars\r
1490          * When commentform is not used, to include a hidden field with itemid   \r
1491          */\r
1492         function parse_vars() {\r
1493                 global $itemid;\r
1494                 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';\r
1495         }\r
1496 \r
1497         /**\r
1498          * Parse skinvar version\r
1499          * (include nucleus versionnumber)       \r
1500          */\r
1501         function parse_version() {\r
1502                 global $nucleus;\r
1503                 echo 'Nucleus CMS ' . $nucleus['version'];\r
1504         }\r
1505         \r
1506         /**\r
1507          * Parse skinvar sticky\r
1508          */\r
1509         function parse_sticky($itemnumber = 0, $template = '') {\r
1510                 global $manager;\r
1511                 \r
1512                 $itemnumber = intval($itemnumber);\r
1513                 $itemarray = array($itemnumber);\r
1514 \r
1515                 $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));\r
1516                 $this->_preBlogContent('sticky',$b);\r
1517                 $this->amountfound = $b->readLogFromList($itemarray, $template);\r
1518                 $this->_postBlogContent('sticky',$b);\r
1519         }\r
1520 \r
1521 \r
1522 }\r