Guest User

Untitled

a guest
Oct 9th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.40 KB | None | 0 0
  1.     public function render($parameters = array()) {
  2.         $this->template->setFile(dirname(__FILE__) . '/MiniCalendar.latte');
  3.         $this->template->headings = array(
  4.             $this->_translator->translate('UNIVERSAL__MONDAY_SHORT'),
  5.             $this->_translator->translate('UNIVERSAL__TUESDAY_SHORT'),
  6.             $this->_translator->translate('UNIVERSAL__WEDNESDAY_SHORT'),
  7.             $this->_translator->translate('UNIVERSAL__THURSDAY_SHORT'),
  8.             $this->_translator->translate('UNIVERSAL__FRIDAY_SHORT'),
  9.             $this->_translator->translate('UNIVERSAL__SATURDAY_SHORT'),
  10.             $this->_translator->translate('UNIVERSAL__SUNDAY_SHORT'));
  11.         $this->template->days_in_this_week = 1;
  12.         $this->template->day_counter = 0;
  13.         $this->template->dates_array = array();
  14. $this->template->h = $this->_pom;
  15.         $session = $this->_parent->getSession('myCalendar');
  16.         if ($session->calData) {
  17.             $this->template->running_day = date('w', mktime(0, 0, 0, $session->calData['month'], 0, $session->calData['year']));
  18.             $this->template->days_in_month = date('t', mktime(0, 0, 0, $session->calData['month'], 1, $session->calData['year']));
  19.             $dt = new \Nette\DateTime();
  20.             $dt->setDate($session->calData['year'], $session->calData['month'], 1);
  21.  
  22.             $this->template->pizza = $this->_helper->getActionsByDatesForCalendar($dt); //CalendarModel::getData($session->calData['month'], $session->calData['year']);
  23.  
  24.             $this->template->year = $session->calData['year'];
  25.             $this->template->month = intval($session->calData['month']); //($session->calData['month'] < 10) ? '0' . $session->calData['month'] : $session->calData['month'];
  26.         } else {
  27.             $this->template->running_day = date('w', mktime(0, 0, 0, date('n'), 0, date('Y')));
  28.             $this->template->days_in_month = date('t', mktime(0, 0, 0, date('n'), 1, date('Y')));
  29.             $dt = new \Nette\DateTime();
  30.             $dt->setDate($dt->format('Y'), $dt->format('m'), 1);
  31.  
  32.             $this->template->pizza = $this->_helper->getActionsByDatesForCalendar($dt); //   array(); //CalendarModel::getData(date('m'), date('Y'));
  33.             $this->template->year = date('Y');
  34.             $this->template->month = date('n');
  35.         }
  36.         $sessionActions = $this->_parent->getSession($this->_sessionKey);
  37.         $this->template->showActions = array();
  38.         if (isset($sessionActions->start) and isset($sessionActions->end)) {
  39.             $this->template->showActions = $this->_helper->fetchAll(array(
  40.                 'from <=' => $sessionActions->end,
  41.                 'to >=' => $sessionActions->start
  42.             ), 'from');
  43.             unset($sessionActions->start);
  44.             unset($sessionActions->end);
  45.         }
  46.         $this->template->translatedText = array(0 => $this->_translator->translate("F_OK"),
  47.                                                 1 =>$this->_translator->translate("UNIVERSAL__ACTIONS_FOR_DAY"));
  48.         $this->template->render();
  49.     }
  50.    
  51.     public function handleActions($dt) {
  52.         $start = new \Nette\DateTime($dt);$this->_pom = $start;
  53.         $start->setTime(0, 0, 0);
  54.         $end = clone $start;
  55.         $end->setTime(23, 59, 59);
  56.         $session = $this->_parent->getSession($this->_sessionKey);
  57.         $session->start = $start;
  58.         $session->end = $end;
  59.         $this->invalidateControl('dialog');
  60.     }
  61.    
  62.     public function handleBack() {
  63.         $session = $this->_parent->getSession('myCalendar');
  64.         if ($session->calData['month'] === 1) {
  65.             $session->calData['year'] = ($session->calData['year'] - 1);
  66.             $session->calData['month'] = ($session->calData['month'] + 11);
  67.         }
  68.         else {
  69.             $session->calData['month'] = ($session->calData['month'] - 1);
  70.         }
  71.         $this->invalidateControl('miniCalendar');$this->invalidateControl('dialog');
  72.     }
  73.     public function handleNext() {
  74.         $session = $this->_parent->getSession('myCalendar');
  75.         if ($session->calData['month'] === 12) {
  76.             $session->calData['year'] = ($session->calData['year'] + 1);
  77.             $session->calData['month'] = ($session->calData['month'] - 11);
  78.         }
  79.         else {
  80.             $session->calData['month'] = ($session->calData['month'] + 1);
  81.         }
  82.         $this->invalidateControl('miniCalendar');$this->invalidateControl('dialog');
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment