Source for file TableFilters.php
Documentation is available at TableFilters.php
* User Interface Util Class
* @copyright Copyright (c) 2006 Mirchev Ideas Ltd. All rights reserved.
* @copyright Copyright (c) 2006 Mirchev Ideas Ltd. All rights reserved.
* An associative array with filter field and value
* Additional filters added by application logic
* Map between the filter conditions and the actual filter class
'=' =>
'miSqlFilterEqual',
'!=' =>
'miSqlFilterNotEqual',
'>' =>
'miSqlFilterBiggerThan',
'>=' =>
'miSqlFilterBiggerOrEqual',
'<' =>
'miSqlFilterSmallerThan',
'<=' =>
'miSqlFilterSmallerOrEqual',
'substring' =>
'miSqlFilterSubstring',
'starts' =>
'miSqlFilterStarts',
'ends' =>
'miSqlFilterEnds',
'regexp' =>
'miSqlFilterRegExp',
'notin' =>
'miSqlFilterNotIn',
* Sets a condition handler
* The miView expects the handler class be subclassed from miSqlFilter
* @param string $condition
* @param string $handlerClassName
* Set the default filter values
* @param array $defaultFilterValues an associative array with filter field and value
* Adds an additional filter
* @param string $condition
* The the current filters values
* @return array associative array with each filter and it's value
* @throws miConfigurationException
foreach ($filters as $filter) {
$filterValues[$filter[0]] =
$filter[1];
* Returns the filter value of $filterName
* The request is checked first, then the default filter values,
* and if the $filterName cannot not found returns empty string
* TODO: improve efficiency by not using getFilterValues()
* @param string $filterName
* @return string the filter value
if (isset
($filters[$filterName]))
return $filters[$filterName];
* @throws miConfigurationException
foreach ($filterValues as $field =>
$filter) {
$values[strtoupper($field) .
'_FILTERVALUE'] =
$filter;
foreach ($filter as $key =>
$value) {
$values[strtoupper($field) .
'_FILTERVALUE[' .
$key .
']'] =
$value;
* Returns associative array with params that save the feature state
* @throws miConfigurationException
foreach ($filterArray as $filter) {
$params[$filter[0] .
self::FILTER_NAME_SUFFIX] =
$filter[1];
$params[$filter[0] .
self::FILTER_CONDITION_SUFFIX] =
$filter[2];
foreach ($filter[1] as $key =>
$value) {
$params[$filter[0] .
self::FILTER_NAME_SUFFIX .
'[' .
$key .
']'] =
$value;
$params[$filter[0] .
self::FILTER_CONDITION_SUFFIX .
'[' .
$key .
']'] =
$filter[2][$key];
* Gets all filter parameters from the request
* Returns the additional filters along with the filters from the request
* Uses $_REQUEST superglobal instead of $_GET or $_POST
* Note: Value and Condition can be arrays
* @return array array of arrays that each holding the field name[0], value[1] and condition[2]
* @throws miConfigurationException
$suffixLen =
strlen(self::FILTER_NAME_SUFFIX);
$state =
$this->_table->getState();
foreach ($state as $property =>
$value) {
$field =
substr($property, 0, -
$suffixLen);
$condition = isset
($state[$field .
self::FILTER_CONDITION_SUFFIX]) ?
$state[$field .
self::FILTER_CONDITION_SUFFIX] :
'=';
// For security purposes only numeric indexes are allowed
$filters[] =
array($field, $value, $condition);
* Returns an array of filter objects
* @return array array of objects, subclasses of miSqlFilter
* @throws miConfigurationException
foreach ($filters as $filter) {
$filterObjs[] =
$this->createFilterObj($filter[0], $filter[1], $filter[2]);
foreach ($filter[1] as $key =>
$value)
$filterObjs[] =
$this->createFilterObj($filter[0], $value, $filter[2][$key]);
* Creates a filter object
* The object depends on the $condition
* @param string $field the filter field
* @param string $condition
* @throws miConfigurationException
Documentation generated on Thu, 08 May 2008 16:57:45 +0300 by phpDocumentor 1.4.1