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 CalendarUtil {
  4     const ONE_DAY = "OneDay";
  5     const SAME_MONTH_SAME_YEAR = "SameMonthSameYear";
  6     const DIFF_MONTH_SAME_YEAR = "DiffMonthSameYear";
  7     const DIFF_MONTH_DIFF_YEAR = "DiffMonthDiffYear";
  8 
  9     const ONE_DAY_HEADER = "OneDayHeader";
 10     const MONTH_HEADER = "MonthHeader";
 11     const YEAR_HEADER = "YearHeader";
 12 
 13     public static $months_map = array(
 14         '01' => 'Jan',
 15         '02' => 'Feb',
 16         '03' => 'Mar',
 17         '04' => 'Apr',
 18         '05' => 'May',
 19         '06' => 'Jun',
 20         '07' => 'Jul',
 21         '08' => 'Aug',
 22         '09' => 'Sep',
 23         '10' => 'Oct',
 24         '11' => 'Nov',
 25         '12' => 'Dec'
 26     );
 27     private static $format_character_placeholders = array(
 28         '%{sWeekDayShort}',
 29         '%{sWeekDayFull}',
 30         '%{sDayNumShort}',
 31         '%{sDayNumFull}',
 32         '%{sDaySuffix}',
 33         '%{sMonNumShort}',
 34         '%{sMonNumFull}',
 35         '%{sMonShort}',
 36         '%{sMonFull}',
 37         '%{sMonFullDate}',
 38         '%{sYearShort}',
 39         '%{sYearFull}',
 40         '%{eWeekDayShort}',
 41         '%{eWeekDayFull}',
 42         '%{eDayNumShort}',
 43         '%{eDayNumFull}',
 44         '%{eDaySuffix}',
 45         '%{eMonNumShort}',
 46         '%{eMonNumFull}',
 47         '%{eMonShort}',
 48         '%{eMonFull}',
 49         '%{eMonFullDate}',
 50         '%{eYearShort}',
 51         '%{eYearFull}'
 52     );
 53 
 54     private static function format_character_replacements($start, $end) {
 55         return array(
 56             self::i18n_date('%a', $start), // sWeekDayShort
 57             self::i18n_date('%A', $start), // sWeekDayFull
 58             date('d', $start), // sDayNumFull
 59             date('j', $start), //sDayNumShort
 60             date('S', $start), // sDaySuffix
 61             date('n', $start), // sMonNumShort
 62             date('m', $start), // sMonNumFull
 63             self::i18n_date('%b', $start), // sMonShort
 64             self::i18n_date('%B', $start), // sMonFull
 65             _t('CalendarMonthInDate.'. date('F', $start), self::i18n_date('%B', $start)), // sMonFullDate
 66             date('y', $start), // sYearShort
 67             date('Y', $start), // sYearFull
 68 
 69             self::i18n_date('%a', $end), // eWeekDayShort
 70             self::i18n_date('%A', $end), // eWeekDayFull
 71             date('d', $end), // eDayNumFull
 72             date('j', $end), // eDayNumFull
 73             date('S', $end), // eDaySuffix
 74             date('n', $end), // eMonNumShort
 75             date('m', $end), // eMonNumFull
 76             self::i18n_date('%b', $end), // eMonShort
 77             self::i18n_date('%B', $end), // eMonFull
 78             _t('CalendarMonthInDate.'. date('F', $end), self::i18n_date('%B', $end)), // sMonFullDate
 79             date('y', $end), // eYearShort
 80             date('Y', $end), // eYearFull
 81         );
 82     }
 83 
 84     static $NeedTranslate = false;
 85     public static function i18n_date($char, $ts) {
 86         // Need to figure out how we're handling non- UTF-8 users.
 87         //return utf8_encode(strftime($char, $ts));
 88         if(self::$NeedTranslate)
 89             return self::translate(strftime($char, $ts));
 90         return strftime($char, $ts);
 91     }
 92     public static function SetNeedTranslate(){
 93         self::$NeedTranslate = true;
 94     }
 95     public static function translate($str){
 96         return _t('CalendarTranslate.'.$str,$str);
 97     }
 98     public static function localize($start, $end, $key) {
 99         global $customDateTemplates;
100         global $lang;
101         if (is_array($customDateTemplates) && isset($customDateTemplates[$key]))
102             $template = $customDateTemplates[$key];
103         else {
104             $template = _t("Calendar.$key", $key);
105         }
106 
107         return str_replace(self::$format_character_placeholders, self::format_character_replacements($start, $end), $template);
108     }
109 
110     public static function getMonthsMap() {
111         return array(
112             '01' => self::i18n_date('%b', strtotime('2000-01-01')),
113             '02' => self::i18n_date('%b', strtotime('2000-02-01')),
114             '03' => self::i18n_date('%b', strtotime('2000-03-01')),
115             '04' => self::i18n_date('%b', strtotime('2000-04-01')),
116             '05' => self::i18n_date('%b', strtotime('2000-05-01')),
117             '06' => self::i18n_date('%b', strtotime('2000-06-01')),
118             '07' => self::i18n_date('%b', strtotime('2000-07-01')),
119             '08' => self::i18n_date('%b', strtotime('2000-08-01')),
120             '09' => self::i18n_date('%b', strtotime('2000-09-01')),
121             '10' => self::i18n_date('%b', strtotime('2000-10-01')),
122             '11' => self::i18n_date('%b', strtotime('2000-11-01')),
123             '12' => self::i18n_date('%b', strtotime('2000-12-01'))
124         );
125     }
126 
127     public static function getDaysMap() {
128         $days = array();
129         for ($i = 1; $i <= 31; $i++) {
130             $day = $i < 10 ? '0' . $i : $i;
131             $days[$day] = $day;
132         }
133         return $days;
134     }
135 
136     public static function getYearsMap() {
137         $years = array();
138         for ($i = (date('Y') - 5); $i <= (date('Y') + 5); $i++)
139             $years[$i] = $i;
140         return $years;
141     }
142 
143     public static function getDateFromString($str) {
144         $str = str_replace('-', '', $str);
145         if (is_numeric($str)) {
146             $missing = (8 - strlen($str));
147             if ($missing > 0) {
148                 while ($missing > 0) {
149                     $str .= "01";
150                     $missing-=2;
151                 }
152             }
153             return substr($str, 0, 4) . "-" . substr($str, 4, 2) . "-" . substr($str, 6, 2);
154         } else {
155             return date('Y-m-d');
156         }
157     }
158 
159     public static function date_info_from_ics($dtstart, $dtend) {
160         $start_date = null;
161         $end_date = null;
162         $start_time = null;
163         $end_time = null;
164 
165         $start = explode("T", $dtstart);
166         $start_date = CalendarUtil::getDateFromString($start[0]);
167         if (isset($start[1]))
168             $start_time = substr($start[1], 0, 2) . ":" . substr($start[1], 2, 2) . ":" . "00";
169 
170 
171         $end = explode("T", $dtend);
172         $end_date = CalendarUtil::getDateFromString($end[0]);
173         if (isset($end[1]))
174             $end_time = substr($end[1], 0, 2) . ":" . substr($end[1], 2, 2) . ":" . "00";
175 
176         return array($start_date, $end_date, $start_time, $end_time);
177     }
178 
179     public static function getDateFromURL() {
180         $params = Controller::curr()->urlParams;
181         if (isset($params['ID'])) {
182             return CalendarUtil::getDateFromString($params['ID']);
183         }
184         else
185             return false;
186     }
187 
188     public static function get_calendar_for($url_segment) {
189         return $url_segment === null ? DataObject::get_one("Calendar") : DataObject::get_one("Calendar", "URLSegment = '$url_segment'");
190     }
191 
192     public static function CollapseDatesAndTimes($dates) {
193         // Stupid thing doesn't work.
194         return $dates;
195 
196         /* $date_list = new DataObjectSet();
197           $dates = $dates->toArray();
198           for($i=0; $i < sizeof($dates); $i++) {
199           $original_date = $dates[$i];
200           $original_date->Times = new DataObjectSet();
201           $current_date = $original_date;
202           $j = 0;
203           while(($current_date->StartDate == $original_date->StartDate) && ($current_date->EventID == $original_date->EventID)) {
204           $j++;
205           $original_date->Times->push($current_date);
206           if(isset($dates[$i+$j]))
207           $current_date = $dates[$i+$j];
208           else
209           break;
210           }
211           $i += $j;
212           $date_list->push($original_date);
213           }
214           return $date_list; */
215     }
216 
217     public static function Microformat($date, $time, $offset = true) {
218         if (!$date)
219             return "";
220 
221         $ts = strtotime($date . " " . $time);
222 
223         if ($ts < 1)
224             return "";
225 
226         $ret = date('Ymd', $ts) . "T" . date('His', $ts);
227         return $offset ? $ret . CalendarDateTime::$offset : $ret;
228     }
229 
230     /**
231      * This function is used to write a date range in the common
232      * human-readable format on the front end. If the date range spans
233      * days within the month, we do not rewrte the month name. If it spans
234      * two different months, we write both month names, both days, but
235      * do not rewrite the year, etc. Though it appears to break the MVC
236      * guidelines, it is a lot cleaner than conducting all of this logic
237      * on the frontend.
238      */
239     static function getDateString($start_date, $end_date) {
240         $strStartDate = null;
241         $strEndDate = null;
242 
243         $start = strtotime($start_date);
244         $end = strtotime($end_date);
245 
246         $start_year = date("Y", $start);
247         $start_month = date("m", $start);
248 
249         $end_year = date("Y", $end);
250         $end_month = date("m", $end);
251 
252         // Invalid date. Get me out of here!
253         if ($start < 1)
254             return;
255 
256         // Only one day long!
257         else if ($start == $end || !$end || $end < 1)
258             $key = self::ONE_DAY;
259 
260         else {
261             if ($start_year == $end_year)
262                 $key = ($start_month == $end_month) ? self::SAME_MONTH_SAME_YEAR : self::DIFF_MONTH_SAME_YEAR;
263             else
264                 $key = self::DIFF_MONTH_DIFF_YEAR;
265         }
266         $date_string = self::localize($start, $end, $key);
267         $break = strpos($date_string, "%{e");
268         if ($break !== FALSE) {
269             $strStartDate = substr($date_string, 0, $break);
270             $strEndDate = substr($date_string, $break + 1, strlen($date_string) - strlen($strStartDate));
271             return array($strStartDate, $strEndDate);
272         }
273 
274         return array($date_string, "");
275     }
276 
277     static function differenceInMonths($dateObj1, $dateObj2) {
278         return (($dateObj1->format('Y') * 12) + $dateObj1->format('n')) - (($dateObj2->format('Y') * 12) + $dateObj2->format('n'));
279     }
280 
281     function date_sort(&$data) {
282         uasort($data, array("CalendarUtil", "date_sort_callback"));
283     }
284 
285     /**
286      * Callback used by column_sort
287      */
288     function date_sort_callback($a, $b) {
289         if ($a->StartDate == $b->StartDate) {
290             if ($a->StartTime == $b->StartTime)
291                 return 0;
292             else if (strtotime($a->StartTime) > strtotime($b->StartTime))
293                 return 1;
294             else
295                 return -1;
296         }
297         else if (strtotime($a->StartDate) > strtotime($b->StartDate))
298             return 1;
299         else
300             return -1;
301     }
302 
303 }
304 ?>
[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