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

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • 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
  • 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
  • ForeignKey
  • Hierarchy
  • HTMLText
  • HTMLVarchar
  • ImportLog_Item
  • Int
  • ManagerEmailOrderNotification
  • Material3D_File
  • MediawebPage_File
  • MediawebPage_Photo
  • MobileContentDecorator
  • Money
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • OrderDataObject
  • OrderHandlersDecorator
  • OrderItemVariationDecorator
  • OrderService
  • OrderServiceOrder
  • OrdersExportDecorator
  • PageIcon
  • PageWidgets
  • Payment
  • PaymentMethodShippingDecorator
  • PaymentOrderExtension
  • Percentage
  • PhotoAlbumItem
  • PhotoAlbumProductLinkDecorator
  • PhotoAlbumWidgetLinkDecorator
  • PhotoGalleryHomepageWidget_Item
  • PrimaryKey
  • Product3DDecorator
  • ProductCatalogCatalogLinkedDecorator
  • 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 a short text field.
 4  * @package sapphire
 5  * @subpackage model
 6  */
 7 class Varchar extends StringField {
 8     
 9     protected $size;
10      
11     /**
12      * Construct a new short text field
13      * @param $name string The name of the field
14      * @param $size int The maximum size of the field, in terms of characters
15      * @param $options array Optional parameters, e.g. array("nullifyEmpty"=>false). See {@link StringField::setOptions()} for information on the available options
16      * @return unknown_type
17      */
18     function __construct($name, $size = 50, $options = array()) {
19         $this->size = $size ? $size : 50;
20         parent::__construct($name, $options);
21     }
22     
23     /**
24      * (non-PHPdoc)
25      * @see DBField::requireField()
26      */
27     function requireField() {
28         $parts = array(
29             'datatype'=>'varchar',
30             'precision'=>$this->size,
31             'character set'=>'utf8',
32             'collate'=>'utf8_unicode_ci',
33             'arrayValue'=>$this->arrayValue
34         );
35         
36         $values = array(
37             'type' => 'varchar',
38             'parts' => $parts
39         );
40             
41         DB::requireField($this->tableName, $this->name, $values);
42     }
43     
44     /**
45      * Return the first letter of the string followed by a .
46      */
47     function Initial() {
48         if($this->hasValue()) return $this->value[0] . '.';
49     }
50     
51     /**
52      * Ensure that the given value is an absolute URL.
53      */
54     function URL() {
55         if(ereg('^[a-zA-Z]+://', $this->value)) return $this->value;
56         else return "http://" . $this->value;
57     }
58 
59     /**
60      * Return the value of the field in rich text format
61      * @return string
62      */
63     function RTF() {
64         return str_replace("\n", '\par ', $this->value);
65     }
66 
67     /**
68      * Returns the value of the string, limited to the specified number of characters
69      * @param $limit int Character limit
70      * @param $add string Extra string to add to the end of the limited string
71      * @return string
72      */
73     function LimitCharacters($limit = 20, $add = "...") {
74         $value = trim($this->value);
75         return (mb_strlen($value) > $limit) ? mb_substr($value, 0, $limit) . $add : $value;
76     }
77 
78     /**
79      * (non-PHPdoc)
80      * @see DBField::scaffoldFormField()
81      */
82     public function scaffoldFormField($title = null, $params = null) {
83         if(!$this->nullifyEmpty) {
84             // Allow the user to select if it's null instead of automatically assuming empty string is
85             return new NullableField(new TextField($this->name, $title));
86         } else {
87             // Automatically determine null (empty string)
88             return parent::scaffoldFormField($title);
89         }
90     }
91 }
92 
93 ?>
94 
[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.1 API Docs API documentation generated by ApiGen 2.8.0