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

  • Address
  • AddSubsiteTask
  • Announcement
  • AnnouncementDecorator
  • AnnouncementHolder
  • AssociatedFolderDecorator
  • AttachedFiles
  • AudioPhpCaptcha
  • AutoCompleteField
  • BaseMediawebImportParser
  • BookingOrder_StatusLog
  • CalendarUtil
  • CalendarWidgetExtention
  • CatalogCatalogLinkedDecorator
  • CatalogImportTask
  • CatalogOldFieldsDecorator
  • CatalogProductLinkedDecorator
  • CheckoutStep_ShippingMethod
  • ChequePayment
  • ClearHistoryTask
  • ClientEmailOrderNotification_SiteConfig
  • ClientVKOrderNotification_SiteConfig
  • CommentsSiteConfig
  • ContactsPage
  • CookieExtention
  • CostTableShippingRate
  • CustomMenu
  • CustomMenuAdmin
  • CustomMenuDecorator
  • CustomMenuHolder
  • CustomMenuItem
  • CustomPayment
  • DataObjectLoggerExtension
  • DataObjectSubsites
  • DefaultCMSActionDecorator
  • DeleteOldAssociatedFoldersTask
  • DocPage
  • DocumentDirection
  • DocumentHaving
  • DocumentSearchForm
  • DocumentSiteConfig
  • DocumentsPage
  • DocumentType
  • DOMUtil
  • ExtendPageAnnouncement
  • ExtendPageNews
  • ExtendPagePoll
  • FileOversizeDecorator
  • FindCyrillicSiteConfig
  • FolderRenameTask
  • GDMergeAlpha
  • HomePage
  • ImageAutoResize
  • ImageResizeTask
  • ImportAdmin
  • ImportAutoStartTask
  • ImportCatalogMessage
  • ImportConfig
  • ImportLog
  • ImportSiteConfig
  • ImportTask
  • LoggerAdmin
  • LogItem
  • ManagerEmailOrderNotification_SiteConfig
  • MapObject
  • MapObjectGroup
  • MapPage
  • MediawebForm
  • MediawebImportParser
  • MemberLoggerExtension
  • MultiUploadConfig
  • NearestEventExtention
  • NewDocumentsAdmin
  • News_Controller
  • NewsEntry
  • NewsEntry_Controller
  • NewsHolder
  • NewsHolder_Controller
  • NewsLiveCalendarWidget
  • NewsSiteConfig
  • Order_StatusLog
  • Orders1CExchange
  • PageHideFieldsExtension
  • PageInformerRates
  • PageInformerWeather
  • Payment_Failure
  • Payment_Processing
  • Payment_Result
  • Payment_Success
  • PaymentMethod
  • PaymentSiteConfig
  • PayPalPayment
  • PayPalPayment_Handler
  • PhoneField
  • PhotoAlbumExtentions
  • PhpCaptcha
  • PhpCaptchaColour
  • PhpCaptchaField
  • phpMorphy
  • phpMorphy_AncodesResolver_AsIs
  • phpMorphy_AncodesResolver_Proxy
  • phpMorphy_AncodesResolver_ToDialingAncodes
  • phpMorphy_AncodesResolver_ToText
  • phpMorphy_AnnotDecoder_Base
  • phpMorphy_AnnotDecoder_Common
  • phpMorphy_AnnotDecoder_Factory
  • phpMorphy_AnnotDecoder_Predict
  • phpMorphy_FilesBundle
  • phpMorphy_Fsa
  • phpMorphy_Fsa_Decorator
  • phpMorphy_Fsa_Proxy
  • phpMorphy_Fsa_Sparse_File
  • phpMorphy_Fsa_Sparse_Mem
  • phpMorphy_Fsa_Sparse_Shm
  • phpMorphy_Fsa_Tree_File
  • phpMorphy_Fsa_Tree_Mem
  • phpMorphy_Fsa_Tree_Shm
  • phpMorphy_Fsa_WordsCollector
  • phpMorphy_GramInfo
  • phpMorphy_GramInfo_AncodeCache
  • phpMorphy_GramInfo_Decorator
  • phpMorphy_Graminfo_File
  • phpMorphy_Graminfo_Mem
  • phpMorphy_GramInfo_Proxy
  • phpMorphy_GramInfo_Proxy_WithHeader
  • phpMorphy_GramInfo_RuntimeCaching
  • phpMorphy_Graminfo_Shm
  • phpMorphy_GrammemsProvider_Base
  • phpMorphy_GrammemsProvider_Decorator
  • phpMorphy_GrammemsProvider_Empty
  • phpMorphy_GrammemsProvider_Factory
  • phpMorphy_GrammemsProvider_ForFactory
  • phpMorphy_GrammemsProvider_ru_RU
  • phpMorphy_GramTab
  • phpMorphy_GramTab_Empty
  • phpMorphy_GramTab_Proxy
  • phpMorphy_Link
  • phpMorphy_Link_Annot
  • phpMorphy_Link_Base
  • phpMorphy_Morphier_Base
  • phpMorphy_Morphier_Bulk
  • phpMorphy_Morphier_Common
  • phpMorphy_Morphier_Empty
  • phpMorphy_Morphier_Finder_Base
  • phpMorphy_Morphier_Finder_Common
  • phpMorphy_Morphier_Finder_Predict_Databse
  • phpMorphy_Morphier_Finder_Predict_Suffix
  • phpMorphy_Morphier_Helper
  • phpMorphy_Morphier_Predict_Database
  • phpMorphy_Morphier_Predict_Suffix
  • phpMorphy_Morphier_PredictCollector
  • phpMorphy_Semaphore
  • phpMorphy_Semaphore_Empty
  • phpMorphy_Semaphore_Nix
  • phpMorphy_Semaphore_Win
  • phpMorphy_Shm_Cache
  • phpMorphy_Shm_Cache_FileDescriptor
  • phpMorphy_Shm_Header
  • phpMorphy_Source_Dba
  • phpMorphy_Source_Fsa
  • phpMorphy_State
  • phpMorphy_Storage
  • phpMorphy_Storage_Factory
  • phpMorphy_Storage_File
  • phpMorphy_Storage_Mem
  • phpMorphy_Storage_Proxy
  • phpMorphy_Storage_Shm
  • phpMorphy_UnicodeHelper
  • phpMorphy_UnicodeHelper_Base
  • phpMorphy_UnicodeHelper_MultiByteFixed
  • phpMorphy_UnicodeHelper_singlebyte
  • phpMorphy_UnicodeHelper_ucs_2be
  • phpMorphy_UnicodeHelper_ucs_2le
  • phpMorphy_UnicodeHelper_ucs_4be
  • phpMorphy_UnicodeHelper_ucs_4le
  • phpMorphy_UnicodeHelper_utf_16_Base
  • phpMorphy_UnicodeHelper_utf_16be
  • phpMorphy_UnicodeHelper_utf_16le
  • phpMorphy_UnicodeHelper_utf_32_Base
  • phpMorphy_UnicodeHelper_utf_32be
  • phpMorphy_UnicodeHelper_utf_32le
  • phpMorphy_UnicodeHelper_utf_8
  • phpMorphy_WordDescriptor
  • phpMorphy_WordDescriptor_Collection
  • phpMorphy_WordDescriptor_Collection_Serializer
  • phpMorphy_WordForm
  • ProductImportV1Decorator
  • ProductOldFieldsDecorator
  • ProductProductLinkedDecorator
  • PublHolder
  • Publication
  • PublicationSiteTree
  • RatingDataObject
  • RatingExtension
  • RealtySiteConfigDecorator
  • RecentComments
  • RecentFiles
  • RecentPages
  • RelatedPageLink
  • RepairImportTask
  • RoomRate_PriceField
  • RussianUpLower
  • SberbankPayment
  • SberbankPayment_Handler
  • SetMainSiteHomePageTypeTask
  • ShippingEstimator
  • ShippingPackage
  • ShowUserFromExtension
  • SiteConfigDecorator
  • SiteConfigSubsites
  • SiteTreeSubsites
  • SMSCOrderNotification_SiteConfig
  • SMSOrderNotification_SiteConfig
  • SortCMSActionDecorator
  • SS_Report_FakeQuery
  • SSMorphy
  • SSNController
  • SteppedCheckout_PageMessages
  • SubpageListField
  • SubscribeFormAllPagesExtension
  • SubsiteDropdownField
  • SubsiteReportWrapper
  • TableShippingRate
  • UnitellerPayment
  • UnitellerPayment_Handler
  • UnmoderatedComments
  • VideoManager
  • VideoSiteConfig
  • WatermarkImage
  • WatermarkSiteConfig
  • WebylonImportAdmin
  • WebylonImportCatalog
  • WeightTableShippingRate
  • XMLValidate
  • YaMoneyPayment
  • YaMoneyPayment_Handler
  • YMLExporter
  • YMLSiteConfig

Interfaces

  • ImportInterface
  • PaymentObjectInterface
  • phpMorphy_AncodesResolver_Interface
  • phpMorphy_AnnotDecoder_Interface
  • phpMorphy_Fsa_Interface
  • phpMorphy_GramInfo_Interace
  • phpMorphy_GrammemsProvider_Interface
  • phpMorphy_GramTab_Interface
  • phpMorphy_Morphier_Finder_Interface
  • phpMorphy_Morphier_Interface
  • phpMorphy_Shm_Cache_Interface
  • phpMorphy_Source_Interface

Exceptions

  • phpMorphy_Exception

Functions

  • column_sort
  • column_sort_callback_basic
  • encodeFileForEmail
  • encodeMultipart
  • getMimeType
  • htmlEmail
  • loadMimeTypes
  • phpmorphy_overload_mb_funcs
  • plaintextEmail
  • processHeaders
  • QuotedPrintable_encode
  • supressOutput
  • validateError
  • validEmailAddr
  • wrapImagesInline
  • wrapImagesInline_rewriter
  1 <?php
  2 /**
  3  * Address model using a generic format for storing international addresses.
  4  * 
  5  * Typical Address Hierarcy:
  6  *  Continent
  7  *  Country
  8  *  State / Province / Territory (Island?)
  9  *  District / Suburb / County / City
 10  *      Code / Zip (may cross over the above)
 11  *  Street / Road - name + type: eg Gandalf Cresent
 12  *  (Premises/Building/Unit/Suite)
 13  *      (Floor/Level/Side/Wing)
 14  *  Number / Entrance / Room
 15  *  Person(s), Company, Department
 16  *
 17  * Collection of international address formats:
 18  * @see http://bitboost.com/ref/international-address-formats.html
 19  * xAL address standard:
 20  * @see https://www.oasis-open.org/committees/ciq/ciq.html#6
 21  * Universal Postal Union addressing standards:
 22  * @see http://www.upu.int/nc/en/activities/addressing/standards.html
 23  */
 24 class Address extends DataObject{
 25 
 26     static $db = array(
 27         'Country' => 'ShopCountry',  //level1: Country = ISO 2-character country code
 28         'PostalCode' => 'Varchar(20)',
 29         'State' => 'Varchar(100)', //level2: Locality, Administrative Area, State, Province, Territory, Island
 30         'City' => 'Varchar(100)', //level3: Dependent Locality, City, Suburb, County, District      
 31         'Address' => 'Varchar(255)', //Number + type of thoroughfare/street. P.O. box       
 32         
 33     );
 34     
 35     static $has_one = array(
 36         'Member' => 'Member'
 37     );
 38     
 39     static $required_fields = array(
 40         'Address',
 41         'City',
 42         'State',
 43         'Country'
 44     );
 45     
 46     /**
 47      * Tub-titles for address fields that describe what they are for
 48      * @var boolean
 49      */
 50     static $show_form_hints = false;
 51     
 52     function getCMSFields() {
 53         $fields = parent::getCMSFields();       
 54         $fields->replaceField('Country', new RestrictionRegionCountryDropdownField('Country', $this->fieldLabel('Country'), null, $this->Country));     
 55         return $fields;
 56     }
 57     
 58     /**
 59      * @todo: customise format and labels, based on passed locale
 60      * @param unknown_type $nameprefix
 61      */
 62     function getFormFields($nameprefix = ""){
 63         $countries = SiteConfig::current_site_config()->getCountriesList();
 64         //$countryfield = (count($countries)) ? new DropdownField($nameprefix."Country", _t('Address.COUNTRY','Country'),$countries) : new ReadonlyField($nameprefix."Country",_t('Address.COUNTRY','Country'));
 65         if (count($countries) == 0) {
 66             $countryfield = new ReadonlyField($nameprefix."Country", $this->fieldLabel('Country'));
 67         }
 68         else if (count($countries) == 1) {
 69             $countryfield = new HiddenField($nameprefix."Country", $this->fieldLabel('Country'), array_shift(array_keys($countries)));
 70         }
 71         else {
 72             $countryfield = new DropdownField($nameprefix."Country", $this->fieldLabel('Country'), $countries, 'RU');
 73             $countryfield->setHasEmptyDefault(true);
 74             $countryfield->setAutocomplete('country-name');
 75         }
 76         
 77         $fields = new FieldSet(
 78             $countryfield,          
 79             $postalcodefield = new TextField($nameprefix.'PostalCode', $this->fieldLabel('PostalCode')),
 80             $statefield = new TextField($nameprefix.'State', $this->fieldLabel('State')),
 81             $cityfield = new TextField($nameprefix.'City', $this->fieldLabel('City')),
 82             $addressfield = new TextField($nameprefix.'Address', $this->fieldLabel('Address'))
 83         );
 84         $postalcodefield->setAutocomplete('postal-code');
 85         $statefield->setAutocomplete('region');
 86         $cityfield->setAutocomplete('city');
 87         $addressfield->setAutocomplete('street-address');
 88         if(self::$show_form_hints){
 89             $addressfield->setRightTitle(_t("Address.ADDRESSHINT","street / thoroughfare number, name, and type or P.O. Box"));
 90             $cityfield->setRightTitle(_t("Address.CITYHINT","or suburb, county, district"));
 91             $statefield->setRightTitle(_t("Address.STATEHINT","or province, territory, island"));
 92         }
 93         $this->extend('updateFormFields',$fields, $nameprefix);
 94         return $fields;
 95     }
 96     
 97     /**
 98      * Get an array of fields that must be populated in a form.
 99      * Required fields can be customised via self::$required_fields
100      */
101     function getRequiredFields($nameprefix = ""){
102         $fields = array();
103         foreach(self::$required_fields as $field){
104             $fields[] = $nameprefix.$field;
105         }
106         $this->extend('updateRequiredFields',$fields, $nameprefix);
107         return $fields;
108     }
109     
110     /**
111      * Produces a map for loading/saving form fields.
112      */
113     function getFieldMap($prefix = ''){
114         $map = $this->getFormFields()->saveableFields();
115         foreach($map as $key => $value){
116             $map[$prefix.$key] = $key;
117             unset($map[$key]);
118         }
119         return $map;
120     }   
121     
122     /**
123      * Convert address to a single string.
124      */
125     function FullAddress($separator = ', '){
126         $fields = array(
127             'Country' => DBField::Create('ShopCountry', $this->Country)->Nice(),
128             'PostalCode' => $this->PostalCode,
129             'State' => $this->State,
130             'City' => $this->City,
131             'Address' => $this->Address,
132         );
133         $this->extend('updateFullAddress', $fields);
134         return implode($separator, array_filter($fields));
135     }
136     
137     function getTitle() {
138         return $this->FullAddress();
139     }
140     
141     function forTemplate(){
142         return $this->renderWith('Address');
143     }
144     
145     /**
146      * Add alias setters for fields which are synonymous
147      */
148     function setProvince($val){$this->State = $val;}
149     function setTerritory($val){$this->State = $val;}
150     function setIsland($val){$this->State = $val;}  
151     function setStreet($val){$this->Address = $val;}    
152     
153 }
[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