/** get the content of the list view as HTML * this method returns the content in HTML-Code * * @return string $this->_list as HMTL * * @author CommSy Development Group */ function _getWeekContentAsHTMLWithJavaScript() { $week_start = $this->_week_start; $today = ''; $html = ''; $month_array = array($this->_translator->getMessage('DATES_JANUARY_SHORT'), $this->_translator->getMessage('DATES_FEBRUARY_SHORT'), $this->_translator->getMessage('DATES_MARCH_SHORT'), $this->_translator->getMessage('DATES_APRIL_SHORT'), $this->_translator->getMessage('DATES_MAY_SHORT'), $this->_translator->getMessage('DATES_JUNE_SHORT'), $this->_translator->getMessage('DATES_JULY_SHORT'), $this->_translator->getMessage('DATES_AUGUST_SHORT'), $this->_translator->getMessage('DATES_SEPTEMBER_SHORT'), $this->_translator->getMessage('DATES_OCTOBER_SHORT'), $this->_translator->getMessage('DATES_NOVEMBER_SHORT'), $this->_translator->getMessage('DATES_DECEMBER_SHORT')); //get Dates in month $current_date = $this->_list->getFirst(); $finish = false; $date_array = array(); $date_tooltip_array = array(); while ($current_date) { $start_date_month = ''; $start_date_day = ''; $start_date_year = ''; $end_date_month = ''; $end_date_day = ''; $end_date_year = ''; $start_date_time = ''; $start_end_time = ''; $start_date_array = convertDateFromInput($current_date->getStartingDay(), $this->_environment->getSelectedLanguage()); if ($start_date_array['conforms'] == true) { $start_date_array = getDateFromString($start_date_array['timestamp']); $start_date_month = $start_date_array['month']; $start_date_day = $start_date_array['day']; $start_date_year = $start_date_array['year']; } $start_time_array = convertTimeFromInput($current_date->getStartingTime(), $this->_environment->getSelectedLanguage()); $end_date_array = convertDateFromInput($current_date->getEndingDay(), $this->_environment->getSelectedLanguage()); if ($end_date_array['conforms'] == true) { $end_date_array = getDateFromString($end_date_array['timestamp']); $end_date_month = $end_date_array['month']; $end_date_day = $end_date_array['day']; $end_date_year = $end_date_array['year']; } $end_time_array = convertTimeFromInput($current_date->getEndingTime(), $this->_environment->getSelectedLanguage()); if ($start_date_day != '') { $date_array[$start_date_array['day'] . $start_date_array['month'] . $start_date_array['year']][] = $current_date; $date_tooltip_array[$current_date->getItemID()] = $this->getTooltipDate($current_date); $start_day = mb_substr($current_date->getStartingDay(), 8, 2); $start_month = $start_date_array['month']; $start_year = mb_substr($current_date->getStartingDay(), 0, 4); $first_char = mb_substr($start_day, 0, 1); if ($first_char == '0') { $start_day = mb_substr($start_day, 1, 2); } $first_char = mb_substr($start_month, 0, 1); if ($first_char == '0') { $start_month = mb_substr($start_month, 1, 2); } $end_day = mb_substr($current_date->getEndingDay(), 8, 2); $first_char = mb_substr($end_day, 0, 1); if ($first_char == '0') { $end_day = mb_substr($end_day, 1, 2); } $end_month = mb_substr($current_date->getEndingDay(), 5, 2); $first_char = mb_substr($end_month, 0, 1); if ($first_char == '0') { $end_month = mb_substr($end_month, 1, 2); } $end_year = mb_substr($current_date->getEndingDay(), 0, 4); $first_char = mb_substr($end_year, 0, 1); if ($first_char == '0') { $end_year = mb_substr($end_year, 1, 2); } if (is_numeric($start_day) and is_numeric($end_day) and is_numeric($start_month) and is_numeric($end_month) and is_numeric($start_year) and is_numeric($end_year)) { if ($start_day != $end_day and !empty($end_day) and $start_month != $end_month and !empty($end_month) or $start_day == $end_day and !empty($end_day) and $start_month != $end_month and !empty($end_month) or $start_day != $end_day and !empty($end_day) and $start_month == $end_month and !empty($end_month) or $start_year < $end_year and !empty($end_year)) { while ($start_day != $end_day and $start_month != $end_month or $start_day == $end_day and $start_month != $end_month or $start_day != $end_day and $start_month == $end_month or $start_year < $end_year) { $temp_date = clone $current_date; if ($current_date->getStartingTime()) { $temp_date->setStartingTime('00:00:00'); } $temp_starting_day = $temp_date->getStartingDay(); $days = daysInMonth($start_month, $start_year); $start_day++; if ($start_day > $days) { $start_day = 1; $start_month++; if ($start_month > 12) { $start_month = 1; $start_year++; } } $temp_start_day = $start_day; if (mb_strlen($temp_start_day) == 1) { $temp_start_day = '0' . $temp_start_day; } $temp_start_month = $start_month; if (mb_strlen($temp_start_month) == 1) { $temp_start_month = '0' . $temp_start_month; } $temp_starting_day = $start_year . '-' . $temp_start_month . '-' . $temp_start_day; $temp_date->setShownStartingDay($current_date->getStartingDay()); $temp_date->setShownStartingTime($current_date->getStartingTime()); $temp_date->setStartingDay($temp_starting_day); $date_array[$temp_start_day . $temp_start_month . $start_year][] = $temp_date; unset($temp_date); } } } } $current_date = $this->_list->getNext(); } //Create the html part of the calendar //title row with weekdays $html .= '<div id="calender_frame" style="width:100%; background-color:#ffffff; border:1px solid black; padding:0px;">' . LF; $html .= '<div id="calender_dates" style="width:100%; clear:both;">' . LF; $html .= '<div class="calendar_time_head" id="calendar_time"><div class="data_date"> </div></div>' . LF; $display_date_array = array(); for ($i = 1; $i < 8; $i++) { $startday = date("d", $week_start); $startmonth = date("m", $week_start); $startyear = date("Y", $week_start); if ($startday . $startmonth . $startyear == date("dmY")) { $today = $startday . $startmonth . $startyear; } $startarraymonth = $startmonth; $startmonth = $month_array[$startmonth - 1]; $first_char = mb_substr($startday, 0, 1); if ($first_char == '0') { $display_startday = mb_substr($startday, 1, 2); } else { $display_startday = $startday; } if (isset($date_array[$startday . $startarraymonth . $startyear])) { $display_date_array[$i] = $date_array[$startday . $startarraymonth . $startyear]; } switch ($i) { case 1: $text = 'COMMON_DATE_WEEKVIEW_MONDAY'; break; case 2: $text = 'COMMON_DATE_WEEKVIEW_TUESDAY'; break; case 3: $text = 'COMMON_DATE_WEEKVIEW_WEDNESDAY'; break; case 4: $text = 'COMMON_DATE_WEEKVIEW_THURSDAY'; break; case 5: $text = 'COMMON_DATE_WEEKVIEW_FRIDAY'; break; case 6: $text = 'COMMON_DATE_WEEKVIEW_SATURDAY'; break; case 7: $text = 'COMMON_DATE_WEEKVIEW_SUNDAY'; break; } $html .= '<div class="calendar_entry_head" id="calendar_head_' . ($i - 1) . '_' . date("dmY", $week_start) . '"><div class="data_date">' . LF; switch ($text) { case 'COMMON_DATE_WEEKVIEW_MONDAY': $html .= $this->_translator->getMessage('COMMON_DATE_WEEKVIEW_MONDAY', $display_startday, $startmonth); break; case 'COMMON_DATE_WEEKVIEW_TUESDAY': $html .= $this->_translator->getMessage('COMMON_DATE_WEEKVIEW_TUESDAY', $display_startday, $startmonth); break; case 'COMMON_DATE_WEEKVIEW_WEDNESDAY': $html .= $this->_translator->getMessage('COMMON_DATE_WEEKVIEW_WEDNESDAY', $display_startday, $startmonth); break; case 'COMMON_DATE_WEEKVIEW_THURSDAY': $html .= $this->_translator->getMessage('COMMON_DATE_WEEKVIEW_THURSDAY', $display_startday, $startmonth); break; case 'COMMON_DATE_WEEKVIEW_FRIDAY': $html .= $this->_translator->getMessage('COMMON_DATE_WEEKVIEW_FRIDAY', $display_startday, $startmonth); break; case 'COMMON_DATE_WEEKVIEW_SATURDAY': $html .= $this->_translator->getMessage('COMMON_DATE_WEEKVIEW_SATURDAY', $display_startday, $startmonth); break; case 'COMMON_DATE_WEEKVIEW_SUNDAY': $html .= $this->_translator->getMessage('COMMON_DATE_WEEKVIEW_SUNDAY', $display_startday, $startmonth); break; default: break; } $html .= '</div></div>' . LF; $week_start = $week_start + 3600 * 24; } #$html .= '<div style="width:12px; float:left;"> </div>'.LF; $session = $this->_environment->getSession(); $width = '100%'; $html .= '</div>' . LF; $html .= '<div id="calender_days" style="width:100%; clear:both; border-top:1px solid black;">' . LF; $html .= '<div class="calendar_time_day" id="calendar_time"><div class="data_day"> </div></div>' . LF; for ($index = 0; $index < 7; $index++) { $week_start = $this->_week_start + 3600 * 24 * $index; $startday = date("d", $week_start); $first_char = mb_substr($startday, 0, 1); if ($first_char == '0') { $startday = mb_substr($startday, 1, 2); } $startmonth = date("Ymd", $week_start); $first_char = mb_substr($startmonth, 0, 1); if ($first_char == '0') { $startmonth = mb_substr($startmonth, 1, 2); } $startyear = date("Y", $week_start); $params = array(); $params['iid'] = 'NEW'; $params['day'] = $startday; $parameter_array = $this->_environment->getCurrentParameterArray(); $params['month'] = $startmonth; $params['year'] = $startyear; $params['week'] = $this->_week_start; $params['presentation_mode'] = '1'; $params['time'] = 0; $params['modus_from'] = 'calendar'; $anAction = ''; if ($i == 0) { $image = '<img style="width:' . $width . '; height:1em;" src="images/spacer.gif" alt="" border="0"/>'; } else { $image = '<img style="width:' . $width . '; height:2.2em;" src="images/spacer.gif" alt="" border="0"/>'; } if ($this->_with_modifying_actions) { $anAction = ahref_curl($this->_environment->getCurrentContextID(), CS_DATE_TYPE, 'edit', $params, $image); } $html .= '<div class="calendar_entry_day" id="calendar_entry_' . $index . '"><div class="data_day" id="calendar_entry_date_div_' . $index . '">' . $anAction . '</div></div>' . LF; } #$html .= '<div style="width:11px; float:left;"> </div>'.LF; $html .= '</div>' . LF; $html .= '<div id="calender_main" style="height:450px; overflow:none; clear:both;">' . LF; $current_element = 0; $html_javascript = '<script type="text/javascript"><!--' . LF; $html_javascript .= 'var new_dates = new Array(' . LF; for ($index = 0; $index < 24; $index++) { $html .= '<div class="calendar_time" id="calendar_time_' . $index . '"><div class="data">' . $index . '</div></div>' . LF; for ($index_day = 0; $index_day < 7; $index_day++) { $week_start = $this->_week_start + 3600 * 24 * $index_day; $startday = date("d", $week_start); $first_char = mb_substr($startday, 0, 1); if ($first_char == '0') { $startday = mb_substr($startday, 1, 2); } $startmonth = date("Ymd", $week_start); $first_char = mb_substr($startmonth, 0, 1); if ($first_char == '0') { $startmonth = mb_substr($startmonth, 1, 2); } $startyear = date("Y", $week_start); $params = array(); $params['iid'] = 'NEW'; $params['day'] = $startday; $parameter_array = $this->_environment->getCurrentParameterArray(); $params['month'] = $startmonth; $params['year'] = $startyear; $params['week'] = $this->_week_start; $params['presentation_mode'] = '1'; if ($i != 0) { $params['time'] = $index; } else { $params['time'] = 0; } $params['modus_from'] = 'calendar'; $anAction = ''; if ($i == 0) { $image = '<img style="width:' . $width . '; height:1em;" src="images/spacer.gif" alt="" border="0"/>'; } else { $image = '<img style="width:' . $width . '; height:2.2em;" src="images/spacer.gif" alt="" border="0"/>'; } if ($this->_with_modifying_actions) { $anAction = ahref_curl($this->_environment->getCurrentContextID(), CS_DATE_TYPE, 'edit', $params, $image); } #$html .= '<div class="calendar_entry" id="calendar_entry_' . $index . '"><div class="data" id="calendar_entry_date_div_' . $index . '_' . $index_day . '">' . $anAction . '</div></div>'.LF; if ($index < 8 or $index > 15) { $html .= '<div class="calendar_entry" id="calendar_entry_' . $index . '_' . $index_day . '"><div class="data" id="calendar_entry_date_div_' . $index . '_' . $index_day . '"></div></div>' . LF; } else { $html .= '<div class="calendar_entry_work" id="calendar_entry_' . $index . '_' . $index_day . '"><div class="data" id="calendar_entry_date_div_' . $index . '_' . $index_day . '"></div></div>' . LF; } $html_javascript .= 'new Array(\'#calendar_entry_date_div_' . $index . '_' . $index_day . '\',\'<div name="calendar_new_date" id="calendar_entry_background_div_' . $index . '_' . $index_day . '" style="position:absolute; top: 0px; left: 0px; height: 100%; width: 100%; z-index:900;"><div style="width:100%; text-align:left;">' . $anAction . '</div></div>\')'; if ($current_element < 24 * 7 - 1) { $html_javascript .= ',' . LF; } else { $html_javascript .= LF; } $current_element++; } } $html_javascript .= ');' . LF; $html_javascript .= '--></script>' . LF; $html .= $html_javascript; $html .= '</div>' . LF; $html .= '<div class="calendar_footer"> ' . $this->_translator->getMessage('DATES_WEEK_TIPP_FOR_ENTRIES') . '</div>'; $html .= '</div>' . LF; $date_array_for_jQuery = array(); $date_array_for_jQuery_temp = array(); $date_array_for_jQuery_php = array(); $date_index = 0; $tooltips = array(); $tooltip_date = ''; $tooltip_last_id = ''; for ($day = 1; $day < 9; $day++) { $day_entries = $day - 1; $left_position = 0; if (isset($display_date_array[$day_entries])) { #$overlap_array = $this->overlap_display_date_array($display_date_array[$day_entries]); #pr($overlap_array); #$sort_array = array(); foreach ($display_date_array[$day_entries] as $date) { $is_date_for_whole_day = false; $start_hour = mb_substr($date->getStartingTime(), 0, 2); if (mb_substr($start_hour, 0, 1) == '0') { $start_hour = mb_substr($start_hour, 1, 1); } $start_minutes = mb_substr($date->getStartingTime(), 3, 2); if (mb_substr($start_minutes, 0, 1) == '0') { $start_minutes = mb_substr($start_minutes, 1, 1); } if ($date->getStartingDay() != $date->getEndingDay() and $date->getEndingDay() != '') { if ($date->getEndingTime() != '') { $end_hour = 23; $end_minutes = 60; } else { $end_hour = 0; $end_minutes = 0; $is_date_for_whole_day = true; } } else { if ($date->getEndingTime() != '') { $end_hour = mb_substr($date->getEndingTime(), 0, 2); $end_minutes = mb_substr($date->getEndingTime(), 3, 2); } elseif ($date->getStartingTime() != '' and $date->getEndingTime() == '') { $end_hour = $start_hour + 1; $end_minutes = $start_minutes; } else { $end_hour = $start_hour; $end_minutes = $start_minutes; } } if (mb_substr($end_hour, 0, 1) == '0') { $end_hour = mb_substr($end_hour, 1, 1); } if (mb_substr($end_minutes, 0, 1) == '0') { $end_minutes = mb_substr($end_minutes, 1, 1); } // umrechnen in Minuten, für jede viertelstunde 10 px drauf nach vier noch einen pixel drauf $start_minutes = $start_hour * 60 + $start_minutes; $end_minutes = $end_hour * 60 + $end_minutes; $start_quaters = mb_substr($start_minutes / 15, 0, 2); $start_quaters_addon = mb_substr($start_quaters / 4, 0, 2); $end_quaters = mb_substr($end_minutes / 15, 0, 2); $end_quaters_addon = mb_substr($end_quaters / 4, 0, 2); if ($start_quaters == 0 and $end_quaters == 0) { $is_date_for_whole_day = true; } $top = $start_quaters * 10; $left = 19 + 129 * ($day_entries - 1) + $left_position; $width = 129 / count($display_date_array[$day_entries]) - 4; $height = ($end_quaters - $start_quaters) * 10; if ($date->getColor() != '') { $color = $date->getColor(); } else { $color = '#FFFF66'; } $color_border = '#CCCCCC'; $link = $this->_getDateItemLinkWithJavascript($date, $date->getTitle()); // split() is deprecated as of PHP 5.3.x - use explode() instead! //$link_array = split('"', $link); $link_array = explode('"', $link); $href = $link_array[1]; $overlap = 1; if (!$is_date_for_whole_day) { $display_date = $date; foreach ($display_date_array[$day_entries] as $display_date_compare) { $compare_is_date_for_whole_day = false; if ($display_date_compare->getStartingDay() != $display_date_compare->getEndingDay() and $display_date_compare->getEndingDay() != '') { $compare_is_date_for_whole_day = true; } if (!$compare_is_date_for_whole_day and $display_date->getItemID() != $display_date_compare->getItemID()) { if ($this->overlap($display_date, $display_date_compare)) { $overlap++; } } } } $date_array_for_jQuery[] = 'new Array(' . $day_entries . ',\'' . $link . '\',' . $start_quaters . ',' . $end_quaters . ',' . count($display_date_array[$day_entries]) . ',\'' . $color . '\'' . ',\'' . $color_border . '\'' . ',\'' . $href . '\'' . ',\'sticky_' . $date_index . '\'' . ',\'' . $is_date_for_whole_day . '\')'; $date_array_for_jQuery_php[] = array($day_entries, $link, $start_quaters, $end_quaters, count($display_date_array[$day_entries]), $color, $color_border, $href, 'sticky_' . $date_index, $is_date_for_whole_day); #$date_array_for_jQuery_temp[] = 'new Array(' . $day_entries . ',\'' . $link . '\',' . $start_quaters . ',' . $end_quaters . ',' . $overlap_array[$date->getItemID()] . ',\'' . $color . '\'' . ',\'' . $color_border . '\'' . ',\'' . $href . '\'' . ',\'sticky_' . $date_index . '\'' . ',\'' . $is_date_for_whole_day . '\')'; $tooltip = array(); $tooltip['title'] = $date->getTitle(); // if($date->getItemID() != $tooltip_last_id){ // $tooltip_last_id = $date->getItemID(); // // set up style of days and times // $parse_time_start = convertTimeFromInput($date->getStartingTime()); // $conforms = $parse_time_start['conforms']; // if ($conforms == TRUE) { // $start_time_print = getTimeLanguage($parse_time_start['datetime']); // } else { // $start_time_print = $this->_text_as_html_short($this->_compareWithSearchText($date->getStartingTime())); // } // // $parse_time_end = convertTimeFromInput($date->getEndingTime()); // $conforms = $parse_time_end['conforms']; // if ($conforms == TRUE) { // $end_time_print = getTimeLanguage($parse_time_end['datetime']); // } else { // $end_time_print = $this->_text_as_html_short($this->_compareWithSearchText($date->getEndingTime())); // } // // $parse_day_start = convertDateFromInput($date->getStartingDay(),$this->_environment->getSelectedLanguage()); // $conforms = $parse_day_start['conforms']; // if ($conforms == TRUE) { // $start_day_print = $date->getStartingDayName().', '.$this->_translator->getDateInLang($parse_day_start['datetime']); // } else { // $start_day_print = $this->_text_as_html_short($this->_compareWithSearchText($date->getStartingDay())); // } // // $parse_day_end = convertDateFromInput($date->getEndingDay(),$this->_environment->getSelectedLanguage()); // $conforms = $parse_day_end['conforms']; // if ($conforms == TRUE) { // $end_day_print =$date->getEndingDayName().', '.$this->_translator->getDateInLang($parse_day_end['datetime']); // } else { // $end_day_print =$this->_text_as_html_short($this->_compareWithSearchText($date->getEndingDay())); // } // //formating dates and times for displaying // $date_print =""; // $time_print =""; // // if ($end_day_print != "") { //with ending day // $date_print = $this->_translator->getMessage('DATES_AS_OF').' '.$start_day_print.' '.$this->_translator->getMessage('DATES_TILL').' '.$end_day_print; // if ($parse_day_start['conforms'] // and $parse_day_end['conforms']) { //start and end are dates, not strings // $date_print .= ' ('.getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']).' '.$this->_translator->getMessage('DATES_DAYS').')'; // } // // if ($start_time_print != "" and $end_time_print =="") { //starting time given // $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER').' '.$start_time_print; // if ($parse_time_start['conforms'] == true) { // $time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // } elseif ($start_time_print == "" and $end_time_print !="") { //endtime given // $time_print = $this->_translator->getMessage('DATES_TILL').' '.$end_time_print; // if ($parse_time_end['conforms'] == true) { // $time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // } elseif ($start_time_print != "" and $end_time_print !="") { //all times given // if ($parse_time_end['conforms'] == true) { // $end_time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // if ($parse_time_start['conforms'] == true) { // $start_time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // $date_print = $this->_translator->getMessage('DATES_AS_OF').' '.$start_day_print.', '.$start_time_print.'<br />'. // $this->_translator->getMessage('DATES_TILL').' '.$end_day_print.', '.$end_time_print; // if ($parse_day_start['conforms'] // and $parse_day_end['conforms']) { // $date_print .= ' ('.getDifference($parse_day_start['timestamp'], $parse_day_end['timestamp']).' '.$this->_translator->getMessage('DATES_DAYS').')'; // } // } // // } else { //without ending day // $date_print = $this->_translator->getMessage('DATES_ON_DAY').' '.$start_day_print; // if ($start_time_print != "" and $end_time_print =="") { //starting time given // $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER').' '.$start_time_print; // if ($parse_time_start['conforms'] == true) { // $time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // } elseif ($start_time_print == "" and $end_time_print !="") { //endtime given // $time_print = $this->_translator->getMessage('DATES_TILL').' '.$end_time_print; // if ($parse_time_end['conforms'] == true) { // $time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // } elseif ($start_time_print != "" and $end_time_print !="") { //all times given // if ($parse_time_end['conforms'] == true) { // $end_time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // if ($parse_time_start['conforms'] == true) { // $start_time_print .= ' '.$this->_translator->getMessage('DATES_OCLOCK'); // } // $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER').' '.$start_time_print.' '.$this->_translator->getMessage('DATES_TILL').' '.$end_time_print; // } // } // // if ($parse_day_start['timestamp'] == $parse_day_end['timestamp'] and $parse_day_start['conforms'] and $parse_day_end['conforms']) { // $date_print = $this->_translator->getMessage('DATES_ON_DAY').' '.$start_day_print; // if ($start_time_print != "" and $end_time_print =="") { //starting time given // $time_print = $this->_translator->getMessage('DATES_AS_OF_LOWER').' '.$start_time_print; // } elseif ($start_time_print == "" and $end_time_print !="") { //endtime given // $time_print = $this->_translator->getMessage('DATES_TILL').' '.$end_time_print; // } elseif ($start_time_print != "" and $end_time_print !="") { //all times given // $time_print = $this->_translator->getMessage('DATES_FROM_TIME_LOWER').' '.$start_time_print.' '.$this->_translator->getMessage('DATES_TILL').' '.$end_time_print; // } // } // // // Date and time // $temp_array = array(); // $temp_array[] = $this->_translator->getMessage('DATES_DATETIME'); // if ($time_print != '') { // $temp_array[] = $date_print.BRLF.$time_print; // } else { // $temp_array[] = $date_print; // } // $tooltip_date = $temp_array; // } #$tooltip['date'] = $tooltip_date; $tooltip['date'] = $date_tooltip_array[$date->getItemID()]; $tooltip['place'] = $date->getPlace(); $tooltip['participants'] = $date->getParticipantsItemList(); #$tooltip['desc'] = $date->getDescription(); $tooltip['color'] = $color; $tooltips['sticky_' . $date_index] = $tooltip; $date_index++; $left_position = $left_position + $width + 4; } } } $html .= '<div id="mystickytooltip" class="stickytooltip"><div style="border:1px solid #cccccc;">'; foreach ($tooltips as $id => $tooltip) { $html .= '<div id="' . $id . '" class="atip" style="padding:5px; border:2px solid ' . $tooltip['color'] . '">' . LF; $html .= '<table>' . LF; $html .= '<tr><td colspan="2"><b>' . encode(AS_HTML_SHORT, $tooltip['title']) . '</b></td></tr>' . LF; $html .= '<tr><td style="vertical-align:top;"><b>' . $this->_translator->getMessage('DATES_DATETIME') . ':</b></td><td>' . $tooltip['date'][1] . '</td></tr>' . LF; if ($tooltip['place'] != '') { $html .= '<tr><td style="vertical-align:top;"><b>' . $this->_translator->getMessage('DATES_PLACE') . ':</b></td><td>' . encode(AS_HTML_SHORT, $tooltip['place']) . '</td></tr>' . LF; } $html .= '<tr><td style="vertical-align:top;"><b>' . $this->_translator->getMessage('DATE_PARTICIPANTS') . ':</b></td><td>' . LF; if ($tooltip['participants']->isEmpty()) { $html .= $this->_translator->getMessage('TODO_NO_PROCESSOR'); } else { $participant = $tooltip['participants']->getFirst(); $count = $tooltip['participants']->getCount(); $counter = 1; while ($participant) { $html .= $participant->getFullName(); if ($counter < $count) { $html .= ', '; } $participant = $tooltip['participants']->getNext(); $counter++; } } $html .= '</td></tr>' . LF; #$html .= '<tr><td colspan="2">' . $tooltip['desc'] . '</td></tr>'.LF; $html .= '</table>' . LF; $html .= '</div>' . LF; } $html .= '</div></div>'; $html .= '<script type="text/javascript">' . LF; $html .= '<!--' . LF; $html .= 'var calendar_dates = new Array('; #pr($date_array_for_jQuery_php); #pr($date_array_for_jQuery_temp); // die maximale breite bei nebeneinander liegenden Termine $overlap_array = array(); $max_overlap_array = array(); $max_overlap_array_for_date = array(); $date_array_for_jQuery_php_with_position = array(); for ($int = 0; $int < 7; $int++) { $temp_quaters_array = array(); for ($j = 0; $j < 96; $j++) { $temp_quaters_array[] = 0; } for ($i = 0; $i < sizeof($date_array_for_jQuery_php); $i++) { $day = $date_array_for_jQuery_php[$i][0] - 1; if ($day == $int) { $start_quaters = $date_array_for_jQuery_php[$i][2]; $end_quaters = $date_array_for_jQuery_php[$i][3]; for ($j = $start_quaters; $j < $end_quaters; $j++) { $value = $temp_quaters_array[$j]; $temp_quaters_array[$j] = $value + 1; } } } $overlap_array[] = $temp_quaters_array; $max_overlap = 0; for ($i = 0; $i < sizeof($temp_quaters_array); $i++) { if ($max_overlap < $temp_quaters_array[$i]) { $max_overlap = $temp_quaters_array[$i]; } } $max_overlap_array[] = $max_overlap; for ($i = 0; $i < sizeof($date_array_for_jQuery_php); $i++) { $day = $date_array_for_jQuery_php[$i][0] - 1; if ($day == $int) { $start_quaters = $date_array_for_jQuery_php[$i][2]; $end_quaters = $date_array_for_jQuery_php[$i][3]; $max_overlap_for_date = 0; for ($j = $start_quaters; $j < $end_quaters; $j++) { if ($temp_quaters_array[$j] > $max_overlap_for_date) { $max_overlap_for_date = $temp_quaters_array[$j]; } } $max_overlap_array_for_date[] = $max_overlap_for_date; } } } #pr($max_overlap_array); // Arrays zum Sortieren vorbereiten $sort_dates_array = array(); $sort_dates_start_array = array(); for ($i = 0; $i < 7; $i++) { $temp_sort_array = array(); for ($j = 0; $j < $max_overlap_array[$i]; $j++) { $temp_part_array = array(); for ($k = 0; $k < 96; $k++) { $temp_part_array[] = 0; } $temp_sort_array[] = $temp_part_array; } // Termine sortieren $max_overlap_index = 0; foreach ($date_array_for_jQuery_php as $temp_date) { $found_position = false; if ($temp_date[0] - 1 == $i) { $start_quaters = $temp_date[2]; $end_quaters = $temp_date[3]; $date_set = false; for ($temp_part = 0; $temp_part < sizeof($temp_sort_array); $temp_part++) { #foreach($temp_sort_array as $temp_part_array){ if (!$date_set) { $slot_free = true; for ($time = $start_quaters; $time < $end_quaters; $time++) { if ($temp_sort_array[$temp_part][$time] != 0) { #if($temp_part_array[$time] != 0){ $slot_free = false; } } if ($slot_free) { for ($time = $start_quaters; $time < $end_quaters; $time++) { $temp_sort_array[$temp_part][$time] = 1; if (!$found_position) { $temp_date[] = sizeof($temp_sort_array); $temp_date[] = $temp_part; $temp_date[] = $time; $found_position = true; } $temp_part_array[$time] = 1; } $date_set = true; } } } $temp_date[] = $max_overlap_array_for_date[$max_overlap_index]; $date_array_for_jQuery_php_with_position[] = $temp_date; } $max_overlap_index++; } $sort_dates_array[] = $temp_sort_array; } $last = count($date_array_for_jQuery) - 1; #for ($index = 0; $index < count($date_array_for_jQuery); $index++) { # $html .= $date_array_for_jQuery[$index]; # #pr($date_array_for_jQuery[$index]); # if($index < $last){ # $html .= ','; # } #} for ($index = 0; $index < count($date_array_for_jQuery_php_with_position); $index++) { $day_entries = $date_array_for_jQuery_php_with_position[$index][0]; $link = $date_array_for_jQuery_php_with_position[$index][1]; $link = str_replace("'", "\\'", $link); $start_quaters = $date_array_for_jQuery_php_with_position[$index][2]; $end_quaters = $date_array_for_jQuery_php_with_position[$index][3]; $dates_on_day = $date_array_for_jQuery_php_with_position[$index][4]; $color = $date_array_for_jQuery_php_with_position[$index][5]; $color_border = $date_array_for_jQuery_php_with_position[$index][6]; $href = $date_array_for_jQuery_php_with_position[$index][7]; $date_index = $date_array_for_jQuery_php_with_position[$index][8]; $is_date_for_whole_day = $date_array_for_jQuery_php_with_position[$index][9]; if (isset($date_array_for_jQuery_php_with_position[$index][10])) { $max_overlap = $date_array_for_jQuery_php_with_position[$index][10]; } else { $max_overlap = 0; } if (isset($date_array_for_jQuery_php_with_position[$index][11])) { $start_column = $date_array_for_jQuery_php_with_position[$index][11]; } else { $start_column = 0; } if (isset($date_array_for_jQuery_php_with_position[$index][12])) { $start_quarter = $date_array_for_jQuery_php_with_position[$index][12]; } else { $start_quarter = 0; } if (isset($date_array_for_jQuery_php_with_position[$index][13])) { $max_overlap_for_date = $date_array_for_jQuery_php_with_position[$index][13]; } else { $max_overlap_for_date = 0; } $html .= 'new Array(' . $day_entries . ',\'' . $link . '\',' . $start_quaters . ',' . $end_quaters . ',' . $dates_on_day . ',\'' . $color . '\'' . ',\'' . $color_border . '\'' . ',\'' . $href . '\'' . ',\'' . $date_index . '\'' . ',\'' . $is_date_for_whole_day . '\'' . ',' . $max_overlap . '' . ',' . $start_column . '' . ',' . $start_quarter . '' . ',' . $max_overlap_for_date . ')' . LF; #pr($date_array_for_jQuery[$index]); if ($index < $last) { $html .= ','; } } $html .= ');' . LF; $html .= 'var today = "' . $today . '";' . LF; $html .= '-->' . LF; $html .= '</script>' . LF; return $html; }
public function __construct(LiveCart $application, ARSelectFilter $filter, $modelClass = false, $columnTypes = array()) { $this->application = $application; $this->modelClass = $modelClass; $this->filter = $filter; $this->columnTypes = $columnTypes; $request = $this->application->getRequest(); // set recordset boundaries (limits) $filter->setLimit($request->get('page_size', 10), $request->get('offset', 0)); // set order if ($request->isValueSet('sort_col')) { $handle = $this->getFieldHandle($request->get('sort_col'), self::SORT_HANDLE); if ($handle) { $filter->setOrder($handle, $request->get('sort_dir')); } } // apply filters $filters = $request->get('filters'); if (!is_array($filters)) { $filters = (array) json_decode($request->get('filters')); } $conds = array(); if ($filter->getCondition()) { $conds[] = $filter->getCondition(); } foreach ($filters as $field => $value) { if (!strlen($value)) { continue; } $value = urldecode($value); $handle = $this->getFieldHandle($field, self::FILTER_HANDLE); if ($handle instanceof EavFieldCommon) { continue; } else { if (!is_array($handle) && !is_null($handle) && !$handle instanceof ARExpressionHandle) { $fieldInst = $this->getFieldInstance($field); if ($fieldInst && ($fieldInst->getDataType() instanceof ARNumeric || $handle->getField()->getDataType() instanceof ARNumeric)) { $value = preg_replace('/[ ]{2,}/', ' ', $value); $constraints = $fieldInst->getDataType() instanceof ARNumeric ? explode(' ', $value) : array($value); foreach ($constraints as $c) { list($operator, $value) = $this->parseOperatorAndValue($c); if (!is_numeric($value) && $fieldInst->getDataType() instanceof ARNumeric) { continue; } $conds[] = new OperatorCond($handle, $value, $operator); } } else { if ($fieldInst && $fieldInst->getDataType() instanceof ARPeriod) { if (substr($value, 0, 10) == 'daterange ') { $value = str_replace('daterange ', '', $value); list($from, $to) = explode('|', $value); $from = trim($from); $to = trim($to); // convert // 2010-9-1 to 2010-09-01 ( +first or last minute of day) // unset dates to 'inf' (meaning ingnore condition) if ($from == '') { $from = 'inf'; } else { list($y, $m, $d) = explode('-', $from); $from = $y . '-' . str_pad($m, 2, '0', STR_PAD_LEFT) . '-' . str_pad($d, 2, '0', STR_PAD_LEFT) . ' 00:00:00'; } if ($to == '') { $to = 'inf'; } else { list($y, $m, $d) = explode('-', $to); $to = $y . '-' . str_pad($m, 2, '0', STR_PAD_LEFT) . '-' . str_pad($d, 2, '0', STR_PAD_LEFT) . ' 23:59:59'; } } else { list($from, $to) = explode(' | ', $value); } $cond = null; // from condition if ('inf' != $from) { $cond = new EqualsOrMoreCond($handle, getDateFromString($from)); } // to condition if ('now' != $to && 'inf' != $to) { $condTo = new EqualsOrLessCond($handle, getDateFromString($to)); if ($cond) { $cond->addAnd($condTo); } else { $cond = $condTo; } } if ($cond) { $conds[] = $cond; } } else { $conds[] = new LikeCond($handle, '%' . $value . '%'); } } } else { if (is_array($handle)) { $cond = null; foreach ($handle as $h) { $c = new LikeCond($h, '%' . $value . '%'); if (!$cond) { $cond = $c; } else { $cond->addOR($c); } } $conds[] = $cond; } else { if (array_key_exists($field, $this->columnTypes)) { $type = $this->columnTypes[$field]['type']; } else { $type = null; } $value = preg_replace('/[ ]{2,}/', ' ', $value); switch ($type) { case 'numeric': $constraints = explode(' ', $value); foreach ($constraints as $c) { list($operator, $value) = $this->parseOperatorAndValue($c); if (!is_numeric($value)) { continue; } $having[] = new OperatorCond($handle, $value, $operator); } break; default: $having[] = eq(new ARExpressionHandle($field), $value); } } } } } // apply IDs to filter if ($request->get('selectedIDs') || $request->get('isInverse')) { $selectedIDs = json_decode($request->get('selectedIDs')); if ($selectedIDs) { if ((bool) $request->get('isInverse')) { $idcond = new NotINCond(new ARFieldHandle($modelClass, 'ID'), $selectedIDs); } else { $idcond = new INCond(new ARFieldHandle($modelClass, 'ID'), $selectedIDs); } $conds[] = $idcond; } else { if (!(bool) $request->get('isInverse')) { $idcond = new EqualsCond(new ARExpressionHandle(1), 2); $conds[] = $idcond; } } } if ($conds) { $filter->setCondition(new AndChainCondition($conds)); } if (!empty($having)) { $filter->setHavingCondition(new AndChainCondition($having)); } }
public function info() { ClassLoader::importNow("application.helper.getDateFromString"); $product = Product::getInstanceById($this->request->get('id'), ActiveRecord::LOAD_DATA, array('DefaultImage' => 'ProductImage', 'Manufacturer', 'Category')); $thisMonth = date('m'); $lastMonth = date('Y-m', strtotime(date('m') . '/15 -1 month')); $periods = array('_last_1_h' => "-1 hours | now", '_last_3_h' => "-3 hours | now", '_last_6_h' => "-6 hours | now", '_last_12_h' => "-12 hours | now", '_last_24_h' => "-24 hours | now", '_last_3_d' => "-3 days | now", '_this_week' => "w:Monday | now", '_last_week' => "w:Monday ~ -1 week | w:Monday", '_this_month' => $thisMonth . "/1 | now", '_last_month' => $lastMonth . "-1 | " . $lastMonth . "/1", '_this_year' => "January 1 | now", '_last_year' => "January 1 last year | January 1", '_overall' => "now | now"); $purchaseStats = array(); $prevCount = 0; foreach ($periods as $key => $period) { list($from, $to) = explode(' | ', $period); $cond = new EqualsCond(new ARFieldHandle('OrderedItem', 'productID'), $product->getID()); if ('now' != $from) { $cond->addAND(new EqualsOrMoreCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($from))); } if ('now' != $to) { $cond->addAnd(new EqualsOrLessCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($to))); } $f = new ARSelectFilter($cond); $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true)); $f->removeFieldList(); $f->addField('SUM(OrderedItem.count)'); $query = new ARSelectQueryBuilder(); $query->setFilter($f); $query->includeTable('OrderedItem'); $query->joinTable('CustomerOrder', 'OrderedItem', 'ID', 'customerOrderID'); if (($count = array_shift(array_shift(ActiveRecordModel::getDataBySql($query->getPreparedStatement(ActiveRecord::getDBConnection()))))) && ($count > $prevCount || '_overall' == $key)) { $purchaseStats[$key] = $count; } if ($count > $prevCount) { $prevCount = $count; } } $response = new ActionResponse(); $response->set('together', $product->getProductsPurchasedTogether(10)); $response->set('product', $product->toArray()); $response->set('purchaseStats', $purchaseStats); return $response; }
private function isRated(Product $product, $isRating = false) { if (!empty($_COOKIE['rating_' . $product->getID()])) { return true; } if ($isRating) { ClassLoader::importNow("application.helper.getDateFromString"); $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('ProductRating', 'productID'), $product->getID())); if (!$this->user->isAnonymous()) { $cond = new EqualsCond(new ARFieldHandle('ProductRating', 'userID'), $this->user->getID()); } else { if ($hours = $this->config->get('RATING_SAME_IP_TIME')) { $cond = new EqualsCond(new ARFieldHandle('ProductRating', 'ip'), $this->request->getIPLong()); $cond->addAnd(new MoreThanCond(new ARFieldHandle('ProductRating', 'dateCreated'), getDateFromString('-' . $hours . ' hours'))); } } if (isset($cond)) { $f->mergeCondition($cond); return ActiveRecordModel::getRecordCount('ProductRating', $f) > 0; } } }
private function getDateRange() { if ($this->request->get('date') && 'all' != $this->request->get('date')) { $res = array(); foreach (explode(' | ', $this->request->get('date')) as $part) { $res[] = 'now' == $part ? null : getDateFromString($part); } return $res; } }
function write() { global $current_user; $id = isset(Request::$post['id']) ? (int) Request::$post['id'] : false; if (!$id) $this->newAuthor(); $persons = Persons::getByIdsLoaded(array($id)); $person = is_array($persons) ? $persons[$id] : false; if (!$person) return; $savedData = $person->data; /* @var $book Book */ $fields = array( 'lang_code' => 'author_lang', //lang_code 'bio' => 'bio', 'first_name' => 'first_name', 'middle_name' => 'middle_name', 'last_name' => 'last_name', //'id_user' => 'id_user', 'homepage' => 'homepage', 'wiki_url' => 'wiki_url', 'date_birth' => 'date_birth', 'date_death' => 'date_death' ); Request::$post['lang_code'] = Config::$langs[Request::$post['lang_code']]; $to_update = array(); if (isset($_FILES['picture']) && $_FILES['picture']['tmp_name']) { $folder = Config::need('static_path') . '/upload/authors/' . (ceil($person->id / 5000)); @mkdir($folder); chmod($folder, 755); $filename = $folder . '/' . $person->id . '.jpg'; $upload = new UploadAvatar($_FILES['picture']['tmp_name'], 100, 100, "simple", $filename); if ($upload->out) $to_update['has_cover'] = 1; else { throw new Exception('cant copy file to ' . $filename, 100); } } foreach ($fields as $field => $personfield) { if (!isset(Request::$post[$field])) { throw new Exception('field missed #' . $field); } if ($person->data[$personfield] != Request::$post[$field]) { $to_update[$personfield] = Request::$post[$field]; } } $q = array(); if (count($to_update)) $to_update['authorlastSave'] = time(); foreach ($to_update as $field => &$value) { if ($field == 'date_birth' || $field == 'date_death') { $value = getDateFromString($value); } if ($field == 'bio') { list($full, $short) = $person->processBio($value); $q[] = '`bio`=' . Database::escape($full) . ''; $q[] = '`short_bio`=' . Database::escape($short) . ''; $value = $person->data['bio'] = $full; $person->data['short_bio'] = $short; } else { $q[] = '`' . $field . '`=' . Database::escape($value) . ''; $person->data[$field] = $value; } } if (count($q)) { $query = 'UPDATE `persons` SET ' . implode(',', $q) . ' WHERE `id`=' . $person->id; Database::query($query); unset($to_update['authorlastSave']); PersonLog::addLog($to_update, $savedData); PersonLog::saveLog($person->id, BiberLog::TargetType_person, $current_user->id, BiberLog::BiberLogType_personEdit); } }
protected function getOrderCount($from, $to) { $cond = new EqualsOrMoreCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($from)); if ('now' != $to) { $cond->addAnd(new EqualsOrLessCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($to))); } $f = new ARSelectFilter($cond); $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true)); $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isCancelled'), false)); return ActiveRecordModel::getRecordCount('CustomerOrder', $f); }
function write() { global $current_user; $current_user->can_throw('books_edit'); $id = isset(Request::$post['id']) ? (int) Request::$post['id'] : false; if (!$id) { $this->newAuthor(); return; } $person = Persons::getInstance()->getByIdLoaded($id); if (!$person) { return; } $savedData = $person->data; /* @var $book Book */ $fields = array('lang_code' => 'author_lang', 'bio' => 'bio', 'first_name' => 'first_name', 'middle_name' => 'middle_name', 'last_name' => 'last_name', 'homepage' => 'homepage', 'wiki_url' => 'wiki_url', 'date_birth' => 'date_birth', 'date_death' => 'date_death'); if (!Request::$post['first_name'] || !Request::$post['last_name']) { throw new Exception('no author\'s name'); } if (!Request::$post['lang_code']) { throw new Exception('no author\'s language'); } Request::$post['lang_code'] = Config::$langs[Request::$post['lang_code']]; $to_update = array(); if (isset($_FILES['picture']) && $_FILES['picture']['tmp_name']) { $folder = Config::need('static_path') . '/upload/authors/' . ceil($person->id / 5000); @mkdir($folder); // inserting new cover $query = 'INSERT INTO `person_covers` SET `id_person`=' . $person->id; Database::query($query); $cover_id = Database::lastInsertId(); // generating file names $filename_normal = $folder . '/default_' . $person->id . '_' . $cover_id . '.jpg'; $filename_small = $folder . '/small_' . $person->id . '_' . $cover_id . '.jpg'; $filename_big = $folder . '/big_' . $person->id . '_' . $cover_id . '.jpg'; $filename_orig = $folder . '/orig_' . $person->id . '_' . $cover_id . '.jpg'; $to_update['has_cover'] = $cover_id; $thumb = new Thumb(); $thumb->createThumbnails($_FILES['picture']['tmp_name'], array($filename_small, $filename_normal, $filename_big, $filename_orig), self::$cover_sizes); if ($savedData['has_cover']) { $current_user->gainActionPoints('authors_add_cover', $person->id, BiberLog::TargetType_person); } else { $current_user->gainActionPoints('authors_edit_cover', $person->id, BiberLog::TargetType_person); } } foreach ($fields as $field => $personfield) { if (!isset(Request::$post[$field])) { throw new Exception('field missed #' . $field); } if ($person->data[$personfield] != Request::$post[$field]) { $to_update[$personfield] = Request::$post[$field]; } } $q = array(); if (count($to_update)) { $to_update['authorlastSave'] = time(); } foreach ($to_update as $field => &$value) { if ($field == 'date_birth' || $field == 'date_death') { $value = getDateFromString($value); } if ($field == 'bio') { list($full, $short) = $person->processBio($value); $q[] = '`bio`=' . Database::escape($full) . ''; $q[] = '`short_bio`=' . Database::escape($short) . ''; $value = $person->data['bio'] = $full; $person->data['short_bio'] = $short; } else { $q[] = '`' . $field . '`=' . Database::escape($value) . ''; $person->data[$field] = $value; } } if (count($q)) { $query = 'UPDATE `persons` SET ' . implode(',', $q) . ' WHERE `id`=' . $person->id; Database::query($query); unset($to_update['authorlastSave']); PersonLog::addLog($to_update, $savedData, $person->id); PersonLog::saveLog($person->id, BiberLog::TargetType_person, $current_user->id, BiberLog::BiberLogType_personEdit); Persons::getInstance()->dropCache($person->id); $current_user->gainActionPoints(BiberLog::$actionTypes[BiberLog::BiberLogType_personEdit], $person->id, BiberLog::TargetType_person); $search = Search::getInstance(); /* @var $search Search */ $search->setAuthorToFullUpdate($person->id); } ob_end_clean(); header('Location:' . Config::need('www_path') . '/a/' . $person->id); exit; }
private function getMonthContent($list) { $translator = $this->_environment->getTranslationObject(); $current_time = localtime(); // do some time calculations $month = mb_substr($this->_calendar["month"], 4, 2); $year = $this->_calendar["year"]; $days = daysInMonth($month, $year); $first_day_week_day = $this->getWeekDayOfDate(1, $month, $year); // create array with correct daynumber/weekday relationship $format_array = array(); $current_month = array(); $current_year = array(); //skip fields at beginning $empty_fields = ($first_day_week_day + 6) % 7; if ($month != '01') { $prev_month = $month - 1; $prev_month_year = $year; } else { $prev_month = 12; $prev_month_year = $year - 1; } $prev_month_days = daysInMonth($prev_month, $prev_month_year); for ($i = 0; $i < $empty_fields; $i++) { $format_array[]['day'] = $prev_month_days - ($empty_fields - $i) + 1; $current_month[] = (string) $prev_month; $current_year[] = $prev_month_year; } // fill days for ($i = 1; $i <= $days; $i++) { $format_array[]['day'] = $i; $current_month[] = (string) $month; $current_year[] = $year; } // skip at ending $sum = $days + $empty_fields; $remaining = 42 - $sum; if ($month != '12') { $next_month = $month + 1; $next_month_year = $year; } else { $next_month = 1; $next_month_year = $year + 1; } for ($i = 0; $i < $remaining; $i++) { $format_array[]['day'] = $i + 1; $current_month[] = (string) $next_month; $current_year[] = $next_month_year; } // get Dates in month $current_date = $list->getFirst(); $finish = false; $date_tooltip_array = array(); while ($current_date) { $date_tooltip_array[$current_date->getItemID()] = $this->getTooltipDate($current_date); $start_date_month = ''; $start_date_day = ''; $start_date_year = ''; $end_date_month = ''; $end_date_day = ''; $end_date_year = ''; $start_date_array = convertDateFromInput($current_date->getStartingDay(), $this->_environment->getSelectedLanguage()); if ($start_date_array['conforms'] == true) { $start_date_array = getDateFromString($start_date_array['timestamp']); $start_date_month = $start_date_array['month']; $start_date_day = $start_date_array['day']; $start_date_year = $start_date_array['year']; } $end_date_array = convertDateFromInput($current_date->getEndingDay(), $this->_environment->getSelectedLanguage()); if ($end_date_array['conforms'] == true) { $end_date_array = getDateFromString($end_date_array['timestamp']); $end_date_month = $end_date_array['month']; $end_date_day = $end_date_array['day']; $end_date_year = $end_date_array['year']; } if ($start_date_day != '') { //date begins at least one month before currently displayed month, ends in currently displayed month // OR date begins in a year before the current and ends in if (($start_date_month < $month or $start_date_year < $year) and $end_date_month == $month and $end_date_year == $year) { for ($i = 0; $i < $end_date_day; $i++) { $format_array[$empty_fields + $i]['dates'][] = $current_date; } //date begins in currently displayed month, ends aftet currently displayed month //OR date begins in currently displayed year and ends after currently displayed year } elseif ($start_date_month == $month and $start_date_year == $year and ($end_date_month > $month or $end_date_year > $year)) { $rest_month = $days - $start_date_day; for ($i = 0; $i <= $rest_month; $i++) { $format_array[$empty_fields + $start_date_day - 1 + $i]['dates'][] = $current_date; } //date begins before and ends after currently displayed month } elseif (($start_date_month < $month or $start_date_year < $year) and ($end_date_month > $month or $end_date_year > $year)) { for ($i = 0; $i < $days; $i++) { $format_array[$empty_fields + $i]['dates'][] = $current_date; } } else { //Date spans in one month or is on a single day $length = 0; if ($end_date_day != '') { $length = $end_date_day - $start_date_day; } for ($i = 0; $i <= $length; $i++) { $format_array[$empty_fields + $start_date_day - 1 + $i]['dates'][] = $current_date; } } } $current_date = $list->getNext(); } // setup tooltip's and actions $anAction_array = array(); $dateNewArray = array(); $date_index = 0; $tooltips = array(); $tooltip_last_id = ''; $tooltip_date = ''; for ($i = 0; $i < 42; $i++) { if ($format_array[$i]['day'] . $current_month[$i] . $current_year[$i] == date("dmY")) { $today = $format_array[$i]['day'] . $current_month[$i] . $current_year[$i]; } $params = array(); $params['iid'] = 'NEW'; $temp_day = $format_array[$i]['day']; if (mb_strlen($temp_day) == 1) { $temp_day = '0' . $temp_day; } $params['day'] = $temp_day; $parameter_array = $this->_environment->getCurrentParameterArray(); $temp_month = $current_month[$i]; if (mb_strlen($temp_month) == 1) { $temp_month = '0' . $temp_month; } $params['month'] = $current_year[$i] . $temp_month . '01'; $params['year'] = $current_year[$i]; $params['presentation_mode'] = $this->_presentation_mode; $params['modus_from'] = 'calendar'; $anAction = ahref_curl($this->_environment->getCurrentContextID(), CS_DATE_TYPE, 'edit', $params, '<img style="width:100%; height:100%" src="images/spacer.gif" alt="" border="0"/>'); $anAction_array[] = $anAction; $dateNewArray[] = mktime(0, 0, 0, $current_month[$i], $format_array[$i]['day'], $current_year[$i]); } // get return data $return = array(); $days = array(); $i = 0; $todayCompressed = date("jnY"); foreach ($format_array as $format) { $current_month_temp = $current_month[$i]; if ($current_month_temp[0] == 0) { $current_month_temp = $current_month_temp[1]; } $state = "active_day"; // check if day is today if ($todayCompressed === $format['day'] . $current_month_temp . $current_year[$i]) { $state = "this_today"; } elseif ($current_month[$i] != mb_substr($this->_calendar["month"], 4, 2)) { $state = "nonactive_day"; } // process dates for this day $dates = array(); foreach ($format["dates"] as $date) { // link $link = $this->getDateItemLinkWithJavascript($date, $date->getTitle()); $link = str_replace("'", "\\'", $link); $link_array = explode('"', $link); $href = $link_array[1]; // color if ($date->getColor() != '') { $color = $date->getColor(); } else { $color = '#FFFF66'; } $colorStr = ""; switch ($color) { case '#CC0000': $colorStr = "red"; break; case '#FF6600': $colorStr = "orange"; break; case '#FFCC00': $colorStr = "yellow"; break; case '#FFFF66': $colorStr = "light_yellow"; break; case '#33CC00': $colorStr = "green"; break; case '#00CCCC': $colorStr = "turquoise"; break; case '#3366FF': $colorStr = "blue"; break; case '#6633FF': $colorStr = "dark_blue"; break; case '#CC33CC': $colorStr = "purple"; break; default: $colorStr = "grey"; break; } // room $room_title = ""; $date_context_item = $date->getContextItem(); if (isset($date_context_item)) { $room_title = $date_context_item->getTitle(); } // participants $participants = array(); $participantsList = $date->getParticipantsItemList(); if (!$participantsList->isEmpty()) { $participant = $participantsList->getFirst(); while ($participant) { $participants[] = array("name" => $participant->getFullName()); $participant = $participantsList->getNext(); } } $date = array("title" => $date->getTitle(), "display_title" => $date->getTitle(), "date" => $date_tooltip_array[$date->getItemID()], "place" => $date->getPlace(), "participants" => $participants, "color" => $colorStr, "context" => $room_title, "href" => $href); $dates[] = $date; } $days[] = array("day" => $format["day"], "link" => $anAction_array[$i], "state" => $state, "dates" => $dates, "date_new" => $dateNewArray[$i]); $i++; } $return['days'] = $days; return $return; }