コード例 #1
0
 /**
  * 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 "";
     }
 }
コード例 #2
0
 /**
  * Get where/when conditions basing on the interval's bounds types and limit values
  *
  * The function is static because It can be invoked through the getIntervalFilterWhere
  * static method from the SearchClause object to build the filters' SQL where clause
  *
  * @param String fName
  * @param String fullFieldName
  * @param Array intervalData
  * @param Object pSet
  * @param String tableName
  * @param Boolean inverted	The flag indicating if the codition is prepared for the 'Other values'
  * interval (false) or not (true).	
  * @return String
  */
 static function getLimitsConditions($fName, $fullFieldName, $intervalData, $cipherer, $tableName, $connection, $inverted = false)
 {
     $signLow = FilterIntervalList::getIntervalSign($intervalData["lowerLimitType"], true, $inverted);
     $signUp = FilterIntervalList::getIntervalSign($intervalData["upperLimitType"], false, $inverted);
     $condition = array();
     if ($signLow) {
         $fValue = FilterIntervalList::getLimitValue($fName, $intervalData, $cipherer, $tableName, true);
         if ($intervalData["caseSensetive"]) {
             $condition[] = $fValue . $signLow . $fullFieldName;
         } else {
             $condition[] = $connection->upper($fValue) . $signLow . $connection->upper($fullFieldName);
         }
     }
     if ($signUp) {
         $fValue = FilterIntervalList::getLimitValue($fName, $intervalData, $cipherer, $tableName, false);
         if ($intervalData["caseSensetive"]) {
             $condition[] = $fullFieldName . $signUp . $fValue;
         } else {
             $condition[] = $connection->upper($fullFieldName) . $signUp . $connection->upper($fValue);
         }
     }
     return "(" . implode($inverted ? " OR " : " AND ", $condition) . ")";
 }