/** * Get filter's WHERE clause condition basing on the filter's type * * @param String filterType A string representing the filter's type * @param String fName * @param String fValue * @param String dbType * @return String */ function getFilterWhereByType($filterType, $fName, $fValue, $sValue, $parentValues, $connection) { $pSet = new ProjectSettings($this->tName, PAGE_SEARCH); $fullFieldName = RunnerPage::_getFieldSQLDecrypt($fName, $connection, $pSet, $this->cipherer); $fieldType = $pSet->getFieldType($fName); $dateField = IsDateFieldType($fieldType); $timeField = IsTimeType($fieldType); if ($dateField || $timeField) { include_once getabspath("classes/controls/FilterControl.php"); include_once getabspath("classes/controls/FilterIntervalSlider.php"); include_once getabspath("classes/controls/FilterIntervalDateSlider.php"); } switch ($filterType) { case 'interval': $intervalData = $pSet->getFilterIntervalDatabyIndex($fName, $fValue); if (!count($intervalData)) { return ""; } include_once getabspath("classes/controls/FilterControl.php"); include_once getabspath("classes/controls/FilterIntervalList.php"); return FilterIntervalList::getIntervalFilterWhere($fName, $intervalData, $pSet, $this->cipherer, $this->tName, $connection); case 'equals': if (!count($parentValues)) { return $fullFieldName . "=" . $this->cipherer->MakeDBValue($fName, $fValue, "", true); } $wheres = array(); $wheres[] = $fullFieldName . "=" . $this->cipherer->MakeDBValue($fName, $fValue, "", true); $parentFiltersNames = $pSet->getParentFiltersNames($fName); foreach ($parentFiltersNames as $key => $parentName) { $wheres[] = RunnerPage::_getFieldSQLDecrypt($parentName, $connection, $pSet, $this->cipherer) . "=" . $this->cipherer->MakeDBValue($parentName, $parentValues[$key], "", true); } return "(" . implode(" AND ", $wheres) . ")"; case 'checked': if ($fValue != "on" && $fValue != "off") { return ""; } $bNeedQuotes = NeedQuotes($fieldType); include_once getabspath("classes/controls/Control.php"); include_once getabspath("classes/controls/CheckboxField.php"); return CheckboxField::constructFieldWhere($fullFieldName, $bNeedQuotes, $fValue == "on", $pSet->getFieldType($fName), $connection->dbType); case 'slider': if ($dateField) { return FilterIntervalDateSlider::getDateSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } if ($timeField) { include_once getabspath("classes/controls/FilterIntervalTimeSlider.php"); return FilterIntervalTimeSlider::getTimeSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } return $this->cipherer->MakeDBValue($fName, $fValue, "", true) . "<=" . $fullFieldName . " AND " . $fullFieldName . "<=" . $this->cipherer->MakeDBValue($fName, $sValue, "", true); case 'moreequal': if ($dateField) { return FilterIntervalDateSlider::getDateSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } if ($timeField) { include_once getabspath("classes/controls/FilterIntervalTimeSlider.php"); return FilterIntervalTimeSlider::getTimeSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } return $this->cipherer->MakeDBValue($fName, $fValue, "", true) . "<=" . $fullFieldName; case 'lessequal': if ($dateField) { return FilterIntervalDateSlider::getDateSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } if ($timeField) { include_once getabspath("classes/controls/FilterIntervalTimeSlider.php"); return FilterIntervalTimeSlider::getTimeSliderWhere($fName, $pSet, $this->cipherer, $this->tName, $fValue, $sValue, $filterType, $fullFieldName); } return $fullFieldName . "<=" . $this->cipherer->MakeDBValue($fName, $fValue, "", true); default: return ""; } }
/** * Get a case condition basing on the interval's limit types * @param Array interval * @return String */ protected function getCaseCondition($interval) { return FilterIntervalList::getIntervalFilterWhere($this->fName, $interval, $this->pSet, $this->cipherer, $this->tName, $this->connection); }