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

  • Announcement_Controller
  • AnnouncementHolder_Controller
  • BookingAdminPage_Controller
  • BookingPage_Controller
  • Cart_Controller
  • CartPage_Controller
  • Catalog_Controller
  • CheckoutPage_Controller
  • ChequePayment_Handler
  • ContactsPage_Controller
  • ContentController
  • ContentNegotiator
  • Controller
  • DataObjectManager_Controller
  • DatePickerField_Controller
  • Director
  • DocPage_Controller
  • DocumentsPage_Controller
  • Event_Controller
  • EventHolder_Controller
  • FileDataObjectManager_Controller
  • FindCyrillic_Controller
  • HomePage_Controller
  • LastDoc_Controller
  • LiveCalendarWidget_Controller
  • MapObject_Controller
  • MapObjectGroup_Controller
  • MapPage_Controller
  • MediawebPage_Controller
  • ModelAsController
  • MultiUploadControls
  • NewsArchive
  • Orders1CExchange_Controller
  • Page_Controller
  • Payment_Handler
  • PhotoAlbumManager_Controller
  • Product_Controller
  • ProductSearchPage_Controller
  • ProfilePage_Controller
  • PublHolder_Controller
  • Publication_Controller
  • RatingExtension_Controller
  • RegistrationPage_Controller
  • RemoveOrphanedPagesTask
  • RequestHandler
  • Room_Controller
  • RoomCatalog_Controller
  • RootURLController
  • SapphireInfo
  • Search_Controller
  • Session
  • SimpleOrderPage_Controller
  • SiteMap_Controller
  • SpecialCatalog_Controller
  • SS_HTTPRequest
  • SS_HTTPResponse
  • StartCatalog_Controller
  • SubsitesSelectorPage_Controller
  • VideoBankPage_Controller

Interfaces

  • NestedController

Exceptions

  • SS_HTTPResponse_Exception
  1 <?php
  2 /**
  3  * Календарь для отметки новостей
  4  * Исправлена функциональность виджета, получение новостей только с текущего NewsHolder (который использован в конструкторе виджета)
  5  * Исправленые ссылки в списках лет, месяцев и дней для работы календаря через AJAX
  6  *
  7  * @author inxo, menedem
  8  */
  9 class NewsLiveCalendarWidget extends LiveCalendarWidget {
 10     protected function getEventsFor($start_date, $end_date) {
 11         $start = ($start_date instanceof sfDate) ? $start_date : ($start_date !== null ? new sfDate($start_date) : new sfDate());
 12         $end = ($end_date instanceof sfDate) ? $end_date : ($end_date !== null ? new sfDate($end_date) : new sfDate());
 13         if ($start) {
 14             $start = 'DATE(`Date`) >= \'' . $start->date() . '\'';
 15             if ($end) {
 16                 $end = " AND DATE(`Date`) <= '" . $end->date() . "'";
 17             }
 18         }
 19         $events = DataObject::get('NewsEntry', 'ParentID = ' . $this->calendar->ID . ' AND `Status` LIKE \'%Published%\' AND '.$start . $end); //добавлена привязка к родительскому Holder
 20         $map = array();
 21         if ( $events) {
 22             foreach ($events as $event) {
 23                 $map[] = $event->Date;
 24             }
 25         }
 26         return $map;
 27     }
 28 
 29     public function Link($action = null) {
 30         if ($action === null)
 31             $action = "";
 32         return Director::baseURL() . "NewsArchive" . "/$action";
 33     }
 34 
 35     public function ShowMonthLink($month) {
 36         return $this->Link('show') . '/' . $this->calendar->ID . "/" . $month . "/" . $this->anchor_start->format('Ymd'); //добавлен родительских Holder
 37     }
 38 
 39     protected function getNavigationOptions() {
 40         $options = new DataObjectSet();
 41         $counter = new sfDate($this->start_date->get());
 42         $counter->subtractMonth(11);
 43         for ($i = 0; $i < 12; $i++) {
 44             $options->push(new ArrayData(array(
 45                         'Link' => $this->ShowMonthLink($counter->format('Ym')),
 46                         'Selected' => $this->start_date->format('Ym') == $counter->format('Ym') ? 'selected="selected"' : '',
 47                         'Month' => CalendarUtil::i18n_date('%B, %Y', $counter->get())
 48                     )));
 49             $counter->addMonth();
 50         }
 51         unset($counter);
 52         return $options;
 53     }
 54 
 55     function getMonthList(){
 56         $options = new DataObjectSet();
 57         $counter = new sfDate($this->start_date->get());
 58         $counter = $counter->firstDayOfYear();
 59         for ($i = 0; $i < 12; $i++) {           
 60             $options->push(new ArrayData(array(
 61                         'Link' => $counter->format('m'),
 62                         'AjaxLink' => $this->ShowMonthLink($counter->format('Ym')), //добавлена ссылка для AJAX-смены месяца в виджете
 63                         'Selected' => $this->start_date->format('Ym') == $counter->format('Ym') ? 'selected="selected"' : '',
 64                         'Month' => CalendarUtil::i18n_date('%B', $counter->get())
 65                     )));
 66             $counter->addMonth();
 67         }
 68         unset($counter);
 69         return $options;
 70     }
 71 
 72     function getYearList($reverse = false){     
 73         $firstNews = DataObject::get('NewsEntry', 'ParentID = ' . $this->calendar->ID . ' AND `Status` LIKE \'%Published%\' AND Date IS NOT NULL', 'Date ASC',null,1); //добавлен родительский Holder
 74         if ($firstNews) {
 75             $arrayDate = explode('-', $firstNews->First()->Date);
 76             $firstYear = (int) $arrayDate[0];
 77         }
 78         else {
 79             $firstYear = (int) date('Y', strtotime('now'));
 80         }
 81         $currentYear = (int) date('Y', strtotime('now'));
 82         $selectedYear = (int) $this->start_date->format('Y');
 83         if (($selectedYear > $currentYear))
 84             $currentYear = $selectedYear;
 85         if ($selectedYear < $firstYear)         
 86             $firstYear = $selectedYear;
 87         $options = new DataObjectSet();
 88         for($i=$firstYear;$i<=$currentYear;$i++){
 89             $year = new ArrayData(array(
 90                         'Link' => $i,
 91                         'AjaxLink' => $this->ShowMonthLink($i . $this->start_date->format('m')),//добавлена ссылка для AJAX-смены года в виджете
 92                         'Selected' => ($selectedYear == $i) ? 'selected="selected"' : '',
 93                         'Current' => ($selectedYear == $i) ? 'Current' : '',
 94                         'Month' => $i,
 95                         'Name' => $i,
 96                         'YearLink' => $this->calendar->Link('view') . "/" . $i,
 97                     ));
 98             if ($reverse)
 99                 $options->unshift($year);
100             else
101                 $options->push($year);
102         }
103         return $options;
104     }
105 
106     public function forTemplate() {
107         $t = clone $this->start_date; //исправлено, портило оригинальную дату
108         return $this->customise(array(
109             'Weeks' => $this->getWeeks(),
110             'NavigationOptions' => $this->getNavigationOptions(),
111             'CurrentMonthLink' => $this->calendar->Link('view') . "/" . $t->format('Ym'),
112             'PrevMonthLink' => $this->ShowMonthLink($t->subtractMonth()->format('Ym')),
113             'PrevYearLink' => $this->ShowMonthLink($t->subtractYear()->addMonth()->format('Ym')),
114             'NextMonthLink' => $this->ShowMonthLink($t->addMonth()->addYear()->format('Ym')),
115             'NextYearLink' => $this->ShowMonthLink($t->addYear()->subtractMonth()->format('Ym')),
116             'QuickMonthLink' => $this->getQuickMonthLink(),
117             'QuickWeekLink' => $this->getQuickWeekLink(),
118             'QuickWeekendLink' => $this->getQuickWeekendLink(),
119             'CalendarHeader' => $this->calendarHeader,
120             'Ajax' => Director::is_ajax(),
121             'Sun' => CalendarUtil::i18n_date('%a', $this->date_counter->previousDay(sfTIME::SUNDAY)->get()),
122             'Mon' => CalendarUtil::i18n_date('%a', $this->date_counter->addDay()->get()),
123             'Tue' => CalendarUtil::i18n_date('%a', $this->date_counter->addDay()->get()),
124             'Wed' => CalendarUtil::i18n_date('%a', $this->date_counter->addDay()->get()),
125             'Thu' => CalendarUtil::i18n_date('%a', $this->date_counter->addDay()->get()),
126             'Fri' => CalendarUtil::i18n_date('%a', $this->date_counter->addDay()->get()),
127             'Sat' => CalendarUtil::i18n_date('%a', $this->date_counter->addDay()->get())
128         ))->renderWith('NewsLiveCalendarWidget');       
129     }
130 }
131 
132 class NewsArchive extends Controller {
133 
134     static $url_handlers = array(
135         'show/$HolderID/$CurrentMonth/$AnchorStart/$AnchorEnd' => 'handleShow' //добавлен родительский Holder
136     );
137 
138     public function handleShow($request) {
139         $holderID = (int)$request->param('HolderID');
140         if ($holderID) {
141             $calendar = DataObject::get_by_id('NewsHolder', $holderID);
142         } else {
143             $calendar = DataObject::get_one('NewsHolder');
144         }
145         if ($calendar) {
146             $default_view = $request->param('DefaultView') == "1";
147             $c = new NewsLiveCalendarWidget(
148                             $calendar,
149                             new sfDate(CalendarUtil::getDateFromString($request->param('CurrentMonth'))),
150                             null,
151                             $default_view
152             );
153             $c->setAnchorStart($request->param('AnchorStart'));
154             $c->setAnchorEnd($request->param('AnchorEnd'));
155             echo $c->forTemplate();
156         }
157         else
158             return false;
159     }
160 
161 }
162 
[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