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  * Иен терфейс Cms для управления импортом в каталог товаров
  4  *
  5  * @author menedem
  6  */
  7 class ImportAdmin extends ModelAdmin {
  8     
  9     public static $managed_models = array(   
 10       'ImportLog'
 11     );
 12 
 13     static $url_segment = 'import'; 
 14     static $menu_title = 'Import';
 15     static $menu_priority = -10;
 16 
 17     public static $collection_controller_class = "ImportAdmin_CollectionController";
 18   
 19     function getLastLog(){      
 20         return ImportLog::get_last_log();
 21     }
 22     
 23     function getWaitforstart() {
 24         return file_exists(CatalogImportTask::absolute_import_path('start_ok'));
 25     }
 26     
 27     function getIsImportCanceled() {
 28         $rs = Session::get('Import.ImportCanceled');
 29         Session::clear('Import.ImportCanceled');
 30         return $rs;     
 31     }
 32     
 33     function getImportValidationMessage() {     
 34         $rs = Session::get('Import.ValidationMessage');
 35         Session::clear('Import.ValidationMessage');
 36         return $rs;
 37     }
 38         
 39 }
 40 
 41 
 42 class ImportAdmin_CollectionController extends ModelAdmin_CollectionController {
 43 
 44     public function getModelSidebar() {
 45         return $this->renderWith('ImportAdminModelSidebar');
 46     }
 47     
 48     public function ImportForm() {
 49         $sc = SiteConfig::current_site_config();
 50         $fields = new FieldSet();
 51         
 52         $fileField = new FileField('ImportFile', _t('ImportAdmin.ImportFile','Import File'));
 53         $fileField->allowedExtensions = array('xml');
 54         $uploadValidator = new Upload_Validator();
 55         $uploadValidator->setAllowedExtensions(array('xml'));
 56         $fileField->setValidator($uploadValidator);     
 57         $fields->push($fileField);
 58         
 59         $fields->push(new DropdownField("StartPage", _t('ImportSiteConfig.StartPage', 'Start Page'), $sc->getImportStartPageMap(), $sc->StartPage));
 60         $fields->push(new DropdownField('ImportMode', _t('ImportAdmin.ImportMode','Import Mode'), $sc->getImportModeMap(), $sc->ImportMode));
 61         $fields->push(new DropdownField('OldItemAction', _t('ImportSiteConfig.OldItemAction','OldItemAction'), $sc->getOldItemActionMap(), $sc->OldItemAction));
 62         $fields->push(new CheckboxField('ClearCategory',  _t('ImportAdmin.ClearCategory','Clear Category'), $sc->ClearCategory=='true'));
 63         $fields->push(new CheckboxField('ClearProducts', _t('ImportAdmin.ClearProducts','Clear Products'), $sc->ClearProducts=='true'));
 64         
 65         //$fields->push(new FileField('UploadFileToValidate', 'Файл импорта для валидации'));
 66         
 67         $actions = new FieldSet(
 68             new FormAction('prepareImport', _t('ImportAdmin.PrepareImport','Prepare Import')),
 69             new FormAction('cancelImport', _t('ImportAdmin.CancelImport','Cancel Import')),
 70             new FormAction('validateImport', _t('ImportAdmin.ValidateImport','Validate Import File'))
 71         );
 72         
 73         $validator = new RequiredFields(array('ImportFile', 'ImportMode'));
 74         $validator->setJavascriptValidationHandler('none');
 75         
 76         $form = new Form(
 77             $this,
 78             'ImportForm',
 79             $fields,
 80             $actions,
 81             $validator
 82         );
 83         return $form;
 84         
 85     }
 86     
 87     /*
 88      * Подготовка к импорту:
 89      * - загрузка файла импорта  и копирование в нужную папку
 90      * - создание файла настроек
 91      * - создание файла start_ok
 92      *
 93      */
 94     function prepareImport($data, $form) {
 95         if (isset($data['ImportFile']['tmp_name']) && is_file($data['ImportFile']['tmp_name'])) {
 96             move_uploaded_file($data['ImportFile']['tmp_name'], CatalogImportTask::import_filepath());
 97             $config = $this->customise(
 98                 array(
 99                     'Data' => $data
100                 )
101             )->renderWith('Config');
102             file_put_contents(CatalogImportTask::absolute_import_path('config.xml'), $config);
103             file_put_contents(CatalogImportTask::absolute_import_path('start_ok'), 'import by cms');
104             $form->sessionMessage(_t('ImportAddmin.ImportTaskCreated', 'File is uploded. Import start closely.'), 'info');
105             
106             if (file_exists(CatalogImportTask::absolute_import_path('cancelImport')))
107                 unlink(CatalogImportTask::absolute_import_path('cancelImport'));
108             if (file_exists(CatalogImportTask::absolute_import_path('validateImport')))
109                 unlink(CatalogImportTask::absolute_import_path('validateImport'));
110         } 
111         else {
112         }
113         Director::redirectBack();
114         
115     }
116     
117     /*
118      * Отмена импорта:
119      * - удаление импорта  и копирование в нужную папку
120      * - удаление файла настроек
121      * - удаление файла start_ok
122      *
123      */
124     function cancelImport($data, $form) {
125         if (is_file(CatalogImportTask::absolute_import_path('config.xml'))) 
126             unlink(CatalogImportTask::absolute_import_path('config.xml'));
127         if (is_file(CatalogImportTask::absolute_import_path('start_ok'))) { 
128             unlink(CatalogImportTask::absolute_import_path('start_ok'));        
129             $form->sessionMessage(_t('ImportAdmin.ImportTaskCanceled', 'Import Canceled.'), 'info');            
130             Session::set('Import.ImportCanceled',  _t('ImportAdmin.ImportTaskCanceled', 'Import Canceled.'));           
131         }
132         Director::redirectBack();
133     }
134     
135     /*
136      * Валидация файла импорта  
137      *
138      */
139     function validateImport($data, $form) {     
140         if (isset($data['ImportFile']['tmp_name']) && ($data['ImportFile']['size'] > 0) && is_file($data['ImportFile']['tmp_name'])) {
141             $validator = new XMLValidate($data['ImportFile']['tmp_name'], CatalogImportTask::xml_validate_file_path());
142             $rs = $validator->validate();
143             if ($rs != 'validated') {
144                 $errorText = '';
145                 foreach ($rs as $error)
146                     $errorText .= _t('CatalogImportTask.ValidationError', 'Validation Error') . ': ' . $error . '<br>';
147                 if ($errorText) {               
148                     Session::set('Import.ValidationMessage',  $errorText);
149                 }
150             } else {
151                 //Если нет ошибок - удаляем оставшийся файл с инфо о предыдущих ошибках валидации
152                 if (is_file(CatalogImportTask::absolute_import_path('validateImport')))  {          
153                     unlink(CatalogImportTask::absolute_import_path('validateImport'));
154                 }               
155                 Session::set('Import.ValidationMessage', _t('ImportAdmin.ValidationSuccess', 'Validation Success'));
156             }
157             unlink($data['ImportFile']['tmp_name']);
158         }
159         Director::redirectBack();
160     }
161 
162     public function CreateForm() {
163         return false;
164     }
165     
166     function getResultsTable($searchCriteria) {
167         $tf = parent::getResultsTable($searchCriteria);
168         /*
169         $tf->setHighlightConditions(array(
170             array('rule'=>'$Status == "process"', 'class' => 'process'),
171             array('rule'=>'$Status == "error"', 'class' => 'error'),
172         ));
173         */
174         return $tf;
175     }
176 }
[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