From 2c49f28671cedcea973566ee62dcfc5615f855c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Fri, 20 Jun 2008 21:01:22 +0200 Subject: [PATCH] db_filter_ui: Show help text when users don't select a filter criterion --- include/db_filter_ui.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/db_filter_ui.php b/include/db_filter_ui.php index 7fe459d..cbe69cf 100644 --- a/include/db_filter_ui.php +++ b/include/db_filter_ui.php @@ -105,6 +105,7 @@ class FilterInterface private $oFilterSet; private $aEscapeChars; private $aEscapeCharsWith; + private $sErrors; // Used to inform the user about errors (and to give advice) public function FilterInterface($sTableName = '') { @@ -112,6 +113,7 @@ class FilterInterface $this->oFilterSet = new FilterSet(query_escape_string($sTableName)); $this->aEscapeChars = array('.'); $this->aEscapeCharsWith = array('-'); + $this->sErrors = ''; } public function AddFilterObject(Filter $oFilter) @@ -358,6 +360,11 @@ class FilterInterface } $shNewItemsEditor .= 'Add new filter (You don’t have to fill out all rows.)
'; + + /* Show errors, if any */ + if($this->sErrors) + $shNewItemsEditor .= "{$this->sErrors}"; + foreach($this->aFilterInfo as $oOption) { $oDummyFilter = new Filter($oOption->getColumn(), 0, ''); @@ -428,6 +435,11 @@ class FilterInterface { $oFilter = new Filter($oOption->getColumn(), $iOp, $sData); $aReturn[] = $oFilter; + } else if(!$iOp && $sData) + { + /* The user probably meant to add a filter, but forgot to seelect + a filter criterion */ + $this->sErrors .= 'You need to select a filter criterion from the drop-down list
'; } }