OSDN Git Service

applied some bug fixes
[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-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                                 if ($name == 'trackback' && $manager->pluginInstalled('NP_TrackBack')) {\r
444                                         $plugin =& $manager->getPlugin('NP_TrackBack');\r
445                                         if ($plugin != NULL && $blog){\r
446                                                 $bid = $blog->getID();\r
447                                                 if ($value === '1') $value = 'yes';\r
448                                                 if ($value === '0') $value = 'no';\r
449                                                 if ($plugin->getOption('AcceptPing') == 'no' ) {\r
450                                                         $condition = ($value == 'no');\r
451                                                         } else {\r
452                                                         $tb_option = $plugin->getBlogOption($bid,'AllowTrackBack');\r
453                                                         if (!$tb_option) {\r
454                                                                 $condition = ($value == 'yes');\r
455                                                         } else {\r
456                                                                 $condition = ($tb_option == $value);\r
457                                                         }\r
458                                                 }\r
459                                         }\r
460                                         break;\r
461                                 }\r
462                                 $condition = ($blog && ($blog->getSetting($name) == $value));\r
463                                 break;\r
464                         case 'loggedin':\r
465                                 $condition = $member->isLoggedIn();\r
466                                 break;\r
467                         case 'onteam':\r
468                                 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);\r
469                                 break;\r
470                         case 'admin':\r
471                                 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);\r
472                                 break;                          \r
473                         case 'nextitem':\r
474                                 $condition = ($itemidnext != '');\r
475                                 break;\r
476                         case 'previtem':\r
477                                 $condition = ($itemidprev != ''); \r
478                                 break;\r
479                         case 'skintype':\r
480                                 $condition = ($name == $this->skintype);\r
481                                 break;\r
482                         /*\r
483                                 hasplugin,PlugName\r
484                                         -> checks if plugin exists\r
485                                 hasplugin,PlugName,OptionName\r
486                                         -> checks if the option OptionName from plugin PlugName is not set to 'no'\r
487                                 hasplugin,PlugName,OptionName=value\r
488                                         -> checks if the option OptionName from plugin PlugName is set to value\r
489                         */\r
490                         case 'hasplugin':\r
491                 $condition = false;\r
492                 // (pluginInstalled method won't write a message in the actionlog on failure)\r
493                 if ($manager->pluginInstalled('NP_'.$name)) \r
494                 {\r
495                         $plugin =& $manager->getPlugin('NP_' . $name);\r
496                         if ($plugin != NULL){\r
497                             if ($value == "") {\r
498                                 $condition = true;\r
499                             } else {\r
500                                 list($name2, $value2) = explode('=', $value, 2);\r
501                                 if ($value2 == "" && $plugin->getOption($name2) != 'no') {\r
502                                     $condition = true;\r
503                                 } else if ($plugin->getOption($name2) == $value2) {\r
504                                     $condition = true;\r
505                                 }\r
506                             }\r
507                         }\r
508                 }\r
509                 break;                          \r
510                         default:        \r
511                                 return;\r
512                 }\r
513                 $this->_addIfCondition($condition);\r
514         }\r
515         \r
516         function _ifOnTeam($blogName = '') {\r
517                 global $blog, $member, $manager;\r
518                 \r
519                 // when no blog found\r
520                 if (($blogName == '') && (!is_object($blog)))\r
521                         return 0;\r
522                 \r
523                 // explicit blog selection\r
524                 if ($blogName != '') \r
525                         $blogid = getBlogIDFromName($blogName); \r
526                 \r
527                 if (($blogName == '') || !$manager->existsBlogID($blogid))\r
528                         // use current blog\r
529                         $blogid = $blog->getID();\r
530                         \r
531                 return $member->teamRights($blogid);\r
532         }\r
533         \r
534         function _ifAdmin($blogName = '') {\r
535                 global $blog, $member, $manager;\r
536 \r
537                 // when no blog found\r
538                 if (($blogName == '') && (!is_object($blog)))\r
539                         return 0;\r
540 \r
541                 // explicit blog selection\r
542                 if ($blogName != '')\r
543                         $blogid = getBlogIDFromName($blogName);\r
544 \r
545                 if (($blogName == '') || !$manager->existsBlogID($blogid))\r
546                         // use current blog\r
547                         $blogid = $blog->getID();\r
548 \r
549                 return $member->isBlogAdmin($blogid);\r
550         }       \r
551         \r
552         function parse_ifcat($text = '') {\r
553                 if ($text == '') {\r
554                         // new behaviour\r
555                         $this->parse_if('category');\r
556                 } else {\r
557                         // old behaviour\r
558                         global $catid, $blog;\r
559                         if ($blog->isValidCategory($catid))\r
560                                 echo $text;\r
561                 }\r
562         }\r
563         \r
564         // a link to the today page (depending on selected blog, etc...)\r
565         function parse_todaylink($linktext = '') {\r
566                 global $blog, $CONF;\r
567                 if ($blog)\r
568                         echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);\r
569                 else\r
570                         echo $this->_link($CONF['SiteUrl'], $linktext);\r
571         }\r
572         \r
573         // a link to the archives for the current blog (or for default blog)\r
574         function parse_archivelink($linktext = '') {\r
575                 global $blog, $CONF;\r
576                 if ($blog)\r
577                         echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);\r
578                 else\r
579                         echo $this->_link(createArchiveListLink(), $linktext);\r
580         }\r
581 \r
582         // include itemid of prev item\r
583         function parse_previtem() {\r
584                 global $itemidprev;\r
585                 echo $itemidprev;\r
586         }\r
587 \r
588         // include itemtitle of prev item\r
589         function parse_previtemtitle() {\r
590                 global $itemtitleprev;\r
591                 echo htmlspecialchars($itemtitleprev);\r
592         }\r
593 \r
594         // include itemid of next item\r
595         function parse_nextitem() {\r
596                 global $itemidnext;\r
597                 echo $itemidnext;\r
598         }\r
599 \r
600         // include itemtitle of next item\r
601         function parse_nextitemtitle() {\r
602                 global $itemtitlenext;\r
603                 echo htmlspecialchars($itemtitlenext);\r
604         }\r
605 \r
606         function parse_prevarchive() {\r
607                 global $archiveprev;\r
608                 echo $archiveprev;\r
609         }\r
610 \r
611         function parse_nextarchive() {\r
612                 global $archivenext;\r
613                 echo $archivenext;\r
614         }\r
615 \r
616         function parse_archivetype() {\r
617                 global $archivetype;\r
618                 echo $archivetype;\r
619         }\r
620 \r
621         function parse_prevlink($linktext = '', $amount = 10) {\r
622                 global $itemidprev, $archiveprev, $startpos;\r
623 \r
624                 if ($this->skintype == 'item')\r
625                         $this->_itemlink($itemidprev, $linktext);\r
626             else if ($this->skintype == 'search' || $this->skintype == 'index')\r
627                 $this->_searchlink($amount, $startpos, 'prev', $linktext);\r
628                 else\r
629                         $this->_archivelink($archiveprev, $linktext);\r
630         }\r
631         \r
632         function parse_nextlink($linktext = '', $amount = 10) {\r
633                 global $itemidnext, $archivenext, $startpos;\r
634                 if ($this->skintype == 'item')\r
635                         $this->_itemlink($itemidnext, $linktext);\r
636             else if ($this->skintype == 'search' || $this->skintype == 'index')\r
637                 $this->_searchlink($amount, $startpos, 'next', $linktext);\r
638                 else\r
639                         $this->_archivelink($archivenext, $linktext);\r
640         }\r
641         \r
642         /**\r
643          * returns either\r
644          *              - a raw link (html/xml encoded) when no linktext is provided\r
645          *              - a (x)html <a href... link when a text is present (text htmlencoded)\r
646          */\r
647         function _link($url, $linktext = '')\r
648         {\r
649                 $u = htmlspecialchars($url);\r
650                 $u = preg_replace("/&amp;amp;/",'&amp;',$u); // fix URLs that already had encoded ampersands\r
651                 if ($linktext != '')\r
652                         $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>';\r
653                 else\r
654                         $l = $u;\r
655                 return $l;      \r
656         }\r
657 \r
658         /**\r
659          * Outputs a next/prev link\r
660          *\r
661          * @param $maxresults\r
662          *              The maximum amount of items shown per page (e.g. 10)\r
663          * @param $startpos\r
664          *              Current start position (requestVar('startpos'))\r
665          * @param $direction\r
666          *              either 'prev' or 'next'\r
667          * @param $linktext\r
668          *              When present, the output will be a full <a href...> link. When empty,\r
669          *              only a raw link will be outputted\r
670          */\r
671     function _searchlink($maxresults, $startpos, $direction, $linktext = '') {\r
672         global $CONF, $blog, $query, $amount;\r
673         // TODO: Move request uri to linkparams. this is ugly. sorry for that.\r
674         $startpos       = intval($startpos);            // will be 0 when empty. \r
675         $parsed         = parse_url(serverVar('REQUEST_URI'));\r
676         $parsed         = $parsed['query'];\r
677                 $url            = '';\r
678         \r
679         switch ($direction) {\r
680             case 'prev':\r
681                 if ( intval($startpos) - intval($maxresults) >= 0) {\r
682                     $startpos   = intval($startpos) - intval($maxresults);\r
683                     $url                = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);\r
684                 }\r
685                 break;\r
686             case 'next':\r
687                 $iAmountOnPage = $this->amountfound;\r
688                 if ($iAmountOnPage == 0)\r
689                 {\r
690                         // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]\r
691                         // try a count query\r
692                         switch ($this->skintype)\r
693                         {\r
694                                 case 'index':\r
695                                         $sqlquery = $blog->getSqlBlog('', 'count');\r
696                                         break;\r
697                                 case 'search':\r
698                                         $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');\r
699                                         break;\r
700                         }\r
701                         if ($sqlquery) \r
702                                 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);\r
703                 }\r
704                 if (intval($iAmountOnPage) >= intval($maxresults)) {\r
705                         $startpos       = intval($startpos) + intval($maxresults);                \r
706                         $url            = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);\r
707                 }\r
708                 break;\r
709             default:\r
710                 break;\r
711         } // switch($direction)\r
712 \r
713                 if ($url != '')\r
714                         echo $this->_link($url, $linktext);        \r
715     }\r
716 \r
717         function _itemlink($id, $linktext = '') {\r
718                 global $CONF;\r
719                 if ($id)\r
720                         echo $this->_link(createItemLink($id, $this->linkparams), $linktext);\r
721                 else\r
722                         $this->parse_todaylink($linktext);\r
723         }\r
724 \r
725         function _archivelink($id, $linktext = '') {\r
726                 global $CONF, $blog;\r
727                 if ($id)\r
728                         echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);\r
729                 else\r
730                         $this->parse_todaylink($linktext);\r
731         }\r
732         \r
733         \r
734         function parse_itemlink($linktext = '') {       \r
735                 $this->_itemlink($itemid, $linktext);\r
736         }\r
737         \r
738         /**\r
739           * %archivedate(locale,date format)%\r
740           */\r
741         function parse_archivedate($locale = '-def-') {\r
742                 global $archive;\r
743                 \r
744                 if ($locale == '-def-')\r
745                         setlocale(LC_TIME,$template['LOCALE']);\r
746                 else\r
747                         setlocale(LC_TIME,$locale);\r
748                 \r
749                 // get archive date\r
750                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
751 \r
752                 // get format           \r
753                 $args = func_get_args();\r
754                 // format can be spread over multiple parameters\r
755                 if (sizeof($args) > 1) {\r
756                         // take away locale\r
757                         array_shift($args);\r
758                         // implode\r
759                         $format=implode(',',$args);\r
760                 } elseif ($d == 0) {\r
761                         $format = '%B %Y';      \r
762                 } else {\r
763                         $format = '%d %B %Y';   \r
764                 }\r
765                 \r
766                 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));             \r
767         }\r
768         \r
769         function parse_blog($template, $amount = 10, $category = '') {\r
770                 global $blog, $startpos;\r
771                 \r
772                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
773                 $this->_setBlogCategory($blog, $category);\r
774                 $this->_preBlogContent('blog',$blog);\r
775                 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);\r
776                 $this->_postBlogContent('blog',$blog);\r
777         }\r
778 \r
779         function parse_otherblog($blogname, $template, $amount = 10, $category = '') {\r
780                 global $manager;\r
781 \r
782                 list($limit, $offset) = sscanf($amount, '%d(%d)');\r
783 \r
784                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
785                 $this->_setBlogCategory($b, $category);\r
786                 $this->_preBlogContent('otherblog',$b);\r
787                 $this->amountfound = $b->readLog($template, $limit, $offset);\r
788                 $this->_postBlogContent('otherblog',$b);\r
789         }\r
790 \r
791         // include one item (no comments)\r
792         function parse_item($template) {\r
793                 global $blog, $itemid, $highlight;\r
794                 $this->_setBlogCategory($blog, '');     // need this to select default category\r
795                 $this->_preBlogContent('item',$blog);\r
796                 $r = $blog->showOneitem($itemid, $template, $highlight);\r
797                 if ($r == 0)\r
798                         echo _ERROR_NOSUCHITEM;\r
799                 $this->_postBlogContent('item',$blog);\r
800         }\r
801 \r
802         function parse_itemid() {\r
803                 global $itemid;\r
804                 echo $itemid;\r
805         }\r
806 \r
807 \r
808         // include comments for one item\r
809         function parse_comments($template) {\r
810                 global $itemid, $manager, $blog, $highlight;\r
811                 $template = TEMPLATE::read($template);\r
812 \r
813                 // create parser object & action handler\r
814                 $actions = new ITEMACTIONS($blog);\r
815                 $parser = new PARSER($actions->getDefinedActions(),$actions);\r
816                 $actions->setTemplate($template);\r
817                 $actions->setParser($parser);\r
818                 $item = ITEM::getitem($itemid, 0, 0);\r
819                 $actions->setCurrentItem($item);\r
820 \r
821                 $comments = new COMMENTS($itemid);\r
822                 $comments->setItemActions($actions);\r
823                 $comments->showComments($template, -1, 1, $highlight);  // shows ALL comments\r
824         }\r
825 \r
826         function parse_archive($template, $category = '') {\r
827                 global $blog, $archive;\r
828                 // can be used with either yyyy-mm or yyyy-mm-dd\r
829                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
830                 $this->_setBlogCategory($blog, $category);\r
831                 $this->_preBlogContent('achive',$blog);\r
832                 $blog->showArchive($template, $y, $m, $d);\r
833                 $this->_postBlogContent('achive',$blog);\r
834 \r
835         }\r
836 \r
837         function parse_otherarchive($blogname, $template, $category = '') {\r
838                 global $archive, $manager;\r
839                 sscanf($archive,'%d-%d-%d',$y,$m,$d);\r
840                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
841                 $this->_setBlogCategory($b, $category);\r
842                 $this->_preBlogContent('otherachive',$b);\r
843                 $b->showArchive($template, $y, $m, $d);\r
844                 $this->_postBlogContent('otherachive',$b);\r
845         }\r
846 \r
847         function parse_archivelist($template, $category = 'all', $limit = 0) {\r
848                 global $blog;\r
849                 if ($category == 'all') $category = '';\r
850                 $this->_preBlogContent('archivelist',$blog);\r
851                 $this->_setBlogCategory($blog, $category);\r
852                 $blog->showArchiveList($template, 'month', $limit);\r
853                 $this->_postBlogContent('archivelist',$blog);\r
854         }\r
855 \r
856         function parse_archivedaylist($template, $category = 'all', $limit = 0) {\r
857                 global $blog;\r
858                 if ($category == 'all') $category = '';\r
859                 $this->_preBlogContent('archivelist',$blog);\r
860                 $this->_setBlogCategory($blog, $category);\r
861                 $blog->showArchiveList($template, 'day', $limit);\r
862                 $this->_postBlogContent('archivelist',$blog);\r
863         }\r
864 \r
865 \r
866         function parse_itemtitle() {\r
867                 global $manager, $itemid;\r
868                 $item =& $manager->getItem($itemid,0,0);\r
869                 echo htmlspecialchars(strip_tags($item['title']));\r
870         }\r
871 \r
872         function parse_categorylist($template, $blogname = '') {\r
873                 global $blog, $manager;\r
874 \r
875                 if ($blogname == '') {\r
876                         $this->_preBlogContent('categorylist',$blog);\r
877                         $blog->showCategoryList($template);\r
878                         $this->_postBlogContent('categorylist',$blog);\r
879                 } else {\r
880                         $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
881                         $this->_preBlogContent('categorylist',$b);\r
882                         $b->showCategoryList($template);\r
883                         $this->_postBlogContent('categorylist',$b);\r
884                 }\r
885         }\r
886 \r
887         function parse_category($type = 'name') {\r
888                 global $catid, $blog;\r
889                 if (!$blog->isValidCategory($catid))\r
890                         return;\r
891 \r
892                 switch($type) {\r
893                         case 'name':\r
894                                 echo $blog->getCategoryName($catid);\r
895                                 break;\r
896                         case 'desc':\r
897                                 echo $blog->getCategoryDesc($catid);\r
898                                 break;\r
899                         case 'id':\r
900                                 echo $catid;\r
901                                 break;\r
902                 }\r
903         }\r
904 \r
905         function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {\r
906                 global $manager;\r
907                 if ($category == 'all') $category = '';\r
908                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
909                 $this->_setBlogCategory($b, $category);\r
910                 $this->_preBlogContent('otherarchivelist',$b);\r
911                 $b->showArchiveList($template, 'month', $limit);\r
912                 $this->_postBlogContent('otherarchivelist',$b);\r
913         }\r
914 \r
915         function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {\r
916                 global $manager;\r
917                 if ($category == 'all') $category = '';\r
918                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
919                 $this->_setBlogCategory($b, $category);\r
920                 $this->_preBlogContent('otherarchivelist',$b);\r
921                 $b->showArchiveList($template, 'day', $limit);\r
922                 $this->_postBlogContent('otherarchivelist',$b);\r
923         }\r
924 \r
925         function parse_searchresults($template, $maxresults = 50 ) {\r
926                 global $blog, $query, $amount, $startpos;\r
927 \r
928                 $this->_setBlogCategory($blog, '');     // need this to select default category\r
929                 $this->_preBlogContent('searchresults',$blog);\r
930                 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);\r
931                 $this->_postBlogContent('searchresults',$blog);\r
932         }\r
933 \r
934         function parse_othersearchresults($blogname, $template, $maxresults = 50) {\r
935                 global $query, $amount, $manager, $startpos;\r
936                 $b =& $manager->getBlog(getBlogIDFromName($blogname));\r
937                 $this->_setBlogCategory($b, '');        // need this to select default category\r
938                 $this->_preBlogContent('othersearchresults',$b);\r
939                 $b->search($query, $template, $amount, $maxresults, $startpos);\r
940                 $this->_postBlogContent('othersearchresults',$b);\r
941         }\r
942 \r
943         // includes the search query\r
944         function parse_query() {\r
945                 global $query;\r
946                 echo htmlspecialchars($query);\r
947         }\r
948                         \r
949         // include nucleus versionnumber\r
950         function parse_version() {\r
951                 global $nucleus;\r
952                 echo 'Nucleus ' . $nucleus['version'];\r
953         }\r
954         \r
955 \r
956         function parse_errormessage() {\r
957                 global $errormessage;\r
958                 echo $errormessage;\r
959         }\r
960 \r
961 \r
962         function parse_imagetext() {                    \r
963                 echo htmlspecialchars(requestVar('imagetext'));\r
964         }\r
965         \r
966         function parse_image($what = 'imgtag') {\r
967                 global $CONF;\r
968 \r
969                 $imagetext      = htmlspecialchars(requestVar('imagetext'));\r
970                 $imagepopup = requestVar('imagepopup');\r
971                 $width          = intRequestVar('width');\r
972                 $height         = intRequestVar('height');\r
973                 $fullurl        = htmlspecialchars($CONF['MediaURL'] . $imagepopup);\r
974                 \r
975                 switch($what)\r
976                 {\r
977                         case 'url':\r
978                                 echo $fullurl;\r
979                                 break;\r
980                         case 'width':\r
981                                 echo $width;\r
982                                 break;\r
983                         case 'height':\r
984                                 echo $height;\r
985                                 break;\r
986                         case 'caption':\r
987                         case 'text':                    \r
988                                 echo $imagetext;\r
989                                 break;\r
990                         case 'imgtag':\r
991                         default:\r
992                                 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" />";\r
993                                 break;\r
994                 }\r
995         }\r
996         \r
997         // When commentform is not used, to include a hidden field with itemid\r
998         function parse_vars() {\r
999                 global $itemid;\r
1000                 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';\r
1001         }\r
1002         \r
1003         // include a sitevar\r
1004         function parse_sitevar($which) {\r
1005                 global $CONF;\r
1006                 switch($which) {\r
1007                         case 'url':\r
1008                                 echo $CONF['IndexURL'];\r
1009                                 break;\r
1010                         case 'name':\r
1011                                 echo $CONF['SiteName'];\r
1012                                 break;\r
1013                         case 'admin':\r
1014                                 echo $CONF['AdminEmail'];\r
1015                                 break;\r
1016                         case 'adminurl':\r
1017                                 echo $CONF['AdminURL'];\r
1018                 }                       \r
1019         }\r
1020         \r
1021         // shortcut for admin url\r
1022         function parse_adminurl() { $this->parse_sitevar('adminurl'); }\r
1023         \r
1024         function parse_blogsetting($which) {\r
1025                 global $blog;\r
1026                 switch($which) {\r
1027                         case 'id':\r
1028                                 echo $blog->getID();\r
1029                                 break;\r
1030                         case 'url':\r
1031                                 echo $blog->getURL();\r
1032                                 break;\r
1033                         case 'name':\r
1034                                 echo $blog->getName();\r
1035                                 break;\r
1036                         case 'desc':\r
1037                                 echo $blog->getDescription();\r
1038                                 break;\r
1039                         case 'short':\r
1040                                 echo $blog->getShortName();\r
1041                                 break;                          \r
1042                 }       \r
1043         }\r
1044         \r
1045         // includes a member info thingie\r
1046         function parse_member($what) {\r
1047                 global $memberinfo, $member;\r
1048                 \r
1049                 // 1. only allow the member-details-page specific variables on member pages\r
1050                 if ($this->skintype == 'member') {\r
1051 \r
1052                         switch($what) {\r
1053                                 case 'name':\r
1054                                         echo $memberinfo->getDisplayName();\r
1055                                         break;\r
1056                                 case 'realname':\r
1057                                         echo $memberinfo->getRealName();\r
1058                                         break;\r
1059                                 case 'notes':\r
1060                                         echo $memberinfo->getNotes();\r
1061                                         break;\r
1062                                 case 'url':\r
1063                                         echo $memberinfo->getURL();\r
1064                                         break;\r
1065                                 case 'email':\r
1066                                         echo $memberinfo->getEmail();\r
1067                                         break;\r
1068                                 case 'id':\r
1069                                         echo $memberinfo->getID();\r
1070                                         break;                                  \r
1071                         }       \r
1072                 }\r
1073                 \r
1074                 // 2. the next bunch of options is available everywhere, as long as the user is logged in\r
1075                 if ($member->isLoggedIn())\r
1076                 {\r
1077                         switch($what) {\r
1078                                 case 'yourname':\r
1079                                         echo $member->getDisplayName();\r
1080                                         break;\r
1081                                 case 'yourrealname':\r
1082                                         echo $member->getRealName();\r
1083                                         break;\r
1084                                 case 'yournotes':\r
1085                                         echo $member->getNotes();\r
1086                                         break;\r
1087                                 case 'yoururl':\r
1088                                         echo $member->getURL();\r
1089                                         break;\r
1090                                 case 'youremail':\r
1091                                         echo $member->getEmail();\r
1092                                         break;\r
1093                                 case 'yourid':\r
1094                                         echo $member->getID();\r
1095                                         break;                                                                  \r
1096                         }       \r
1097                 }\r
1098 \r
1099         }\r
1100         \r
1101         function parse_preview($template) {\r
1102                 global $blog, $CONF;\r
1103                 \r
1104                 $template = TEMPLATE::read($template);\r
1105                 $row['body'] = '<span id="prevbody"></span>';\r
1106                 $row['title'] = '<span id="prevtitle"></span>';\r
1107                 $row['more'] = '<span id="prevmore"></span>';\r
1108                 $row['itemlink'] = '';\r
1109                 $row['itemid'] = 0; $row['blogid'] = $blog->getID();\r
1110                 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);\r
1111                 echo TEMPLATE::fill($template['ITEM'],$row);\r
1112                 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);\r
1113         }\r
1114         \r
1115         function parse_additemform() {\r
1116                 global $blog, $CONF;\r
1117                 $this->formdata = array(\r
1118                         'adminurl' => htmlspecialchars($CONF['AdminURL']),\r
1119                         'catid' => $blog->getDefaultCategory()\r
1120                 );\r
1121                 $blog->InsertJavaScriptInfo(); \r
1122                 $this->doForm('additemform');\r
1123         }\r
1124 \r
1125         /**\r
1126           * Executes a plugin skinvar\r
1127           *\r
1128           * @param pluginName name of plugin (without the NP_)\r
1129           * \r
1130           * extra parameters can be added\r
1131           */\r
1132         function parse_plugin($pluginName) {\r
1133                 global $manager;\r
1134                 \r
1135                 // only continue when the plugin is really installed\r
1136                 if (!$manager->pluginInstalled('NP_' . $pluginName))\r
1137                         return;\r
1138                 \r
1139                 $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
1140                 if (!$plugin) return;\r
1141 \r
1142                 // get arguments\r
1143                 $params = func_get_args();\r
1144                 \r
1145                 // remove plugin name \r
1146                 array_shift($params);\r
1147                 \r
1148                 // add skin type on front\r
1149                 array_unshift($params, $this->skintype);\r
1150                 \r
1151                 call_user_func_array(array(&$plugin,'doSkinVar'), $params);\r
1152         }\r
1153 \r
1154                         \r
1155         function parse_commentform($destinationurl = '') {\r
1156                 global $blog, $itemid, $member, $CONF, $manager;\r
1157                 \r
1158                 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)\r
1159                 if (stristr($destinationurl, 'action.php')) {\r
1160                         $args = func_get_args();\r
1161                         $destinationurl = $args[1];\r
1162                         ACTIONLOG::add(WARNING,'actionurl is not longer a parameter on commentform skinvars. Moved to be a global setting instead.');\r
1163                 }\r
1164                 \r
1165                 $actionurl = $CONF['ActionURL'];\r
1166                 \r
1167                 // if item is closed, show message and do nothing\r
1168                 $item =& $manager->getItem($itemid,0,0);\r
1169                 if ($item['closed'] || !$blog->commentsEnabled()) {\r
1170                         $this->doForm('commentform-closed');\r
1171                         return;\r
1172                 }\r
1173                 \r
1174                 if (!$destinationurl)\r
1175                         $destinationurl = createItemLink($itemid, $this->linkparams);\r
1176 \r
1177                 $this->formdata = array(\r
1178                         'destinationurl' => htmlspecialchars($destinationurl),\r
1179                         'actionurl' => htmlspecialchars($actionurl),\r
1180                         'itemid' => $itemid,\r
1181                         'user' => htmlspecialchars(cookieVar('comment_user')),\r
1182                         'userid' => htmlspecialchars(cookieVar('comment_userid')),                      \r
1183                         'membername' => $member->getDisplayName(),\r
1184                         'rememberchecked' => cookieVar('comment_user')?'checked="checked"':''\r
1185                 );\r
1186                 \r
1187                 if (!$member->isLoggedIn()) {\r
1188                         $this->doForm('commentform-notloggedin');\r
1189                 } else {\r
1190                         $this->doForm('commentform-loggedin');          \r
1191                 }\r
1192         }\r
1193 \r
1194         function parse_loginform() {\r
1195                 global $member, $CONF;\r
1196                 if (!$member->isLoggedIn()) {\r
1197                         $filename = 'loginform-notloggedin';\r
1198                         $this->formdata = array();\r
1199                 } else {\r
1200                         $filename = 'loginform-loggedin';\r
1201                         $this->formdata = array(\r
1202                                 'membername' => $member->getDisplayName(),\r
1203                         );\r
1204                 }\r
1205                 $this->doForm($filename);\r
1206         }       \r
1207         \r
1208         \r
1209         function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {\r
1210                 global $member, $CONF, $memberid;\r
1211                 \r
1212                 if ($desturl == '') {\r
1213                         if ($CONF['URLMode'] == 'pathinfo')\r
1214                                 $desturl = createMemberLink($memberid);\r
1215                         else\r
1216                                 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);                             \r
1217                 }\r
1218                         \r
1219                 $this->formdata = array(\r
1220                         'url' => $desturl,\r
1221                         'actionurl' => $CONF['ActionURL'],\r
1222                         'memberid' => $memberid,\r
1223                         'rows' => $rows,\r
1224                         'cols' => $cols\r
1225                 );\r
1226                 if ($member->isLoggedIn()) {\r
1227                         $this->doForm('membermailform-loggedin');\r
1228                 } else if ($CONF['NonmemberMail']) {\r
1229                         $this->doForm('membermailform-notloggedin');            \r
1230                 } else {\r
1231                         $this->doForm('membermailform-disallowed');             \r
1232                 }\r
1233 \r
1234         }\r
1235 \r
1236         function parse_searchform($blogname = '') {\r
1237                 global $CONF, $manager, $maxresults;\r
1238                 if ($blogname) {\r
1239                         $blog =& $manager->getBlog(getBlogIDFromName($blogname));\r
1240                 } else {\r
1241                         global $blog;\r
1242                 }\r
1243                 // use default blog when no blog is selected\r
1244                 $this->formdata = array(\r
1245                         'id' => $blog?$blog->getID():$CONF['DefaultBlog'],\r
1246                         'query' => htmlspecialchars(getVar('query')),\r
1247                 );\r
1248                 $this->doForm('searchform');\r
1249         }\r
1250 \r
1251         function parse_nucleusbutton($imgurl = '',\r
1252                                                              $imgwidth = '85',\r
1253                                                              $imgheight = '31') {\r
1254                 global $CONF;\r
1255                 if ($imgurl == '') {\r
1256                         $imgurl = $CONF['AdminURL'] . 'nucleus.gif';\r
1257                 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){\r
1258                         // when skindit IncludeMode is used: start from skindir\r
1259                         $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;\r
1260                 }\r
1261 \r
1262                 $this->formdata = array(\r
1263                         'imgurl' => $imgurl,\r
1264                         'imgwidth' => $imgwidth,\r
1265                         'imgheight' => $imgheight,\r
1266                 );\r
1267                 $this->doForm('nucleusbutton');\r
1268         }\r
1269         \r
1270         function parse_self() {\r
1271                 global $CONF;\r
1272                 echo $CONF['Self'];\r
1273         }\r
1274         \r
1275         function parse_referer() {\r
1276                 echo htmlspecialchars(serverVar('HTTP_REFERER'));\r
1277         }\r
1278         \r
1279         /**\r
1280           * Helper function that sets the category that a blog will need to use \r
1281           *\r
1282           * @param $blog\r
1283           *             An object of the blog class, passed by reference (we want to make changes to it)\r
1284           * @param $catname\r
1285           *             The name of the category to use\r
1286           */\r
1287         function _setBlogCategory(&$blog, $catname) {\r
1288                 global $catid;\r
1289                 if ($catname != '')\r
1290                         $blog->setSelectedCategoryByName($catname);\r
1291                 else\r
1292                         $blog->setSelectedCategory($catid);\r
1293         }\r
1294         \r
1295         function _preBlogContent($type, &$blog) {\r
1296                 global $manager;\r
1297                 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));\r
1298         }\r
1299 \r
1300         function _postBlogContent($type, &$blog) {\r
1301                 global $manager;\r
1302                 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));\r
1303         }\r
1304 \r
1305 }\r
1306 \r
1307 ?>\r