/** * Get date info string (legacy from old calendar) * @return string */ public function get_date_info($view, $date_time) { $str = ""; global $current_user; $dateFormat = $current_user->getUserDateTimePreferences(); if ($view == 'month' || $view == 'sharedMonth') { for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $date_time->year; break; case "m": $str .= " " . $date_time->get_month_name(); break; } } } else { if ($view == 'agendaWeek' || $view == 'sharedWeek') { $first_day = $date_time; $first_day = CalendarUtils::get_first_day_of_week($date_time); $last_day = $first_day->get("+6 days"); for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $first_day->year; break; case "m": $str .= " " . $first_day->get_month_name(); break; case "d": $str .= " " . $first_day->get_day(); break; } } $str .= " - "; for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $last_day->year; break; case "m": $str .= " " . $last_day->get_month_name(); break; case "d": $str .= " " . $last_day->get_day(); break; } } } else { if ($view == 'agendaDay') { $str .= $date_time->get_day_of_week() . " "; for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $date_time->year; break; case "m": $str .= " " . $date_time->get_month_name(); break; case "d": $str .= " " . $date_time->get_day(); break; } } } else { if ($view == 'mobile') { $str .= $date_time->get_day_of_week() . " "; for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $date_time->year; break; case "m": $str .= " " . $date_time->get_month_name(); break; case "d": $str .= " " . $date_time->get_day(); break; } } } else { if ($view == 'year') { $str .= $date_time->year; } else { //could be a custom view. $first_day = $date_time; $first_day = CalendarUtils::get_first_day_of_week($date_time); $last_day = $first_day->get("+6 days"); for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $first_day->year; break; case "m": $str .= " " . $first_day->get_month_name(); break; case "d": $str .= " " . $first_day->get_day(); break; } } $str .= " - "; for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $last_day->year; break; case "m": $str .= " " . $last_day->get_month_name(); break; case "d": $str .= " " . $last_day->get_day(); break; } } } } } } } return $str; }
/** * Get date string of next or previous calendar grid * @param string $direction next or previous * @return string */ public function get_neighbor_date_str($direction) { if ($direction == "previous") { $sign = "-"; } else { $sign = "+"; } if ($this->view == 'month') { $day = $this->date_time->get_day_by_index_this_month(0)->get($sign . "1 month")->get_day_begin(1); } else { if ($this->view == 'week' || $this->view == 'shared') { $day = CalendarUtils::get_first_day_of_week($this->date_time); $day = $day->get($sign . "7 days"); } else { if ($this->view == 'day') { $day = $this->date_time->get($sign . "1 day")->get_day_begin(); } else { if ($this->view == 'year') { $day = $this->date_time->get($sign . "1 year")->get_day_begin(); } else { $calendarStrings = return_module_language($GLOBALS['current_language'], 'Calendar'); return $calendarStrings['ERR_NEIGHBOR_DATE']; } } } } return $day->get_date_str(); }
/** * Get date string of next or previous calendar grid * @param string $direction next or previous * @return string */ public function get_neighbor_date_str($direction) { if ($direction == "previous") { $sign = "-"; } else { $sign = "+"; } if ($this->view == 'month') { $day = $this->date_time->get_day_by_index_this_month(0)->get($sign . "1 month")->get_day_begin(1); } else { if ($this->view == 'week' || $this->view == 'shared') { $day = CalendarUtils::get_first_day_of_week($this->date_time); $day = $day->get($sign . "7 days"); } else { if ($this->view == 'day') { $day = $this->date_time->get($sign . "1 day")->get_day_begin(); } else { if ($this->view == 'year') { $day = $this->date_time->get($sign . "1 year")->get_day_begin(); } else { return "get_neighbor_date_str: notdefined for this view"; } } } } return $day->get_date_str(); }
/** * Get html of year calendar * @return string */ protected function display_year() { $weekEnd1 = 0 - $this->startday; $weekEnd2 = -1 - $this->startday; if ($weekEnd1 < 0) { $weekEnd1 += 7; } if ($weekEnd2 < 0) { $weekEnd2 += 7; } $year_start = $GLOBALS['timedate']->fromString($this->cal->date_time->year . '-01-01'); $str = ""; $str .= '<table id="daily_cal_table" cellspacing="1" cellpadding="0" border="0" width="100%">'; for ($m = 0; $m < 12; $m++) { $month_start = $year_start->get("+" . $m . " months"); $month_start_ts = $month_start->format('U') + $month_start->getOffset(); $month_end = $month_start->get("+" . $month_start->format('t') . " days"); $week_start = CalendarUtils::get_first_day_of_week($month_start); $week_start_ts = $week_start->format('U') + $week_start->getOffset(); // convert to timestamp, ignore tz $month_end_ts = $month_end->format('U') + $month_end->getOffset(); $table_id = "daily_cal_table" . $m; //bug 47471 if ($m % 3 == 0) { $str .= "<tr>"; } $str .= '<td class="yearCalBodyMonth" align="center" valign="top" scope="row">'; $str .= '<a class="yearCalBodyMonthLink" href="' . ajaxLink('index.php?module=Calendar&action=index&view=month&&hour=0&day=1&month=' . ($m + 1) . '&year=' . $GLOBALS['timedate']->fromTimestamp($month_start_ts)->format('Y')) . '">' . $GLOBALS['app_list_strings']['dom_cal_month_long'][$m + 1] . '</a>'; $str .= '<table id="' . $table_id . '" cellspacing="1" cellpadding="0" border="0" width="100%">'; $str .= '<tr class="monthCalBodyTH">'; for ($d = 0; $d < 7; $d++) { $str .= '<th width="14%">' . $this->weekdays[$d] . '</th>'; } $str .= '</tr>'; $curr_time_global = $week_start_ts; $w = 0; while ($curr_time_global < $month_end_ts) { $str .= '<tr class="monthViewDayHeight yearViewDayHeight">'; for ($d = 0; $d < 7; $d++) { $curr_time = $week_start_ts + $d * 86400 + $w * 60 * 60 * 24 * 7; if ($curr_time < $month_start_ts || $curr_time >= $month_end_ts) { $monC = ""; } else { $monC = '<a href="' . ajaxLink('index.php?module=Calendar&action=index&view=day&hour=0&day=' . $GLOBALS['timedate']->fromTimestamp($curr_time)->format('j') . '&month=' . $GLOBALS['timedate']->fromTimestamp($curr_time)->format('n') . '&year=' . $GLOBALS['timedate']->fromTimestamp($curr_time)->format('Y')) . '">' . $GLOBALS['timedate']->fromTimestamp($curr_time)->format('j') . '</a>'; } if ($d == $weekEnd1 || $d == $weekEnd2) { $str .= "<td class='weekEnd monthCalBodyWeekEnd'>"; } else { $str .= "<td class='monthCalBodyWeekDay'>"; } $str .= $monC; $str .= "</td>"; } $str .= "</tr>"; $curr_time_global += 60 * 60 * 24 * 7; $w++; } $str .= '</table>'; $str .= '</td>'; if (($m - 2) % 3 == 0) { $str .= "</tr>"; } } $str .= "</table>"; return $str; }
/** * Get date info string (legacy from old calendar) * @return string */ public function get_date_info($view, $date_time) { $str = ""; global $current_user; $dateFormat = $current_user->getUserDateTimePreferences(); if ($view == 'month') { for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $date_time->year; break; case "m": $str .= " " . $date_time->get_month_name(); break; } } } else { if ($view == 'week' || $view == 'shared') { $first_day = $date_time; $first_day = CalendarUtils::get_first_day_of_week($date_time); $last_day = $first_day->get("+6 days"); for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $first_day->year; break; case "m": $str .= " " . $first_day->get_month_name(); break; case "d": $str .= " " . $first_day->get_day(); break; } } $str .= " - "; for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $last_day->year; break; case "m": $str .= " " . $last_day->get_month_name(); break; case "d": $str .= " " . $last_day->get_day(); break; } } } else { if ($view == 'day') { $str .= $date_time->get_day_of_week() . " "; for ($i = 0; $i < strlen($dateFormat['date']); $i++) { switch ($dateFormat['date'][$i]) { case "Y": $str .= " " . $date_time->year; break; case "m": $str .= " " . $date_time->get_month_name(); break; case "d": $str .= " " . $date_time->get_day(); break; } } } else { if ($view == 'year') { $str .= $date_time->year; } else { sugar_die("echo_date_info: date not supported"); } } } } return $str; }