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

  • Address
  • AddSubsiteTask
  • Announcement
  • AnnouncementDecorator
  • AnnouncementHolder
  • AssociatedFolderDecorator
  • AttachedFiles
  • AudioPhpCaptcha
  • AutoCompleteField
  • Base1CExchanger
  • BookingOrder_StatusLog
  • CalendarUtil
  • CalendarWidgetExtention
  • CatalogCatalogLinkedDecorator
  • CatalogOldFieldsDecorator
  • CatalogProductLinkedDecorator
  • CheckoutStep_ShippingMethod
  • ChequePayment
  • ClearHistoryTask
  • ClientEmailOrderNotification_SiteConfig
  • ClientVKOrderNotification_SiteConfig
  • CommentsSiteConfig
  • ContactsPage
  • CookieExtention
  • CostTableShippingRate
  • CustomMenu
  • CustomMenuAdmin
  • CustomMenuDecorator
  • CustomMenuHolder
  • CustomMenuItem
  • CustomPayment
  • DataObjectLoggerExtension
  • DataObjectSubsites
  • DefaultCMSActionDecorator
  • DocPage
  • DocumentDirection
  • DocumentHaving
  • DocumentSearchForm
  • DocumentSiteConfig
  • DocumentsPage
  • DocumentType
  • DOMUtil
  • ExtendPageAnnouncement
  • ExtendPagePoll
  • FavoriteExtention
  • FavoritePage
  • FavoriteProductMemberExtention
  • FavoriteProducts
  • FileOversizeDecorator
  • FindCyrillicSiteConfig
  • FolderRenameTask
  • GDMergeAlpha
  • HomePage
  • ImageAutoResize
  • ImageResizeTask
  • ImportCatalog1C_Importer
  • ImportCatalogSiteConfig
  • ImportSiteConfig
  • LoggerAdmin
  • LogItem
  • ManagerEmailOrderNotification_SiteConfig
  • MapObject
  • MapObjectGroup
  • MapPage
  • MediawebForm
  • MemberLoggerExtension
  • MonumentsSiteConfig
  • MultiUploadConfig
  • NearestEventExtention
  • NewDocumentsAdmin
  • NewsArchive
  • NewsEntry
  • NewsHolder
  • NewsSiteConfig
  • Order_StatusLog
  • Orders1CExchange_Exporter
  • 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
  • ProductCatalogImportTask
  • ProductOldFieldsDecorator
  • ProductParamValue_BoolValueField
  • ProductParamValue_MultiValueField
  • ProductParamValue_MultiValueSetField
  • ProductParamValue_ValueField
  • ProductProductLinkedDecorator
  • PublHolder
  • Publication
  • PublicationSiteTree
  • RatingDataObject
  • RatingExtension
  • RealtySiteConfigDecorator
  • RecentComments
  • RecentFiles
  • RecentPages
  • RelatedPageLink
  • RoomRate_PriceField
  • RussianUpLower
  • SberbankPayment
  • SberbankPayment_Handler
  • SetMainSiteHomePageTypeTask
  • ShippingEstimator
  • ShippingPackage
  • ShowUserFromExtension
  • ShowViewedProductExtention
  • SiteConfigDecorator
  • SiteConfigSubsites
  • SiteTreeSubsites
  • SMSCOrderNotification_SiteConfig
  • SMSOrderNotification_SiteConfig
  • Socle
  • SocleSize
  • SortCMSActionDecorator
  • SS_Report_FakeQuery
  • SSMorphy
  • SSNController
  • SteppedCheckout_PageMessages
  • SubpageListField
  • SubscribeFormAllPagesExtension
  • SubsiteDropdownField
  • SubsiteReportWrapper
  • TableShippingRate
  • UnitellerPayment
  • UnitellerPayment_Handler
  • UnmoderatedComments
  • VAT
  • VideoManager
  • VideoSiteConfig
  • ViewedProductExtention
  • WatermarkImage
  • WatermarkSiteConfig
  • WeightTableShippingRate
  • XMLValidate
  • YaMoneyPayment
  • YaMoneyPayment_Handler
  • YMLExporter
  • YMLSiteConfig

Interfaces

  • 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
  • validEmailAddr
  • wrapImagesInline
  • wrapImagesInline_rewriter
  1 <?php
  2 
  3 /**
  4  * Description of NewsEntry
  5  *
  6  * @author inxo
  7  */
  8 class NewsEntry extends Page {
  9 
 10     static $can_be_root = false;
 11     static $allowed_children = "none";
 12     static $default_parent = "NewsHolder";
 13 
 14     static $db = array(
 15         'Date' => 'Date',
 16         'Description' => 'Text',
 17         'Important' => 'Boolean', // важная новости
 18     );
 19 
 20     static $has_one = array(
 21         'Photo' => 'Image',
 22     );
 23 
 24     static $defaults = array(
 25         'ShowInMenus' => 0,
 26         'ShowInSiteMap' => 0,
 27         'ShowInSearch' => 1,
 28         'ShowOnlyInTab' => 1,
 29         'CanCreateChildren' => array(0),
 30         'Viewers' => 'Anyone',
 31         'Editors' => 'LoggedInUsers',
 32         'Date' => 'now()',
 33     );
 34 
 35     static $summary_fields = array(
 36         'Date', 'Title', 'Description'
 37     );
 38 
 39     static $searchable_fields = array(
 40         'Title', 'Description', 'Content'
 41     );
 42     
 43     // флаг показа новостей только на вкладке или в дереве
 44     protected static $show_only_in_tab = 1;
 45     
 46     static function set_show_only_in_tab($value) {
 47         self::$show_only_in_tab = $value;
 48     }
 49     
 50     function getCMSFields() {
 51         $fields = parent::getCMSFields();
 52         $fields->removeByName('MenuTitle');
 53 
 54         $dateField = new DateField('Date', $this->fieldLabel('Date'));
 55         if (!property_exists('FormField', 'use_html5') || !FormField::use_html5()) {
 56             $dateField->setLocale(Member::currentUser()->Locale);
 57             $dateField->setConfig('dateformat', 'dd/MM/yyyy');
 58             $dateField->setConfig('showcalendar', true);
 59         }
 60         $fields->addFieldToTab('Root.Content.Main', $dateField, 'Title');
 61         
 62         $m = new TextareaField('Description', $this->fieldLabel('Description'));
 63         $fields->addFieldToTab('Root.Content.Main', $m, 'Content');
 64         
 65         $fields->addFieldToTab('Root.Content.Main', new CheckboxField('Important', $this->fieldLabel('Important')), 'Description');
 66 
 67         $fields->addFieldToTab('Root.Content', new Tab('Image', $this->fieldLabel('Photo')), 'PagePhotos');
 68         $i = new ImageField('Photo', $this->fieldLabel('Photo'));
 69         $folder = ($this->AssociatedFolderName) ? $this->AssociatedFolderName : 'News';
 70         $i->setFolderName($folder);
 71         $fields->addFieldToTab("Root.Content.Image", $i);
 72         return $fields;
 73     }
 74 
 75     public function getCMSActions() {
 76         Requirements::javascript('webylon/javascript/SubpageAction.js');
 77         $fields = parent::getCMSActions();
 78         $fields->push(new HiddenField('backLink', '', $this->Parent()->ID));
 79         $fields->insertFirst(new FormAction('goBack', _t('News.BACKBUTTON', 'Back')));
 80         return $fields;
 81     }
 82 
 83     public function getCMSValidator() {
 84         return new RequiredFields('Title');
 85 //        return new RequiredFields('Date', 'Title');
 86     }
 87 
 88     public function populateDefaults() {
 89         parent::populateDefaults();
 90         $this->setField('Date', date('Y-m-d', strtotime('now')));
 91         $this->ShowOnlyInTab = (self::$show_only_in_tab) ? 1 : 0;
 92     }
 93     
 94     function requireDefaultRecords() {
 95         parent::requireDefaultRecords();
 96         $state = (int)self::$show_only_in_tab;
 97         // черновые версии новостей
 98         DB::query("UPDATE `Page` SET `ShowOnlyInTab` = {$state} WHERE `ID` in (SELECT `ID` FROM `NewsEntry`)");         
 99         // опубликованные новости
100         DB::query("UPDATE `Page_Live` SET `ShowOnlyInTab` = {$state} WHERE `ID` in (SELECT `ID` FROM `NewsEntry_Live`)");           
101     }
102 
103     function onBeforeWrite() {
104         parent::onBeforeWrite();
105         if ($this->PhotoID) {
106             $img = DataObject::get_by_id('Image', $this->PhotoID);
107             if (!$img || !$img->ID) {
108                 $this->PhotoID = 0;
109             }
110         }       
111         $this->ShowOnlyInTab = (self::$show_only_in_tab) ? 1 : 0;
112     }
113     
114     function BackLink() {       
115         if (isset($_SERVER['HTTP_REFERER'])) {
116             $baseURL = Director::absoluteBaseURL();
117             if ($_SERVER['HTTP_REFERER'] == $baseURL) {             
118                 return $baseURL;
119             }
120             if ($archivePage = DataObject::get_one('NewsArchive')) {                    
121                 $link = $archivePage->AbsoluteLink();
122                 if (strpos($_SERVER['HTTP_REFERER'], $link) !== false) {
123                     return $link;
124                 }
125             }
126         }
127         return $this->Parent()->Link();
128     }
129 
130     function RSSContent() {
131         if (strlen($this->Description) > 0) {
132             return $this->Description;
133         }
134         return $this->Content;
135     }
136 }
137 
138 class NewsEntry_Controller extends Page_Controller {
139 
140 }
141 
142 
[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