mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 22:57:14 +02:00
Updated e_model with nextprev and column ordering
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
* Form Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
||||
* $Revision: 1.53 $
|
||||
* $Date: 2009-10-22 23:46:49 $
|
||||
* $Revision: 1.54 $
|
||||
* $Date: 2009-10-23 04:25:13 $
|
||||
* $Author: e107coders $
|
||||
*
|
||||
*/
|
||||
@@ -713,12 +713,21 @@ class e_form
|
||||
{
|
||||
$text = "";
|
||||
|
||||
// FIXME - Temporary solution, we really need to add parse_str() support
|
||||
$tmp = explode(".", ($requeststr ? $requeststr : e_QUERY));
|
||||
$etmp = explode(".", $querypattern);
|
||||
// Recommended pattern: ?mode=list&fld=[FIELD]&asc=[ASC]&frm=[FROM]
|
||||
|
||||
if(strpos($querypattern,'&')!==FALSE)
|
||||
{
|
||||
$tmp = $_GET; // we can assume it's always $_GET since that's what it will generate
|
||||
$etmp = array();
|
||||
parse_str($querypattern,$etmp);
|
||||
}
|
||||
else // Legacy Queries. eg. main.[FIELD].[ASC].[FROM]
|
||||
{
|
||||
$tmp = explode(".", ($requeststr ? $requeststr : e_QUERY));
|
||||
$etmp = explode(".", $querypattern);
|
||||
}
|
||||
|
||||
|
||||
// Note: this function should probably be adapted to ALSO deal with $_GET. eg. ?mode=main&field=user_name&asc=desc&from=100
|
||||
// or as a pattern: ?mode=main&field=[FIELD]&asc=[ASC]&from=[FROM]
|
||||
|
||||
foreach($etmp as $key => $val) // I'm sure there's a more efficient way to do this, but too tired to see it right now!.
|
||||
{
|
||||
@@ -737,6 +746,9 @@ class e_form
|
||||
$fromval = $tmp[$key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(!varset($fromval)){ $fromval = 0; }
|
||||
|
||||
@@ -757,7 +769,7 @@ class e_form
|
||||
$val['url'] = e_SELF."?".str_replace($srch,$repl,$querypattern);
|
||||
}
|
||||
|
||||
$text .= (varset($val['url'])) ? "<a href='".$val['url']."'>" : ""; // Really this column-sorting link should be auto-generated, or be autocreated via unobtrusive js.
|
||||
$text .= (varset($val['url'])) ? "<a href='".str_replace("&","&",$val['url'])."'>" : ""; // Really this column-sorting link should be auto-generated, or be autocreated via unobtrusive js.
|
||||
$text .= $val['title'];
|
||||
$text .= ($val['url']) ? "</a>" : "";
|
||||
$text .= ($key == "options") ? $this->columnSelector($fieldarray,$columnPref) : "";
|
||||
|
@@ -9,9 +9,9 @@
|
||||
* e107 Base Model
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
||||
* $Revision: 1.20 $
|
||||
* $Date: 2009-10-22 14:18:18 $
|
||||
* $Author: secretr $
|
||||
* $Revision: 1.21 $
|
||||
* $Date: 2009-10-23 04:25:13 $
|
||||
* $Author: e107coders $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -1716,24 +1716,32 @@ class e_model_interface
|
||||
$frm = e107::getForm();
|
||||
$mes = e107::getMessage();
|
||||
$pref = e107::getConfig()->getPref();
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$amount = 20; // do we hardcode or let the plugin developer decide.. OR - a pref in admin?
|
||||
$from = vartrue($_GET['frm']) ? $_GET['frm'] : 0; //TODO sanitize?.
|
||||
|
||||
$text = "<form method='post' action='".e_SELF."?mode=create'>
|
||||
<fieldset id='core-".$this->table."-list'>
|
||||
<legend class='e-hideme'>".$this->pluginTitle."</legend>
|
||||
<table cellpadding='0' cellspacing='0' class='adminlist'>".
|
||||
$frm->colGroup($this->fields,$this->fieldpref).
|
||||
$frm->thead($this->fields,$this->fieldpref).
|
||||
$frm->thead($this->fields,$this->fieldpref, 'mode='.$this->mode.'&fld=[FIELD]&asc=[ASC]&frm=[FROM]').
|
||||
|
||||
"<tbody>";
|
||||
|
||||
|
||||
if(!$sql->db_Select_gen($this->listQry))
|
||||
if(!$total = $sql->db_Select_gen($this->listQry))
|
||||
{
|
||||
$text .= "\n<tr><td colspan='".count($this->fields)."' class='center middle'>".LAN_NO_RECORDS."</td></tr>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $this->listQry;
|
||||
$query .= ($_GET['fld'] && $_GET['asc']) ? " ORDER BY ".$_GET['fld']." ".$_GET['asc'] : "";
|
||||
$query .= " LIMIT ".$from.",".$amount;
|
||||
|
||||
$sql->db_Select_gen($query);
|
||||
$row = $sql->db_getList('ALL', FALSE, FALSE);
|
||||
|
||||
foreach($row as $field)
|
||||
@@ -1756,6 +1764,8 @@ class e_model_interface
|
||||
";
|
||||
|
||||
//TODO Auto next/prev
|
||||
$parms = $total.",".$amount.",".$from.",".e_SELF.'?action='.$this->mode.'&frm=[FROM]';
|
||||
$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
|
||||
|
||||
$ns->tablerender($this->pluginTitle." :: ".$this->adminMenu['list']['caption'], $mes->render().$text);
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@
|
||||
* e107 Release Plugin
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2009-10-22 07:52:13 $
|
||||
* $Revision: 1.7 $
|
||||
* $Date: 2009-10-23 04:25:19 $
|
||||
* $Author: e107coders $
|
||||
*
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ class releasePlugin extends e_model_interface
|
||||
'pref_name' => array('title'=> 'name', 'type' => 'text')
|
||||
);
|
||||
|
||||
$this->listQry = "SELECT * FROM #release ORDER BY release_id DESC";
|
||||
$this->listQry = "SELECT * FROM #release"; // without any Order or Limit.
|
||||
$this->editQry = "SELECT * FROM #release WHERE release_id = {ID}";
|
||||
$this->table = "release";
|
||||
$this->primary = "release_id";
|
||||
|
Reference in New Issue
Block a user