[ Index ] |
PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2010 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 // ---------------------------------------------------------------- 24 // obligate check for phpwcms constants 25 if (!defined('PHPWCMS_ROOT')) { 26 die("You Cannot Access This Script Directly, Have a Nice Day."); 27 } 28 // ---------------------------------------------------------------- 29 30 // include calendar functions 31 include_once($phpwcms['modules'][$module]['path'].'inc/functions.inc.php'); 32 33 // OK lets switch language :) 34 // set correct locale 35 if(!empty($BLM['locale_string'])) { 36 $_oldLocale = setlocale(LC_TIME, NULL); //save current locale 37 setlocale(LC_TIME, $BLM['locale_string']); 38 } 39 40 $_entry['query'] = ''; 41 42 // define some defaults 43 if(isset($_GET['calendardate'])) { 44 45 $_SESSION['calendardate'] = substr(clean_slweg($_GET['calendardate']), 0, 7); 46 47 } 48 if(!empty($_SESSION['calendardate'])) { 49 50 @list($plugin['current_month'], $plugin['current_year']) = explode('-', $_SESSION['calendardate']); 51 52 $plugin['current_month'] = intval($plugin['current_month']); 53 $plugin['current_year'] = intval($plugin['current_year']); 54 55 if(empty($plugin['current_year'])) { 56 $plugin['current_year'] = gmdate('Y'); 57 } 58 if(empty($plugin['current_month'])) { 59 $plugin['current_month'] = gmdate('n'); 60 } 61 62 } else { 63 64 $plugin['current_year'] = gmdate('Y'); 65 $plugin['current_month'] = gmdate('n'); 66 67 } 68 69 $plugin['first_of_month'] = gmmktime(0, 0, 0, $plugin['current_month'], 1, $plugin['current_year']); 70 $plugin['days_in_month'] = gmdate('t', $plugin['first_of_month']); 71 $plugin['week_start'] = date('W', $plugin['first_of_month']); 72 $plugin['first_day'] = 0; 73 $plugin['weekday'] = (gmstrftime('%w', $plugin['first_of_month']) + 7 - $plugin['first_day']) % 7; //adjust for $first_day 74 $plugin['this_date'] = html_entities(ucfirst(gmstrftime('%B %Y', $plugin['first_of_month']))); 75 76 $plugin['location'] = decode_entities(MODULE_HREF); 77 $plugin['loc_this_month'] = $plugin['location'].'&calendardate='.date('m-Y'); 78 79 $plugin['loc_next_month'] = $plugin['location'].'&calendardate='; 80 if($plugin['current_month'] == 12) { 81 $plugin['loc_next_month'] .= '1-'.($plugin['current_year']+1); 82 } else { 83 $plugin['loc_next_month'] .= ($plugin['current_month']+1).'-'.$plugin['current_year']; 84 } 85 $plugin['loc_prev_month'] = $plugin['location'].'&calendardate='; 86 if($plugin['current_month'] == 1) { 87 $plugin['loc_prev_month'] .= '12-'.($plugin['current_year']-1); 88 } else { 89 $plugin['loc_prev_month'] .= ($plugin['current_month']-1).'-'.$plugin['current_year']; 90 } 91 $plugin['week_add'] = intval(gmstrftime('%W', gmmktime(0, 0, 0, 1, 1, $plugin['current_year']))) ? 0 : 1; 92 93 // paginate and search form processing 94 if(isset($_POST['do_pagination'])) { 95 96 $_SESSION['list_active'] = empty($_POST['showactive']) ? 0 : 1; 97 $_SESSION['list_inactive'] = empty($_POST['showinactive']) ? 0 : 1; 98 99 $_SESSION['filter'] = clean_slweg($_POST['filter']); 100 if(empty($_SESSION['filter'])) { 101 unset($_SESSION['filter']); 102 } else { 103 $_SESSION['filter'] = convertStringToArray($_SESSION['filter'], ' '); 104 $_POST['filter'] = $_SESSION['filter']; 105 } 106 107 } 108 109 110 $_entry['list_active'] = isset($_SESSION['list_active']) ? $_SESSION['list_active'] : 1; 111 $_entry['list_inactive'] = isset($_SESSION['list_inactive']) ? $_SESSION['list_inactive'] : 1; 112 113 114 // set correct status query 115 if($_entry['list_active'] != $_entry['list_inactive']) { 116 117 if(!$_entry['list_active']) { 118 $_entry['query'] .= 'calendar_status=0'; 119 } 120 if(!$_entry['list_inactive']) { 121 $_entry['query'] .= 'calendar_status=1'; 122 } 123 124 } else { 125 $_entry['query'] .= 'calendar_status!=9'; 126 } 127 128 if(isset($_SESSION['filter']) && is_array($_SESSION['filter']) && count($_SESSION['filter'])) { 129 130 $_entry['filter_array'] = array(); 131 132 foreach($_SESSION['filter'] as $_entry['filter']) { 133 //usr_name, usr_login, usr_email 134 $_entry['filter_array'][] = "CONCAT(calendar_title, calendar_tag, calendar_text) LIKE '%".aporeplace($_entry['filter'])."%'"; 135 } 136 if(count($_entry['filter_array'])) { 137 138 $_SESSION['filter'] = ' AND ('.implode(' OR ', $_entry['filter_array']).')'; 139 $_entry['query'] .= $_SESSION['filter']; 140 141 } 142 143 } elseif(isset($_SESSION['filter']) && is_string($_SESSION['filter'])) { 144 145 $_entry['query'] .= $_SESSION['filter']; 146 147 } 148 149 150 151 ?> 152 <h1 class="title" style="margin-bottom:10px"><?php echo $BLM['listing_title'] ?></h1> 153 154 <!-- <form action="<?php echo MODULE_HREF ?>" method="post" name="paginate" id="paginate"><input type="hidden" name="do_pagination" value="1" /> --> 155 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="paginate" summary=""> 156 <tr> 157 <td><table border="0" cellpadding="0" cellspacing="0" summary=""> 158 <tr> 159 160 <!-- 161 <td><input type="checkbox" name="showactive" id="showactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_active'], 1) ?> /></td> 162 <td><label for="showactive"><img src="img/button/aktiv_12x13_1.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td> 163 <td><input type="checkbox" name="showinactive" id="showinactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_inactive'], 1) ?> /></td> 164 <td><label for="showinactive"><img src="img/button/aktiv_12x13_0.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td> 165 166 <td class="chatlist">| </td> 167 168 <td><input type="text" name="filter" id="filter" size="10" value="<?php 169 170 if(isset($_POST['filter']) && is_array($_POST['filter']) ) { 171 echo html_specialchars(implode(' ', $_POST['filter'])); 172 } 173 174 ?>" class="textinput" style="margin:0 2px 0 0;width:110px;text-align:left;" title="filter results by username, name or email" /></td> 175 <td><input type="image" name="gofilter" src="img/famfamfam/action_go.gif" style="margin-right:3px;" /></td> 176 177 <td class="chatlist">| </td> 178 // --> 179 <td class="calendarButton"><button onclick="location.href='<?php echo $plugin['loc_prev_month'] ?>';return false;"><</button></td> 180 <td class="calendarButton"><button onclick="location.href='<?php echo $plugin['loc_this_month'] ?>';return false;"><?php echo $BLM['today'] ?></button></td> 181 <td class="calendarButton"><button onclick="location.href='<?php echo $plugin['loc_next_month'] ?>';return false;">></button></td> 182 183 </tr> 184 </table></td> 185 186 <td class="chatlist" align="right"> 187 188 </td> 189 190 </tr> 191 </table> 192 <!-- </form> --> 193 194 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="calendar" summary=""> 195 196 <?php 197 198 // list current calendar here 199 200 if($plugin['current_month'] == 12) { 201 $plugin['end_month'] = 1; 202 $plugin['end_year'] = $plugin['current_year'] + 1; 203 } else { 204 $plugin['end_month'] = $plugin['current_month'] + 1; 205 $plugin['end_year'] = $plugin['current_year']; 206 } 207 208 209 $sql = 'SELECT *, '; 210 $sql .= "DATE_FORMAT(calendar_start, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_start_date, "; 211 $sql .= "DATE_FORMAT(calendar_end, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_end_date, "; 212 $sql .= "DATE_FORMAT(calendar_start, '%H:%i') AS calendar_start_time, "; 213 $sql .= "DATE_FORMAT(calendar_end, '%H:%i') AS calendar_end_time, "; 214 $sql .= "DATE_FORMAT(calendar_start, '%e') AS calendar_day "; 215 $sql .= ' FROM '.DB_PREPEND.'phpwcms_calendar WHERE '; 216 $sql .= 'calendar_status != 9 AND '; 217 $sql .= 'calendar_range = 0 AND '; 218 $sql .= "calendar_start >= '".aporeplace($plugin['current_year'].'-'.$plugin['current_month'].'-1 00:00:00')."' AND "; 219 $sql .= "calendar_start < '".aporeplace($plugin['end_year'].'-'.$plugin['end_month'].'-1 00:00:00')."' ORDER BY calendar_start ASC"; 220 $plugin['dates'] = _dbQuery($sql); 221 222 // run through dates and put in right day, fist for all non-repeating dates 223 $_entry['dates'] = array(); 224 foreach($plugin['dates'] as $_entry['x']) { 225 226 $_entry['day'] = intval($_entry['x']['calendar_day']); 227 $_entry['dates'][ $_entry['day'] ][] = $_entry['x']; 228 229 } 230 231 $sql = 'SELECT *, '; 232 $sql .= "DATE_FORMAT(calendar_start, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_start_date, "; 233 $sql .= "DATE_FORMAT(calendar_end, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_end_date, "; 234 $sql .= "DATE_FORMAT(calendar_range_start, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_rangestart, "; 235 $sql .= "DATE_FORMAT(calendar_range_end, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_rangeend, "; 236 $sql .= "DATE_FORMAT(calendar_start, '%H:%i') AS calendar_start_time, "; 237 $sql .= "DATE_FORMAT(calendar_end, '%H:%i') AS calendar_end_time, "; 238 $sql .= "DATE_FORMAT(calendar_start, '%e') AS calendar_day "; 239 $sql .= ' FROM '.DB_PREPEND.'phpwcms_calendar WHERE '; 240 $sql .= 'calendar_status != 9 AND '; 241 $sql .= 'calendar_range > 0 AND '; 242 $sql .= "calendar_range_start < '".aporeplace($plugin['end_year'].'-'.$plugin['end_month'].'-01 00:00:00')."' AND "; 243 $sql .= "calendar_range_end > '".aporeplace($plugin['current_year'].'-'.$plugin['current_month'].'-1 00:00:00')."' "; 244 $sql .= 'ORDER BY calendar_range_start ASC'; 245 $plugin['dates'] = _dbQuery($sql); 246 247 // run through dates and put in right day, fist for all non-repeating dates 248 249 foreach($plugin['dates'] as $_entry['y']) { 250 251 $_entry['day'] = intval($_entry['y']['calendar_day']); 252 $_entry['range_start_timestamp'] = strtotime($_entry['y']['calendar_range_start'].' 00:00:00'); 253 $_entry['range_end_timestamp'] = strtotime($_entry['y']['calendar_range_end'].' 23:59:59'); 254 $_entry['this_timestamp'] = strtotime($_entry['y']['calendar_start']); 255 $_entry['date_weekday'] = date('w', $_entry['this_timestamp']); 256 $_entry['day_month'] = date('j', $_entry['this_timestamp']); 257 $_entry['day_year'] = date('dm', $_entry['this_timestamp']); 258 259 for($_entry['x'] = 1, $_entry['timestamp']=$plugin['first_of_month']; $_entry['x'] <= $plugin['days_in_month']; $_entry['x']++, $_entry['timestamp']+=86400) { 260 261 if($_entry['timestamp'] >= $_entry['range_start_timestamp'] && $_entry['timestamp'] <= $_entry['range_end_timestamp']) { 262 263 $_entry['weekday'] = date('w', $_entry['timestamp']); 264 // 1 daily 265 // 2 Every weekday (Mon-Fri) 266 // 3 Every Mon., Wed. and Fri. 267 // 4 Every Tues. and Thurs. 268 // 5 Weekly 269 // 6 Monthly 270 // 7 yearly 271 272 if( $_entry['y']['calendar_range'] == 1 273 || 274 ($_entry['y']['calendar_range'] == 2 && $_entry['weekday'] != 6 && $_entry['weekday'] != 0) 275 || 276 ($_entry['y']['calendar_range'] == 3 && ($_entry['weekday'] == 1 || $_entry['weekday'] == 3 || $_entry['weekday'] == 5)) 277 || 278 ($_entry['y']['calendar_range'] == 4 && ($_entry['weekday'] == 2 || $_entry['weekday'] == 4)) 279 || 280 ($_entry['y']['calendar_range'] == 5 && $_entry['weekday'] == $_entry['date_weekday']) 281 || 282 ($_entry['y']['calendar_range'] == 6 && $_entry['x'] == $_entry['day_month']) 283 || 284 ($_entry['y']['calendar_range'] == 7 && date('dm', $_entry['timestamp']) == $_entry['day_year']) ) 285 { 286 287 $_entry['y']['calendar_start_date'] = date('d'.$BLM['date_delimiter'].'m'.$BLM['date_delimiter'].'Y', $_entry['timestamp']); 288 $_entry['y']['calendar_end_date'] = $_entry['y']['calendar_start_date']; 289 $_entry['dates'][ $_entry['x'] ][] = $_entry['y']; 290 291 } 292 293 294 } 295 296 } 297 298 299 } 300 301 302 303 304 $plugin['day_names'] = returnDayNameArray(); 305 306 // head row 307 308 echo '<tr>'.LF; 309 echo ' <th class="calendarWeek">'.$BLM['weekNrTitle'].'</th>'.LF; 310 echo ' <th><img src="img/famfamfam/calendar_view_month.gif" alt="" /></th>'.LF; 311 echo ' <th width="95%" class="calendarMonth">'; 312 313 echo $plugin['this_date']; 314 315 echo '</th>'.LF; 316 echo ' <th> </th>'.LF; 317 echo '</tr>'.LF; 318 319 $_entry['rowspan'] = gmstrftime('%w', $plugin['first_of_month']); 320 $_entry['rowspan'] = 8 - ($_entry['rowspan']==0 ? 7 : $_entry['rowspan']); 321 $_entry['c'] = 0; 322 323 for($_entry['x'] = 1, $_entry['timestamp']=$plugin['first_of_month']; $_entry['x'] <= $plugin['days_in_month']; $_entry['x']++, $_entry['timestamp']+=86400) { 324 325 $_entry['day_num'] = gmstrftime('%w', $_entry['timestamp']); 326 $_entry['day_num'] = $_entry['day_num']==0 ? 7 : $_entry['day_num']; 327 328 echo '<tr'; 329 if($_entry['x'] % 2) { 330 echo ' class="calendarAltRow"'; 331 } 332 echo '>'.LF; 333 334 if($_entry['day_num'] == 1) { 335 336 if($plugin['days_in_month'] - $_entry['x'] < 7) { 337 $_entry['rowspan'] = $plugin['days_in_month'] - $_entry['x'] + 1; 338 } else { 339 $_entry['rowspan'] = 7; 340 } 341 342 } 343 344 345 346 if($_entry['rowspan']) { 347 348 echo ' <td '; 349 echo ($_entry['rowspan'] > 1) ? 'rowspan="'.$_entry['rowspan'].'" ' : ''; 350 echo 'class="calendarWeek'; 351 echo ($_entry['c'] % 2) ? '' : ' calendarWeekAlt'; 352 echo '">'; 353 354 $_entry['wno'] = gmstrftime('%W', $_entry['timestamp']) + $plugin['week_add']; 355 if($_entry['wno'] == 53) { 356 $_entry['wno'] = 1; 357 } 358 359 echo $_entry['wno']; 360 echo '</td>'.LF; 361 362 $_entry['rowspan'] = 0; 363 $_entry['c']++; 364 365 } 366 367 $_entry['class'] = ($_entry['day_num'] == 7 || $_entry['x'] == $plugin['days_in_month']) ? ' calendarSunday' : ''; 368 369 echo ' <td class="calendarDay'.$_entry['class'].'"><span>'.$_entry['x'].'</span><br />'.html_specialchars(gmstrftime('%a', $_entry['timestamp'])).'</td>'.LF; 370 echo ' <td class="calendarData'.$_entry['class'].'">'; 371 372 // run available dates for current day 373 if(isset($_entry['dates'][ $_entry['x'] ])) { 374 375 foreach($_entry['dates'][ $_entry['x'] ] as $_entry['date']) { 376 377 $_entry['link '] = $_entry['date']['calendar_title'].' ('; 378 if($_entry['date']['calendar_allday']) { 379 $_entry['link '] .= $BLM['all_day']; 380 } else { 381 $_entry['link '] .= $_entry['date']['calendar_start_time'].'–'; 382 if($_entry['date']['calendar_start_date'] != $_entry['date']['calendar_end_date']) { 383 $_entry['link '] .= $_entry['date']['calendar_end_date'].', '; 384 } 385 $_entry['link '] .= $_entry['date']['calendar_end_time']; 386 } 387 $_entry['link '] .= ')'; 388 389 if($_entry['date']['calendar_range']) { 390 $_entry['link '] = $BLM['repeat_list'.$_entry['date']['calendar_range']].': '.$_entry['link ']; 391 } 392 $_entry['link '] = html_specialchars($_entry['link ']); 393 394 echo '<p><a href="'.MODULE_HREF.'&edit='.$_entry['date']['calendar_id'].'"'; 395 if($_entry['date']['calendar_status'] == 0) echo ' class="off"'; 396 echo '>' . $_entry['link '] . '</a>'; 397 398 echo '<a href="'.MODULE_HREF.'&delete='.$_entry['date']['calendar_id'].'" class="calendarDateDel"'; 399 echo ' title="'.$BLM['delete'].': '. $_entry['link '] .'"'; 400 echo ' onclick="return confirm(\''.$BLM['delete_entry'].' \n'.js_singlequote($_entry['date']['calendar_title']).'\');">'; 401 echo '<img src="img/button/del_9x9.gif" alt="" border="0" /></a>'; 402 403 /* 404 echo '<img src="img/button/'; 405 if($_entry['date']['calendar_status'] == 0) echo 'in'; 406 echo 'aktiv_mini1.gif" alt="" border="0" />'; 407 */ 408 409 echo '</p>'; 410 411 } 412 413 } else { 414 415 echo ' '; 416 417 } 418 419 echo '</td>'.LF; 420 421 echo ' <td class="calendarButton'.$_entry['class'].'">'; 422 echo '<a href="'.MODULE_HREF.'&edit=0&defaultdate='; 423 echo $_entry['x'].'-'.$plugin['current_month'].'-'.$plugin['current_year'].'" title="'.$BLM['add_event'].'">'; 424 echo '<img src="img/famfamfam/calendar_add.gif" alt="" border="0" />'; 425 echo '</a></td>'.LF; 426 427 echo '</tr>'.LF; 428 429 } 430 431 // switch language back 432 if(!empty($BLM['locale_string'])) { 433 setlocale(LC_TIME, $_oldLocale); //switch current locale back to old value 434 } 435 436 437 ?> 438 439 </table>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Nov 16 22:51:00 2010 | Cross-referenced by PHPXref 0.7 |