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 /**
  4  * Страница для банка документов
  5  *
  6  * @author inxo
  7  */
  8 class DocumentsPage extends Page {
  9 
 10     static $default = array(
 11         'URLSegment' => 'docs',
 12         'ProvideComments' => 0,
 13     );
 14     static $allowed_children = 'none';
 15 
 16     function getCMSFields() {
 17         $fields = parent::getCMSFields();
 18         return $fields;
 19     }
 20 
 21     /**
 22      * Автоматическая генерация страницы документов
 23      */
 24     function requireDefaultRecords() {
 25         parent::requireDefaultRecords();
 26 
 27         if (!$page = DataObject::get_one('DocumentsPage')) {
 28             $page = new DocumentsPage();
 29             $page->Title = 'Банк докуметов';
 30             $page->Content = '<p>&nbsp;</p>';
 31             $page->URLSegment = 'docs';
 32             $page->writeToStage('Stage');
 33             $page->publish('Stage', 'Live');
 34 
 35             if (method_exists('DB', 'alteration_message'))
 36                 DB::alteration_message('Page \'Documents\' created', 'created');
 37         }
 38     }
 39 
 40 }
 41 
 42 class DocumentsPage_Controller extends Page_Controller {
 43 
 44     private $_currentFilter = array();
 45 
 46     function index() {
 47         $SearchResult = $this->ItemsList();
 48         return $this->customise(array(
 49             'Sorts' => $this->Sorts(),
 50             'SearchResult' => $SearchResult,
 51             'SearchCount' => count($SearchResult),
 52             'Form' => $this->Search()
 53         ));
 54     }
 55 
 56     function view() {
 57         if (isset($_GET['docID']) && ($id = (int)$_GET['docID'])) {            
 58             if ($id && is_numeric($id)) {
 59                 if ($doc = DataObject::get_by_id('DocumentItem', $id)) {
 60                     return $this->customise(array(
 61                         'Form' => null,
 62                         'Document' => $doc,
 63                         'SearchResult' => null
 64                     ));
 65                 }
 66             }
 67         }
 68         return $this->httpError(404, 'Page not found');
 69     }
 70 
 71     function doSearch($data, $form) {
 72         Session::set('Documents.SearchFormData', $data);
 73         $onlyhead = false;
 74         if (isset($data['OnlyHead'])) {
 75             $onlyhead = true;
 76         }
 77         foreach ($data as $key => $value) {
 78             switch ($key) {
 79                 case 'Type':
 80                     if (is_numeric($value))
 81                         $this->_currentFilter[$key . 'ID'] = $key . "ID = " . (int) $value;
 82                     break;
 83                 case 'Direction':
 84                     if (is_numeric($value))
 85                         $this->_currentFilter[$key . 'ID'] = $key . "ID = " . (int) $value;
 86                     break;
 87                 case 'Having':
 88                     if (is_numeric($value))
 89                         $this->_currentFilter[$key . 'ID'] = $key . "ID = " . (int) $value;
 90                     break;
 91                 case 'Number':
 92                     if (!empty($value))
 93                         $this->_currentFilter[$key] = $key . " LIKE '%" . Convert::raw2sql(preg_replace('/[%_\\\]/', '\\$1', $value)) . "%'";
 94                     break;
 95                 case 'Keywords':
 96                     if(!empty ($value)){
 97                         $value = Convert::raw2sql(preg_replace('/[%_\\\]/', '\\$1', $value));
 98                         if($onlyhead){
 99                             $this->_currentFilter[$key] = "Name LIKE '%" . $value . "%'";
100                         }else{
101                             $this->_currentFilter[$key] = "(Name LIKE '%" . $value . "%' OR Description LIKE '%" . $value . "%' OR Content LIKE '%" . $value . "%' OR Keywords LIKE '%" . $value . "%')";
102                         }
103                     }
104                     break;
105                 case 'DateStart':
106                     if (!empty($value)) {
107                         // TODO date('Y-m-d', strtotime($value))
108                         $date = Convert::raw2sql(join('-', array_reverse(preg_split('![/.-]!', $value))));
109                         $this->_currentFilter[$key] = "Date >= '" . $date . "'";
110                     }
111                     break;
112                 case 'DateEnd':
113                     if (!empty($value)) {
114                         $date = Convert::raw2sql(join('-', array_reverse(preg_split('![/.-]!', $value))));
115                         $this->_currentFilter[$key] = "Date <= '" . $date . "'";
116                     }
117                     break;
118 
119                 default:
120                     break;
121             }
122         }
123         $SearchResult = $this->ItemsList();
124         return $this->customise(array(
125             'Sorts' => $this->Sorts(),
126             'SearchResult' => $SearchResult,
127             'SearchCount' => count($SearchResult),
128             'Form' => $this->Search()
129         ));
130     }
131 
132     function Search() {
133         $do = Dataobject::get("DocumentType");
134         $typeDropDown = null;
135         if($do) $typeDropDown = $do->toDropdownMap(
136             "ID",
137             "Title",
138             _t('Documents.AnyFieldEmpty', '(Any)'),
139             true
140         );
141         $type = new DropdownField(
142             'Type',
143             _t('Documents.TypeField', 'Type'),
144             $typeDropDown
145         );
146         $do = Dataobject::get("DocumentHaving");
147         $havingDropDown = null;
148         if($do) $havingDropDown = $do->toDropdownMap(
149             "ID",
150             "Title",
151             _t('Documents.AnyFieldEmpty', '(Any)'),
152             true
153         );
154         $having = new DropdownField(
155             'Having',
156             _t('Documents.HavingField', 'Having'),
157             $havingDropDown
158         );
159         $do = Dataobject::get("DocumentDirection");
160         $directionDropDown = null;
161         if($do) $directionDropDown = $do->toDropdownMap(
162             "ID",
163             "Title",
164             _t('Documents.AnyFieldEmpty', '(Any)'),
165             true
166         );
167         $direction = new DropdownField(
168             'Direction',
169             _t('Documents.DirectionField', 'Direction'),
170             $directionDropDown
171         );
172         $date_start = new DateField('DateStart', _t('Documents.StartDate', 'Дата подписания с'));
173         //$date_start->setConfig('showcalendar', 1);
174         $date_start->setConfig('dateformat', 'dd.mm.yyyy');
175         $date_end = new DateField('DateEnd', _t('Documents.EndDate', 'Дата подписания по'));
176         //$date_end->setConfig('showcalendar', 1);
177         $date_end->setConfig('dateformat', 'dd.mm.yyyy');
178         $order = new DropdownField(
179             'Sort',
180             _t('Documents.SortField', 'Sort'),
181             array(
182                 'ASC' => _t('Documents.SortField_ASC', 'ASC'),
183                 'DESC' => _t('Documents.SortField_DESC', 'DESC'),
184             )
185         );
186         $fields = new FieldSet(
187             $type,
188             $having,
189             $direction,
190             new TextField('Number', _t('Documents.NumberTextField')),
191             new TextField('Keywords', _t('Documents.KeywordsTextField')),
192             $date_start,
193             $date_end,
194             new CheckboxField('OnlyHead', _t('Documents.SearchOnlyInHeader', 'Search only in header')),
195             $order
196         );
197         $actions = new FieldSet(
198             new FormAction('doSearch', _t('Documents.SearchButton', 'Найти'))
199         );
200         $form = new DocumentSearchForm($this, 'Search', $fields, $actions);
201         $form->setFormMethod('GET');
202         $form->disableDefaultAction();
203         $form->disableSecurityToken();
204         $data = Session::get('Documents.SearchFormData');
205         if ($data)
206             $form->loadDataFrom($data);
207         return $form;
208     }
209 
210     function Sorts() {
211         $params = $_SERVER['REQUEST_URI'];
212         $dir = $this->getCurrentSort();
213         $ndir = 'ASC';
214         if($dir=='ASC'){
215             $ndir = 'DESC';
216         }
217         if(stristr($params, 'Sort='.$dir))
218         $params = str_replace('Sort='.$dir, 'Sort='.$ndir, $params);
219         else{
220             $params .= '?Sort='.$ndir;
221         }
222         $link = $params;
223         return new ArrayData(array(
224             'Name' => _t('Documents.SortBy', 'Sort By'),
225             'Dir' => $dir,
226             'Link' => $link
227         ));
228     }
229 
230     function AllDocuments(){
231         return count(DataObject::get('DocumentItem','ShowPublic = 1'));
232     }
233 
234     function ItemsList() {
235         return DataObject::get(
236             'DocumentItem',
237             $this->getCurrentFilter(), // filter
238             'Date ' . $this->getCurrentSort(),
239             '',
240             $this->getLimitPerPage()
241         );
242     }
243 
244     private function getCurrentFilter() {
245         //Debug::dump($this->_currentFilter);
246         $result = array('ShowPublic = 1');
247         foreach ($this->_currentFilter as $key => $value) {
248             array_push($result, $value);
249         }
250         return implode(' AND ', $result);
251     }
252 
253     private function getCurrentSort() {
254         if (isset($_REQUEST['Sort']) && ($_REQUEST['Sort'] == 'ASC' || $_REQUEST['Sort'] == 'DESC')) {
255             $sort = $_REQUEST['Sort'];
256             Session::set('Dpcuments.CurrentSort', $sort);
257             return $sort;
258         }
259         $sort = Session::get('Documents.CurrentSort');
260         if ($sort && ($sort == 'ASC' || $sort == 'DESC')) {
261             return $sort;
262         } else {
263             $sort = 'DESC';
264             Session::set('Dpcuments.CurrentSort', $sort);
265             return $sort;
266         }
267     }
268 
269     private function getLimitPerPage() {
270         $start = 0;
271         $sc = SiteConfig::current_site_config();
272         $limit = ($sc->DocumentsPerPage > 0) ? $sc->DocumentsPerPage : 20;
273         
274         if (isset($_GET['start']) && is_numeric($_GET['start'])) {
275             $start = (int) $_GET['start'];
276         }
277         return $start.','.$limit;
278     }
279 
280 }
281 
[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