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