mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
Admin-ui automated tree sorting when $sortField and $sortParent are defined.
This commit is contained in:
@@ -2345,6 +2345,10 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
/**
|
/**
|
||||||
* @var array UI field data
|
* @var array UI field data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
protected $pid;
|
||||||
|
|
||||||
protected $fields = array();
|
protected $fields = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2415,6 +2419,12 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
* @var string field containing the order number
|
* @var string field containing the order number
|
||||||
*/
|
*/
|
||||||
protected $sortField = null;
|
protected $sortField = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string field containing the parent field
|
||||||
|
*/
|
||||||
|
protected $sortParent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int reorder step
|
* @var int reorder step
|
||||||
@@ -3997,10 +4007,23 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
$qry .= "\n".implode("\n", $joins);
|
$qry .= "\n".implode("\n", $joins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // default listQry
|
||||||
{
|
{
|
||||||
|
if(!empty($listQry))
|
||||||
|
{
|
||||||
|
$qry = $this->parseCustomListQry($listQry);
|
||||||
|
}
|
||||||
|
elseif($this->sortField && $this->sortParent) // automated 'tree' sorting.
|
||||||
|
{
|
||||||
|
$qry = "SELECT SQL_CALC_FOUND_ROWS a. *, CASE WHEN a.".$this->sortParent." = 0 THEN a.".$this->sortField." ELSE b.".$this->sortField." + (( a.".$this->sortField.")/1000) END AS treesort FROM `#".$this->table."` AS a LEFT JOIN `#".$this->table."` AS b ON a.".$this->sortParent." = b.".$this->pid;
|
||||||
|
$this->listOrder = 'treesort,'.$this->sortField;
|
||||||
|
$this->orderStep = ($this->orderStep === 1) ? 100 : $this->orderStep;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$qry = "SELECT SQL_CALC_FOUND_ROWS ".$tableSFields." FROM ".$tableFrom;
|
||||||
|
}
|
||||||
|
|
||||||
$qry = $listQry ? $this->parseCustomListQry($listQry) : "SELECT SQL_CALC_FOUND_ROWS ".$tableSFields." FROM ".$tableFrom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// group field - currently auto-added only if there are joins
|
// group field - currently auto-added only if there are joins
|
||||||
|
@@ -131,10 +131,16 @@ class download_cat_ui extends e_admin_ui
|
|||||||
protected $table = "download_category";
|
protected $table = "download_category";
|
||||||
protected $pid = "download_category_id";
|
protected $pid = "download_category_id";
|
||||||
protected $perPage = 0; //no limit
|
protected $perPage = 0; //no limit
|
||||||
protected $listOrder = 'download_category_order';
|
// protected $listOrder = 'download_category_parent,download_category_order';
|
||||||
// protected $defaultOrderField = 'download_category_parent,download_category_order';
|
|
||||||
// protected $listQry = "SELECT * FROM #faq_info"; // without any Order or Limit.
|
protected $batchCopy = true;
|
||||||
// protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}";
|
|
||||||
|
// initiate as a parent/child tree.
|
||||||
|
protected $sortField = 'download_category_order';
|
||||||
|
protected $sortParent = 'download_category_parent';
|
||||||
|
|
||||||
|
protected $listOrder = null; // automatic
|
||||||
|
|
||||||
|
|
||||||
protected $fields = array(
|
protected $fields = array(
|
||||||
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
||||||
@@ -147,7 +153,7 @@ class download_cat_ui extends e_admin_ui
|
|||||||
'download_category_parent' => array('title'=> LAN_PARENT, 'type' => 'method', 'width' => '5%', 'batch' => TRUE, 'filter'=>TRUE),
|
'download_category_parent' => array('title'=> LAN_PARENT, 'type' => 'method', 'width' => '5%', 'batch' => TRUE, 'filter'=>TRUE),
|
||||||
'download_category_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'inline' => true, 'width' => 'auto', 'data' => 'int', 'batch' => TRUE, 'filter'=>TRUE),
|
'download_category_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'inline' => true, 'width' => 'auto', 'data' => 'int', 'batch' => TRUE, 'filter'=>TRUE),
|
||||||
'download_category_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'data'=>'int', 'width' => '5%', 'thclass' => 'right', 'class'=> 'right' ),
|
'download_category_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'data'=>'int', 'width' => '5%', 'thclass' => 'right', 'class'=> 'right' ),
|
||||||
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
|
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center', 'sort'=>1)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -622,11 +628,11 @@ $columnInfo = array(
|
|||||||
<tr>
|
<tr>
|
||||||
<td>".$row['limit_id']."</td>
|
<td>".$row['limit_id']."</td>
|
||||||
<td>".r_userclass_name($row['limit_classnum'])."</td>
|
<td>".r_userclass_name($row['limit_classnum'])."</td>
|
||||||
<td>
|
<td class='form-inline'>
|
||||||
<input type='text' class='form-control' size='5' name='count_num[{$row['limit_id']}]' value='".($row['limit_count_num'] ? $row['limit_count_num'] : "")."'/> ".DOWLAN_109."
|
<input type='text' class='form-control' size='5' name='count_num[{$row['limit_id']}]' value='".($row['limit_count_num'] ? $row['limit_count_num'] : "")."'/> ".DOWLAN_109."
|
||||||
<input type='text' class='form-control' size='5' name='count_days[{$row['limit_id']}]' value='".($row['limit_count_days'] ? $row['limit_count_days'] : "")."'/> ".DOWLAN_110."
|
<input type='text' class='form-control' size='5' name='count_days[{$row['limit_id']}]' value='".($row['limit_count_days'] ? $row['limit_count_days'] : "")."'/> ".DOWLAN_110."
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class='form-inline'>
|
||||||
<input type='text' class='form-control' size='5' name='bw_num[{$row['limit_id']}]' value='".($row['limit_bw_num'] ? $row['limit_bw_num'] : "")."'/> ".DOWLAN_111." ".DOWLAN_109."
|
<input type='text' class='form-control' size='5' name='bw_num[{$row['limit_id']}]' value='".($row['limit_bw_num'] ? $row['limit_bw_num'] : "")."'/> ".DOWLAN_111." ".DOWLAN_109."
|
||||||
<input type='text' class='form-control' size='5' name='bw_days[{$row['limit_id']}]' value='".($row['limit_bw_days'] ? $row['limit_bw_days'] : "")."'/> ".DOWLAN_110."
|
<input type='text' class='form-control' size='5' name='bw_days[{$row['limit_id']}]' value='".($row['limit_bw_days'] ? $row['limit_bw_days'] : "")."'/> ".DOWLAN_110."
|
||||||
</td>
|
</td>
|
||||||
@@ -646,11 +652,11 @@ $columnInfo = array(
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='2'>".r_userclass("newlimit_class", 0, "off", "guest, member, admin, classes, language")."</td>
|
<td colspan='2'>".r_userclass("newlimit_class", 0, "off", "guest, member, admin, classes, language")."</td>
|
||||||
<td>
|
<td class='form-inline'>
|
||||||
<input type='text' class='form-control' size='5' name='new_count_num' value=''/> ".DOWLAN_109."
|
<input type='text' class='form-control' size='5' name='new_count_num' value=''/> ".DOWLAN_109."
|
||||||
<input type='text' class='form-control' size='5' name='new_count_days' value=''/> ".DOWLAN_110."
|
<input type='text' class='form-control' size='5' name='new_count_days' value=''/> ".DOWLAN_110."
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class='form-inline'>
|
||||||
<input type='text' class='form-control' size='5' name='new_bw_num' value=''/> ".DOWLAN_111." ".DOWLAN_109."
|
<input type='text' class='form-control' size='5' name='new_bw_num' value=''/> ".DOWLAN_111." ".DOWLAN_109."
|
||||||
<input type='text' class='form-control' size='5' name='new_bw_days' value=''/> ".DOWLAN_110."
|
<input type='text' class='form-control' size='5' name='new_bw_days' value=''/> ".DOWLAN_110."
|
||||||
</td>
|
</td>
|
||||||
|
Reference in New Issue
Block a user