Exemple #1
0
 function preprocess()
 {
     global $FANNIE_URL;
     $this->uid = ltrim(FannieAuth::getUID($this->current_user), "0");
     $this->title = "Cal";
     $this->header = "Calendars";
     $plugin = new CalendarPlugin();
     $this->add_script($FANNIE_URL . 'src/javascript/jquery.js');
     $this->add_script($FANNIE_URL . 'src/javascript/jquery-ui.js');
     $this->add_script($plugin->pluginURL() . '/javascript/calendar.js');
     $this->add_script($plugin->pluginURL() . '/javascript/ajax.js');
     $view = FormLib::get_form_value('view', 'index');
     if (FormLib::get('calID') === '') {
         $view = 'index';
     }
     if ($view == 'month') {
         $this->window_dressing = False;
     } else {
         $this->add_css_file($FANNIE_URL . 'src/javascript/jquery-ui.css');
     }
     if (file_exists(dirname(__FILE__) . '/css/' . $view . '.css')) {
         $this->add_css_file($plugin->pluginURL() . '/css/' . $view . '.css');
     }
     return True;
 }
 public function __construct(&$page, $params)
 {
     $this->page =& $page;
     $this->params = $params;
     switch (count($params)) {
         case 0:
             break;
             // main page of calendar behaviour, don't change anything
         // main page of calendar behaviour, don't change anything
         case 1:
             // there's one parameter after slash
             $slug = $params[0];
             /* We try to find a subpage of the calendar page, so the event's page can be customized */
             $page_found = Page::findBySlug($slug, $this->page, true);
             /* A subpage is found, so display it */
             if (is_a($page_found, "Page")) {
                 $this->page = $page_found;
             } elseif (CalendarPlugin::validateDateString($slug, CALENDAR_SQL_DATE_FORMAT)) {
                 $date = new DateTime($slug);
                 $events = CalendarEvent::findEventsByDate($date);
                 $this->page->title = $date->format(CALENDAR_DISPLAY_DATE_FORMAT);
                 $this->beginCapture();
                 CalendarPlugin::showEvents($events);
                 $this->endCapture();
             } elseif (is_numeric($slug) && ($event = CalendarEvent::findById((int) $slug))) {
                 $this->page->title = $event->getTitle();
                 $this->beginCapture();
                 CalendarPlugin::showEvent($event);
                 $this->endCapture();
             } else {
                 $this->pageNotFound();
             }
             break;
         case 2:
             // there're two parameters after slash
             $year = (int) $params[0];
             $month = (int) $params[1];
             $date = new DateTime();
             $date->setDate($year, $month, 1);
             $this->beginCapture();
             CalendarPlugin::showCalendar($this->page->slug, $date);
             $this->endCapture();
             break;
         default:
             $this->pageNotFound();
     }
 }
 private function validate_post_data(array $post_data)
 {
     $errors = array();
     // title
     if (empty($post_data['title'])) {
         $errors['title'] = __('Title is required');
     }
     // date_from
     if (empty($post_data['date_from'])) {
         $errors['date_from'] = __('Date from is required');
     } elseif (CalendarPlugin::validateDateString($post_data['date_from'], CALENDAR_DISPLAY_DATE_FORMAT) == false) {
         $errors['date_from'] = __('Date from is invalid');
     }
     // date_to
     if (!empty($post_data['date_to']) && CalendarPlugin::validateDateString($post_data['date_to'], CALENDAR_DISPLAY_DATE_FORMAT) == false) {
         $errors['date_to'] = __('Date to is invalid');
     }
     return $errors;
 }
/**
 * Alias of CalendarPlugin::validateDateString()
 * @deprecated
 */
function validateDateString($date_str, $format)
{
    return CalendarPlugin::validateDateString($date_str, $format);
}