Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/kernel/db/dblist.php
Show First 20 Lines • Show All 255 Lines • ▼ Show 20 Line(s) | |||||
* @return kDBList | * @return kDBList | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
parent::__construct(); | parent::__construct(); | ||||
$this->OrderFields = Array(); | $this->OrderFields = Array(); | ||||
foreach ( $this->getFilterStructure() as $filter_params ) { | |||||
$filters = $this->getFilterStructure(); | $property_name = $filter_params['type']; | ||||
$filter_group =& $this->$property_name; | |||||
foreach ($filters as $filter_params) { | |||||
$filter =& $this->$filter_params['type']; | $filter_group[$filter_params['class']] = $this->Application->makeClass( | ||||
$filter[ $filter_params['class'] ] = $this->Application->makeClass('kMultipleFilter', Array ($filter_params['join_using'])); | 'kMultipleFilter', | ||||
array($filter_params['join_using']) | |||||
); | |||||
} | } | ||||
$this->PerPage = -1; | $this->PerPage = -1; | ||||
} | } | ||||
function setGridName($grid_name) | function setGridName($grid_name) | ||||
{ | { | ||||
$this->gridName = $grid_name; | $this->gridName = $grid_name; | ||||
Show All 34 Lines | |||||
* @param string $name filter name (for internal use) | * @param string $name filter name (for internal use) | ||||
* @param string $clause where/having clause part (no OR/AND allowed) | * @param string $clause where/having clause part (no OR/AND allowed) | ||||
* @param int $filter_type is filter having filter or where filter | * @param int $filter_type is filter having filter or where filter | ||||
* @param int $filter_scope filter subtype: FLT_NORMAL,FLT_SYSTEM,FLT_SEARCH,FLT_VIEW,FLT_CUSTOM | * @param int $filter_scope filter subtype: FLT_NORMAL,FLT_SYSTEM,FLT_SEARCH,FLT_VIEW,FLT_CUSTOM | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function addFilter($name, $clause, $filter_type = self::WHERE_FILTER, $filter_scope = self::FLT_SYSTEM) | public function addFilter($name, $clause, $filter_type = self::WHERE_FILTER, $filter_scope = self::FLT_SYSTEM) | ||||
{ | { | ||||
$filter_source = Array ( | $this->getFilterCollection($filter_type, $filter_scope)->addFilter($name, $clause); | ||||
self::WHERE_FILTER => 'WhereFilter', | |||||
self::HAVING_FILTER => 'HavingFilter', | |||||
self::AGGREGATE_FILTER => 'AggregateFilter' | |||||
); | |||||
$filter_name = $filter_source[$filter_type]; | |||||
$filter =& $this->$filter_name; | |||||
$filter =& $filter[$filter_scope]; | |||||
/* @var $filter kMultipleFilter */ | |||||
$filter->addFilter($name, $clause); | |||||
} | } | ||||
/** | /** | ||||
* Reads filter content | * Reads filter content | ||||
* | * | ||||
* @param string $name filter name (for internal use) | * @param string $name filter name (for internal use) | ||||
* @param int $filter_type is filter having filter or where filter | * @param int $filter_type is filter having filter or where filter | ||||
* @param int $filter_scope filter subtype: FLT_NORMAL,FLT_SYSTEM,FLT_SEARCH,FLT_VIEW,FLT_CUSTOM | * @param int $filter_scope filter subtype: FLT_NORMAL,FLT_SYSTEM,FLT_SEARCH,FLT_VIEW,FLT_CUSTOM | ||||
* @return string | * @return string | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function getFilter($name, $filter_type = self::WHERE_FILTER, $filter_scope = self::FLT_SYSTEM) | public function getFilter($name, $filter_type = self::WHERE_FILTER, $filter_scope = self::FLT_SYSTEM) | ||||
{ | { | ||||
$filter_source = Array ( | return $this->getFilterCollection($filter_type, $filter_scope)->getFilter($name); | ||||
self::WHERE_FILTER => 'WhereFilter', | |||||
self::HAVING_FILTER => 'HavingFilter', | |||||
self::AGGREGATE_FILTER => 'AggregateFilter' | |||||
); | |||||
$filter_name = $filter_source[$filter_type]; | |||||
$filter =& $this->$filter_name; | |||||
$filter =& $filter[$filter_scope]; | |||||
/* @var $filter kMultipleFilter */ | |||||
return $filter->getFilter($name); | |||||
} | } | ||||
/** | /** | ||||
* Removes specified filter from filters list | * Removes specified filter from filters list | ||||
* | * | ||||
* @param string $name filter name (for internal use) | * @param string $name filter name (for internal use) | ||||
* @param int $filter_type is filter having filter or where filter | * @param int $filter_type is filter having filter or where filter | ||||
* @param int $filter_scope filter subtype: FLT_NORMAL,FLT_SYSTEM,FLT_SEARCH,FLT_VIEW,FLT_CUSTOM | * @param int $filter_scope filter subtype: FLT_NORMAL,FLT_SYSTEM,FLT_SEARCH,FLT_VIEW,FLT_CUSTOM | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function removeFilter($name, $filter_type = self::WHERE_FILTER, $filter_scope = self::FLT_SYSTEM) | public function removeFilter($name, $filter_type = self::WHERE_FILTER, $filter_scope = self::FLT_SYSTEM) | ||||
{ | { | ||||
$filter_source = Array ( | $this->getFilterCollection($filter_type, $filter_scope)->removeFilter($name); | ||||
} | |||||
/** | |||||
* Returns filter collection. | |||||
* | |||||
* @param integer $filter_type Is filter having filter or where filter. | |||||
* @param integer $filter_scope Filter subtype: FLT_NORMAL,FLT_SYSTEM,FLT_SEARCH,FLT_VIEW,FLT_CUSTOM. | |||||
* | |||||
* @return kMultipleFilter | |||||
*/ | |||||
protected function getFilterCollection($filter_type = self::WHERE_FILTER, $filter_scope = self::FLT_SYSTEM) | |||||
{ | |||||
$filter_source = array( | |||||
self::WHERE_FILTER => 'WhereFilter', | self::WHERE_FILTER => 'WhereFilter', | ||||
self::HAVING_FILTER => 'HavingFilter', | self::HAVING_FILTER => 'HavingFilter', | ||||
self::AGGREGATE_FILTER => 'AggregateFilter' | self::AGGREGATE_FILTER => 'AggregateFilter' | ||||
); | ); | ||||
$filter_name = $filter_source[$filter_type]; | /** @var kMultipleFilter[] $filters */ | ||||
$property_name = $filter_source[$filter_type]; | |||||
$filter =& $this->$filter_name; | $filters =& $this->$property_name; | ||||
$filter =& $filter[$filter_scope]; | |||||
/* @var $filter kMultipleFilter */ | |||||
$filter->removeFilter($name); | return $filters[$filter_scope]; | ||||
} | } | ||||
/** | /** | ||||
* Clear all filters | * Clear all filters | ||||
* | * | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function clearFilters() | public function clearFilters() | ||||
{ | { | ||||
$filters = $this->getFilterStructure(); | foreach ( $this->getFilterStructure() as $filter_params ) { | ||||
$property_name = $filter_params['type']; | |||||
$filter_group =& $this->$property_name; | |||||
foreach ($filters as $filter_params) { | $filter_group[$filter_params['class']]->clearFilters(); | ||||
$filter =& $this->$filter_params['type']; | |||||
$filter[ $filter_params['class'] ]->clearFilters(); | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Counts the total number of records base on the query resulted from {@link kDBList::GetSelectSQL()} | * Counts the total number of records base on the query resulted from {@link kDBList::GetSelectSQL()} | ||||
* | * | ||||
* The method modifies the query to substitude SELECT part (fields listing) with COUNT(*). | * The method modifies the query to substitude SELECT part (fields listing) with COUNT(*). | ||||
* Special care should be applied when working with lists based on grouped queries, all aggregate function fields | * Special care should be applied when working with lists based on grouped queries, all aggregate function fields | ||||
▲ Show 20 Lines • Show All 1373 Lines • Show Last 20 Lines |