From bef0f55b53c7aa536c3b863caeee3ab9c0c5ce56 Mon Sep 17 00:00:00 2001 From: dignajar Date: Mon, 27 Jul 2015 22:01:52 -0300 Subject: [PATCH] Plugin label and position --- admin/controllers/configure-plugin.php | 8 ++------ admin/controllers/install-plugin.php | 8 ++++++-- admin/themes/default/index.php | 6 +++--- admin/views/configure-plugin.php | 5 +++++ admin/views/plugins.php | 6 ++---- kernel/abstract/plugin.class.php | 5 +++-- languages/en_US.json | 3 ++- plugins/pages/language/en_US.json | 3 +-- plugins/pages/language/fr_FR.json | 3 +-- plugins/pages/plugin.php | 11 +---------- 10 files changed, 26 insertions(+), 32 deletions(-) diff --git a/admin/controllers/configure-plugin.php b/admin/controllers/configure-plugin.php index c4f6b6ee..1eb1c411 100644 --- a/admin/controllers/configure-plugin.php +++ b/admin/controllers/configure-plugin.php @@ -17,10 +17,11 @@ if($Login->role()!=='admin') { // Main before POST // ============================================================================ $_Plugin = false; +$pluginClassName = $layout['parameters']; foreach($plugins['all'] as $P) { - if($P->className()==$layout['parameters']) { + if($P->className()==$pluginClassName) { $_Plugin = $P; } } @@ -30,11 +31,6 @@ if($_Plugin===false) { Redirect::page('admin', 'plugins'); } -// Check if the plugin has the method form. -if($_Plugin->form()===false) { - Redirect::page('admin', 'plugins'); -} - // ============================================================================ // POST Method // ============================================================================ diff --git a/admin/controllers/install-plugin.php b/admin/controllers/install-plugin.php index 6b615e82..80659233 100644 --- a/admin/controllers/install-plugin.php +++ b/admin/controllers/install-plugin.php @@ -22,7 +22,11 @@ if($Login->role()!=='admin') { // ============================================================================ $pluginClassName = $layout['parameters']; -$Plugin = new $pluginClassName; -$Plugin->install(); +foreach($plugins['all'] as $P) +{ + if($P->className()==$pluginClassName) { + $P->install(); + } +} Redirect::page('admin', 'plugins'); \ No newline at end of file diff --git a/admin/themes/default/index.php b/admin/themes/default/index.php index 85316ab8..1383815d 100644 --- a/admin/themes/default/index.php +++ b/admin/themes/default/index.php @@ -7,9 +7,9 @@ <?php echo $layout['title'] ?> - - - + + + diff --git a/admin/views/configure-plugin.php b/admin/views/configure-plugin.php index 92743329..6a75f709 100644 --- a/admin/views/configure-plugin.php +++ b/admin/views/configure-plugin.php @@ -4,6 +4,11 @@ +
+ + +
+ form(); ?> diff --git a/admin/views/plugins.php b/admin/views/plugins.php index abd8a5c2..ff85a5a4 100644 --- a/admin/views/plugins.php +++ b/admin/views/plugins.php @@ -5,14 +5,12 @@ { echo '
'; - echo '

'.$Plugin->name().' '.$Language->g('Version').': '.$Plugin->version().'

'; + echo '

'.$Plugin->name().''.$Language->g('Version').': '.$Plugin->version().'

'; echo '

'.$Plugin->description().'

'; if($Plugin->installed()) { echo ''.$Language->g('Uninstall plugin').''; - if($Plugin->form()) { - echo ''.$Language->g('Configure plugin').''; - } + echo ''.$Language->g('Configure plugin').''; } else { echo ''.$Language->g('Install plugin').''; diff --git a/kernel/abstract/plugin.class.php b/kernel/abstract/plugin.class.php index bebd3c84..914f2ecf 100644 --- a/kernel/abstract/plugin.class.php +++ b/kernel/abstract/plugin.class.php @@ -145,7 +145,7 @@ class Plugin { } // Return TRUE if the installation success, otherwise FALSE. - public function install() + public function install($position=0) { if($this->installed()) { return false; @@ -157,7 +157,8 @@ class Plugin { // Create database $Tmp = new dbJSON($this->filenameDb); $Tmp->db = $this->dbFields; - $Tmp->db['position'] = 0; + $Tmp->db['position'] = $position; + $Tmp->db['label'] = $this->name(); $Tmp->save(); return true; diff --git a/languages/en_US.json b/languages/en_US.json index 5ed0bc5c..f7b00786 100644 --- a/languages/en_US.json +++ b/languages/en_US.json @@ -130,5 +130,6 @@ "show-blog": "Show blog", "default-home-page": "Default home page", "version": "Version", - "there-are-no-drafts": "There are no drafts." + "there-are-no-drafts": "There are no drafts.", + "plugin-label": "Plugin label" } \ No newline at end of file diff --git a/plugins/pages/language/en_US.json b/plugins/pages/language/en_US.json index 3ea163e7..4ca73a5a 100755 --- a/plugins/pages/language/en_US.json +++ b/plugins/pages/language/en_US.json @@ -12,6 +12,5 @@ "pages": "Pages", "home": "Home", - "show-home-link": "Show home link", - "label-text-to-display": "Label text to display" + "show-home-link": "Show home link" } \ No newline at end of file diff --git a/plugins/pages/language/fr_FR.json b/plugins/pages/language/fr_FR.json index 82c6e5a4..dd0b3212 100755 --- a/plugins/pages/language/fr_FR.json +++ b/plugins/pages/language/fr_FR.json @@ -12,6 +12,5 @@ "pages": "Pages", "home": "Accueil", - "show-home-link": "Afficher le lien de la page d’accueil", - "label-text-to-display": "Texte à afficher" + "show-home-link": "Afficher le lien de la page d’accueil" } \ No newline at end of file diff --git a/plugins/pages/plugin.php b/plugins/pages/plugin.php index fc0379bf..20ccb3ca 100755 --- a/plugins/pages/plugin.php +++ b/plugins/pages/plugin.php @@ -5,8 +5,7 @@ class pluginPages extends Plugin { public function init() { $this->dbFields = array( - 'homeLink'=>true, - 'label'=> 'Pages' + 'homeLink'=>true ); } @@ -17,11 +16,6 @@ class pluginPages extends Plugin { $html = '
'; $html .= 'getDbField('homeLink')?'checked':'').'>'; $html .= ''; - $html .= '
'; - $html .= '
'; - $html .= ''; $html .= '
'; return $html; @@ -63,12 +57,9 @@ class pluginPages extends Plugin { } $html .= ''; } - - } $html .= ''; - $html .= '
'; $html .= '';