browse apps: Add support for filtering by name
This commit is contained in:
committed by
Chris Morgan
parent
449d1721df
commit
628bc7c767
@@ -1035,6 +1035,7 @@ class Application {
|
|||||||
$oFilter->AddFilterInfo('appVersion.rating', 'Rating', array(FILTER_EQUALS), FILTER_VALUES_ENUM, array('Platinum', 'Gold', 'Silver', 'Bronze', 'Garbage'));
|
$oFilter->AddFilterInfo('appVersion.rating', 'Rating', array(FILTER_EQUALS), FILTER_VALUES_ENUM, array('Platinum', 'Gold', 'Silver', 'Bronze', 'Garbage'));
|
||||||
$oFilter->AddFilterInfo('appFamily.catId', 'Category', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aCatIds, $aCatNames);
|
$oFilter->AddFilterInfo('appFamily.catId', 'Category', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aCatIds, $aCatNames);
|
||||||
$oFilter->AddFilterInfo('appVersion.license', 'License', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aLicenses);
|
$oFilter->AddFilterInfo('appVersion.license', 'License', array(FILTER_EQUALS), FILTER_VALUES_ENUM, $aLicenses);
|
||||||
|
$oFilter->AddFilterInfo('appFamily.appName', 'Name', array(FILTER_CONTAINS, FILTER_STARTS_WITH, FILTER_ENDS_WITH), FILTER_VALUES_NORMAL);
|
||||||
$oFilter->AddFilterInfo('onlyDownloadable', 'Only show downloadable apps', array(FILTER_OPTION_BOOL), FILTER_VALUES_OPTION_BOOL, array('false','true'));
|
$oFilter->AddFilterInfo('onlyDownloadable', 'Only show downloadable apps', array(FILTER_OPTION_BOOL), FILTER_VALUES_OPTION_BOOL, array('false','true'));
|
||||||
return $oFilter;
|
return $oFilter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
define('FILTER_LIKE', 1);
|
define('FILTER_LIKE', 1);
|
||||||
define('FILTER_EQUALS', 2);
|
define('FILTER_CONTAINS', 2); // Same as LIKE, but value is wrapped by wildcards
|
||||||
define('FILTER_GREATER_THAN', 3);
|
define('FILTER_STARTS_WITH', 3); // Same as LIKE, but with a prepended wildcard
|
||||||
define('FILTER_LESS_THAN', 4);
|
define('FILTER_ENDS_WITH', 4); // Same as LIKE, but with an appended wildcard
|
||||||
define('FILTER_NOT_EQUALS', 5);
|
define('FILTER_EQUALS', 5);
|
||||||
define('FILTER_NOT_LIKE', 6);
|
define('FILTER_GREATER_THAN', 6);
|
||||||
define('FILTER_OPTION_BOOL', 7);
|
define('FILTER_LESS_THAN', 7);
|
||||||
|
define('FILTER_NOT_EQUALS', 8);
|
||||||
|
define('FILTER_NOT_LIKE', 9);
|
||||||
|
define('FILTER_OPTION_BOOL', 10);
|
||||||
|
|
||||||
/* A filter as part of an SQL query, such as something = 'somevalue' */
|
/* A filter as part of an SQL query, such as something = 'somevalue' */
|
||||||
class Filter
|
class Filter
|
||||||
@@ -55,6 +58,9 @@ class Filter
|
|||||||
switch($this->iType)
|
switch($this->iType)
|
||||||
{
|
{
|
||||||
case FILTER_LIKE:
|
case FILTER_LIKE:
|
||||||
|
case FILTER_CONTAINS:
|
||||||
|
case FILTER_STARTS_WITH:
|
||||||
|
case FILTER_ENDS_WITH:
|
||||||
return 'LIKE';
|
return 'LIKE';
|
||||||
case FILTER_EQUALS:
|
case FILTER_EQUALS:
|
||||||
return '=';
|
return '=';
|
||||||
@@ -79,9 +85,25 @@ class Filter
|
|||||||
if($this->iType == FILTER_OPTION_BOOL)
|
if($this->iType == FILTER_OPTION_BOOL)
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
|
$sData = $this->sData;
|
||||||
|
|
||||||
|
/* Add wildcards if required */
|
||||||
|
switch($this->iType)
|
||||||
|
{
|
||||||
|
case FILTER_CONTAINS:
|
||||||
|
$sData = "%$sData%";
|
||||||
|
break;
|
||||||
|
case FILTER_STARTS_WITH:
|
||||||
|
$sData = "$sData%";
|
||||||
|
break;
|
||||||
|
case FILTER_ENDS_WITH:
|
||||||
|
$sData = "%$sData";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$sOp = $this->getOperator();
|
$sOp = $this->getOperator();
|
||||||
|
|
||||||
return "{$this->sColumn} $sOp '{$this->sData}'";
|
return "{$this->sColumn} $sOp '$sData'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
require_once('db_filter.php');
|
require_once('db_filter.php');
|
||||||
|
|
||||||
define(FILTER_VALUES_NORMAL, 1);
|
define('FILTER_VALUES_NORMAL', 1);
|
||||||
define(FILTER_VALUES_ENUM, 2);
|
define('FILTER_VALUES_ENUM', 2);
|
||||||
define(FILTER_VALUES_BOOL, 3);
|
define('FILTER_VALUES_BOOL', 3);
|
||||||
define(FILTER_VALUES_OPTION, 4);
|
define('FILTER_VALUES_OPTION', 4);
|
||||||
|
|
||||||
/* Info describing an available filter: what column it applies to,
|
/* Info describing an available filter: what column it applies to,
|
||||||
and what comparison options are available */
|
and what comparison options are available */
|
||||||
@@ -78,6 +78,12 @@ class FilterInfo
|
|||||||
return 'equal to';
|
return 'equal to';
|
||||||
case FILTER_LIKE:
|
case FILTER_LIKE:
|
||||||
return 'like';
|
return 'like';
|
||||||
|
case FILTER_CONTAINS:
|
||||||
|
return 'contains';
|
||||||
|
case FILTER_STARTS_WITH:
|
||||||
|
return 'starts with';
|
||||||
|
case FILTER_ENDS_WITH:
|
||||||
|
return 'ends with';
|
||||||
case FILTER_NOT_LIKE:
|
case FILTER_NOT_LIKE:
|
||||||
return 'not like';
|
return 'not like';
|
||||||
case FILTER_NOT_EQUALS:
|
case FILTER_NOT_EQUALS:
|
||||||
@@ -216,7 +222,7 @@ class FilterInterface
|
|||||||
|
|
||||||
if($iId == -1)
|
if($iId == -1)
|
||||||
{
|
{
|
||||||
$sText = 'select';
|
$sText = 'criteria';
|
||||||
$sSel = " selected='selected'";
|
$sSel = " selected='selected'";
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user