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  * За основу взят аналогичный класс от sshop
  5  * TODO добавить итератор для шагов чтобы можно было выводить их список с указанием текущего положения формат (ID, Title, Link, IsCurrent, IsPast, IsFuture, Pos)
  6  *
  7  * @package cart
  8  * @subpackage steppedcheckout
  9  * @author dvp
 10  */
 11 class SteppedCheckout extends Extension {
 12 
 13     static $first_step = null; 
 14     
 15     /**
 16      * Массив шагов (ассоциативный)
 17      *
 18      * формат: 'название_шага' => 'Класс_шага'
 19      * Класс_шага должен иметь action название_шага - на нее передается управление при переходе на шаг
 20      * @see CheckoutStep
 21      *
 22      * @static
 23      */
 24     static $steps = null;
 25 
 26     /**
 27      * Настраивает шаги формы и подключает к CheckoutPage_Controller нужные расширения
 28      */
 29     static function setup($steps = null){
 30         CheckoutPage::$use_steps = true;
 31         
 32         // Если уже настроено - выходим. 2 раза настраивать нельзя
 33         if (self::$steps) return;
 34 
 35         if (!$steps) {
 36             // Попробуем создать шаги сами
 37             $steps = array();
 38             
 39             if (CartSiteConfig::CartRegistraionAvailable()) {
 40                 $steps['membership'] = 'CheckoutStep_Membership';
 41             }
 42 
 43             $steps['contactdetails'] = 'CheckoutStep_ContactDetails';
 44             
 45             if (Order::$use_shipping) {
 46                 $steps['shippingmethod'] = 'CheckoutStep_ShippingMethod';
 47             }
 48 
 49             if (Order::$use_payments) {
 50                 $steps['paymentmethod'] = 'CheckoutStep_PaymentMethod';
 51             }
 52 
 53             $steps['summary'] = 'CheckoutStep_Summary';
 54         }
 55 
 56         Object::add_extension("CheckoutPage_Controller", "SteppedCheckout");
 57         foreach($steps as $action => $classname){
 58             Object::add_extension("CheckoutPage_Controller", $classname);
 59         }
 60 
 61         if (!self::$first_step) {
 62             reset($steps);
 63             self::$first_step = key($steps);
 64         }
 65         self::$steps = $steps;
 66     }
 67 
 68     /**
 69      * Redirect back to start of checkout if no cart started
 70      */
 71     function onAfterInit(){
 72         $action = $this->owner->getRequest()->param('Action');
 73         if(!Cart::has_items() && !empty($action) && isset(self::$steps[$action])){
 74             Director::redirect($this->owner->Link());
 75             return;
 76         }
 77     }
 78 
 79     /**
 80      * Check if passed action is the same as the current step
 81      */
 82     function IsCurrentStep($name){
 83         if($this->owner->getAction() === $name){
 84             return true;
 85         }
 86         if($this->owner->getAction() == "index" && $this->actionPos($name) === 0){
 87             return true;
 88         }
 89         return false;
 90     }
 91 
 92     /**
 93      * Check if passed action is for a step before current
 94      */
 95     function IsPastStep($name){
 96         //echo "ispast ";
 97         return $this->compareActions($name,$this->owner->getAction()) < 0;
 98     }
 99 
100     /**
101      * Check if passed action is for a step after current
102      */
103     function IsFutureStep($name){
104         //echo "isfuture ";
105         return $this->compareActions($name,$this->owner->getAction()) > 0;
106     }
107     
108     /**
109      *  Возвращает список шагов процесса оформления заказа со ссылками, параметрами LinkingMode, LinkOrCurrent и Active
110      *  LinkingMode = filled | current | future
111      *  LinkOrCurrent = link | current
112      *  Active = 1 - шаг доступен, 0 - шаг пропускается
113      *
114      *  @return DataObjectSet
115      *
116      */
117     function StepsList($activeOnly=false) {
118         $steps = new DataObjectSet();       
119         $conf = SiteConfig::current_site_config();      
120         foreach(self::$steps as $action => $step) {
121             if ($activeOnly && !singleton($step)->StepIsActive()) {
122                 continue;
123             }
124             $t = array();
125             $t['Title'] = _t('CheckoutPage.step_'.$action, 'Step '.$action);
126             $t['Link'] = $this->owner->Link($action);
127             $t['Action'] = $action;
128             $t['LinkingMode'] = ($this->IsCurrentStep($action) ? 'current' : ($this->IsFutureStep($action) ? 'future' : (!singleton($step)->StepIsActive() ? 'skipped' : 'filled')));
129             $t['LinkOrCurrent'] = ($this->IsCurrentStep($action) ? 'current' : 'link');
130             $t['Active'] = (int)singleton($step)->StepIsActive();
131             $steps->push(new ArrayData($t));
132         }
133         return $steps;
134     }
135     
136     /**
137      * Get first step from stored steps
138      */
139     function index(){
140         if (self::$first_step && Cart::has_items()){
141             return $this->owner->redirect($this->owner->Link(self::$first_step));
142             //return $this->owner->{self::$first_step}();
143         }
144         return array();
145     }
146 
147     /**
148      * Check if one step comes before or after the another
149      */
150     private function compareActions($action1, $action2){
151         return $this->actionPos($action1) - $this->actionPos($action2);
152     }
153 
154     /**
155      * Get the numerical position of a step
156      */
157     private function actionPos($incoming){
158         $count = 0;
159         foreach (self::$steps as $action => $step){
160             if ($action == $incoming) {
161                 return $count;
162             }
163             $count++;
164         }
165         return $count;
166     }
167 
168 }
169 
170 
171 /**
172  * Добавляем сообщения для шагов
173  *
174  * Список возможных полей для шагов формируем по классам-потомкам от CheckoutStep.
175  * Это не совсем правильно т.к. теоретически один класс может использоваться на 2-х разных шагах,
176  * но список актуальных шагов на момент генерации БД недоступен.
177  * При редактировании CheckoutPage видимы только поля тех шагов, которые определены в конфиге.
178  * 
179  * Чтобы не изменять структуру БД в зависимотси от шагов, возможно хранить сообщения в отдельной таблице
180  * - тогда можно генерирвать записи в таблице в момент редактирования CheckoutPage по актуальым шагам.
181  *
182  */
183 class SteppedCheckout_PageMessages extends DataObjectDecorator {
184     
185     function extraStatics() {
186         $db = array();
187         foreach (ClassInfo::subclassesFor('CheckoutStep') as $class) {
188             if ($class == 'CheckoutStep') continue;
189             $db[self::stepMessageName(singleton($class)->stepName())] = 'HTMLText';
190         }
191         return array('db' => $db);
192     }
193     
194     function updateCMSFields(&$fields) {
195         if (!Object::has_extension("CheckoutPage_Controller", "SteppedCheckout")) return;
196         $fields->addFieldToTab('Root.Content', new Tab("Steps", _t('CheckoutPage.tab_Steps', 'Step Messages')), 'Metadata');
197         foreach (SteppedCheckout::$steps as $stepClass) {
198             $step = singleton($stepClass);
199             $name = $this->stepMessageName($step->stepName());
200             $fields->addFieldToTab('Root.Content.Steps', new HtmlEditorField($name, $step->stepTitle(), 12));
201         }
202     }
203     
204     /**
205      * Возвращает сообщение для шага
206      * 
207      * @param string $step - кодовое название шага
208      * 
209      * @return string - сообщение из БД
210      */
211     function getStepMessage($step) {
212         $name = $this->stepMessageName($step);
213         return $this->owner->getField($name);
214     }
215     
216     /**
217      * Формирует имя поля в котором будет храниться сообщение шага
218      * 
219      * @param string $step - кодовое название шага
220      * 
221      * @return string - имя поля
222      */
223     private static function stepMessageName($step) {
224         return 'Step' . ucfirst($step);
225     }
226     
227 }
[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