diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 4286a8398..2292e1551 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.17 $ - * $Date: 2009-10-22 05:14:07 $ + * $Revision: 1.18 $ + * $Date: 2009-10-22 07:23:17 $ * $Author: e107coders $ */ @@ -1607,7 +1607,7 @@ class e_model_interface var $listQry; var $table; var $primary; - var $mode; // to work with $_GET and admin menu. + var $mode; // as found in the URL query. $_GET['mode] function __construct() { @@ -1617,32 +1617,9 @@ class e_model_interface function init() { - global $user_pref; + global $user_pref; // e107::getConfig('user') ?? - if(varset($_POST['update']) || varset($_POST['create'])) - { - - $id = intval($_POST['record_id']); - $this->submitPage($id); - } - - if(varset($_POST['delete'])) - { - $id = key($_POST['delete']); - $this->deleteRecord($id); - $_GET['mode'] = "list"; - } - - if(varset($_GET['mode'])=='create') - { - $id = varset($_POST['edit']) ? key($_POST['edit']) : ""; - $this->createRecord($id); - } - else - { - $this->listRecords(); - } - //TODO add options 'preferences page'. + $this->mode = varset($_GET['mode']) ? $_GET['mode'] : 'list'; if(isset($_POST['submit-e-columns'])) { @@ -1650,26 +1627,49 @@ class e_model_interface $user_pref[$column_pref_name] = $_POST['e-columns']; save_prefs('user'); } + + if(varset($_POST['update']) || varset($_POST['create'])) + { + + $id = intval($_POST['record_id']); + $this->saveRecord($id); + } + + if(varset($_POST['delete'])) + { + $id = key($_POST['delete']); + $this->deleteRecord($id); + $this->mode = "list"; + } + + if(varset($_POST['saveOptions'])) + { + $this->saveSettings(); + } + + if($this->mode) + { + $method = $this->mode."Page"; + $this->$method(); + } + } /** * Generic DB Record Listing Function. - * @param object $mode [optional] * @return */ - function listRecords($mode=FALSE) + function listPage() { $ns = e107::getRender(); $sql = e107::getDb(); $frm = e107::getForm(); $mes = e107::getMessage(); - - global $pref; - + $pref = e107::getConfig()->getPref(); $text = "
-
+
".$this->pluginTitle." ". $frm->colGroup($this->fields,$this->fieldpref). @@ -1680,7 +1680,7 @@ class e_model_interface if(!$sql->db_Select_gen($this->listQry)) { - $text .= "\n\n"; + $text .= "\n\n"; } else { @@ -1714,9 +1714,11 @@ class e_model_interface * @param object $id [optional] * @return */ - function createRecord($id=FALSE) + function createPage() { global $e_userclass, $e_event; + + $id = varset($_POST['edit']) ? key($_POST['edit']) : ""; $tp = e107::getParser(); $ns = e107::getRender(); @@ -1788,13 +1790,13 @@ class e_model_interface * @param object $id [optional] * @return */ - function submitPage($id=FALSE) + function saveRecord($id=FALSE) { global $e107cache, $admin_log, $e_event; - $emessage = eMessage::getInstance(); + $sql = e107::getDb(); $tp = e107::getParser(); - + $mes = e107::getMessage(); $insert_array = array(); @@ -1822,11 +1824,11 @@ class e_model_interface } - $emessage->add($message, $status); + $mes->add($message, $status); } /** - * Generic Save DB Record Function. + * Generic Delete DB Record Function. * @param object $id * @return */ @@ -1837,13 +1839,13 @@ class e_model_interface return; } - $emessage = eMessage::getInstance(); + $mes = e107::getMessage(); $sql = e107::getDb(); $query = $this->primary." = ".$id; $status = $sql->db_Delete($this->table,$query) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED; $message = LAN_DELETED; - $emessage->add($message, $status); + $mes->add($message, $status); } @@ -1858,7 +1860,7 @@ class e_model_interface { $frm = e107::getForm(); - $att = $this->fields[$key]; + $att = ($this->mode == 'options') ? $this->prefs[$key] : $this->fields[$key]; $value = $row[$key]; if($att['type']=='method') @@ -1867,6 +1869,11 @@ class e_model_interface return $this->$meth($value); } + if($att['type']=='boolean') + { + return $frm->radio_switch($key, $row[$key]); + } + return $frm->text($key, $row[$key], 50); } @@ -1884,6 +1891,14 @@ class e_model_interface { $att = $this->fields[$key]; //TODO add checkbox. + + if($att['type']=='method') + { + $meth = $key; + return $this->$meth($row[$key]); + } + + if($key == "options") { $id = $this->primary; @@ -1906,6 +1921,76 @@ class e_model_interface } + /** + * Generic Options/Preferences Form. + * @return + */ + function optionsPage() + { + $pref = e107::getConfig()->getPref(); + $frm = e107::getForm(); + $ns = e107::getRender(); + $mes = e107::getMessage(); + + //XXX Lan - Options + $text = " + +
+ ".LAN_OPTIONS." +
".CUSLAN_42."
".LAN_NO_RECORDS."
+ + + + + \n"; + + + foreach($this->prefs as $key => $var) + { + $text .= " + + + + \n"; + } + + $text .= " +
".$var['title']." + ".$this->renderElement($key,$pref)." +
+
+ ".$frm->admin_button('saveOptions', LAN_SAVE, 'submit')." +
+
+ + "; + + $ns->tablerender($this->pluginTitle." :: ".LAN_OPTIONS, $mes->render().$text); + } + + + function saveSettings() // Non Functional.. needs to use native e_model functions. + { + global $pref, $admin_log; + + $mes = e107::getMessage(); + + $temp['listPages'] = $_POST['listPages']; + + 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); + } + } + + + /** * Generic Admin Menu Generator * @param object $action diff --git a/e107_plugins/release/admin_config.php b/e107_plugins/release/admin_config.php index e4c993509..27a585cc6 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.4 $ - * $Date: 2009-10-22 05:14:11 $ + * $Revision: 1.5 $ + * $Date: 2009-10-22 07:23:22 $ * $Author: e107coders $ * */ @@ -19,8 +19,7 @@ require_once("../../class2.php"); if (!getperms("P")) { header("location:".e_BASE."index.php"); exit; } require_once(e_ADMIN."auth.php"); - -class efeed extends e_model_interface +class releasePlugin extends e_model_interface { var $fields; var $fieldpref; @@ -33,6 +32,7 @@ class efeed extends e_model_interface { $this->fields = array( + 'release_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE, 'primary'=>TRUE), 'release_type' => array('title'=> 'type', 'type' => 'method', 'width'=>'auto'), 'release_folder' => array('title'=> 'folder', 'type' => 'text', 'width' => 'auto'), // User name @@ -47,10 +47,11 @@ class efeed extends e_model_interface 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last') ); - $this->prefs = array( + $this->prefs = array( //TODO add option for core or plugin pref. + 'pref_type' => array('title'=> 'type', 'type'=>'text'), - 'pref_folder' => array('title'=> 'folder', 'type' => 'text', 'width' => 'auto'), // User name - 'pref_name' => array('title'=> 'name', 'type' => 'text', 'width' => 'auto'), + 'pref_folder' => array('title'=> 'folder', 'type' => 'boolean'), + 'pref_name' => array('title'=> 'name', 'type' => 'text') ); @@ -65,14 +66,21 @@ class efeed extends e_model_interface $this->adminMenu = array( 'list' => array('caption'=>'Release List', 'perm'=>'0'), - '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'), + 'custom' => array('caption'=>'Custom Page', 'perm'=>0) ); } - // custom method. (matches field/key name) + // Custom View/Form-Element method. ie. Naming should match field/key with type=method. function release_type($curVal) { + if($this->mode == 'list') + { + return $curVal; + } + $types = array("theme","plugin"); $text = ""; return $text; } - - - //TODO move this to the model class.. and make generic. - function optionsPage() + + //custom Page = Naming should match $this->adminMenu key + 'Page'. + function customPage() { - global $e107, $pref,$emessage; - - $frm = e107::getForm(); - - - if(!isset($pref['pageCookieExpire'])) $pref['pageCookieExpire'] = 84600; - - //XXX Lan - Options - $text = " -
-
- ".LAN_OPTIONS." - - - - - - - - - - - - - - - - -
".CUSLAN_29." - ".$frm->radio_switch('listPages', $pref['listPages'])." -
".CUSLAN_30." - ".$frm->text('pageCookieExpire', $pref['pageCookieExpire'], 10)." -
-
- ".$frm->admin_button('saveOptions', CUSLAN_40, 'submit')." -
-
-
- "; - - $e107->ns->tablerender(LAN_OPTIONS, $emessage->render().$text); + $ns = e107::getRender(); + $ns->tablerender("Custom","This is a custom Page"); } - function saveSettings() - { - global $pref, $admin_log, $emessage; - $temp['listPages'] = $_POST['listPages']; - $temp['pageCookieExpire'] = $_POST['pageCookieExpire']; - if ($admin_log->logArrayDiffs($temp, $pref, 'CPAGE_04')) - { - save_prefs(); // Only save if changes - $emessage->add(CUSLAN_45, E_MESSAGE_SUCCESS); - } - else - { - $emessage->add(CUSLAN_46); - } - } - - - } - -$ef = new efeed; -$ef->init(); - - - - +$rp = new releasePlugin; +$rp->init(); require_once(e_ADMIN."footer.php"); - - function admin_config_adminmenu() { - global $ef; + global $rp; global $action; - $ef->show_options($action); + $rp->show_options($action); } -/** - * Handle page DOM within the page header - * - * @return string JS source - */ -function headerjs() -{ - require_once(e_HANDLER.'js_helper.php'); - $ret = " - - - "; - - return $ret; -} ?> \ No newline at end of file