コード例 #1
0
ファイル: view.html.php プロジェクト: justinlyon/scc
 function month($tpl = null)
 {
     $fcp = new FrontCalendarPage();
     $model =& $this->getModel();
     $this->assignRef('highlights', $model->getAnnouncement());
     $list = $fcp->formatEntries($model->getList());
     $selected = $model->getSelected();
     $this->assignRef('selected', $selected);
     $options = $model->getOptions();
     $this->assignRef('options', $options);
     $selectedTime = CalendarForm::getMonthStart($selected);
     $mondayStart = true;
     $grid = $fcp->setMonthGrid($selectedTime, $list, $mondayStart);
     $this->assignRef('grid', $grid);
     $this->assignRef('weekday', date("w"));
     $this->assignRef('events', $list);
     $curview = date("F Y", $selectedTime);
     $curmonth = $selected->getMonth();
     $curyear = $selected->getYear();
     $prevmonth = intval($selected->getMonth()) - 1 > 0 ? intval($selected->getMonth()) - 1 : 12;
     $prevyear = $prevmonth == 12 ? intval($selected->getYear()) - 1 : $selected->getYear();
     $nextmonth = intval($selected->getMonth()) + 1 < 13 ? intval($selected->getMonth()) + 1 : 1;
     $nextyear = $nextmonth == 1 ? intval($selected->getYear()) + 1 : $selected->getYear();
     $this->assignRef('cur_view', $curview);
     $this->assignRef('cur_month', $curmonth);
     $this->assignRef('cur_year', $curyear);
     $this->assignRef('prev_month', $prevmonth);
     $this->assignRef('prev_year', $prevyear);
     $this->assignRef('next_month', $nextmonth);
     $this->assignRef('next_year', $nextyear);
     $heading = "Calendar of Events: " . $this->cur_view;
     $document =& JFactory::getDocument();
     $document->setTitle($heading);
     parent::display($tpl);
 }
コード例 #2
0
ファイル: CalendarForm.php プロジェクト: justinlyon/scc
 /**
  * Returns the last second for the identified
  * month in the given CalendarForm.
  * @param bean CalendarForm
  * @return int (timestamp) last second of given month
  */
 public function getMonthEnd($cal)
 {
     global $logger;
     $logger->debug(get_class($this) . "::getMonthEnd({$cal})");
     $start = CalendarForm::getMonthStart($cal);
     $days = date('t', $start);
     return mktime(23, 59, 59, $cal->getMonth(), $days, $cal->getYear());
 }
コード例 #3
0
 /** Edit a calendar event
  * @access public
  * @return void
  */
 public function editAction()
 {
     $form = new CalendarForm();
     $form->details->setLegend('Edit an event');
     $this->view->form = $form;
     $event = $this->_gcal->getEvent($this->getParam('id'));
     $eventData = array('title' => $event->title, 'id' => substr($event->id, strrpos($event->id, '/') + 1, 26), 'startTime' => date('G:i', strtotime($event->when[0]->startTime)), 'endTime' => date('G:i', strtotime($event->when[0]->endTime)), 'startDate' => date('Y-m-d', strtotime($event->when[0]->startTime)), 'endDate' => date('Y-m-d', strtotime($event->when[0]->startTime)), 'location' => $event->where[0], 'updated' => $event->updated, 'content' => $event->content, 'type' => $event->extendedProperty[0], 'creator' => $event->extendedProperty[1]);
     $form->populate($eventData);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $formData['id'] = $this->getParam('id');
             $formData['creator'] = $this->_helper->identity->getPerson()->fullname;
             $edit = $this->_gcal->editEvent($formData);
             $this->getFlash()->addMessage('Calendar event updated');
             $this->redirect('/users/calendar/');
         } else {
             $form->populate($this->_request->getPost());
         }
     }
 }
コード例 #4
0
 /**
  * Gets the appropriate elements from the form (or request)
  * and adds them to a convenience bean object.
  * 
  * @access private
  * @return bean SummaryPageModel
  */
 private function getBeanFromRequest()
 {
     $bean = new CalendarForm();
     $now = time();
     $month = isset($_REQUEST['month']) ? $_REQUEST['month'] : date("m", $now);
     $year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date("Y", $now);
     $category = isset($_REQUEST['category']) && $_REQUEST['category'] > 0 ? $_REQUEST['category'] : null;
     $bean->setMonth($month);
     $bean->setYear($year);
     $bean->setCategory($category);
     return $bean;
 }
コード例 #5
0
ファイル: FrontCalendarPage.php プロジェクト: justinlyon/scc
 /**
  * A shared private method used to render the common
  * controls.
  * 
  * @access private
  * @param template $tmpl the template object
  * @param model $model the page model
  */
 function renderControls($tmpl, $model)
 {
     global $mainframe;
     $options = $model->getOptions();
     $selected = $model->getSelected();
     $selectedTime = CalendarForm::getMonthStart($selected);
     // set the select lists
     $months = $options['month'];
     for ($i = 0; $i < count($months['value']); $i++) {
         $tmpl->addVar('month_options', 'value', $months['value'][$i]);
         $tmpl->addVar('month_options', 'text', $months['text'][$i]);
         if ($months['value'][$i] == $selected->getMonth()) {
             $tmpl->addVar('month_options', 'selected', 'selected');
         } else {
             $tmpl->addVar('month_options', 'selected', '');
         }
         $tmpl->parseTemplate('month_options', 'a');
     }
     $years = $options['year'];
     for ($i = 0; $i < count($years['value']); $i++) {
         $tmpl->addVar('year_options', 'value', $years['value'][$i]);
         if ($years['value'][$i] == $selected->getYear()) {
             $tmpl->addVar('year_options', 'selected', 'selected');
         } else {
             $tmpl->addVar('year_options', 'selected', '');
         }
         $tmpl->parseTemplate('year_options', 'a');
     }
     $categories = $options['category'];
     foreach ($categories as $cat) {
         $tmpl->addVar('category_options', 'coid', $cat['oid']);
         $tmpl->addVar('category_options', 'name', $cat['name']);
         if ($cat['oid'] == $selected->getCategory()) {
             $tmpl->addVar('category_options', 'selected', 'selected');
         } else {
             $tmpl->addVar('category_options', 'selected', '');
         }
         $tmpl->parseTemplate('category_options', 'a');
     }
     $control['cur_view'] = date("F Y", $selectedTime);
     $control['cur_month'] = $selected->getMonth();
     $control['cur_year'] = $selected->getYear();
     $control['prev_month'] = intval($selected->getMonth()) - 1 > 0 ? intval($selected->getMonth()) - 1 : 12;
     $control['prev_month_year'] = $control['prev_month'] == 12 ? intval($selected->getYear()) - 1 : $selected->getYear();
     $control['next_month'] = intval($selected->getMonth()) + 1 < 13 ? intval($selected->getMonth()) + 1 : 1;
     $control['next_month_year'] = $control['next_month'] == 1 ? intval($selected->getYear()) + 1 : $selected->getYear();
     // page title
     $mainframe->setPageTitle("Calendar of Events | " . $control['cur_view']);
     // add the menu marker
     if (isset($_REQUEST['ccmenu'])) {
         $control['ccmenu'] = $_REQUEST['ccmenu'];
     }
     $cal_link = $this->cceventSefUrl('index.php?option=com_ccevents&scope=cldr&task=month&month=' . $selected->getMonth() . '&year=' . $selected->getYear());
     $tmpl->addVar('calendar', 'cal_view_link', $cal_link);
     $tmpl->addVars('calendar', $control);
 }