1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

More model interface stuff - now a fully working example.

This commit is contained in:
CaMer0n
2009-10-22 07:52:13 +00:00
parent 9069a6379e
commit b3485772e6
2 changed files with 26 additions and 41 deletions

View File

@@ -9,8 +9,8 @@
* e107 Base Model * e107 Base Model
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
* $Revision: 1.18 $ * $Revision: 1.19 $
* $Date: 2009-10-22 07:23:17 $ * $Date: 2009-10-22 07:52:07 $
* $Author: e107coders $ * $Author: e107coders $
*/ */
@@ -1621,12 +1621,16 @@ class e_model_interface
$this->mode = varset($_GET['mode']) ? $_GET['mode'] : 'list'; $this->mode = varset($_GET['mode']) ? $_GET['mode'] : 'list';
$column_pref_name = "admin_".$this->table."_columns";
if(isset($_POST['submit-e-columns'])) if(isset($_POST['submit-e-columns']))
{ {
$column_pref_name = "admin_".$this->table."_columns";
$user_pref[$column_pref_name] = $_POST['e-columns']; $user_pref[$column_pref_name] = $_POST['e-columns'];
save_prefs('user'); 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'])) if(varset($_POST['update']) || varset($_POST['create']))
{ {
@@ -1666,7 +1670,8 @@ class e_model_interface
$sql = e107::getDb(); $sql = e107::getDb();
$frm = e107::getForm(); $frm = e107::getForm();
$mes = e107::getMessage(); $mes = e107::getMessage();
$pref = e107::getConfig()->getPref(); $pref = e107::getConfig()->getPref();
$text = "<form method='post' action='".e_SELF."?mode=create'> $text = "<form method='post' action='".e_SELF."?mode=create'>
<fieldset id='core-".$this->table."-list'> <fieldset id='core-".$this->table."-list'>
@@ -1704,6 +1709,8 @@ class e_model_interface
</fieldset> </fieldset>
</form> </form>
"; ";
//TODO Auto next/prev
$ns->tablerender($this->pluginTitle." :: ".$this->adminMenu['list']['caption'], $mes->render().$text); $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; global $pref, $admin_log;
$mes = e107::getMessage(); unset($_POST['saveOptions'],$_POST['e-columns']);
$temp['listPages'] = $_POST['listPages']; foreach($_POST as $key=>$val)
if ($admin_log->logArrayDiffs($temp, $pref, 'CPAGE_04'))
{ {
save_prefs(); // Only save if changes e107::getConfig('core')->set($key,$val);
// e107::getConfig()->
$mes->add(LAN_SAVED, E_MESSAGE_SUCCESS);
}
else
{
$mes->add(CUSLAN_46);
} }
e107::getConfig('core')->save();
} }

View File

@@ -9,8 +9,8 @@
* e107 Release Plugin * e107 Release Plugin
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $
* $Revision: 1.5 $ * $Revision: 1.6 $
* $Date: 2009-10-22 07:23:22 $ * $Date: 2009-10-22 07:52:13 $
* $Author: e107coders $ * $Author: e107coders $
* *
*/ */
@@ -21,16 +21,9 @@ require_once(e_ADMIN."auth.php");
class releasePlugin extends e_model_interface class releasePlugin extends e_model_interface
{ {
var $fields;
var $fieldpref;
var $listQry;
var $table;
var $primary;
function __construct() function __construct()
{ {
$this->fields = array( $this->fields = array(
'release_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), '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_version' => array('title'=> 'version', 'type' => 'text', 'width' => 'auto'),
'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'), '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_authorURL' => array('title'=> LAN_AUTHOR.'URL', 'type' => 'url', 'width' => 'auto', 'thclass' => 'left'),
'release_date' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto'), 'release_date' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto'),
'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), 'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ),
'release_url' => array('title'=> 'URL', 'type' => 'url', '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_type' => array('title'=> 'type', 'type'=>'text'),
'pref_folder' => array('title'=> 'folder', 'type' => 'boolean'), '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->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->table = "release";
$this->primary = "release_id"; $this->primary = "release_id";
$this->pluginTitle = "e107 Release"; $this->pluginTitle = "e107 Release";
@@ -69,8 +57,7 @@ class releasePlugin extends e_model_interface
'create' => array('caption'=>LAN_CREATE."/".LAN_EDIT, 'perm'=>'0'), 'create' => array('caption'=>LAN_CREATE."/".LAN_EDIT, 'perm'=>'0'),
'options' => array('caption'=>LAN_OPTIONS, 'perm'=>'0'), 'options' => array('caption'=>LAN_OPTIONS, 'perm'=>'0'),
'custom' => array('caption'=>'Custom Page', 'perm'=>0) 'custom' => array('caption'=>'Custom Page', 'perm'=>0)
); );
} }
// Custom View/Form-Element method. ie. Naming should match field/key with type=method. // 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"); $ns->tablerender("Custom","This is a custom Page");
} }
} }
$rp = new releasePlugin; $rp = new releasePlugin;
@@ -107,11 +93,9 @@ $rp->init();
require_once(e_ADMIN."footer.php"); require_once(e_ADMIN."footer.php");
function admin_config_adminmenu() //TODO move this into e_model_interface
function admin_config_adminmenu()
{ {
global $rp; global $rp;
global $action;
$rp->show_options($action); $rp->show_options($action);
} }