page = str_replace('{SUBSCRIBE_PATH}', $subscribe_path, $this->page); $this->page = str_replace('{DOWNLOAD_FILENAME}', $download_filename, $this->page); } else { $this->page = preg_replace('!<\!-- switch display_download on -->(.*)<\!-- switch display_download off -->!is', '', $this->page); } } function draw_admin() { global $phpiCal_config, $getdate, $cal, $master_array, $is_loged_in; if ($is_loged_in == TRUE) { // Print Calendar Checkboxes $COLUMNS_TO_PRINT = 3; $column = 1; $filelist = availableCalendars('', '', '', true); foreach ($filelist as $file) { if ($column > $COLUMNS_TO_PRINT) { $delete_table .= ''; $column = 1; } if ($column == 1) { $delete_table .= '
"; #print_r ($this_time_arr); #print ""; foreach ($this_time_arr as $eventKey => $loopevent) { $drawEvent = drawEventTimes ($cal_time, $loopevent["event_end"]); $j = 0; while (isset($event_length[$thisday][$j])) { if ($event_length[$thisday][$j]["state"] == "ended") { $event_length[$thisday][$j] = array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"); break; } $j++; } if ($j == sizeof($event_length[$thisday])) { array_push ($event_length[$thisday], array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin")); } } } if (sizeof($event_length[$thisday]) == 0) { if ($dayborder == 0) { $class = ' class="weekborder"'; $dayborder++; } else { $class = ''; $dayborder = 0; } $drawWidth = 1; $colspan_width = round((80 / $nbrGridCols[$thisday]) * $drawWidth); $weekdisplay .= '
";print_r($switch);echo ""; foreach ($switch as $tag => $data) { $temp = str_replace('{'.$tag.'}', $data, $temp); } $middle .= $temp; $start_day = strtotime("+1 day", $start_day); if ($i == 7) { $i = 0; $middle .= $endweek; $checkagain = date ("m", $start_day); if ($checkagain != $minical_month) $whole_month = FALSE; } } while ($whole_month == TRUE); $return = str_replace(''.$match1[1].'', $weekday_loop, $template_p); $return = preg_replace('!<\!-- loop monthweeks on -->(.*)<\!-- loop monthweeks off -->!is', $middle, $return); $return = str_replace('{MONTH_TITLE}', $month_title, $return); $return = str_replace('{CAL}', $cal, $return); $return = str_replace('{MONTH_DATE}', $month_date, $return); return $return; } function nomonthbottom() { $this->page = preg_replace('!<\!-- switch showbottom on -->(.*)<\!-- switch showbottom off -->!is','', $this->page); } function nosearch() { $this->page = preg_replace('!<\!-- switch show_search on -->(.*)<\!-- switch show_search off -->!is','', $this->page); } function monthbottom() { global $phpiCal_config, $getdate, $master_array, $this_year, $this_month, $cal, $timeFormat, $timeFormat_small, $dateFormat_week_list, $lang; preg_match("!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_odd off -->!is", $this->page, $match1); preg_match("!<\!-- loop showbottomevents_even on -->(.*)<\!-- loop showbottomevents_even off -->!is", $this->page, $match2); $loop[0] = trim($match1[1]); $loop[1] = trim($match2[1]); $m_start = $this_year.$this_month.'01'; $u_start = strtotime($m_start); $i=0; $seen_events = array(); $middle = ''; do { if (isset($master_array[$m_start])) { foreach ($master_array[$m_start] as $cal_time => $event_times) { # $switch['CAL'] = $cal; # $switch['START_DATE'] = localizeDate ($dateFormat_week_list, $u_start); $start_date = localizeDate ($dateFormat_week_list, $u_start); foreach ($event_times as $uid => $val) { if (isset($seen_events[$uid]) && $val['spans_day'] == 1) continue; $seen_events[$uid] = 1; $switch['CAL'] = $cal; $switch['START_DATE'] = $start_date; $switch['CALNAME'] = $val['calname']; if (!isset($val['event_start'])) { $switch['START_TIME'] = $lang['l_all_day']; $switch['EVENT_TEXT'] = openevent($m_start, $cal_time, $uid, $val, @$month_event_lines, 15, 'psf'); $switch['DESCRIPTION'] = urldecode($val['description']); } else { $event_start = $val['start_unixtime']; $event_end = (isset($val['display_end'])) ? $val['display_end'] : $val["event_end"]; $event_start = date($timeFormat, $val['start_unixtime']); $event_end = date($timeFormat, @strtotime ($event_end)); $switch['START_TIME'] = $event_start . ' - ' . $event_end; $switch['EVENT_TEXT'] = openevent($m_start, $cal_time, $uid, $val, 0, 15, 'psf'); $switch['DESCRIPTION'] = urldecode($val['description']); } if ($switch['EVENT_TEXT'] != '') { $switch['DAYLINK'] = $m_start; $temp = $loop[$i]; foreach ($switch as $tag => $data) { $temp = str_replace('{'.$tag.'}', $data, $temp); } $middle .= $temp; $i = ($i == 1) ? 0 : 1; } unset ($switch); } } } $u_start = strtotime("+1 day", $u_start); $m_start = date('Ymd', $u_start); $check_month = date('m', $u_start); # unset ($switch); } while ($this_month == $check_month); $this->page = preg_replace('!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_even off -->!is', $middle, $this->page); } function Page($file = 'std.tpl') { global $phpiCal_config; if (!file_exists($file)){ #look for it in default if not found $file = str_replace("templates/$phpiCal_config->template","templates/default",$file); if (!file_exists($file)) die("Template file $file not found."); } $this->page = join('', file($file)); } function parse($file) { global $phpiCal_config; $lang; if (basename(dirname($file)) == "$phpiCal_config->template" || $file =='./functions/event.js'){ if (!is_file($file)){ #look for it in default if not found $file = str_replace("templates/$phpiCal_config->template","templates/default",$file); } if (!is_file($file)){ exit(error($lang['l_error_path'], $file)); } ob_start(); include($file); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; } } function replace_tags($tags = array()) { if (sizeof($tags) > 0) foreach ($tags as $tag => $data) { // This removes any unfilled tags if (!$data) { $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!is', '', $this->page); } // This replaces any tags $this->page = str_replace('{' . strtoupper($tag) . '}', $data, $this->page); } else die('No tags designated for replacement.'); } function replace_files($tags = array()) { if (sizeof($tags) > 0) foreach ($tags as $tag => $data) { // This opens up another template and parses it as well. $data = $this->parse($data); // This removes any unfilled tags if (!$data) { $this->page = preg_replace('!<\!-- switch ' . $tag . ' on -->(.*)<\!-- switch ' . $tag . ' off -->!is', '', $this->page); } // This replaces any tags $this->page = str_replace('{' . strtoupper($tag) . '}', $data, $this->page); } else die('No tags designated for replacement.'); } function output() { global $phpiCal_config, $php_started, $lang, $template_started, $cpath; // Looks for {MONTH} before sending page out preg_match_all ('!\{MONTH_([A-Z]*)\|?([+|-])([0-9]{1,2})\}!is', $this->page, $match); if (sizeof($match) > 0) { $i=0; foreach ($match[1] as $key => $val) { if ($match[1][$i] == 'SMALL') { $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_small.tpl'); $type = 'small'; $offset = $match[2][$i].$match[3][$i]; } elseif ($match[1][$i] == 'MEDIUM') { $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_medium.tpl'); $type = 'medium'; $offset = $match[3][$i]; } else { $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_large.tpl'); $type = 'large'; $offset = $match[2][$i].$match[3][$i]; } $data = $this->draw_month($phpiCal_config->template_file, $offset, $type); $this->page = str_replace($match[0][$i], $data, $this->page); $i++; } } $php_ended = @getmicrotime(); $generated1 = number_format(($php_ended-$php_started),3); $generated2 = number_format(($php_ended-$phpiCal_config->template_started),3); $this->page = str_replace('{GENERATED1}', $generated1, $this->page); $this->page = str_replace('{GENERATED2}', $generated2, $this->page); if ($phpiCal_config->enable_rss != 'yes') { $this->page = preg_replace('!<\!-- switch rss_powered on -->(.*)<\!-- switch rss_powered off -->!is', '', $this->page); } else { $this->page = str_replace('{BASE}', BASE, $this->page); } if ($cpath){ $this->page = str_replace('&getdate', "&cpath=$cpath&getdate", $this->page); } print($this->page); } } ?>