From 337adc1bbfc79a8d29eda49e13d98e8940b521df Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 17 Apr 2011 12:44:36 +0200 Subject: [PATCH] Made calendar block independent of other calendar block --- root/portal/modules/portal_calendar.php | 75 +++++++++++-------- .../portal/modules/calendar_side.html | 70 +++++++++-------- .../portal/modules/calendar_side.html | 64 ++++++++-------- 3 files changed, 117 insertions(+), 92 deletions(-) diff --git a/root/portal/modules/portal_calendar.php b/root/portal/modules/portal_calendar.php index bed41adf..d0b0487f 100644 --- a/root/portal/modules/portal_calendar.php +++ b/root/portal/modules/portal_calendar.php @@ -52,6 +52,11 @@ class portal_calendar_module * file must be in "adm/style/portal/" */ var $custom_acp_tpl = 'acp_portal_calendar'; + + /** + * additional variables + */ + var $mini_cal_fdow; function get_template_side($module_id) { @@ -62,18 +67,18 @@ class portal_calendar_module // 0 = Sunday first - 1 = Monday first. ;-) if ($config['board3_sunday_first_' . $module_id]) { - define('MINI_CAL_FDOW', 0); + $this->mini_cal_fdow = 0; } else { - define('MINI_CAL_FDOW', 1); + $this->mini_cal_fdow = 1; } // get the calendar month $mini_cal_month = 0; - if(isset($_GET['m']) || isset($_POST['m'])) + if(isset($_GET['m' . $module_id]) || isset($_POST['m' . $module_id])) { - $mini_cal_month = request_var('m', 0); + $mini_cal_month = request_var('m' . $module_id, 0); } // initialise some variables @@ -81,19 +86,43 @@ class portal_calendar_module $mini_cal_today = date('Ymd', time() + $user->timezone + $user->dst - date('Z')); $s_cal_month = ($mini_cal_month != 0) ? $mini_cal_month . ' month' : $mini_cal_today; $this->getMonth($s_cal_month); - $mini_cal_count = MINI_CAL_FDOW; + $mini_cal_count = $this->mini_cal_fdow; $mini_cal_this_year = $this->dateYYYY; $mini_cal_this_month = $this->dateMM; $mini_cal_this_day = $this->dateDD; $mini_cal_month_days = $this->daysMonth; + + // output our general calendar bits + $down = $mini_cal_month - 1; + $up = $mini_cal_month + 1; + $prev_month = '<<'; + $next_month = '>>'; + + $template->assign_block_vars('minical', array( + 'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false, + 'L_MINI_CAL_MONTH' => (($config['board3_long_month_' . $module_id]) ? $user->lang['mini_cal']['long_month'][$this->day[0][1]] : $user->lang['mini_cal']['month'][$this->day[0][1]]) . " " . $this->day[0][2], + 'L_MINI_CAL_SUN' => '' . $user->lang['mini_cal']['day'][1] . '', + 'L_MINI_CAL_MON' => $user->lang['mini_cal']['day'][2], + 'L_MINI_CAL_TUE' => $user->lang['mini_cal']['day'][3], + 'L_MINI_CAL_WED' => $user->lang['mini_cal']['day'][4], + 'L_MINI_CAL_THU' => $user->lang['mini_cal']['day'][5], + 'L_MINI_CAL_FRI' => $user->lang['mini_cal']['day'][6], + 'L_MINI_CAL_SAT' => $user->lang['mini_cal']['day'][7], + 'U_PREV_MONTH' => $prev_month, + 'U_NEXT_MONTH' => $next_month, + 'S_DISPLAY_EVENTS' => ($config['board3_display_events_' . $module_id]) ? true : false, + 'MODULE_ID' => $module_id, + )); // output the days for the current month for($i=0; $i < $mini_cal_month_days;) { // is this the first day of the week? - if($mini_cal_count == MINI_CAL_FDOW) + if($mini_cal_count == $this->mini_cal_fdow) { - $template->assign_block_vars('mini_cal_row', array()); + $template->assign_block_vars('minical.mini_cal_row', array( + 'MODULE_ID' => $module_id, + )); } // is this a valid weekday? @@ -104,7 +133,7 @@ class portal_calendar_module $d_mini_cal_today = $mini_cal_this_year . (($mini_cal_this_month <= 9) ? '0' . $mini_cal_this_month : $mini_cal_this_month) . (($mini_cal_this_day <= 9) ? '0' . $mini_cal_this_day : $mini_cal_this_day); $mini_cal_day = ($mini_cal_today == $d_mini_cal_today) ? '' . $mini_cal_this_day . '' : $mini_cal_this_day; - $template->assign_block_vars('mini_cal_row.mini_cal_days', array( + $template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array( 'MINI_CAL_DAY' => ($mini_cal_count == 0) ? '' . $mini_cal_day . '' : $mini_cal_day) ); $i++; @@ -112,7 +141,7 @@ class portal_calendar_module // no day else { - $template->assign_block_vars('mini_cal_row.mini_cal_days', array( + $template->assign_block_vars('minical.mini_cal_row.mini_cal_days', array( 'MINI_CAL_DAY' => ' ') ); } @@ -130,27 +159,6 @@ class portal_calendar_module } } - // output our general calendar bits - $down = $mini_cal_month - 1; - $up = $mini_cal_month + 1; - $prev_month = '<<'; - $next_month = '>>'; - - $template->assign_vars(array( - 'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false, - 'L_MINI_CAL_MONTH' => (($config['board3_long_month_' . $module_id]) ? $user->lang['mini_cal']['long_month'][$this->day[0][1]] : $user->lang['mini_cal']['month'][$this->day[0][1]]) . " " . $this->day[0][2], - 'L_MINI_CAL_SUN' => '' . $user->lang['mini_cal']['day'][1] . '', - 'L_MINI_CAL_MON' => $user->lang['mini_cal']['day'][2], - 'L_MINI_CAL_TUE' => $user->lang['mini_cal']['day'][3], - 'L_MINI_CAL_WED' => $user->lang['mini_cal']['day'][4], - 'L_MINI_CAL_THU' => $user->lang['mini_cal']['day'][5], - 'L_MINI_CAL_FRI' => $user->lang['mini_cal']['day'][6], - 'L_MINI_CAL_SAT' => $user->lang['mini_cal']['day'][7], - 'U_PREV_MONTH' => $prev_month, - 'U_NEXT_MONTH' => $next_month, - 'S_DISPLAY_EVENTS' => ($config['board3_display_events_' . $module_id]) ? true : false, - )); - /* * Let's start displaying the events * make sure we only display events in the future @@ -173,24 +181,26 @@ class portal_calendar_module // current events if((($cur_event['start_time'] + 86400) >= $today_timestamp && $cur_event['all_day']) || ($cur_event['start_time'] <= $today_timestamp && $cur_event['end_time'] >= $today_timestamp)) { - $template->assign_block_vars('cur_events', array( + $template->assign_block_vars('minical.cur_events', array( 'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '', 'EVENT_TITLE' => $cur_event['title'], 'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'), 'END_TIME' => (!empty($cur_event['end_time'])) ? $user->format_date($cur_event['end_time'], 'j. M Y, H:i') : false, 'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '', 'ALL_DAY' => ($cur_event['all_day']) ? true : false, + 'MODULE_ID' => $module_id, )); } else { - $template->assign_block_vars('upcoming_events', array( + $template->assign_block_vars('minical.upcoming_events', array( 'EVENT_URL' => (isset($cur_event['url']) && $cur_event['url'] != '') ? $this->validate_url($cur_event['url']) : '', 'EVENT_TITLE' => $cur_event['title'], 'START_TIME' => $user->format_date($cur_event['start_time'], 'j. M Y, H:i'), 'END_TIME' => $user->format_date($cur_event['end_time'], 'j. M Y, H:i'), 'EVENT_DESC' => (isset($cur_event['desc']) && $cur_event['desc'] != '') ? $cur_event['desc'] : '', 'ALL_DAY' => (($cur_event['start_time'] - $cur_event['end_time']) == 1) ? true : false, + 'MODULE_ID' => $module_id, )); } } @@ -570,6 +580,7 @@ class portal_calendar_module $url = str_replace("\r\n", "\n", str_replace('\"', '"', trim($url))); $url = str_replace(' ', '%20', $url); + $url = str_replace('&', '&', $url); // if there is no scheme, then add http schema if (!preg_match('#^[a-z][a-z\d+\-.]*:/{2}#i', $url)) diff --git a/root/styles/prosilver/template/portal/modules/calendar_side.html b/root/styles/prosilver/template/portal/modules/calendar_side.html index b80794ed..7ceb41be 100644 --- a/root/styles/prosilver/template/portal/modules/calendar_side.html +++ b/root/styles/prosilver/template/portal/modules/calendar_side.html @@ -1,52 +1,58 @@ - + + + {$LR_BLOCK_H_L} {$TITLE}{$LR_BLOCK_H_R} - - - + + + - - + + - - - - - - - - + + + + + + + + + - + +
{U_PREV_MONTH}{L_MINI_CAL_MONTH}{U_NEXT_MONTH}{minical.U_PREV_MONTH}{minical.L_MINI_CAL_MONTH}{minical.U_NEXT_MONTH}
{L_MINI_CAL_SUN}{minical.L_MINI_CAL_SUN} {L_MINI_CAL_MON}{L_MINI_CAL_TUE}{L_MINI_CAL_WED}{L_MINI_CAL_THU}{L_MINI_CAL_FRI}{L_MINI_CAL_SAT}{L_MINI_CAL_SUN}{minical.L_MINI_CAL_MON}{minical.L_MINI_CAL_TUE}{minical.L_MINI_CAL_WED}{minical.L_MINI_CAL_THU}{minical.L_MINI_CAL_FRI}{minical.L_MINI_CAL_SAT}{minical.L_MINI_CAL_SUN}
{mini_cal_row.mini_cal_days.MINI_CAL_DAY}{minical.mini_cal_row.mini_cal_days.MINI_CAL_DAY}
- +