
Aenean ornare velit lacus, ac varius enim lorem ullamcorper dolore aliquam.
-diff --git a/bl-kernel/abstract/dblist.class.php b/bl-kernel/abstract/dblist.class.php index d51d97f2..2de37d23 100644 --- a/bl-kernel/abstract/dblist.class.php +++ b/bl-kernel/abstract/dblist.class.php @@ -65,6 +65,8 @@ class dbList extends dbJSON $this->db[$key]['name'] = $name; $this->db[$key]['list'] = array(); + + $this->sortAlphanumeric(); $this->save(); return $key; @@ -93,10 +95,18 @@ class dbList extends dbJSON unset( $this->db[$oldKey] ); } + $this->sortAlphanumeric(); $this->save(); return $newKey; } + // Sort the categories by "Natural order" + private function sortAlphanumeric() + { + // Sort key alphanumeric strings, a01, a10, b10, c02 + return ksort($this->db); + } + // Returns the name associated to the key, FALSE if the key doesn't exist public function getName($key) { @@ -108,18 +118,13 @@ class dbList extends dbJSON } // Returns an array with key=>name of the list - public function getKeyNameArray($sortAlphanumeric=true) + public function getKeyNameArray() { $tmp = array(); foreach($this->db as $key=>$fields) { $tmp[$key] = $fields['name']; } - // Sort alphanumeric strings, a01, a10, a11, a20 - if($sortAlphanumeric) { - natcasesort($tmp); - } - return $tmp; } diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 13acf26c..9c383e70 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -55,6 +55,26 @@ class Plugin { } } + public function setDb($args) + { + foreach($this->dbFields as $key=>$value) { + if( isset($args[$key]) ) { + $value = Sanitize::html( $args[$key] ); + settype($value, gettype($this->dbFields[$key])); + $this->db[$key] = $value; + } + } + + $this->save(); + } + + public function save() + { + $tmp = new dbJSON($this->filenameDb); + $tmp->db = $this->db; + $tmp->save(); + } + public function htmlPath() { return HTML_PATH_PLUGINS.$this->directoryName.'/'; @@ -86,6 +106,22 @@ class Plugin { return true; } + // Returns the value of the field from the database + // (string) $field + // (boolean) $html, TRUE returns the value sanitized, FALSE unsanitized + public function getValue($field, $html=true) + { + if( isset($this->db[$field]) ) { + if($html) { + return $this->db[$field]; + } + else { + return Sanitize::htmlDecode($this->db[$field]); + } + } + return false; + } + public function getDbField($key, $html=true) { if(isset($this->db[$key])) { @@ -103,33 +139,6 @@ class Plugin { return ''; } - public function setDb($args) - { - $tmp = $this->db; - - foreach($this->dbFields as $key=>$value) - { - if(isset($args[$key])) - { - // Sanitize value - $tmpValue = Sanitize::html( $args[$key] ); - - // Set type - settype($tmpValue, gettype($value)); - - // Set value - $tmp[$key] = $tmpValue; - } - } - - $this->db = $tmp; - - // Save db on file - $Tmp = new dbJSON($this->filenameDb); - $Tmp->db = $tmp; - $Tmp->save(); - } - public function name() { return $this->getMetadata('name'); diff --git a/bl-kernel/admin/controllers/configure-plugin.php b/bl-kernel/admin/controllers/configure-plugin.php index 60946a16..822be86b 100644 --- a/bl-kernel/admin/controllers/configure-plugin.php +++ b/bl-kernel/admin/controllers/configure-plugin.php @@ -6,7 +6,7 @@ if($Login->role()!=='admin') { Alert::set($Language->g('you-do-not-have-sufficient-permissions')); - Redirect::page('admin', 'dashboard'); + Redirect::page('dashboard'); } // ============================================================================ @@ -16,24 +16,20 @@ if($Login->role()!=='admin') { // ============================================================================ // Main before POST // ============================================================================ -$_Plugin = false; +$plugin = false; $pluginClassName = $layout['parameters']; -foreach($plugins['all'] as $P) -{ - if($P->className()==$pluginClassName) { - $_Plugin = $P; - } +// Check if the plugin exists +if( isset($plugins['all'][$pluginClassName]) ) { + $plugin = $plugins['all'][$pluginClassName]; } - -// Check if the plugin exists. -if($_Plugin===false) { - Redirect::page('admin', 'plugins'); +else { + Redirect::page('plugins'); } // Check if the plugin has the method form() -if(!method_exists($_Plugin, 'form')) { - Redirect::page('admin', 'plugins'); +if( !method_exists($plugin, 'form') ) { + Redirect::page('plugins'); } // ============================================================================ @@ -42,11 +38,16 @@ if(!method_exists($_Plugin, 'form')) { if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { - $_Plugin->setDb($_POST); + $plugin->setDb($_POST); - Theme::plugins('afterFormSave'); + // Add to syslog + $Syslog->add(array( + 'dictionaryKey'=>'plugin-configured', + 'notes'=>$plugin->name() + )); - Alert::set($Language->g('the-changes-have-been-saved')); + // Create an alert + Alert::set( $Language->g('The changes have been saved') ); } // ============================================================================ diff --git a/bl-kernel/admin/controllers/edit-page.php b/bl-kernel/admin/controllers/edit-page.php index ecc3c651..8c8babab 100644 --- a/bl-kernel/admin/controllers/edit-page.php +++ b/bl-kernel/admin/controllers/edit-page.php @@ -112,4 +112,4 @@ if( !$dbPages->exists($layout['parameters']) ) { Redirect::page('pages'); } -$page = $pagesKey[$layout['parameters']]; +$page = $pagesByKey[$layout['parameters']]; diff --git a/bl-kernel/admin/controllers/install-plugin.php b/bl-kernel/admin/controllers/install-plugin.php index e4ceeaaa..9e46e437 100644 --- a/bl-kernel/admin/controllers/install-plugin.php +++ b/bl-kernel/admin/controllers/install-plugin.php @@ -6,7 +6,7 @@ if($Login->role()!=='admin') { Alert::set($Language->g('you-do-not-have-sufficient-permissions')); - Redirect::page('admin', 'dashboard'); + Redirect::page('dashboard'); } // ============================================================================ @@ -33,4 +33,4 @@ foreach($plugins['all'] as $P) } } -Redirect::page('admin', 'plugins'); +Redirect::page('plugins'); diff --git a/bl-kernel/admin/controllers/plugins.php b/bl-kernel/admin/controllers/plugins.php index 9297c685..554fb3ea 100644 --- a/bl-kernel/admin/controllers/plugins.php +++ b/bl-kernel/admin/controllers/plugins.php @@ -6,7 +6,7 @@ if($Login->role()!=='admin') { Alert::set($Language->g('you-do-not-have-sufficient-permissions')); - Redirect::page('admin', 'dashboard'); + Redirect::page('dashboard'); } // ============================================================================ diff --git a/bl-kernel/admin/controllers/uninstall-plugin.php b/bl-kernel/admin/controllers/uninstall-plugin.php index 6e32daf5..4052eb76 100644 --- a/bl-kernel/admin/controllers/uninstall-plugin.php +++ b/bl-kernel/admin/controllers/uninstall-plugin.php @@ -6,7 +6,7 @@ if($Login->role()!=='admin') { Alert::set($Language->g('you-do-not-have-sufficient-permissions')); - Redirect::page('admin', 'dashboard'); + Redirect::page('dashboard'); } // ============================================================================ @@ -29,4 +29,4 @@ $pluginClassName = $layout['parameters']; $Plugin = new $pluginClassName; $Plugin->uninstall(); -Redirect::page('admin', 'plugins'); +Redirect::page('plugins'); diff --git a/bl-kernel/admin/views/configure-plugin.php b/bl-kernel/admin/views/configure-plugin.php index 564270eb..c684023f 100644 --- a/bl-kernel/admin/views/configure-plugin.php +++ b/bl-kernel/admin/views/configure-plugin.php @@ -1,6 +1,6 @@ $_Plugin->name(), 'icon'=>'puzzle-piece')); +HTML::title(array('title'=>$plugin->name(), 'icon'=>'puzzle-piece')); HTML::formOpen(array('id'=>'jsformplugin')); @@ -11,7 +11,7 @@ HTML::formOpen(array('id'=>'jsformplugin')); )); // Print the plugin form - echo $_Plugin->form(); + echo $plugin->form(); // Form buttons echo '