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 Decimal field.
 4  * @package sapphire
 5  * @subpackage model
 6  */
 7 
 8 //require_once 'Zend/Currency.php';
 9 
10 class Decimal extends DBField {
11     protected $wholeSize, $decimalSize, $defaultValue;
12 
13     public static $thousand_sep = ' ';
14     public static $decimal_sep = '.';
15     
16     /**
17      * Create a new Decimal field.
18      */
19     function __construct($name, $wholeSize = 9, $decimalSize = 2, $defaultValue = 0) {
20         $this->wholeSize = isset($wholeSize) ? $wholeSize : 9;
21         $this->decimalSize = isset($decimalSize) ? $decimalSize : 2;
22         $this->defaultValue = $defaultValue;
23         parent::__construct($name);
24     }
25     function setDecimal($value) {
26         $this->decimalSize = $value;
27     }
28     
29     function Nice($decimalSize = false) {
30         if ($decimalSize === false)
31             $decimalSize = $this->decimalSize;
32         return number_format($this->value, $decimalSize, self::$decimal_sep, self::$thousand_sep);
33     }
34     
35     function Int() {
36         return ceil( $this->value );
37     }
38 
39     function hasValue() {
40         return ($this->value != 0);
41     }
42     
43     function requireField() {
44         $parts=Array('datatype'=>'decimal', 'precision'=>"$this->wholeSize,$this->decimalSize", 'default'=>sprintf("%.{$this->decimalSize}f", $this->defaultValue), 'arrayValue'=>$this->arrayValue);
45         $values=Array('type'=>'decimal', 'parts'=>$parts);
46         DB::requireField($this->tableName, $this->name, $values);
47     }
48     
49     function saveInto($dataObject) {
50         $fieldName = $this->name;
51         if($fieldName) {
52             $dataObject->$fieldName = (float)preg_replace('/[^0-9.\-\+]/', '', $this->value);
53         } else {
54             user_error("DBField::saveInto() Called on a nameless '" . get_class($this) . "' object", E_USER_ERROR);
55         }
56     }
57     
58     public function scaffoldFormField($title = null, $params = null) {
59         return new NumericField($this->name, $title);
60     }
61         
62     public function nullValue() {
63         return "0.00";
64     }
65 
66     /**
67      * Return an encoding of the given value suitable for inclusion in a SQL statement.
68      * If necessary, this should include quotes.
69      */
70     function prepValueForDB($value) {
71         if($value === true) {
72             return 1;
73         } if(!$value || !is_numeric($value)) {
74             if(strpos($value, '[')===false)
75                 return '0';
76             else
77                 return addslashes($value);
78         } else {
79                         $value = str_replace(',', '.', $value);
80             return '\''.addslashes($value).'\'';
81         }
82     }
83     
84 }
85 
86 ?>
87 
[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