From: sakamocchi Date: Sat, 14 Apr 2012 10:17:15 +0000 (+0900) Subject: MERGE: リビジョン1755のマージ。SkinクラスでActionsクラス以外のバックエンドクラスを利用可能に。 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=39c03473b664653a2ca1559486b6fee7106739c8;p=nucleus-jp%2Fnucleus-next.git MERGE: リビジョン1755のマージ。SkinクラスでActionsクラス以外のバックエンドクラスを利用可能に。 管理画面をスキン/テンプレートシステムで構成する基盤として、Actionsクラスに関係するコードをSkinクラスからActionsクラスに移動し、関連する修正を行った。これにより、SkinクラスはActionsクラス以外のバックエンドクラスを利用可能となった。 Revision 1755: CHANGE: modification to allow Skin class to utilize the others than Actions class Moving some codes related to Actions class into Actions class and add some members and methods. Actions::$default_actions Actions::getDefinedActions() Actions::$skin_type_friendly_names Actions::getSkinTypeFriendlyNames() Then adding some arguments to Skin::__construct() and Skin::getFriendlyNames() to indicate an backend class and an event identifier. Add $template['friendly_names'] in Admin::action_skinoverview() and pass it into listplug_table_skinlist() to display skin types. http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1755 --- diff --git a/nucleus/libs/ACTIONS.php b/nucleus/libs/ACTIONS.php index e75f5c0..61e8343 100644 --- a/nucleus/libs/ACTIONS.php +++ b/nucleus/libs/ACTIONS.php @@ -1,2086 +1,2294 @@ - value) - var $formdata; - - // filled out with the number of displayed items after calling one of the - // (other)blog/(other)searchresults skinvars. - var $amountfound; - - /** - * Actions::__construct() - * Constructor for a new Actions object - * - * @param string $type - * @return void - */ - public function __construct($type) - { - global $catid; - - // call constructor of superclass first - $this->BaseActions(); - $this->skintype = $type; - - if ( $catid ) - { - $this->linkparams = array('catid' => $catid); - } - return; - } - - /** - * Actions::setSkin() - * Set the skin - * @param object $skin an instance of Skin class - * @return void - */ - public function setSkin(&$skin) - { - $this->skin =& $skin; - return; - } - - /** - * Actions::setParser() - * Set the parser - * - * @param object $parser an instance of Parser class - * @return void - */ - public function setParser(&$parser) - { - $this->parser =& $parser; - return; - } - - /** - * Actions::doForm() - * Forms get parsedincluded now, using an extra skinvar - * - * @param string $filename - * @return void - */ - public function doForm($filename) - { - global $DIR_NUCLEUS; - array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket'); - - $oldIncludeMode = Parser::getProperty('IncludeMode'); - $oldIncludePrefix = Parser::getProperty('IncludePrefix'); - Parser::setProperty('IncludeMode','normal'); - Parser::setProperty('IncludePrefix',''); - - $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template'); - Parser::setProperty('IncludeMode',$oldIncludeMode); - Parser::setProperty('IncludePrefix',$oldIncludePrefix); - - array_pop($this->parser->actions); // errordiv - array_pop($this->parser->actions); // callback - array_pop($this->parser->actions); // text - array_pop($this->parser->actions); // formdata - array_pop($this->parser->actions); // ticket - return; - } - - /** - * Actions::checkCondition() - * Checks conditions for if statements - * - * @param string $field type of <%if%> - * @param string $name property of field - * @param string $value value of property - * @return boolean condition - */ - public function checkCondition($field, $name='', $value = '') - { - global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists; - - $condition = 0; - switch ( $field ) - { - case 'category': - $condition = ($blog && $this->ifCategory($name,$value)); - break; - case 'blogsetting': - $condition = ($blog && ($blog->getSetting($name) == $value)); - break; - case 'loggedin': - $condition = $member->isLoggedIn(); - break; - case 'onteam': - $condition = $member->isLoggedIn() && $this->ifOnTeam($name); - break; + value) + private $formdata; + + // filled out with the number of displayed items after calling one of the + // (other)blog/(other)searchresults skinvars. + private $amountfound; + + /** + * Actions::$default_actions + * list of whole action names with which this class can deal + */ + static private $default_actions = array( + 'addlink', + 'addpopupcode', + 'adminurl', + 'archivelink', + 'bloglist', + 'category', + 'charset', + 'else', + 'elseif', + 'elseifnot', + 'endif', + 'if', + 'ifnot', + 'include', + 'loginform', + 'member', + 'nucleusbutton', + 'otherarchivedaylist', + 'otherarchivelist', + 'otherarchiveyearlist', + 'otherblog', + 'parsedinclude', + 'phpinclude', + 'plugin', + 'referer', + 'searchform', + 'self', + 'set', + 'sitevar', + 'skinfile', + 'skinname', + 'sticky', + 'todaylink', + 'version', + // deprecated (Nucleus v2.0) + /* TODO: remove this */ + 'ifcat' + ); + + /** + * Actions::$page_type_friendly_names + * friendly name for wrapped page types + */ + static public $skin_type_friendly_names = array( + 'index' => _SKIN_PART_MAIN, + 'item' => _SKIN_PART_ITEM, + 'archivelist' => _SKIN_PART_ALIST, + 'archive' => _SKIN_PART_ARCHIVE, + 'search' => _SKIN_PART_SEARCH, + 'error' => _SKIN_PART_ERROR, + 'member' => _SKIN_PART_MEMBER, + 'imagepopup' => _SKIN_PART_POPUP + ); + + /** + * Actions::getDefinedActions() + * + * @static + * @param string $type page type + * @return array allowed actions for the page type + */ + static public function getDefinedActions($type='') + { + // extra actions specific for a certain skin type + $extra_actions = array(); + + switch ( $type ) + { + case 'index': + $extra_actions = array( + 'blog', + 'blogsetting', + 'preview', + 'additemform', + 'categorylist', + 'archivelist', + 'archivedaylist', + 'archiveyearlist', + 'nextlink', + 'prevlink' + ); + break; + case 'archive': + $extra_actions = array( + 'blog', + 'archive', + 'otherarchive', + 'categorylist', + 'archivelist', + 'archivedaylist', + 'archiveyearlist', + 'blogsetting', + 'archivedate', + 'nextarchive', + 'prevarchive', + 'nextlink', + 'prevlink', + 'archivetype' + ); + break; + case 'archivelist': + $extra_actions = array( + 'blog', + 'archivelist', + 'archivedaylist', + 'archiveyearlist', + 'categorylist', + 'blogsetting' + ); + break; + case 'search': + $extra_actions = array( + 'blog', + 'archivelist', + 'archivedaylist', + 'archiveyearlist', + 'categorylist', + 'searchresults', + 'othersearchresults', + 'blogsetting', + 'query', + 'nextlink', + 'prevlink' + ); + break; + case 'imagepopup': + $extra_actions = array( + 'image', + // deprecated (Nucleus v2.0) + /* TODO: remove this */ + 'imagetext' + ); + break; + case 'member': + $extra_actions = array( + 'membermailform', + 'blogsetting', + 'nucleusbutton', + 'categorylist' + ); + break; + case 'item': + $extra_actions = array( + 'blog', + 'item', + 'comments', + 'commentform', + 'vars', + 'blogsetting', + 'nextitem', + 'previtem', + 'nextlink', + 'prevlink', + 'nextitemtitle', + 'previtemtitle', + 'categorylist', + 'archivelist', + 'archivedaylist', + 'archiveyearlist', + 'itemtitle', + 'itemid', + 'itemlink' + ); + break; + case 'error': + $extra_actions = array( + 'errormessage', + 'categorylist' + ); + break; + default: + $extra_actions = array( + 'blog', + 'blogsetting', + 'preview', + 'additemform', + 'categorylist', + 'archivelist', + 'archivedaylist', + 'archiveyearlist', + 'nextlink', + 'prevlink', + 'membermailform', + 'nucleusbutton', + 'categorylist' + ); + break; + } + return array_merge(self::$default_actions, $extra_actions); + } + + /** + * Actions::getSkinTypeFriendlyNames() + * + * @static + * @param void + * @return array list of friendly names for page actions + */ + static public function getSkinTypeFriendlyNames() + { + return self::$skin_type_friendly_names; + } + + /** + * Actions::__construct() + * Constructor for a new Actions object + * + * @param string $type + * @return void + */ + public function __construct($type) + { + global $catid; + + // call constructor of superclass first + $this->BaseActions(); + $this->skintype = $type; + + if ( $catid ) + { + $this->linkparams = array('catid' => $catid); + } + return; + } + + /** + * Actions::setSkin() + * Set the skin + * @param object $skin an instance of Skin class + * @return void + */ + public function setSkin(&$skin) + { + $this->skin =& $skin; + return; + } + + /** + * Actions::setParser() + * Set the parser + * + * @param object $parser an instance of Parser class + * @return void + */ + public function setParser(&$parser) + { + $this->parser =& $parser; + return; + } + + /** + * Actions::doForm() + * Forms get parsedincluded now, using an extra skinvar + * + * @param string $filename + * @return void + */ + public function doForm($filename) + { + global $DIR_NUCLEUS; + array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket'); + + $oldIncludeMode = Parser::getProperty('IncludeMode'); + $oldIncludePrefix = Parser::getProperty('IncludePrefix'); + Parser::setProperty('IncludeMode','normal'); + Parser::setProperty('IncludePrefix',''); + + $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template'); + Parser::setProperty('IncludeMode',$oldIncludeMode); + Parser::setProperty('IncludePrefix',$oldIncludePrefix); + + array_pop($this->parser->actions); // errordiv + array_pop($this->parser->actions); // callback + array_pop($this->parser->actions); // text + array_pop($this->parser->actions); // formdata + array_pop($this->parser->actions); // ticket + return; + } + + /** + * Actions::checkCondition() + * Checks conditions for if statements + * + * @param string $field type of <%if%> + * @param string $name property of field + * @param string $value value of property + * @return boolean condition + */ + public function checkCondition($field, $name='', $value = '') + { + global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists; + + $condition = 0; + switch ( $field ) + { + case 'category': + $condition = ($blog && $this->ifCategory($name,$value)); + break; + case 'blogsetting': + $condition = ($blog && ($blog->getSetting($name) == $value)); + break; + case 'loggedin': + $condition = $member->isLoggedIn(); + break; + case 'onteam': + $condition = $member->isLoggedIn() && $this->ifOnTeam($name); + break; case 'admin': $condition = $member->isLoggedIn() && $this->ifAdmin($name); break; - case 'nextitem': - $condition = ($itemidnext != ''); - break; - case 'previtem': - $condition = ($itemidprev != ''); - break; - case 'archiveprevexists': - $condition = ($archiveprevexists == true); - break; - case 'archivenextexists': - $condition = ($archivenextexists == true); - break; - case 'skintype': - $condition = (($name == $this->skintype) || ($name == requestVar('action'))); - break; - case 'hasplugin': - $condition = $this->ifHasPlugin($name, $value); - break; - default: - $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value); - break; - } - return $condition; - } - - /** - * Actions::_ifHasPlugin() - * hasplugin,PlugName - * -> checks if plugin exists - * hasplugin,PlugName,OptionName - * -> checks if the option OptionName from plugin PlugName is not set to 'no' - * hasplugin,PlugName,OptionName=value - * -> checks if the option OptionName from plugin PlugName is set to value - * - * @param string $name name of plugin - * @param string $value - * @return - */ - private function ifHasPlugin($name, $value) - { - global $manager; - $condition = false; - // (pluginInstalled method won't write a message in the actionlog on failure) - if ( $manager->pluginInstalled("NP_{$name}") ) - { - $plugin =& $manager->getPlugin("NP_{$name}"); - if ( $plugin != NULL ) - { - if ( $value == "" ) - { - $condition = true; - } - else - { - list($name2, $value2) = preg_split('#=#', $value, 2); - if ( $value2 == "" && $plugin->getOption($name2) != 'no' ) - { - $condition = true; - } - else if ( $plugin->getOption($name2) == $value2 ) - { - $condition = true; - } - } - } - } - return $condition; - } - - /** - * Actions::ifPlugin() - * Checks if a plugin exists and call its doIf function - * - * @param string $name name of plugin - * @param string $key name of plugin option - * @param string $value value of plugin option - * @return void - */ - private function ifPlugin($name, $key = '', $value = '') - { - global $manager; - - $plugin =& $manager->getPlugin("NP_{$name}"); - if ( !$plugin ) - { - return; - } - - $params = func_get_args(); - array_shift($params); - - return call_user_func_array(array(&$plugin, 'doIf'), $params); - } - - /** - * Actions::ifCategory() - * Different checks for a category - * - * @param string $name - * @param string $value - * @return boolean - */ - private function ifCategory($name = '', $value='') - { - global $blog, $catid; - - // when no parameter is defined, just check if a category is selected - if ( ($name != 'catname' && $name != 'catid') || ($value == '') ) - { - return $blog->isValidCategory($catid); - } - - // check category name - if ( $name == 'catname' ) - { - $value = $blog->getCategoryIdFromName($value); - if ( $value == $catid ) - { - return $blog->isValidCategory($catid); - } - } - - // check category id - if ( ($name == 'catid') && ($value == $catid) ) - { - return $blog->isValidCategory($catid); - } - return FALSE; - } - - /** - * Actions::ifOnTeam() - * Checks if a member is on the team of a blog and return his rights - * - * @param string $blogName name of weblog - * @return mixed - */ - private function ifOnTeam($blogName = '') - { - global $blog, $member, $manager; - - // when no blog found - if ( ($blogName == '') && !is_object($blog) ) - { - return 0; - } - - // explicit blog selection - if ( $blogName != '' ) - { - $blogid = getBlogIDFromName($blogName); - } - - if ( ($blogName == '') || !$manager->existsBlogID($blogid) ) - { - // use current blog - $blogid = $blog->getID(); - } - - return $member->teamRights($blogid); - } - - /** - * Actions::ifAdmin() - * Checks if a member is admin of a blog - * - * @param string $blogName name of weblog - * @return mixed - */ - private function ifAdmin($blogName = '') - { - global $blog, $member, $manager; - - // when no blog found - if ( ($blogName == '') && (!is_object($blog)) ) - { - return 0; - } - - // explicit blog selection - if ( $blogName != '' ) - { - $blogid = getBlogIDFromName($blogName); - } - - if ( ($blogName == '') || !$manager->existsBlogID($blogid) ) - { - // use current blog - $blogid = $blog->getID(); - } - - return $member->isBlogAdmin($blogid); - } - - /** - * Actions::link() - * returns either - * - a raw link (html/xml encoded) when no linktext is provided - * - a (x)html ' . Entity::hsc($linktext) . ''; - } - else - { - $l = $u; - } - return $l; - } - - /** - * Actions::searchlink() - * Outputs a next/prev link - * - * @param $maxresults - * The maximum amount of items shown per page (e.g. 10) - * @param $startpos - * Current start position (requestVar('startpos')) - * @param $direction - * either 'prev' or 'next' - * @param $linktext - * When present, the output will be a full link. When empty, - * only a raw link will be outputted - */ - private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '') - { - global $CONF, $blog, $query, $amount; - // TODO: Move request uri to linkparams. this is ugly. sorry for that. - $startpos = (integer) $startpos; - $parsed = parse_url(serverVar('REQUEST_URI')); - $path = $parsed['path']; - $parsed = $parsed['query']; - $url = ''; - - if ( $direction == 'prev' ) - { - if ( intval($startpos) - intval($maxresults) >= 0 ) - { - $startpos = intval($startpos) - intval($maxresults); - - if ( $this->skintype == 'index' ) - { - $url = $path; - } - else if ( $this->skintype == 'search' ) - { - $url = $CONF['SearchURL']; - } - $url .= '?' . alterQueryStr($parsed,'startpos',$startpos); - } - } - else if ( $direction == 'next' ) - { - global $navigationItems; - if ( !isset($navigationItems) ) - { - $navigationItems = 0; - } - - if ( $recount ) - { - $iAmountOnPage = 0; - } - else - { - $iAmountOnPage = $this->amountfound; - } - - if ( intval($navigationItems) > 0 ) - { - $iAmountOnPage = intval($navigationItems) - intval($startpos); - } - elseif ( $iAmountOnPage == 0 ) - { - /* - * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%] - * try a count query - */ - if ( $this->skintype == 'index' ) - { - $sqlquery = $blog->getSqlBlog('', 'count'); - $url = $path; - } - else if ( $this->skintype == 'search' ) - { - $unused_highlight = ''; - $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count'); - $url = $CONF['SearchURL']; - } - if ( $sqlquery ) - { - $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos); - } - } - - $url = ''; - if ( intval($iAmountOnPage) >= intval($maxresults) ) - { - $startpos = intval($startpos) + intval($maxresults); - $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos); - } - } - - if ( $url != '' ) - { - echo $this->link($url, $linktext); - } - return; - } - - /** - * Actions::itemlink() - * Creates an item link and if no id is given a todaylink - * - * @param integer $id id for link - * @param string $linktext text for link - * @return void - */ - private function itemlink($id, $linktext = '') - { - global $CONF; - if ( $id != 0 ) - { - echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext); - } - else - { - $this->parse_todaylink($linktext); - } - return; - } - - /** - * Actions::archivelink) - * Creates an archive link and if no id is given a todaylink - * - * @param integer $id id for link - * @param string $linktext text for link - * @return void - */ - private function archivelink($id, $linktext = '') - { - global $CONF, $blog; - if ( $id != 0 ) - { - echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext); - } - else - { - $this->parse_todaylink($linktext); - } - return; - } - - /** - * Actions:setBlogCategory() - * Helper function that sets the category that a blog will need to use - * - * @param string $blog An object of the blog class, passed by reference (we want to make changes to it) - * @param string $catname The name of the category to use - * @return void - */ - private function setBlogCategory(&$blog, $catname) - { - global $catid; - if ( $catname != '' ) - { - $blog->setSelectedCategoryByName($catname); - } - else - { - $blog->setSelectedCategory($catid); - } - return; - } - - /** - * Actions::preBlogContent() - * Notifies the Manager that a PreBlogContent event occurs - * - * @param string $type type of skin - * @param object $blog an instance of Blog class - * @return void - */ - private function preBlogContent($type, &$blog) - { - global $manager; - $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type)); - return; - } - - /** - * Actions::postBlogContent() - * Notifies the Manager that a PostBlogContent event occurs - * - * @param string $type type of skin - * @param objecct $blog an instance of Blog class - * @return void - */ - private function postBlogContent($type, &$blog) - { - global $manager; - $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type)); - return; - } - - /** - * Actions::parse_additemform() - * Parse skinvar additemform - * - * @param void - * @return void - */ - public function parse_additemform() - { - global $blog, $CONF; - $this->formdata = array( - 'adminurl' => Entity::hsc($CONF['AdminURL']), - 'catid' => $blog->getDefaultCategory() - ); - $blog->InsertJavaScriptInfo(); - $this->doForm('additemform'); - return; - } - - /** - * Actions::parse_addlink() - * Parse skinvar addlink - * A Link that allows to open a bookmarklet to add an item - */ - public function parse_addlink() - { - global $CONF, $member, $blog; - if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) ) - { - echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid; - } - return; - } - - /** - * Actions::parse_addpopupcode() - * Parse skinvar addpopupcode - * Code that opens a bookmarklet in an popup window - * - * @param void - * @return void - */ - public function parse_addpopupcode() - { - echo "if (event && event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');winbm.focus();return false;"; - return; - } - - /** - * Parse skinvar adminurl - * (shortcut for admin url) - * - * @param void - * @return void - */ - public function parse_adminurl() - { - $this->parse_sitevar('adminurl'); - return; - } - - /** - * Actions::parse_archive() - * Parse skinvar archive - * - * @param string $template name of template - * @param string $category name of category - * @return - */ - public function parse_archive($template, $category = '') - { - global $blog, $archive; - // can be used with either yyyy-mm or yyyy-mm-dd - sscanf($archive,'%d-%d-%d', $y, $m, $d); - $this->setBlogCategory($blog, $category); - $this->preBlogContent('achive',$blog); - $blog->showArchive($template, $y, $m, $d); - $this->postBlogContent('achive',$blog); - return; - } - - /** - * Actions::parse_archivedate() - * %archivedate(locale,date format)% - * - * @param string $locale - * @return void - */ - public function parse_archivedate($locale = '-def-') - { - global $archive; - - /* - * TODO: these lines are no meaning because there is no $template. - if ( $locale == '-def-' ) - { - setlocale(LC_TIME, $template['LOCALE']); - } - else - { - setlocale(LC_TIME, $locale); - } - */ - - // get archive date - sscanf($archive,'%d-%d-%d',$y,$m,$d); - - // get format - $args = func_get_args(); - // format can be spread over multiple parameters - if ( sizeof($args) > 1 ) - { - // take away locale - array_shift($args); - // implode - $format=implode(',',$args); - } - elseif ( $d == 0 && $m !=0 ) - { - $format = '%B %Y'; - } - elseif ( $m == 0 ) - { - $format = '%Y'; - } - else - { - $format = '%d %B %Y'; - } - echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y)); - return; - } - - /** - * Actions::parse_archivedaylist() - * Parse skinvar archivedaylist - * - * @param string $template name of template - * @param string $category name of category - * @param integer $limit the number of items in a display - * @return void - */ - public function parse_archivedaylist($template, $category = 'all', $limit = 0) - { - global $blog; - if ( $category == 'all' ) - { - $category = ''; - } - $this->preBlogContent('archivelist',$blog); - $this->setBlogCategory($blog, $category); - $blog->showArchiveList($template, 'day', $limit); - $this->postBlogContent('archivelist',$blog); - return; - } - - /** - * Actions::parse_archivelink() - * A link to the archives for the current blog (or for default blog) - * - * @param string $linktext text for link - * @return void - */ - public function parse_archivelink($linktext = '') - { - global $blog, $CONF; - if ( $blog ) - { - echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext); - } - else - { - echo $this->link(Link::create_archivelist_link(), $linktext); - } - return; - } - - /** - * Actions::parse_archivelist() - * - * @param string $template name of template - * @param string $category name of category - * @param integer $limit the number of items in a display - * @return void - */ - public function parse_archivelist($template, $category = 'all', $limit = 0) - { - global $blog; - if ( $category == 'all' ) - { - $category = ''; - } - $this->preBlogContent('archivelist',$blog); - $this->setBlogCategory($blog, $category); - $blog->showArchiveList($template, 'month', $limit); - $this->postBlogContent('archivelist',$blog); - return; - } - - /** - * Actions::parse_archiveyearlist() - * - * @param string $template name of template - * @param string $category name of category - * @param integer $limit the number of items in a display - */ - public function parse_archiveyearlist($template, $category = 'all', $limit = 0) - { - global $blog; - if ( $category == 'all' ) - { - $category = ''; - } - $this->preBlogContent('archivelist',$blog); - $this->setBlogCategory($blog, $category); - $blog->showArchiveList($template, 'year', $limit); - $this->postBlogContent('archivelist',$blog); - return; - } - - /** - * Actions::parse_archivetype() - * Parse skinvar archivetype - * - * @param void - * @return void - */ - public function parse_archivetype() - { - global $archivetype; - echo $archivetype; - return; - } - - /** - * Actions::parse_blog() - * Parse skinvar blog - * - * @param string $template name of template - * @param mixed $amount the number of items in a display, in case it includes the beginning - * @param string $category name of category - * @return void - */ - public function parse_blog($template, $amount = 10, $category = '') - { - global $blog, $startpos; - - list($limit, $offset) = sscanf($amount, '%d(%d)'); - $this->setBlogCategory($blog, $category); - $this->preBlogContent('blog',$blog); - $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos); - $this->postBlogContent('blog',$blog); - return; - } - - /** - * Actions::parse_bloglist() - * Parse skinvar bloglist - * Shows a list of all blogs - * - * @param string $template name of template - * @param string $bnametype whether 'name' or 'shortname' is used for the link text - * @param string $orderby order criteria - * @param string $direction order ascending or descending - * @return void - */ - public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') - { - Blog::showBlogList($template, $bnametype, $orderby, $direction); - return; - } - - /** - * Actions::parse_blogsetting() - * Parse skinvar blogsetting - * - * @param string $which key of weblog settings - * @return void - */ - public function parse_blogsetting($which) - { - global $blog; - switch( $which ) - { - case 'id': - echo Entity::hsc($blog->getID()); - break; - case 'url': - echo Entity::hsc($blog->getURL()); - break; - case 'name': - echo Entity::hsc($blog->getName()); - break; - case 'desc': - echo Entity::hsc($blog->getDescription()); - break; - case 'short': - echo Entity::hsc($blog->getShortName()); - break; - } - return; - } - - /** - * Actions::parse_callback() - * Parse callback - * - * @param string $eventName name of event - * @param string $type type of skin - * @return void - */ - public function parse_callback($eventName, $type) - { - global $manager; - $manager->notify($eventName, array('type' => $type)); - return; - } - - /** - * Actions::parse_category() - * Parse skinvar category - * - * @param string $type key of category settings - * @return void - */ - public function parse_category($type = 'name') - { - global $catid, $blog; - if ( !$blog->isValidCategory($catid) ) - { - return; - } - - switch ( $type ) - { - case 'name': - echo $blog->getCategoryName($catid); - break; - case 'desc': - echo $blog->getCategoryDesc($catid); - break; - case 'id': - echo $catid; - break; - } - return; - } - - /** - * Actions::parse_categorylist() - * Parse categorylist - * - * @param string $template name of template - * @param string $blogname name of weblog - * @return void - */ - public function parse_categorylist($template, $blogname = '') - { - global $blog, $manager; - - // when no blog found - if ( ($blogname == '') && (!is_object($blog)) ) - { - return 0; - } - - if ( $blogname == '' ) - { - $this->preBlogContent('categorylist',$blog); - $blog->showCategoryList($template); - $this->postBlogContent('categorylist',$blog); - } - else - { - $b =& $manager->getBlog(getBlogIDFromName($blogname)); - $this->preBlogContent('categorylist',$b); - $b->showCategoryList($template); - $this->postBlogContent('categorylist',$b); - } - return; - } - - /** - * Actions::parse_charset() - * Parse skinvar charset - * - * @param void - * @return void - */ - public function parse_charset() - { - echo i18n::get_current_charset(); - return; - } - - /** - * Actions::parse_commentform() - * Parse skinvar commentform - * - * @param string $destinationurl URI for redirection - * @return void - */ - public function parse_commentform($destinationurl = '') - { - global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage; - - // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0) - if ( stristr($destinationurl, 'action.php') ) - { - $args = func_get_args(); - $destinationurl = $args[1]; - ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER); - } - - $actionurl = $CONF['ActionURL']; - - // if item is closed, show message and do nothing - $item =& $manager->getItem($itemid,0,0); - if ( $item['closed'] || !$blog->commentsEnabled() ) - { - $this->doForm('commentform-closed'); - return; - } - - if ( !$blog->isPublic() && !$member->isLoggedIn() ) - { - $this->doForm('commentform-closedtopublic'); - return; - } - - if ( !$destinationurl ) - { - // note: createLink returns an HTML encoded URL - $destinationurl = Link::create_link( - 'item', - array( - 'itemid' => $itemid, - 'title' => $item['title'], - 'timestamp' => $item['timestamp'], - 'extra' => $this->linkparams - ) - ); - } - else - { - // HTML encode URL - $destinationurl = Entity::hsc($destinationurl); - } - - // values to prefill - $user = cookieVar($CONF['CookiePrefix'] .'comment_user'); - if ( !$user ) - { - $user = postVar('user'); - } - - $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid'); - if ( !$userid ) - { - $userid = postVar('userid'); - } - - $email = cookieVar($CONF['CookiePrefix'] .'comment_email'); - if (!$email) - { - $email = postVar('email'); - } - - $body = postVar('body'); - - $this->formdata = array( - 'destinationurl' => $destinationurl, // url is already HTML encoded - 'actionurl' => Entity::hsc($actionurl), - 'itemid' => $itemid, - 'user' => Entity::hsc($user), - 'userid' => Entity::hsc($userid), - 'email' => Entity::hsc($email), - 'body' => Entity::hsc($body), - 'membername' => $member->getDisplayName(), - 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':'' - ); - - if ( !$member->isLoggedIn() ) - { - $this->doForm('commentform-notloggedin'); - } - else - { - $this->doForm('commentform-loggedin'); - } - return; - } - - /** - * Actions::parse_comments() - * Parse skinvar comments - * include comments for one item - * - * @param string $template name of template - * @return void - */ - public function parse_comments($template) - { - global $itemid, $manager, $blog, $highlight; - $template =& $manager->getTemplate($template); - - // create parser object & action handler - $actions = new ItemActions($blog); - $parser = new Parser($actions->getDefinedActions(),$actions); - $actions->setTemplate($template); - $actions->setParser($parser); - $item = Item::getitem($itemid, 0, 0); - $actions->setCurrentItem($item); - - $comments = new Comments($itemid); - $comments->setItemActions($actions); - // shows ALL comments - $comments->showComments($template, -1, 1, $highlight); - return; - } - - /** - * Actions::parse_errordiv() - * Parse errordiv - * - * @param void - * @return void - */ - public function parse_errordiv() - { - global $errormessage; - if ( $errormessage ) - { - echo '
' . Entity::hsc($errormessage) . "
\n"; - } - return; - } - - /** - * Actions::parse_errormessage() - * Parse skinvar errormessage - * - * @param void - * @return void - */ - public function parse_errormessage() - { - global $errormessage; - echo $errormessage; - return; - } - - /** - * Actions::parse_formdata() - * Parse formdata - * - * @param string $what key of format data - * @return void - */ - public function parse_formdata($what) - { - echo $this->formdata[$what]; - return; - } - - /** - * Actions::parse_ifcat() - * Parse ifcat - * - * @param string $text - * @return void - */ - public function parse_ifcat($text = '') - { - if ( $text == '' ) - { - // new behaviour - $this->parse_if('category'); - } - else - { - // old behaviour - global $catid, $blog; - if ( $blog->isValidCategory($catid) ) - { - echo $text; - } - } - return; - } - - /** - * Actions::parse_image() - * Parse skinvar image - * - * @param string $what name of tag - * @return void - */ - public function parse_image($what = 'imgtag') - { - global $CONF; - - $imagetext = Entity::hsc(requestVar('imagetext')); - $imagepopup = requestVar('imagepopup'); - $width = intRequestVar('width'); - $height = intRequestVar('height'); - $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup); - - switch ( $what ) - { - case 'url': - echo $fullurl; - break; - case 'width': - echo $width; - break; - case 'height': - echo $height; - break; - case 'caption': - case 'text': - echo $imagetext; - break; - case 'imgtag': - default: - echo "\"$imagetext\""; - break; - } - return; - } - - /** - * Actions::parse_imagetext() - * Parse skinvar imagetext - * - * @param void - * @return void - */ - public function parse_imagetext() - { - $this->parse_image('imagetext'); - return; - } - - /** - * Actions::parse_item() - * Parse skinvar item - * include one item (no comments) - * - * @param void - * @return void - */ - public function parse_item($template) - { - global $blog, $itemid, $highlight; - - // need this to select default category - $this->setBlogCategory($blog, ''); - $this->preBlogContent('item',$blog); - $r = $blog->showOneitem($itemid, $template, $highlight); - if ( $r == 0 ) - { - echo _ERROR_NOSUCHITEM; - } - $this->postBlogContent('item',$blog); - return; - } - - /** - * Actions::parse_itemid() - * Parse skinvar itemid - * - * @param void - * @return void - */ - public function parse_itemid() - { - global $itemid; - echo $itemid; - return; - } - - /** - * Actions::parseitemlink() - * Parse skinvar itemlink - * - * @param void - * @return void - */ - public function parse_itemlink($linktext = '') - { - global $itemid; - $this->itemlink($itemid, $linktext); - return; - } - - /** - * Actions::parse_itemtitle() - * Parse itemtitle - * - * @param void - * @return void - */ - public function parse_itemtitle($format = '') - { - global $manager, $itemid; - $item =& $manager->getItem($itemid,0,0); - - switch ( $format ) - { - case 'xml': - echo Entity::hen($item['title']); - break; - case 'raw': - echo $item['title']; - break; - case 'attribute': - default: - echo Entity::hsc(strip_tags($item['title'])); - break; - } - return; - } - - /** - * Actions::parse_loginform() - * Parse skinvar loginform - * - * @param void - * @return void - */ - public function parse_loginform() - { - global $member, $CONF; - if ( !$member->isLoggedIn() ) - { - $filename = 'loginform-notloggedin'; - $this->formdata = array(); - } - else - { - $filename = 'loginform-loggedin'; - $this->formdata = array( - 'membername' => $member->getDisplayName(), - ); - } - $this->doForm($filename); - return; - } - - /** - * Actions::parse_member() - * Parse skinvar member - * (includes a member info thingie) - * - * @param string $what which memberdata is needed - * @return void - */ - public function parse_member($what) - { - global $memberinfo, $member, $CONF; - - // 1. only allow the member-details-page specific variables on member pages - if ( $this->skintype == 'member' ) - { - switch( $what ) - { - case 'name': - echo Entity::hsc($memberinfo->getDisplayName()); - break; - case 'realname': - echo Entity::hsc($memberinfo->getRealName()); - break; - case 'notes': - echo Entity::hsc($memberinfo->getNotes()); - break; - case 'url': - echo Entity::hsc($memberinfo->getURL()); - break; - case 'email': - echo Entity::hsc($memberinfo->getEmail()); - break; - case 'id': - echo Entity::hsc($memberinfo->getID()); - break; - } - } - - // 2. the next bunch of options is available everywhere, as long as the user is logged in - if ( $member->isLoggedIn() ) - { - switch( $what ) - { - case 'yourname': - echo $member->getDisplayName(); - break; - case 'yourrealname': - echo $member->getRealName(); - break; - case 'yournotes': - echo $member->getNotes(); - break; - case 'yoururl': - echo $member->getURL(); - break; - case 'youremail': - echo $member->getEmail(); - break; - case 'yourid': - echo $member->getID(); - break; - case 'yourprofileurl': - if ($CONF['URLMode'] == 'pathinfo') - echo Link::create_member_link($member->getID()); - else - echo $CONF['IndexURL'] . Link::create_member_link($member->getID()); - break; - } - } - return; - } - - /** - * Link::parse_membermailform() - * Parse skinvar membermailform - * - * @param integer $rows the height for textarea - * @param integer $cols the width for textarea - * @param string $desturl URI to redirect - * @return void - */ - public function parse_membermailform($rows = 10, $cols = 40, $desturl = '') - { - global $member, $CONF, $memberid; - - if ( $desturl == '' ) - { - if ( $CONF['URLMode'] == 'pathinfo' ) - { - $desturl = Link::create_member_link($memberid); - } - else - { - $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid); - } - } - - $message = postVar('message'); - $frommail = postVar('frommail'); - - $this->formdata = array( - 'url' => Entity::hsc($desturl), - 'actionurl' => Entity::hsc($CONF['ActionURL']), - 'memberid' => $memberid, - 'rows' => $rows, - 'cols' => $cols, - 'message' => Entity::hsc($message), - 'frommail' => Entity::hsc($frommail) - ); - - if ( $member->isLoggedIn() ) - { - $this->doForm('membermailform-loggedin'); - } - else if ( $CONF['NonmemberMail'] ) - { - $this->doForm('membermailform-notloggedin'); - } - else - { - $this->doForm('membermailform-disallowed'); - } - return; - } - - /** - * Actions::parse_nextarchive() - * Parse skinvar nextarchive - * - * @param void - * @return void - */ - public function parse_nextarchive() - { - global $archivenext; - echo $archivenext; - return; - } - - /** - * Parse skinvar nextitem - * (include itemid of next item) - * - * @param void - * @return void - */ - public function parse_nextitem() - { - global $itemidnext; - if ( isset($itemidnext) ) - { - echo (int)$itemidnext; - } - return; - } - - /** - * Actions::parse_nextitemtitle() - * Parse skinvar nextitemtitle - * (include itemtitle of next item) - * - * @param string $format format of text - * @return void - */ - public function parse_nextitemtitle($format = '') - { - global $itemtitlenext; - - switch ( $format ) - { - case 'xml': - echo Entity::hen($itemtitlenext); - break; - case 'raw': - echo $itemtitlenext; - break; - case 'attribute': - default: - echo Entity::hsc($itemtitlenext); - break; - } - return; - } - - /** - * Actions::parse_nextlink() - * Parse skinvar nextlink - * - * @param string $linktext text for content of anchor element - * @param integer $amount the amount of items in a display - * @param integer $recount increment from this value - * @return void - */ - public function parse_nextlink($linktext = '', $amount = 10, $recount = '') - { - global $itemidnext, $archivenext, $startpos; - if ( $this->skintype == 'item' ) - { - $this->itemlink($itemidnext, $linktext); - } - else if ( $this->skintype == 'search' || $this->skintype == 'index' ) - { - $this->searchlink($amount, $startpos, 'next', $linktext, $recount); - } - else - { - $this->archivelink($archivenext, $linktext); - } - return; - } - - /** - * Actions::parse_nucleusbutton() - * Parse skinvar nucleusbutton - * - * @param string $imgurl URL for image - * @param integer $imgwidth width of image - * @param integer $imgheidht height of image - */ - public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31') - { - global $CONF; - if ( $imgurl == '' ) - { - $imgurl = $CONF['AdminURL'] . 'nucleus.gif'; - } - else if ( Parser::getProperty('IncludeMode') == 'skindir' ) - { - // when skindit IncludeMode is used: start from skindir - $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl; - } - - $this->formdata = array( - 'imgurl' => $imgurl, - 'imgwidth' => $imgwidth, - 'imgheight' => $imgheight, - ); - $this->doForm('nucleusbutton'); - return; - } - - /** - * Actions::parse_otherarchive() - * Parse skinvar otherarchive - * - * @param string $blogname name of weblog - * @param string $template name of template - * @param string $category name of category - * @return void - */ - public function parse_otherarchive($blogname, $template, $category = '') - { - global $archive, $manager; - sscanf($archive,'%d-%d-%d',$y,$m,$d); - $b =& $manager->getBlog(getBlogIDFromName($blogname)); - $this->setBlogCategory($b, $category); - $this->preBlogContent('otherachive',$b); - $b->showArchive($template, $y, $m, $d); - $this->postBlogContent('otherachive',$b); - return; - } - - /** - * Actions::parse_otherarchivedaylist() - * Parse skinvar otherarchivedaylist - * - * @param string $blogname name of weblog - * @param string $template name of template - * @param string $category name of category - * @param integer $limit the amount of items in a display - * @return void - */ - public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) - { - global $manager; - if ( $category == 'all') - { - $category = ''; - } - $b =& $manager->getBlog(getBlogIDFromName($blogname)); - $this->setBlogCategory($b, $category); - $this->preBlogContent('otherarchivelist',$b); - $b->showArchiveList($template, 'day', $limit); - $this->postBlogContent('otherarchivelist',$b); - return; - } - - /** - * Actions::parse_otherarchivelist() - * Parse skinvar otherarchivelist - * - * @param string $blogname name of weblog - * @param string $template name of template - * @param string $category name of category - * @param integer $limit the amount of items in a display - * @return void - */ - public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) - { - global $manager; - if ( $category == 'all' ) - { - $category = ''; - } - $b =& $manager->getBlog(getBlogIDFromName($blogname)); - $this->setBlogCategory($b, $category); - $this->preBlogContent('otherarchivelist',$b); - $b->showArchiveList($template, 'month', $limit); - $this->postBlogContent('otherarchivelist',$b); - return; - } - - /** - * Actions::parse_otherarchiveyearlist() - * Parse skinvar otherarchiveyearlist - * - * @param string $blogname name of weblog - * @param string $template name of template - * @param string $category name of category - * @limit integer $limit the amount of items in a display - */ - public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) - { - global $manager; - if ( $category == 'all' ) - { - $category = ''; - } - $b =& $manager->getBlog(getBlogIDFromName($blogname)); - $this->setBlogCategory($b, $category); - $this->preBlogContent('otherarchivelist',$b); - $b->showArchiveList($template, 'year', $limit); - $this->postBlogContent('otherarchivelist',$b); - return; - } - - /** - * Actions::parse_otherblog() - * Parse skinvar otherblog - * - * @param string $blogname name of weblog - * @param string $template name of template - * @param mixed $amount the amount of items, in case it includes the beginning - * @param string $category name of category - * @return void - */ - public function parse_otherblog($blogname, $template, $amount = 10, $category = '') - { - global $manager; - - list($limit, $offset) = sscanf($amount, '%d(%d)'); - - $b =& $manager->getBlog(getBlogIDFromName($blogname)); - $this->setBlogCategory($b, $category); - $this->preBlogContent('otherblog',$b); - $this->amountfound = $b->readLog($template, $limit, $offset); - $this->postBlogContent('otherblog',$b); - return; - } - - /** - * Actions::parse_othersearchresults() - * Parse skinvar othersearchresults - * - * @param string $blogname name of weblog - * @param string $template name of template - * @param integer $maxresults the amount of results - * @return void - */ - public function parse_othersearchresults($blogname, $template, $maxresults = 50) - { - global $query, $amount, $manager, $startpos; - $b =& $manager->getBlog(getBlogIDFromName($blogname)); - // need this to select default category - $this->setBlogCategory($b, ''); - $this->preBlogContent('othersearchresults',$b); - $b->search($query, $template, $amount, $maxresults, $startpos); - $this->postBlogContent('othersearchresults',$b); - return; - } - - /** - * Actions::parse_plugin() - * Executes a plugin skinvar - * extra parameters can be added - * - * @param string $pluginName name of plugin (without the NP_) - * @return void - */ - public function parse_plugin($pluginName) - { - global $manager; - - $plugin =& $manager->getPlugin('NP_' . $pluginName); - if ( !$plugin ) - { - return; - } - - // get arguments - $params = func_get_args(); - - // remove plugin name - array_shift($params); - - // add skin type on front - array_unshift($params, $this->skintype); - - call_user_func_array(array(&$plugin,'doSkinVar'), $params); - return; - } - - /** - * Actions::parse_prevarchive() - * Parse skinvar prevarchive - * - * @param void - * @return void - */ - public function parse_prevarchive() - { - global $archiveprev; - echo $archiveprev; - } - - /** - * Actions::parse_preview() - * Parse skinvar preview - * - * @param string $template name of tempalte - * @return void - */ - public function parse_preview($template) - { - global $blog, $CONF, $manager; - - $template =& $manager->getTemplate($template); - - $row['body'] = ''; - $row['title'] = ''; - $row['more'] = ''; - $row['itemlink'] = ''; - $row['itemid'] = 0; $row['blogid'] = $blog->getID(); - - echo Template::fill($template['ITEM_HEADER'],$row); - echo Template::fill($template['ITEM'],$row); - echo Template::fill($template['ITEM_FOOTER'],$row); - return; - } - - /** - * Actions::parse_previtem() - * Parse skinvar previtem - * (include itemid of prev item) - * - * @param void - * @return void - */ - public function parse_previtem() - { - global $itemidprev; - if ( isset($itemidprev) ) - { - echo (integer) $itemidprev; - } - return; - } - - /** - * Actions::parse_previtemtitle() - * Parse skinvar previtemtitle - * (include itemtitle of prev item) - * - * @param String $format string format - * @return String formatted string - */ - public function parse_previtemtitle($format = '') - { - global $itemtitleprev; - - switch ( $format ) - { - case 'xml': - echo Entity::hen($itemtitleprev); - break; - case 'raw': - echo $itemtitleprev; - break; - case 'attribute': - default: - echo Entity::hsc($itemtitleprev); - break; - } - return; - } - - /** - * Actions::parse_prevlink() - * Parse skinvar prevlink - * - * @param string $linktext text as a content of anchor element - * @param integer the amount of links - * @return void - */ - public function parse_prevlink($linktext = '', $amount = 10) - { - global $itemidprev, $archiveprev, $startpos; - - if ( $this->skintype == 'item' ) - { - $this->itemlink($itemidprev, $linktext); - } - else if ( $this->skintype == 'search' || $this->skintype == 'index' ) - { - $this->searchlink($amount, $startpos, 'prev', $linktext); - } - else - { - $this->archivelink($archiveprev, $linktext); - } - return; - } - - /** - * Actions::parse_query() - * Parse skinvar query - * (includes the search query) - * - * @param void - * @return void - */ - public function parse_query() - { - global $query; - echo Entity::hsc($query); - return; - } - - /** - * Actions::parse_referer() - * Parse skinvar referer - * - * @param void - * @return void - */ - public function parse_referer() - { - echo Entity::hsc(serverVar('HTTP_REFERER')); - return; - } - - /** - * Actions::parse_searchform() - * Parse skinvar searchform - * - * @param string $blogname name of weblog - * @return void - */ - public function parse_searchform($blogname = '') - { - global $CONF, $manager, $maxresults; - if ( $blogname ) - { - $blog =& $manager->getBlog(getBlogIDFromName($blogname)); - } - else - { - global $blog; - } - // use default blog when no blog is selected - $this->formdata = array( - 'id' => $blog?$blog->getID():$CONF['DefaultBlog'], - 'query' => Entity::hsc(getVar('query')), - ); - $this->doForm('searchform'); - return; - } - - /** - * Actions::parse_searchresults() - * Parse skinvar searchresults - * - * @param string $template name of tempalte - * @param integer $maxresults searched items in a display - * @return void; - */ - public function parse_searchresults($template, $maxresults = 50 ) - { - global $blog, $query, $amount, $startpos; - - $this->setBlogCategory($blog, ''); // need this to select default category - $this->preBlogContent('searchresults',$blog); - $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos); - $this->postBlogContent('searchresults',$blog); - return; - } - - /** - * Actions::parse_self() - * Parse skinvar self - * - * @param void - * @return void - */ - public function parse_self() - { - global $CONF; - echo $CONF['Self']; - return; - } - - /** - * Actions::parse_sitevar() - * Parse skinvar sitevar - * (include a sitevar) - * - * @param string $which - * @return void - */ - public function parse_sitevar($which) - { - global $CONF; - switch ( $which ) - { - case 'url': - echo $CONF['IndexURL']; - break; - case 'name': - echo $CONF['SiteName']; - break; - case 'admin': - echo $CONF['AdminEmail']; - break; - case 'adminurl': - echo $CONF['AdminURL']; - } - return; - } - - /** - * Actions::parse_skinname() - * Parse skinname - * - * @param void - * @return void - */ - public function parse_skinname() - { - echo $this->skin->getName(); - return; - } - - /** - * Actions::parse_skintype() - * Parse skintype (experimental) - * - * @param void - * @return void - */ - public function parse_skintype() - { - echo $this->skintype; - return; - } - - /** - * Actions::parse_text() - * Parse text - * - * @param void - * @return void - */ - public function parse_text($which) - { - // constant($which) only available from 4.0.4 :( - if ( defined($which) ) - { - eval("echo $which;"); - } - return; - } - - /** - * Actions::parse_ticket() - * Parse ticket - * - * @param void - * @return void - */ - public function parse_ticket() - { - global $manager; - $manager->addTicketHidden(); - return; - } - - /** - * Actions::parse_todaylink() - * Parse skinvar todaylink - * A link to the today page (depending on selected blog, etc...) - * - * @param string $linktext text for link - * @return void - */ - public function parse_todaylink($linktext = '') - { - global $blog, $CONF; - if ( $blog ) - { - echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext); - } - else - { - echo $this->link($CONF['SiteUrl'], $linktext); - } - return; - } - - /** - * Parse vars - * When commentform is not used, to include a hidden field with itemid - * - * @param void - * @return void - */ - public function parse_vars() - { - global $itemid; - echo '' . "\n"; - return; - } - - /** - * Actions::parse_version() - * Parse skinvar version - * (include nucleus versionnumber) - * - * @param void - * @return void - */ - public function parse_version() - { - global $nucleus; - echo 'Nucleus CMS ' . $nucleus['version']; - return; - } - - /** - * Actions::parse_sticky() - * Parse skinvar sticky - * - * @param integer $itemnumber id of item - * @param string $template name of template - * @return void - */ - public function parse_sticky($itemnumber = 0, $template = '') - { - global $manager; - - $itemnumber = intval($itemnumber); - $itemarray = array($itemnumber); - - $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber)); - $this->preBlogContent('sticky',$b); - $this->amountfound = $b->readLogFromList($itemarray, $template); - $this->postBlogContent('sticky',$b); - return; - } -} + case 'nextitem': + $condition = ($itemidnext != ''); + break; + case 'previtem': + $condition = ($itemidprev != ''); + break; + case 'archiveprevexists': + $condition = ($archiveprevexists == true); + break; + case 'archivenextexists': + $condition = ($archivenextexists == true); + break; + case 'skintype': + $condition = (($name == $this->skintype) || ($name == requestVar('action'))); + break; + case 'hasplugin': + $condition = $this->ifHasPlugin($name, $value); + break; + default: + $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value); + break; + } + return $condition; + } + + /** + * Actions::_ifHasPlugin() + * hasplugin,PlugName + * -> checks if plugin exists + * hasplugin,PlugName,OptionName + * -> checks if the option OptionName from plugin PlugName is not set to 'no' + * hasplugin,PlugName,OptionName=value + * -> checks if the option OptionName from plugin PlugName is set to value + * + * @param string $name name of plugin + * @param string $value + * @return + */ + private function ifHasPlugin($name, $value) + { + global $manager; + $condition = false; + // (pluginInstalled method won't write a message in the actionlog on failure) + if ( $manager->pluginInstalled("NP_{$name}") ) + { + $plugin =& $manager->getPlugin("NP_{$name}"); + if ( $plugin != NULL ) + { + if ( $value == "" ) + { + $condition = true; + } + else + { + list($name2, $value2) = preg_split('#=#', $value, 2); + if ( $value2 == "" && $plugin->getOption($name2) != 'no' ) + { + $condition = true; + } + else if ( $plugin->getOption($name2) == $value2 ) + { + $condition = true; + } + } + } + } + return $condition; + } + + /** + * Actions::ifPlugin() + * Checks if a plugin exists and call its doIf function + * + * @param string $name name of plugin + * @param string $key name of plugin option + * @param string $value value of plugin option + * @return void + */ + private function ifPlugin($name, $key = '', $value = '') + { + global $manager; + + $plugin =& $manager->getPlugin("NP_{$name}"); + if ( !$plugin ) + { + return; + } + + $params = func_get_args(); + array_shift($params); + + return call_user_func_array(array(&$plugin, 'doIf'), $params); + } + + /** + * Actions::ifCategory() + * Different checks for a category + * + * @param string $name + * @param string $value + * @return boolean + */ + private function ifCategory($name = '', $value='') + { + global $blog, $catid; + + // when no parameter is defined, just check if a category is selected + if ( ($name != 'catname' && $name != 'catid') || ($value == '') ) + { + return $blog->isValidCategory($catid); + } + + // check category name + if ( $name == 'catname' ) + { + $value = $blog->getCategoryIdFromName($value); + if ( $value == $catid ) + { + return $blog->isValidCategory($catid); + } + } + + // check category id + if ( ($name == 'catid') && ($value == $catid) ) + { + return $blog->isValidCategory($catid); + } + return FALSE; + } + + /** + * Actions::ifOnTeam() + * Checks if a member is on the team of a blog and return his rights + * + * @param string $blogName name of weblog + * @return mixed + */ + private function ifOnTeam($blogName = '') + { + global $blog, $member, $manager; + + // when no blog found + if ( ($blogName == '') && !is_object($blog) ) + { + return 0; + } + + // explicit blog selection + if ( $blogName != '' ) + { + $blogid = getBlogIDFromName($blogName); + } + + if ( ($blogName == '') || !$manager->existsBlogID($blogid) ) + { + // use current blog + $blogid = $blog->getID(); + } + + return $member->teamRights($blogid); + } + + /** + * Actions::ifAdmin() + * Checks if a member is admin of a blog + * + * @param string $blogName name of weblog + * @return mixed + */ + private function ifAdmin($blogName = '') + { + global $blog, $member, $manager; + + // when no blog found + if ( ($blogName == '') && (!is_object($blog)) ) + { + return 0; + } + + // explicit blog selection + if ( $blogName != '' ) + { + $blogid = getBlogIDFromName($blogName); + } + + if ( ($blogName == '') || !$manager->existsBlogID($blogid) ) + { + // use current blog + $blogid = $blog->getID(); + } + + return $member->isBlogAdmin($blogid); + } + + /** + * Actions::link() + * returns either + * - a raw link (html/xml encoded) when no linktext is provided + * - a (x)html
' . Entity::hsc($linktext) . ''; + } + else + { + $l = $u; + } + return $l; + } + + /** + * Actions::searchlink() + * Outputs a next/prev link + * + * @param $maxresults + * The maximum amount of items shown per page (e.g. 10) + * @param $startpos + * Current start position (requestVar('startpos')) + * @param $direction + * either 'prev' or 'next' + * @param $linktext + * When present, the output will be a full link. When empty, + * only a raw link will be outputted + */ + private function searchlink($maxresults, $startpos, $direction, $linktext = '', $recount = '') + { + global $CONF, $blog, $query, $amount; + // TODO: Move request uri to linkparams. this is ugly. sorry for that. + $startpos = (integer) $startpos; + $parsed = parse_url(serverVar('REQUEST_URI')); + $path = $parsed['path']; + $parsed = $parsed['query']; + $url = ''; + + if ( $direction == 'prev' ) + { + if ( intval($startpos) - intval($maxresults) >= 0 ) + { + $startpos = intval($startpos) - intval($maxresults); + + if ( $this->skintype == 'index' ) + { + $url = $path; + } + else if ( $this->skintype == 'search' ) + { + $url = $CONF['SearchURL']; + } + $url .= '?' . alterQueryStr($parsed,'startpos',$startpos); + } + } + else if ( $direction == 'next' ) + { + global $navigationItems; + if ( !isset($navigationItems) ) + { + $navigationItems = 0; + } + + if ( $recount ) + { + $iAmountOnPage = 0; + } + else + { + $iAmountOnPage = $this->amountfound; + } + + if ( intval($navigationItems) > 0 ) + { + $iAmountOnPage = intval($navigationItems) - intval($startpos); + } + elseif ( $iAmountOnPage == 0 ) + { + /* + * [%nextlink%] or [%prevlink%] probably called before [%blog%] or [%searchresults%] + * try a count query + */ + if ( $this->skintype == 'index' ) + { + $sqlquery = $blog->getSqlBlog('', 'count'); + $url = $path; + } + else if ( $this->skintype == 'search' ) + { + $unused_highlight = ''; + $sqlquery = $blog->getSqlSearch($query, $amount, $unused_highlight, 'count'); + $url = $CONF['SearchURL']; + } + if ( $sqlquery ) + { + $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos); + } + } + + $url = ''; + if ( intval($iAmountOnPage) >= intval($maxresults) ) + { + $startpos = intval($startpos) + intval($maxresults); + $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos); + } + } + + if ( $url != '' ) + { + echo $this->link($url, $linktext); + } + return; + } + + /** + * Actions::itemlink() + * Creates an item link and if no id is given a todaylink + * + * @param integer $id id for link + * @param string $linktext text for link + * @return void + */ + private function itemlink($id, $linktext = '') + { + global $CONF; + if ( $id != 0 ) + { + echo $this->link(Link::create_item_link($id, $this->linkparams), $linktext); + } + else + { + $this->parse_todaylink($linktext); + } + return; + } + + /** + * Actions::archivelink) + * Creates an archive link and if no id is given a todaylink + * + * @param integer $id id for link + * @param string $linktext text for link + * @return void + */ + private function archivelink($id, $linktext = '') + { + global $CONF, $blog; + if ( $id != 0 ) + { + echo $this->link(Link::create_archive_link($blog->getID(), $id, $this->linkparams), $linktext); + } + else + { + $this->parse_todaylink($linktext); + } + return; + } + + /** + * Actions:setBlogCategory() + * Helper function that sets the category that a blog will need to use + * + * @param string $blog An object of the blog class, passed by reference (we want to make changes to it) + * @param string $catname The name of the category to use + * @return void + */ + private function setBlogCategory(&$blog, $catname) + { + global $catid; + if ( $catname != '' ) + { + $blog->setSelectedCategoryByName($catname); + } + else + { + $blog->setSelectedCategory($catid); + } + return; + } + + /** + * Actions::preBlogContent() + * Notifies the Manager that a PreBlogContent event occurs + * + * @param string $type type of skin + * @param object $blog an instance of Blog class + * @return void + */ + private function preBlogContent($type, &$blog) + { + global $manager; + $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => $type)); + return; + } + + /** + * Actions::postBlogContent() + * Notifies the Manager that a PostBlogContent event occurs + * + * @param string $type type of skin + * @param objecct $blog an instance of Blog class + * @return void + */ + private function postBlogContent($type, &$blog) + { + global $manager; + $manager->notify('PostBlogContent', array('blog' => &$blog, 'type' => $type)); + return; + } + + /** + * Actions::parse_additemform() + * Parse skinvar additemform + * + * @param void + * @return void + */ + public function parse_additemform() + { + global $blog, $CONF; + $this->formdata = array( + 'adminurl' => Entity::hsc($CONF['AdminURL']), + 'catid' => $blog->getDefaultCategory() + ); + $blog->InsertJavaScriptInfo(); + $this->doForm('additemform'); + return; + } + + /** + * Actions::parse_addlink() + * Parse skinvar addlink + * A Link that allows to open a bookmarklet to add an item + */ + public function parse_addlink() + { + global $CONF, $member, $blog; + if ( $member->isLoggedIn() && $member->isTeamMember($blog->blogid) ) + { + echo $CONF['AdminURL'].'bookmarklet.php?blogid='.$blog->blogid; + } + return; + } + + /** + * Actions::parse_addpopupcode() + * Parse skinvar addpopupcode + * Code that opens a bookmarklet in an popup window + * + * @param void + * @return void + */ + public function parse_addpopupcode() + { + echo "if (event && event.preventDefault) event.preventDefault();winbm=window.open(this.href,'nucleusbm','scrollbars=yes,width=600,height=500,left=10,top=10,status=yes,resizable=yes');winbm.focus();return false;"; + return; + } + + /** + * Parse skinvar adminurl + * (shortcut for admin url) + * + * @param void + * @return void + */ + public function parse_adminurl() + { + $this->parse_sitevar('adminurl'); + return; + } + + /** + * Actions::parse_archive() + * Parse skinvar archive + * + * @param string $template name of template + * @param string $category name of category + * @return + */ + public function parse_archive($template, $category = '') + { + global $blog, $archive; + // can be used with either yyyy-mm or yyyy-mm-dd + sscanf($archive,'%d-%d-%d', $y, $m, $d); + $this->setBlogCategory($blog, $category); + $this->preBlogContent('achive',$blog); + $blog->showArchive($template, $y, $m, $d); + $this->postBlogContent('achive',$blog); + return; + } + + /** + * Actions::parse_archivedate() + * %archivedate(locale,date format)% + * + * @param string $locale + * @return void + */ + public function parse_archivedate($locale = '-def-') + { + global $archive; + + /* + * TODO: these lines are no meaning because there is no $template. + if ( $locale == '-def-' ) + { + setlocale(LC_TIME, $template['LOCALE']); + } + else + { + setlocale(LC_TIME, $locale); + } + */ + + // get archive date + sscanf($archive,'%d-%d-%d',$y,$m,$d); + + // get format + $args = func_get_args(); + // format can be spread over multiple parameters + if ( sizeof($args) > 1 ) + { + // take away locale + array_shift($args); + // implode + $format=implode(',',$args); + } + elseif ( $d == 0 && $m !=0 ) + { + $format = '%B %Y'; + } + elseif ( $m == 0 ) + { + $format = '%Y'; + } + else + { + $format = '%d %B %Y'; + } + echo i18n::formatted_datetime($format, mktime(0,0,0,$m?$m:1,$d?$d:1,$y)); + return; + } + + /** + * Actions::parse_archivedaylist() + * Parse skinvar archivedaylist + * + * @param string $template name of template + * @param string $category name of category + * @param integer $limit the number of items in a display + * @return void + */ + public function parse_archivedaylist($template, $category = 'all', $limit = 0) + { + global $blog; + if ( $category == 'all' ) + { + $category = ''; + } + $this->preBlogContent('archivelist',$blog); + $this->setBlogCategory($blog, $category); + $blog->showArchiveList($template, 'day', $limit); + $this->postBlogContent('archivelist',$blog); + return; + } + + /** + * Actions::parse_archivelink() + * A link to the archives for the current blog (or for default blog) + * + * @param string $linktext text for link + * @return void + */ + public function parse_archivelink($linktext = '') + { + global $blog, $CONF; + if ( $blog ) + { + echo $this->link(Link::create_archivelist_link($blog->getID(), $this->linkparams), $linktext); + } + else + { + echo $this->link(Link::create_archivelist_link(), $linktext); + } + return; + } + + /** + * Actions::parse_archivelist() + * + * @param string $template name of template + * @param string $category name of category + * @param integer $limit the number of items in a display + * @return void + */ + public function parse_archivelist($template, $category = 'all', $limit = 0) + { + global $blog; + if ( $category == 'all' ) + { + $category = ''; + } + $this->preBlogContent('archivelist',$blog); + $this->setBlogCategory($blog, $category); + $blog->showArchiveList($template, 'month', $limit); + $this->postBlogContent('archivelist',$blog); + return; + } + + /** + * Actions::parse_archiveyearlist() + * + * @param string $template name of template + * @param string $category name of category + * @param integer $limit the number of items in a display + */ + public function parse_archiveyearlist($template, $category = 'all', $limit = 0) + { + global $blog; + if ( $category == 'all' ) + { + $category = ''; + } + $this->preBlogContent('archivelist',$blog); + $this->setBlogCategory($blog, $category); + $blog->showArchiveList($template, 'year', $limit); + $this->postBlogContent('archivelist',$blog); + return; + } + + /** + * Actions::parse_archivetype() + * Parse skinvar archivetype + * + * @param void + * @return void + */ + public function parse_archivetype() + { + global $archivetype; + echo $archivetype; + return; + } + + /** + * Actions::parse_blog() + * Parse skinvar blog + * + * @param string $template name of template + * @param mixed $amount the number of items in a display, in case it includes the beginning + * @param string $category name of category + * @return void + */ + public function parse_blog($template, $amount = 10, $category = '') + { + global $blog, $startpos; + + list($limit, $offset) = sscanf($amount, '%d(%d)'); + $this->setBlogCategory($blog, $category); + $this->preBlogContent('blog',$blog); + $this->amountfound = $blog->readLog($template, $limit, $offset, $startpos); + $this->postBlogContent('blog',$blog); + return; + } + + /** + * Actions::parse_bloglist() + * Parse skinvar bloglist + * Shows a list of all blogs + * + * @param string $template name of template + * @param string $bnametype whether 'name' or 'shortname' is used for the link text + * @param string $orderby order criteria + * @param string $direction order ascending or descending + * @return void + */ + public function parse_bloglist($template, $bnametype = '', $orderby='number', $direction='asc') + { + Blog::showBlogList($template, $bnametype, $orderby, $direction); + return; + } + + /** + * Actions::parse_blogsetting() + * Parse skinvar blogsetting + * + * @param string $which key of weblog settings + * @return void + */ + public function parse_blogsetting($which) + { + global $blog; + switch( $which ) + { + case 'id': + echo Entity::hsc($blog->getID()); + break; + case 'url': + echo Entity::hsc($blog->getURL()); + break; + case 'name': + echo Entity::hsc($blog->getName()); + break; + case 'desc': + echo Entity::hsc($blog->getDescription()); + break; + case 'short': + echo Entity::hsc($blog->getShortName()); + break; + } + return; + } + + /** + * Actions::parse_callback() + * Parse callback + * + * @param string $eventName name of event + * @param string $type type of skin + * @return void + */ + public function parse_callback($eventName, $type) + { + global $manager; + $manager->notify($eventName, array('type' => $type)); + return; + } + + /** + * Actions::parse_category() + * Parse skinvar category + * + * @param string $type key of category settings + * @return void + */ + public function parse_category($type = 'name') + { + global $catid, $blog; + if ( !$blog->isValidCategory($catid) ) + { + return; + } + + switch ( $type ) + { + case 'name': + echo $blog->getCategoryName($catid); + break; + case 'desc': + echo $blog->getCategoryDesc($catid); + break; + case 'id': + echo $catid; + break; + } + return; + } + + /** + * Actions::parse_categorylist() + * Parse categorylist + * + * @param string $template name of template + * @param string $blogname name of weblog + * @return void + */ + public function parse_categorylist($template, $blogname = '') + { + global $blog, $manager; + + // when no blog found + if ( ($blogname == '') && (!is_object($blog)) ) + { + return 0; + } + + if ( $blogname == '' ) + { + $this->preBlogContent('categorylist',$blog); + $blog->showCategoryList($template); + $this->postBlogContent('categorylist',$blog); + } + else + { + $b =& $manager->getBlog(getBlogIDFromName($blogname)); + $this->preBlogContent('categorylist',$b); + $b->showCategoryList($template); + $this->postBlogContent('categorylist',$b); + } + return; + } + + /** + * Actions::parse_charset() + * Parse skinvar charset + * + * @param void + * @return void + */ + public function parse_charset() + { + echo i18n::get_current_charset(); + return; + } + + /** + * Actions::parse_commentform() + * Parse skinvar commentform + * + * @param string $destinationurl URI for redirection + * @return void + */ + public function parse_commentform($destinationurl = '') + { + global $blog, $itemid, $member, $CONF, $manager, $DIR_LIBS, $errormessage; + + // warn when trying to provide a actionurl (used to be a parameter in Nucleus <2.0) + if ( stristr($destinationurl, 'action.php') ) + { + $args = func_get_args(); + $destinationurl = $args[1]; + ActionLog::add(WARNING,_ACTIONURL_NOTLONGER_PARAMATER); + } + + $actionurl = $CONF['ActionURL']; + + // if item is closed, show message and do nothing + $item =& $manager->getItem($itemid,0,0); + if ( $item['closed'] || !$blog->commentsEnabled() ) + { + $this->doForm('commentform-closed'); + return; + } + + if ( !$blog->isPublic() && !$member->isLoggedIn() ) + { + $this->doForm('commentform-closedtopublic'); + return; + } + + if ( !$destinationurl ) + { + // note: createLink returns an HTML encoded URL + $destinationurl = Link::create_link( + 'item', + array( + 'itemid' => $itemid, + 'title' => $item['title'], + 'timestamp' => $item['timestamp'], + 'extra' => $this->linkparams + ) + ); + } + else + { + // HTML encode URL + $destinationurl = Entity::hsc($destinationurl); + } + + // values to prefill + $user = cookieVar($CONF['CookiePrefix'] .'comment_user'); + if ( !$user ) + { + $user = postVar('user'); + } + + $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid'); + if ( !$userid ) + { + $userid = postVar('userid'); + } + + $email = cookieVar($CONF['CookiePrefix'] .'comment_email'); + if (!$email) + { + $email = postVar('email'); + } + + $body = postVar('body'); + + $this->formdata = array( + 'destinationurl' => $destinationurl, // url is already HTML encoded + 'actionurl' => Entity::hsc($actionurl), + 'itemid' => $itemid, + 'user' => Entity::hsc($user), + 'userid' => Entity::hsc($userid), + 'email' => Entity::hsc($email), + 'body' => Entity::hsc($body), + 'membername' => $member->getDisplayName(), + 'rememberchecked' => cookieVar($CONF['CookiePrefix'] .'comment_user')?'checked="checked"':'' + ); + + if ( !$member->isLoggedIn() ) + { + $this->doForm('commentform-notloggedin'); + } + else + { + $this->doForm('commentform-loggedin'); + } + return; + } + + /** + * Actions::parse_comments() + * Parse skinvar comments + * include comments for one item + * + * @param string $template name of template + * @return void + */ + public function parse_comments($template) + { + global $itemid, $manager, $blog, $highlight; + $template =& $manager->getTemplate($template); + + // create parser object & action handler + $actions = new ItemActions($blog); + $parser = new Parser($actions->getDefinedActions(),$actions); + $actions->setTemplate($template); + $actions->setParser($parser); + $item = Item::getitem($itemid, 0, 0); + $actions->setCurrentItem($item); + + $comments = new Comments($itemid); + $comments->setItemActions($actions); + // shows ALL comments + $comments->showComments($template, -1, 1, $highlight); + return; + } + + /** + * Actions::parse_errordiv() + * Parse errordiv + * + * @param void + * @return void + */ + public function parse_errordiv() + { + global $errormessage; + if ( $errormessage ) + { + echo '
' . Entity::hsc($errormessage) . "
\n"; + } + return; + } + + /** + * Actions::parse_errormessage() + * Parse skinvar errormessage + * + * @param void + * @return void + */ + public function parse_errormessage() + { + global $errormessage; + echo $errormessage; + return; + } + + /** + * Actions::parse_formdata() + * Parse formdata + * + * @param string $what key of format data + * @return void + */ + public function parse_formdata($what) + { + echo $this->formdata[$what]; + return; + } + + /** + * Actions::parse_ifcat() + * Parse ifcat + * + * @param string $text + * @return void + */ + public function parse_ifcat($text = '') + { + if ( $text == '' ) + { + // new behaviour + $this->parse_if('category'); + } + else + { + // old behaviour + global $catid, $blog; + if ( $blog->isValidCategory($catid) ) + { + echo $text; + } + } + return; + } + + /** + * Actions::parse_image() + * Parse skinvar image + * + * @param string $what name of tag + * @return void + */ + public function parse_image($what = 'imgtag') + { + global $CONF; + + $imagetext = Entity::hsc(requestVar('imagetext')); + $imagepopup = requestVar('imagepopup'); + $width = intRequestVar('width'); + $height = intRequestVar('height'); + $fullurl = Entity::hsc($CONF['MediaURL'] . $imagepopup); + + switch ( $what ) + { + case 'url': + echo $fullurl; + break; + case 'width': + echo $width; + break; + case 'height': + echo $height; + break; + case 'caption': + case 'text': + echo $imagetext; + break; + case 'imgtag': + default: + echo "\"$imagetext\""; + break; + } + return; + } + + /** + * Actions::parse_imagetext() + * Parse skinvar imagetext + * + * @param void + * @return void + */ + public function parse_imagetext() + { + $this->parse_image('imagetext'); + return; + } + + /** + * Actions::parse_item() + * Parse skinvar item + * include one item (no comments) + * + * @param void + * @return void + */ + public function parse_item($template) + { + global $blog, $itemid, $highlight; + + // need this to select default category + $this->setBlogCategory($blog, ''); + $this->preBlogContent('item',$blog); + $r = $blog->showOneitem($itemid, $template, $highlight); + if ( $r == 0 ) + { + echo _ERROR_NOSUCHITEM; + } + $this->postBlogContent('item',$blog); + return; + } + + /** + * Actions::parse_itemid() + * Parse skinvar itemid + * + * @param void + * @return void + */ + public function parse_itemid() + { + global $itemid; + echo $itemid; + return; + } + + /** + * Actions::parseitemlink() + * Parse skinvar itemlink + * + * @param void + * @return void + */ + public function parse_itemlink($linktext = '') + { + global $itemid; + $this->itemlink($itemid, $linktext); + return; + } + + /** + * Actions::parse_itemtitle() + * Parse itemtitle + * + * @param void + * @return void + */ + public function parse_itemtitle($format = '') + { + global $manager, $itemid; + $item =& $manager->getItem($itemid,0,0); + + switch ( $format ) + { + case 'xml': + echo Entity::hen($item['title']); + break; + case 'raw': + echo $item['title']; + break; + case 'attribute': + default: + echo Entity::hsc(strip_tags($item['title'])); + break; + } + return; + } + + /** + * Actions::parse_loginform() + * Parse skinvar loginform + * + * @param void + * @return void + */ + public function parse_loginform() + { + global $member, $CONF; + if ( !$member->isLoggedIn() ) + { + $filename = 'loginform-notloggedin'; + $this->formdata = array(); + } + else + { + $filename = 'loginform-loggedin'; + $this->formdata = array( + 'membername' => $member->getDisplayName(), + ); + } + $this->doForm($filename); + return; + } + + /** + * Actions::parse_member() + * Parse skinvar member + * (includes a member info thingie) + * + * @param string $what which memberdata is needed + * @return void + */ + public function parse_member($what) + { + global $memberinfo, $member, $CONF; + + // 1. only allow the member-details-page specific variables on member pages + if ( $this->skintype == 'member' ) + { + switch( $what ) + { + case 'name': + echo Entity::hsc($memberinfo->getDisplayName()); + break; + case 'realname': + echo Entity::hsc($memberinfo->getRealName()); + break; + case 'notes': + echo Entity::hsc($memberinfo->getNotes()); + break; + case 'url': + echo Entity::hsc($memberinfo->getURL()); + break; + case 'email': + echo Entity::hsc($memberinfo->getEmail()); + break; + case 'id': + echo Entity::hsc($memberinfo->getID()); + break; + } + } + + // 2. the next bunch of options is available everywhere, as long as the user is logged in + if ( $member->isLoggedIn() ) + { + switch( $what ) + { + case 'yourname': + echo $member->getDisplayName(); + break; + case 'yourrealname': + echo $member->getRealName(); + break; + case 'yournotes': + echo $member->getNotes(); + break; + case 'yoururl': + echo $member->getURL(); + break; + case 'youremail': + echo $member->getEmail(); + break; + case 'yourid': + echo $member->getID(); + break; + case 'yourprofileurl': + if ($CONF['URLMode'] == 'pathinfo') + echo Link::create_member_link($member->getID()); + else + echo $CONF['IndexURL'] . Link::create_member_link($member->getID()); + break; + } + } + return; + } + + /** + * Link::parse_membermailform() + * Parse skinvar membermailform + * + * @param integer $rows the height for textarea + * @param integer $cols the width for textarea + * @param string $desturl URI to redirect + * @return void + */ + public function parse_membermailform($rows = 10, $cols = 40, $desturl = '') + { + global $member, $CONF, $memberid; + + if ( $desturl == '' ) + { + if ( $CONF['URLMode'] == 'pathinfo' ) + { + $desturl = Link::create_member_link($memberid); + } + else + { + $desturl = $CONF['IndexURL'] . Link::create_member_link($memberid); + } + } + + $message = postVar('message'); + $frommail = postVar('frommail'); + + $this->formdata = array( + 'url' => Entity::hsc($desturl), + 'actionurl' => Entity::hsc($CONF['ActionURL']), + 'memberid' => $memberid, + 'rows' => $rows, + 'cols' => $cols, + 'message' => Entity::hsc($message), + 'frommail' => Entity::hsc($frommail) + ); + + if ( $member->isLoggedIn() ) + { + $this->doForm('membermailform-loggedin'); + } + else if ( $CONF['NonmemberMail'] ) + { + $this->doForm('membermailform-notloggedin'); + } + else + { + $this->doForm('membermailform-disallowed'); + } + return; + } + + /** + * Actions::parse_nextarchive() + * Parse skinvar nextarchive + * + * @param void + * @return void + */ + public function parse_nextarchive() + { + global $archivenext; + echo $archivenext; + return; + } + + /** + * Parse skinvar nextitem + * (include itemid of next item) + * + * @param void + * @return void + */ + public function parse_nextitem() + { + global $itemidnext; + if ( isset($itemidnext) ) + { + echo (int)$itemidnext; + } + return; + } + + /** + * Actions::parse_nextitemtitle() + * Parse skinvar nextitemtitle + * (include itemtitle of next item) + * + * @param string $format format of text + * @return void + */ + public function parse_nextitemtitle($format = '') + { + global $itemtitlenext; + + switch ( $format ) + { + case 'xml': + echo Entity::hen($itemtitlenext); + break; + case 'raw': + echo $itemtitlenext; + break; + case 'attribute': + default: + echo Entity::hsc($itemtitlenext); + break; + } + return; + } + + /** + * Actions::parse_nextlink() + * Parse skinvar nextlink + * + * @param string $linktext text for content of anchor element + * @param integer $amount the amount of items in a display + * @param integer $recount increment from this value + * @return void + */ + public function parse_nextlink($linktext = '', $amount = 10, $recount = '') + { + global $itemidnext, $archivenext, $startpos; + if ( $this->skintype == 'item' ) + { + $this->itemlink($itemidnext, $linktext); + } + else if ( $this->skintype == 'search' || $this->skintype == 'index' ) + { + $this->searchlink($amount, $startpos, 'next', $linktext, $recount); + } + else + { + $this->archivelink($archivenext, $linktext); + } + return; + } + + /** + * Actions::parse_nucleusbutton() + * Parse skinvar nucleusbutton + * + * @param string $imgurl URL for image + * @param integer $imgwidth width of image + * @param integer $imgheidht height of image + */ + public function parse_nucleusbutton($imgurl = '', $imgwidth = '85', $imgheight = '31') + { + global $CONF; + if ( $imgurl == '' ) + { + $imgurl = $CONF['AdminURL'] . 'nucleus.gif'; + } + else if ( Parser::getProperty('IncludeMode') == 'skindir' ) + { + // when skindit IncludeMode is used: start from skindir + $imgurl = $CONF['SkinsURL'] . Parser::getProperty('IncludePrefix') . $imgurl; + } + + $this->formdata = array( + 'imgurl' => $imgurl, + 'imgwidth' => $imgwidth, + 'imgheight' => $imgheight, + ); + $this->doForm('nucleusbutton'); + return; + } + + /** + * Actions::parse_otherarchive() + * Parse skinvar otherarchive + * + * @param string $blogname name of weblog + * @param string $template name of template + * @param string $category name of category + * @return void + */ + public function parse_otherarchive($blogname, $template, $category = '') + { + global $archive, $manager; + sscanf($archive,'%d-%d-%d',$y,$m,$d); + $b =& $manager->getBlog(getBlogIDFromName($blogname)); + $this->setBlogCategory($b, $category); + $this->preBlogContent('otherachive',$b); + $b->showArchive($template, $y, $m, $d); + $this->postBlogContent('otherachive',$b); + return; + } + + /** + * Actions::parse_otherarchivedaylist() + * Parse skinvar otherarchivedaylist + * + * @param string $blogname name of weblog + * @param string $template name of template + * @param string $category name of category + * @param integer $limit the amount of items in a display + * @return void + */ + public function parse_otherarchivedaylist($blogname, $template, $category = 'all', $limit = 0) + { + global $manager; + if ( $category == 'all') + { + $category = ''; + } + $b =& $manager->getBlog(getBlogIDFromName($blogname)); + $this->setBlogCategory($b, $category); + $this->preBlogContent('otherarchivelist',$b); + $b->showArchiveList($template, 'day', $limit); + $this->postBlogContent('otherarchivelist',$b); + return; + } + + /** + * Actions::parse_otherarchivelist() + * Parse skinvar otherarchivelist + * + * @param string $blogname name of weblog + * @param string $template name of template + * @param string $category name of category + * @param integer $limit the amount of items in a display + * @return void + */ + public function parse_otherarchivelist($blogname, $template, $category = 'all', $limit = 0) + { + global $manager; + if ( $category == 'all' ) + { + $category = ''; + } + $b =& $manager->getBlog(getBlogIDFromName($blogname)); + $this->setBlogCategory($b, $category); + $this->preBlogContent('otherarchivelist',$b); + $b->showArchiveList($template, 'month', $limit); + $this->postBlogContent('otherarchivelist',$b); + return; + } + + /** + * Actions::parse_otherarchiveyearlist() + * Parse skinvar otherarchiveyearlist + * + * @param string $blogname name of weblog + * @param string $template name of template + * @param string $category name of category + * @limit integer $limit the amount of items in a display + */ + public function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) + { + global $manager; + if ( $category == 'all' ) + { + $category = ''; + } + $b =& $manager->getBlog(getBlogIDFromName($blogname)); + $this->setBlogCategory($b, $category); + $this->preBlogContent('otherarchivelist',$b); + $b->showArchiveList($template, 'year', $limit); + $this->postBlogContent('otherarchivelist',$b); + return; + } + + /** + * Actions::parse_otherblog() + * Parse skinvar otherblog + * + * @param string $blogname name of weblog + * @param string $template name of template + * @param mixed $amount the amount of items, in case it includes the beginning + * @param string $category name of category + * @return void + */ + public function parse_otherblog($blogname, $template, $amount = 10, $category = '') + { + global $manager; + + list($limit, $offset) = sscanf($amount, '%d(%d)'); + + $b =& $manager->getBlog(getBlogIDFromName($blogname)); + $this->setBlogCategory($b, $category); + $this->preBlogContent('otherblog',$b); + $this->amountfound = $b->readLog($template, $limit, $offset); + $this->postBlogContent('otherblog',$b); + return; + } + + /** + * Actions::parse_othersearchresults() + * Parse skinvar othersearchresults + * + * @param string $blogname name of weblog + * @param string $template name of template + * @param integer $maxresults the amount of results + * @return void + */ + public function parse_othersearchresults($blogname, $template, $maxresults = 50) + { + global $query, $amount, $manager, $startpos; + $b =& $manager->getBlog(getBlogIDFromName($blogname)); + // need this to select default category + $this->setBlogCategory($b, ''); + $this->preBlogContent('othersearchresults',$b); + $b->search($query, $template, $amount, $maxresults, $startpos); + $this->postBlogContent('othersearchresults',$b); + return; + } + + /** + * Actions::parse_plugin() + * Executes a plugin skinvar + * extra parameters can be added + * + * @param string $pluginName name of plugin (without the NP_) + * @return void + */ + public function parse_plugin($pluginName) + { + global $manager; + + $plugin =& $manager->getPlugin('NP_' . $pluginName); + if ( !$plugin ) + { + return; + } + + // get arguments + $params = func_get_args(); + + // remove plugin name + array_shift($params); + + // add skin type on front + array_unshift($params, $this->skintype); + + call_user_func_array(array(&$plugin,'doSkinVar'), $params); + return; + } + + /** + * Actions::parse_prevarchive() + * Parse skinvar prevarchive + * + * @param void + * @return void + */ + public function parse_prevarchive() + { + global $archiveprev; + echo $archiveprev; + } + + /** + * Actions::parse_preview() + * Parse skinvar preview + * + * @param string $template name of tempalte + * @return void + */ + public function parse_preview($template) + { + global $blog, $CONF, $manager; + + $template =& $manager->getTemplate($template); + + $row['body'] = ''; + $row['title'] = ''; + $row['more'] = ''; + $row['itemlink'] = ''; + $row['itemid'] = 0; $row['blogid'] = $blog->getID(); + + echo Template::fill($template['ITEM_HEADER'],$row); + echo Template::fill($template['ITEM'],$row); + echo Template::fill($template['ITEM_FOOTER'],$row); + return; + } + + /** + * Actions::parse_previtem() + * Parse skinvar previtem + * (include itemid of prev item) + * + * @param void + * @return void + */ + public function parse_previtem() + { + global $itemidprev; + if ( isset($itemidprev) ) + { + echo (integer) $itemidprev; + } + return; + } + + /** + * Actions::parse_previtemtitle() + * Parse skinvar previtemtitle + * (include itemtitle of prev item) + * + * @param String $format string format + * @return String formatted string + */ + public function parse_previtemtitle($format = '') + { + global $itemtitleprev; + + switch ( $format ) + { + case 'xml': + echo Entity::hen($itemtitleprev); + break; + case 'raw': + echo $itemtitleprev; + break; + case 'attribute': + default: + echo Entity::hsc($itemtitleprev); + break; + } + return; + } + + /** + * Actions::parse_prevlink() + * Parse skinvar prevlink + * + * @param string $linktext text as a content of anchor element + * @param integer the amount of links + * @return void + */ + public function parse_prevlink($linktext = '', $amount = 10) + { + global $itemidprev, $archiveprev, $startpos; + + if ( $this->skintype == 'item' ) + { + $this->itemlink($itemidprev, $linktext); + } + else if ( $this->skintype == 'search' || $this->skintype == 'index' ) + { + $this->searchlink($amount, $startpos, 'prev', $linktext); + } + else + { + $this->archivelink($archiveprev, $linktext); + } + return; + } + + /** + * Actions::parse_query() + * Parse skinvar query + * (includes the search query) + * + * @param void + * @return void + */ + public function parse_query() + { + global $query; + echo Entity::hsc($query); + return; + } + + /** + * Actions::parse_referer() + * Parse skinvar referer + * + * @param void + * @return void + */ + public function parse_referer() + { + echo Entity::hsc(serverVar('HTTP_REFERER')); + return; + } + + /** + * Actions::parse_searchform() + * Parse skinvar searchform + * + * @param string $blogname name of weblog + * @return void + */ + public function parse_searchform($blogname = '') + { + global $CONF, $manager, $maxresults; + if ( $blogname ) + { + $blog =& $manager->getBlog(getBlogIDFromName($blogname)); + } + else + { + global $blog; + } + // use default blog when no blog is selected + $this->formdata = array( + 'id' => $blog?$blog->getID():$CONF['DefaultBlog'], + 'query' => Entity::hsc(getVar('query')), + ); + $this->doForm('searchform'); + return; + } + + /** + * Actions::parse_searchresults() + * Parse skinvar searchresults + * + * @param string $template name of tempalte + * @param integer $maxresults searched items in a display + * @return void; + */ + public function parse_searchresults($template, $maxresults = 50 ) + { + global $blog, $query, $amount, $startpos; + + $this->setBlogCategory($blog, ''); // need this to select default category + $this->preBlogContent('searchresults',$blog); + $this->amountfound = $blog->search($query, $template, $amount, $maxresults, $startpos); + $this->postBlogContent('searchresults',$blog); + return; + } + + /** + * Actions::parse_self() + * Parse skinvar self + * + * @param void + * @return void + */ + public function parse_self() + { + global $CONF; + echo $CONF['Self']; + return; + } + + /** + * Actions::parse_sitevar() + * Parse skinvar sitevar + * (include a sitevar) + * + * @param string $which + * @return void + */ + public function parse_sitevar($which) + { + global $CONF; + switch ( $which ) + { + case 'url': + echo $CONF['IndexURL']; + break; + case 'name': + echo $CONF['SiteName']; + break; + case 'admin': + echo $CONF['AdminEmail']; + break; + case 'adminurl': + echo $CONF['AdminURL']; + } + return; + } + + /** + * Actions::parse_skinname() + * Parse skinname + * + * @param void + * @return void + */ + public function parse_skinname() + { + echo $this->skin->getName(); + return; + } + + /** + * Actions::parse_skintype() + * Parse skintype (experimental) + * + * @param void + * @return void + */ + public function parse_skintype() + { + echo $this->skintype; + return; + } + + /** + * Actions::parse_text() + * Parse text + * + * @param void + * @return void + */ + public function parse_text($which) + { + // constant($which) only available from 4.0.4 :( + if ( defined($which) ) + { + eval("echo $which;"); + } + return; + } + + /** + * Actions::parse_ticket() + * Parse ticket + * + * @param void + * @return void + */ + public function parse_ticket() + { + global $manager; + $manager->addTicketHidden(); + return; + } + + /** + * Actions::parse_todaylink() + * Parse skinvar todaylink + * A link to the today page (depending on selected blog, etc...) + * + * @param string $linktext text for link + * @return void + */ + public function parse_todaylink($linktext = '') + { + global $blog, $CONF; + if ( $blog ) + { + echo $this->link(Link::create_blogid_link($blog->getID(),$this->linkparams), $linktext); + } + else + { + echo $this->link($CONF['SiteUrl'], $linktext); + } + return; + } + + /** + * Parse vars + * When commentform is not used, to include a hidden field with itemid + * + * @param void + * @return void + */ + public function parse_vars() + { + global $itemid; + echo '' . "\n"; + return; + } + + /** + * Actions::parse_version() + * Parse skinvar version + * (include nucleus versionnumber) + * + * @param void + * @return void + */ + public function parse_version() + { + global $nucleus; + echo 'Nucleus CMS ' . $nucleus['version']; + return; + } + + /** + * Actions::parse_sticky() + * Parse skinvar sticky + * + * @param integer $itemnumber id of item + * @param string $template name of template + * @return void + */ + public function parse_sticky($itemnumber = 0, $template = '') + { + global $manager; + + $itemnumber = intval($itemnumber); + $itemarray = array($itemnumber); + + $b =& $manager->getBlog(getBlogIDFromItemID($itemnumber)); + $this->preBlogContent('sticky',$b); + $this->amountfound = $b->readLogFromList($itemarray, $template); + $this->postBlogContent('sticky',$b); + return; + } +} diff --git a/nucleus/libs/ADMIN.php b/nucleus/libs/ADMIN.php index 7739466..6657749 100644 --- a/nucleus/libs/ADMIN.php +++ b/nucleus/libs/ADMIN.php @@ -1,7 +1,7 @@ action_templateoverview(); } - /** - * @todo document this - */ - function action_skinoverview() { - global $member, $manager; - - $member->isAdmin() or $this->disallow(); - - $this->pagehead(); - - echo '

(',_BACKTOMANAGE,')

'; - - echo '

' . _SKIN_EDIT_TITLE . '

'; - - echo '

' . _SKIN_AVAILABLE_TITLE . '

'; - - $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname'; - $template['content'] = 'skinlist'; - $template['tabindex'] = 10; - showlist($query,'table',$template); - - echo '

' . _SKIN_NEW_TITLE . '

'; - - ?> -
-
- - - addTicketHidden() ?> - - - - - - - - - -
- -
-
- - pagefoot(); - } + /** + * Admin::action_skinoverview() + * + * @param void + * @return void + */ + public function action_skinoverview() + { + global $member, $manager; + + $member->isAdmin() or $this->disallow(); + + $this->pagehead(); + + echo '

(' . _BACKTOMANAGE . ")

\n"; + echo '

' . _SKIN_EDIT_TITLE . "

\n"; + echo '

' . _SKIN_AVAILABLE_TITLE . "

\n"; + + $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname;'; + $template['content'] = 'skinlist'; + $template['tabindex'] = 10; + $template['friendly_names'] = Skin::getFriendlyNames('Actions'); + showlist($query,'table',$template); + + echo '

' . _SKIN_NEW_TITLE . "

\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + + $manager->addTicketHidden() . "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo '\n"; + echo '\n"; + echo "\n"; + echo "
" . _SKIN_NAME; + echo help('shortnames'); + echo "
" . _SKIN_DESC . "
' . _SKIN_CREATE . "' . "
\n"; + + echo "
\n"; + echo "
\n"; + + $this->pagefoot(); + return; + } /** * @todo document this diff --git a/nucleus/libs/SKIN.php b/nucleus/libs/SKIN.php index c602467..38a1e9d 100644 --- a/nucleus/libs/SKIN.php +++ b/nucleus/libs/SKIN.php @@ -1,718 +1,605 @@ -id = (integer) $id; - - // read skin name/description/content type - $query = "SELECT * FROM %s WHERE sdnumber=%d"; - $query = sprintf($query, sql_table('skin_desc'), (integer) $this->id); - $res = sql_query($query); - $obj = sql_fetch_object($res); - $this->valid = (sql_num_rows($res) > 0); - if ( !$this->valid ) - { - return; - } - - $this->name = $obj->sdname; - $this->description = $obj->sddesc; - $this->contentType = $obj->sdtype; - $this->includeMode = $obj->sdincmode; - $this->includePrefix = $obj->sdincpref; - return; - } - - /** - * Skin::getID() - * Get SKIN id - * - * @param void - * @return integer id for this skin instance - */ - public function getID() - { - return (integer) $this->id; - } - - /** - * Skin::isValid() - * - * @param void - * @return boolean - */ - public function isValid() - { - return (boolean) $this->valid; - } - - /** - * Skin::getName() - * Get SKIN name - * - * @param void - * @return string name of this skin instance - */ - public function getName() - { - return (string) $this->name; - } - - /** - * Skin::getDescription() - * Get SKIN description - * - * @param void - * @return string description of this skin instance - */ - public function getDescription() - { - return (string) $this->description; - } - - /** - * Skin::getContentType() - * Get SKIN content type - * e.g. text/xml, text/html, application/atom+xml - * - * @param void - * @return string name of this skin instance - */ - public function getContentType() - { - return (string) $this->contentType; - } - - /** - * Skin::getIncludeMode() - * Get include mode of the SKIN - * - * Returns either 'normal' or 'skindir': - * 'normal': if a all data of the skin can be found in the databse - * 'skindir': if the skin has data in the it's skin driectory - * - * @param void - * @return string normal/skindir - */ - public function getIncludeMode() - { - return (string) $this->includeMode; - } - - /** - * Skin::getIncludePrefix() - * Get include prefix of the SKIN - * - * Get name of the subdirectory (with trailing slash) where - * the files of the current skin can be found (e.g. 'default/') - * - * @param void - * @return string include prefix of this skin instance - */ - public function getIncludePrefix() - { - return (string) $this->includePrefix; - } - - /** - * Skin::exists() - * Checks if a skin with a given shortname exists - * - * @static - * @param string $name Skin short name - * @return integer number of skins with the given ID - */ - static public function exists($name) - { - $query = "SELECT COUNT(*) AS result FROM %s WHERE sdname='%s';"; - $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name)); - return quickQuery($query) > 0; - } - - /** - * Skin::existsID() - * Checks if a skin with a given ID exists - * - * @static - * @param string $id Skin ID - * @return integer number of skins with the given ID - */ - static public function existsID($id) - { - $query = "SELECT COUNT(*) AS result FROM %s WHERE sdnumber=%d;"; - $query = sprintf($query, sql_table('skin_desc'), (integer) $id); - return quickQuery($query) > 0; - } - - /** - * Skin::createFromName() - * Returns a skin given its shortname - * - * @static - * @param string $name Skin shortname - * @return object instance of Skin class - */ - static public function createFromName($name) - { - return new SKIN(SKIN::getIdFromName($name)); - } - - /** - * Skin::getIdFromName() - * Returns a skin ID given its shortname - * - * @static - * @param string $name Skin shortname - * @return integer Skin ID - */ - static public function getIdFromName($name) - { - $query = "SELECT sdnumber FROM %s WHERE sdname='%s';"; - $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name)); - $res = sql_query($query); - $obj = sql_fetch_object($res); - return $obj->sdnumber; - } - - /** - * Skin::getNameFromId() - * Returns a skin shortname given its ID - * - * @static - * @param string $name - * @return string Skin short name - */ - static public function getNameFromId($id) - { - $query = "SELECT sdname AS result FROM %s WHERE sdnumber=%d;"; - $query = sprintf($query, sql_table('skin_desc'), (integer) $id); - return quickQuery($query); - } - - /** - * SKIN::createNew() - * Creates a new skin, with the given characteristics. - * - * @static - * @param String $name value for nucleus_skin.sdname - * @param String $desc value for nucleus_skin.sddesc - * @param String $type value for nucleus_skin.sdtype - * @param String $includeMode value for nucleus_skin.sdinclude - * @param String $includePrefix value for nucleus_skin.sdincpref - * @return Integer ID for just inserted record - */ - function createNew($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') - { - global $manager; - - $manager->notify( - 'PreAddSkin', - array( - 'name' => &$name, - 'description' => &$desc, - 'type' => &$type, - 'includeMode' => &$includeMode, - 'includePrefix' => &$includePrefix - ) - ); - - $query = "INSERT INTO %s (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('%s', '%s', '%s', '%s', '%s');"; - $sdname = sql_real_escape_string($name); - $sddesc = sql_real_escape_string($desc); - $sdtype = sql_real_escape_string($type); - $sdincmode = sql_real_escape_string($includeMode); - $sdincpref = sql_real_escape_string($includePrefix); - $query = sprintf($query, sql_table('skin_desc'), $sdname, $sddesc, $sdtype, $sdincmode, $sdincpref); - sql_query($query); - $newid = sql_insert_id(); - - $manager->notify( - 'PostAddSkin', - array( - 'skinid' => $newid, - 'name' => $name, - 'description' => $desc, - 'type' => $type, - 'includeMode' => $includeMode, - 'includePrefix' => $includePrefix - ) - ); - return $newid; - } - - /** - * Skin::parse() - * Parse a SKIN - * - * @param string $type - * @return void - */ - public function parse($type) - { - global $currentSkinName, $manager, $CONF; - - $manager->notify('InitSkinParse',array('skin' => &$this, 'type' => $type)); - - // set output type - sendContentType($this->getContentType(), 'skin'); - - // set skin name as global var (so plugins can access it) - $currentSkinName = $this->getName(); - $contents = $this->getContent($type); - - if ( !$contents ) - { - // use base skin if this skin does not have contents - $defskin = new SKIN($CONF['BaseSkin']); - $contents = $defskin->getContent($type); - if ( !$contents ) - { - echo _ERROR_SKIN; - return; - } - } - - $actions = $this->getAllowedActionsForType($type); - - $manager->notify('PreSkinParse',array('skin' => &$this, 'type' => $type, 'contents' => &$contents)); - - // set IncludeMode properties of parser - Parser::setProperty('IncludeMode', $this->getIncludeMode()); - Parser::setProperty('IncludePrefix', $this->getIncludePrefix()); - - $handler = new Actions($type, $this); - $parser = new Parser($actions, $handler); - $handler->setParser($parser); - $handler->setSkin($this); - $parser->parse($contents); - - $manager->notify('PostSkinParse',array('skin' => &$this, 'type' => $type)); - return; - } - - /** - * Skin::getContent() - * Get content of the skin part from the database - * - * @param string $type type of the skin (e.g. index, item, search ...) - * @return string content of scontent - */ - function getContent($type) - { - $query = "SELECT scontent FROM %s WHERE sdesc=%d and stype='%s';"; - $query = sprintf($query, sql_table('skin'), (integer) $this->id, sql_real_escape_string($type)); - $res = sql_query($query); - - if ( sql_num_rows($res) == 0 ) - { - return ''; - } - return sql_result($res, 0, 0); - } - - /** - * SKIN::update() - * Updates the contents for one part of the skin in the database - * - * @param string $type type of the skin part (e.g. index, item, search ...) - * @param string $content new content for this skin part - * @return void - * - */ - function update($type, $content) - { - global $manager; - - $query = "SELECT sdesc FROM %s WHERE stype='%s' and sdesc=%d;"; - $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id); - $res = sql_query($query); - - $skintypeexists = sql_fetch_object($res); - $skintypevalue = ($content == true); - - if( $skintypevalue && $skintypeexists ) - { - // PreUpdateSkinPart event - $manager->notify( - 'PreUpdateSkinPart', - array( - 'skinid' => $this->id, - 'type' => $type, - 'content' => &$content - ) - ); - } - else if( $skintypevalue && !$skintypeexists ) - { - // PreAddSkinPart event - $manager->notify( - 'PreAddSkinPart', - array( - 'skinid' => $this->id, - 'type' => $type, - 'content' => &$content - ) - ); - } - else if( !$skintypevalue && $skintypeexists ) - { - // PreDeleteSkinPart event - $manager->notify( - 'PreDeleteSkinPart', - array( - 'skinid' => $this->id, - 'type' => $type - ) - ); - } - - // delete old thingie - $query = "DELETE FROM %s WHERE stype='%s' and sdesc=%d"; - $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id); - sql_query($query); - - // write new thingie - if ( $content ) - { - $query = "INSERT INTO %s (scontent, stype, sdesc) VALUE ('%s', '%s', %d)"; - $query = sprintf($query, sql_table('skin'), sql_real_escape_string($content), sql_real_escape_string($type), (integer) $this->id); - sql_query($query); - } - - if( $skintypevalue && $skintypeexists ) - { - // PostUpdateSkinPart event - $manager->notify( - 'PostUpdateSkinPart', - array( - 'skinid' => $this->id, - 'type' => $type, - 'content' => &$content - ) - ); - } - else if( $skintypevalue && (!$skintypeexists) ) - { - // PostAddSkinPart event - $manager->notify( - 'PostAddSkinPart', - array( - 'skinid' => $this->id, - 'type' => $type, - 'content' => &$content - ) - ); - } - else if( (!$skintypevalue) && $skintypeexists ) - { - // PostDeleteSkinPart event - $manager->notify( - 'PostDeleteSkinPart', - array( - 'skinid' => $this->id, - 'type' => $type - ) - ); - } - return; - } - - /** - * Skin::deleteAllParts() - * Deletes all skin parts from the database - * - * @param void - * @return void - */ - function deleteAllParts() - { - $query = "DELETE FROM %s WHERE sdesc=%d;"; - $query = sprintf($query, sql_table('skin'), (integer) $this->id); - sql_query($query); - } - - /** - * Skin::updateGeneralInfo() - * Updates the general information about the skin - * - * @param string $name name of the skin - * @param string $desc description of the skin - * @param string $type type of the skin - * @param string $includeMode include mode of the skin - * @param string $includePrefix include prefix of the skin - * @return void - */ - function updateGeneralInfo($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') - { - $name = sql_real_escape_string($name); - $desc = sql_real_escape_string($desc); - $type = sql_real_escape_string($type); - $includeMode = sql_real_escape_string($includeMode); - $includePrefix = sql_real_escape_string($includePrefix); - - $query ="UPDATE %s SET sdname='', sddesc='%s', sdtype='%s', sdincmode='%s', sdincpref='%s' WHERE sdnumber=%d:"; - $query = sprintf($query, $name, $desc, $type, $includeMode, $includePrefix, (integer) $this->id); - - sql_query($query); - return; - } - - /** - * Skin::getFriendlyNames() - * Get an array with the names of possible skin parts - * Used to show all possible parts of a skin in the administration backend - * - * @param void - * @param array type of the skin - */ - static public function getFriendlyNames() - { - $skintypes = array( - 'index' => _SKIN_PART_MAIN, - 'item' => _SKIN_PART_ITEM, - 'archivelist' => _SKIN_PART_ALIST, - 'archive' => _SKIN_PART_ARCHIVE, - 'search' => _SKIN_PART_SEARCH, - 'error' => _SKIN_PART_ERROR, - 'member' => _SKIN_PART_MEMBER, - 'imagepopup' => _SKIN_PART_POPUP - ); - - $query = "SELECT stype FROM " . sql_table('skin') - . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member')"; - $res = sql_query($query); - while ( $row = sql_fetch_array($res) ) - { - /* TODO: ucfirst() depends on the current locale */ - $skintypes[strtolower($row['stype'])] = ucfirst($row['stype']); - } - return $skintypes; - } - - /** - * Skin::getAllowedActionsForType() - * Get the allowed actions for a skin type - * returns an array with the allowed actions - * - * @param string $type type of the skin (e.g. index, item, search ...) - * @return array allowed action types - */ - function getAllowedActionsForType($type) - { - global $blogid; - - // some actions that can be performed at any time, from anywhere - $defaultActions = array( - 'otherblog', - 'plugin', - 'version', - 'nucleusbutton', - 'include', - 'phpinclude', - 'parsedinclude', - 'loginform', - 'sitevar', - 'otherarchivelist', - 'otherarchivedaylist', - 'otherarchiveyearlist', - 'self', - 'adminurl', - 'todaylink', - 'archivelink', - 'member', - 'category', - 'searchform', - 'referer', - 'skinname', - 'skinfile', - 'set', - 'if', - 'else', - 'endif', - 'elseif', - 'ifnot', - 'elseifnot', - 'charset', - 'bloglist', - 'addlink', - 'addpopupcode', - 'sticky', - // deprecated (Nucleus v2.0) - /* TODO: remove this */ - 'ifcat' - ); - - // extra actions specific for a certain skin type - $extraActions = array(); - - switch ( $type ) - { - case 'index': - $extraActions = array( - 'blog', - 'blogsetting', - 'preview', - 'additemform', - 'categorylist', - 'archivelist', - 'archivedaylist', - 'archiveyearlist', - 'nextlink', - 'prevlink' - ); - break; - case 'archive': - $extraActions = array( - 'blog', - 'archive', - 'otherarchive', - 'categorylist', - 'archivelist', - 'archivedaylist', - 'archiveyearlist', - 'blogsetting', - 'archivedate', - 'nextarchive', - 'prevarchive', - 'nextlink', - 'prevlink', - 'archivetype' - ); - break; - case 'archivelist': - $extraActions = array( - 'blog', - 'archivelist', - 'archivedaylist', - 'archiveyearlist', - 'categorylist', - 'blogsetting' - ); - break; - case 'search': - $extraActions = array( - 'blog', - 'archivelist', - 'archivedaylist', - 'archiveyearlist', - 'categorylist', - 'searchresults', - 'othersearchresults', - 'blogsetting', - 'query', - 'nextlink', - 'prevlink' - ); - break; - case 'imagepopup': - $extraActions = array( - 'image', - // deprecated (Nucleus v2.0) - /* TODO: remove this */ - 'imagetext' - ); - break; - case 'member': - $extraActions = array( - 'membermailform', - 'blogsetting', - 'nucleusbutton', - 'categorylist' - ); - break; - case 'item': - $extraActions = array( - 'blog', - 'item', - 'comments', - 'commentform', - 'vars', - 'blogsetting', - 'nextitem', - 'previtem', - 'nextlink', - 'prevlink', - 'nextitemtitle', - 'previtemtitle', - 'categorylist', - 'archivelist', - 'archivedaylist', - 'archiveyearlist', - 'itemtitle', - 'itemid', - 'itemlink' - ); - break; - case 'error': - $extraActions = array( - 'errormessage', - 'categorylist' - ); - break; - default: - if ( $blogid && $blogid > 0 ) - { - $extraActions = array( - 'blog', - 'blogsetting', - 'preview', - 'additemform', - 'categorylist', - 'archivelist', - 'archivedaylist', - 'archiveyearlist', - 'nextlink', - 'prevlink', - 'membermailform', - 'nucleusbutton', - 'categorylist' - ); - } - break; - } - return array_merge($defaultActions, $extraActions); - } -} +id = (integer) $id; + + // read skin name/description/content type + $query = "SELECT * FROM %s WHERE sdnumber=%d"; + $query = sprintf($query, sql_table('skin_desc'), (integer) $this->id); + $res = sql_query($query); + $obj = sql_fetch_object($res); + $this->valid = (sql_num_rows($res) > 0); + if ( !$this->valid ) + { + return; + } + + /* + * NOTE: include needed action class + */ + if ( $action_class != 'Actions' ) + { + if ( !class_exists($action_class, FALSE) + && (!file_exists("{$DIR_LIBS}{$action_class}.php") + || !include("{$DIR_LIBS}{$action_class}.php")) ) + { + return; + } + } + else + { + if ( !class_exists('Actions', FALSE) + && (!file_exists("{$DIR_LIBS}ACTIONS.php") + || !include("{$DIR_LIBS}ACTIONS.php")) ) + { + return; + } + } + + $this->action_class = $action_class; + $this->event_identifier = $event_identifier; + + $this->name = $obj->sdname; + $this->description = $obj->sddesc; + $this->contentType = $obj->sdtype; + $this->includeMode = $obj->sdincmode; + $this->includePrefix = $obj->sdincpref; + + return; + } + + /** + * Skin::getID() + * Get SKIN id + * + * @param void + * @return integer id for this skin instance + */ + public function getID() + { + return (integer) $this->id; + } + + /** + * Skin::isValid() + * + * @param void + * @return boolean + */ + public function isValid() + { + return (boolean) $this->valid; + } + + /** + * Skin::getName() + * Get SKIN name + * + * @param void + * @return string name of this skin instance + */ + public function getName() + { + return (string) $this->name; + } + + /** + * Skin::getDescription() + * Get SKIN description + * + * @param void + * @return string description of this skin instance + */ + public function getDescription() + { + return (string) $this->description; + } + + /** + * Skin::getContentType() + * Get SKIN content type + * e.g. text/xml, text/html, application/atom+xml + * + * @param void + * @return string name of this skin instance + */ + public function getContentType() + { + return (string) $this->contentType; + } + + /** + * Skin::getIncludeMode() + * Get include mode of the SKIN + * + * Returns either 'normal' or 'skindir': + * 'normal': if a all data of the skin can be found in the databse + * 'skindir': if the skin has data in the it's skin driectory + * + * @param void + * @return string normal/skindir + */ + public function getIncludeMode() + { + return (string) $this->includeMode; + } + + /** + * Skin::getIncludePrefix() + * Get include prefix of the SKIN + * + * Get name of the subdirectory (with trailing slash) where + * the files of the current skin can be found (e.g. 'default/') + * + * @param void + * @return string include prefix of this skin instance + */ + public function getIncludePrefix() + { + return (string) $this->includePrefix; + } + + /** + * Skin::exists() + * Checks if a skin with a given shortname exists + * + * @static + * @param string $name Skin short name + * @return integer number of skins with the given ID + */ + static public function exists($name) + { + $query = "SELECT COUNT(*) AS result FROM %s WHERE sdname='%s';"; + $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name)); + return (quickQuery($query) > 0); + } + + /** + * Skin::existsID() + * Checks if a skin with a given ID exists + * + * @static + * @param string $id Skin ID + * @return integer number of skins with the given ID + */ + static public function existsID($id) + { + $query = "SELECT COUNT(*) AS result FROM %s WHERE sdnumber=%d;"; + $query = sprintf($query, sql_table('skin_desc'), (integer) $id); + return (quickQuery($query) > 0); + } + + /** + * Skin::createFromName() + * Returns a skin given its shortname + * + * @static + * @param string $name Skin shortname + * @return object instance of Skin class + */ + static public function createFromName($name) + { + return new SKIN(SKIN::getIdFromName($name)); + } + + /** + * Skin::getIdFromName() + * Returns a skin ID given its shortname + * + * @static + * @param string $name Skin shortname + * @return integer Skin ID + */ + static public function getIdFromName($name) + { + $query = "SELECT sdnumber FROM %s WHERE sdname='%s';"; + $query = sprintf($query, sql_table('skin_desc'), sql_real_escape_string($name)); + $res = sql_query($query); + $obj = sql_fetch_object($res); + return $obj->sdnumber; + } + + /** + * Skin::getNameFromId() + * Returns a skin shortname given its ID + * + * @static + * @param string $name + * @return string Skin short name + */ + static public function getNameFromId($id) + { + $query = "SELECT sdname AS result FROM %s WHERE sdnumber=%d;"; + $query = sprintf($query, sql_table('skin_desc'), (integer) $id); + return quickQuery($query); + } + + /** + * SKIN::createNew() + * Creates a new skin, with the given characteristics. + * + * @static + * @param String $name value for nucleus_skin.sdname + * @param String $desc value for nucleus_skin.sddesc + * @param String $type value for nucleus_skin.sdtype + * @param String $includeMode value for nucleus_skin.sdinclude + * @param String $includePrefix value for nucleus_skin.sdincpref + * @return Integer ID for just inserted record + */ + public function createNew($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') + { + global $manager; + + $manager->notify( + 'PreAddSkin', + array( + 'name' => &$name, + 'description' => &$desc, + 'type' => &$type, + 'includeMode' => &$includeMode, + 'includePrefix' => &$includePrefix + ) + ); + + $query = "INSERT INTO %s (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('%s', '%s', '%s', '%s', '%s');"; + $sdname = sql_real_escape_string($name); + $sddesc = sql_real_escape_string($desc); + $sdtype = sql_real_escape_string($type); + $sdincmode = sql_real_escape_string($includeMode); + $sdincpref = sql_real_escape_string($includePrefix); + $query = sprintf($query, sql_table('skin_desc'), $sdname, $sddesc, $sdtype, $sdincmode, $sdincpref); + sql_query($query); + $newid = sql_insert_id(); + + $manager->notify( + 'PostAddSkin', + array( + 'skinid' => $newid, + 'name' => $name, + 'description' => $desc, + 'type' => $type, + 'includeMode' => $includeMode, + 'includePrefix' => $includePrefix + ) + ); + return $newid; + } + + /** + * Skin::parse() + * Parse a SKIN + * + * @param string $type + * @return void + */ + public function parse($type) + { + global $currentSkinName, $manager, $CONF; + + $manager->notify("Init{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type)); + + // set output type + sendContentType($this->getContentType(), 'skin'); + + // set skin name as global var (so plugins can access it) + $currentSkinName = $this->getName(); + $contents = $this->getContent($type); + + if ( !$contents ) + { + // use base skin if this skin does not have contents + $defskin = new SKIN($CONF['BaseSkin']); + $contents = $defskin->getContent($type); + if ( !$contents ) + { + echo _ERROR_SKIN; + return; + } + } + + $actions = $this->getAllowedActionsForType($type); + + $manager->notify("Pre{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type, 'contents' => &$contents)); + + // set IncludeMode properties of parser + Parser::setProperty('IncludeMode', $this->getIncludeMode()); + Parser::setProperty('IncludePrefix', $this->getIncludePrefix()); + + $action_class = $this->action_class; + $handler = new $action_class($type); + + $parser = new Parser($actions, $handler); + $handler->setParser($parser); + $handler->setSkin($this); + $parser->parse($contents); + + $manager->notify("Post{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type)); + return; + } + + /** + * Skin::getContent() + * Get content of the skin part from the database + * + * @param string $type type of the skin (e.g. index, item, search ...) + * @return string content of scontent + */ + public function getContent($type) + { + $query = "SELECT scontent FROM %s WHERE sdesc=%d and stype='%s';"; + $query = sprintf($query, sql_table('skin'), (integer) $this->id, sql_real_escape_string($type)); + $res = sql_query($query); + + if ( sql_num_rows($res) == 0 ) + { + return ''; + } + return sql_result($res, 0, 0); + } + + /** + * SKIN::update() + * Updates the contents for one part of the skin in the database + * + * @param string $type type of the skin part (e.g. index, item, search ...) + * @param string $content new content for this skin part + * @return void + * + */ + public function update($type, $content) + { + global $manager; + + $query = "SELECT sdesc FROM %s WHERE stype='%s' and sdesc=%d;"; + $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id); + $res = sql_query($query); + + $skintypeexists = sql_fetch_object($res); + $skintypevalue = ($content == true); + + if( $skintypevalue && $skintypeexists ) + { + $data = array( + 'skinid' => $this->id, + 'type' => $type, + 'content' => &$content + ); + + // PreUpdateSkinPart event + $manager->notify("PreUpdate{{$this->event_identifier}}Part", $data); + } + else if( $skintypevalue && !$skintypeexists ) + { + $data = array( + 'skinid' => $this->id, + 'type' => $type, + 'content' => &$content + ); + + $manager->notify("PreAdd{$this->event_identifier}Part", $data); + } + else if( !$skintypevalue && $skintypeexists ) + { + $data = array( + 'skinid' => $this->id, + 'type' => $type + ); + + $manager->notify("PreDelete{$this->event_identifier}Part", $data); + } + + // delete old thingie + $query = "DELETE FROM %s WHERE stype='%s' and sdesc=%d"; + $query = sprintf($query, sql_table('skin'), sql_real_escape_string($type), (integer) $this->id); + sql_query($query); + + // write new thingie + if ( $content ) + { + $query = "INSERT INTO %s (scontent, stype, sdesc) VALUE ('%s', '%s', %d)"; + $query = sprintf($query, sql_table('skin'), sql_real_escape_string($content), sql_real_escape_string($type), (integer) $this->id); + sql_query($query); + } + + if( $skintypevalue && $skintypeexists ) + { + $data = array( + 'skinid' => $this->id, + 'type' => $type, + 'content' => &$content + ); + + // PostUpdateSkinPart event + $manager->notify("PostUpdate{$this->event_identifier}Part", $data); + } + else if( $skintypevalue && (!$skintypeexists) ) + { + $data = array( + 'skinid' => $this->id, + 'type' => $type, + 'content' => &$content + ); + + // PostAddSkinPart event + $manager->notify("PostAdd{$this->event_identifier}Part", $data); + } + else if( (!$skintypevalue) && $skintypeexists ) + { + $data = array( + 'skinid' => $this->id, + 'type' => $type + ); + + $manager->notify("PostDelete{$this->event_identifier}Part", $data); + } + return; + } + + /** + * Skin::deleteAllParts() + * Deletes all skin parts from the database + * + * @param void + * @return void + */ + public function deleteAllParts() + { + $query = "DELETE FROM %s WHERE sdesc=%d;"; + $query = sprintf($query, sql_table('skin'), (integer) $this->id); + sql_query($query); + } + + /** + * Skin::updateGeneralInfo() + * Updates the general information about the skin + * + * @param string $name name of the skin + * @param string $desc description of the skin + * @param string $type type of the skin + * @param string $includeMode include mode of the skin + * @param string $includePrefix include prefix of the skin + * @return void + */ + public function updateGeneralInfo($name, $desc, $type = 'text/html', $includeMode = 'normal', $includePrefix = '') + { + $name = sql_real_escape_string($name); + $desc = sql_real_escape_string($desc); + $type = sql_real_escape_string($type); + $includeMode = sql_real_escape_string($includeMode); + $includePrefix = sql_real_escape_string($includePrefix); + + $query ="UPDATE %s SET sdname='', sddesc='%s', sdtype='%s', sdincmode='%s', sdincpref='%s' WHERE sdnumber=%d:"; + $query = sprintf($query, $name, $desc, $type, $includeMode, $includePrefix, (integer) $this->id); + + sql_query($query); + return; + } + + /** + * Skin::getAllowedActionsForType() + * Get the allowed actions for a skin type + * returns an array with the allowed actions + * + * @param string $type type of the skin (e.g. index, item, search ...) + * @return array allowed action types + */ + public function getAllowedActionsForType($type) + { + /** + * NOTE: static method with variable class name is supported since PHP 5.3 + * So now we utilize eval function. + */ + $page_action_names = array(); + eval("\$defined_actions = {$this->action_class}::getDefinedActions('{$type}');"); + return $defined_actions; + } + + /** + * Skin::getFriendlyNames() + * Get an array with the names of possible skin parts + * Used to show all possible parts of a skin in the administration backend + * + * @static + * @param string $action_class name of action class (optional) + * @param array type of the skin + */ + static public function getFriendlyNames($action_class='Actions') + { + global $DIR_LIBS; + + /* + * NOTE: include needed action class + */ + if ( $action_class != 'Actions' ) + { + if ( !class_exists($action_class, FALSE) + && (!file_exists("{$DIR_LIBS}{$action_class}.php") + || !include("{$DIR_LIBS}{$action_class}.php")) ) + { + return; + } + } + else + { + if ( !class_exists('Actions', FALSE) + && (!file_exists("{$DIR_LIBS}ACTIONS.php") + || !include("{$DIR_LIBS}ACTIONS.php")) ) + { + return; + } + } + + /** + * NOTE: static method with variable class name is supported since PHP 5.3 + * So now we utilize eval function. + */ + eval("\$friendly_names = {$action_class}::getSkinTypeFriendlyNames();"); + + $action_names = array(); + foreach ( $friendly_names as $action_name => $friendly_name ) + { + $action_names[] = $action_name; + } + + $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s');"; + $query = sprintf($query, sql_table('skin'), implode("','", $action_names)); + $res = sql_query($query); + + while ( $row = sql_fetch_array($res) ) + { + $friendly_names[strtolower($row['stype'])] = $row['stype']; + } + return $friendly_names; + } +} diff --git a/nucleus/libs/showlist.php b/nucleus/libs/showlist.php index cf51766..fd954ec 100644 --- a/nucleus/libs/showlist.php +++ b/nucleus/libs/showlist.php @@ -1,967 +1,968 @@ -\n"; - - // add extra row if needed - if ( ifset($template['extra']) ) - { - echo '\n"; - } - - break; - case 'BODY': - $current = $template['current']; - - echo '\n"; - break; - case 'FOOT': - echo ''; - break; - } - return; -} - -function listplug_table($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo "\n\n"; - echo "\n"; - echo "\n"; - echo "\n"; - // print head - call_user_func("listplug_table_{$template['content']}" , $template, 'HEAD'); - echo "\n"; - echo "\n"; - echo "\n"; - break; - case 'BODY': - // print tabletype specific thingies - echo "\n"; - call_user_func("listplug_table_{$template['content']}" , $template, 'BODY'); - echo "\n"; - break; - case 'FOOT': - call_user_func("listplug_table_{$template['content']}" , $template, 'FOOT'); - echo "\n"; - echo "
\n"; - echo "\n"; - break; - } - return; -} - -function listplug_table_memberlist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _LIST_MEMBER_NAME . "\n"; - echo '' . _LIST_MEMBER_RNAME . "\n"; - echo '' . _LIST_MEMBER_URL . "\n"; - echo '' . _LIST_MEMBER_ADMIN . "\n"; - help('superadmin'); - echo "\n"; - echo '' . _LIST_MEMBER_LOGIN; - help('canlogin'); - echo "\n"; - echo '' . _LISTS_ACTIONS. "\n"; - break; - case 'BODY': - $current = $template['current']; - echo ''; - $id = listplug_nextBatchId(); - echo "mnumber}\" />\n"; - echo "\n"; - echo ""; - echo "" . Entity::hsc($current->mrealname) . "\n"; - echo '' . Entity::hsc($current->murl) . "\n"; - echo '' . ($current->madmin ? _YES : _NO) . "\n"; - echo '' . ($current->mcanlogin ? _YES : _NO) . "\n"; - echo '' . _LISTS_EDIT . "\n"; - echo '' . _LISTS_DELETE . "\n"; - break; - } - return; -} - -function listplug_table_teamlist($template, $type) -{ - global $manager; - switch( $type ) - { - case 'HEAD': - echo "" . _LIST_MEMBER_NAME . "\n"; - echo "" . _LIST_MEMBER_RNAME . "\n"; - echo "" . _LIST_TEAM_ADMIN . "\n"; - help('teamadmin'); - echo "\n"; - echo ""._LISTS_ACTIONS."\n"; - break; - case 'BODY': - $current = $template['current']; - - echo ''; - $id = listplug_nextBatchId(); - echo "tmember}\" />\n"; - echo '\n"; - echo ""; - echo '', Entity::hsc($current->mrealname), "\n"; - echo '', ($current->tadmin ? _YES : _NO) , "\n"; - echo "tmember&blogid={$current->tblog}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; - - $url = "index.php?action=teamchangeadmin&memberid={$current->tmember}&blogid={$current->tblog}"; - $url = $manager->addTicketToUrl($url); - echo '' . _LIST_TEAM_CHADMIN . "\n"; - break; - } - return; -} - -function listplug_table_pluginlist($template, $type) -{ - global $manager; - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_INFO . "\n"; - echo '' . _LISTS_DESC . "\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $current = $template['current']; - - $plug =& $manager->getPlugin($current->pfile); - if ( $plug ) - { - echo "\n"; - echo '

' . Entity::hsc($plug->getName()) . "

\n"; - - echo "
\n"; - if ( $plug->getAuthor() ) - { - echo '
' . _LIST_PLUGS_AUTHOR . "
\n"; - echo '
' . Entity::hsc($plug->getAuthor()) , "
\n"; - } - - if ( $plug->getVersion() ) - { - echo '
' . _LIST_PLUGS_VER, "
\n"; - echo '
' . Entity::hsc($plug->getVersion()) . "
\n"; - } - - if ( $plug->getURL() ) - { - echo '
' . _LIST_PLUGS_SITE . "
\n"; - echo '
リンク
' . "\n"; - } - echo "
\n"; - echo "\n"; - - echo "\n"; - echo "
\n"; - echo '
' . _LIST_PLUGS_DESC ."
\n"; - echo '
' . Entity::hen($plug->getDescription()) ."
\n"; - if ( sizeof($plug->getEventList()) > 0 ) - { - echo '
' . _LIST_PLUGS_SUBS ."
\n"; - echo '
' . Entity::hsc(implode(', ', $plug->getEventList())) ."
\n"; - } - - if ( sizeof($plug->getPluginDep()) > 0 ) - { - echo '
' . _LIST_PLUGS_DEP ."
\n"; - echo '
' . Entity::hsc(implode(', ', $plug->getPluginDep())) ."
\n"; - } - - /* check dependency */ - $req = array(); - $res = sql_query('SELECT pfile FROM ' . sql_table('plugin')); - while( $o = sql_fetch_object($res) ) - { - $preq =& $manager->getPlugin($o->pfile); - if ( $preq ) - { - $depList = $preq->getPluginDep(); - foreach ( $depList as $depName ) - { - if ( $current->pfile == $depName ) - { - $req[] = $o->pfile; - } - } - } - } - - if ( count($req) > 0 ) - { - echo '
' . _LIST_PLUGS_DEPREQ . "
\n"; - echo '
' . Entity::hsc(implode(', ', $req)) . "
\n"; - } - - /* check the database to see if it is up-to-date and notice the user if not */ - if ( !$plug->subscribtionListIsUptodate() ) - { - echo '
' . 'NOTICE:' . "
\n"; - echo '
' . _LIST_PLUG_SUBS_NEEDUPDATE . "
\n"; - } - - echo "
\n"; - echo "\n"; - } - else - { - echo '' . sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current->pfile)) . "\n"; - } - - echo "\n"; - echo "\n"; - echo "\n"; - break; - } - return; -} - -function listplug_table_plugoptionlist($template, $type) -{ - global $manager; - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_INFO . "\n"; - echo '' . _LISTS_VALUE . "\n"; - break; - case 'BODY': - listplug_plugOptionRow($template['current']); - break; - case 'FOOT': - echo "\n"; - echo '' . _PLUGS_SAVE . "\n"; - echo "\n"; - echo "\n"; - echo "" . _PLUGS_SAVE . "\n"; - echo "\n"; - echo "\n"; - break; - } - return; -} - -function listplug_plugOptionRow($current) -{ - $varname = "plugoption[{$current['oid']}][{$current['contextid']}]"; - - // retreive the optionmeta - $meta = NucleusPlugin::getOptionMeta($current['typeinfo']); - - // only if it is not a hidden option write the controls to the page - if ( in_array('access', $meta) && $meta['access'] == 'hidden' ) - { - return; - } - - if ( !$current['description'] ) - { - echo '' , Entity::hsc($current['name']) . "\n"; - } - else - { - if ( !defined($current['description']) ) - { - echo '' , Entity::hsc($current['description']) . "\n"; - } - else - { - echo '' , Entity::hsc(constant($current['description'])) . "\n"; - } - } - echo "\n"; - switch($current['type']) - { - case 'yesno': - Admin::input_yesno($varname, $current['value'], 0, 'yes', 'no'); - break; - case 'password': - echo '\n"; - break; - case 'select': - echo '\n"; - - break; - case 'textarea': - //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']); - if ( array_key_exists('access', $meta) && $meta['access'] == 'readonly' ) - { - echo '\n"; - break; - case 'text': - default: - //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']); - echo '\n"; - } - if ( array_key_exists('extra', $current) ) - { - echo $current['extra']; - } - echo "\n"; - - return; -} - -function listplug_table_itemlist($template, $type) -{ - $cssclass = ''; - - switch( $type ) - { - case 'HEAD': - echo ""._LIST_ITEM_INFO."\n"; - echo ""._LIST_ITEM_CONTENT."\n"; - echo ""._LISTS_ACTIONS.""; - break; - case 'BODY': - $current = $template['current']; - // string -> unix timestamp - $current->itime = strtotime($current->itime); - - if ( $current->idraft == 1 ) - { - $cssclass = " class='draft'"; - } - - // (can't use offset time since offsets might vary between blogs) - if ( $current->itime > $template['now'] ) - { - $cssclass = " class='future'"; - } - - echo "\n"; - echo "
\n"; - echo '
' . _LIST_ITEM_BLOG . "
\n"; - echo '
' . Entity::hsc($current->bshortname) . "
\n"; - echo '
' . _LIST_ITEM_CAT . "
\n"; - echo '
' . Entity::hsc($current->cname) . "
\n"; - echo '
' . _LIST_ITEM_AUTHOR . "
\n"; - echo '
' . Entity::hsc($current->mname) . "
\n"; - echo '
' . _LIST_ITEM_DATE . "
\n"; - echo '
' . date("Y-m-d",$current->itime) . "
\n"; - echo '
' . _LIST_ITEM_TIME . "
\n"; - echo '
' . date("H:i",$current->itime) . "
\n"; - echo "
\n"; - echo "\n"; - - $id = listplug_nextBatchId(); - - echo "\n"; - echo "

\n"; - echo "inumber}\" />\n"; - echo "\n"; - echo "

\n"; - - $current->ibody = strip_tags($current->ibody); - $current->ibody = Entity::hsc(Entity::shorten($current->ibody, 300, '...')); - echo "

$current->ibody

\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - break; - } - return; -} - -// for batch operations: generates the index numbers for checkboxes -function listplug_nextBatchId() -{ - static $id = 0; - return $id++; -} - -function listplug_table_commentlist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_INFO . "\n"; - echo '' . _LIST_COMMENT . "\n"; - echo '' . _LISTS_ACTIONS . ""; - break; - case 'BODY': - $current = $template['current']; - $current->ctime = strtotime($current->ctime); // string -> unix timestamp - - echo "\n"; - echo "
    \n"; - echo '
  • ' . date("Y-m-d@H:i",$current->ctime) . "
  • \n"; - if ( isset($current->mname) ) - { - echo '
  • ' . Entity::hsc($current->mname) ,' ', _LIST_COMMENTS_MEMBER . "
  • \n"; - } - else - { - echo '
  • ' . Entity::hsc($current->cuser) . "
  • \n"; - } - if ( isset($current->cmail) && $current->cmail ) - { - echo '
  • ' . Entity::hsc($current->cmail) . "
  • \n"; - } - if ( isset($current->cemail) && $current->cemail ) - { - echo '
  • ' . Entity::hsc($current->cemail) . "
  • \n"; - } - echo "
\n"; - echo "\n"; - - $id = listplug_nextBatchId(); - - echo ''; - echo "cnumber}\" />\n"; - echo "'; - echo ''; - - echo '' . _LISTS_EDIT . "\n"; - echo '' . _LISTS_DELETE . "\n"; - if ( $template['canAddBan'] ) - { - echo '' . _LIST_COMMENT_BANIP . "\n"; - } - break; - } - return; -} - -function listplug_table_bloglist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _NAME . "\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->bname = Entity::hsc($current->bname); - - echo "bnumber} shortname:{$current->bshortname}\">burl}\">\"".{$current->bname}\n"; - echo "bnumber}\" title=\"" . _BLOGLIST_TT_ADD ."\">" . _BLOGLIST_ADD . "\n"; - echo "bnumber}\" title=\"". _BLOGLIST_TT_EDIT."\">". _BLOGLIST_EDIT."\n"; - echo "bnumber}\" title=\"". _BLOGLIST_TT_COMMENTS."\">". _BLOGLIST_COMMENTS."\n"; - echo "bnumber}\" title=\"". _BLOGLIST_TT_BMLET."\">". _BLOGLIST_BMLET . "\n"; - - if ( $current->tadmin == 1 ) - { - echo "bnumber}\" title=\"" . _BLOGLIST_TT_SETTINGS . "\">" . _BLOGLIST_SETTINGS . "\n"; - echo "bnumber}\" title=\"" . _BLOGLIST_TT_BANS . "\">" . _BLOGLIST_BANS . "\n"; - } - - if ( $template['superadmin'] ) - { - echo "bnumber}\" title=\"". _BLOGLIST_TT_DELETE."\">" ._BLOGLIST_DELETE. "\n"; - } - break; - } - return; -} - -function listplug_table_shortblognames($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _EBLOG_SHORTNAME . "\n"; - echo '' . _EBLOG_NAME. ""; - break; - case 'BODY': - $current = $template['current']; - $current->bshortname = Entity::hsc($current->bshortname); - $current->bname = Entity::hsc($current->bname); - - echo "{$current->bshortname}\n"; - echo "{$current->bname}\n"; - break; - } - return; -} - -function listplug_table_shortnames($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _NAME . "\n"; - echo '' . _LISTS_DESC. "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->name = Entity::hsc($current->name); - $current->description = Entity::hsc($current->description); - - echo "{$current->name}\n"; - echo "{$current->description}\n"; - break; - } - return; -} - - -function listplug_table_categorylist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_NAME . ""; - echo '' . _LISTS_DESC."\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $id = listplug_nextBatchId(); - - $current = $template['current']; - $current->cname = Entity::hsc($current->cname); - $current->cdesc = Entity::hsc($current->cdesc); - - echo "\n"; - echo "catid}\" />\n"; - echo "\n"; - echo "\n"; - echo "{$current->cdesc}\n"; - echo "cblog}&catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "\n"; - echo "cblog}&catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; - break; - } - return; -} - -function listplug_table_templatelist($template, $type) -{ - global $manager; - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_NAME . "\n"; - echo '' . _LISTS_DESC . "\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->tdnumber = (integer) $current->tdnumber; - $current->tdname = Entity::hsc($current->tdname); - $current->tddesc = Entity::hsc($current->tddesc); - - $url = "index.php?action=templateclone&templateid={$current->tdnumber}"; - $url = Entity::hsc($manager->addTicketToUrl($url)); - - echo "{$current->tdname}\n"; - echo "{$current->tddesc}\n"; - echo "\n"; - echo "tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "\n"; - echo "\n"; - echo "\n"; - echo "" . _LISTS_CLONE . "\n"; - echo "\n"; - echo "\n"; - echo "tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; - echo "\n"; - break; - } - return; -} - -function listplug_table_skinlist($template, $type) -{ - global $CONF, $DIR_SKINS, $manager; - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_NAME . "\n"; - echo '' . _LISTS_DESC . "\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->sdnumber = (integer) $current->sdnumber; - $current->sdname = Entity::hsc($current->sdname); - $current->sdtype = Entity::hsc($current->sdtype); - - echo "\n"; - - // use a special style for the default skin - if ( $current->sdnumber == $CONF['BaseSkin'] ) - { - echo '

' . $current->sdname . "

\n"; - } - else - { - echo '

' . $current->sdname . "

\n"; - } - - echo "
\n"; - echo '
' . _LISTS_TYPE . "
\n"; - echo '
' . $current->sdtype . "
\n"; - - echo '
' . _LIST_SKINS_INCMODE . "
\n"; - - if ( $current->sdincmode == 'skindir' ) - { - echo '
' . _PARSER_INCMODE_SKINDIR . "
\n"; - } - else - { - echo '
' . _PARSER_INCMODE_NORMAL . "
\n"; - } - - if ( $current->sdincpref ) - { - echo '
' . _LIST_SKINS_INCPREFIX . "
\n"; - echo '
' . Entity::hsc($current->sdincpref) . "
\n"; - } - echo "
\n"; - - // add preview image when present - if ( $current->sdincpref && @file_exists("{$DIR_SKINS}{$current->sdincpref}preview.png") ) - { - echo "

\n"; - - $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current->sdname); - $has_enlargement = @file_exists($DIR_SKINS . $current->sdincpref . 'preview-large.png'); - if ( $has_enlargement ) - { - echo '\n"; - echo '' . $alternatve_text . \n"; - echo "
\n"; - } - else - { - echo '' . $alternatve_text .
\n"; - } - - if ( @file_exists("{$DIR_SKINS}{$current->sdincpref}readme.html") ) - { - $url = $CONF['SkinsURL'] . Entity::hsc($current->sdincpref) . 'readme.html'; - $title = sprintf(_LIST_SKIN_README, $current->sdname); - echo "" . _LIST_SKIN_README_TXT . "\n"; - } - - echo "

\n"; - } - - echo "\n"; - - echo "\n"; - echo '

' . Entity::hsc($current->sddesc) . "

\n"; - - /* show list of defined parts */ - $query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype"; - $query = sprintf($query, sql_table('skin'), $current->sdnumber); - $r = sql_query($query); - - $types = array(); - while ( $o = sql_fetch_object($r) ) - { - array_push($types, $o->stype); - } - if ( sizeof($types) > 0 ) - { - $friendlyNames = SKIN::getFriendlyNames(); - for ( $i = 0; $i < sizeof($types); $i++ ) - { - $type = $types[$i]; - if ( !in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup')) ) - { - $article = 'skinpartspecial'; - } - else - { - $article = "skinpart{$type}"; - } - $types[$i] = "
  • \n"; - $types[$i] .= helpHtml($article) . "\n"; - $types[$i] .= "sdnumber}&type={$type}\" tabindex=\"{$template['tabindex']}\">" . Entity::hsc($friendlyNames[$type]) . "\n"; - $types[$i] .= "
  • \n"; - } - echo _LIST_SKINS_DEFINED; - echo '
      ' . implode('', $types) . "
    \n"; - } - echo ""; - echo "\n"; - echo "sdnumber}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "\n"; - echo "\n"; - - $url = "index.php?action=skinclone&skinid={$current->sdnumber}"; - $url = Entity::hsc($manager->addTicketToUrl($url)); - echo "\n"; - echo "" . _LISTS_CLONE . "\n"; - echo "\n"; - echo "\n"; - echo "sdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; - break; - } - return; -} - -function listplug_table_draftlist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_BLOG . "\n"; - echo '' . _LISTS_TITLE . "\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->bshortname = Entity::hsc($current->bshortname); - $current->ititle = Entity::hsc(strip_tags($current->ititle)); - - echo "{$current->bshortname}\n"; - echo "{$current->ititle}\n"; - echo "inumber}\">" . _LISTS_EDIT . "\n"; - echo "inumber}\">" . _LISTS_DELETE . "\n"; - break; - } - return; -} - -function listplug_table_otherdraftlist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_BLOG . "\n"; - echo '' . _LISTS_TITLE . "\n"; - echo '' . _LISTS_AUTHOR . "\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->bshortname = Entity::hsc($current->bshortname); - $current->ititle = Entity::hsc(strip_tags($current->ititle)); - $current->mname = Entity::hsc($current->mname); - - echo "{$current->bshortname}\n"; - echo "{$current->ititle}\n"; - echo "{$current->mname}\n"; - echo "inumber}\">" . _LISTS_EDIT . "\n"; - echo "inumber}\">" . _LISTS_DELETE . "\n"; - break; - } - return; -} - -function listplug_table_actionlist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _LISTS_TIME . "\n"; - echo '' . _LIST_ACTION_MSG . "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->timestamp = Entity::hsc($current->timestamp); - $current->message = Entity::hsc($current->message); - - echo "{$current->timestamp}\n"; - echo "{$current->message}\n"; - break; - } - return; -} - -function listplug_table_banlist($template, $type) -{ - switch( $type ) - { - case 'HEAD': - echo '' . _LIST_BAN_IPRANGE . "\n"; - echo '' . _LIST_BAN_REASON."\n"; - echo '' . _LISTS_ACTIONS . "\n"; - break; - case 'BODY': - $current = $template['current']; - $current->blogid = (integer) $current->blogid; - $current->iprange = Entity::hsc($current->iprange); - $current->reason = Entity::hsc($current->reason); - - echo "{$current->iprange}\n"; - echo "{$current->reason}\n"; - echo "blogid}&iprange=\"Entity::hsc($current->iprange}\">" . _LISTS_DELETE . "\n"; - break; - } - return; -} +\n"; + + // add extra row if needed + if ( ifset($template['extra']) ) + { + echo '\n"; + } + + break; + case 'BODY': + $current = $template['current']; + + echo '\n"; + break; + case 'FOOT': + echo ''; + break; + } + return; +} + +function listplug_table($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo "\n\n"; + echo "\n"; + echo "\n"; + echo "\n"; + // print head + call_user_func("listplug_table_{$template['content']}" , $template, 'HEAD'); + echo "\n"; + echo "\n"; + echo "\n"; + break; + case 'BODY': + // print tabletype specific thingies + echo "\n"; + call_user_func("listplug_table_{$template['content']}" , $template, 'BODY'); + echo "\n"; + break; + case 'FOOT': + call_user_func("listplug_table_{$template['content']}" , $template, 'FOOT'); + echo "\n"; + echo "
    \n"; + echo "\n"; + break; + } + return; +} + +function listplug_table_memberlist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _LIST_MEMBER_NAME . "\n"; + echo '' . _LIST_MEMBER_RNAME . "\n"; + echo '' . _LIST_MEMBER_URL . "\n"; + echo '' . _LIST_MEMBER_ADMIN . "\n"; + help('superadmin'); + echo "\n"; + echo '' . _LIST_MEMBER_LOGIN; + help('canlogin'); + echo "\n"; + echo '' . _LISTS_ACTIONS. "\n"; + break; + case 'BODY': + $current = $template['current']; + echo ''; + $id = listplug_nextBatchId(); + echo "mnumber}\" />\n"; + echo "\n"; + echo ""; + echo "" . Entity::hsc($current->mrealname) . "\n"; + echo '' . Entity::hsc($current->murl) . "\n"; + echo '' . ($current->madmin ? _YES : _NO) . "\n"; + echo '' . ($current->mcanlogin ? _YES : _NO) . "\n"; + echo '' . _LISTS_EDIT . "\n"; + echo '' . _LISTS_DELETE . "\n"; + break; + } + return; +} + +function listplug_table_teamlist($template, $type) +{ + global $manager; + switch( $type ) + { + case 'HEAD': + echo "" . _LIST_MEMBER_NAME . "\n"; + echo "" . _LIST_MEMBER_RNAME . "\n"; + echo "" . _LIST_TEAM_ADMIN . "\n"; + help('teamadmin'); + echo "\n"; + echo ""._LISTS_ACTIONS."\n"; + break; + case 'BODY': + $current = $template['current']; + + echo ''; + $id = listplug_nextBatchId(); + echo "tmember}\" />\n"; + echo '\n"; + echo ""; + echo '', Entity::hsc($current->mrealname), "\n"; + echo '', ($current->tadmin ? _YES : _NO) , "\n"; + echo "tmember&blogid={$current->tblog}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; + + $url = "index.php?action=teamchangeadmin&memberid={$current->tmember}&blogid={$current->tblog}"; + $url = $manager->addTicketToUrl($url); + echo '' . _LIST_TEAM_CHADMIN . "\n"; + break; + } + return; +} + +function listplug_table_pluginlist($template, $type) +{ + global $manager; + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_INFO . "\n"; + echo '' . _LISTS_DESC . "\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $current = $template['current']; + + $plug =& $manager->getPlugin($current->pfile); + if ( $plug ) + { + echo "\n"; + echo '

    ' . Entity::hsc($plug->getName()) . "

    \n"; + + echo "
    \n"; + if ( $plug->getAuthor() ) + { + echo '
    ' . _LIST_PLUGS_AUTHOR . "
    \n"; + echo '
    ' . Entity::hsc($plug->getAuthor()) , "
    \n"; + } + + if ( $plug->getVersion() ) + { + echo '
    ' . _LIST_PLUGS_VER, "
    \n"; + echo '
    ' . Entity::hsc($plug->getVersion()) . "
    \n"; + } + + if ( $plug->getURL() ) + { + echo '
    ' . _LIST_PLUGS_SITE . "
    \n"; + echo '
    リンク
    ' . "\n"; + } + echo "
    \n"; + echo "\n"; + + echo "\n"; + echo "
    \n"; + echo '
    ' . _LIST_PLUGS_DESC ."
    \n"; + echo '
    ' . Entity::hen($plug->getDescription()) ."
    \n"; + if ( sizeof($plug->getEventList()) > 0 ) + { + echo '
    ' . _LIST_PLUGS_SUBS ."
    \n"; + echo '
    ' . Entity::hsc(implode(', ', $plug->getEventList())) ."
    \n"; + } + + if ( sizeof($plug->getPluginDep()) > 0 ) + { + echo '
    ' . _LIST_PLUGS_DEP ."
    \n"; + echo '
    ' . Entity::hsc(implode(', ', $plug->getPluginDep())) ."
    \n"; + } + + /* check dependency */ + $req = array(); + $res = sql_query('SELECT pfile FROM ' . sql_table('plugin')); + while( $o = sql_fetch_object($res) ) + { + $preq =& $manager->getPlugin($o->pfile); + if ( $preq ) + { + $depList = $preq->getPluginDep(); + foreach ( $depList as $depName ) + { + if ( $current->pfile == $depName ) + { + $req[] = $o->pfile; + } + } + } + } + + if ( count($req) > 0 ) + { + echo '
    ' . _LIST_PLUGS_DEPREQ . "
    \n"; + echo '
    ' . Entity::hsc(implode(', ', $req)) . "
    \n"; + } + + /* check the database to see if it is up-to-date and notice the user if not */ + if ( !$plug->subscribtionListIsUptodate() ) + { + echo '
    ' . 'NOTICE:' . "
    \n"; + echo '
    ' . _LIST_PLUG_SUBS_NEEDUPDATE . "
    \n"; + } + + echo "
    \n"; + echo "\n"; + } + else + { + echo '' . sprintf(_PLUGINFILE_COULDNT_BELOADED, Entity::hsc($current->pfile)) . "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + break; + } + return; +} + +function listplug_table_plugoptionlist($template, $type) +{ + global $manager; + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_INFO . "\n"; + echo '' . _LISTS_VALUE . "\n"; + break; + case 'BODY': + listplug_plugOptionRow($template['current']); + break; + case 'FOOT': + echo "\n"; + echo '' . _PLUGS_SAVE . "\n"; + echo "\n"; + echo "\n"; + echo "" . _PLUGS_SAVE . "\n"; + echo "\n"; + echo "\n"; + break; + } + return; +} + +function listplug_plugOptionRow($current) +{ + $varname = "plugoption[{$current['oid']}][{$current['contextid']}]"; + + // retreive the optionmeta + $meta = NucleusPlugin::getOptionMeta($current['typeinfo']); + + // only if it is not a hidden option write the controls to the page + if ( in_array('access', $meta) && $meta['access'] == 'hidden' ) + { + return; + } + + if ( !$current['description'] ) + { + echo '' , Entity::hsc($current['name']) . "\n"; + } + else + { + if ( !defined($current['description']) ) + { + echo '' , Entity::hsc($current['description']) . "\n"; + } + else + { + echo '' , Entity::hsc(constant($current['description'])) . "\n"; + } + } + echo "\n"; + switch($current['type']) + { + case 'yesno': + Admin::input_yesno($varname, $current['value'], 0, 'yes', 'no'); + break; + case 'password': + echo '\n"; + break; + case 'select': + echo '\n"; + + break; + case 'textarea': + //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']); + if ( array_key_exists('access', $meta) && $meta['access'] == 'readonly' ) + { + echo '\n"; + break; + case 'text': + default: + //$meta = NucleusPlugin::getOptionMeta($current['typeinfo']); + echo '\n"; + } + if ( array_key_exists('extra', $current) ) + { + echo $current['extra']; + } + echo "\n"; + + return; +} + +function listplug_table_itemlist($template, $type) +{ + $cssclass = ''; + + switch( $type ) + { + case 'HEAD': + echo ""._LIST_ITEM_INFO."\n"; + echo ""._LIST_ITEM_CONTENT."\n"; + echo ""._LISTS_ACTIONS.""; + break; + case 'BODY': + $current = $template['current']; + // string -> unix timestamp + $current->itime = strtotime($current->itime); + + if ( $current->idraft == 1 ) + { + $cssclass = " class='draft'"; + } + + // (can't use offset time since offsets might vary between blogs) + if ( $current->itime > $template['now'] ) + { + $cssclass = " class='future'"; + } + + echo "\n"; + echo "
    \n"; + echo '
    ' . _LIST_ITEM_BLOG . "
    \n"; + echo '
    ' . Entity::hsc($current->bshortname) . "
    \n"; + echo '
    ' . _LIST_ITEM_CAT . "
    \n"; + echo '
    ' . Entity::hsc($current->cname) . "
    \n"; + echo '
    ' . _LIST_ITEM_AUTHOR . "
    \n"; + echo '
    ' . Entity::hsc($current->mname) . "
    \n"; + echo '
    ' . _LIST_ITEM_DATE . "
    \n"; + echo '
    ' . date("Y-m-d",$current->itime) . "
    \n"; + echo '
    ' . _LIST_ITEM_TIME . "
    \n"; + echo '
    ' . date("H:i",$current->itime) . "
    \n"; + echo "
    \n"; + echo "\n"; + + $id = listplug_nextBatchId(); + + echo "\n"; + echo "

    \n"; + echo "inumber}\" />\n"; + echo "\n"; + echo "

    \n"; + + $current->ibody = strip_tags($current->ibody); + $current->ibody = Entity::hsc(Entity::shorten($current->ibody, 300, '...')); + echo "

    $current->ibody

    \n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + break; + } + return; +} + +// for batch operations: generates the index numbers for checkboxes +function listplug_nextBatchId() +{ + static $id = 0; + return $id++; +} + +function listplug_table_commentlist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_INFO . "\n"; + echo '' . _LIST_COMMENT . "\n"; + echo '' . _LISTS_ACTIONS . ""; + break; + case 'BODY': + $current = $template['current']; + $current->ctime = strtotime($current->ctime); // string -> unix timestamp + + echo "\n"; + echo "
      \n"; + echo '
    • ' . date("Y-m-d@H:i",$current->ctime) . "
    • \n"; + if ( isset($current->mname) ) + { + echo '
    • ' . Entity::hsc($current->mname) ,' ', _LIST_COMMENTS_MEMBER . "
    • \n"; + } + else + { + echo '
    • ' . Entity::hsc($current->cuser) . "
    • \n"; + } + if ( isset($current->cmail) && $current->cmail ) + { + echo '
    • ' . Entity::hsc($current->cmail) . "
    • \n"; + } + if ( isset($current->cemail) && $current->cemail ) + { + echo '
    • ' . Entity::hsc($current->cemail) . "
    • \n"; + } + echo "
    \n"; + echo "\n"; + + $id = listplug_nextBatchId(); + + echo ''; + echo "cnumber}\" />\n"; + echo "'; + echo ''; + + echo '' . _LISTS_EDIT . "\n"; + echo '' . _LISTS_DELETE . "\n"; + if ( $template['canAddBan'] ) + { + echo '' . _LIST_COMMENT_BANIP . "\n"; + } + break; + } + return; +} + +function listplug_table_bloglist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _NAME . "\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->bname = Entity::hsc($current->bname); + + echo "bnumber} shortname:{$current->bshortname}\">burl}\">\"".{$current->bname}\n"; + echo "bnumber}\" title=\"" . _BLOGLIST_TT_ADD ."\">" . _BLOGLIST_ADD . "\n"; + echo "bnumber}\" title=\"". _BLOGLIST_TT_EDIT."\">". _BLOGLIST_EDIT."\n"; + echo "bnumber}\" title=\"". _BLOGLIST_TT_COMMENTS."\">". _BLOGLIST_COMMENTS."\n"; + echo "bnumber}\" title=\"". _BLOGLIST_TT_BMLET."\">". _BLOGLIST_BMLET . "\n"; + + if ( $current->tadmin == 1 ) + { + echo "bnumber}\" title=\"" . _BLOGLIST_TT_SETTINGS . "\">" . _BLOGLIST_SETTINGS . "\n"; + echo "bnumber}\" title=\"" . _BLOGLIST_TT_BANS . "\">" . _BLOGLIST_BANS . "\n"; + } + + if ( $template['superadmin'] ) + { + echo "bnumber}\" title=\"". _BLOGLIST_TT_DELETE."\">" ._BLOGLIST_DELETE. "\n"; + } + break; + } + return; +} + +function listplug_table_shortblognames($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _EBLOG_SHORTNAME . "\n"; + echo '' . _EBLOG_NAME. ""; + break; + case 'BODY': + $current = $template['current']; + $current->bshortname = Entity::hsc($current->bshortname); + $current->bname = Entity::hsc($current->bname); + + echo "{$current->bshortname}\n"; + echo "{$current->bname}\n"; + break; + } + return; +} + +function listplug_table_shortnames($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _NAME . "\n"; + echo '' . _LISTS_DESC. "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->name = Entity::hsc($current->name); + $current->description = Entity::hsc($current->description); + + echo "{$current->name}\n"; + echo "{$current->description}\n"; + break; + } + return; +} + + +function listplug_table_categorylist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_NAME . ""; + echo '' . _LISTS_DESC."\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $id = listplug_nextBatchId(); + + $current = $template['current']; + $current->cname = Entity::hsc($current->cname); + $current->cdesc = Entity::hsc($current->cdesc); + + echo "\n"; + echo "catid}\" />\n"; + echo "\n"; + echo "\n"; + echo "{$current->cdesc}\n"; + echo "cblog}&catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "\n"; + echo "cblog}&catid={$current->catid}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; + break; + } + return; +} + +function listplug_table_templatelist($template, $type) +{ + global $manager; + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_NAME . "\n"; + echo '' . _LISTS_DESC . "\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->tdnumber = (integer) $current->tdnumber; + $current->tdname = Entity::hsc($current->tdname); + $current->tddesc = Entity::hsc($current->tddesc); + + $url = "index.php?action=templateclone&templateid={$current->tdnumber}"; + $url = Entity::hsc($manager->addTicketToUrl($url)); + + echo "{$current->tdname}\n"; + echo "{$current->tddesc}\n"; + echo "\n"; + echo "tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_EDIT . "\n"; + echo "\n"; + echo "\n"; + echo "" . _LISTS_CLONE . "\n"; + echo "\n"; + echo "\n"; + echo "tdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; + echo "\n"; + break; + } + return; +} + +function listplug_table_skinlist($template, $type) +{ + global $CONF, $DIR_SKINS, $manager; + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_NAME . "\n"; + echo '' . _LISTS_DESC . "\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->sdnumber = (integer) $current->sdnumber; + $current->sdname = Entity::hsc($current->sdname); + $current->sdtype = Entity::hsc($current->sdtype); + + echo "\n"; + + // use a special style for the default skin + if ( $current->sdnumber == $CONF['BaseSkin'] ) + { + echo '

    ' . $current->sdname . "

    \n"; + } + else + { + echo '

    ' . $current->sdname . "

    \n"; + } + + echo "
    \n"; + echo '
    ' . _LISTS_TYPE . "
    \n"; + echo '
    ' . $current->sdtype . "
    \n"; + + echo '
    ' . _LIST_SKINS_INCMODE . "
    \n"; + + if ( $current->sdincmode == 'skindir' ) + { + echo '
    ' . _PARSER_INCMODE_SKINDIR . "
    \n"; + } + else + { + echo '
    ' . _PARSER_INCMODE_NORMAL . "
    \n"; + } + + if ( $current->sdincpref ) + { + echo '
    ' . _LIST_SKINS_INCPREFIX . "
    \n"; + echo '
    ' . Entity::hsc($current->sdincpref) . "
    \n"; + } + echo "
    \n"; + + // add preview image when present + if ( $current->sdincpref && @file_exists("{$DIR_SKINS}{$current->sdincpref}preview.png") ) + { + echo "

    \n"; + + $alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current->sdname); + $has_enlargement = @file_exists($DIR_SKINS . $current->sdincpref . 'preview-large.png'); + if ( $has_enlargement ) + { + echo '\n"; + echo '' . $alternatve_text . \n"; + echo "
    \n"; + } + else + { + echo '' . $alternatve_text .
    \n"; + } + + if ( @file_exists("{$DIR_SKINS}{$current->sdincpref}readme.html") ) + { + $url = $CONF['SkinsURL'] . Entity::hsc($current->sdincpref) . 'readme.html'; + $title = sprintf(_LIST_SKIN_README, $current->sdname); + echo "" . _LIST_SKIN_README_TXT . "\n"; + } + + echo "

    \n"; + } + + echo "\n"; + + echo "\n"; + echo '

    ' . Entity::hsc($current->sddesc) . "

    \n"; + + /* show list of defined parts */ + $query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype"; + $query = sprintf($query, sql_table('skin'), $current->sdnumber); + $r = sql_query($query); + + $types = array(); + while ( $o = sql_fetch_object($r) ) + { + array_push($types, $o->stype); + } + if ( sizeof($types) > 0 ) + { + for ( $i = 0; $i < sizeof($types); $i++ ) + { + $type = $types[$i]; + if ( !array_key_exists($type, $template['friendly_names']) || $type == strtolower($template['friendly_names'][$type]) ) + { + $article = 'skinpartspecial'; + } + else + { + $article = "skinpart{$type}"; + } + $types[$i] = "
  • \n" + . helpHtml($article) . "\n" + . "sdnumber}&type={$type}\" tabindex=\"{$template['tabindex']}\">" + . Entity::hsc($template['friendly_names'][$type]) + . "\n" + . "
  • \n"; + } + echo _LIST_SKINS_DEFINED; + echo '
      ' . implode('', $types) . "
    \n"; + } + echo ""; + echo "\n"; + echo "sdnumber}\n tabindex=\n{$template['tabindex']}>" . _LISTS_EDIT . "\n"; + echo "\n"; + + $url = "index.php?action=skinclone&skinid={$current->sdnumber}"; + $url = Entity::hsc($manager->addTicketToUrl($url)); + echo "\n"; + echo "" . _LISTS_CLONE . "\n"; + echo "\n"; + echo "\n"; + echo "sdnumber}\" tabindex=\"{$template['tabindex']}\">" . _LISTS_DELETE . "\n"; + break; + } + return; +} + +function listplug_table_draftlist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_BLOG . "\n"; + echo '' . _LISTS_TITLE . "\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->bshortname = Entity::hsc($current->bshortname); + $current->ititle = Entity::hsc(strip_tags($current->ititle)); + + echo "{$current->bshortname}\n"; + echo "{$current->ititle}\n"; + echo "inumber}\">" . _LISTS_EDIT . "\n"; + echo "inumber}\">" . _LISTS_DELETE . "\n"; + break; + } + return; +} + +function listplug_table_otherdraftlist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_BLOG . "\n"; + echo '' . _LISTS_TITLE . "\n"; + echo '' . _LISTS_AUTHOR . "\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->bshortname = Entity::hsc($current->bshortname); + $current->ititle = Entity::hsc(strip_tags($current->ititle)); + $current->mname = Entity::hsc($current->mname); + + echo "{$current->bshortname}\n"; + echo "{$current->ititle}\n"; + echo "{$current->mname}\n"; + echo "inumber}\">" . _LISTS_EDIT . "\n"; + echo "inumber}\">" . _LISTS_DELETE . "\n"; + break; + } + return; +} + +function listplug_table_actionlist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _LISTS_TIME . "\n"; + echo '' . _LIST_ACTION_MSG . "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->timestamp = Entity::hsc($current->timestamp); + $current->message = Entity::hsc($current->message); + + echo "{$current->timestamp}\n"; + echo "{$current->message}\n"; + break; + } + return; +} + +function listplug_table_banlist($template, $type) +{ + switch( $type ) + { + case 'HEAD': + echo '' . _LIST_BAN_IPRANGE . "\n"; + echo '' . _LIST_BAN_REASON."\n"; + echo '' . _LISTS_ACTIONS . "\n"; + break; + case 'BODY': + $current = $template['current']; + $current->blogid = (integer) $current->blogid; + $current->iprange = Entity::hsc($current->iprange); + $current->reason = Entity::hsc($current->reason); + + echo "{$current->iprange}\n"; + echo "{$current->reason}\n"; + echo "blogid}&iprange=\"Entity::hsc($current->iprange}\">" . _LISTS_DELETE . "\n"; + break; + } + return; +}