5 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
6 * Copyright (C) 2002-2004 The Nucleus Group
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * (see nucleus/documentation/index.html#license for more info)
14 * Class representing a skin
16 * $Id: SKIN.php,v 1.1.1.1 2005-02-28 07:14:14 kimitake Exp $
20 // after creating a SKIN object, evaluates to true when the skin exists
23 // skin characteristics. Use the getXXX methods rather than accessing directly
27 var $includeMode; // either 'normal' or 'skindir'
32 $this->id = intval($id);
34 // read skin name/description/content type
35 $res = sql_query('SELECT * FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $this->id);
36 $obj = mysql_fetch_object($res);
37 $this->isValid = (mysql_num_rows($res) > 0);
41 $this->name = $obj->sdname;
42 $this->description = $obj->sddesc;
43 $this->contentType = $obj->sdtype;
44 $this->includeMode = $obj->sdincmode;
45 $this->includePrefix = $obj->sdincpref;
49 function getID() { return $this->id; }
50 function getName() { return $this->name; }
51 function getDescription() { return $this->description; }
52 function getContentType() { return $this->contentType; }
53 function getIncludeMode() { return $this->includeMode; }
54 function getIncludePrefix() { return $this->includePrefix; }
56 // returns true if there is a skin with the given shortname (static)
57 function exists($name) {
58 return quickQuery('select count(*) as result FROM '.sql_table('skin_desc').' WHERE sdname="'.addslashes($name).'"') > 0;
61 // returns true if there is a skin with the given ID (static)
62 function existsID($id) {
63 return quickQuery('select COUNT(*) as result FROM '.sql_table('skin_desc').' WHERE sdnumber='.intval($id)) > 0;
67 function createFromName($name) {
68 return new SKIN(SKIN::getIdFromName($name));
72 function getIdFromName($name) {
73 $query = 'SELECT sdnumber'
74 . ' FROM '.sql_table('skin_desc')
75 . ' WHERE sdname="'.addslashes($name).'"';
76 $res = sql_query($query);
77 $obj = mysql_fetch_object($res);
78 return $obj->sdnumber;
82 function getNameFromId($id) {
83 return quickQuery('SELECT sdname as result FROM '.sql_table('skin_desc').' WHERE sdnumber=' . intval($id));
87 * Creates a new skin, with the given characteristics.
91 function createNew($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') {
98 'description' => &$desc,
100 'includeMode' => &$includeMode,
101 'includePrefix' => &$includePrefix
105 sql_query('INSERT INTO '.sql_table('skin_desc')." (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('" . addslashes($name) . "','" . addslashes($desc) . "','".addslashes($type)."','".addslashes($includeMode)."','".addslashes($includePrefix)."')");
106 $newid = mysql_insert_id();
113 'description' => $desc,
115 'includeMode' => $includeMode,
116 'includePrefix' => $includePrefix
123 function parse($type) {
124 global $manager, $CONF;
127 sendContentType($this->getContentType(), 'skin', _CHARSET);
129 // set skin name as global var (so plugins can access it)
130 global $currentSkinName;
131 $currentSkinName = $this->getName();
133 $contents = $this->getContent($type);
136 // use base skin if this skin does not have contents
137 $defskin =& new SKIN($CONF['BaseSkin']);
138 $contents = $defskin->getContent($type);
145 $actions = $this->getAllowedActionsForType($type);
147 $manager->notify('PreSkinParse',array('skin' => &$this, 'type' => $type));
149 // set IncludeMode properties of parser
150 PARSER::setProperty('IncludeMode',$this->getIncludeMode());
151 PARSER::setProperty('IncludePrefix',$this->getIncludePrefix());
153 $handler =& new ACTIONS($type, $this);
154 $parser =& new PARSER($actions, $handler);
155 $handler->setParser($parser);
156 $handler->setSkin($this);
157 $parser->parse($contents);
159 $manager->notify('PostSkinParse',array('skin' => &$this, 'type' => $type));
164 function getContent($type) {
165 $query = 'SELECT scontent FROM '.sql_table('skin')." WHERE sdesc=$this->id and stype='". addslashes($type) ."'";
166 $res = sql_query($query);
168 if (mysql_num_rows($res) == 0)
171 return mysql_result($res, 0, 0);
175 * Updates the contents of one part of the skin
177 function update($type, $content) {
179 $content = trim($content);
181 // delete old thingie
182 sql_query('DELETE FROM '.sql_table('skin')." WHERE stype='".addslashes($type)."' and sdesc=" . intval($skinid));
186 sql_query('INSERT INTO '.sql_table('skin')." SET scontent='" . addslashes($content) . "', stype='" . addslashes($type) . "', sdesc=" . intval($skinid));
191 * Deletes all skin parts from the database
193 function deleteAllParts() {
194 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc='.$this->getID());
198 * Updates the general information about the skin
200 function updateGeneralInfo($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') {
201 $query = 'UPDATE '.sql_table('skin_desc').' SET'
202 . " sdname='" . addslashes($name) . "',"
203 . " sddesc='" . addslashes($desc) . "',"
204 . " sdtype='" . addslashes($type) . "',"
205 . " sdincmode='" . addslashes($includeMode) . "',"
206 . " sdincpref='" . addslashes($includePrefix) . "'"
207 . " WHERE sdnumber=" . $this->getID();
212 * static: returns an array of friendly names
214 function getFriendlyNames() {
216 'index' => _SKIN_PART_MAIN,
217 'item' => _SKIN_PART_ITEM,
218 'archivelist' => _SKIN_PART_ALIST,
219 'archive' => _SKIN_PART_ARCHIVE,
220 'search' => _SKIN_PART_SEARCH,
221 'error' => _SKIN_PART_ERROR,
222 'member' => _SKIN_PART_MEMBER,
223 'imagepopup' => _SKIN_PART_POPUP
227 function getAllowedActionsForType($type) {
228 // some actions that can be performed at any time, from anywhere
229 $defaultActions = array('otherblog',
239 'otherarchivedaylist',
245 'ifcat', // deprecated (Nucleus v2.0)
257 // extra actions specific for a certain skin type
258 $extraActions = array();
262 $extraActions = array('blog',
274 $extraActions = array('blog',
290 $extraActions = array('blog',
298 $extraActions = array('blog',
303 'othersearchresults',
311 $extraActions = array('image',
312 'imagetext', // deprecated (Nucleus v2.0)
316 $extraActions = array(
323 $extraActions = array('blog',
344 $extraActions = array(
349 return array_merge($defaultActions, $extraActions);
356 * This class contains the functions that get called by using
357 * the special tags in the skins
359 * The allowed tags for a type of skinpart are defined by the
360 * SKIN::getAllowedActionsForType($type) method
362 class ACTIONS extends BaseActions {
364 // part of the skin currently being parsed ('index', 'item', 'archive',
365 // 'archivelist', 'member', 'search', 'error', 'imagepopup')
368 // contains an assoc array with parameters that need to be included when
369 // generating links to items/archives/... (e.g. catid)
372 // reference to the skin object for which a part is being parsed
376 // used when including templated forms from the include/ dir. The $formdata var
377 // contains the values to fill out in there (assoc array name -> value)
381 // filled out with the number of displayed items after calling one of the
383 // (other)blog/(other)searchresults skinvars.
387 function ACTIONS($type) {
388 // call constructor of superclass first
389 $this->BaseActions();
391 $this->skintype = $type;
395 $this->linkparams = array('catid' => $catid);
398 function setSkin(&$skin) {
399 $this->skin =& $skin;
402 function setParser(&$parser) {
403 $this->parser =& $parser;
407 Forms get parsedincluded now, using an extra <formdata> skinvar
409 function doForm($filename) {
411 array_push($this->parser->actions,'formdata','text','callback','errordiv');
412 $oldIncludeMode = PARSER::getProperty('IncludeMode');
413 $oldIncludePrefix = PARSER::getProperty('IncludePrefix');
414 PARSER::setProperty('IncludeMode','normal');
415 PARSER::setProperty('IncludePrefix','');
416 $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template');
417 PARSER::setProperty('IncludeMode',$oldIncludeMode);
418 PARSER::setProperty('IncludePrefix',$oldIncludePrefix);
419 array_pop($this->parser->actions); // errordiv
420 array_pop($this->parser->actions); // callback
421 array_pop($this->parser->actions); // text
422 array_pop($this->parser->actions); // formdata
424 function parse_formdata($what) {
425 echo $this->formdata[$what];
427 function parse_text($which) {
428 // constant($which) only available from 4.0.4 :(
429 if (defined($which)) {
430 eval("echo $which;");
433 function parse_callback($eventName, $type)
436 $manager->notify($eventName, array('type' => $type));
438 function parse_errordiv() {
439 global $errormessage;
441 echo '<div class="error">', htmlspecialchars($errormessage),'</div>';
444 function parse_skinname() {
445 echo $this->skin->getName();
448 function parse_if($field, $name='', $value = '') {
449 global $catid, $blog, $member, $itemidnext, $itemidprev, $manager;
454 $condition = ($blog && $blog->isValidCategory($catid));
457 if ($name == 'trackback') {
458 $plugin =& $manager->getPlugin('NP_TrackBack');
459 if ($plugin != NULL){
460 $bid = $blog->getID();
461 if ($value === '1') $value = 'yes';
462 if ($value === '0') $value = 'no';
463 if ($plugin->getOption('AcceptPing') == 'no' ) {
464 $condition = ($value == 'no');
466 $tb_option = $plugin->getBlogOption($bid,'AllowTrackBack');
468 $condition = ($value == 'yes');
470 $condition = ($tb_option == $value);
476 $condition = ($blog && ($blog->getSetting($name) == $value));
479 $condition = $member->isLoggedIn();
482 $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);
485 $condition = $member->isLoggedIn() && $this->_ifAdmin($name);
488 $condition = ($itemidnext != '');
491 $condition = ($itemidprev != '');
494 $condition = ($name == $this->skintype);
498 -> checks if plugin exists
499 hasplugin,PlugName,OptionName
500 -> checks if the option OptionName from plugin PlugName is not set to 'no'
501 hasplugin,PlugName,OptionName=value
502 -> checks if the option OptionName from plugin PlugName is set to value
506 // (pluginInstalled method won't write a message in the actionlog on failure)
507 if ($manager->pluginInstalled('NP_'.$name))
509 $plugin =& $manager->getPlugin('NP_' . $name);
510 if ($plugin != NULL){
514 list($name2, $value2) = explode('=', $value, 2);
515 if ($value2 == "" && $plugin->getOption($name2) != 'no') {
517 } else if ($plugin->getOption($name2) == $value2) {
527 $this->_addIfCondition($condition);
530 function _ifOnTeam($blogName = '') {
531 global $blog, $member, $manager;
533 // when no blog found
534 if (($blogName == '') && (!is_object($blog)))
537 // explicit blog selection
539 $blogid = getBlogIDFromName($blogName);
541 if (($blogName == '') || !$manager->existsBlogID($blogid))
543 $blogid = $blog->getID();
545 return $member->teamRights($blogid);
548 function _ifAdmin($blogName = '') {
549 global $blog, $member, $manager;
551 // when no blog found
552 if (($blogName == '') && (!is_object($blog)))
555 // explicit blog selection
557 $blogid = getBlogIDFromName($blogName);
559 if (($blogName == '') || !$manager->existsBlogID($blogid))
561 $blogid = $blog->getID();
563 return $member->isBlogAdmin($blogid);
566 function parse_ifcat($text = '') {
569 $this->parse_if('category');
572 global $catid, $blog;
573 if ($blog->isValidCategory($catid))
578 // a link to the today page (depending on selected blog, etc...)
579 function parse_todaylink($linktext = '') {
582 echo $this->_link(createBlogidLink($blog->getID(),$this->linkparams), $linktext);
584 echo $this->_link($CONF['SiteUrl'], $linktext);
587 // a link to the archives for the current blog (or for default blog)
588 function parse_archivelink($linktext = '') {
591 echo $this->_link(createArchiveListLink($blog->getID(),$this->linkparams), $linktext);
593 echo $this->_link(createArchiveListLink(), $linktext);
596 // include itemid of prev item
597 function parse_previtem() {
602 // include itemtitle of prev item
603 function parse_previtemtitle() {
604 global $itemtitleprev;
605 echo htmlspecialchars($itemtitleprev);
608 // include itemid of next item
609 function parse_nextitem() {
614 // include itemtitle of next item
615 function parse_nextitemtitle() {
616 global $itemtitlenext;
617 echo htmlspecialchars($itemtitlenext);
620 function parse_prevarchive() {
625 function parse_nextarchive() {
630 function parse_archivetype() {
635 function parse_prevlink($linktext = '', $amount = 10) {
636 global $itemidprev, $archiveprev, $startpos;
638 if ($this->skintype == 'item')
639 $this->_itemlink($itemidprev, $linktext);
640 else if ($this->skintype == 'search' || $this->skintype == 'index')
641 $this->_searchlink($amount, $startpos, 'prev', $linktext);
643 $this->_archivelink($archiveprev, $linktext);
646 function parse_nextlink($linktext = '', $amount = 10) {
647 global $itemidnext, $archivenext, $startpos;
648 if ($this->skintype == 'item')
649 $this->_itemlink($itemidnext, $linktext);
650 else if ($this->skintype == 'search' || $this->skintype == 'index')
651 $this->_searchlink($amount, $startpos, 'next', $linktext);
653 $this->_archivelink($archivenext, $linktext);
658 * - a raw link (html/xml encoded) when no linktext is provided
659 * - a (x)html <a href... link when a text is present (text htmlencoded)
661 function _link($url, $linktext = '')
663 $u = htmlspecialchars($url);
664 $u = preg_replace("/&amp;/",'&',$u); // fix URLs that already had encoded ampersands
666 $l = '<a href="' . $u .'">'.htmlspecialchars($linktext).'</a>';
673 * Outputs a next/prev link
676 * The maximum amount of items shown per page (e.g. 10)
678 * Current start position (requestVar('startpos'))
680 * either 'prev' or 'next'
682 * When present, the output will be a full <a href...> link. When empty,
683 * only a raw link will be outputted
685 function _searchlink($maxresults, $startpos, $direction, $linktext = '') {
686 global $CONF, $blog, $query, $amount;
687 // TODO: Move request uri to linkparams. this is ugly. sorry for that.
688 $startpos = intval($startpos); // will be 0 when empty.
689 $parsed = parse_url(serverVar('REQUEST_URI'));
690 $parsed = $parsed['query'];
693 switch ($direction) {
695 if ( intval($startpos) - intval($maxresults) >= 0) {
696 $startpos = intval($startpos) - intval($maxresults);
697 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
701 $iAmountOnPage = $this->amountfound;
702 if ($iAmountOnPage == 0)
704 // [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%]
706 switch ($this->skintype)
709 $sqlquery = $blog->getSqlBlog('', 'count');
712 $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count');
716 $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos);
718 if (intval($iAmountOnPage) >= intval($maxresults)) {
719 $startpos = intval($startpos) + intval($maxresults);
720 $url = $CONF['SearchURL'].'?'.alterQueryStr($parsed,'startpos',$startpos);
725 } // switch($direction)
728 echo $this->_link($url, $linktext);
731 function _itemlink($id, $linktext = '') {
734 echo $this->_link(createItemLink($id, $this->linkparams), $linktext);
736 $this->parse_todaylink($linktext);
739 function _archivelink($id, $linktext = '') {
742 echo $this->_link(createArchiveLink($blog->getID(), $id, $this->linkparams), $linktext);
744 $this->parse_todaylink($linktext);
748 function parse_itemlink($linktext = '') {
749 $this->_itemlink($itemid, $linktext);
753 * %archivedate(locale,date format)%
755 function parse_archivedate($locale = '-def-') {
758 if ($locale == '-def-')
759 setlocale(LC_TIME,$template['LOCALE']);
761 setlocale(LC_TIME,$locale);
764 sscanf($archive,'%d-%d-%d',$y,$m,$d);
767 $args = func_get_args();
768 // format can be spread over multiple parameters
769 if (sizeof($args) > 1) {
773 $format=implode(',',$args);
777 $format = '%d %B %Y';
780 echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));
783 function parse_blog($template, $amount = 10, $category = '') {
784 global $blog, $startpos;
786 list($limit, $offset) = sscanf($amount, '%d(%d)');
787 $this->_setBlogCategory($blog, $category);
788 $this->_preBlogContent('blog',$blog);
789 $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos);
790 $this->_postBlogContent('blog',$blog);
793 function parse_otherblog($blogname, $template, $amount = 10, $category = '') {
796 list($limit, $offset) = sscanf($amount, '%d(%d)');
798 $b =& $manager->getBlog(getBlogIDFromName($blogname));
799 $this->_setBlogCategory($b, $category);
800 $this->_preBlogContent('otherblog',$b);
801 $this->amountfound = $b->readLog($template, $limit, $offset);
802 $this->_postBlogContent('otherblog',$b);
805 // include one item (no comments)
806 function parse_item($template) {
807 global $blog, $itemid, $highlight;
808 $this->_setBlogCategory($blog, ''); // need this to select default category
809 $this->_preBlogContent('item',$blog);
810 $r = $blog->showOneitem($itemid, $template, $highlight);
812 echo _ERROR_NOSUCHITEM;
813 $this->_postBlogContent('item',$blog);
816 function parse_itemid() {
822 // include comments for one item
823 function parse_comments($template) {
824 global $itemid, $manager, $blog, $highlight;
825 $template =& $manager->getTemplate($template);
827 // create parser object & action handler
828 $actions =& new ITEMACTIONS($blog);
829 $parser =& new PARSER($actions->getDefinedActions(),$actions);
830 $actions->setTemplate($template);
831 $actions->setParser($parser);
832 $item = ITEM::getitem($itemid, 0, 0);
833 $actions->setCurrentItem($item);
835 $comments =& new COMMENTS($itemid);
836 $comments->setItemActions($actions);
837 $comments->showComments($template, -1, 1, $highlight); // shows ALL comments
840 function parse_archive($template, $category = '') {
841 global $blog, $archive;
842 // can be used with either yyyy-mm or yyyy-mm-dd
843 sscanf($archive,'%d-%d-%d',$y,$m,$d);
844 $this->_setBlogCategory($blog, $category);
845 $this->_preBlogContent('achive',$blog);
846 $blog->showArchive($template, $y, $m, $d);
847 $this->_postBlogContent('achive',$blog);
851 function parse_otherarchive($blogname, $template, $category = '') {
852 global $archive, $manager;
853 sscanf($archive,'%d-%d-%d',$y,$m,$d);
854 $b =& $manager->getBlog(getBlogIDFromName($blogname));
855 $this->_setBlogCategory($b, $category);
856 $this->_preBlogContent('otherachive',$b);
857 $b->showArchive($template, $y, $m, $d);
858 $this->_postBlogContent('otherachive',$b);
861 function parse_archivelist($template, $category = 'all', $limit = 0) {
863 if ($category == 'all') $category = '';
864 $this->_preBlogContent('archivelist',$blog);
865 $this->_setBlogCategory($blog, $category);
866 $blog->showArchiveList($template, 'month', $limit);
867 $this->_postBlogContent('archivelist',$blog);
870 function parse_archivedaylist($template, $category = 'all', $limit = 0) {
872 if ($category == 'all') $category = '';
873 $this->_preBlogContent('archivelist',$blog);
874 $this->_setBlogCategory($blog, $category);
875 $blog->showArchiveList($template, 'day', $limit);
876 $this->_postBlogContent('archivelist',$blog);
880 function parse_itemtitle() {
881 global $manager, $itemid;
882 $item =& $manager->getItem($itemid,0,0);
883 echo htmlspecialchars(strip_tags($item['title']));
886 function parse_categorylist($template, $blogname = '') {
887 global $blog, $manager;
889 if ($blogname == '') {
890 $this->_preBlogContent('categorylist',$blog);
891 $blog->showCategoryList($template);
892 $this->_postBlogContent('categorylist',$blog);
894 $b =& $manager->getBlog(getBlogIDFromName($blogname));
895 $this->_preBlogContent('categorylist',$b);
896 $b->showCategoryList($template);
897 $this->_postBlogContent('categorylist',$b);
901 function parse_category($type = 'name') {
902 global $catid, $blog;
903 if (!$blog->isValidCategory($catid))
908 echo $blog->getCategoryName($catid);
911 echo $blog->getCategoryDesc($catid);
919 function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) {
921 if ($category == 'all') $category = '';
922 $b =& $manager->getBlog(getBlogIDFromName($blogname));
923 $this->_setBlogCategory($b, $category);
924 $this->_preBlogContent('otherarchivelist',$b);
925 $b->showArchiveList($template, 'month', $limit);
926 $this->_postBlogContent('otherarchivelist',$b);
929 function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) {
931 if ($category == 'all') $category = '';
932 $b =& $manager->getBlog(getBlogIDFromName($blogname));
933 $this->_setBlogCategory($b, $category);
934 $this->_preBlogContent('otherarchivelist',$b);
935 $b->showArchiveList($template, 'day', $limit);
936 $this->_postBlogContent('otherarchivelist',$b);
939 function parse_searchresults($template, $maxresults = 50 ) {
940 global $blog, $query, $amount, $startpos;
942 $this->_setBlogCategory($blog, ''); // need this to select default category
943 $this->_preBlogContent('searchresults',$blog);
944 $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos);
945 $this->_postBlogContent('searchresults',$blog);
948 function parse_othersearchresults($blogname, $template, $maxresults = 50) {
949 global $query, $amount, $manager, $startpos;
950 $b =& $manager->getBlog(getBlogIDFromName($blogname));
951 $this->_setBlogCategory($b, ''); // need this to select default category
952 $this->_preBlogContent('othersearchresults',$b);
953 $b->search($query, $template, $amount, $maxresults, $startpos);
954 $this->_postBlogContent('othersearchresults',$b);
957 // includes the search query
958 function parse_query() {
960 echo htmlspecialchars($query);
963 // include nucleus versionnumber
964 function parse_version() {
966 echo 'Nucleus ' . $nucleus['version'];
970 function parse_errormessage() {
971 global $errormessage;
976 function parse_imagetext() {
977 echo htmlspecialchars(requestVar('imagetext'));
980 function parse_image($what = 'imgtag') {
983 $imagetext = htmlspecialchars(requestVar('imagetext'));
984 $imagepopup = requestVar('imagepopup');
985 $width = requestVar('width');
986 $height = requestVar('height');
987 $fullurl = $CONF['MediaURL'] . $imagepopup;
1006 echo "<img src=\"$fullurl\" width=\"$width\" height=\"$height\" alt=\"$imagetext\" />";
1011 // When commentform is not used, to include a hidden field with itemid
1012 function parse_vars() {
1014 echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
1017 // include a sitevar
1018 function parse_sitevar($which) {
1022 echo $CONF['IndexURL'];
1025 echo $CONF['SiteName'];
1028 echo $CONF['AdminEmail'];
1031 echo $CONF['AdminURL'];
1035 // shortcut for admin url
1036 function parse_adminurl() { $this->parse_sitevar('adminurl'); }
1038 function parse_blogsetting($which) {
1042 echo $blog->getID();
1045 echo $blog->getURL();
1048 echo $blog->getName();
1051 echo $blog->getDescription();
1054 echo $blog->getShortName();
1059 // includes a member info thingie
1060 function parse_member($what) {
1061 global $memberinfo, $member;
1063 // 1. only allow the member-details-page specific variables on member pages
1064 if ($this->skintype == 'member') {
1068 echo $memberinfo->getDisplayName();
1071 echo $memberinfo->getRealName();
1074 echo $memberinfo->getNotes();
1077 echo $memberinfo->getURL();
1080 echo $memberinfo->getEmail();
1083 echo $memberinfo->getID();
1088 // 2. the next bunch of options is available everywhere, as long as the user is logged in
1089 if ($member->isLoggedIn())
1093 echo $member->getDisplayName();
1095 case 'yourrealname':
1096 echo $member->getRealName();
1099 echo $member->getNotes();
1102 echo $member->getURL();
1105 echo $member->getEmail();
1108 echo $member->getID();
1115 function parse_preview($template) {
1116 global $blog, $CONF, $manager;
1118 $template =& $manager->getTemplate($template);
1119 $row['body'] = '<span id="prevbody"></span>';
1120 $row['title'] = '<span id="prevtitle"></span>';
1121 $row['more'] = '<span id="prevmore"></span>';
1122 $row['itemlink'] = '';
1123 $row['itemid'] = 0; $row['blogid'] = $blog->getID();
1124 echo TEMPLATE::fill($template['ITEM_HEADER'],$row);
1125 echo TEMPLATE::fill($template['ITEM'],$row);
1126 echo TEMPLATE::fill($template['ITEM_FOOTER'],$row);
1129 function parse_additemform() {
1130 global $blog, $CONF;
1131 $this->formdata = array(
1132 'adminurl' => htmlspecialchars($CONF['AdminURL']),
1133 'catid' => $blog->getDefaultCategory()
1135 $blog->InsertJavaScriptInfo();
1136 $this->doForm('additemform');
1140 * Executes a plugin skinvar
1142 * @param pluginName name of plugin (without the NP_)
1144 * extra parameters can be added
1146 function parse_plugin($pluginName) {
1149 // only continue when the plugin is really installed
1150 if (!$manager->pluginInstalled('NP_' . $pluginName))
1153 $plugin =& $manager->getPlugin('NP_' . $pluginName);
1154 if (!$plugin) return;
1157 $params = func_get_args();
1159 // remove plugin name
1160 array_shift($params);
1162 // add skin type on front
1163 array_unshift($params, $this->skintype);
1165 call_user_func_array(array(&$plugin,'doSkinVar'), $params);
1169 function parse_commentform($destinationurl = '') {
1170 global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage;
1172 // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0)
1173 if (stristr($destinationurl, 'action.php')) {
1174 $args = func_get_args();
1175 $destinationurl = $args[1];
1176 ACTIONLOG::add(WARNING,'actionurl is not longer a parameter on commentform skinvars. Moved to be a global setting instead.');
1179 $actionurl = $CONF['ActionURL'];
1181 // if item is closed, show message and do nothing
1182 $item =& $manager->getItem($itemid,0,0);
1183 if ($item['closed'] || !$blog->commentsEnabled()) {
1184 $this->doForm('commentform-closed');
1188 if (!$destinationurl)
1189 $destinationurl = createItemLink($itemid, $this->linkparams);
1191 // values to prefill
1192 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
1193 if (!$user) $user = postVar('user');
1194 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
1195 if (!$userid) $userid = postVar('userid');
1196 $body = postVar('body');
1198 $this->formdata = array(
1199 'destinationurl' => htmlspecialchars($destinationurl),
1200 'actionurl' => htmlspecialchars($actionurl),
1201 'itemid' => $itemid,
1202 'user' => htmlspecialchars($user),
1203 'userid' => htmlspecialchars($userid),
1204 'body' => htmlspecialchars($body),
1205 'membername' => $member->getDisplayName(),
1206 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':''
1209 if (!$member->isLoggedIn()) {
1210 $this->doForm('commentform-notloggedin');
1212 $this->doForm('commentform-loggedin');
1216 function parse_loginform() {
1217 global $member, $CONF;
1218 if (!$member->isLoggedIn()) {
1219 $filename = 'loginform-notloggedin';
1220 $this->formdata = array();
1222 $filename = 'loginform-loggedin';
1223 $this->formdata = array(
1224 'membername' => $member->getDisplayName(),
1227 $this->doForm($filename);
1231 function parse_membermailform($rows = 10, $cols = 40, $desturl = '') {
1232 global $member, $CONF, $memberid;
1234 if ($desturl == '') {
1235 if ($CONF['URLMode'] == 'pathinfo')
1236 $desturl = createMemberLink($memberid);
1238 $desturl = $CONF['IndexURL'] . createMemberLink($memberid);
1241 $message = postVar('message');
1242 $frommail = postVar('frommail');
1244 $this->formdata = array(
1245 'url' => htmlspecialchars($desturl),
1246 'actionurl' => htmlspecialchars($CONF['ActionURL']),
1247 'memberid' => $memberid,
1250 'message' => htmlspecialchars($message),
1251 'frommail' => htmlspecialchars($frommail)
1253 if ($member->isLoggedIn()) {
1254 $this->doForm('membermailform-loggedin');
1255 } else if ($CONF['NonmemberMail']) {
1256 $this->doForm('membermailform-notloggedin');
1258 $this->doForm('membermailform-disallowed');
1263 function parse_searchform($blogname = '') {
1264 global $CONF, $manager, $maxresults;
1266 $blog =& $manager->getBlog(getBlogIDFromName($blogname));
1270 // use default blog when no blog is selected
1271 $this->formdata = array(
1272 'id' => $blog?$blog->getID():$CONF['DefaultBlog'],
1273 'query' => htmlspecialchars(getVar('query')),
1275 $this->doForm('searchform');
1278 function parse_nucleusbutton($imgurl = '',
1280 $imgheight = '31') {
1282 if ($imgurl == '') {
1283 $imgurl = $CONF['AdminURL'] . 'nucleus.gif';
1284 } else if (PARSER::getProperty('IncludeMode') == 'skindir'){
1285 // when skindit IncludeMode is used: start from skindir
1286 $imgurl = $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $imgurl;
1289 $this->formdata = array(
1290 'imgurl' => $imgurl,
1291 'imgwidth' => $imgwidth,
1292 'imgheight' => $imgheight,
1294 $this->doForm('nucleusbutton');
1297 function parse_self() {
1302 function parse_referer() {
1303 echo htmlspecialchars(serverVar('HTTP_REFERER'));
1307 * Helper function that sets the category that a blog will need to use
1310 * An object of the blog class, passed by reference (we want to make changes to it)
1312 * The name of the category to use
1314 function _setBlogCategory(&$blog, $catname) {
1317 $blog->setSelectedCategoryByName($catname);
1319 $blog->setSelectedCategory($catid);
1322 function _preBlogContent($type, &$blog) {
1324 $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type));
1327 function _postBlogContent($type, &$blog) {
1329 $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => $type));