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 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
452 $tb_option = $plugin->getBlogOption($bid,'AllowTrackBack');
\r
454 $condition = ($value == 'yes');
\r
456 $condition = ($tb_option == $value);
\r
462 $condition = ($blog && ($blog->getSetting($name) == $value));
\r
465 $condition = $member->isLoggedIn();
\r
468 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
\r
471 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
\r
474 $condition = ($itemidnext != '');
\r
477 $condition = ($itemidprev != '');
\r
480 $condition = ($name == $this->skintype);
\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
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
495 $plugin =& $manager->getPlugin('NP_' . $name);
\r
496 if ($plugin != NULL){
\r
497 if ($value == "") {
\r
500 list($name2, $value2) = explode('=', $value, 2);
\r
501 if ($value2 == "" && $plugin->getOption($name2) != 'no') {
\r
503 } else if ($plugin->getOption($name2) == $value2) {
\r
513 $this->_addIfCondition($condition);
\r
516 function _ifOnTeam($blogName = '') {
\r
517 global $blog, $member, $manager;
\r
519 // when no blog found
\r
520 if (($blogName == '') && (!is_object($blog)))
\r
523 // explicit blog selection
\r
524 if ($blogName != '')
\r
525 $blogid = getBlogIDFromName($blogName);
\r
527 if (($blogName == '') || !$manager->existsBlogID($blogid))
\r
528 // use current blog
\r
529 $blogid = $blog->getID();
\r
531 return $member->teamRights($blogid);
\r
534 function _ifAdmin($blogName = '') {
\r
535 global $blog, $member, $manager;
\r
537 // when no blog found
\r
538 if (($blogName == '') && (!is_object($blog)))
\r
541 // explicit blog selection
\r
542 if ($blogName != '')
\r
543 $blogid = getBlogIDFromName($blogName);
\r
545 if (($blogName == '') || !$manager->existsBlogID($blogid))
\r
546 // use current blog
\r
547 $blogid = $blog->getID();
\r
549 return $member->isBlogAdmin($blogid);
\r
552 function parse_ifcat($text = '') {
\r
555 $this->parse_if('category');
\r
558 global $catid, $blog;
\r
559 if ($blog->isValidCategory($catid))
\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
568 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);
\r
570 echo $this->_link($CONF['SiteUrl'], $linktext);
\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
577 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);
\r
579 echo $this->_link(createArchiveListLink(), $linktext);
\r
582 // include itemid of prev item
\r
583 function parse_previtem() {
\r
584 global $itemidprev;
\r
588 // include itemtitle of prev item
\r
589 function parse_previtemtitle() {
\r
590 global $itemtitleprev;
\r
591 echo htmlspecialchars($itemtitleprev);
\r
594 // include itemid of next item
\r
595 function parse_nextitem() {
\r
596 global $itemidnext;
\r
600 // include itemtitle of next item
\r
601 function parse_nextitemtitle() {
\r
602 global $itemtitlenext;
\r
603 echo htmlspecialchars($itemtitlenext);
\r
606 function parse_prevarchive() {
\r
607 global $archiveprev;
\r
611 function parse_nextarchive() {
\r
612 global $archivenext;
\r
616 function parse_archivetype() {
\r
617 global $archivetype;
\r
621 function parse_prevlink($linktext = '', $amount = 10) {
\r
622 global $itemidprev, $archiveprev, $startpos;
\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
629 $this->_archivelink($archiveprev, $linktext);
\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
639 $this->_archivelink($archivenext, $linktext);
\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
647 function _link($url, $linktext = '')
\r
649 $u = htmlspecialchars($url);
\r
650 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands
\r
651 if ($linktext != '')
\r
652 $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>';
\r
659 * Outputs a next/prev link
\r
661 * @param $maxresults
\r
662 * The maximum amount of items shown per page (e.g. 10)
\r
664 * Current start position (requestVar('startpos'))
\r
665 * @param $direction
\r
666 * either 'prev' or 'next'
\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
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
679 switch ($direction) {
\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
687 $iAmountOnPage = $this->amountfound;
\r
688 if ($iAmountOnPage == 0)
\r
690 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
\r
691 // try a count query
\r
692 switch ($this->skintype)
\r
695 $sqlquery = $blog->getSqlBlog('', 'count');
\r
698 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
\r
702 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
\r
704 if (intval($iAmountOnPage) >= intval($maxresults)) {
\r
705 $startpos = intval($startpos) + intval($maxresults);
\r
706 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
\r
711 } // switch($direction)
\r
714 echo $this->_link($url, $linktext);
\r
717 function _itemlink($id, $linktext = '') {
\r
720 echo $this->_link(createItemLink($id, $this->linkparams), $linktext);
\r
722 $this->parse_todaylink($linktext);
\r
725 function _archivelink($id, $linktext = '') {
\r
726 global $CONF, $blog;
\r
728 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);
\r
730 $this->parse_todaylink($linktext);
\r
734 function parse_itemlink($linktext = '') {
\r
735 $this->_itemlink($itemid, $linktext);
\r
739 * %archivedate(locale,date format)%
\r
741 function parse_archivedate($locale = '-def-') {
\r
744 if ($locale == '-def-')
\r
745 setlocale(LC_TIME,$template['LOCALE']);
\r
747 setlocale(LC_TIME,$locale);
\r
749 // get archive date
\r
750 sscanf($archive,'%d-%d-%d',$y,$m,$d);
\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
759 $format=implode(',',$args);
\r
760 } elseif ($d == 0) {
\r
761 $format = '%B %Y';
\r
763 $format = '%d %B %Y';
\r
766 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));
\r
769 function parse_blog($template, $amount = 10, $category = '') {
\r
770 global $blog, $startpos;
\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
779 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
\r
782 list($limit, $offset) = sscanf($amount, '%d(%d)');
\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
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
798 echo _ERROR_NOSUCHITEM;
\r
799 $this->_postBlogContent('item',$blog);
\r
802 function parse_itemid() {
\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
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
821 $comments = new COMMENTS($itemid);
\r
822 $comments->setItemActions($actions);
\r
823 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
\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
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
847 function parse_archivelist($template, $category = 'all', $limit = 0) {
\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
856 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
\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
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
872 function parse_categorylist($template, $blogname = '') {
\r
873 global $blog, $manager;
\r
875 if ($blogname == '') {
\r
876 $this->_preBlogContent('categorylist',$blog);
\r
877 $blog->showCategoryList($template);
\r
878 $this->_postBlogContent('categorylist',$blog);
\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
887 function parse_category($type = 'name') {
\r
888 global $catid, $blog;
\r
889 if (!$blog->isValidCategory($catid))
\r
894 echo $blog->getCategoryName($catid);
\r
897 echo $blog->getCategoryDesc($catid);
\r
905 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
\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
915 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
\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
925 function parse_searchresults($template, $maxresults = 50 ) {
\r
926 global $blog, $query, $amount, $startpos;
\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
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
943 // includes the search query
\r
944 function parse_query() {
\r
946 echo htmlspecialchars($query);
\r
949 // include nucleus versionnumber
\r
950 function parse_version() {
\r
952 echo 'Nucleus ' . $nucleus['version'];
\r
956 function parse_errormessage() {
\r
957 global $errormessage;
\r
958 echo $errormessage;
\r
962 function parse_imagetext() {
\r
963 echo htmlspecialchars(requestVar('imagetext'));
\r
966 function parse_image($what = 'imgtag') {
\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
992 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" />";
\r
997 // When commentform is not used, to include a hidden field with itemid
\r
998 function parse_vars() {
\r
1000 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
\r
1003 // include a sitevar
\r
1004 function parse_sitevar($which) {
\r
1008 echo $CONF['IndexURL'];
\r
1011 echo $CONF['SiteName'];
\r
1014 echo $CONF['AdminEmail'];
\r
1017 echo $CONF['AdminURL'];
\r
1021 // shortcut for admin url
\r
1022 function parse_adminurl() { $this->parse_sitevar('adminurl'); }
\r
1024 function parse_blogsetting($which) {
\r
1028 echo $blog->getID();
\r
1031 echo $blog->getURL();
\r
1034 echo $blog->getName();
\r
1037 echo $blog->getDescription();
\r
1040 echo $blog->getShortName();
\r
1045 // includes a member info thingie
\r
1046 function parse_member($what) {
\r
1047 global $memberinfo, $member;
\r
1049 // 1. only allow the member-details-page specific variables on member pages
\r
1050 if ($this->skintype == 'member') {
\r
1054 echo $memberinfo->getDisplayName();
\r
1057 echo $memberinfo->getRealName();
\r
1060 echo $memberinfo->getNotes();
\r
1063 echo $memberinfo->getURL();
\r
1066 echo $memberinfo->getEmail();
\r
1069 echo $memberinfo->getID();
\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
1079 echo $member->getDisplayName();
\r
1081 case 'yourrealname':
\r
1082 echo $member->getRealName();
\r
1085 echo $member->getNotes();
\r
1088 echo $member->getURL();
\r
1091 echo $member->getEmail();
\r
1094 echo $member->getID();
\r
1101 function parse_preview($template) {
\r
1102 global $blog, $CONF;
\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
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
1121 $blog->InsertJavaScriptInfo();
\r
1122 $this->doForm('additemform');
\r
1126 * Executes a plugin skinvar
\r
1128 * @param pluginName name of plugin (without the NP_)
\r
1130 * extra parameters can be added
\r
1132 function parse_plugin($pluginName) {
\r
1135 // only continue when the plugin is really installed
\r
1136 if (!$manager->pluginInstalled('NP_' . $pluginName))
\r
1139 $plugin =& $manager->getPlugin('NP_' . $pluginName);
\r
1140 if (!$plugin) return;
\r
1143 $params = func_get_args();
\r
1145 // remove plugin name
\r
1146 array_shift($params);
\r
1148 // add skin type on front
\r
1149 array_unshift($params, $this->skintype);
\r
1151 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
\r
1155 function parse_commentform($destinationurl = '') {
\r
1156 global $blog, $itemid, $member, $CONF, $manager;
\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
1165 $actionurl = $CONF['ActionURL'];
\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
1174 if (!$destinationurl)
\r
1175 $destinationurl = createItemLink($itemid, $this->linkparams);
\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
1187 if (!$member->isLoggedIn()) {
\r
1188 $this->doForm('commentform-notloggedin');
\r
1190 $this->doForm('commentform-loggedin');
\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
1200 $filename = 'loginform-loggedin';
\r
1201 $this->formdata = array(
\r
1202 'membername' => $member->getDisplayName(),
\r
1205 $this->doForm($filename);
\r
1209 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {
\r
1210 global $member, $CONF, $memberid;
\r
1212 if ($desturl == '') {
\r
1213 if ($CONF['URLMode'] == 'pathinfo')
\r
1214 $desturl = createMemberLink($memberid);
\r
1216 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);
\r
1219 $this->formdata = array(
\r
1220 'url' => $desturl,
\r
1221 'actionurl' => $CONF['ActionURL'],
\r
1222 'memberid' => $memberid,
\r
1226 if ($member->isLoggedIn()) {
\r
1227 $this->doForm('membermailform-loggedin');
\r
1228 } else if ($CONF['NonmemberMail']) {
\r
1229 $this->doForm('membermailform-notloggedin');
\r
1231 $this->doForm('membermailform-disallowed');
\r
1236 function parse_searchform($blogname = '') {
\r
1237 global $CONF, $manager, $maxresults;
\r
1239 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
\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
1248 $this->doForm('searchform');
\r
1251 function parse_nucleusbutton($imgurl = '',
\r
1253 $imgheight = '31') {
\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
1262 $this->formdata = array(
\r
1263 'imgurl' => $imgurl,
\r
1264 'imgwidth' => $imgwidth,
\r
1265 'imgheight' => $imgheight,
\r
1267 $this->doForm('nucleusbutton');
\r
1270 function parse_self() {
\r
1272 echo $CONF['Self'];
\r
1275 function parse_referer() {
\r
1276 echo htmlspecialchars(serverVar('HTTP_REFERER'));
\r
1280 * Helper function that sets the category that a blog will need to use
\r
1283 * An object of the blog class, passed by reference (we want to make changes to it)
\r
1285 * The name of the category to use
\r
1287 function _setBlogCategory(&$blog, $catname) {
\r
1289 if ($catname != '')
\r
1290 $blog->setSelectedCategoryByName($catname);
\r
1292 $blog->setSelectedCategory($catid);
\r
1295 function _preBlogContent($type, &$blog) {
\r
1297 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
\r
1300 function _postBlogContent($type, &$blog) {
\r
1302 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));
\r