OSDN Git Service

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