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  * @class FavoritePage - страница просмотра избранного
  4  *
  5  * @author menedem
  6  */
  7 class FavoritePage extends Page {
  8 
  9     static $defaults = array(      
 10         'DevEditType' => 'Fixed',
 11         'AutoChild' => 0
 12     );
 13     static $allowed_children = 'none';  
 14     
 15     protected static $favorite_object_class = 'Product';    // класс объекта для добавления в избранное
 16     
 17     static $favorite_cookie_name = 'FavoriteProducts';  
 18     
 19     /**
 20      * Получение ссылки на страницу избранных товаров + действие (если есть)
 21      *
 22      * @return string
 23      */
 24     static function find_link($action = false, $productID = false) {
 25         if (!$page = DataObject::get_one('FavoritePage')) {
 26             user_error('Создайте страницу "Избранные товары"', E_USER_ERROR);
 27         }
 28         if ($action == false) {
 29             return $page->Link();
 30         } else {
 31             return $page->Link($action . "/{$productID}");
 32         }
 33     }
 34     
 35     /**
 36      * Задать объект для добавления в избранное
 37      *
 38      * @return string
 39      */
 40     static function get_favorite_object_class() {
 41         return self::$favorite_object_class;
 42     }
 43     
 44     /**
 45      * Задать объект для добавления в избранное
 46      *
 47      * @param string
 48      */
 49     static function set_favorite_object_class($class) {
 50         self::$favorite_object_class = $class;
 51     }
 52     
 53     /**
 54      * Возврат избранного (из профиля или из кук)
 55      *
 56      * @return string
 57      */
 58     static function get_user_favorites() {
 59         $member = Member::currentUser();
 60         if ($member) {
 61             $IDs = base64_decode($member->FavoriteProducts);
 62         } else {
 63             $IDs = CookieExtention::get_cookie_data(FavoritePage::$favorite_cookie_name);
 64         }
 65         return $IDs;
 66     }   
 67     
 68     function canCreate($member = false) {
 69         $favoritePage = Dataobject::get_one('FavoritePage');    
 70         if ($favoritePage) {
 71             return false;
 72         }
 73         return parent::canCreate($member);
 74     }
 75 
 76     function canDelete($member = false) {
 77         if (Director::isDev()) {
 78             return true;
 79         }
 80         return parent::canDelete($member);
 81     }
 82     
 83     /**
 84      * Получение избранных товаров (из Кук или изпрофиля пользователя)
 85      *
 86      * @return DataObjectSet
 87      */
 88     function ShowFavoriteObjects() {    
 89         $IDs = self::get_user_favorites();
 90         $rs = new DataObjectSet();
 91         if ($IDs) {
 92             $IDs = explode(',', $IDs);
 93             foreach($IDs as $id) {              
 94                 if ($object = Dataobject::get_by_id(self::$favorite_object_class, (int)$id)) {
 95                     $rs->push($object);
 96                 }
 97             }
 98         }
 99         return $rs;
100     }
101     
102     /**
103      * Для совместимости со старыми сайтами
104      *
105      * @return DataObjectSet
106      */
107     function ShowFavoriteProducts() {
108         return $this->ShowFavoriteObjects();
109     }
110     
111     /**
112      * Получение количества товаров в избранном
113      *
114      * @return int
115      */
116     function FavoriteCount() {
117         $IDs = self::get_user_favorites();      
118         $count = 0;
119         if ($IDs) {
120             $IDs = explode(',', $IDs);
121             $count = count($IDs);
122         }
123         return $count;  
124     }   
125 
126     function requireDefaultRecords() {
127         parent::requireDefaultRecords();
128         
129         if ($this->class != 'FavoritePage') return;
130         // default pages
131         if(!($page = SiteTree::get_by_link('favorite'))) {
132             $page = new FavoritePage();
133             $page->Title = _t('SiteTree.DEFAULTFAVORITETITLE', 'Favorite');
134             $page->Content = _t('SiteTree.DEFAULTFAVORITECONTENT', '<p>Welcome to SilverStripe! This is the default Favorite page. </p>');
135             $page->URLSegment = 'favorite';
136             $page->Status = 'Published';
137             //$page->Sort = 3; // !!! порядок 1-home, 2-about, 3-contacts
138             $page->write();
139             $page->publish('Stage', 'Live');
140             $page->flushCache();
141             DB::alteration_message('Favorite page created', 'created');
142         }       
143     }   
144 }
145 
146 class FavoritePage_Controller extends Page_Controller { 
147         
148     /**
149      * Обработчик очистки избранных 
150      *   
151      */
152     function clear_favorite() {
153         CookieExtention::clear_cookies(FavoritePage::$favorite_cookie_name);
154         FavoriteProductMemberExtention::saveFavorites('');
155         if (!$this->isAjax())
156             Director::redirectBack();
157         return Convert::raw2json('success');
158     }
159     
160     /**
161      * Обработчик добавления товара в избранное
162      *  
163      */
164     function additem($params) { 
165         $rs = false;
166         $params = $params->allParams();
167         if (isset($params['ID'])) {
168             $productID[] = $params['ID'];       
169             $rs = CookieExtention::add_item_to_cookie(FavoritePage::$favorite_cookie_name, $productID);
170             FavoriteProductMemberExtention::saveFavorites($rs);
171         }
172         if (!$this->isAjax())
173             Director::redirectBack();
174         if (trim($rs)) {
175             return Convert::raw2json(count(explode(',', $rs)));
176         }
177         return 0;
178     }
179     
180     /**
181      * Обработчик удаления избранных товаров из корзины
182      *  
183      */
184     function deleteitem($params) {  
185         $rs = false;
186         $params = $params->allParams();
187         if (isset($params['ID'])) {
188             $productID[] = $params['ID'];       
189             $rs = CookieExtention::delete_item_from_cookie(FavoritePage::$favorite_cookie_name, $productID);
190             FavoriteProductMemberExtention::saveFavorites($rs);
191         }
192         if (!$this->isAjax())
193             Director::redirectBack();
194         if (trim($rs)) {
195             return Convert::raw2json(count(explode(',', $rs)));
196         }
197         return 0;
198     }
199 }
[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