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

  • AdditionalMenuWidget_Item
  • AdvancedSliderHomepageWidget_Item
  • AssetManagerFolder
  • BannerWidget_Item
  • BaseObjectDecorator
  • BookingOrder
  • BookingPaymentMethod
  • BookingService
  • Boolean
  • ButtonsBlockHomepageWidget_Item
  • CarouselHomepageWidget_Item
  • CatalogFilter
  • CatalogRubricsHomepageWidget_CatalogDecorator
  • ClientEmailOrderNotification
  • ClientVKOrderNotification
  • ComponentSet
  • Currency
  • DatabaseAdmin
  • DataObject
  • DataObjectDecorator
  • DataObjectLog
  • DataObjectSet
  • DataObjectSet_Iterator
  • Date
  • DB
  • DBField
  • Decimal
  • DocumentItem
  • DocumentPage_File
  • Double
  • Enum
  • ErrorPageSubsite
  • FileDataObjectTrackingDecorator
  • FileImportDecorator
  • Float
  • FlowerGarden_Size
  • ForeignKey
  • Hierarchy
  • HouseCatalogProductDecorator
  • HTMLText
  • HTMLVarchar
  • Import1CLog
  • Import1CLog_File
  • Import1CLog_Item
  • Import1CLog_Task
  • ImportCatalog1C_PriceType
  • ImportCatalog1C_ProductProp
  • Int
  • ManagerEmailOrderNotification
  • Material3D_File
  • MediawebPage_File
  • MediawebPage_Photo
  • MobileContentDecorator
  • Money
  • MonumentGalleryItem
  • MonumentPhotoGallery
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • Notification
  • OrderDataObject
  • OrderDecorator
  • OrderHandlersDecorator
  • OrderItemDecorator
  • OrderItemVariationDecorator
  • Orders1CExchange_OrdersDecorator
  • OrderService
  • OrderServiceOrder
  • PageIcon
  • PageWidgets
  • Payment
  • PaymentMethodShippingDecorator
  • PaymentOrderExtension
  • Percentage
  • Person
  • PhotoAlbumItem
  • PhotoAlbumProductLinkDecorator
  • PhotoAlbumWidgetLinkDecorator
  • PhotoGalleryHomepageWidget_Item
  • PortraitType
  • PrimaryKey
  • Product3DDecorator
  • ProductCatalogCatalogLinkedDecorator
  • ProductImportLog
  • ProductImportLog_Item
  • ProductParam
  • ProductParamValue
  • ProductVariation
  • RatePeriod
  • RealtyImportLog
  • RealtyImportLog_Item
  • RedirectEntry
  • RoomOrder
  • RoomOrderPerson
  • RoomRate
  • RoomService
  • RoomServiceOrder
  • SberbankPaymentDecorator
  • SeoOpenGraphPageDecorator
  • ServiceOrder
  • ShippingMethodPaymentDecorator
  • ShopCountry
  • SimpleOrderCatalogDecorator
  • SimpleOrderProductDecorator
  • SiteConfigWidgets
  • SiteTreeDecorator
  • SiteTreeImportDecorator
  • SliderHomepageWidget_Item
  • SMSCOrderNotification
  • SMSOrderNotification
  • SortableDataObject
  • SQLMap
  • SQLMap_Iterator
  • SQLQuery
  • SS_Database
  • SS_Datetime
  • SS_Query
  • StringField
  • SubsiteDomain
  • Text
  • TextAnonsWidget_Item
  • Texture3D_File
  • Time
  • Varchar
  • Versioned
  • Versioned_Version
  • VideoCategory
  • VideoEntry
  • VKNotificationQueue
  • WebylonWidget_Item
  • YaMoneyPaymentDecorator
  • Year

Interfaces

  • CompositeDBField
  • CurrentPageIdentifier
  • DataObjectInterface
 1 <?php
 2 /**
 3  * An abstract base class for the string field types (i.e. Varchar and Text)
 4  * @package sapphire
 5  * @subpackage model
 6  * @author Pete Bacon Darwin
 7  *
 8  */
 9 abstract class StringField extends DBField {
10     protected $nullifyEmpty = true;
11 
12     /**
13      * Construct a string type field with a set of optional parameters
14      * @param $name string The name of the field
15      * @param $options array An array of options e.g. array('nullifyEmpty'=>false).  See {@link StringField::setOptions()} for information on the available options
16      */
17     function __construct($name = null, $options = array()) {
18         // Workaround: The singleton pattern calls this constructor with true/1 as the second parameter, so we must ignore it
19         if(is_array($options)){
20             $this->setOptions($options);
21         }
22         parent::__construct($name);
23     }
24     
25     /**
26      * Update the optional parameters for this field.
27      * @param $options array of options
28      * The options allowed are:
29      *   <ul><li>"nullifyEmpty"
30      *       This is a boolean flag.
31      *       True (the default) means that empty strings are automatically converted to nulls to be stored in the database.
32      *       Set it to false to ensure that nulls and empty strings are kept intact in the database.
33      *   </li></ul>
34      * @return unknown_type
35      */
36     function setOptions(array $options = array()) {
37         if(array_key_exists("nullifyEmpty", $options)) {
38             $this->nullifyEmpty = $options["nullifyEmpty"] ? true : false;
39         }
40     }
41     
42     /**
43      * Set whether this field stores empty strings rather than converting them to null
44      * @param $value boolean True if empty strings are to be converted to null
45      */
46     function setNullifyEmpty($value) {
47         $this->nullifyEmpty == $value ? true : false;
48     }
49     /**
50      * Get whether this field stores empty strings rather than converting them to null
51      * @return bool True if empty strings are to be converted to null
52      */
53     function getNullifyEmpty() {
54         return $this->nullifyEmpty;
55     }
56 
57     /**
58      * (non-PHPdoc)
59      * @see core/model/fieldtypes/DBField#hasValue()
60      */
61     function hasValue() {
62         return ($this->value || $this->value == '0') || ( !$this->nullifyEmpty && $this->value === '');
63     }
64 
65     /**
66      * (non-PHPdoc)
67      * @see core/model/fieldtypes/DBField#prepValueForDB($value)
68      */
69     function prepValueForDB($value) {
70         if ( !$this->nullifyEmpty && $value === '' ) {
71             return "'" . Convert::raw2sql($value) . "'";
72         } else {
73             return parent::prepValueForDB($value);
74         }
75     }
76 
77     
78     /**
79      * Return another DBField object with this value in lowercase.
80      */
81     function Lower() {
82         return DBField::create(get_class($this), strtolower($this->value), $this->name);
83     }
84 
85     /**
86      * Return another DBField object with this value in uppercase.
87      */
88     function Upper() {
89         return DBField::create(get_class($this), strtoupper($this->value), $this->name);
90     }
91 
92 }
93 
[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