X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=nucleus%2Flibs%2FACTIONS.php;h=243c06c331322f3b806fef4cf139647fae482289;hb=9f3adaabc9ce98a491836b8b4de4a88c6c748e26;hp=c7c354dc1088269b0f6455f36b129e2e876a192d;hpb=e6b2f97b05858937e0cea32b6c728fc9437ee697;p=nucleus-jp%2Fnucleus-next.git diff --git a/nucleus/libs/ACTIONS.php b/nucleus/libs/ACTIONS.php index c7c354d..243c06c 100644 --- a/nucleus/libs/ACTIONS.php +++ b/nucleus/libs/ACTIONS.php @@ -13,84 +13,66 @@ * This class contains the functions that get called by using * the special tags in the skins * - * The allowed tags for a type of skinpart are defined by the - * Skin::getAllowedActionsForType($type) method - * * @license http://nucleuscms.org/license.txt GNU General Public License * @copyright Copyright (C) 2002-2012 The Nucleus Group - * @version $Id: ACTIONS.php 1725 2012-04-07 02:21:32Z sakamocchi $ + * @version $Id: ACTIONS.php 1784 2012-04-22 04:28:30Z sakamocchi $ */ class Actions extends BaseActions { // part of the skin currently being parsed ('index', 'item', 'archive', // 'archivelist', 'member', 'search', 'error', 'imagepopup') - var $skintype; + private $skintype; // contains an assoc array with parameters that need to be included when // generating links to items/archives/... (e.g. catid) - var $linkparams; - - // reference to the skin object for which a part is being parsed - var $skin; + private $linkparams; // used when including templated forms from the include/ dir. The $formdata var // contains the values to fill out in there (assoc array name -> value) - var $formdata; + private $formdata; // filled out with the number of displayed items after calling one of the // (other)blog/(other)searchresults skinvars. - var $amountfound; + private $amountfound; /** - * AdminActions::$page_action_names + * Actions::$default_actions * list of whole action names with which this class can deal */ - static private $page_action_names = array( - 'otherblog', - 'plugin', - 'version', - 'nucleusbutton', - 'include', - 'phpinclude', - 'parsedinclude', - 'loginform', - 'sitevar', - 'otherarchivelist', - 'otherarchivedaylist', - 'otherarchiveyearlist', - 'self', + static private $default_actions = array( + 'addlink', + 'addpopupcode', 'adminurl', - 'todaylink', 'archivelink', - 'member', + 'bloglist', 'category', - 'searchform', + 'loginform', + 'member', + 'nucleusbutton', + 'otherarchivedaylist', + 'otherarchivelist', + 'otherarchiveyearlist', + 'otherblog', + 'plugin', 'referer', + 'searchform', + 'self', + 'sitevar', 'skinname', - 'skinfile', - 'set', - 'if', - 'else', - 'endif', - 'elseif', - 'ifnot', - 'elseifnot', - 'charset', - 'bloglist', - 'addlink', - 'addpopupcode', 'sticky', + 'todaylink', + 'version', // deprecated (Nucleus v2.0) /* TODO: remove this */ 'ifcat' ); /** - * Actions::$page_type_friendly_names + * Actions::$skin_type_friendly_names * friendly name for wrapped page types */ - static public $page_type_friendly_names = array( + static public $default_skin_types = array( 'index' => _SKIN_PART_MAIN, 'item' => _SKIN_PART_ITEM, 'archivelist' => _SKIN_PART_ALIST, @@ -102,57 +84,50 @@ class Actions extends BaseActions ); /** - * Actions::get_allowed_actions_for_type() + * Actions::getAvailableSkinTypes() * * @static - * @param string $type page type - * @return array allowed actions for the page type + * @param void + * @return array list of friendly names for page actions */ - static public function get_allowed_actions_for_type($type) - { - $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) - 'ifcat' - ); + static public function getAvailableSkinTypes() + { + return self::$default_skin_types; + } + + /** + * Actions::__construct() + * Constructor for a new Actions object + * + * @param string $type + * @return void + */ + public function __construct($type) + { + global $catid; - // extra actions specific for a certain skin type + // call constructor of superclass first + parent::__construct(); + $this->skintype = $type; + + if ( $catid ) + { + $this->linkparams = array('catid' => $catid); + } + return; + } + + /** + * Actions::getAvailableActions() + * + * @param void + * @return array allowed actions for the page type + */ + public function getAvailableActions() + { $extra_actions = array(); - switch ( $type ) + switch ( $this->skintype ) { case 'index': $extra_actions = array( @@ -274,78 +249,10 @@ class Actions extends BaseActions ); break; } - return array_merge($default_actions, $extra_actions); - } - - /** - * AdminActions::get_page_action_names() - * - * @static - * @param void - * @return array list of page action names - */ - static public function get_page_action_names() - { - return self::$page_action_names; - } - - /** - * Actions::get_page_type_friendly_names() - * - * @static - * @param void - * @return array list of friendly names for page actions - */ - static public function get_page_type_friendly_names() - { - return self::$page_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; + $defined_actions = array_merge(self::$default_actions, $extra_actions); - 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; + return array_merge($defined_actions, parent::getAvailableActions()); } /** @@ -358,7 +265,7 @@ class Actions extends BaseActions public function doForm($filename) { global $DIR_NUCLEUS; - array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket'); + array_push($this->parser->actions,'formdata', 'callback','errordiv','ticket'); $oldIncludeMode = Parser::getProperty('IncludeMode'); $oldIncludePrefix = Parser::getProperty('IncludePrefix'); @@ -371,7 +278,6 @@ class Actions extends BaseActions 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; @@ -386,7 +292,7 @@ class Actions extends BaseActions * @param string $value value of property * @return boolean condition */ - public function checkCondition($field, $name='', $value = '') + protected function checkCondition($field, $name='', $value = '') { global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists; @@ -408,12 +314,6 @@ class Actions extends BaseActions case 'admin': $condition = $member->isLoggedIn() && $this->ifAdmin($name); break; - case 'superadmin': - $condition = $member->isLoggedIn() && $member->isAdmin(); - break; - case 'allowloginedit': - $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin()); - break; case 'nextitem': $condition = ($itemidnext != ''); break; @@ -432,27 +332,6 @@ class Actions extends BaseActions case 'hasplugin': $condition = $this->ifHasPlugin($name, $value); break; - case 'adminaction': - $condition = ($this->objAdmin->action == $name); - break; - case 'adminoldaction': - $condition = ($this->objAdmin->action == $name); - break; - case 'addresschange': - $condition = ($this->_ifAddresscange()); - break; - case 'bechangepass': - $condition = ($this->_beChangePassword()); - break; - case 'skincandidates': - $condition = ($this->_ifSkincandidates()); - break; - case 'nameclashes': - $condition = requestVar('nameclashes'); - break; - case 'existsnewplugin': - $condition = ($this->_existsNewPlugin()); - break; default: $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value); break; @@ -675,8 +554,8 @@ class Actions extends BaseActions // 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']; + $path = ( in_array('path', $parsed) ) ? $parsed['path'] : ''; + $parsed = ( in_array('query', $parsed) ) ? $parsed['query'] : ''; $url = ''; if ( $direction == 'prev' ) @@ -693,7 +572,7 @@ class Actions extends BaseActions { $url = $CONF['SearchURL']; } - $url .= '?' . alterQueryStr($parsed,'startpos',$startpos); + $url .= '?' . alterQueryStr($parsed, 'startpos', $startpos); } } else if ( $direction == 'next' ) @@ -736,7 +615,7 @@ class Actions extends BaseActions } if ( $sqlquery ) { - $iAmountOnPage = intval(quickQuery($sqlquery)) - intval($startpos); + $iAmountOnPage = intval(DB::getValue($sqlquery)) - intval($startpos); } } @@ -1234,19 +1113,6 @@ class Actions extends BaseActions } /** - * 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 * @@ -1354,19 +1220,20 @@ class Actions extends BaseActions */ public function parse_comments($template) { - global $itemid, $manager, $blog, $highlight; + global $manager, $blog, $highlight, $itemid; + $template =& $manager->getTemplate($template); + $item =& $manager->getitem($itemid, 0, 0); // 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); + $handler = new ItemActions($blog); + $handler->setTemplate($template); + $handler->setCurrentItem($item); + + $parser = new Parser($handler); $comments = new Comments($itemid); - $comments->setItemActions($actions); + $comments->setItemActions($handler); // shows ALL comments $comments->showComments($template, -1, 1, $highlight); return; @@ -2249,7 +2116,7 @@ class Actions extends BaseActions */ public function parse_skinname() { - echo $this->skin->getName(); + echo $this->parser->skin->getName(); return; } @@ -2267,23 +2134,6 @@ class Actions extends BaseActions } /** - * 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 *