function MonthNavigator($url_segment = null, $start_date = null)
 {
     $cal = CalendarUtil::get_calendar_for($url_segment);
     if ($cal) {
         if ($start_date !== null) {
             $start_date = new sfDate(CalendarUtil::getDateFromString($start_date));
         }
         return new MonthNavigator($cal, $start_date);
     }
     return false;
 }
 public static function getDateFromURL()
 {
     $params = Controller::curr()->urlParams;
     if (isset($params['ID'])) {
         return CalendarUtil::getDateFromString($params['ID']);
     } else {
         return false;
     }
 }
 public function handleShow($request)
 {
     $calendar = DataObject::get_by_id($request->param('CalendarClass'), $request->param('CalendarID'));
     if ($calendar) {
         $default_view = $request->param('DefaultView') == "1";
         $c = new LiveCalendarWidget($calendar, new sfDate(CalendarUtil::getDateFromString($request->param('CurrentMonth'))), null, $default_view);
         $c->setAnchorStart($request->param('AnchorStart'));
         $c->setAnchorEnd($request->param('AnchorEnd'));
         echo $c->forTemplate();
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 public function parseURL()
 {
     // User has specified a start date. We're not in the default view.
     if (isset($this->urlParams['Action'])) {
         $this->start_date = new sfDate(CalendarUtil::getDateFromString($this->urlParams['Action']));
         // User has specified an end date.
         if (isset($this->urlParams['ID'])) {
             $this->view = "range";
             $this->end_date = new sfDate(CalendarUtil::getDateFromString(str_replace("-", "", $this->urlParams['ID'])));
         } else {
             switch (strlen(str_replace("-", "", $this->urlParams['Action']))) {
                 case 8:
                     $this->view = "day";
                     $this->end_date = new sfDate($this->start_date->get() + 1);
                     break;
                 case 6:
                     $this->view = "month";
                     $this->end_date = new sfDate($this->start_date->finalDayOfMonth()->date());
                     break;
                 case 4:
                     $this->view = "year";
                     $this->end_date = new sfDate($this->start_date->finalDayOfYear()->date());
                     break;
                 default:
                     $this->view = "default";
                     $this->end_date = new sfDate($this->start_date->addMonth(Calendar::$defaultFutureMonths)->date());
                     break;
             }
         }
     } else {
         $this->view = "default";
         $this->start_date = new sfDate(date('Y-m-d'));
         $this->end_date = new sfDate($this->start_date->addMonth(Calendar::$defaultFutureMonths)->date());
     }
     $this->start_date->reset();
 }
Exemplo n.º 5
0
 public static function getDateFromURL()
 {
     $params = Director::urlParams();
     if (isset($params['Action'])) {
         return CalendarUtil::getDateFromString($params['Action']);
     } else {
         return false;
     }
 }
 public function parseURL()
 {
     if ($this->urlParams['Action'] && $this->urlParams['Action'] == "view") {
         $this->start_date = new sfDate(CalendarUtil::getDateFromString($this->urlParams['ID']));
         // User has specified an end date.
         if (isset($this->urlParams['OtherID'])) {
             $this->view = "range";
             $this->end_date = new sfDate(CalendarUtil::getDateFromString(str_replace("-", "", $this->urlParams['OtherID'])));
         } else {
             switch (strlen(str_replace("-", "", $this->urlParams['ID']))) {
                 case 8:
                     $this->view = "day";
                     $this->end_date = new sfDate($this->start_date->get() + 1);
                     break;
                 case 6:
                     $this->view = "month";
                     $this->end_date = new sfDate($this->start_date->finalDayOfMonth()->date());
                     break;
                 case 4:
                     $this->view = "year";
                     $this->end_date = new sfDate($this->start_date->finalDayOfYear()->date());
                     break;
                 default:
                     $this->view = "default";
                     $this->end_date = new sfDate($this->start_date->addMonth(Calendar::$defaultFutureMonths)->date());
                     break;
             }
         }
     } else {
         // The default "landing page." No dates specified. Just show first X number of events (see Calendar::DefaultEventDisplay)
         // Why 6 months? Because otherwise the loop will just run forever.
         $this->view = "default";
         $this->start_date = new sfDate(date('Y-m-d'));
         $this->end_date = new sfDate($this->start_date->addMonth(Calendar::$defaultFutureMonths)->date());
     }
     $this->start_date->reset();
 }