OSDN Git Service

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