From b3485772e6b5397bf2e37feb0a7c9254f143619d Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Thu, 22 Oct 2009 07:52:13 +0000 Subject: [PATCH] More model interface stuff - now a fully working example. --- e107_handlers/model_class.php | 35 ++++++++++++++------------- e107_plugins/release/admin_config.php | 32 ++++++------------------ 2 files changed, 26 insertions(+), 41 deletions(-) diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 2292e1551..348949914 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -9,8 +9,8 @@ * e107 Base Model * * $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $ - * $Revision: 1.18 $ - * $Date: 2009-10-22 07:23:17 $ + * $Revision: 1.19 $ + * $Date: 2009-10-22 07:52:07 $ * $Author: e107coders $ */ @@ -1621,12 +1621,16 @@ class e_model_interface $this->mode = varset($_GET['mode']) ? $_GET['mode'] : 'list'; + $column_pref_name = "admin_".$this->table."_columns"; + if(isset($_POST['submit-e-columns'])) - { - $column_pref_name = "admin_".$this->table."_columns"; + { $user_pref[$column_pref_name] = $_POST['e-columns']; save_prefs('user'); + $this->mode = 'list'; } + + $this->fieldpref = (varset($user_pref[$column_pref_name])) ? $user_pref[$column_pref_name] : array_keys($this->fields); if(varset($_POST['update']) || varset($_POST['create'])) { @@ -1666,7 +1670,8 @@ class e_model_interface $sql = e107::getDb(); $frm = e107::getForm(); $mes = e107::getMessage(); - $pref = e107::getConfig()->getPref(); + $pref = e107::getConfig()->getPref(); + $text = "
@@ -1704,6 +1709,8 @@ class e_model_interface
"; + + //TODO Auto next/prev $ns->tablerender($this->pluginTitle." :: ".$this->adminMenu['list']['caption'], $mes->render().$text); } @@ -1969,24 +1976,18 @@ class e_model_interface } - function saveSettings() // Non Functional.. needs to use native e_model functions. + function saveSettings() //TODO needs to use native e_model functions, validation etc. { global $pref, $admin_log; - $mes = e107::getMessage(); + unset($_POST['saveOptions'],$_POST['e-columns']); - $temp['listPages'] = $_POST['listPages']; - - if ($admin_log->logArrayDiffs($temp, $pref, 'CPAGE_04')) + foreach($_POST as $key=>$val) { - save_prefs(); // Only save if changes - // e107::getConfig()-> - $mes->add(LAN_SAVED, E_MESSAGE_SUCCESS); - } - else - { - $mes->add(CUSLAN_46); + e107::getConfig('core')->set($key,$val); } + + e107::getConfig('core')->save(); } diff --git a/e107_plugins/release/admin_config.php b/e107_plugins/release/admin_config.php index 27a585cc6..ce79ab8ad 100644 --- a/e107_plugins/release/admin_config.php +++ b/e107_plugins/release/admin_config.php @@ -9,8 +9,8 @@ * e107 Release Plugin * * $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $ - * $Revision: 1.5 $ - * $Date: 2009-10-22 07:23:22 $ + * $Revision: 1.6 $ + * $Date: 2009-10-22 07:52:13 $ * $Author: e107coders $ * */ @@ -21,16 +21,9 @@ require_once(e_ADMIN."auth.php"); class releasePlugin extends e_model_interface { - var $fields; - var $fieldpref; - var $listQry; - var $table; - var $primary; - function __construct() - { - + { $this->fields = array( 'release_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), @@ -40,7 +33,6 @@ class releasePlugin extends e_model_interface 'release_version' => array('title'=> 'version', 'type' => 'text', 'width' => 'auto'), 'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'), 'release_authorURL' => array('title'=> LAN_AUTHOR.'URL', 'type' => 'url', 'width' => 'auto', 'thclass' => 'left'), - 'release_date' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto'), 'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), 'release_url' => array('title'=> 'URL', 'type' => 'url', 'width' => '10%', 'thclass' => 'center' ), @@ -51,15 +43,11 @@ class releasePlugin extends e_model_interface 'pref_type' => array('title'=> 'type', 'type'=>'text'), 'pref_folder' => array('title'=> 'folder', 'type' => 'boolean'), - 'pref_name' => array('title'=> 'name', 'type' => 'text') - + 'pref_name' => array('title'=> 'name', 'type' => 'text') ); - - $this->fieldpref = (varset($user_pref['admin_release_columns'])) ? $user_pref['admin_release_columns'] : array_keys($this->fields); - + $this->listQry = "SELECT * FROM #release ORDER BY release_id DESC"; - $this->editQry = "SELECT * FROM #release WHERE release_id = {ID}"; - + $this->editQry = "SELECT * FROM #release WHERE release_id = {ID}"; $this->table = "release"; $this->primary = "release_id"; $this->pluginTitle = "e107 Release"; @@ -69,8 +57,7 @@ class releasePlugin extends e_model_interface 'create' => array('caption'=>LAN_CREATE."/".LAN_EDIT, 'perm'=>'0'), 'options' => array('caption'=>LAN_OPTIONS, 'perm'=>'0'), 'custom' => array('caption'=>'Custom Page', 'perm'=>0) - ); - + ); } // Custom View/Form-Element method. ie. Naming should match field/key with type=method. @@ -99,7 +86,6 @@ class releasePlugin extends e_model_interface $ns->tablerender("Custom","This is a custom Page"); } - } $rp = new releasePlugin; @@ -107,11 +93,9 @@ $rp->init(); require_once(e_ADMIN."footer.php"); - -function admin_config_adminmenu() +function admin_config_adminmenu() //TODO move this into e_model_interface { global $rp; - global $action; $rp->show_options($action); }