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  * Represents an enumeration field.
 4  * @package sapphire
 5  * @subpackage model
 6  */
 7 class Enum extends DBField {
 8     
 9     protected $enum, $default;
10     
11     public static $default_search_filter_class = 'ExactMatchFilter';
12     
13     /**
14      * Create a new Enum field.
15      * You should create an enum field like this: 
16      *              "MyField" => "Enum('Val1, Val2, Val3', 'Val1')"
17      *  or:         "MyField" => "Enum(Array('Val1', 'Val2', 'Val3'), 'Val1')"
18      *  but NOT:    "MyField" => "Enum('Val1', 'Val2', 'Val3', 'Val1')"
19      * @param enum: A string containing a comma separated list of options or an array of Vals.
20      * @param default The default option, which is either NULL or one of the items in the enumeration.
21      */
22     function __construct($name, $enum = NULL, $default = NULL) {
23         if($enum) {
24             if(!is_array($enum)){
25                 $enum = preg_split("/ *, */", trim($enum));
26             }
27 
28             $this->enum = $enum;
29             
30             // If there's a default, then       
31             if($default) {
32                 if(in_array($default, $enum)) {
33                     $this->default = $default;
34                 } else {
35                     user_error("Enum::__construct() The default value '$default' does not match any item in the enumeration", E_USER_ERROR);
36                 }
37                 
38             // By default, set the default value to the first item
39             } else {
40                 $this->default = reset($enum);
41             }
42         }
43         parent::__construct($name);
44     }
45     
46     function requireField(){
47         $parts=Array('datatype'=>'enum', 'enums'=>$this->enum, 'character set'=>'utf8', 'collate'=> 'utf8_unicode_ci', 'default'=>$this->default, 'table'=>$this->tableName, 'arrayValue'=>$this->arrayValue);
48         $values=Array('type'=>'enum', 'parts'=>$parts);
49         DB::requireField($this->tableName, $this->name, $values);
50 }
51     
52     /**
53      * Return a dropdown field suitable for editing this field 
54      */
55     function formField($title = null, $name = null, $hasEmpty = false, $value = "", $form = null, $emptyString = null) {
56         if(!$title) $title = $this->name;
57         if(!$name) $name = $this->name;
58 
59         $field = new DropdownField($name, $title, $this->enumValues($hasEmpty), $value, $form, $emptyString);
60             
61         return $field;      
62     }
63 
64     public function scaffoldFormField($title = null, $params = null) {
65         return $this->formField($title);
66     }
67     
68     function scaffoldSearchField($title = null) {
69         $anyText = _t('Enum.ANY', 'Any');
70         return $this->formField($title, null, false, '', null, "($anyText)");
71     }
72 
73     function hasValue() {
74         return ($this->value !== '' && $this->value !== null);
75     }
76     
77     /**
78      * Return the values of this enum, suitable for insertion into a dropdown field.
79      */
80     function enumValues($hasEmpty = false) {
81         return ($hasEmpty) ? array_merge(array('' => ''), ArrayLib::valuekey($this->enum)) : ArrayLib::valuekey($this->enum);
82     }
83     
84     function Lower() {
85         return StringField::Lower();
86     }
87     function Upper() {
88         return StringField::Upper();
89     }
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