diff options
Diffstat (limited to '')
-rw-r--r-- | admin.php | 110 | ||||
-rw-r--r-- | admin/include/functions_plugins.inc.php | 40 | ||||
-rw-r--r-- | admin/plugin.php | 40 | ||||
-rw-r--r-- | include/functions_plugins.inc.php | 37 | ||||
-rw-r--r-- | plugins/add_index/admin/admin_menu.php | 4 | ||||
-rw-r--r-- | plugins/add_index/admin/admin_menu.tpl | 4 | ||||
-rw-r--r-- | plugins/add_index/main.admin.inc.php | 24 | ||||
-rw-r--r-- | plugins/add_index/main.inc.php | 1 | ||||
-rw-r--r-- | plugins/admin_advices/main.inc.php | 33 | ||||
-rw-r--r-- | plugins/event_tracer/main.inc.php | 35 | ||||
-rw-r--r-- | plugins/event_tracer/tracer_admin.php | 18 | ||||
-rw-r--r-- | plugins/event_tracer/tracer_admin.tpl | 4 |
12 files changed, 150 insertions, 200 deletions
@@ -2,10 +2,10 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | branch : BSF (Best So Far) -// | file : $RCSfile$ +// | file : $Id$ // | last update : $Date$ // | last modifier : $Author$ // | revision : $Revision$ @@ -54,66 +54,15 @@ check_conf(); // | variables init | // +-----------------------------------------------------------------------+ -unset($page['page']); - -if - ( - isset($_GET['page']) +if (isset($_GET['page']) and preg_match('/^[a-z_]*$/', $_GET['page']) - ) + and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php')) { - if - ( - (!isset($_GET['page_type']) or $_GET['page_type'] == 'standard') - and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php') - ) - { - $page['page']['type'] = 'standard'; - $page['page']['name'] = $_GET['page']; - } - else if - ( - (isset($_GET['page_type']) and $_GET['page_type'] == 'plugin') - and isset($_GET['plugin_id']) - and preg_match('/^[a-z_]*$/', $_GET['plugin_id']) - and is_file(PHPWG_PLUGINS_PATH.$_GET['plugin_id'].'/admin/'.$_GET['page'].'.php') - ) - { - if (function_exists('mysql_real_escape_string')) - { - $page['page']['plugin_id'] = mysql_real_escape_string($_GET['plugin_id']); - } - else - { - $page['page']['plugin_id'] = mysql_escape_string($_GET['plugin_id']); - } - - $check_db_plugin = get_db_plugins('active', $page['page']['plugin_id']); - if (!empty($check_db_plugin)) - { - $page['page']['type'] = $_GET['page_type']; - $page['page']['name'] = $_GET['page']; - } - else - { - unset($page['page']); - } - unset($check_db_plugin); - } + $page['page'] = $_GET['page']; } - -if (!isset($page['page'])) +else { - if (isset($_GET['page_type']) and $_GET['page_type'] == 'plugin') - { - $page['page']['type'] = 'standard'; - $page['page']['name'] = 'plugins'; - } - else - { - $page['page']['type'] = 'standard'; - $page['page']['name'] = 'intro'; - } + $page['page'] = 'intro'; } $page['errors'] = array(); @@ -184,47 +133,22 @@ if ($conf['allow_random_representative']) } // required before plugin page inclusion -trigger_action('plugin_admin_menu'); - -switch($page['page']['type']) -{ - case 'standard': - { - include(PHPWG_ROOT_PATH.'admin/'.$page['page']['name'].'.php'); - break; - } - case 'plugin': - { - include(PHPWG_PLUGINS_PATH.$page['page']['plugin_id'].'/admin/'.$page['page']['name'].'.php'); - break; - } - default: - { - die ("Hacking attempt!"); - break; - } -} - - -//------------------------------------------------------------- content display -$template->assign_block_vars('plugin_menu.menu_item', +$plugin_menu_links = array( array( 'NAME' => l10n('admin'), 'URL' => $link_start.'plugins' ) ); -if ( isset($page['plugin_admin_menu']) ) +$plugin_menu_links = trigger_event('get_admin_plugin_menu_links', + $plugin_menu_links ); + + +include(PHPWG_ROOT_PATH.'admin/'.$page['page'].'.php'); + +//------------------------------------------------------------- content display +foreach ($plugin_menu_links as $menu_item) { - $plug_base_url = $link_start.'plugin&section='; - foreach ($page['plugin_admin_menu'] as $menu) - { - $template->assign_block_vars('plugin_menu.menu_item', - array( - 'NAME' => $menu['title'], - 'URL' => $plug_base_url.$menu['uid'] - ) - ); - } + $template->assign_block_vars('plugin_menu.menu_item', $menu_item); } // +-----------------------------------------------------------------------+ diff --git a/admin/include/functions_plugins.inc.php b/admin/include/functions_plugins.inc.php index 45f3c734c..f5b43a6af 100644 --- a/admin/include/functions_plugins.inc.php +++ b/admin/include/functions_plugins.inc.php @@ -1,7 +1,7 @@ <?php // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | -// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | branch : BSF (Best So Far) // | file : $Id$ @@ -68,36 +68,16 @@ function get_fs_plugins() return $plugins; } -/*allows plugins to add their content to the administration page*/ -function add_plugin_admin_menu($title, $func) +/** + * Retrieves an url for a plugin page. + * @param string plugin_id + * @param string page - the php script file name (without .php extension) + */ +function get_admin_plugin_menu_link($plugin_id, $page) { - global $page; - if ( is_array( $func) ) - { - $s = ''; - foreach( $func as $e) - { - if (is_object($e)) - { - $s.=get_class($e)."\n"; - } - else - { - $s.=$e; - } - } - $uid = md5( $s ); - } - else - { - $uid = md5( $func ); - } - $page['plugin_admin_menu'][] = - array( - 'title' => $title, - 'function' => $func, - 'uid' => $uid - ); + $url = get_root_url().'admin.php?page=plugin&section=' + .urlencode($plugin_id .'~'. $page); + return $url; } ?>
\ No newline at end of file diff --git a/admin/plugin.php b/admin/plugin.php index c880cdca7..a057e87c8 100644 --- a/admin/plugin.php +++ b/admin/plugin.php @@ -2,10 +2,10 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | branch : BSF (Best So Far) -// | file : $RCSfile$ +// | file : $Id$ // | last update : $Date$ // | last modifier : $Author$ // | revision : $Revision$ @@ -33,27 +33,27 @@ if( !defined("PHPWG_ROOT_PATH") ) include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); check_status(ACCESS_ADMINISTRATOR); -$template->set_filenames(array('plugin' => 'admin/plugin.tpl')); - -if ( isset($page['plugin_admin_menu']) ) +$section = explode('~', $_GET['section'] ); +if (count($section)!=2) { - foreach ($page['plugin_admin_menu'] as $menu) - { - if (isset($_GET['section']) and $menu['uid']==$_GET['section']) - { - $found_menu=$menu; - break; - } - } + die('Invalid plugin URL'); } -if ( isset($found_menu) ) +$plugin_id = $section[0]; +$check_db_plugin = get_db_plugins('active', $plugin_id ); +if (empty($check_db_plugin)) { - $template->assign_var('PLUGIN_TITLE', $found_menu['title'] ); - call_user_func( - $found_menu['function'], - PHPWG_ROOT_PATH.'admin.php?page=plugin&section='.$found_menu['uid'] ); + die('Invalid URL - plugin '.$plugin_id.' not active'); } +$section[1]=str_replace('./', '', $section[1]); // no up in dir structure -$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin'); -?> +$filename = PHPWG_PLUGINS_PATH.$plugin_id.'/'.$section[1].'.php'; +if (is_file($filename)) +{ + include_once($filename); +} +else +{ + die('Missing '.$filename); +} +?>
\ No newline at end of file diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php index 204d4e315..ccc52d194 100644 --- a/include/functions_plugins.inc.php +++ b/include/functions_plugins.inc.php @@ -1,7 +1,7 @@ <?php // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | -// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | branch : BSF (Best So Far) // | file : $Id$ @@ -152,7 +152,6 @@ function trigger_event($event, $data=null) return $data; } - function trigger_action($event, $data=null) { global $pwg_event_handlers; @@ -195,6 +194,35 @@ function trigger_action($event, $data=null) } } +/** Saves some data with the associated plugim id. It can be retrieved later ( + * during this script lifetime) using get_plugin_data + * @param string plugin_id + * @param mixed data + * returns true on success, false otherwise + */ +function set_plugin_data($plugin_id, &$data) +{ + global $pwg_loaded_plugins; + if ( isset($pwg_loaded_plugins[$plugin_id]) ) + { + $pwg_loaded_plugins[$plugin_id]['plugin_data'] = &$data; + return true; + } + return false; +} + +/** Retrieves plugin data saved previously with set_plugin_data + * @param string plugin_id + */ +function &get_plugin_data($plugin_id) +{ + global $pwg_loaded_plugins; + if ( isset($pwg_loaded_plugins[$plugin_id]) ) + { + return $pwg_loaded_plugins[$plugin_id]['plugin_data']; + } + return null; +} /* Returns an array of plugins defined in the database * @param string $state optional filter on this state @@ -235,6 +263,8 @@ function load_plugin($plugin) $file_name = PHPWG_PLUGINS_PATH.$plugin['id'].'/main.inc.php'; if ( file_exists($file_name) ) { + global $pwg_loaded_plugins; + $pwg_loaded_plugins[ $plugin['id'] ] = $plugin; include_once( $file_name ); } } @@ -242,7 +272,8 @@ function load_plugin($plugin) /*loads all the plugins on startup*/ function load_plugins() { - global $conf; + global $conf, $pwg_loaded_plugins; + $pwg_loaded_plugins = array(); if ($conf['enable_plugins']) { $plugins = get_db_plugins('active'); diff --git a/plugins/add_index/admin/admin_menu.php b/plugins/add_index/admin/admin_menu.php index 2ab250119..62a12bab4 100644 --- a/plugins/add_index/admin/admin_menu.php +++ b/plugins/add_index/admin/admin_menu.php @@ -66,11 +66,11 @@ $template->assign_var('EVENT_TRACER_FILTERS', implode("\n", $this->my_config['fi $template->assign_var('EVENT_TRACER_SHOW_ARGS', $this->my_config['show_args'] ? 'checked="checked"' : '' );*/
$template->assign_var('filename', $conf['add_index_filename']);
$template->assign_var('source_directory_path', $conf['add_index_source_directory_path']);
-$template->assign_var('F_ACTION', $my_url);
+//$template->assign_var('F_ACTION', $my_url);
// +-----------------------------------------------------------------------+
// | Sending html code |
// +-----------------------------------------------------------------------+
-$template->assign_var_from_handle('PLUGIN_ADMIN_CONTENT', 'plugin_admin_content');
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
?>
\ No newline at end of file diff --git a/plugins/add_index/admin/admin_menu.tpl b/plugins/add_index/admin/admin_menu.tpl index b365e312f..22104d270 100644 --- a/plugins/add_index/admin/admin_menu.tpl +++ b/plugins/add_index/admin/admin_menu.tpl @@ -1,4 +1,8 @@ <!-- $Id: admin_menu.tpl Ruben ARNAUD -->
+<div class="titrePage">
+ <h2>{lang:Add_Index}</h2>
+</div>
+
<p>{lang:add_index_Description_1}</p>
<p>{lang:add_index_Description_2}</p>
diff --git a/plugins/add_index/main.admin.inc.php b/plugins/add_index/main.admin.inc.php index 24cfa1dc5..457ea760a 100644 --- a/plugins/add_index/main.admin.inc.php +++ b/plugins/add_index/main.admin.inc.php @@ -33,6 +33,7 @@ if ((!defined('PHPWG_ROOT_PATH')) or (!(defined('IN_ADMIN') and IN_ADMIN))) class AdminAddIndex extends AddIndex
{
+ var $my_id;
function load_params()
{
global $conf;
@@ -62,7 +63,7 @@ class AdminAddIndex extends AddIndex array
(
'CAPTION' => l10n('Advanced_Add_Index'),
- 'URL' => get_root_url().'admin.php?page=main_page&page_type=plugin&plugin_id=add_index&overwrite'
+ 'URL' => get_admin_plugin_menu_link($this->my_id, 'admin/main_page').'&overwrite'
));
return $advanced_features;
@@ -75,7 +76,7 @@ class AdminAddIndex extends AddIndex array_push($site_manager_plugin_links,
array
(
- 'U_HREF' => get_root_url().'admin.php?page=main_page&page_type=plugin&plugin_id=add_index&site_id='.$site_id,
+ 'U_HREF' => get_admin_plugin_menu_link($this->my_id, 'admin/main_page').'&site_id='.$site_id,
'U_CAPTION' => l10n('Manager_Add_Index'),
'U_HINT' => l10n('Add_Index')
));
@@ -84,20 +85,21 @@ class AdminAddIndex extends AddIndex return $site_manager_plugin_links;
}
- function plugin_admin_menu()
+ function plugin_admin_menu($menu)
{
- add_plugin_admin_menu(l10n('Menu_Add_Index'), array(&$this, 'do_plugin_admin_menu'));
+ array_push($menu,
+ array(
+ 'NAME' => l10n('Menu_Add_Index'),
+ 'URL' => get_admin_plugin_menu_link($this->my_id, 'admin/admin_menu')
+ )
+ );
+ return $menu;
}
-
- function do_plugin_admin_menu($my_url)
- {
- include_once(dirname(__FILE__).'/admin/'.'admin_menu.php');
- }
-
}
// Create object
$add_index = new AdminAddIndex();
+$add_index->my_id = $plugin['id'];
// Load Add Index parameters
$add_index->load_params();
@@ -106,6 +108,6 @@ $add_index->load_params(); add_event_handler('loading_lang', array(&$add_index, 'loading_lang'));
add_event_handler('get_admin_advanced_features_links', array(&$add_index, 'get_admin_advanced_features_links'));
add_event_handler('get_admins_site_links', array(&$add_index, 'get_admins_site_links'), EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
-add_event_handler('plugin_admin_menu', array(&$add_index, 'plugin_admin_menu') );
+add_event_handler('get_admin_plugin_menu_links', array(&$add_index, 'plugin_admin_menu') );
?>
\ No newline at end of file diff --git a/plugins/add_index/main.inc.php b/plugins/add_index/main.inc.php index 1f6346486..07ade8e10 100644 --- a/plugins/add_index/main.inc.php +++ b/plugins/add_index/main.inc.php @@ -49,6 +49,7 @@ if (in_array(script_basename(), array('popuphelp', 'admin'))) include_once(dirname(__FILE__).'/'.'main.base.inc.php');
include_once(dirname(__FILE__).'/'.'main.normal.inc.php');
}
+ set_plugin_data($plugin['id'], $add_index);
}
?>
\ No newline at end of file diff --git a/plugins/admin_advices/main.inc.php b/plugins/admin_advices/main.inc.php index a17f5a658..172cdf489 100644 --- a/plugins/admin_advices/main.inc.php +++ b/plugins/admin_advices/main.inc.php @@ -10,16 +10,15 @@ add_event_handler('loc_begin_page_tail', 'set_admin_advice' ); function set_admin_advice()
{
- global $page, $user, $template, $conf;
+ global $page, $user, $template, $conf;
// This Plugin works only on the Admin page
if ( isset($page['body_id']) and $page['body_id']=='theAdminPage'
- and isset($page['page']['name']) and $page['page']['name'] == 'intro'
- and isset($page['page']['type']) and $page['page']['type'] == 'standard'
+ and $page['page'] == 'intro'
)
{
- // Setup Advice Language (Maybe there is already a variable)
- $advlang = ( isset($user['language']) ) ?
+ // Setup Advice Language (Maybe there is already a variable)
+ $advlang = ( isset($user['language']) ) ?
$user['language'] : $conf['default_language']; // en_UK.iso-8859-1
$adv = array();
@@ -30,22 +29,22 @@ function set_admin_advice() // If there is an advice
if ( $cond )
- {
-// $template->set_filenames( array( 'advice' => 'admin_advices.tpl' ));
+ {
+// $template->set_filenames( array( 'advice' => 'admin_advices.tpl' ));
$template->set_filenames(array(
- 'admin_advice' =>
+ 'admin_advice' =>
PHPWG_ROOT_PATH.'/plugins/admin_advices/admin_advices.tpl')
);
-
+
// Random Thumbnail
$query = '
SELECT *
FROM '.IMAGES_TABLE.'
ORDER BY RAND(NOW())
LIMIT 0, 1
-;';
- $result = pwg_query($query);
- $row = mysql_fetch_assoc($result);
+;';
+ $result = pwg_query($query);
+ $row = mysql_fetch_assoc($result);
if ( is_array($row) )
{
$template->assign_block_vars(
@@ -56,12 +55,12 @@ SELECT * 'IMAGE_TITLE' => $row['name'],
)
);
- }
+ }
$advice_text = array_shift($adv);
$template->assign_vars(
array(
- 'ADVICE_ABOUT' => '$conf[' . "'$confk'] ",
- 'ADVICE_TEXT' => $advice_text,
+ 'ADVICE_ABOUT' => '$conf[' . "'$confk'] ",
+ 'ADVICE_TEXT' => $advice_text,
)
);
foreach ($adv as $advice)
@@ -71,8 +70,8 @@ SELECT * array(
'ADVICE' => $advice
)
- );
- }
+ );
+ }
$template->parse('admin_advice');
}
}
diff --git a/plugins/event_tracer/main.inc.php b/plugins/event_tracer/main.inc.php index fef23296a..1eb89f094 100644 --- a/plugins/event_tracer/main.inc.php +++ b/plugins/event_tracer/main.inc.php @@ -11,10 +11,12 @@ class EventTracer { var $me_working; var $my_config; - - function EventTracer() + var $my_id; + + function EventTracer($id) { $this->me_working=0; + $this->my_id=$id; } function load_config() @@ -76,23 +78,24 @@ class EventTracer } } - function plugin_admin_menu() + function plugin_admin_menu($menu) { - add_plugin_admin_menu( "Event Tracer", array(&$this, 'do_admin') ); + array_push($menu, + array( + 'NAME' => 'Event Tracer', + 'URL' => get_admin_plugin_menu_link($this->my_id, 'tracer_admin') + ) + ); + return $menu; } - - function do_admin($my_url) - { - include( dirname(__FILE__).'/tracer_admin.php' ); - } - } -$eventTracer = new EventTracer(); -$eventTracer->load_config(); +$obj = new EventTracer($plugin['id']); +$obj->load_config(); -add_event_handler('plugin_admin_menu', array(&$eventTracer, 'plugin_admin_menu') ); -add_event_handler('pre_trigger_event', array(&$eventTracer, 'on_pre_trigger_event') ); -add_event_handler('post_trigger_event', array(&$eventTracer, 'on_post_trigger_event') ); -add_event_handler('trigger_action', array(&$eventTracer, 'on_trigger_action') ); +add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') ); +add_event_handler('pre_trigger_event', array(&$obj, 'on_pre_trigger_event') ); +add_event_handler('post_trigger_event', array(&$obj, 'on_post_trigger_event') ); +add_event_handler('trigger_action', array(&$obj, 'on_trigger_action') ); +set_plugin_data($plugin['id'], $obj); ?>
\ No newline at end of file diff --git a/plugins/event_tracer/tracer_admin.php b/plugins/event_tracer/tracer_admin.php index 7371d2531..2495c0dc0 100644 --- a/plugins/event_tracer/tracer_admin.php +++ b/plugins/event_tracer/tracer_admin.php @@ -1,6 +1,8 @@ <?php if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); +$me = get_plugin_data($plugin_id); + global $template; $template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/tracer_admin.tpl') ); @@ -11,17 +13,17 @@ if ( isset($_POST['eventTracer_filters']) ) $v = str_replace( "\n\n", "\n", $v ); $v = stripslashes($v); if (!empty($v)) - $this->my_config['filters'] = explode("\n", $v); + $me->my_config['filters'] = explode("\n", $v); else - $this->my_config['filters'] = array(); - $this->my_config['show_args'] = isset($_POST['eventTracer_show_args']); - $this->save_config(); + $me->my_config['filters'] = array(); + $me->my_config['show_args'] = isset($_POST['eventTracer_show_args']); + $me->save_config(); global $page; array_push($page['infos'], 'event tracer options saved'); } -$template->assign_var('EVENT_TRACER_FILTERS', implode("\n", $this->my_config['filters'] ) ); -$template->assign_var('EVENT_TRACER_SHOW_ARGS', $this->my_config['show_args'] ? 'checked="checked"' : '' ); -$template->assign_var('EVENT_TRACER_F_ACTION', $my_url); +$template->assign_var('EVENT_TRACER_FILTERS', implode("\n", $me->my_config['filters'] ) ); +$template->assign_var('EVENT_TRACER_SHOW_ARGS', $me->my_config['show_args'] ? 'checked="checked"' : '' ); +//$template->assign_var('EVENT_TRACER_F_ACTION', $my_url); -$template->assign_var_from_handle( 'PLUGIN_ADMIN_CONTENT', 'plugin_admin_content'); +$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); ?>
\ No newline at end of file diff --git a/plugins/event_tracer/tracer_admin.tpl b/plugins/event_tracer/tracer_admin.tpl index 95ee65907..93deee3b0 100644 --- a/plugins/event_tracer/tracer_admin.tpl +++ b/plugins/event_tracer/tracer_admin.tpl @@ -1,3 +1,7 @@ +<div class="titrePage"> + <h2>Event Tracer</h2> +</div> + <p> The event tracer is a developer tool that logs in the footer of the window all calls to trigger_event method. You can use this plugin to see what events is PhpWebGallery calling. |