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
* This class contains the functions that get called by using\r
* the special tags in the skins\r
*\r
- * The allowed tags for a type of skinpart are defined by the\r
- * Skin::getAllowedActionsForType($type) method\r
- *\r
* @license http://nucleuscms.org/license.txt GNU General Public License\r
* @copyright Copyright (C) 2002-2012 The Nucleus Group\r
* @version $Id: ACTIONS.php 1784 2012-04-22 04:28:30Z sakamocchi $\r
);\r
\r
/**\r
- * Actions::getDefinedActions()\r
+ * Actions::getAvailableSkinTypes()\r
* \r
* @static\r
- * @param string $type page type\r
+ * @param void\r
+ * @return array list of friendly names for page actions\r
+ */\r
+ static public function getAvailableSkinTypes()\r
+ {\r
+ return self::$default_skin_types;\r
+ }\r
+ \r
+ /**\r
+ * Actions::__construct()\r
+ * Constructor for a new Actions object\r
+ * \r
+ * @param string $type\r
+ * @return void\r
+ */\r
+ public function __construct($type)\r
+ {\r
+ global $catid;\r
+ \r
+ // call constructor of superclass first\r
+ parent::__construct();\r
+ $this->skintype = $type;\r
+ \r
+ if ( $catid )\r
+ {\r
+ $this->linkparams = array('catid' => $catid);\r
+ }\r
+ return;\r
+ }\r
+ \r
+ /**\r
+ * Actions::getAvailableActions()\r
+ * \r
+ * @param void\r
* @return array allowed actions for the page type\r
*/\r
- static public function getDefinedActions($type='')\r
+ public function getAvailableActions()\r
{\r
$extra_actions = array();\r
\r
- switch ( $type )\r
+ switch ( $this->skintype )\r
{\r
case 'index':\r
$extra_actions = array(\r
\r
$defined_actions = array_merge(self::$default_actions, $extra_actions);\r
\r
- return array_merge($defined_actions, parent::getDefinedActions());\r
- }\r
- \r
- /**\r
- * Actions::getDefaultSkinTypes()\r
- * \r
- * @static\r
- * @param void\r
- * @return array list of friendly names for page actions\r
- */\r
- static public function getDefaultSkinTypes()\r
- {\r
- return self::$default_skin_types;\r
- }\r
- \r
- /**\r
- * Actions::__construct()\r
- * Constructor for a new Actions object\r
- * \r
- * @param string $type\r
- * @return void\r
- */\r
- public function __construct($type)\r
- {\r
- global $catid;\r
- \r
- // call constructor of superclass first\r
- parent::__construct();\r
- $this->skintype = $type;\r
- \r
- if ( $catid )\r
- {\r
- $this->linkparams = array('catid' => $catid);\r
- }\r
- return;\r
+ return array_merge($defined_actions, parent::getAvailableActions());\r
}\r
\r
/**\r
public function parse_comments($template)\r
{\r
global $itemid, $manager, $blog, $highlight;\r
+ \r
$template =& $manager->getTemplate($template);\r
+ $item = Item::getitem($itemid, 0, 0);\r
\r
// create parser object & action handler\r
$handler = new ItemActions($blog);\r
- $parser = new Parser($handler->getDefinedActions(),$handler);\r
$handler->setTemplate($template);\r
- $handler->setParser($parser);\r
- $item = Item::getitem($itemid, 0, 0);\r
$handler->setCurrentItem($item);\r
\r
+ $parser = new Parser($handler);\r
+ \r
$comments = new Comments($itemid);\r
$comments->setItemActions($handler);\r
// shows ALL comments\r
}\r
elseif ( method_exists('Admin', $methodName) )\r
{\r
- call_user_func(array(self, $methodName));\r
+ call_user_func(array(__CLASS__, $methodName));\r
}\r
else if ( self::existsSkinContents('adminerrorpage') )\r
{\r
$actions = array_merge($actions, self::$skin->getAllowedActionsForType($type));\r
}\r
\r
- $parser = new Parser($actions, $handler);\r
- $handler->setParser($parser);\r
$handler->setSkin(self::$skin);\r
+ \r
+ $parser = new Parser($handler);\r
$parser->parse($contents);\r
\r
if ( $type == 'pagefoot' )\r
\r
self::$skin = (object) $skn;\r
$handler = new AdminActions($actnName, self::$skin, $this);\r
- $actions = Skin::getAllowedActionsForType($actnName);\r
- \r
- $parser = new PARSER($actions, $handler);\r
- $handler->setParser($parser);\r
$handler->setSkin(self::$skin);\r
+ \r
+ $parser = new PARSER($handler);\r
$parser->parse($contents);\r
+ \r
return;\r
}\r
\r
// reference to the skin object for which a part is being parsed
private $skin;
- // an instance of parser class
-// private $parser;
- protected $parser;
-
private $skintype;
/* NOTE: list of whole available action names for tags
);
/**
- * AdminActions::getDefinedActions()
+ * AdminActions::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;
+ }
+
+ /**
+ * AdminActions::getDefaultTypes()
+ *
+ * @static
+ * @param void
+ * @return array list of friendly names for page actions
+ */
+ static public function getDefaultTypes()
+ {
+ return self::$default_skin_types;
+ }
+
+ /**
+ * AdminActions::__construct()
+ * Constructor for a new Actions object
+ *
+ * @param string $type
+ * @return void
+ */
+ public function __construct($type)
+ {
+ // call constructor of superclass first
+ parent::__construct();
+ $this->skintype = $type;
+ if ( !class_exists('Navlist') || !class_exists('Batch') )
+ {
+ global $DIR_LIBS;
+ include $DIR_LIBS . 'ENCAPSULATE.php';
+ }
+ return;
+ }
+
+ /**
+ * AdminActions::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 'actionlog':
$extra_actions = array(
$defined_actions = array_merge(self::$default_actions, $extra_actions);
- return array_merge($defined_actions, parent::getDefinedActions());
- }
-
- /**
- * AdminActions::getDefaultSkinTypes()
- *
- * @static
- * @param void
- * @return array list of friendly names for page actions
- */
- static public function getDefaultSkinTypes()
- {
- return self::$default_skin_types;
- }
-
- /**
- * AdminActions::getDefaultTypes()
- *
- * @static
- * @param void
- * @return array list of friendly names for page actions
- */
- static public function getDefaultTypes()
- {
- return self::$default_skin_types;
- }
-
- /**
- * AdminActions::__construct()
- * Constructor for a new Actions object
- *
- * @param string $type
- * @return void
- */
- public function __construct($type)
- {
- // call constructor of superclass first
- parent::__construct();
- $this->skintype = $type;
- if ( !class_exists('Navlist') || !class_exists('Batch') )
- {
- global $DIR_LIBS;
- include $DIR_LIBS . 'ENCAPSULATE.php';
- }
- return;
+ return array_merge($defined_actions, parent::getAvailableActions());
}
/**
}
/**
- * AdminActions::setParser()
- * Set the parser
- *
- * @param object $parser an instance of Parser class
- * @return void
- */
- public function setParser(&$parser)
- {
- $this->parser =& $parser;
- return;
- }
-
- /**
* AdminActions::parse_actionloglist()
* Parse skinvar actionloglist
*
. "<%name%></a> <%help%></li>\n";
}
$handler = new Actions('template', $template, new ADMIN);
- $parser = new PARSER(Actions::getDefinedActions(), $handler);
+
+ $parser = new PARSER($handler);
foreach ( $types as $type => $fName )
{
foreach ( $options as $option )
{
$handler = new Actions($this->skintype, $template, $option);
- $parser = new PARSER(Actions::getDefinedActions(), $handler);
+
+ $parser = new PARSER($handler);
+
// new plugin?
if ( $prevPid != $option['pid'] )
{
{
$template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
}
- $handler = new Actions($this->skintype, $template, $this->objAdmin);
- $parser = new PARSER(Actions::getDefinedActions(), $handler);
+ $handler = new Actions($this->skintype);
+
+ $parser = new PARSER($handler);
$parser->parse($template['title']);
if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
\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 = sql_query($query);\r
\r
}\r
\r
/**\r
+ * BodyActions::getAvailableActions()\r
+ * Get the defined actions in an item\r
+ * \r
+ * @param void\r
+ * @return array self::$defined_actions\r
+ */\r
+ public function getAvailableActions()\r
+ {\r
+ return array_merge(self::$defined_actions, parent::getAvailableActions());\r
+ }\r
+ \r
+ /**\r
* BodyActions::setCurrentItem()\r
* Set the current item\r
* \r
}\r
\r
/**\r
- * BodyActions::getDefinedActions()\r
- * Get the defined actions in an item\r
- * \r
- * @static
- * @param void\r
- * @return Array self::$defined_actions\r
- */\r
- static public function getDefinedActions()
- {\r
- return array_merge(self::$defined_actions, parent::getDefinedActions());
- }\r
- \r
- /**\r
* BodyActions::parse_plugin()\r
* Parse a plugin var\r
* Called if <%plugin(...)%> in an item appears\r
}
/**
- * BaseActions::getDefinedActions()
+ * BaseActions::getAvailableActions()
*
- * @static
* @param void
* @return void
*/
- static public function getDefinedActions()
+ public function getAvailableActions()
{
return self::$defined_actions;
}
}\r
\r
/**\r
- * CommentActions::getDefinedActions()\r
+ * CommentActions::getAvailableActions()\r
* \r
- * @static
* @param void\r
* @return array actions array\r
*/\r
- static public function getDefinedActions()
+ public function getAvailableActions()\r
{\r
- return array_merge(self::$defined_actions, parent::getDefinedActions());
+ return array_merge(self::$defined_actions, parent::getAvailableActions());\r
}\r
\r
/**\r
\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
}\r
\r
/**\r
- * ItemActions::getDefinedActions()\r
+ * ItemActions::getAvailableActions()\r
* Returns an array with the actions that are defined\r
* in the ItemActions class\r
* \r
- * @static
* @param void\r
* @return void\r
*/\r
- static public function getDefinedActions()
+ public function getAvailableActions()\r
{\r
- return array_merge(self::$defined_actions, parent::getDefinedActions());
+ return array_merge(self::$defined_actions, parent::getAvailableActions());\r
}\r
\r
/**\r
public function highlightAndParse(&$data)\r
{\r
$handler = new BodyActions($this->blog);
- $parser = new Parser($handler->getDefinedActions(), $handler);
$handler->setTemplate($this->template);
$handler->setHighlight($this->strHighlight);
$handler->setCurrentItem($this->currentItem);
+ \r
+ $parser = new Parser($handler);\r
$parser->parse($handler->highlight($data));
return;\r
}\r
* Creates a new parser object with the given allowed actions\r
* and the given handler\r
*\r
- * @param $allowedActions array\r
* @param $handler class object with functions for each action (reference)\r
* @param $delim optional delimiter\r
* @param $paramdelim optional parameterdelimiter\r
*/\r
- public function __construct($allowedActions, &$handler, $delim = '(<%|%>)', $pdelim = ',')\r
+ public function __construct( &$handler, $delim = '(<%|%>)', $pdelim = ',')\r
{\r
- $this->actions = $allowedActions;\r
- $this->handler =& $handler;\r
- $this->delim = $delim;\r
- $this->pdelim = $pdelim;\r
+ $this->handler = &$handler;\r
+ $this->actions = $handler->getAvailableActions();\r
+ $this->delim = $delim;\r
+ $this->pdelim = $pdelim;\r
$this->norestrictions = 0; // set this to 1 to disable checking for allowedActions\r
+ \r
+ $handler->setParser($this);\r
+ \r
return;\r
}\r
\r
{\r
global $manager;\r
\r
- $manager->notify(\r
- 'PreAddSkin',\r
- array(\r
+ $data = array(
'name' => &$name,\r
'description' => &$desc,\r
'type' => &$type,\r
'includeMode' => &$includeMode,\r
'includePrefix' => &$includePrefix\r
- )\r
);\r
+ $manager->notify('PreAddSkin', $data);
\r
$query = "INSERT INTO %s (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('%s', '%s', '%s', '%s', '%s');";\r
$sdname = sql_real_escape_string($name);\r
sql_query($query);\r
$newid = sql_insert_id();\r
\r
- $manager->notify(\r
- 'PostAddSkin',\r
- array(\r
+ $data = array(
'skinid' => $newid,\r
'name' => $name,\r
'description' => $desc,\r
'type' => $type,\r
'includeMode' => $includeMode,\r
'includePrefix' => $includePrefix\r
- )\r
);\r
+ $manager->notify('PostAddSkin', $data);
+
return $newid;\r
}\r
\r
{\r
global $currentSkinName, $manager, $CONF, $DIR_NUCLEUS;\r
\r
- $manager->notify("Init{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));\r
+ $data = array(
+ 'skin' => &$this,
+ 'type' => $type
+ );
+ $manager->notify("Init{$this->event_identifier}Parse", $data);
\r
// include skin locale file for <%text%> tag if useable\r
$this->includeTranslation();\r
}\r
}\r
\r
- $manager->notify("Pre{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type, 'contents' => &$contents));\r
+ $data = array(
+ 'skin' => &$this,
+ 'type' => $type,
+ 'contents' => &$contents
+ );
+ $manager->notify("Pre{$this->event_identifier}Parse", $data);
\r
// set IncludeMode properties of parser\r
Parser::setProperty('IncludeMode', $this->getIncludeMode());\r
// call action handler\r
$action_class = $this->action_class;\r
$handler = new $action_class($type);\r
+ $handler->setSkin($this);\r
\r
// register action handler to parser\r
- $actions = $handler->getDefinedActions($type);\r
- $parser = new Parser($actions, $handler);\r
- \r
- $handler->setParser($parser);\r
- $handler->setSkin($this);\r
+ $parser = new Parser($handler);\r
$parser->parse($contents);\r
\r
- $manager->notify("Post{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));\r
+ $data = array(
+ 'skin' => &$this,
+ 'type' => $type
+ );
+ $manager->notify("Post{$this->event_identifier}Parse", $data);
+
return;\r
}\r
\r
*/\r
public function getDefaultTypes()\r
{\r
- return call_user_func(array($this->action_class, 'getDefaultSkinTypes'));\r
+ return call_user_func(array($this->action_class, 'getAvailableSkinTypes'));\r
}\r
\r
/**\r
* Get the allowed actions for a skin type\r
* returns an array with the allowed actions\r
* \r
- * @param string $type type of the skin\r
+ * @param string $skintype type of the skin\r
* @return array allowed action types\r
*/\r
- public function getAllowedActionsForType($type)\r
+ public function getAllowedActionsForType($skintype)\r
{\r
- return call_user_func(array($this->action_class, 'getDefinedActions'), $type);\r
+ $handler = new $this->action_class($skintype);\r
+ return $handler->getAvailableActions();\r
}\r
\r
}\r
include $DIR_LIBS . 'ACTIONS.php';\r
}\r
$template = Template::fill($template, $data);\r
- $handler = new Actions('template', $template, $data);\r
- $parser = new PARSER(Actions::getDefinedActions(), $handler);\r
+ $handler = new Actions('template', $template, $data);\r
+ \r
+ $parser = new Parser($handler);\r
$parser->parse($template);\r
+ \r
return;\r
}\r
\r
global $DIR_LIBS;\r
include $DIR_LIBS . 'ACTIONS.php';\r
}\r
- $handler = new Actions('template', $template, $data);\r
- $parser = new PARSER(Actions::getDefinedActions(), $handler);\r
+ \r
+ $handler = new Actions('template', $template, $data);\r
+ \r
+ $parser = new PARSER($handler);\r
$parser->parse($template);\r
+ \r
return;\r
}\r
\r