private $includePrefix;\r
private $name;\r
\r
- /* \r
- * FIXME:\r
- * whether to be used by Admin class or not\r
- * the other way is preferrable instead of this\r
- * for example, adding admindir to normal/skindir in nucleus_skin_desc.sdincmode \r
- * \r
- */\r
- private $admin = FALSE;\r
+ /* action class */\r
+ private $action_class;\r
+ private $event_identifier;\r
\r
/**\r
* Skin::__construct()\r
* Constructor for a new SKIN object\r
* \r
- * @param integer $id id of the skin\r
- * @param boolean $admin for admin pages or not\r
+ * @param integer $id id of the skin\r
+ * @param string $action_class name of class extended from BaseActions\r
+ * @param string $event_identifier event identifier. for example, InitAdminSkinParse if AdminSkin is used\r
* @return void\r
*/\r
- public function __construct($id, $admin=FALSE)\r
+ public function __construct($id, $action_class='Actions', $event_identifier='Skin')\r
{\r
global $DIR_LIBS;\r
\r
return;\r
}\r
\r
- $this->name = $obj->sdname;\r
- $this->description = $obj->sddesc;\r
- $this->contentType = $obj->sdtype;\r
- $this->includeMode = $obj->sdincmode;\r
- $this->includePrefix = $obj->sdincpref;\r
/*\r
- * FIXME: this key should be replaced by other way\r
- * such that adding admin key into skin table and so on\r
+ * NOTE: include needed action class\r
*/\r
- if ( !$admin )\r
+ if ( $action_class != 'Actions' )\r
{\r
- if ( !class_exists('Actions', FALSE) )\r
+ if ( !class_exists($action_class, FALSE)\r
+ && !file_exists("{$DIR_LIBS}{$action_class}.php")\r
+ && !include("{$DIR_LIBS}{$action_class}.php") )\r
{\r
- include("{$DIR_LIBS}ACTIONS.php");\r
+ return;\r
}\r
- $this->admin = FALSE;\r
}\r
else\r
{\r
- if ( !class_exists('AdminActions', FALSE) )\r
+ if ( !class_exists('Actions', FALSE)\r
+ && !file_exists("{$DIR_LIBS}ACTIONS.php")\r
+ && !include("{$DIR_LIBS}ACTIONS.php") )\r
{\r
- include("{$DIR_LIBS}AdminActions.php");\r
+ return;\r
}\r
- $this->admin = TRUE;\r
}\r
\r
+ $this->action_class = $action_class;\r
+ $this->event_identifier = $event_identifier;\r
+ \r
+ $this->name = $obj->sdname;\r
+ $this->description = $obj->sddesc;\r
+ $this->contentType = $obj->sdtype;\r
+ $this->includeMode = $obj->sdincmode;\r
+ $this->includePrefix = $obj->sdincpref;\r
+ \r
return;\r
}\r
\r
{\r
global $currentSkinName, $manager, $CONF;\r
\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('InitSkinParse',array('skin' => &$this, 'type' => $type));\r
- }\r
- else\r
- {\r
- $manager->notify('InitAdminSkinParse',array('skin' => &$this, 'type' => $type));\r
- }\r
+ $manager->notify("Init{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));\r
\r
// set output type\r
sendContentType($this->getContentType(), 'skin');\r
\r
$actions = $this->getAllowedActionsForType($type);\r
\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PreSkinParse',array('skin' => &$this, 'type' => $type, 'contents' => &$contents));\r
- }\r
- else\r
- {\r
- $manager->notify('PreAdminSkinParse',array('skin' => &$this, 'type' => $type, 'contents' => &$contents));\r
- }\r
+ $manager->notify("Pre{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type, 'contents' => &$contents));\r
\r
// set IncludeMode properties of parser\r
Parser::setProperty('IncludeMode', $this->getIncludeMode());\r
Parser::setProperty('IncludePrefix', $this->getIncludePrefix());\r
\r
- if ( !$this->admin )\r
- {\r
- $handler = new Actions($type);\r
- }\r
- else\r
- {\r
- $handler = new AdminActions($type);\r
- }\r
+ $action_class = $this->action_class;\r
+ $handler = new $action_class($type);\r
\r
$parser = new Parser($actions, $handler);\r
$handler->setParser($parser);\r
$handler->setSkin($this);\r
$parser->parse($contents);\r
\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PostSkinParse',array('skin' => &$this, 'type' => $type));\r
- }\r
- else\r
- {\r
- $manager->notify('PostSkinParse',array('skin' => &$this, 'type' => $type));\r
- }\r
+ $manager->notify("Post{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));\r
return;\r
}\r
\r
);\r
\r
// PreUpdateSkinPart event\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PreUpdateSkinPart', $data);\r
- }\r
- else\r
- {\r
- $manager->notify('PreUpdateAdminSkinPart', $data);\r
- }\r
+ $manager->notify("PreUpdate{{$this->event_identifier}}Part", $data);\r
}\r
else if( $skintypevalue && !$skintypeexists )\r
{\r
'content' => &$content\r
);\r
\r
- // PreAddSkinPart event\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PreAddSkinPart', $data);\r
- }\r
- else\r
- {\r
- $manager->notify('PreAddAdminSkinPart', $data);\r
- }\r
+ $manager->notify("PreAdd{$this->event_identifier}Part", $data);\r
}\r
else if( !$skintypevalue && $skintypeexists )\r
{\r
'type' => $type\r
);\r
\r
- // PreDeleteSkinPart event\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PreDeleteSkinPart', $data);\r
- }\r
- else\r
- {\r
- $manager->notify('PreDeleteAdminSkinPart', $data);\r
- }\r
+ $manager->notify("PreDelete{$this->event_identifier}Part", $data);\r
}\r
\r
// delete old thingie\r
);\r
\r
// PostUpdateSkinPart event\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PostUpdateSkinPart', $data);\r
- }\r
- else\r
- {\r
- $manager->notify('PostUpdateAdminSkinPart', $data);\r
- }\r
+ $manager->notify("PostUpdate{$this->event_identifier}Part", $data);\r
}\r
else if( $skintypevalue && (!$skintypeexists) )\r
{\r
);\r
\r
// PostAddSkinPart event\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PostAddSkinPart', $data);\r
- }\r
- else\r
- {\r
- $manager->notify('PostAddAdminSkinPart', $data);\r
- }\r
+ $manager->notify("PostAdd{$this->event_identifier}Part", $data);\r
}\r
else if( (!$skintypevalue) && $skintypeexists )\r
{\r
'type' => $type\r
);\r
\r
- // PostDeleteSkinPart event\r
- if ( !$this->admin )\r
- {\r
- $manager->notify('PostDeleteSkinPart', $data);\r
- }\r
- else\r
- {\r
- $manager->notify('PostDeleteAdminSkinPart', $data);\r
- }\r
+ $manager->notify("PostDelete{$this->event_identifier}Part", $data);\r
}\r
return;\r
}\r
}\r
\r
/**\r
+ * Skin::getAllowedActionsForType()\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 (e.g. index, item, search ...)\r
+ * @return array allowed action types\r
+ */\r
+ public function getAllowedActionsForType($type)\r
+ {\r
+ /**\r
+ * NOTE: static method with variable class name is supported since 5.3\r
+ * So now we utilize eval function.\r
+ */\r
+ $page_action_names = array();\r
+ eval("\$page_action_names = {$this->action_class}::get_allowed_actions_for_type('{$type}');");\r
+ return $page_action_names;\r
+ }\r
+ \r
+ /**\r
* Skin::getFriendlyNames()\r
* Get an array with the names of possible skin parts\r
* Used to show all possible parts of a skin in the administration backend\r
* \r
- * @param void\r
+ * @static\r
+ * @param string $action_class name of action class (optional)\r
* @param array type of the skin\r
*/\r
- static public function getFriendlyNames()\r
+ static public function getFriendlyNames($action_class='Actions')\r
{\r
- if ( !$this->$admin )\r
+ global $DIR_LIBS;\r
+ \r
+ /*\r
+ * NOTE: include needed action class\r
+ */\r
+ if ( $action_class != 'Actions' )\r
{\r
- $friendly_names = Actions::get_page_type_friendly_names();\r
- $action_names = Actions::get_page_action_names();\r
+ if ( !class_exists($action_class, FALSE)\r
+ && !file_exists("{$DIR_LIBS}{$action_class}.php")\r
+ || !include("{$DIR_LIBS}{$action_class}.php") )\r
+ {\r
+ return;\r
+ }\r
}\r
else\r
{\r
- $friendly_names = AdminActions::get_page_type_friendly_names();\r
- $action_names = AdminActions::get_page_action_names();\r
+ if ( !class_exists('Actions', FALSE)\r
+ && !file_exists("{$DIR_LIBS}ACTIONS.php")\r
+ || !include("{$DIR_LIBS}ACTIONS.php") )\r
+ {\r
+ return;\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * NOTE: static method with variable class name is supported since 5.3\r
+ * So now we utilize eval function.\r
+ */\r
+ eval("\$friendly_names = {$action_class}::get_page_type_friendly_names();");\r
+ \r
+ $action_names = array();\r
+ foreach ( $friendly_names as $action_name => $friendly_name )\r
+ {\r
+ $action_names[] = $action_name;\r
}\r
\r
$query = "SELECT stype FROM %s WHERE stype NOT IN ('%s');";\r
}\r
return $friendly_names;\r
}\r
- \r
- /**\r
- * Skin::getAllowedActionsForType()\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 (e.g. index, item, search ...)\r
- * @return array allowed action types\r
- */\r
- public function getAllowedActionsForType($type)\r
- {\r
- if ( !$this->admin )\r
- {\r
- return Actions::get_allowed_actions_for_type($type);\r
- }\r
- else\r
- {\r
- return AdminActions::get_allowed_actions_for_type($type);\r
- }\r
- }\r
}\r
}\r
if ( sizeof($types) > 0 )\r
{\r
- $friendlyNames = Skin::getFriendlyNames();\r
- $defaultParts = array(\r
- 'index',\r
- 'item',\r
- 'archivelist',\r
- 'archive',\r
- 'search',\r
- 'error',\r
- 'member',\r
- 'imagepopup',\r
- );\r
for ( $i = 0; $i < sizeof($types); $i++ )\r
{\r
$type = $types[$i];\r
- if ( !in_array($type, $defaultParts) )\r
+ if ( $i != $types[$i] )\r
{\r
$article = 'skinpartspecial';\r
}\r
}\r
$types[$i] = "<li>\n"\r
. helpHtml($article) . "\n"\r
- . "<a href=\"index.php?action=skinedittype&skinid={$current->sdnumber}&type={$type}\" tabindex=\"{$vars['tabindex']}\">" . Entity::hsc($friendlyNames[$type]) . "</a>\n"\r
- . "</li>\n";\r
+ . "<a href=\"index.php?action=skinedittype&skinid={$current->sdnumber}&type={$type}\" tabindex=\"{$template['tabindex']}\">"\r
+ . Entity::hsc($template['friendly_names'][$type])\r
+ . "</a>\n"\r
+ . "</li>\n";\r
}\r
$data['skinparts'] = '<br /><br />' . _LIST_SKINS_DEFINED . "<ul>\n" . implode($types, '') . "</ul>\n";\r
}\r
{\r
$data['skinname'] = Entity::hsc($current->sdname);\r
}\r
-\r
+ \r
// add preview image when present\r
if ( $current->sdincpref && @file_exists("{$adminSkinDir}{$current->sdincpref}preview.png") )\r
{\r
$data['skinthumb'] = "<p>\n";\r
-\r
+ \r
$alternatve_text = sprintf(_LIST_SKIN_PREVIEW, $current->sdname);\r
$has_enlargement = @file_exists($adminSkinDir . $current->sdincpref . 'preview-large.png');\r
if ( $has_enlargement )\r
{\r
$data['skinthumb'] .= "</a><br />\n";\r
}\r
-\r
+ \r
if ( @file_exists("{$DIR_SKINS}{$current->sdincpref}readme.html") )\r
{\r
$url = $adminSkinURL . Entity::hsc($current->sdincpref) . 'readme.html';\r
{\r
$data['readme'] ="";\r
}\r
-\r
+ \r
$data['skinthumb'] .= "</p>\n";\r
}\r
/* show list of defined parts */\r
$query = "SELECT stype FROM %s WHERE sdesc=%d ORDER BY stype";\r
$query = sprintf($query, sql_table('skin'), $current->sdnumber);\r
$r = sql_query($query);\r
-\r
+ \r
$types = array();\r
while ( $o = sql_fetch_object($r) )\r
{\r
}\r
if ( sizeof($types) > 0 )\r
{\r
- $friendlyNames = AdminActions::get_page_type_friendly_names();\r
- $adminDefaultTypes = AdminActions::get_page_action_names();\r
for ( $i = 0; $i < sizeof($types); $i++ )\r
{\r
$type = $types[$i];\r
$article = "skinpart{$type}";\r
}\r
$types[$i] = "<li>\n"\r
- . helpHtml($article) . "\n"\r
- . "<a href=\"index.php?action=adminskinedittype&skinid={$current->sdnumber}&type={$type}\" tabindex=\"{$vars['tabindex']}\">" . Entity::hsc($friendlyNames[$type]) . "</a>\n"\r
- . "</li>\n";\r
+ . helpHtml($article) . "\n"\r
+ . "<a href=\"index.php?action=adminskinedittype&skinid={$current->sdnumber}&type={$type}\" tabindex=\"{$vars['tabindex']}\">"\r
+ . Entity::hsc($template['friendly_names'][$type])\r
+ . "</a>\n"\r
+ . "</li>\n";\r
+ }\r
+ $data['skinparts'] = '<br /><br />' . _LIST_SKINS_DEFINED . "<ul>\n" . implode($types, '') . "</ul>\n";\r
}\r
- $data['skinparts'] = '<br /><br />' . _LIST_SKINS_DEFINED . "<ul>\n" . implode($types, '') . "</ul>\n";\r
- }\r
- else\r
- {\r
- $data['skinparts'] = '';\r
- }\r
- break;\r
- case 'FOOT':\r
- if ( isset($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT']) || !empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT']) )\r
- {\r
- $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT'];\r
+ else\r
+ {\r
+ $data['skinparts'] = '';\r
+ }\r
+ break;\r
+ case 'FOOT':\r
+ if ( isset($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT']) || !empty($templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT']) )\r
+ {\r
+ $template = $templates['SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT'];\r
+ }\r
+ else\r
+ {\r
+ $template = "";\r
+ }\r
+ $data = array();\r
+ break;\r
}\r
- else\r
- {\r
- $template = "";\r
-}\r
-$data = array();\r
- break;\r
-}\r
-return Template::fill($template, $data);\r
+ return Template::fill($template, $data);\r
}\r
\r
function listplug_table_admintemplatelist($vars, $type, $templateName = '')\r