5 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
6 * Copyright (C) 2002-2004 The Nucleus Group
\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
14 * Class representing a skin
\r
18 // after creating a SKIN object, evaluates to true when the skin exists
\r
21 // skin characteristics. Use the getXXX methods rather than accessing directly
\r
25 var $includeMode; // either 'normal' or 'skindir'
\r
29 function SKIN($id) {
\r
30 $this->id = intval($id);
\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
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
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
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
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
65 function createFromName($name) {
\r
66 return new SKIN(SKIN::getIdFromName($name));
\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
80 function getNameFromId($id) {
\r
81 return quickQuery('SELECT sdname as result FROM '.sql_table('skin_desc').' WHERE sdnumber=' . intval($id));
\r
85 * Creates a new skin, with the given characteristics.
\r
89 function createNew($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') {
\r
96 'description' => &$desc,
\r
98 'includeMode' => &$includeMode,
\r
99 'includePrefix' => &$includePrefix
\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
109 'skinid' => $newid,
\r
111 'description' => $desc,
\r
113 'includeMode' => $includeMode,
\r
114 'includePrefix' => $includePrefix
\r
121 function parse($type) {
\r
122 global $manager, $CONF;
\r
125 sendContentType($this->getContentType(), 'skin', _CHARSET);
\r
127 // set skin name as global var (so plugins can access it)
\r
128 global $currentSkinName;
\r
129 $currentSkinName = $this->getName();
\r
131 $contents = $this->getContent($type);
\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
143 $actions = $this->getAllowedActionsForType($type);
\r
145 $manager->notify('PreSkinParse',array('skin' => &$this, 'type' => $type));
\r
147 // set IncludeMode properties of parser
\r
148 PARSER::setProperty('IncludeMode',$this->getIncludeMode());
\r
149 PARSER::setProperty('IncludePrefix',$this->getIncludePrefix());
\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
157 $manager->notify('PostSkinParse',array('skin' => &$this, 'type' => $type));
\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
166 if (mysql_num_rows($res) == 0)
\r
169 return mysql_result($res, 0, 0);
\r
173 * Updates the contents of one part of the skin
\r
175 function update($type, $content) {
\r
176 $skinid = $this->id;
\r
177 $content = trim($content);
\r
179 // delete old thingie
\r
180 sql_query('DELETE FROM '.sql_table('skin')." WHERE stype='".addslashes($type)."' and sdesc=" . intval($skinid));
\r
182 // write new thingie
\r
184 sql_query('INSERT INTO '.sql_table('skin')." SET scontent='" . addslashes($content) . "', stype='" . addslashes($type) . "', sdesc=" . intval($skinid));
\r
189 * Deletes all skin parts from the database
\r
191 function deleteAllParts() {
\r
192 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc='.$this->getID());
\r
196 * Updates the general information about the skin
\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
210 * static: returns an array of friendly names
\r
212 function getFriendlyNames() {
\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
225 function getAllowedActionsForType($type) {
\r
226 // some actions that can be performed at any time, from anywhere
\r
227 $defaultActions = array('otherblog',
\r
236 'otherarchivelist',
\r
237 'otherarchivedaylist',
\r
243 'ifcat', // deprecated (Nucleus v2.0)
\r
255 // extra actions specific for a certain skin type
\r
256 $extraActions = array();
\r
260 $extraActions = array('blog',
\r
272 $extraActions = array('blog',
\r
287 case 'archivelist':
\r
288 $extraActions = array('blog',
\r
296 $extraActions = array('blog',
\r
301 'othersearchresults',
\r
309 $extraActions = array('image',
\r
310 'imagetext', // deprecated (Nucleus v2.0)
\r
314 $extraActions = array(
\r
321 $extraActions = array('blog',
\r
342 $extraActions = array(
\r
347 return array_merge($defaultActions, $extraActions);
\r
354 * This class contains the functions that get called by using
\r
355 * the special tags in the skins
\r
357 * The allowed tags for a type of skinpart are defined by the
\r
358 * SKIN::getAllowedActionsForType($type) method
\r
360 class ACTIONS extends BaseActions {
\r
362 // part of the skin currently being parsed ('index', 'item', 'archive',
\r
363 // 'archivelist', 'member', 'search', 'error', 'imagepopup')
\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
370 // reference to the skin object for which a part is being parsed
\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
379 // filled out with the number of displayed items after calling one of the
\r
381 // (other)blog/(other)searchresults skinvars.
\r
385 function ACTIONS($type) {
\r
386 // call constructor of superclass first
\r
387 $this->BaseActions();
\r
389 $this->skintype = $type;
\r
393 $this->linkparams = array('catid' => $catid);
\r
396 function setSkin(&$skin) {
\r
397 $this->skin =& $skin;
\r
400 function setParser(&$parser) {
\r
401 $this->parser =& $parser;
\r
405 Forms get parsedincluded now, using an extra <formdata> skinvar
\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
420 function parse_formdata($what) {
\r
421 echo $this->formdata[$what];
\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
430 function parse_skinname() {
\r
431 echo $this->skin->getName();
\r
434 function parse_if($field, $name='', $value = '') {
\r
435 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager;
\r
440 $condition = ($blog && $blog->isValidCategory($catid));
\r
442 case 'blogsetting':
\r
443 $condition = ($blog && $blog->isValidCategory($catid));
\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
455 $tb_option = $plugin->getBlogOption($bid,'AllowTrackBack');
\r
457 $condition = ($value == 'yes');
\r
459 $condition = ($tb_option == $value);
\r
465 $condition = ($blog && ($blog->getSetting($name) == $value));
\r
468 $condition = $member->isLoggedIn();
\r
471 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
\r
474 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
\r
477 $condition = ($itemidnext != '');
\r
480 $condition = ($itemidprev != '');
\r
483 $condition = ($name == $this->skintype);
\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
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
498 $plugin =& $manager->getPlugin('NP_' . $name);
\r
499 if ($plugin != NULL){
\r
500 if ($value == "") {
\r
503 list($name2, $value2) = explode('=', $value, 2);
\r
504 if ($value2 == "" && $plugin->getOption($name2) != 'no') {
\r
506 } else if ($plugin->getOption($name2) == $value2) {
\r
516 $this->_addIfCondition($condition);
\r
519 function _ifOnTeam($blogName = '') {
\r
520 global $blog, $member, $manager;
\r
522 // when no blog found
\r
523 if (($blogName == '') && (!is_object($blog)))
\r
526 // explicit blog selection
\r
527 if ($blogName != '')
\r
528 $blogid = getBlogIDFromName($blogName);
\r
530 if (($blogName == '') || !$manager->existsBlogID($blogid))
\r
531 // use current blog
\r
532 $blogid = $blog->getID();
\r
534 return $member->teamRights($blogid);
\r
537 function _ifAdmin($blogName = '') {
\r
538 global $blog, $member, $manager;
\r
540 // when no blog found
\r
541 if (($blogName == '') && (!is_object($blog)))
\r
544 // explicit blog selection
\r
545 if ($blogName != '')
\r
546 $blogid = getBlogIDFromName($blogName);
\r
548 if (($blogName == '') || !$manager->existsBlogID($blogid))
\r
549 // use current blog
\r
550 $blogid = $blog->getID();
\r
552 return $member->isBlogAdmin($blogid);
\r
555 function parse_ifcat($text = '') {
\r
558 $this->parse_if('category');
\r
561 global $catid, $blog;
\r
562 if ($blog->isValidCategory($catid))
\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
571 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);
\r
573 echo $this->_link($CONF['SiteUrl'], $linktext);
\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
580 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);
\r
582 echo $this->_link(createArchiveListLink(), $linktext);
\r
585 // include itemid of prev item
\r
586 function parse_previtem() {
\r
587 global $itemidprev;
\r
591 // include itemtitle of prev item
\r
592 function parse_previtemtitle() {
\r
593 global $itemtitleprev;
\r
594 echo htmlspecialchars($itemtitleprev);
\r
597 // include itemid of next item
\r
598 function parse_nextitem() {
\r
599 global $itemidnext;
\r
603 // include itemtitle of next item
\r
604 function parse_nextitemtitle() {
\r
605 global $itemtitlenext;
\r
606 echo htmlspecialchars($itemtitlenext);
\r
609 function parse_prevarchive() {
\r
610 global $archiveprev;
\r
614 function parse_nextarchive() {
\r
615 global $archivenext;
\r
619 function parse_archivetype() {
\r
620 global $archivetype;
\r
624 function parse_prevlink($linktext = '', $amount = 10) {
\r
625 global $itemidprev, $archiveprev, $startpos;
\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
632 $this->_archivelink($archiveprev, $linktext);
\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
642 $this->_archivelink($archivenext, $linktext);
\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
650 function _link($url, $linktext = '')
\r
652 $u = htmlspecialchars($url);
\r
653 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands
\r
654 if ($linktext != '')
\r
655 $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>';
\r
662 * Outputs a next/prev link
\r
664 * @param $maxresults
\r
665 * The maximum amount of items shown per page (e.g. 10)
\r
667 * Current start position (requestVar('startpos'))
\r
668 * @param $direction
\r
669 * either 'prev' or 'next'
\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
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
682 switch ($direction) {
\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
690 $iAmountOnPage = $this->amountfound;
\r
691 if ($iAmountOnPage == 0)
\r
693 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
\r
694 // try a count query
\r
695 switch ($this->skintype)
\r
698 $sqlquery = $blog->getSqlBlog('', 'count');
\r
701 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
\r
705 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
\r
707 if (intval($iAmountOnPage) >= intval($maxresults)) {
\r
708 $startpos = intval($startpos) + intval($maxresults);
\r
709 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
\r
714 } // switch($direction)
\r
717 echo $this->_link($url, $linktext);
\r
720 function _itemlink($id, $linktext = '') {
\r
723 echo $this->_link(createItemLink($id, $this->linkparams), $linktext);
\r
725 $this->parse_todaylink($linktext);
\r
728 function _archivelink($id, $linktext = '') {
\r
729 global $CONF, $blog;
\r
731 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);
\r
733 $this->parse_todaylink($linktext);
\r
737 function parse_itemlink($linktext = '') {
\r
738 $this->_itemlink($itemid, $linktext);
\r
742 * %archivedate(locale,date format)%
\r
744 function parse_archivedate($locale = '-def-') {
\r
747 if ($locale == '-def-')
\r
748 setlocale(LC_TIME,$template['LOCALE']);
\r
750 setlocale(LC_TIME,$locale);
\r
752 // get archive date
\r
753 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\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
762 $format=implode(',',$args);
\r
763 } elseif ($d == 0) {
\r
764 $format = '%B %Y';
\r
766 $format = '%d %B %Y';
\r
769 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));
\r
772 function parse_blog($template, $amount = 10, $category = '') {
\r
773 global $blog, $startpos;
\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
782 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
\r
785 list($limit, $offset) = sscanf($amount, '%d(%d)');
\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
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
801 echo _ERROR_NOSUCHITEM;
\r
802 $this->_postBlogContent('item',$blog);
\r
805 function parse_itemid() {
\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
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
824 $comments = new COMMENTS($itemid);
\r
825 $comments->setItemActions($actions);
\r
826 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
\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
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
850 function parse_archivelist($template, $category = 'all', $limit = 0) {
\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
859 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
\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
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
875 function parse_categorylist($template, $blogname = '') {
\r
876 global $blog, $manager;
\r
878 if ($blogname == '') {
\r
879 $this->_preBlogContent('categorylist',$blog);
\r
880 $blog->showCategoryList($template);
\r
881 $this->_postBlogContent('categorylist',$blog);
\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
890 function parse_category($type = 'name') {
\r
891 global $catid, $blog;
\r
892 if (!$blog->isValidCategory($catid))
\r
897 echo $blog->getCategoryName($catid);
\r
900 echo $blog->getCategoryDesc($catid);
\r
908 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
\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
918 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
\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
928 function parse_searchresults($template, $maxresults = 50 ) {
\r
929 global $blog, $query, $amount, $startpos;
\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
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
946 // includes the search query
\r
947 function parse_query() {
\r
949 echo htmlspecialchars($query);
\r
952 // include nucleus versionnumber
\r
953 function parse_version() {
\r
955 echo 'Nucleus ' . $nucleus['version'];
\r
959 function parse_errormessage() {
\r
960 global $errormessage;
\r
961 echo $errormessage;
\r
965 function parse_imagetext() {
\r
966 echo htmlspecialchars(requestVar('imagetext'));
\r
969 function parse_image($what = 'imgtag') {
\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
995 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" />";
\r
1000 // When commentform is not used, to include a hidden field with itemid
\r
1001 function parse_vars() {
\r
1003 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
\r
1006 // include a sitevar
\r
1007 function parse_sitevar($which) {
\r
1011 echo $CONF['IndexURL'];
\r
1014 echo $CONF['SiteName'];
\r
1017 echo $CONF['AdminEmail'];
\r
1020 echo $CONF['AdminURL'];
\r
1024 // shortcut for admin url
\r
1025 function parse_adminurl() { $this->parse_sitevar('adminurl'); }
\r
1027 function parse_blogsetting($which) {
\r
1031 echo $blog->getID();
\r
1034 echo $blog->getURL();
\r
1037 echo $blog->getName();
\r
1040 echo $blog->getDescription();
\r
1043 echo $blog->getShortName();
\r
1048 // includes a member info thingie
\r
1049 function parse_member($what) {
\r
1050 global $memberinfo, $member;
\r
1052 // 1. only allow the member-details-page specific variables on member pages
\r
1053 if ($this->skintype == 'member') {
\r
1057 echo $memberinfo->getDisplayName();
\r
1060 echo $memberinfo->getRealName();
\r
1063 echo $memberinfo->getNotes();
\r
1066 echo $memberinfo->getURL();
\r
1069 echo $memberinfo->getEmail();
\r
1072 echo $memberinfo->getID();
\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
1082 echo $member->getDisplayName();
\r
1084 case 'yourrealname':
\r
1085 echo $member->getRealName();
\r
1088 echo $member->getNotes();
\r
1091 echo $member->getURL();
\r
1094 echo $member->getEmail();
\r
1097 echo $member->getID();
\r
1104 function parse_preview($template) {
\r
1105 global $blog, $CONF;
\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
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
1124 $blog->InsertJavaScriptInfo();
\r
1125 $this->doForm('additemform');
\r
1129 * Executes a plugin skinvar
\r
1131 * @param pluginName name of plugin (without the NP_)
\r
1133 * extra parameters can be added
\r
1135 function parse_plugin($pluginName) {
\r
1138 // only continue when the plugin is really installed
\r
1139 if (!$manager->pluginInstalled('NP_' . $pluginName))
\r
1142 $plugin =& $manager->getPlugin('NP_' . $pluginName);
\r
1143 if (!$plugin) return;
\r
1146 $params = func_get_args();
\r
1148 // remove plugin name
\r
1149 array_shift($params);
\r
1151 // add skin type on front
\r
1152 array_unshift($params, $this->skintype);
\r
1154 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
\r
1158 function parse_commentform($destinationurl = '') {
\r
1159 global $blog, $itemid, $member, $CONF, $manager;
\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
1168 $actionurl = $CONF['ActionURL'];
\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
1177 if (!$destinationurl)
\r
1178 $destinationurl = createItemLink($itemid, $this->linkparams);
\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
1190 if (!$member->isLoggedIn()) {
\r
1191 $this->doForm('commentform-notloggedin');
\r
1193 $this->doForm('commentform-loggedin');
\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
1203 $filename = 'loginform-loggedin';
\r
1204 $this->formdata = array(
\r
1205 'membername' => $member->getDisplayName(),
\r
1208 $this->doForm($filename);
\r
1212 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {
\r
1213 global $member, $CONF, $memberid;
\r
1215 if ($desturl == '') {
\r
1216 if ($CONF['URLMode'] == 'pathinfo')
\r
1217 $desturl = createMemberLink($memberid);
\r
1219 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);
\r
1222 $this->formdata = array(
\r
1223 'url' => $desturl,
\r
1224 'actionurl' => $CONF['ActionURL'],
\r
1225 'memberid' => $memberid,
\r
1229 if ($member->isLoggedIn()) {
\r
1230 $this->doForm('membermailform-loggedin');
\r
1231 } else if ($CONF['NonmemberMail']) {
\r
1232 $this->doForm('membermailform-notloggedin');
\r
1234 $this->doForm('membermailform-disallowed');
\r
1239 function parse_searchform($blogname = '') {
\r
1240 global $CONF, $manager, $maxresults;
\r
1242 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
\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
1251 $this->doForm('searchform');
\r
1254 function parse_nucleusbutton($imgurl = '',
\r
1256 $imgheight = '31') {
\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
1265 $this->formdata = array(
\r
1266 'imgurl' => $imgurl,
\r
1267 'imgwidth' => $imgwidth,
\r
1268 'imgheight' => $imgheight,
\r
1270 $this->doForm('nucleusbutton');
\r
1273 function parse_self() {
\r
1275 echo $CONF['Self'];
\r
1278 function parse_referer() {
\r
1279 echo htmlspecialchars(serverVar('HTTP_REFERER'));
\r
1283 * Helper function that sets the category that a blog will need to use
\r
1286 * An object of the blog class, passed by reference (we want to make changes to it)
\r
1288 * The name of the category to use
\r
1290 function _setBlogCategory(&$blog, $catname) {
\r
1292 if ($catname != '')
\r
1293 $blog->setSelectedCategoryByName($catname);
\r
1295 $blog->setSelectedCategory($catid);
\r
1298 function _preBlogContent($type, &$blog) {
\r
1300 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
\r
1303 function _postBlogContent($type, &$blog) {
\r
1305 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
\r