diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index cbd310b91..d2b9debb5 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -2345,6 +2345,10 @@ class e_admin_controller_ui extends e_admin_controller /** * @var array UI field data */ + + + protected $pid; + protected $fields = array(); /** @@ -2415,6 +2419,12 @@ class e_admin_controller_ui extends e_admin_controller * @var string field containing the order number */ protected $sortField = null; + + + /** + * @var string field containing the parent field + */ + protected $sortParent = null; /** * @var int reorder step @@ -3997,10 +4007,23 @@ class e_admin_controller_ui extends e_admin_controller $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 diff --git a/e107_plugins/download/includes/admin.php b/e107_plugins/download/includes/admin.php index 1a10deebe..241799620 100644 --- a/e107_plugins/download/includes/admin.php +++ b/e107_plugins/download/includes/admin.php @@ -131,10 +131,16 @@ class download_cat_ui extends e_admin_ui protected $table = "download_category"; protected $pid = "download_category_id"; protected $perPage = 0; //no limit - protected $listOrder = 'download_category_order'; - // protected $defaultOrderField = 'download_category_parent,download_category_order'; - // protected $listQry = "SELECT * FROM #faq_info"; // without any Order or Limit. - // protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}"; + // protected $listOrder = 'download_category_parent,download_category_order'; + + protected $batchCopy = true; + + // initiate as a parent/child tree. + protected $sortField = 'download_category_order'; + protected $sortParent = 'download_category_parent'; + + protected $listOrder = null; // automatic + protected $fields = array( '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_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' ), - '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(