Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

-Activation plugins changed in the ppa config.inc.php-dist file

-Dropped function manage_translation from plugin file
-Created function get_translation in the PluginExample to get the plugins translations
-Added entry to 'pt' => 'portuguese-br' in the plugins/lang/translation.php, following the comment extracted from lang/translation.php
-Small beauty changes in the comments
-Removed some whitespaces and extra tabs
-Removed commented debug from libraries/lib.inc.php
  • Loading branch information...
commit 57e0917edb04fe02af53dd422cbb53018b1c5027 1 parent 8ccfe9f
@leonardosapiras authored
View
20 classes/plugins/PluginManager.php
@@ -15,7 +15,7 @@ class PluginManager {
public $functions_list = array();
/**
- * Add a plugin in the manager
+ * Add a plugin in the manager
* @param $plugin
*/
function add_plugin($plugin) {
@@ -31,7 +31,7 @@ function get_plugin($plugin_index) {
}
/**
- * Add a function in the $functions_list list, with the information when this function will be used by the
+ * Add a function in the $functions_list list, with the information when this function will be used by the
* phppgadmin core.
* @param $plugin_index - Index that identify the plugin. Example the plugin_example's index is plugin_example :-)
* @param $when - This identify when the added function will be called
@@ -61,5 +61,21 @@ function execute_plugin_funtions($when, &$function_args) {
}
}
}
+
+ /**
+ * Get the plugin translations
+ * @param $plugin_index - Name of the plugin index. 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($plugin_index, $language) {
+ require_once("./plugins/{$plugin_index}/lang/recoded/english.php");
+ require_once("./plugins/{$plugin_index}/lang/translations.php");
+ if (isset($pluginLangFiles[$language])) {
+ include_once("./plugins/{$plugin_index}/lang/recoded/{$language}.php");
+ }
+ return $plugin_lang;
+ }
}
?>
View
3  conf/config.inc.php-dist
@@ -151,8 +151,9 @@
$conf['ajax_refresh'] = 3;
// Plugins
+ // Add index to plugins that will be activated.
+ // Example: array('PluginExample', 'Slony', ...)
$conf['plugins'] = array();
- $conf['plugins'][] = 'PluginExample';
/*****************************************
* Don't modify anything below this line *
View
2  libraries/lib.inc.php
@@ -180,7 +180,7 @@
}
// Check if there are activated plugins
- $plugins = $conf['plugins'];//xdebug_var_dump($lang, $_language);
+ $plugins = $conf['plugins'];
require_once('./classes/plugins/PluginManager.php');
$plugin_manager = new PluginManager();
//register the plugins and their functions
View
1  plugins/PluginExample/lang/translations.php
@@ -22,6 +22,7 @@
$availableLanguages = array(
'en' => 'english',
+ 'pt' => 'portuguese-br',
'pt-br' => 'portuguese-br'
);
?>
View
17 plugins/PluginExample/plugin.php
@@ -12,10 +12,12 @@ class PluginExample {
* Constructor
* Register the plugin's functions in hooks of PPA.
* @param $plugin_manager - Instance of plugin manager
+ * @param $language Current phpPgAdmin language. If it was not found in the plugin, English will be used.
*/
function __construct($plugin_manager, $language) {
- $this->manage_transalation($language);
+ $this->plugin_lang = $plugin_manager->get_transalation($this->plugin_index, $language);
$plugin_manager->add_plugin_functions($this->plugin_index, 'toplinks', 'add_plugin_toplinks');
+
/* Register more functions here */
}
@@ -34,18 +36,5 @@ function get_plugin_index() {
function add_plugin_toplinks(&$toplinks_operations) {
$toplinks_operations[$this->plugin_index] = "<a class=\"toplink\" href=\"#\">{$this->plugin_lang['plugin_toplink']}</a>";
}
-
- /**
- * Manage the plugins translations
- * TODO: to put this function in the PluginManager class
- */
- function manage_transalation($language) {
- require_once("./plugins/{$this->plugin_index}/lang/recoded/english.php");
- include_once("./plugins/{$this->plugin_index}/lang/translations.php");
- if (isset($pluginLangFiles[$language])) {
- include_once("./plugins/{$this->plugin_index}/lang/recoded/{$language}.php");
- }
- $this->plugin_lang = $plugin_lang;
- }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.