Parser::__construct()でBaseActions派生クラスのsetParser()を実行し、自身を登録するように変更。これに伴い、Parserクラスのインスタンスを作成する処理が変更となった。
また、BaseActions派生クラスのメソッド名も以下のように変更した。
・getDefaultSkinTypes()をgetAvailableSkinTypes()に
・getDefinedActions()をgetAvailableActions()に
Revision 1818:
CHANGE: constructor of Parser class, method names of BaseActions-derived
classes
Now Parser class set itself into BaseActions-derived class as $parser
calling setParser() within its constructor.
And rename two methods of BaseActions-derived class:
getDefaultSkinTypes() to getAvailableSkinTypes()
getDefinedActions() to getAvailableActions()
http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1818
$contents = $handler->getTemplateFor('bookmarklet', 'add');
$manager->notify('PreAddItemForm', array('contents' => &$contents, 'blog' => &$blog));
- $parser = new Parser($handler->getDefinedActions(), $handler);
+ $parser = new Parser($handler);
$parser->parse($contents);
return;
$contents = $handler->getTemplateFor('bookmarklet', 'edit');
- $parser = new Parser($handler->getDefinedActions(), $handler);
+ $parser = new Parser($handler);
$parser->parse($contents);
return;
* 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 1784 2012-04-22 04:28:30Z sakamocchi $
);
/**
- * Actions::getDefinedActions()
+ * Actions::getAvailableSkinTypes()
*
* @static
- * @param string $type page type
+ * @param void
+ * @return array list of friendly names for page actions
+ */
+ 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;
+
+ // 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
*/
- static public function getDefinedActions($type='')
+ public function getAvailableActions()
{
$extra_actions = array();
- switch ( $type )
+ switch ( $this->skintype )
{
case 'index':
$extra_actions = array(
$defined_actions = array_merge(self::$default_actions, $extra_actions);
- return array_merge($defined_actions, parent::getDefinedActions());
- }
-
- /**
- * Actions::getDefaultSkinTypes()
- *
- * @static
- * @param void
- * @return array list of friendly names for page actions
- */
- static public function getDefaultSkinTypes()
- {
- return self::$default_skin_types;
- }
-
- /**
- * Actions::__construct()
- * Constructor for a new Actions object
- *
- * @param string $type
- * @return void
- */
- public function __construct($type)
- {
- global $catid;
-
- // call constructor of superclass first
- parent::__construct();
- $this->skintype = $type;
-
- if ( $catid )
- {
- $this->linkparams = array('catid' => $catid);
- }
- return;
+ return array_merge($defined_actions, parent::getAvailableActions());
}
/**
public function parse_comments($template)
{
global $itemid, $manager, $blog, $highlight;
+
$template =& $manager->getTemplate($template);
+ $item = Item::getitem($itemid, 0, 0);
// create parser object & action handler
$handler = new ItemActions($blog);
- $parser = new Parser($handler->getDefinedActions(),$handler);
$handler->setTemplate($template);
- $handler->setParser($parser);
- $item = Item::getitem($itemid, 0, 0);
$handler->setCurrentItem($item);
+ $parser = new Parser($handler);
+
$comments = new Comments($itemid);
$comments->setItemActions($handler);
// shows ALL comments
$contents = $handler->getTemplateFor('admin', 'add');
$manager->notify('PreAddItemForm', array('contents' => &$contents, 'blog' => &$blog));
- $parser = new Parser($handler->getDefinedActions(), $handler);
+ $parser = new Parser($handler);
$this->pagehead();
$parser->parse($contents);
$content = $handler->getTemplateFor('admin', 'edit');
- $parser = new Parser($handler->getDefinedActions(), $handler);
+ $parser = new Parser($handler);
$this->pagehead();
$parser->parse($content);
\r
// create parser object & action handler\r
$handler = new ItemActions($this);\r
- $parser = new Parser($handler->getDefinedActions(), $handler);\r
$handler->setTemplate($template);\r
$handler->setHighlight($highlight);\r
$handler->setLastVisit($lastVisit);\r
- $handler->setParser($parser);\r
$handler->setShowComments($comments);\r
\r
+ $parser = new Parser($handler);\r
+ \r
// execute query\r
$items = DB::getResult($query);\r
\r
}
/**
+ * BodyActions::getAvailableActions()
+ * Get the defined actions in an item
+ *
+ * @param void
+ * @return array self::$defined_actions
+ */
+ public function getAvailableActions()
+ {
+ return array_merge(self::$defined_actions, parent::getAvailableActions());
+ }
+
+ /**
* BodyActions::setCurrentItem()
* Set the current item
*
}
/**
- * BodyActions::getDefinedActions()
- * Get the defined actions in an item
- *
- * @static
- * @param void
- * @return Array self::$defined_actions
- */
- static public function getDefinedActions()
- {
- return array_merge(self::$defined_actions, parent::getDefinedActions());
- }
-
- /**
* BodyActions::parse_plugin()
* Parse a plugin var
* Called if <%plugin(...)%> in an item appears
}
/**
- * BaseActions::getDefinedActions()
+ * BaseActions::getAvailableActions()
*
- * @static
* @param void
* @return void
*/
- static public function getDefinedActions()
+ public function getAvailableActions()
{
return self::$defined_actions;
}
}
/**
- * CommentActions::getDefinedActions()
+ * CommentActions::getAvailableActions()
*
- * @static
* @param void
* @return array actions array
*/
- static public function getDefinedActions()
+ public function getAvailableActions()
{
- return array_merge(self::$defined_actions, parent::getDefinedActions());
+ return array_merge(self::$defined_actions, parent::getAvailableActions());
}
/**
\r
// create parser object & action handler\r
$handler = new CommentActions($this);\r
- $parser = new Parser($handler->getDefinedActions(),$handler);\r
$handler->setTemplate($template);\r
- $handler->setParser($parser);\r
-\r
+ \r
+ $parser = new Parser($handler);\r
+ \r
if ($maxToShow == 0) {\r
$this->commentcount = $this->amountComments();\r
} else {\r
}
/**
- * ItemActions::getDefinedActions()
+ * ItemActions::getAvailableActions()
* Returns an array with the actions that are defined
* in the ItemActions class
*
- * @static
* @param void
* @return void
*/
- static public function getDefinedActions()
+ public function getAvailableActions()
{
- return array_merge(self::$defined_actions, parent::getDefinedActions());
+ return array_merge(self::$defined_actions, parent::getAvailableActions());
}
/**
public function highlightAndParse(&$data)
{
$handler = new BodyActions($this->blog);
- $parser = new Parser($handler->getDefinedActions(), $handler);
$handler->setTemplate($this->template);
$handler->setHighlight($this->strHighlight);
$handler->setCurrentItem($this->currentItem);
+
+ $parser = new Parser($handler);
$parser->parse($handler->highlight($data));
return;
}
/**
* PageFactory::$type
- * One of the types got by self::getDefaultSkinTypes()
+ * One of the types got by self::getAvailableSkinTypes()
*/
private $type = '';
);
/**
- * PageFactory::getDefinedActions()
- *
- * @static
- * @param void
- * @return array array for defined action names
- *
- */
- static public function getDefinedActions($type='')
- {
- return array_merge(self::$defined_actions, parent::getDefinedActions());
- }
-
- /**
* AdminActions::getSkinTypeFriendlyNames()
*
* @static
* @param void
* @return array list of friendly names for page actions
*/
- static public function getDefaultSkinTypes()
+ static public function getAvailableSkinTypes()
{
return self::$default_skin_types;
}
}
/**
+ * PageFactory::getAvailableActions()
+ *
+ * @param void
+ * @return array array for defined action names
+ *
+ */
+ public function getAvailableActions()
+ {
+ return array_merge(self::$defined_actions, parent::getAvailableActions());
+ }
+
+ /**
* PageFactory::setVariables()
*
* @param array $variables associated array for item data
global $DIR_LIBS;
// the $type is not in the allowed types array
- if ( !array_key_exists($type, $this->getDefaultSkinTypes()) )
+ if ( !array_key_exists($type, $this->getAvailableSkinTypes()) )
{
return '';
}
* Creates a new parser object with the given allowed actions
* and the given handler
*
- * @param $allowedActions array
* @param $handler class object with functions for each action (reference)
* @param $delim optional delimiter
* @param $paramdelim optional parameterdelimiter
*/
- public function __construct($allowedActions, &$handler, $delim = '(<%|%>)', $pdelim = ',')
+ public function __construct( &$handler, $delim = '(<%|%>)', $pdelim = ',')
{
- $this->actions = $allowedActions;
- $this->handler =& $handler;
- $this->delim = $delim;
- $this->pdelim = $pdelim;
+ $this->handler = &$handler;
+ $this->actions = $handler->getAvailableActions();
+ $this->delim = $delim;
+ $this->pdelim = $pdelim;
$this->norestrictions = 0; // set this to 1 to disable checking for allowedActions
+
+ $handler->setParser($this);
+
return;
}
// call action handler
$action_class = $this->action_class;
$handler = new $action_class($type);
+ $handler->setSkin($this);
// register action handler to parser
- $actions = $handler->getDefinedActions($type);
- $parser = new Parser($actions, $handler);
-
- $handler->setParser($parser);
- $handler->setSkin($this);
+ $parser = new Parser($handler);
$parser->parse($contents);
$data = array(
*/
public function getDefaultTypes()
{
- return call_user_func(array($this->action_class, 'getDefaultSkinTypes'));
+ return call_user_func(array($this->action_class, 'getAvailableSkinTypes'));
}
/**
* Get the allowed actions for a skin type
* returns an array with the allowed actions
*
- * @param string $type type of the skin
+ * @param string $skintype type of the skin
* @return array allowed action types
*/
- public function getAllowedActionsForType($type)
+ public function getAllowedActionsForType($skintype)
{
- return call_user_func(array($this->action_class, 'getDefinedActions'), $type);
+ $handler = new $this->action_class($skintype);
+ return $handler->getAvailableActions();
}
}