| [ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/calendar_menu/calendar.php,v $ 14 | $Revision: 1.19 $ 15 | $Date: 2006/11/16 10:24:14 $ 16 | $Author: e107coders $ 17 | 18 | 11.11.06 - steved - mods for next CVS release 19 | 20 +----------------------------------------------------------------------------+ 21 */ 22 23 24 require_once ("../../class2.php"); 25 require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php"); 26 if (isset($_POST['viewallevents'])) 27 { 28 Header("Location: " . e_PLUGIN . "calendar_menu/event.php?" . $_POST['enter_new_val']); 29 } 30 if (isset($_POST['doit'])) 31 { 32 Header("Location: " . e_PLUGIN . "calendar_menu/event.php?ne." . $_POST['enter_new_val']); 33 } 34 if (isset($_POST['subs'])) 35 { 36 Header("Location: " . e_PLUGIN . "calendar_menu/subscribe.php"); 37 } 38 39 @include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php"); 40 define("PAGE_NAME", EC_LAN_121); 41 42 require_once ('ecal_class.php'); 43 $ecal_class = new ecal_class; 44 45 if (is_readable(THEME."calendar_template.php")) 46 { 47 require (THEME."calendar_template.php"); 48 } 49 else 50 { 51 require(e_PLUGIN."calendar_menu/calendar_template.php"); 52 } 53 54 $num = (isset($_POST['num']) && $_POST['num'] ? $_POST['num'] : ""); 55 56 57 $category_filter = ""; 58 if ((isset($_POST['event_cat_ids']) && $_POST['event_cat_ids'] != "all")) 59 { 60 $category_filter = " AND (e.event_category = '".$_POST['event_cat_ids']."') "; 61 } 62 63 64 require_once(HEADERF); 65 66 // get current date information --------------------------------------------------------------------- 67 $qs = explode(".", e_QUERY); 68 if($qs[0] == "") 69 { // Show current month 70 $datearray = $ecal_class->cal_date; 71 } 72 else 73 { // Get date from query 74 $datearray = getdate($qs[0]); 75 } 76 $month = $datearray['mon']; 77 $year = $datearray['year']; 78 79 80 // set up arrays for calender display ------------------------------------------------------------------ 81 if($pref['eventpost_weekstart'] == 'sun') { 82 $week = Array(EC_LAN_25, EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24); 83 } else { 84 $week = Array(EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24, EC_LAN_25); 85 } 86 $months = Array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11); 87 $monthabb = Array(EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN, EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC); 88 89 $days = array(EC_LAN_DAY_1, EC_LAN_DAY_2, EC_LAN_DAY_3, EC_LAN_DAY_4, EC_LAN_DAY_5, EC_LAN_DAY_6, EC_LAN_DAY_7, EC_LAN_DAY_8, EC_LAN_DAY_9, EC_LAN_DAY_10, EC_LAN_DAY_11, EC_LAN_DAY_12, EC_LAN_DAY_13, EC_LAN_DAY_14, EC_LAN_DAY_15, EC_LAN_DAY_16, EC_LAN_DAY_17, EC_LAN_DAY_18, EC_LAN_DAY_19, EC_LAN_DAY_20, EC_LAN_DAY_21, EC_LAN_DAY_22, EC_LAN_DAY_23, EC_LAN_DAY_24, EC_LAN_DAY_25, EC_LAN_DAY_26, EC_LAN_DAY_27, EC_LAN_DAY_28, EC_LAN_DAY_29, EC_LAN_DAY_30, EC_LAN_DAY_31); 90 91 // show events------------------------------------------------------------------------------------------- 92 $monthstart = mktime(0, 0, 0, $month, 1, $year); // Start of month to be shown 93 $firstdayarray = getdate($monthstart); 94 $monthend = mktime(0, 0, 0, $month + 1, 1, $year) - 1; // End of month to be shown 95 96 $prevmonth = ($month-1); 97 $prevyear = $year; 98 if ($prevmonth == 0) 99 { 100 $prevmonth = 12; 101 $prevyear = ($year-1); 102 } 103 $previous = mktime(0, 0, 0, $prevmonth, 1, $prevyear); // Used by nav 104 105 $nextmonth = ($month + 1); 106 $nextyear = $year; 107 if ($nextmonth == 13) 108 { 109 $nextmonth = 1; 110 $nextyear = ($year + 1); 111 } 112 $next = mktime(0, 0, 0, $nextmonth, 1, $nextyear); 113 $py = $year-1; 114 $prevlink = mktime(0, 0, 0, $month, 1, $py); 115 $ny = $year + 1; 116 $nextlink = mktime(0, 0, 0, $month, 1, $ny); 117 118 $prop = mktime(0, 0, 0, $month, 1, $year); // Sets start date for new event entry 119 $nowmonth = $ecal_class->cal_date['mon']; 120 $nowyear = $ecal_class->cal_date['year']; 121 $nowday = $ecal_class->cal_date['mday']; 122 123 // time switch buttons 124 $cal_text = $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes); 125 126 // navigation buttons 127 $nav_text = $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shortcodes); 128 129 // get events from selected 130 $qry = "SELECT e.*, ec.* 131 FROM #event as e 132 LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id 133 WHERE e.event_id != '' 134 AND ((e.event_start >= ".intval($monthstart)." AND e.event_start <= ".intval($monthend).") 135 OR (e.event_end >= ".intval($monthstart)." AND e.event_end <= ".intval($monthend).") 136 OR (e.event_start <= ".intval($monthstart)." AND e.event_end >= ".intval($monthend).") 137 OR (e.event_recurring = '1' AND e.event_rec_y = ".intval($month).")) {$category_filter} 138 {$ecal_class->extra_query} 139 ORDER BY e.event_start"; 140 141 if ($sql->db_Select_gen($qry)) 142 { 143 while ($row = $sql->db_Fetch()) 144 { 145 // check for recurring events in this month 146 if($row['event_recurring']=='1') 147 { 148 if ($month == $row['event_rec_y']) 149 { // Change it into an event that happens today 150 $row['event_start'] = mktime(0,0,0,$row['event_rec_y'],$row['event_rec_m'],$year); 151 $row['event_end'] = $row['event_start']; 152 } 153 else 154 { // Effectively create a null event 155 $row['event_start'] = 0; 156 $row['event_end'] = 0; 157 } 158 } 159 160 $evf = getdate($row['event_start']); 161 $tmp = $evf['mday']; // Day of month for start 162 $eve = getdate($row['event_end']); 163 $tmp2 = $eve['mday']; // Day of month for end 164 $tmp3 = date("t", $monthstart); // number of days in this month 165 if ((($ecal_class->max_recent_show != 0) && (time() - $row['event_datestamp']) <= $ecal_class->max_recent_show)) $row['is_recent'] = TRUE; 166 167 //1) start in month, end in month 168 if(($row['event_start']>=$monthstart && $row['event_start']<=$monthend) && $row['event_end']<=$monthend) 169 { 170 $events[$tmp][] = $row; 171 for ($c=($tmp+1); $c<($tmp2+1); $c++) 172 { 173 $row['event_true_end'][$c] = ($c!=$tmp2 ? 1 : 2); 174 $events[$c][] = $row; 175 } 176 177 //2) start in month, end after month 178 } 179 elseif(($row['event_start']>=$monthstart && $row['event_start']<=$monthend) && $row['event_end']>=$monthend) 180 { 181 $events[$tmp][] = $row; 182 for ($c=($tmp+1); $c<=$tmp3; $c++) 183 { 184 $row['event_true_end'][$c] = 1; 185 $events[$c][] = $row; 186 } 187 188 //3) start before month, end in month 189 } 190 elseif($row['event_start']<=$monthstart && ($row['event_end']>=$monthstart && $row['event_end']<=$monthend)) 191 { 192 for ($c=1; $c<=$tmp2; $c++) 193 { 194 $row['event_true_end'][$c] = ($c!=$tmp2 ? 1 : 2); 195 $events[$c][] = $row; 196 } 197 198 //4) start before month, end after month 199 } 200 elseif($row['event_start']<=$monthstart && $row['event_end']>=$monthend) 201 { 202 for ($c=1; $c<=$tmp3; $c++){ 203 $row['event_true_end'][$c] = 1; 204 $events[$c][] = $row; 205 } 206 } 207 } 208 } 209 210 211 // ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference! 212 213 $start = $monthstart; 214 $numberdays = date("t", $start); // number of days in this month 215 216 $text = ""; 217 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_START, FALSE, $calendar_shortcodes); 218 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER_START, FALSE, $calendar_shortcodes); 219 foreach($week as $day) 220 { 221 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER, FALSE, $calendar_shortcodes); 222 } 223 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_HEADER_END, FALSE, $calendar_shortcodes); 224 225 $calmonth = $datearray['mon']; 226 $calday = $datearray['mday']; 227 $calyear = $datearray['year']; 228 229 if ($pref['eventpost_weekstart'] == 'mon') 230 { 231 $firstdayoffset = ($firstdayarray['wday'] == 0 ? $firstdayarray['wday']+6 : $firstdayarray['wday']-1); 232 } 233 else 234 { 235 $firstdayoffset = $firstdayarray['wday'] ; 236 } 237 for ($c=0; $c<$firstdayoffset; $c++) 238 { 239 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calendar_shortcodes); 240 } 241 $loop = $firstdayoffset; 242 243 for ($c = 1; $c <= $numberdays; $c++) 244 { 245 $dayarray = getdate($start + (($c-1) * 86400)); 246 $stopp = mktime(24, 0, 0, $calmonth, $c, $calyear); 247 $startt = mktime(0, 0, 0, $calmonth, $c, $calyear); 248 // Highlight the current day. 249 if ($dayarray['mon'] == $calmonth) 250 { 251 if ($nowday == $c && $calmonth == $nowmonth && $calyear == $nowyear) 252 { 253 //today 254 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_TODAY, FALSE, $calendar_shortcodes); 255 } 256 elseif(isset($events[$c]) && is_array($events[$c]) && !empty($events[$c]) && count($events[$c]) > 0) 257 { 258 //day has events 259 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_EVENT, FALSE, $calendar_shortcodes); 260 } 261 else 262 { 263 // no events and not today 264 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_EMPTY, FALSE, $calendar_shortcodes); 265 } 266 // if there are events then list them 267 if (array_key_exists($c, $events)) 268 { 269 foreach($events[$c] as $ev) 270 { 271 //if ($event_true_end[$c][$a]){ 272 if(isset($ev['event_true_end']) && $ev['event_true_end']) 273 { 274 //$ev['indicat'] = ($ev['event_true_end']==1 ? "->" : "|"); 275 $ev['indicat'] = ""; 276 $ev['imagesize'] = "4"; 277 $ev['fulltopic'] = FALSE; 278 $ev['startofevent'] = FALSE; 279 } 280 else 281 { 282 $ev['indicat'] = ""; 283 $ev['imagesize'] = "8"; 284 $ev['fulltopic'] = TRUE; 285 $ev['startofevent'] = TRUE; 286 } 287 $text .= $tp -> parseTemplate($CALENDAR_SHOWEVENT, FALSE, $calendar_shortcodes); 288 } 289 } 290 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_END, FALSE, $calendar_shortcodes); 291 } 292 $loop++; 293 if ($loop == 7) 294 { 295 $loop = 0; 296 if($c != $numberdays) 297 { 298 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_WEEKSWITCH, FALSE, $calendar_shortcodes); 299 } 300 } 301 } 302 //remainder cells to end the row properly with empty cells 303 if($loop!=0) 304 { 305 $remainder = 7-$loop; 306 for ($c=0; $c<$remainder; $c++) 307 { 308 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_DAY_NON, FALSE, $calendar_shortcodes); 309 } 310 } 311 $text .= $tp -> parseTemplate($CALENDAR_CALENDAR_END, FALSE, $calendar_shortcodes); 312 313 $caption = EC_LAN_79; // "Calendar View"; 314 $nav = $cal_text . $nav_text . $text; 315 $ns->tablerender($caption, $nav); 316 317 require_once(FOOTERF); 318 319 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |