OSDN Git Service

01ccdf72afd4f118556d4f9f0394d5ac66aa4643
[nucleus-jp/nucleus-jp-ancient.git] / euc / nucleus / libs / SKIN.php
1 <?php\r
2 \r
3 \r
4 /**\r
5   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
6   * Copyright (C) 2002-2005 The Nucleus Group\r
7   *\r
8   * This program is free software; you can redistribute it and/or\r
9   * modify it under the terms of the GNU General Public License\r
10   * as published by the Free Software Foundation; either version 2\r
11   * of the License, or (at your option) any later version.\r
12   * (see nucleus/documentation/index.html#license for more info)\r
13   *\r
14   * Class representing a skin\r
15   *\r
16   * $Id: SKIN.php,v 1.5 2005-03-16 08:10:35 kimitake Exp $\r
17   * $NucleusJP: SKIN.php,v 1.4 2005/03/12 06:19:05 kimitake Exp $\r
18   */\r
19 class SKIN {\r
20 \r
21         // after creating a SKIN object, evaluates to true when the skin exists\r
22         var $isValid;\r
23         \r
24         // skin characteristics. Use the getXXX methods rather than accessing directly\r
25         var $id;\r
26         var $description;\r
27         var $contentType;\r
28         var $includeMode;               // either 'normal' or 'skindir'\r
29         var $includePrefix;\r
30         var $name;\r
31         \r
32         function SKIN($id) {\r
33                 $this->id = intval($id);\r
34 \r
35                 // read skin name/description/content type\r
36                 $res = sql_query('SELECT * FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $this->id);\r
37                 $obj = mysql_fetch_object($res);\r
38                 $this->isValid = (mysql_num_rows($res) > 0);\r
39                 if (!$this->isValid)\r
40                         return;\r
41                         \r
42                 $this->name = $obj->sdname;\r
43                 $this->description = $obj->sddesc;\r
44                 $this->contentType = $obj->sdtype;\r
45                 $this->includeMode = $obj->sdincmode;\r
46                 $this->includePrefix = $obj->sdincpref;\r
47 \r
48         }\r
49         \r
50         function getID() {                              return $this->id; }\r
51         function getName() {                    return $this->name; }\r
52         function getDescription() {     return $this->description; }\r
53         function getContentType() {     return $this->contentType; }\r
54         function getIncludeMode() {     return $this->includeMode; }\r
55         function getIncludePrefix() {   return $this->includePrefix; }\r
56         \r
57         // returns true if there is a skin with the given shortname (static)\r
58         function exists($name) {\r
59                 return quickQuery('select count(*) as result FROM '.sql_table('skin_desc').' WHERE sdname="'.addslashes($name).'"') > 0;\r
60         }\r
61 \r
62         // returns true if there is a skin with the given ID (static)\r
63         function existsID($id) {\r
64                 return quickQuery('select COUNT(*) as result FROM '.sql_table('skin_desc').' WHERE sdnumber='.intval($id)) > 0;\r
65         }       \r
66         \r
67         // (static)\r
68         function createFromName($name) {\r
69                 return new SKIN(SKIN::getIdFromName($name));\r
70         }       \r
71         \r
72         // (static)\r
73         function getIdFromName($name) {\r
74                 $query =  'SELECT sdnumber'\r
75                        . ' FROM '.sql_table('skin_desc')\r
76                        . ' WHERE sdname="'.addslashes($name).'"';\r
77                 $res = sql_query($query);\r
78                 $obj = mysql_fetch_object($res);\r
79                 return $obj->sdnumber;  \r
80         }\r
81         \r
82         // (static)\r
83         function getNameFromId($id) {\r
84                 return quickQuery('SELECT sdname as result FROM '.sql_table('skin_desc').' WHERE sdnumber=' . intval($id));\r
85         }\r
86         \r
87         /**\r
88          * Creates a new skin, with the given characteristics.\r
89          *\r
90          * (static)\r
91          */\r
92         function createNew($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') {\r
93                 global $manager;\r
94                 \r
95                 $manager->notify(\r
96                         'PreAddSkin',\r
97                         array(\r
98                                 'name' => &$name,\r
99                                 'description' => &$desc,\r
100                                 'type' => &$type,\r
101                                 'includeMode' => &$includeMode,\r
102                                 'includePrefix' => &$includePrefix\r
103                         )\r
104                 );\r
105 \r
106                 sql_query('INSERT INTO '.sql_table('skin_desc')." (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('" . addslashes($name) . "','" . addslashes($desc) . "','".addslashes($type)."','".addslashes($includeMode)."','".addslashes($includePrefix)."')");\r
107                 $newid = mysql_insert_id();\r
108                 \r
109                 $manager->notify(\r
110                         'PostAddSkin',\r
111                         array(\r
112                                 'skinid' => $newid,\r
113                                 'name' => $name,\r
114                                 'description' => $desc,\r
115                                 'type' => $type,\r
116                                 'includeMode' => $includeMode,\r
117                                 'includePrefix' => $includePrefix\r
118                         )\r
119                 );\r
120                 \r
121                 return $newid;\r
122         }\r
123         \r
124         function parse($type) {\r
125                 global $manager, $CONF;\r
126 \r
127                 // set output type\r
128                 sendContentType($this->getContentType(), 'skin', _CHARSET);\r
129 \r
130                 // set skin name as global var (so plugins can access it)\r
131                 global $currentSkinName;\r
132                 $currentSkinName = $this->getName();\r
133 \r
134                 $contents = $this->getContent($type);\r
135 \r
136                 if (!$contents) {\r
137                         // use base skin if this skin does not have contents\r
138                         $defskin =& new SKIN($CONF['BaseSkin']);\r
139                         $contents = $defskin->getContent($type);\r
140                         if (!$contents) {\r
141                                 echo _ERROR_SKIN;\r
142                                 return;\r
143                         }\r
144                 }\r
145 \r
146                 $actions = $this->getAllowedActionsForType($type);\r
147 \r
148                 $manager->notify('PreSkinParse',array('skin' => &$this, 'type' => $type));\r
149 \r
150                 // set IncludeMode properties of parser\r
151                 PARSER::setProperty('IncludeMode',$this->getIncludeMode());\r
152                 PARSER::setProperty('IncludePrefix',$this->getIncludePrefix());\r
153 \r
154                 $handler =& new ACTIONS($type, $this);\r
155                 $parser =& new PARSER($actions, $handler);\r
156                 $handler->setParser($parser);\r
157                 $handler->setSkin($this);\r
158                 $parser->parse($contents);\r
159 \r
160                 $manager->notify('PostSkinParse',array('skin' => &$this, 'type' => $type));\r
161 \r
162 \r
163         }\r
164 \r
165         function getContent($type) {\r
166                 $query = 'SELECT scontent FROM '.sql_table('skin')." WHERE sdesc=$this->id and stype='". addslashes($type) ."'";\r
167                 $res = sql_query($query);\r
168 \r
169                 if (mysql_num_rows($res) == 0)\r
170                         return '';\r
171                 else\r
172                         return mysql_result($res, 0, 0);\r
173         }\r
174 \r
175         /**\r
176          * Updates the contents of one part of the skin\r
177          */\r
178         function update($type, $content) {\r
179                 $skinid = $this->id;\r
180 \r
181                 // delete old thingie\r
182                 sql_query('DELETE FROM '.sql_table('skin')." WHERE stype='".addslashes($type)."' and sdesc=" . intval($skinid));\r
183 \r
184                 // write new thingie\r
185                 if ($content) {\r
186                         sql_query('INSERT INTO '.sql_table('skin')." SET scontent='" . addslashes($content) . "', stype='" . addslashes($type) . "', sdesc=" . intval($skinid));\r
187                 }       \r
188         }\r
189         \r
190         /**\r
191          * Deletes all skin parts from the database\r
192          */\r
193         function deleteAllParts() {\r
194                 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc='.$this->getID());\r
195         }\r
196         \r
197         /**\r
198          * Updates the general information about the skin\r
199          */\r
200         function updateGeneralInfo($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') {\r
201                 $query =  'UPDATE '.sql_table('skin_desc').' SET'\r
202                        . " sdname='" . addslashes($name) . "',"\r
203                        . " sddesc='" . addslashes($desc) . "',"\r
204                        . " sdtype='" . addslashes($type) . "',"\r
205                            . " sdincmode='" . addslashes($includeMode) . "',"\r
206                            . " sdincpref='" . addslashes($includePrefix) . "'"                 \r
207                        . " WHERE sdnumber=" . $this->getID();\r
208                 sql_query($query);              \r
209         }\r
210         \r
211         /**\r
212          * static: returns an array of friendly names\r
213          */\r
214         function getFriendlyNames() {\r
215                 return array(\r
216                         'index' => _SKIN_PART_MAIN,\r
217                         'item' => _SKIN_PART_ITEM,\r
218                         'archivelist' => _SKIN_PART_ALIST,\r
219                         'archive' => _SKIN_PART_ARCHIVE,\r
220                         'search' => _SKIN_PART_SEARCH,\r
221                         'error' => _SKIN_PART_ERROR,\r
222                         'member' => _SKIN_PART_MEMBER,\r
223                         'imagepopup' => _SKIN_PART_POPUP\r
224                 );      \r
225         }\r
226         \r
227         function getAllowedActionsForType($type) {\r
228                 // some actions that can be performed at any time, from anywhere\r
229                 $defaultActions = array('otherblog',\r
230                                                                 'plugin',\r
231                                                                 'version',\r
232                                                                 'nucleusbutton',\r
233                                                                 'include',\r
234                                                                 'phpinclude',\r
235                                                                 'parsedinclude',\r
236                                                                 'loginform',\r
237                                                                 'sitevar',\r
238                                                                 'otherarchivelist',\r
239                                                                 'otherarchivedaylist',\r
240                                                                 'self',\r
241                                                                 'adminurl',\r
242                                                                 'todaylink',\r
243                                                                 'archivelink',\r
244                                                                 'member',\r
245                                                                 'ifcat',                                        // deprecated (Nucleus v2.0)\r
246                                                                 'category',\r
247                                                                 'searchform',\r
248                                                                 'referer',\r
249                                                                 'skinname',\r
250                                                                 'skinfile',\r
251                                                                 'set',\r
252                                                                 'if',\r
253                                                                 'else',\r
254                                                                 'endif'\r
255                                                                 );\r
256                 \r
257                 // extra actions specific for a certain skin type\r
258                 $extraActions = array();\r
259 \r
260                 switch ($type) {\r
261                         case 'index':\r
262                                 $extraActions = array('blog', \r
263                                                     'blogsetting',\r
264                                                     'preview',\r
265                                                     'additemform',\r
266                                                                 'categorylist',                                             \r
267                                                     'archivelist',\r
268                                                     'archivedaylist',\r
269                                                     'nextlink',\r
270                                                     'prevlink'\r
271                                                     );                          \r
272                                 break;\r
273                         case 'archive':\r
274                                 $extraActions = array('blog',\r
275                                                                 'archive',\r
276                                                                 'otherarchive',\r
277                                                                 'categorylist',                                                         \r
278                                                                 'archivelist',\r
279                                                     'archivedaylist',                                                           \r
280                                                                 'blogsetting',\r
281                                                                 'archivedate',\r
282                                                             'nextarchive',\r
283                                                             'prevarchive',\r
284                                                             'nextlink',\r
285                                                             'prevlink',\r
286                                                             'archivetype'\r
287                                 );\r
288                                 break;\r
289                         case 'archivelist':\r
290                                 $extraActions = array('blog',\r
291                                                             'archivelist',\r
292                                                                 'archivedaylist',\r
293                                                                 'categorylist',\r
294                                                             'blogsetting',\r
295                                                            );\r
296                                 break;\r
297                         case 'search':\r
298                                 $extraActions = array('blog',\r
299                                                                 'archivelist',\r
300                                                     'archivedaylist',\r
301                                                                 'categorylist',\r
302                                                                 'searchresults',\r
303                                                                 'othersearchresults',\r
304                                                                 'blogsetting',\r
305                                                                 'query',\r
306                                                                 'nextlink',\r
307                                                                 'prevlink'\r
308                                                                 );\r
309                                 break;\r
310                         case 'imagepopup':\r
311                                 $extraActions = array('image',\r
312                                                                 'imagetext',                            // deprecated (Nucleus v2.0)\r
313                                                                 );\r
314                                 break;\r
315                         case 'member':\r
316                                 $extraActions = array(\r
317                                                                 'membermailform',\r
318                                                                 'blogsetting',\r
319                                                                 'nucleusbutton'\r
320                                 );\r
321                                 break;\r
322                         case 'item':\r
323                                 $extraActions = array('blog',\r
324                                                             'item',\r
325                                                             'comments',\r
326                                                             'commentform',\r
327                                                             'vars',\r
328                                                             'blogsetting',\r
329                                                             'nextitem',\r
330                                                             'previtem',\r
331                                                             'nextlink',\r
332                                                             'prevlink',\r
333                                                             'nextitemtitle',\r
334                                                             'previtemtitle',\r
335                                                                 'categorylist',                                                     \r
336                                                             'archivelist',\r
337                                                     'archivedaylist',                                                       \r
338                                                             'itemtitle',\r
339                                                             'itemid',\r
340                                                             'itemlink',\r
341                                                             );\r
342                                 break;\r
343                         case 'error':\r
344                                 $extraActions = array(\r
345                                                                 'errormessage'\r
346                                 );\r
347                                 break;\r
348                 }\r
349                 return array_merge($defaultActions, $extraActions);\r
350         }\r
351         \r
352 }\r
353 \r
354 \r
355 /*\r
356  * This class contains the functions that get called by using\r
357  * the special tags in the skins\r
358  *\r
359  * The allowed tags for a type of skinpart are defined by the \r
360  * SKIN::getAllowedActionsForType($type) method\r
361  */\r
362 class ACTIONS extends BaseActions {\r
363 \r
364         // part of the skin currently being parsed ('index', 'item', 'archive',\r
365         // 'archivelist', 'member', 'search', 'error', 'imagepopup')\r
366         var $skintype;\r
367         \r
368         // contains an assoc array with parameters that need to be included when\r
369         // generating links to items/archives/... (e.g. catid)  \r
370         var $linkparams;\r
371         \r
372         // reference to the skin object for which a part is being parsed\r
373         var $skin;\r
374         \r
375 \r
376         // used when including templated forms from the include/ dir. The $formdata var \r
377         // contains the values to fill out in there (assoc array name -> value)\r
378         var $formdata;\r
379         \r
380 \r
381         // filled out with the number of displayed items after calling one of the \r
382 \r
383         // (other)blog/(other)searchresults skinvars.\r
384 \r
385         var $amountfound;\r
386 \r
387         function ACTIONS($type) {\r
388                 // call constructor of superclass first\r
389                 $this->BaseActions();\r
390 \r
391                 $this->skintype = $type;\r
392 \r
393                 global $catid;\r
394                 if ($catid) \r
395                         $this->linkparams = array('catid' => $catid);\r
396         }\r
397 \r
398         function setSkin(&$skin) {\r
399                 $this->skin =& $skin;\r
400         }\r
401         \r
402         function setParser(&$parser) {\r
403                 $this->parser =& $parser;\r
404         }\r
405         \r
406         /*\r
407                 Forms get parsedincluded now, using an extra <formdata> skinvar\r
408         */\r
409         function doForm($filename) {\r
410                 global $DIR_NUCLEUS;\r
411                 array_push($this->parser->actions,'formdata','text','callback','errordiv');\r
412                 $oldIncludeMode = PARSER::getProperty('IncludeMode');\r
413                 $oldIncludePrefix = PARSER::getProperty('IncludePrefix');\r
414                 PARSER::setProperty('IncludeMode','normal');\r
415                 PARSER::setProperty('IncludePrefix','');\r
416                 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');\r
417                 PARSER::setProperty('IncludeMode',$oldIncludeMode);\r
418                 PARSER::setProperty('IncludePrefix',$oldIncludePrefix);\r
419                 array_pop($this->parser->actions);              // errordiv\r
420                 array_pop($this->parser->actions);              // callback\r
421                 array_pop($this->parser->actions);              // text\r
422                 array_pop($this->parser->actions);              // formdata\r
423         }\r
424         function parse_formdata($what) {\r
425                 echo $this->formdata[$what];\r
426         }\r
427         function parse_text($which) {\r
428                 // constant($which) only available from 4.0.4 :(\r
429                 if (defined($which)) {  \r
430                         eval("echo $which;");\r
431                 }\r
432         }\r
433         function parse_callback($eventName, $type)\r
434         {\r
435                 global $manager;\r
436                 $manager->notify($eventName, array('type' => $type));\r
437         }\r
438         function parse_errordiv() {\r
439                 global $errormessage;\r
440                 if ($errormessage)\r
441                         echo '<div class="error">', htmlspecialchars($errormessage),'</div>';\r
442         }\r
443         \r
444         function parse_skinname() {\r
445                 echo $this->skin->getName();\r
446         }\r
447         \r
448         function parse_if($field, $name='', $value = '') {\r
449                 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager;\r
450 \r
451                 $condition = 0;\r
452                 switch($field) {\r
453                         case 'category':\r
454                                 $condition = ($blog && $this->_ifCategory($name,$value));\r
455                                 break;\r
456                         case 'blogsetting':\r
457                                 if ($name == 'trackback' && $manager->pluginInstalled('NP_TrackBack')) {\r
458                                         $plugin =& $manager->getPlugin('NP_TrackBack');\r
459                                         if ($plugin != NULL && $blog){\r
460                                                 $bid = $blog->getID();\r
461                                                 if ($value === '1') $value = 'yes';\r
462                                                 if ($value === '0') $value = 'no';\r
463                                                 if ($plugin->getOption('AcceptPing') == 'no' ) {\r
464                                                         $condition = ($value == 'no');\r
465                                                         } else {\r
466                                                         $tb_option = $plugin->getBlogOption($bid,'AllowTrackBack');\r
467                                                         if (!$tb_option) {\r
468                                                                 $condition = ($value == 'yes');\r
469                                                         } else {\r
470                                                                 $condition = ($tb_option == $value);\r
471                                                         }\r
472                                                 }\r
473                                         }\r
474                                         break;\r
475                                 }\r
476                                 $condition = ($blog && ($blog->getSetting($name) == $value));\r
477                                 break;\r
478                         case 'loggedin':\r
479                                 $condition = $member->isLoggedIn();\r
480                                 break;\r
481                         case 'onteam':\r
482                                 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);\r
483                                 break;\r
484                         case 'admin':\r
485                                 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);\r
486                                 break;                          \r
487                         case 'nextitem':\r
488                                 $condition = ($itemidnext != '');\r
489                                 break;\r
490                         case 'previtem':\r
491                                 $condition = ($itemidprev != ''); \r
492                                 break;\r
493                         case 'skintype':\r
494                                 $condition = ($name == $this->skintype);\r
495                                 break;\r
496                         /*\r
497                                 hasplugin,PlugName\r
498                                         -> checks if plugin exists\r
499                                 hasplugin,PlugName,OptionName\r
500                                         -> checks if the option OptionName from plugin PlugName is not set to 'no'\r
501                                 hasplugin,PlugName,OptionName=value\r
502                                         -> checks if the option OptionName from plugin PlugName is set to value\r
503                         */\r
504                         case 'hasplugin':\r
505                 $condition = false;\r
506                 // (pluginInstalled method won't write a message in the actionlog on failure)\r
507                 if ($manager->pluginInstalled('NP_'.$name)) \r
508                 {\r
509                                         $plugin =& $manager->getPlugin('NP_' . $name);\r
510                                         if ($plugin != NULL){\r
511                                                 if ($value == "") {\r
512                                                         $condition = true;\r
513                                                 } else {\r
514                                                         list($name2, $value2) = explode('=', $value, 2);\r
515                                                         if ($value2 == "" && $plugin->getOption($name2) != 'no') {\r
516                                                                 $condition = true;\r
517                                                         } else if ($plugin->getOption($name2) == $value2) {\r
518                                                                 $condition = true;\r
519                                                         }\r
520                                                 }\r
521                                         }\r
522                 }\r
523                 break;                          \r
524                         default:        \r
525                                 return;\r
526                 }\r
527                 $this->_addIfCondition($condition);\r
528         }\r
529         \r
530         function _ifCategory($name = '', $value='') {\r
531                 global $blog, $catid;\r
532 \r
533                 // when no parameter is defined, just check if a category is selected\r
534                 if (($name != 'catname' && $name != 'catid') || ($value == ''))\r
535                         return $blog->isValidCategory($catid);\r
536 \r
537                 // check category name\r
538                 if ($name == 'catname') {\r
539                         $value = $blog->getCategoryIdFromName($value);\r
540                         if ($value == $catid)\r
541                                 return $blog->isValidCategory($catid);\r
542                 }\r
543 \r
544                 // check category id\r
545                 if (($name == 'catid') && ($value == $catid))\r
546                         return $blog->isValidCategory($catid);\r
547                 \r
548                 return false;\r
549         }\r
550    \r
551         function _ifOnTeam($blogName = '') {\r
552                 global $blog, $member, $manager;\r
553                 \r
554                 // when no blog found\r
555                 if (($blogName == '') && (!is_object($blog)))\r
556                         return 0;\r
557                 \r
558                 // explicit blog selection\r
559                 if ($blogName != '') \r
560                         $blogid = getBlogIDFromName($blogName); \r
561                 \r
562                 if (($blogName == '') || !$manager->existsBlogID($blogid))\r
563                         // use current blog\r
564                         $blogid = $blog->getID();\r
565                         \r
566                 return $member->teamRights($blogid);\r
567         }\r
568         \r
569         function _ifAdmin($blogName = '') {\r
570                 global $blog, $member, $manager;\r
571 \r
572                 // when no blog found\r
573                 if (($blogName == '') && (!is_object($blog)))\r
574                         return 0;\r
575 \r
576                 // explicit blog selection\r
577                 if ($blogName != '')\r
578                         $blogid = getBlogIDFromName($blogName);\r
579 \r
580                 if (($blogName == '') || !$manager->existsBlogID($blogid))\r
581                         // use current blog\r
582                         $blogid = $blog->getID();\r
583 \r
584                 return $member->isBlogAdmin($blogid);\r
585         }       \r
586         \r
587         function parse_ifcat($text = '') {\r
588                 if ($text == '') {\r
589                         // new behaviour\r
590                         $this->parse_if('category');\r
591                 } else {\r
592                         // old behaviour\r
593                         global $catid, $blog;\r
594                         if ($blog->isValidCategory($catid))\r
595                                 echo $text;\r
596                 }\r
597         }\r
598         \r
599         // a link to the today page (depending on selected blog, etc...)\r
600         function parse_todaylink($linktext = '') {\r
601                 global $blog, $CONF;\r
602                 if ($blog)\r
603                         echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);\r
604                 else\r
605                         echo $this->_link($CONF['SiteUrl'], $linktext);\r
606         }\r
607         \r
608         // a link to the archives for the current blog (or for default blog)\r
609         function parse_archivelink($linktext = '') {\r
610                 global $blog, $CONF;\r
611                 if ($blog)\r
612                         echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);\r
613                 else\r
614                         echo $this->_link(createArchiveListLink(), $linktext);\r
615         }\r
616 \r
617         // include itemid of prev item\r
618         function parse_previtem() {\r
619                 global $itemidprev;\r
620                 echo $itemidprev;\r
621         }\r
622 \r
623         // include itemtitle of prev item\r
624         function parse_previtemtitle() {\r
625                 global $itemtitleprev;\r
626                 echo htmlspecialchars($itemtitleprev);\r
627         }\r
628 \r
629         // include itemid of next item\r
630         function parse_nextitem() {\r
631                 global $itemidnext;\r
632                 echo $itemidnext;\r
633         }\r
634 \r
635         // include itemtitle of next item\r
636         function parse_nextitemtitle() {\r
637                 global $itemtitlenext;\r
638                 echo htmlspecialchars($itemtitlenext);\r
639         }\r
640 \r
641         function parse_prevarchive() {\r
642                 global $archiveprev;\r
643                 echo $archiveprev;\r
644         }\r
645 \r
646         function parse_nextarchive() {\r
647                 global $archivenext;\r
648                 echo $archivenext;\r
649         }\r
650 \r
651         function parse_archivetype() {\r
652                 global $archivetype;\r
653                 echo $archivetype;\r
654         }\r
655 \r
656         function parse_prevlink($linktext = '', $amount = 10) {\r
657                 global $itemidprev, $archiveprev, $startpos;\r
658 \r
659                 if ($this->skintype == 'item')\r
660                         $this->_itemlink($itemidprev, $linktext);\r
661             else if ($this->skintype == 'search' || $this->skintype == 'index')\r
662                 $this->_searchlink($amount, $startpos, 'prev', $linktext);\r
663                 else\r
664                         $this->_archivelink($archiveprev, $linktext);\r
665         }\r
666         \r
667         function parse_nextlink($linktext = '', $amount = 10) {\r
668                 global $itemidnext, $archivenext, $startpos;\r
669                 if ($this->skintype == 'item')\r
670                         $this->_itemlink($itemidnext, $linktext);\r
671             else if ($this->skintype == 'search' || $this->skintype == 'index')\r
672                 $this->_searchlink($amount, $startpos, 'next', $linktext);\r
673                 else\r
674                         $this->_archivelink($archivenext, $linktext);\r
675         }\r
676         \r
677         /**\r
678          * returns either\r
679          *              - a raw link (html/xml encoded) when no linktext is provided\r
680          *              - a (x)html <a href... link when a text is present (text htmlencoded)\r
681          */\r
682         function _link($url, $linktext = '')\r
683         {\r
684                 $u = htmlspecialchars($url);\r
685                 $u = preg_replace("/&amp;amp;/",'&amp;',$u); // fix URLs that already had encoded ampersands\r
686                 if ($linktext != '')\r
687                         $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>';\r
688                 else\r
689                         $l = $u;\r
690                 return $l;      \r
691         }\r
692 \r
693         /**\r
694          * Outputs a next/prev link\r
695          *\r
696          * @param $maxresults\r
697          *              The maximum amount of items shown per page (e.g. 10)\r
698          * @param $startpos\r
699          *              Current start position (requestVar('startpos'))\r
700          * @param $direction\r
701          *              either 'prev' or 'next'\r
702          * @param $linktext\r
703          *              When present, the output will be a full <a href...> link. When empty,\r
704          *              only a raw link will be outputted\r
705          */\r
706     function _searchlink($maxresults, $startpos, $direction, $linktext = '') {\r
707         global $CONF, $blog, $query, $amount;\r
708         // TODO: Move request uri to linkparams. this is ugly. sorry for that.\r
709         $startpos       = intval($startpos);            // will be 0 when empty. \r
710         $parsed         = parse_url(serverVar('REQUEST_URI'));\r
711         $parsed         = $parsed['query'];\r
712                 $url            = '';\r
713         \r
714         switch ($direction) {\r
715             case 'prev':\r
716                 if ( intval($startpos) - intval($maxresults) >= 0) {\r
717                     $startpos   = intval($startpos) - intval($maxresults);\r
718                     $url                = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);\r
719                 }\r
720                 break;\r
721             case 'next':\r
722                 $iAmountOnPage = $this->amountfound;\r
723                 if ($iAmountOnPage == 0)\r
724                 {\r
725                         // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]\r
726                         // try a count query\r
727                         switch ($this->skintype)\r
728                         {\r
729                                 case 'index':\r
730                                         $sqlquery = $blog->getSqlBlog('', 'count');\r
731                                         break;\r
732                                 case 'search':\r
733                                         $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');\r
734                                         break;\r
735                         }\r
736                         if ($sqlquery) \r
737                                 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);\r
738                 }\r
739                 if (intval($iAmountOnPage) >= intval($maxresults)) {\r
740                         $startpos       = intval($startpos) + intval($maxresults);                \r
741                         $url            = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);\r
742                 }\r
743                 break;\r
744             default:\r
745                 break;\r
746         } // switch($direction)\r
747 \r
748                 if ($url != '')\r
749                         echo $this->_link($url, $linktext);        \r
750     }\r
751 \r
752         function _itemlink($id, $linktext = '') {\r
753                 global $CONF;\r
754                 if ($id)\r
755                         echo $this->_link(createItemLink($id, $this->linkparams), $linktext);\r
756                 else\r
757                         $this->parse_todaylink($linktext);\r
758         }\r
759 \r
760         function _archivelink($id, $linktext = '') {\r
761                 global $CONF, $blog;\r
762                 if ($id)\r
763                         echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);\r
764                 else\r
765                         $this->parse_todaylink($linktext);\r
766         }\r
767         \r
768         \r
769         function parse_itemlink($linktext = '') {       \r
770                 $this->_itemlink($itemid, $linktext);\r
771         }\r
772         \r
773         /**\r
774           * %archivedate(locale,date format)%\r
775           */\r
776         function parse_archivedate($locale = '-def-') {\r
777                 global $archive;\r
778                 \r
779                 if ($locale == '-def-')\r
780                         setlocale(LC_TIME,$template['LOCALE']);\r
781                 else\r
782                         setlocale(LC_TIME,$locale);\r
783                 \r
784                 // get archive date\r
785                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
786 \r
787                 // get format           \r
788                 $args = func_get_args();\r
789                 // format can be spread over multiple parameters\r
790                 if (sizeof($args) > 1) {\r
791                         // take away locale\r
792                         array_shift($args);\r
793                         // implode\r
794                         $format=implode(',',$args);\r
795                 } elseif ($d == 0) {\r
796                         $format = '%B %Y';      \r
797                 } else {\r
798                         $format = '%d %B %Y';   \r
799                 }\r
800                 \r
801                 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));             \r
802         }\r
803         \r
804         function parse_blog($template, $amount = 10, $category = '') {\r
805                 global $blog, $startpos;\r
806                 \r
807                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
808                 $this->_setBlogCategory($blog, $category);\r
809                 $this->_preBlogContent('blog',$blog);\r
810                 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);\r
811                 $this->_postBlogContent('blog',$blog);\r
812         }\r
813 \r
814         function parse_otherblog($blogname, $template, $amount = 10, $category = '') {\r
815                 global $manager;\r
816 \r
817                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
818 \r
819                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
820                 $this->_setBlogCategory($b, $category);\r
821                 $this->_preBlogContent('otherblog',$b);\r
822                 $this->amountfound = $b->readLog($template, $limit, $offset);\r
823                 $this->_postBlogContent('otherblog',$b);\r
824         }\r
825 \r
826         // include one item (no comments)\r
827         function parse_item($template) {\r
828                 global $blog, $itemid, $highlight;\r
829                 $this->_setBlogCategory($blog, '');     // need this to select default category\r
830                 $this->_preBlogContent('item',$blog);\r
831                 $r = $blog->showOneitem($itemid, $template, $highlight);\r
832                 if ($r == 0)\r
833                         echo _ERROR_NOSUCHITEM;\r
834                 $this->_postBlogContent('item',$blog);\r
835         }\r
836 \r
837         function parse_itemid() {\r
838                 global $itemid;\r
839                 echo $itemid;\r
840         }\r
841 \r
842 \r
843         // include comments for one item\r
844         function parse_comments($template) {\r
845                 global $itemid, $manager, $blog, $highlight;\r
846                 $template =& $manager->getTemplate($template);\r
847 \r
848                 // create parser object & action handler\r
849                 $actions =& new ITEMACTIONS($blog);\r
850                 $parser =& new PARSER($actions->getDefinedActions(),$actions);\r
851                 $actions->setTemplate($template);\r
852                 $actions->setParser($parser);\r
853                 $item = ITEM::getitem($itemid, 0, 0);\r
854                 $actions->setCurrentItem($item);\r
855 \r
856                 $comments =& new COMMENTS($itemid);\r
857                 $comments->setItemActions($actions);\r
858                 $comments->showComments($template, -1, 1, $highlight);  // shows ALL comments\r
859         }\r
860 \r
861         function parse_archive($template, $category = '') {\r
862                 global $blog, $archive;\r
863                 // can be used with either yyyy-mm or yyyy-mm-dd\r
864                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
865                 $this->_setBlogCategory($blog, $category);\r
866                 $this->_preBlogContent('achive',$blog);\r
867                 $blog->showArchive($template, $y, $m, $d);\r
868                 $this->_postBlogContent('achive',$blog);\r
869 \r
870         }\r
871 \r
872         function parse_otherarchive($blogname, $template, $category = '') {\r
873                 global $archive, $manager;\r
874                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
875                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
876                 $this->_setBlogCategory($b, $category);\r
877                 $this->_preBlogContent('otherachive',$b);\r
878                 $b->showArchive($template, $y, $m, $d);\r
879                 $this->_postBlogContent('otherachive',$b);\r
880         }\r
881 \r
882         function parse_archivelist($template, $category = 'all', $limit = 0) {\r
883                 global $blog;\r
884                 if ($category == 'all') $category = '';\r
885                 $this->_preBlogContent('archivelist',$blog);\r
886                 $this->_setBlogCategory($blog, $category);\r
887                 $blog->showArchiveList($template, 'month', $limit);\r
888                 $this->_postBlogContent('archivelist',$blog);\r
889         }\r
890 \r
891         function parse_archivedaylist($template, $category = 'all', $limit = 0) {\r
892                 global $blog;\r
893                 if ($category == 'all') $category = '';\r
894                 $this->_preBlogContent('archivelist',$blog);\r
895                 $this->_setBlogCategory($blog, $category);\r
896                 $blog->showArchiveList($template, 'day', $limit);\r
897                 $this->_postBlogContent('archivelist',$blog);\r
898         }\r
899 \r
900 \r
901         function parse_itemtitle() {\r
902                 global $manager, $itemid;\r
903                 $item =& $manager->getItem($itemid,0,0);\r
904                 echo htmlspecialchars(strip_tags($item['title']));\r
905         }\r
906 \r
907         function parse_categorylist($template, $blogname = '') {\r
908                 global $blog, $manager;\r
909 \r
910                 if ($blogname == '') {\r
911                         $this->_preBlogContent('categorylist',$blog);\r
912                         $blog->showCategoryList($template);\r
913                         $this->_postBlogContent('categorylist',$blog);\r
914                 } else {\r
915                         $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
916                         $this->_preBlogContent('categorylist',$b);\r
917                         $b->showCategoryList($template);\r
918                         $this->_postBlogContent('categorylist',$b);\r
919                 }\r
920         }\r
921 \r
922         function parse_category($type = 'name') {\r
923                 global $catid, $blog;\r
924                 if (!$blog->isValidCategory($catid))\r
925                         return;\r
926 \r
927                 switch($type) {\r
928                         case 'name':\r
929                                 echo $blog->getCategoryName($catid);\r
930                                 break;\r
931                         case 'desc':\r
932                                 echo $blog->getCategoryDesc($catid);\r
933                                 break;\r
934                         case 'id':\r
935                                 echo $catid;\r
936                                 break;\r
937                 }\r
938         }\r
939 \r
940         function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {\r
941                 global $manager;\r
942                 if ($category == 'all') $category = '';\r
943                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
944                 $this->_setBlogCategory($b, $category);\r
945                 $this->_preBlogContent('otherarchivelist',$b);\r
946                 $b->showArchiveList($template, 'month', $limit);\r
947                 $this->_postBlogContent('otherarchivelist',$b);\r
948         }\r
949 \r
950         function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {\r
951                 global $manager;\r
952                 if ($category == 'all') $category = '';\r
953                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
954                 $this->_setBlogCategory($b, $category);\r
955                 $this->_preBlogContent('otherarchivelist',$b);\r
956                 $b->showArchiveList($template, 'day', $limit);\r
957                 $this->_postBlogContent('otherarchivelist',$b);\r
958         }\r
959 \r
960         function parse_searchresults($template, $maxresults = 50 ) {\r
961                 global $blog, $query, $amount, $startpos;\r
962 \r
963                 $this->_setBlogCategory($blog, '');     // need this to select default category\r
964                 $this->_preBlogContent('searchresults',$blog);\r
965                 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);\r
966                 $this->_postBlogContent('searchresults',$blog);\r
967         }\r
968 \r
969         function parse_othersearchresults($blogname, $template, $maxresults = 50) {\r
970                 global $query, $amount, $manager, $startpos;\r
971                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
972                 $this->_setBlogCategory($b, '');        // need this to select default category\r
973                 $this->_preBlogContent('othersearchresults',$b);\r
974                 $b->search($query, $template, $amount, $maxresults, $startpos);\r
975                 $this->_postBlogContent('othersearchresults',$b);\r
976         }\r
977 \r
978         // includes the search query\r
979         function parse_query() {\r
980                 global $query;\r
981                 echo htmlspecialchars($query);\r
982         }\r
983                         \r
984         // include nucleus versionnumber\r
985         function parse_version() {\r
986                 global $nucleus;\r
987                 echo 'Nucleus CMS ' . $nucleus['version'];\r
988         }\r
989         \r
990 \r
991         function parse_errormessage() {\r
992                 global $errormessage;\r
993                 echo $errormessage;\r
994         }\r
995 \r
996 \r
997         function parse_imagetext() {                    \r
998                 echo htmlspecialchars(requestVar('imagetext'));\r
999         }\r
1000         \r
1001         function parse_image($what = 'imgtag') {\r
1002                 global $CONF;\r
1003 \r
1004                 $imagetext      = htmlspecialchars(requestVar('imagetext'));\r
1005                 $imagepopup = requestVar('imagepopup');\r
1006                 $width          = intRequestVar('width');\r
1007                 $height         = intRequestVar('height');\r
1008                 $fullurl        = htmlspecialchars($CONF['MediaURL'] . $imagepopup);\r
1009                 \r
1010                 switch($what)\r
1011                 {\r
1012                         case 'url':\r
1013                                 echo $fullurl;\r
1014                                 break;\r
1015                         case 'width':\r
1016                                 echo $width;\r
1017                                 break;\r
1018                         case 'height':\r
1019                                 echo $height;\r
1020                                 break;\r
1021                         case 'caption':\r
1022                         case 'text':                    \r
1023                                 echo $imagetext;\r
1024                                 break;\r
1025                         case 'imgtag':\r
1026                         default:\r
1027                                 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" title=\"$imagetext\" />";\r
1028                                 break;\r
1029                 }\r
1030         }\r
1031         \r
1032         // When commentform is not used, to include a hidden field with itemid\r
1033         function parse_vars() {\r
1034                 global $itemid;\r
1035                 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';\r
1036         }\r
1037         \r
1038         // include a sitevar\r
1039         function parse_sitevar($which) {\r
1040                 global $CONF;\r
1041                 switch($which) {\r
1042                         case 'url':\r
1043                                 echo $CONF['IndexURL'];\r
1044                                 break;\r
1045                         case 'name':\r
1046                                 echo $CONF['SiteName'];\r
1047                                 break;\r
1048                         case 'admin':\r
1049                                 echo $CONF['AdminEmail'];\r
1050                                 break;\r
1051                         case 'adminurl':\r
1052                                 echo $CONF['AdminURL'];\r
1053                 }                       \r
1054         }\r
1055         \r
1056         // shortcut for admin url\r
1057         function parse_adminurl() { $this->parse_sitevar('adminurl'); }\r
1058         \r
1059         function parse_blogsetting($which) {\r
1060                 global $blog;\r
1061                 switch($which) {\r
1062                         case 'id':\r
1063                                 echo $blog->getID();\r
1064                                 break;\r
1065                         case 'url':\r
1066                                 echo $blog->getURL();\r
1067                                 break;\r
1068                         case 'name':\r
1069                                 echo $blog->getName();\r
1070                                 break;\r
1071                         case 'desc':\r
1072                                 echo $blog->getDescription();\r
1073                                 break;\r
1074                         case 'short':\r
1075                                 echo $blog->getShortName();\r
1076                                 break;                          \r
1077                 }       \r
1078         }\r
1079         \r
1080         // includes a member info thingie\r
1081         function parse_member($what) {\r
1082                 global $memberinfo, $member;\r
1083                 \r
1084                 // 1. only allow the member-details-page specific variables on member pages\r
1085                 if ($this->skintype == 'member') {\r
1086 \r
1087                         switch($what) {\r
1088                                 case 'name':\r
1089                                         echo $memberinfo->getDisplayName();\r
1090                                         break;\r
1091                                 case 'realname':\r
1092                                         echo $memberinfo->getRealName();\r
1093                                         break;\r
1094                                 case 'notes':\r
1095                                         echo $memberinfo->getNotes();\r
1096                                         break;\r
1097                                 case 'url':\r
1098                                         echo $memberinfo->getURL();\r
1099                                         break;\r
1100                                 case 'email':\r
1101                                         echo $memberinfo->getEmail();\r
1102                                         break;\r
1103                                 case 'id':\r
1104                                         echo $memberinfo->getID();\r
1105                                         break;                                  \r
1106                         }       \r
1107                 }\r
1108                 \r
1109                 // 2. the next bunch of options is available everywhere, as long as the user is logged in\r
1110                 if ($member->isLoggedIn())\r
1111                 {\r
1112                         switch($what) {\r
1113                                 case 'yourname':\r
1114                                         echo $member->getDisplayName();\r
1115                                         break;\r
1116                                 case 'yourrealname':\r
1117                                         echo $member->getRealName();\r
1118                                         break;\r
1119                                 case 'yournotes':\r
1120                                         echo $member->getNotes();\r
1121                                         break;\r
1122                                 case 'yoururl':\r
1123                                         echo $member->getURL();\r
1124                                         break;\r
1125                                 case 'youremail':\r
1126                                         echo $member->getEmail();\r
1127                                         break;\r
1128                                 case 'yourid':\r
1129                                         echo $member->getID();\r
1130                                         break;                                                                  \r
1131                         }       \r
1132                 }\r
1133 \r
1134         }\r
1135         \r
1136         function parse_preview($template) {\r
1137                 global $blog, $CONF, $manager;\r
1138                 \r
1139                 $template =& $manager->getTemplate($template);\r
1140                 $row['body'] = '<span id="prevbody"></span>';\r
1141                 $row['title'] = '<span id="prevtitle"></span>';\r
1142                 $row['more'] = '<span id="prevmore"></span>';\r
1143                 $row['itemlink'] = '';\r
1144                 $row['itemid'] = 0; $row['blogid'] = $blog->getID();\r
1145                 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);\r
1146                 echo TEMPLATE::fill($template['ITEM'],$row);\r
1147                 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);\r
1148         }\r
1149         \r
1150         function parse_additemform() {\r
1151                 global $blog, $CONF;\r
1152                 $this->formdata = array(\r
1153                         'adminurl' => htmlspecialchars($CONF['AdminURL']),\r
1154                         'catid' => $blog->getDefaultCategory()\r
1155                 );\r
1156                 $blog->InsertJavaScriptInfo(); \r
1157                 $this->doForm('additemform');\r
1158         }\r
1159 \r
1160         /**\r
1161           * Executes a plugin skinvar\r
1162           *\r
1163           * @param pluginName name of plugin (without the NP_)\r
1164           * \r
1165           * extra parameters can be added\r
1166           */\r
1167         function parse_plugin($pluginName) {\r
1168                 global $manager;\r
1169                 \r
1170                 // only continue when the plugin is really installed\r
1171                 if (!$manager->pluginInstalled('NP_' . $pluginName))\r
1172                         return;\r
1173                 \r
1174                 $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
1175                 if (!$plugin) return;\r
1176 \r
1177                 // get arguments\r
1178                 $params = func_get_args();\r
1179                 \r
1180                 // remove plugin name \r
1181                 array_shift($params);\r
1182                 \r
1183                 // add skin type on front\r
1184                 array_unshift($params, $this->skintype);\r
1185                 \r
1186                 call_user_func_array(array(&$plugin,'doSkinVar'), $params);\r
1187         }\r
1188 \r
1189                         \r
1190         function parse_commentform($destinationurl = '') {\r
1191                 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;\r
1192                 \r
1193                 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)\r
1194                 if (stristr($destinationurl, 'action.php')) {\r
1195                         $args = func_get_args();\r
1196                         $destinationurl = $args[1];\r
1197                         ACTIONLOG::add(WARNING,'actionurl is not longer a parameter on commentform skinvars. Moved to be a global setting instead.');\r
1198                 }\r
1199                 \r
1200                 $actionurl = $CONF['ActionURL'];\r
1201                 \r
1202                 // if item is closed, show message and do nothing\r
1203                 $item =& $manager->getItem($itemid,0,0);\r
1204                 if ($item['closed'] || !$blog->commentsEnabled()) {\r
1205                         $this->doForm('commentform-closed');\r
1206                         return;\r
1207                 }\r
1208                 \r
1209                 if (!$destinationurl)\r
1210                         $destinationurl = createItemLink($itemid, $this->linkparams);\r
1211 \r
1212                 // values to prefill\r
1213                 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');\r
1214                 if (!$user) $user = postVar('user');\r
1215                 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');\r
1216                 if (!$userid) $userid = postVar('userid');\r
1217                 $body = postVar('body');\r
1218                 \r
1219                 $this->formdata = array(\r
1220                         'destinationurl' => htmlspecialchars($destinationurl),\r
1221                         'actionurl' => htmlspecialchars($actionurl),\r
1222                         'itemid' => $itemid,\r
1223                         'user' => htmlspecialchars($user),\r
1224                         'userid' => htmlspecialchars($userid),                  \r
1225                         'body' => htmlspecialchars($body),                      \r
1226                         'membername' => $member->getDisplayName(),\r
1227                         'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''\r
1228                 );\r
1229                 \r
1230                 if (!$member->isLoggedIn()) {\r
1231                         $this->doForm('commentform-notloggedin');\r
1232                 } else {\r
1233                         $this->doForm('commentform-loggedin');          \r
1234                 }\r
1235         }\r
1236 \r
1237         function parse_loginform() {\r
1238                 global $member, $CONF;\r
1239                 if (!$member->isLoggedIn()) {\r
1240                         $filename = 'loginform-notloggedin';\r
1241                         $this->formdata = array();\r
1242                 } else {\r
1243                         $filename = 'loginform-loggedin';\r
1244                         $this->formdata = array(\r
1245                                 'membername' => $member->getDisplayName(),\r
1246                         );\r
1247                 }\r
1248                 $this->doForm($filename);\r
1249         }       \r
1250         \r
1251         \r
1252         function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {\r
1253                 global $member, $CONF, $memberid;\r
1254                 \r
1255                 if ($desturl == '') {\r
1256                         if ($CONF['URLMode'] == 'pathinfo')\r
1257                                 $desturl = createMemberLink($memberid);\r
1258                         else\r
1259                                 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);                             \r
1260                 }\r
1261                         \r
1262                 $message = postVar('message');\r
1263                 $frommail = postVar('frommail');\r
1264                 \r
1265                 $this->formdata = array(\r
1266                         'url' => htmlspecialchars($desturl),\r
1267                         'actionurl' => htmlspecialchars($CONF['ActionURL']),\r
1268                         'memberid' => $memberid,\r
1269                         'rows' => $rows,\r
1270                         'cols' => $cols,\r
1271                         'message' => htmlspecialchars($message),\r
1272                         'frommail' => htmlspecialchars($frommail)\r
1273                 );\r
1274                 if ($member->isLoggedIn()) {\r
1275                         $this->doForm('membermailform-loggedin');\r
1276                 } else if ($CONF['NonmemberMail']) {\r
1277                         $this->doForm('membermailform-notloggedin');            \r
1278                 } else {\r
1279                         $this->doForm('membermailform-disallowed');             \r
1280                 }\r
1281 \r
1282         }\r
1283 \r
1284         function parse_searchform($blogname = '') {\r
1285                 global $CONF, $manager, $maxresults;\r
1286                 if ($blogname) {\r
1287                         $blog =& $manager->getBlog(getBlogIDFromName($blogname));\r
1288                 } else {\r
1289                         global $blog;\r
1290                 }\r
1291                 // use default blog when no blog is selected\r
1292                 $this->formdata = array(\r
1293                         'id' => $blog?$blog->getID():$CONF['DefaultBlog'],\r
1294                         'query' => htmlspecialchars(getVar('query')),\r
1295                 );\r
1296                 $this->doForm('searchform');\r
1297         }\r
1298 \r
1299         function parse_nucleusbutton($imgurl = '',\r
1300                                                              $imgwidth = '85',\r
1301                                                              $imgheight = '31') {\r
1302                 global $CONF;\r
1303                 if ($imgurl == '') {\r
1304                         $imgurl = $CONF['AdminURL'] . 'nucleus.gif';\r
1305                 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){\r
1306                         // when skindit IncludeMode is used: start from skindir\r
1307                         $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;\r
1308                 }\r
1309 \r
1310                 $this->formdata = array(\r
1311                         'imgurl' => $imgurl,\r
1312                         'imgwidth' => $imgwidth,\r
1313                         'imgheight' => $imgheight,\r
1314                 );\r
1315                 $this->doForm('nucleusbutton');\r
1316         }\r
1317         \r
1318         function parse_self() {\r
1319                 global $CONF;\r
1320                 echo $CONF['Self'];\r
1321         }\r
1322         \r
1323         function parse_referer() {\r
1324                 echo htmlspecialchars(serverVar('HTTP_REFERER'));\r
1325         }\r
1326         \r
1327         /**\r
1328           * Helper function that sets the category that a blog will need to use \r
1329           *\r
1330           * @param $blog\r
1331           *             An object of the blog class, passed by reference (we want to make changes to it)\r
1332           * @param $catname\r
1333           *             The name of the category to use\r
1334           */\r
1335         function _setBlogCategory(&$blog, $catname) {\r
1336                 global $catid;\r
1337                 if ($catname != '')\r
1338                         $blog->setSelectedCategoryByName($catname);\r
1339                 else\r
1340                         $blog->setSelectedCategory($catid);\r
1341         }\r
1342         \r
1343         function _preBlogContent($type, &$blog) {\r
1344                 global $manager;\r
1345                 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));\r
1346         }\r
1347 \r
1348         function _postBlogContent($type, &$blog) {\r
1349                 global $manager;\r
1350                 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));\r
1351         }\r
1352 \r
1353 }\r
1354 \r
1355 ?>\r