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 /**
  4  * Объект лога импорта. Создается на каждый запуск импорта.  
  5  * Хранит даты начала и окончания, дату каталога, статус и сообщение статуса, а также протокол импорта
  6  * включающий в себя все сообщения о его ходе 
  7  *
  8  */
  9 class ImportLog extends DataObject {
 10     
 11     static $db = array(
 12         'StartTime' => 'SS_Datetime',
 13         'EndTime' => 'SS_Datetime',
 14         'CatalogDate' => 'SS_Datetime',     
 15         'Status' => "Enum('process,ok,error')",
 16         'StatusMessage' => 'Text'       
 17     );
 18     
 19     static $has_many = array(
 20         'Items' => 'ImportLog_Item'
 21     );
 22     
 23     static $searchable_fields = array(
 24 //      'StartTime', //!!! TODO добавить в форму - форму надо делать вручную
 25         'Status',
 26     );
 27    
 28     static $summary_fields = array(
 29         'StartTime',
 30         'Duration',
 31         'TextStatus',
 32         'StatusMessage',     
 33         'CatalogDate', 
 34     );
 35     
 36     static $default_sort = 'ID DESC';
 37     
 38     /**
 39      * Получение лога последнего импорта
 40      * 
 41      * 
 42      * @return DataObject
 43      */
 44     static function get_last_log() {
 45         return DataObject::get_one('ImportLog', '', true, 'ID DESC');
 46     }
 47 
 48     static function optimize_log_tables($max_log_count) {
 49         $max_log_count -= 1;
 50         $oldImportLogs = DataObject::get('ImportLog', '', 'ID DESC', '', "$max_log_count,100");
 51         if ($oldImportLogs) {
 52             foreach($oldImportLogs as $oldImportLog) {
 53                 $oldImportLog->delete();
 54             }
 55         }
 56         DB::Query("OPTIMIZE TABLE `ImportLog_Item`");
 57         DB::Query("OPTIMIZE TABLE `ImportLog`");
 58     }
 59     
 60     function fieldLabels($includerelations = true) {
 61         $labels = parent::fieldLabels($includerelations);
 62         $labels['LastEdited'] = _t('ImportLog.LastEdited', 'Last Edited'); 
 63         $labels['Duration'] = _t('ImportLog.Duration', 'Duration');
 64         $labels['TextStatus'] = _t('ImportLog.Status', 'Status');
 65         return $labels;
 66     }
 67     
 68     function populateDefaults() {
 69         parent::populateDefaults();
 70         $this->StartTime = date('Y-m-d H:i:s');
 71         $this->Status = 'process';
 72         $this->StatusMessage = _t('ImportLog.ImportStart', 'Import Start');
 73     }
 74     
 75     function getCMSFields() {
 76         $fields = new FieldSet();
 77         $fields->push(new LiteralField('LogTextResult', $this->renderWith('ImportLog')));       
 78         return $fields;
 79     }
 80     
 81     /**
 82      * Добавление сообщения к протоколу импорта
 83      * 
 84      * @param string $message 
 85      * @param string $status 
 86      *      
 87      */
 88     function addLog($message, $status='message') {
 89         $item = new ImportLog_Item();
 90         $item->Message = $message;
 91         $item->Status = $status;
 92         $item->ImportLogID = $this->ID;
 93         $item->write();     
 94     }
 95     
 96     /**
 97      * Установка статуса импорта (с сообщением)
 98      * 
 99      * @param string $type 
100      * @param string $message 
101      *   
102      */
103     function setStatusType($type, $message) {
104         $this->Status = $type;
105         $this->StatusMessage = $message;
106         $this->write();
107     }
108     
109     /**
110      * Подсчет длительности импорта
111      * 
112      * @return string
113      */
114     function Duration() {
115         $end = $this->EndTime ? $this->EndTime : $this->LastEdited;
116 //      return strtotime($end) - strtotime($this->StartTime);
117         return gmdate('H:i:s', strtotime($end) - strtotime($this->StartTime));
118     }
119     
120     /**
121      * Возврат локализованного статуса текущего импорта
122      * 
123      * @return string
124      */
125     function TextStatus() {
126         return _t('ImportLog.Status_' . $this->Status, $this->Status);
127     }
128     
129     function onBeforeWrite() {
130         parent::onBeforeWrite();
131         if (!$this->EndTime && $this->Status != 'process') {
132             $this->EndTime = date('Y-m-d H:i:s');
133         }
134     }
135     
136     function onBeforeDelete() {
137         parent::onBeforeDelete();
138         
139         if ($this->Items()->Count()) {
140             foreach($this->Items() as $item) {
141                 $item->delete();
142             }
143         }
144     }
145     
146     function canEdit() {
147         return false;
148     }   
149 }
150 
151 /*
152  * Сообщение протокола импорта
153  */
154 class ImportLog_Item extends DataObject {
155     static $db = array(     
156         'Status' => "Enum('message,warning,error')",
157         'Message' => 'Text'
158     );  
159     
160     static $has_one = array(
161         'ImportLog' => 'ImportLog'
162     );
163 }
[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