Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: leonardosapiras/phppgadmin
...
head fork: leonardosapiras/phppgadmin
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 24, 2011
@leonardosapiras Updated code in the PluginManager constructor
-Merged $lang['strpluginnotfound'] with $lang['strpluginnotfoundcomplem'].
-Regenated translations.
-Exit the code when a given plugin doen't exist.
c717532
@leonardosapiras Dealing with Plugin
-Moved the code from PluginManager->get_translation() to Exemple's contruct, with some changes.
-Dropped PluginManager->get_translation().
2e18ebd
Commits on May 26, 2011
@leonardosapiras Code refactor
-Removed some useless code.
-Moved some code from Example/plugin.php to PluginManager.php.
e727129
View
2  classes/Misc.php
@@ -1089,7 +1089,7 @@ function printTopbar() {
$toplinks[] = "<a class=\"toplink\" href=\"{$sql_url}find\" target=\"sqledit\" onclick=\"window.open('{$sql_url}find','{$sql_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus(); return false;\">{$lang['strfind']}</a>";
/* TOPLINK HOOK'S PLACE */
$plugin_functions_parameters = array(
- 'toplinks' => &$toplinks, //the array of toplinks is passed by reference.
+ 'toplinks' => &$toplinks,
'href' => $this->href
);
/* * */
View
28 classes/PluginManager.php
@@ -30,10 +30,8 @@ function __construct($language) {
include_once($plugin_file);
$plugin = new $activated_plugin($this, $language);
} else {
- //TODO: create a HTML.
printf($lang['strpluginnotfound']."\t\n", $activated_plugin);
- printf($lang['strpluginnotfoundcomplem']);
- // TODO: exit??
+ exit;
}
}
}
@@ -41,10 +39,8 @@ function __construct($language) {
/**
* Add a plugin in the list of plugins to manage
* @param $plugin - Instance from plugin
- * @param $hooks - Array with functions and the places where they will hook. The default value is an empty array.
- * @param $actions - Array with functions that the plugin will use as actions. The default value is an empty array.
*/
- function add_plugin($plugin, $hooks = array(), $actions = array()) {
+ function add_plugin($plugin) {
//The $name is the identification of the plugin.
//Example: PluginExample is the identification for PluginExample
//It will be used to get a specific plugin from the plugins_list.
@@ -52,11 +48,13 @@ function add_plugin($plugin, $hooks = array(), $actions = array()) {
$this->plugins_list[$plugin_name] = $plugin;
//Register the plugin's functions
+ $hooks = $plugin->get_hooks(); //TODO: validate if the plugin has the get_hooks method?
foreach ($hooks as $hook => $functions) {
$this->functions_list['hooks'][$hook][$plugin_name] = $functions;
}
//Register the plugin's actions
+ $actions = $plugin->get_actions();
$this->functions_list['actions'][$plugin_name] = $actions;
}
@@ -72,7 +70,6 @@ function get_plugin($name) {
} else {
// Show an error and stop the application
printf($lang['strpluginnotfound']."\t\n", $name);
- printf($lang['strpluginnotfoundcomplem']);
exit;
}
}
@@ -88,7 +85,7 @@ function execute_plugin_funtions($hook, &$function_args) {
if (isset($this->functions_list['hooks'][$hook])) {
foreach ($this->functions_list['hooks'][$hook] as $plugin_name => $functions) {
foreach ($functions as $function) {
- $plugin = $this->get_plugin($plugin_name);
+ $plugin = $this->plugins_list[$plugin_name];
if (method_exists($plugin, $function)) {
call_user_func_array(array($plugin, $function), array(&$function_args));
}
@@ -98,21 +95,6 @@ function execute_plugin_funtions($hook, &$function_args) {
}
/**
- * Get the plugin translations
- * @param $name - Plugin's name. Example: PluginExample, Crud, etc...
- * @param $language - Current phpPgAdmin language. If it was not found in the plugin, English will be used.
- *
- * TODO: check if an english translation file exists. If not, to think a way to alert about it.
- */
- function get_transalation($name, $language) {
- require_once("./plugins/{$name}/lang/recoded/english.php");
- if (file_exists("./plugins/{$name}/lang/recoded/{$language}.php")) {
- include_once("./plugins/{$name}/lang/recoded/{$language}.php");
- }
- return $plugin_lang;
- }
-
- /**
* Execute a plugin's action
* @param $action - action that will be executed. The action is the name of a plugin's function.
*/
View
3  lang/english.php
@@ -912,7 +912,6 @@
$lang['strftscantparsercopy'] = 'Can\'t specify both parser and template during text search configuration creation.';
//Plugins
- $lang['strpluginnotfound'] = 'Error: plugin \'%s\' not found. Check if this plugin exists in the plugins/ directory, or if this plugins has a plugin.php file.';
- $lang['strpluginnotfoundcomplem'] = 'Plugin\'s names are case sensitive';
+ $lang['strpluginnotfound'] = 'Error: plugin \'%s\' not found. Check if this plugin exists in the plugins/ directory, or if this plugins has a plugin.php file. Plugin\'s names are case sensitive';
$lang['stractionnotfound'] = 'Error: action \'%s\' not found in the \'%s\' plugin, or it was not specified as an action.';
?>
View
3  lang/portuguese-br.php
@@ -912,7 +912,6 @@
$lang['strftscantparsercopy'] = 'Não é possível especificar ambos parser e modelo durante a criação da configuração de busca de texto.';
//Plugins
- $lang['strpluginnotfound'] = 'Erro: plugin \'%s\' não encontrado. Verifique se esse plugin existe no diretório plugins/, ou se esse plugin contém um arquivo plugin.php';
- $lang['strpluginnotfoundcomplem'] = 'Os nomes dos plugins são case sensitive';
+ $lang['strpluginnotfound'] = 'Erro: plugin \'%s\' não encontrado. Verifique se esse plugin existe no diretório plugins/, ou se esse plugin contém um arquivo plugin.php. Os nomes dos plugins são case sensitive.';
$lang['stractionnotfound'] = 'Erro: ação \'%s\' não encontrada no plugin \'%s\'.';
?>
View
3  lang/recoded/english.php
@@ -912,7 +912,6 @@
$lang['strftscantparsercopy'] = 'Can\'t specify both parser and template during text search configuration creation.';
//Plugins
- $lang['strpluginnotfound'] = 'Error: plugin \'%s\' not found. Check if this plugin exists in the plugins/ directory, or if this plugins has a plugin.php file.';
- $lang['strpluginnotfoundcomplem'] = 'Plugin\'s names are case sensitive';
+ $lang['strpluginnotfound'] = 'Error: plugin \'%s\' not found. Check if this plugin exists in the plugins/ directory, or if this plugins has a plugin.php file. Plugin\'s names are case sensitive';
$lang['stractionnotfound'] = 'Error: action \'%s\' not found in the \'%s\' plugin, or it was not specified as an action.';
?>
View
3  lang/recoded/portuguese-br.php
@@ -912,7 +912,6 @@
$lang['strftscantparsercopy'] = 'N&#227;o &#233; poss&#237;vel especificar ambos parser e modelo durante a cria&#231;&#227;o da configura&#231;&#227;o de busca de texto.';
//Plugins
- $lang['strpluginnotfound'] = 'Erro: plugin \'%s\' n&#227;o encontrado. Verifique se esse plugin existe no diret&#243;rio plugins/, ou se esse plugin cont&#233;m um arquivo plugin.php';
- $lang['strpluginnotfoundcomplem'] = 'Os nomes dos plugins s&#227;o case sensitive';
+ $lang['strpluginnotfound'] = 'Erro: plugin \'%s\' n&#227;o encontrado. Verifique se esse plugin existe no diret&#243;rio plugins/, ou se esse plugin cont&#233;m um arquivo plugin.php. Os nomes dos plugins s&#227;o case sensitive.';
$lang['stractionnotfound'] = 'Erro: a&#231;&#227;o \'%s\' n&#227;o encontrada no plugin \'%s\'.';
?>
View
11 plugins/Example/plugin.php
@@ -14,8 +14,15 @@ class Example {
* @param $language Current phpPgAdmin language. If it was not found in the plugin, English will be used.
*/
function __construct($plugin_manager, $language) {
- $this->lang = $plugin_manager->get_transalation($this->name, $language);
- $plugin_manager->add_plugin($this, $this->get_hooks(), $this->get_actions());
+ // Set the plugin's language
+ $lang_directory = dirname(__FILE__)."/lang/recoded";
+ require_once("$lang_directory/english.php");
+ if (file_exists("$lang_directory/$language.php")) {
+ include_once("$lang_directory/$language.php");
+ }
+ $this->lang = $plugin_lang;
+
+ $plugin_manager->add_plugin($this);
}
/**

No commit comments for this range

Something went wrong with that request. Please try again.