From 4489066c982c1044028295164ec2f2e840c16881 Mon Sep 17 00:00:00 2001 From: rub Date: Mon, 8 Jan 2007 00:16:10 +0000 Subject: Feature Issue ID 0000496: Integrate MOD add_index on PWG with plugin.lang.php Add some plugin triggers: o for help o for language o for site manager o for advanced features Allow to launch directly plugin page (without section key) Add add_index plugin, available on site manager and advanced features Configuration page and best help must be coming soon. git-svn-id: http://piwigo.org/svn/trunk@1699 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin.php | 81 +++++++- admin/advanced_feature.php | 63 ++++-- .../include/functions_notification_by_mail.inc.php | 3 +- admin/plugins.php | 10 +- admin/site_manager.php | 18 +- include/common.inc.php | 1 + include/functions.inc.php | 1 + include/functions_plugins.inc.php | 2 +- include/functions_user.inc.php | 15 +- .../en_UK.iso-8859-1/help/advanced_feature.html | 2 +- language/en_UK.iso-8859-1/help/remote_site.html | 51 ----- language/en_UK.iso-8859-1/help/site_manager.html | 51 +++++ .../fr_FR.iso-8859-1/help/advanced_feature.html | 6 +- language/fr_FR.iso-8859-1/help/remote_site.html | 56 ------ language/fr_FR.iso-8859-1/help/site_manager.html | 56 ++++++ nbm.php | 4 + plugins/add_index/admin/main_page.php | 220 +++++++++++++++++++++ plugins/add_index/admin/main_page.tpl | 14 ++ plugins/add_index/index.php | 35 ++++ .../en_UK.iso-8859-1/help/advanced_feature.html | 7 + .../language/en_UK.iso-8859-1/help/index.php | 35 ++++ .../en_UK.iso-8859-1/help/site_manager.html | 7 + .../add_index/language/en_UK.iso-8859-1/index.php | 35 ++++ .../language/en_UK.iso-8859-1/plugin.lang.php | 44 +++++ .../fr_FR.iso-8859-1/help/advanced_feature.html | 7 + .../language/fr_FR.iso-8859-1/help/index.php | 35 ++++ .../fr_FR.iso-8859-1/help/site_manager.html | 7 + .../add_index/language/fr_FR.iso-8859-1/index.php | 35 ++++ .../language/fr_FR.iso-8859-1/plugin.lang.php | 44 +++++ plugins/add_index/language/index.php | 35 ++++ plugins/add_index/main.admin.inc.php | 78 ++++++++ plugins/add_index/main.inc.php | 74 +++++++ plugins/admin_advices/main.inc.php | 4 +- popuphelp.php | 33 +++- template/yoga/admin/advanced_feature.tpl | 8 +- template/yoga/admin/site_manager.tpl | 6 + 36 files changed, 1036 insertions(+), 147 deletions(-) delete mode 100644 language/en_UK.iso-8859-1/help/remote_site.html create mode 100644 language/en_UK.iso-8859-1/help/site_manager.html delete mode 100644 language/fr_FR.iso-8859-1/help/remote_site.html create mode 100644 language/fr_FR.iso-8859-1/help/site_manager.html create mode 100644 plugins/add_index/admin/main_page.php create mode 100644 plugins/add_index/admin/main_page.tpl create mode 100644 plugins/add_index/index.php create mode 100644 plugins/add_index/language/en_UK.iso-8859-1/help/advanced_feature.html create mode 100644 plugins/add_index/language/en_UK.iso-8859-1/help/index.php create mode 100644 plugins/add_index/language/en_UK.iso-8859-1/help/site_manager.html create mode 100644 plugins/add_index/language/en_UK.iso-8859-1/index.php create mode 100644 plugins/add_index/language/en_UK.iso-8859-1/plugin.lang.php create mode 100644 plugins/add_index/language/fr_FR.iso-8859-1/help/advanced_feature.html create mode 100644 plugins/add_index/language/fr_FR.iso-8859-1/help/index.php create mode 100644 plugins/add_index/language/fr_FR.iso-8859-1/help/site_manager.html create mode 100644 plugins/add_index/language/fr_FR.iso-8859-1/index.php create mode 100644 plugins/add_index/language/fr_FR.iso-8859-1/plugin.lang.php create mode 100644 plugins/add_index/language/index.php create mode 100644 plugins/add_index/main.admin.inc.php create mode 100644 plugins/add_index/main.inc.php diff --git a/admin.php b/admin.php index a7830ba9c..b5165257d 100644 --- a/admin.php +++ b/admin.php @@ -54,15 +54,66 @@ check_conf(); // | variables init | // +-----------------------------------------------------------------------+ -if (isset($_GET['page']) +unset($page['page']); + +if + ( + isset($_GET['page']) and preg_match('/^[a-z_]*$/', $_GET['page']) - and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php')) + ) { - $page['page'] = $_GET['page']; + 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('', $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); + } } -else + +if (!isset($page['page'])) { - $page['page'] = 'intro'; + 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['errors'] = array(); @@ -135,7 +186,25 @@ if ($conf['allow_random_representative']) // required before plugin page inclusion trigger_action('plugin_admin_menu'); -include(PHPWG_ROOT_PATH.'admin/'.$page['page'].'.php'); +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', diff --git a/admin/advanced_feature.php b/admin/advanced_feature.php index a178b50f1..f8991ff07 100644 --- a/admin/advanced_feature.php +++ b/admin/advanced_feature.php @@ -2,7 +2,7 @@ // +-----------------------------------------------------------------------+ // | PhpWebGallery - a PHP based picture gallery | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | -// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | +// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | // +-----------------------------------------------------------------------+ // | branch : BSF (Best So Far) // | file : $RCSfile$ @@ -36,7 +36,7 @@ if (!defined('PHPWG_ROOT_PATH')) check_status(ACCESS_ADMINISTRATOR); // +-----------------------------------------------------------------------+ -// | actions | +// | Actions | // +-----------------------------------------------------------------------+ /*$action = (isset($_GET['action']) and !is_adviser()) ? $_GET['action'] : ''; @@ -54,25 +54,64 @@ switch ($action) }*/ // +-----------------------------------------------------------------------+ -// | template init | +// | Define advanced features | +// +-----------------------------------------------------------------------+ + +$advanced_features = array(); + +// Add advanced features +/*array_push($advanced_features, + array + ( + 'CAPTION' => l10n('???'), + 'URL' => $start_url.'???' + ));*/ + +array_push($advanced_features, + array + ( + 'CAPTION' => l10n('Elements_not_linked'), + 'URL' => get_root_url().'admin.php?page=element_set&cat=not_linked' + )); + +array_push($advanced_features, + array + ( + 'CAPTION' => l10n('Duplicates'), + 'URL' => get_root_url().'admin.php?page=element_set&cat=duplicates' + )); + +//$advanced_features is array of array composed of CAPTION & URL +$advanced_features = + trigger_event('array_advanced_features', $advanced_features); + +// +-----------------------------------------------------------------------+ +// | Template init | // +-----------------------------------------------------------------------+ $template->set_filenames(array('advanced_feature'=>'admin/advanced_feature.tpl')); -$start_url = PHPWG_ROOT_PATH.'admin.php?page=advanced_feature&action='; +$start_url = get_root_url().'admin.php?page=advanced_feature&action='; $template->assign_vars( - array( -// 'U_ADV_????' => $start_url.'???', - 'U_ADV_ELEMENT_NOT_LINKED' => PHPWG_ROOT_PATH.'admin.php?page=element_set&cat=not_linked', - 'U_ADV_DUP_FILES' => PHPWG_ROOT_PATH.'admin.php?page=element_set&cat=duplicates', - 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=advanced_feature' - ) - ); + array + ( + 'U_HELP' => get_root_url().'popuphelp.php?page=advanced_feature' + )); + +// advanced_features +if (count($advanced_features) > 0) +{ + foreach ($advanced_features as $advanced_feature) + { + $template->assign_block_vars('advanced_features.advanced_feature', $advanced_feature); + } +} // +-----------------------------------------------------------------------+ -// | sending html code | +// | Sending html code | // +-----------------------------------------------------------------------+ $template->assign_var_from_handle('ADMIN_CONTENT', 'advanced_feature'); + ?> diff --git a/admin/include/functions_notification_by_mail.inc.php b/admin/include/functions_notification_by_mail.inc.php index 13113da28..29ec90372 100644 --- a/admin/include/functions_notification_by_mail.inc.php +++ b/admin/include/functions_notification_by_mail.inc.php @@ -254,10 +254,11 @@ function set_user_id_on_env_nbm($user_id) // language files include(get_language_filepath('common.lang.php')); - @include(get_language_filepath('local.lang.php')); // No test admin because script is checked admin (user selected no) // Translations are in admin file too include(get_language_filepath('admin.lang.php')); + trigger_action('loading_lang'); + @include(get_language_filepath('local.lang.php')); } } diff --git a/admin/plugins.php b/admin/plugins.php index e8f2c2a5a..d58e25a64 100644 --- a/admin/plugins.php +++ b/admin/plugins.php @@ -42,7 +42,15 @@ $my_base_url = PHPWG_ROOT_PATH.'admin.php?page=plugins'; // +-----------------------------------------------------------------------+ if ( isset($_REQUEST['action']) and isset($_REQUEST['plugin']) ) { - $plugin_id = $_REQUEST['plugin']; + if (function_exists('mysql_real_escape_string')) + { + $plugin_id = mysql_real_escape_string($_REQUEST['plugin']); + } + else + { + $plugin_id = mysql_escape_string($_REQUEST['plugin']); + } + $crt_db_plugin = get_db_plugins('', $plugin_id); if (!empty($crt_db_plugin)) { diff --git a/admin/site_manager.php b/admin/site_manager.php index aa0ad5f31..53330d7f9 100644 --- a/admin/site_manager.php +++ b/admin/site_manager.php @@ -205,7 +205,7 @@ SELECT galleries_url } $template->assign_vars( array( - 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=remote_site', + 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=site_manager', 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php' .get_query_string_diff( array('action','site') ) ) ); @@ -293,6 +293,22 @@ while ($row = mysql_fetch_array($result)) ) ); } + + $plugin_links = array(); + //$plugin_links is array of array composed of U_HREF, U_HINT & U_CAPTION + $plugin_links = + trigger_event('array_site_manager_plugin_links', + $plugin_links, $row['id'], $is_remote); + + // plugin_links + if (count($plugin_links) > 0) + { + foreach ($plugin_links as $plugin_link) + { + $template->assign_block_vars('sites.site.plugin_links.plugin_link', $plugin_link); + } + } + } if ( isset($local_listing_site_url) and !isset($local_listing_site_id) ) diff --git a/include/common.inc.php b/include/common.inc.php index 07d73ee6c..01e6869e1 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -149,6 +149,7 @@ if (defined('IN_ADMIN') and IN_ADMIN) { include_once(get_language_filepath('admin.lang.php')); } +trigger_action('loading_lang'); @include_once(get_language_filepath('local.lang.php')); // only now we can set the localized username of the guest user (and not in diff --git a/include/functions.inc.php b/include/functions.inc.php index 3593652e0..3a3ee5259 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -640,6 +640,7 @@ function redirect_html( $url , $msg = '', $refresh_time = 0) { $user = build_user( $conf['guest_id'], true); include_once(get_language_filepath('common.lang.php')); + trigger_action('loading_lang'); @include_once(get_language_filepath('local.lang.php')); list($tmpl, $thm) = explode('/', $conf['default_template']); $template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm); diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php index 3eda2e3f8..204d4e315 100644 --- a/include/functions_plugins.inc.php +++ b/include/functions_plugins.inc.php @@ -33,7 +33,7 @@ register their functions to handle these events. An event is identified by a string. */ -define('PHPWG_PLUGINS_PATH',PHPWG_ROOT_PATH.'plugins/'); +define('PHPWG_PLUGINS_PATH', PHPWG_ROOT_PATH.'plugins/'); define('EVENT_HANDLER_PRIORITY_NEUTRAL', 50); diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index dba5072fb..5499eb86c 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -821,19 +821,26 @@ SELECT name * PhpWebGallery default language. * * @param string filename + * @param string dirname * @return string filepath */ -function get_language_filepath($filename) +function get_language_filepath($filename, $dirname = '') { global $user, $conf; + if (empty($dirname)) + { + $dirname = PHPWG_ROOT_PATH; + } + $dirname .= 'language'.'/'; + $directories = array(); if ( isset($user['language']) ) { - $directories[] = PHPWG_ROOT_PATH.'language/'.$user['language']; + $directories[] = $dirname.$user['language']; } - $directories[] = PHPWG_ROOT_PATH.'language/'.$conf['default_language']; - $directories[] = PHPWG_ROOT_PATH.'language/'.PHPWG_DEFAULT_LANGUAGE; + $directories[] = $dirname.$conf['default_language']; + $directories[] = $dirname.PHPWG_DEFAULT_LANGUAGE; foreach ($directories as $directory) { diff --git a/language/en_UK.iso-8859-1/help/advanced_feature.html b/language/en_UK.iso-8859-1/help/advanced_feature.html index 821604712..59b28616e 100644 --- a/language/en_UK.iso-8859-1/help/advanced_feature.html +++ b/language/en_UK.iso-8859-1/help/advanced_feature.html @@ -1,6 +1,6 @@

Advanced features

-

List special functionnalties for expert PWG administrator.

+

List special functionnalties for expert PWG administrator: