Plugins: new way of adding links and content to administration pages...

git-svn-id: http://piwigo.org/svn/trunk@1705 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2007-01-09 11:38:54 +00:00
parent c841c568f6
commit b910549db2
12 changed files with 150 additions and 200 deletions
+2 -2
View File
@@ -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');
?>
+4
View File
@@ -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>
+13 -11
View File
@@ -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&amp;page_type=plugin&amp;plugin_id=add_index&amp;overwrite'
'URL' => get_admin_plugin_menu_link($this->my_id, 'admin/main_page').'&amp;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&amp;page_type=plugin&amp;plugin_id=add_index&amp;site_id='.$site_id,
'U_HREF' => get_admin_plugin_menu_link($this->my_id, 'admin/main_page').'&amp;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') );
?>
+1
View File
@@ -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);
}
?>
+16 -17
View File
@@ -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');
}
}
+19 -16
View File
@@ -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);
?>
+10 -8
View File
@@ -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');
?>
+4
View File
@@ -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.