Ejemplo n.º 1
0
Archivo: events.php Proyecto: anqh/anqh
 /**
  * Controller default action
  */
 public function action_index()
 {
     $year = (int) $this->request->param('year');
     $month = (int) $this->request->param('month');
     $day = (int) $this->request->param('day');
     $week = (int) $this->request->param('week');
     // Initial view shows todays events and current week
     if (!$day && !$month && !$week) {
         // Create todays events
         $this->stamp_begin = strtotime('today');
         $this->stamp_end = strtotime('tomorrow -1 second');
         if ($events = $this->_events()) {
             $section_today = $this->sections_events($events);
         }
         $week = date('W');
     }
     $year = $year ? $year : date('Y');
     $month = $month ? $month : date('n');
     if ($week) {
         // Show week
         $this->stamp_begin = strtotime($year . '-W' . Num::pad($week));
         $this->stamp_end = strtotime('next week', $this->stamp_begin);
         $this->stamp_next = $this->stamp_end;
         $this->stamp_previous = strtotime('last week', $this->stamp_begin);
         $section_pagination = $this->section_pagination('week');
         $this->view->title = __('Events') . ' ' . Date::format(Date::DM_SHORT, $this->stamp_begin) . ' - ' . Date::format(Date::DMY_SHORT, $this->stamp_end);
     } else {
         if ($day) {
             // Show day
             $this->stamp_begin = mktime(0, 0, 0, $month, $day, $year);
             $this->stamp_end = strtotime('tomorrow -1 second', $this->stamp_begin);
             $this->stamp_next = $this->stamp_end;
             $this->stamp_previous = strtotime('yesterday', $this->stamp_begin);
             $section_pagination = $this->section_pagination('day');
             $this->view->title = __('Events') . ' ' . Date::format(Date::DMY_SHORT, $this->stamp_begin);
         } else {
             // Show month
             $this->stamp_begin = mktime(0, 0, 0, $month, 1, $year);
             $this->stamp_end = strtotime('next month', $this->stamp_begin);
             $this->stamp_next = $this->stamp_end;
             $this->stamp_previous = strtotime('last month', $this->stamp_begin);
             $section_pagination = $this->section_pagination('month');
             $this->view->title = __('Events') . ' ' . Date::format(Date::MY_LONG, $this->stamp_begin);
         }
     }
     $events = $this->_events();
     // Today
     if (isset($section_today)) {
         $this->view->add(View_Page::COLUMN_CENTER, $section_today);
     }
     // Filters
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_filters($events));
     // Pagination
     $this->view->add(View_Page::COLUMN_CENTER, $section_pagination);
     // Event list
     $this->view->add(View_Page::COLUMN_CENTER, $this->sections_events($events));
     // Pagination
     $this->view->add(View_Page::COLUMN_CENTER, $section_pagination);
     // Calendar
     $this->view->add(View_Page::COLUMN_RIGHT, $this->section_calendar());
     // Hot events
     $this->view->add(View_Page::COLUMN_RIGHT, $this->section_events_hot());
     // New events
     $this->view->add(View_Page::COLUMN_RIGHT, $this->section_events_new());
     // Updated events
     $this->view->add(View_Page::COLUMN_RIGHT, $this->section_events_updated());
     // Set actions
     if (Permission::has(new Model_Event(), Model_Event::PERMISSION_CREATE)) {
         $this->view->actions[] = array('link' => Route::get('events')->uri(array('action' => 'add')), 'text' => '<i class="fa fa-plus-circle"></i> ' . __('Create event'), 'class' => 'btn-primary');
     }
     // Load events
     $this->view->stamp = $this->stamp_begin;
 }