Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • ExactMatchFilterWithEmpty
  • LeftAndMainQuota
  • TextFieldWithEmptyFlag
  • WebylonSiteConfig
 1 <?php
 2 /**
 3  * Ôčëüňđ ďî ňĺęńňîâîěó ďîëţ ń âîçěîćíîńňüţ ďîčńęŕ ďóńňîăî çíŕ÷ĺíč˙
 4  * 
 5  * @package webylon
 6  * @author menedem  
 7  */
 8 class ExactMatchFilterWithEmpty extends SearchFilter {
 9     
10     private $need_empty = false;
11         
12     function setEmpty($val=true) {
13         $this->need_empty = $val;
14     }
15     
16     function setValue($val) {
17         if(is_array($val) && isset($val['IsEmpty']) && ((int)$val['IsEmpty'])) {
18             $this->setEmpty();
19         } else {
20             $this->value = $val;
21         }
22     }
23     
24     /**
25      * Applies an exact match (equals) on a field value.
26      *
27      * @return unknown
28      */
29     public function apply(SQLQuery $query) {
30         $query = $this->applyRelation($query);      
31         if ($this->need_empty) {            
32             return $query->where(sprintf(
33                 "(%s = '' OR %s IS NULL)",
34                 $this->getDbName(),
35                 $this->getDbName()              
36             ));
37         } else {            
38             return $query->where(sprintf(
39                 "%s = '%s'",
40                 $this->getDbName(),
41                 Convert::raw2sql($this->getValue())
42             ));
43             
44         }
45     }
46     
47     public function isEmpty() {
48         return ($this->getValue() == null || $this->getValue() == '') && !$this->need_empty; // 
49     }
50 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0