PluginProbe
Smart Forms – when you need more than just a contact form / trunk
Smart Forms – when you need more than just a contact form vtrunk
trunk 0.5 0.5.5 0.6 0.7 0.8 0.8.5 0.9.1
smart-forms / php_classes / api / query / comparators / TextComparator.php

TextComparator.php in Smart Forms – when you need more than just a contact form trunk, at php_classes/api/query/comparators/TextComparator.php

41 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require_once SMART_FORMS_DIR.'php_classes/api/query/comparators/ComparatorBase.php';
4 class TextComparator extends ComparatorBase
5 {
6
7 public function Validate()
8 {
9 if($this->Comparator!='=' &&
10 $this->Comparator!='<>')
11 return 'Invalid Comparison for '.$this->Field['Id'].'. Allowed values =,<>,like,not like';
12
13
14
15 }
16
17 public function GetConditionString()
18 {
19 global $wpdb;
20 switch ($this->Comparator)
21 {
22 case '<>':
23 return $wpdb->prepare(" detail.value <> %s ",$this->Value);
24 case '=':
25 return $wpdb->prepare(" detail.value =%s",$this->Value);
26 case 'not like':
27 if(strlen($this->Value)<4)
28 {
29 return " detail.value not like '%".$wpdb->esc_like($this->Value)."%'";
30 }else
31 return $wpdb->prepare(" not match(detail.value) against(%s in boolean mode) ",'*'.$this->Value.'*');
32 case 'like':
33 if(strlen($this->Value)<4)
34 {
35 return " detail.value like '%".$wpdb->esc_like($this->Value)."%'";
36 }else
37 return $wpdb->prepare(" match(detail.value) against(%s in boolean mode)",'*'.$this->Value.'*');
38 }
39 }
40 }
41