diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index 0c4f86160..4286a8398 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.16 $ - * $Date: 2009-10-22 04:15:27 $ + * $Revision: 1.17 $ + * $Date: 2009-10-22 05:14:07 $ * $Author: e107coders $ */ @@ -1607,6 +1607,7 @@ class e_model_interface var $listQry; var $table; var $primary; + var $mode; // to work with $_GET and admin menu. function __construct() { @@ -1641,6 +1642,7 @@ class e_model_interface { $this->listRecords(); } + //TODO add options 'preferences page'. if(isset($_POST['submit-e-columns'])) { @@ -1703,22 +1705,24 @@ class e_model_interface "; - $ns->tablerender($this->pluginTitle." :: ".$this->listCaption, $mes->render().$text); + $ns->tablerender($this->pluginTitle." :: ".$this->adminMenu['list']['caption'], $mes->render().$text); } /** - * + * Generic DB Record Creation Form. * @param object $id [optional] * @return */ function createRecord($id=FALSE) { - global $frm, $e_userclass, $e_event; + global $e_userclass, $e_event; $tp = e107::getParser(); $ns = e107::getRender(); $sql = e107::getDb(); + $frm = e107::getForm(); + if($id) { @@ -1775,7 +1779,7 @@ class e_model_interface "; - $ns->tablerender($this->pluginTitle." :: ".$this->createCaption, $text); + $ns->tablerender($this->pluginTitle." :: ".$this->adminMenu['create']['caption'], $text); } @@ -1786,16 +1790,21 @@ class e_model_interface */ function submitPage($id=FALSE) { - global $sql, $tp, $e107cache, $admin_log, $e_event; + global $e107cache, $admin_log, $e_event; $emessage = eMessage::getInstance(); + $sql = e107::getDb(); + $tp = e107::getParser(); + $insert_array = array(); + //TODO validation and sanitizing using above classes. + foreach($this->fields as $key=>$att) { if($att['forced']!=TRUE) { - $insert_array[$key] = $_POST[$key]; + $insert_array[$key] = $_POST[$key]; } } @@ -1803,7 +1812,7 @@ class e_model_interface { $insert_array['WHERE'] = $this->primary." = ".$id; $status = $sql->db_Update($this->table,$insert_array) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED; - $message = LAN_UPDATED; + $message = LAN_UPDATED; // deliberately ambiguous - to be used on success or error. } else @@ -1833,10 +1842,90 @@ class e_model_interface $query = $this->primary." = ".$id; $status = $sql->db_Delete($this->table,$query) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED; - $message = LAN_DELETED; - $emessage->add($message, $status); + $message = LAN_DELETED; + $emessage->add($message, $status); } + + + /** + * Render Form Element (edit page) + * @param object $key + * @param object $row + * @return + */ + function renderElement($key,$row) + { + $frm = e107::getForm(); + + $att = $this->fields[$key]; + $value = $row[$key]; + + if($att['type']=='method') + { + $meth = $key; + return $this->$meth($value); + } + + return $frm->text($key, $row[$key], 50); + + } + + + + + /** + * Render Field value (listing page) + * @param object $key + * @param object $row + * @return + */ + function renderValue($key,$row) + { + $att = $this->fields[$key]; + //TODO add checkbox. + if($key == "options") + { + $id = $this->primary; + $text = ""; + $text .= ""; + return $text; + } + + switch($att['type']) + { + case 'url': + return "".$row[$key].""; + break; + + default: + return $row[$key]; + break; + } + return $row[$key] .$att['type']; + } + + + /** + * Generic Admin Menu Generator + * @param object $action + * @return + */ + function show_options($action) + { + + $action = varset($_GET['mode'],'list'); + + foreach($this->adminMenu as $key=>$val) + { + $var[$key]['text'] = $val['caption']; + $var[$key]['link'] = e_SELF."?mode=".$key; + $var[$key]['perm'] = $val['perm']; + } + + e_admin_menu($this->pluginTitle, $action, $var); + } + } diff --git a/e107_plugins/release/admin_config.php b/e107_plugins/release/admin_config.php index a40bc65b8..e4c993509 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.3 $ - * $Date: 2009-10-22 04:15:32 $ + * $Revision: 1.4 $ + * $Date: 2009-10-22 05:14:11 $ * $Author: e107coders $ * */ @@ -18,9 +18,6 @@ require_once("../../class2.php"); if (!getperms("P")) { header("location:".e_BASE."index.php"); exit; } require_once(e_ADMIN."auth.php"); -require_once(e_HANDLER."form_handler.php"); -$frm = new e_form(true); -require_once(e_HANDLER."model_class.php"); class efeed extends e_model_interface @@ -37,141 +34,44 @@ 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', 'width'=>'auto','method'=>'feed_type'), + 'release_type' => array('title'=> 'type', 'type' => 'method', 'width'=>'auto'), 'release_folder' => array('title'=> 'folder', 'type' => 'text', 'width' => 'auto'), // User name 'release_name' => array('title'=> 'name', '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 first'), // Display name - 'release_authorURL' => array('title'=> LAN_AUTHOR.'URL', 'type' => 'url', 'width' => 'auto', 'thclass' => 'left first'), // Display name + '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'), // Photo - 'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting) - 'release_url' => array('title'=> 'URL', 'type' => 'url', 'width' => '10%', 'thclass' => 'center' ), // No real vetting + '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' ), 'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last') ); + $this->prefs = array( + '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'), + + ); + $this->fieldpref = (varset($user_pref['admin_release_columns'])) ? $user_pref['admin_release_columns'] : array_keys($this->fields); - $this->table = "release"; + $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"; - $this->listCaption = "Release List"; - $this->createCaption = LAN_CREATE."/".LAN_EDIT; + $this->adminMenu = array( + 'list' => array('caption'=>'Release List', 'perm'=>'0'), + 'create' => array('caption'=>LAN_CREATE."/".LAN_EDIT, 'perm'=>'0') + ); } - - -// -------------------------------------------------------------------------- - /** - * Generic DB Record Listing Function. - * @param object $mode [optional] - * @return - */ - /*function listRecords($mode=FALSE) - { - $ns = e107::getRender(); - $sql = e107::getDb(); - - global $frm, $pref; - - $emessage = eMessage::getInstance(); - - $text = "
- "; - - $ns->tablerender($this->pluginTitle." :: ".$this->listCaption, $emessage->render().$text); - } -*/ - /** - * Render Field value (listing page) - * @param object $key - * @param object $row - * @return - */ - function renderValue($key,$row) - { - $att = $this->fields[$key]; - - if($key == "options") - { - $id = $this->primary; - $text = ""; - $text .= ""; - return $text; - } - - switch($att['type']) - { - case 'url': - return "".$row[$key].""; - break; - - default: - return $row[$key]; - break; - } - return $row[$key] .$att['type']; - } - /** - * Render Form Element (edit page) - * @param object $key - * @param object $row - * @return - */ - function renderElement($key,$row) - { - global $frm; - $att = $this->fields[$key]; - $value = $row[$key]; - - if($att['method']) - { - $meth = $att['method']; - return $this->$meth($value); - } - - return $frm->text($key, $row[$key], 50); - - } - - function feed_type($curVal) + // custom method. (matches field/key name) + function release_type($curVal) { $types = array("theme","plugin"); $text = "