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
*
* $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,13 +1621,17 @@ 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']))
{
@@ -1668,6 +1672,7 @@ class e_model_interface
$mes = e107::getMessage();
$pref = e107::getConfig()->getPref();
$text = "<form method='post' action='".e_SELF."?mode=create'>
<fieldset id='core-".$this->table."-list'>
<legend class='e-hideme'>".$this->pluginTitle."</legend>
@@ -1705,6 +1710,8 @@ class e_model_interface
</form>
";
//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'];
foreach($_POST as $key=>$val)
{
e107::getConfig('core')->set($key,$val);
}
if ($admin_log->logArrayDiffs($temp, $pref, 'CPAGE_04'))
{
save_prefs(); // Only save if changes
// 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
*
* $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' ),
@@ -52,14 +44,10 @@ 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')
);
$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->table = "release";
$this->primary = "release_id";
$this->pluginTitle = "e107 Release";
@@ -70,7 +58,6 @@ class releasePlugin extends e_model_interface
'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);
}