// All rights reserved. This script is part of PHPWCMS. The PHPWCMS web content management system is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html A copy is found in the textfile GPL.txt and important notices to the license from the author is found in LICENSE.txt distributed with these scripts. This script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This copyright notice MUST APPEAR in all copies of the script! *************************************************************************************/ // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- // include calendar functions include_once($phpwcms['modules'][$module]['path'].'inc/functions.inc.php'); // OK lets switch language :) // set correct locale if(!empty($BLM['locale_string'])) { $_oldLocale = setlocale(LC_TIME, NULL); //save current locale setlocale(LC_TIME, $BLM['locale_string']); } $_entry['query'] = ''; // define some defaults if(isset($_GET['calendardate'])) { $_SESSION['calendardate'] = substr(clean_slweg($_GET['calendardate']), 0, 7); } if(!empty($_SESSION['calendardate'])) { @list($plugin['current_month'], $plugin['current_year']) = explode('-', $_SESSION['calendardate']); $plugin['current_month'] = intval($plugin['current_month']); $plugin['current_year'] = intval($plugin['current_year']); if(empty($plugin['current_year'])) { $plugin['current_year'] = gmdate('Y'); } if(empty($plugin['current_month'])) { $plugin['current_month'] = gmdate('n'); } } else { $plugin['current_year'] = gmdate('Y'); $plugin['current_month'] = gmdate('n'); } $plugin['first_of_month'] = gmmktime(0, 0, 0, $plugin['current_month'], 1, $plugin['current_year']); $plugin['days_in_month'] = gmdate('t', $plugin['first_of_month']); $plugin['week_start'] = date('W', $plugin['first_of_month']); $plugin['first_day'] = 0; $plugin['weekday'] = (gmstrftime('%w', $plugin['first_of_month']) + 7 - $plugin['first_day']) % 7; //adjust for $first_day $plugin['this_date'] = html_entities(ucfirst(gmstrftime('%B %Y', $plugin['first_of_month']))); $plugin['location'] = decode_entities(MODULE_HREF); $plugin['loc_this_month'] = $plugin['location'].'&calendardate='.date('m-Y'); $plugin['loc_next_month'] = $plugin['location'].'&calendardate='; if($plugin['current_month'] == 12) { $plugin['loc_next_month'] .= '1-'.($plugin['current_year']+1); } else { $plugin['loc_next_month'] .= ($plugin['current_month']+1).'-'.$plugin['current_year']; } $plugin['loc_prev_month'] = $plugin['location'].'&calendardate='; if($plugin['current_month'] == 1) { $plugin['loc_prev_month'] .= '12-'.($plugin['current_year']-1); } else { $plugin['loc_prev_month'] .= ($plugin['current_month']-1).'-'.$plugin['current_year']; } $plugin['week_add'] = intval(gmstrftime('%W', gmmktime(0, 0, 0, 1, 1, $plugin['current_year']))) ? 0 : 1; // paginate and search form processing if(isset($_POST['do_pagination'])) { $_SESSION['list_active'] = empty($_POST['showactive']) ? 0 : 1; $_SESSION['list_inactive'] = empty($_POST['showinactive']) ? 0 : 1; $_SESSION['filter'] = clean_slweg($_POST['filter']); if(empty($_SESSION['filter'])) { unset($_SESSION['filter']); } else { $_SESSION['filter'] = convertStringToArray($_SESSION['filter'], ' '); $_POST['filter'] = $_SESSION['filter']; } } $_entry['list_active'] = isset($_SESSION['list_active']) ? $_SESSION['list_active'] : 1; $_entry['list_inactive'] = isset($_SESSION['list_inactive']) ? $_SESSION['list_inactive'] : 1; // set correct status query if($_entry['list_active'] != $_entry['list_inactive']) { if(!$_entry['list_active']) { $_entry['query'] .= 'calendar_status=0'; } if(!$_entry['list_inactive']) { $_entry['query'] .= 'calendar_status=1'; } } else { $_entry['query'] .= 'calendar_status!=9'; } if(isset($_SESSION['filter']) && is_array($_SESSION['filter']) && count($_SESSION['filter'])) { $_entry['filter_array'] = array(); foreach($_SESSION['filter'] as $_entry['filter']) { //usr_name, usr_login, usr_email $_entry['filter_array'][] = "CONCAT(calendar_title, calendar_tag, calendar_text) LIKE '%".aporeplace($_entry['filter'])."%'"; } if(count($_entry['filter_array'])) { $_SESSION['filter'] = ' AND ('.implode(' OR ', $_entry['filter_array']).')'; $_entry['query'] .= $_SESSION['filter']; } } elseif(isset($_SESSION['filter']) && is_string($_SESSION['filter'])) { $_entry['query'] .= $_SESSION['filter']; } ?>

 
= '".aporeplace($plugin['current_year'].'-'.$plugin['current_month'].'-1 00:00:00')."' AND "; $sql .= "calendar_start < '".aporeplace($plugin['end_year'].'-'.$plugin['end_month'].'-1 00:00:00')."' ORDER BY calendar_start ASC"; $plugin['dates'] = _dbQuery($sql); // run through dates and put in right day, fist for all non-repeating dates $_entry['dates'] = array(); foreach($plugin['dates'] as $_entry['x']) { $_entry['day'] = intval($_entry['x']['calendar_day']); $_entry['dates'][ $_entry['day'] ][] = $_entry['x']; } $sql = 'SELECT *, '; $sql .= "DATE_FORMAT(calendar_start, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_start_date, "; $sql .= "DATE_FORMAT(calendar_end, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_end_date, "; $sql .= "DATE_FORMAT(calendar_range_start, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_rangestart, "; $sql .= "DATE_FORMAT(calendar_range_end, '%d".$BLM['date_delimiter']."%m".$BLM['date_delimiter']."%Y') AS calendar_rangeend, "; $sql .= "DATE_FORMAT(calendar_start, '%H:%i') AS calendar_start_time, "; $sql .= "DATE_FORMAT(calendar_end, '%H:%i') AS calendar_end_time, "; $sql .= "DATE_FORMAT(calendar_start, '%e') AS calendar_day "; $sql .= ' FROM '.DB_PREPEND.'phpwcms_calendar WHERE '; $sql .= 'calendar_status != 9 AND '; $sql .= 'calendar_range > 0 AND '; $sql .= "calendar_range_start < '".aporeplace($plugin['end_year'].'-'.$plugin['end_month'].'-01 00:00:00')."' AND "; $sql .= "calendar_range_end > '".aporeplace($plugin['current_year'].'-'.$plugin['current_month'].'-1 00:00:00')."' "; $sql .= 'ORDER BY calendar_range_start ASC'; $plugin['dates'] = _dbQuery($sql); // run through dates and put in right day, fist for all non-repeating dates foreach($plugin['dates'] as $_entry['y']) { $_entry['day'] = intval($_entry['y']['calendar_day']); $_entry['range_start_timestamp'] = strtotime($_entry['y']['calendar_range_start'].' 00:00:00'); $_entry['range_end_timestamp'] = strtotime($_entry['y']['calendar_range_end'].' 23:59:59'); $_entry['this_timestamp'] = strtotime($_entry['y']['calendar_start']); $_entry['date_weekday'] = date('w', $_entry['this_timestamp']); $_entry['day_month'] = date('j', $_entry['this_timestamp']); $_entry['day_year'] = date('dm', $_entry['this_timestamp']); for($_entry['x'] = 1, $_entry['timestamp']=$plugin['first_of_month']; $_entry['x'] <= $plugin['days_in_month']; $_entry['x']++, $_entry['timestamp']+=86400) { if($_entry['timestamp'] >= $_entry['range_start_timestamp'] && $_entry['timestamp'] <= $_entry['range_end_timestamp']) { $_entry['weekday'] = date('w', $_entry['timestamp']); // 1 daily // 2 Every weekday (Mon-Fri) // 3 Every Mon., Wed. and Fri. // 4 Every Tues. and Thurs. // 5 Weekly // 6 Monthly // 7 yearly if( $_entry['y']['calendar_range'] == 1 || ($_entry['y']['calendar_range'] == 2 && $_entry['weekday'] != 6 && $_entry['weekday'] != 0) || ($_entry['y']['calendar_range'] == 3 && ($_entry['weekday'] == 1 || $_entry['weekday'] == 3 || $_entry['weekday'] == 5)) || ($_entry['y']['calendar_range'] == 4 && ($_entry['weekday'] == 2 || $_entry['weekday'] == 4)) || ($_entry['y']['calendar_range'] == 5 && $_entry['weekday'] == $_entry['date_weekday']) || ($_entry['y']['calendar_range'] == 6 && $_entry['x'] == $_entry['day_month']) || ($_entry['y']['calendar_range'] == 7 && date('dm', $_entry['timestamp']) == $_entry['day_year']) ) { $_entry['y']['calendar_start_date'] = date('d'.$BLM['date_delimiter'].'m'.$BLM['date_delimiter'].'Y', $_entry['timestamp']); $_entry['y']['calendar_end_date'] = $_entry['y']['calendar_start_date']; $_entry['dates'][ $_entry['x'] ][] = $_entry['y']; } } } } $plugin['day_names'] = returnDayNameArray(); // head row echo ''.LF; echo ' '.LF; echo ' '.LF; echo ' '.LF; echo ' '.LF; echo ''.LF; $_entry['rowspan'] = gmstrftime('%w', $plugin['first_of_month']); $_entry['rowspan'] = 8 - ($_entry['rowspan']==0 ? 7 : $_entry['rowspan']); $_entry['c'] = 0; for($_entry['x'] = 1, $_entry['timestamp']=$plugin['first_of_month']; $_entry['x'] <= $plugin['days_in_month']; $_entry['x']++, $_entry['timestamp']+=86400) { $_entry['day_num'] = gmstrftime('%w', $_entry['timestamp']); $_entry['day_num'] = $_entry['day_num']==0 ? 7 : $_entry['day_num']; echo ''.LF; if($_entry['day_num'] == 1) { if($plugin['days_in_month'] - $_entry['x'] < 7) { $_entry['rowspan'] = $plugin['days_in_month'] - $_entry['x'] + 1; } else { $_entry['rowspan'] = 7; } } if($_entry['rowspan']) { echo ' '.LF; $_entry['rowspan'] = 0; $_entry['c']++; } $_entry['class'] = ($_entry['day_num'] == 7 || $_entry['x'] == $plugin['days_in_month']) ? ' calendarSunday' : ''; echo ' '.LF; echo ' '.LF; echo ' '.LF; echo ''.LF; } // switch language back if(!empty($BLM['locale_string'])) { setlocale(LC_TIME, $_oldLocale); //switch current locale back to old value } ?>
'.$BLM['weekNrTitle'].''; echo $plugin['this_date']; echo ' 
1) ? 'rowspan="'.$_entry['rowspan'].'" ' : ''; echo 'class="calendarWeek'; echo ($_entry['c'] % 2) ? '' : ' calendarWeekAlt'; echo '">'; $_entry['wno'] = gmstrftime('%W', $_entry['timestamp']) + $plugin['week_add']; if($_entry['wno'] == 53) { $_entry['wno'] = 1; } echo $_entry['wno']; echo ''.$_entry['x'].'
'.html_specialchars(gmstrftime('%a', $_entry['timestamp'])).'
'; // run available dates for current day if(isset($_entry['dates'][ $_entry['x'] ])) { foreach($_entry['dates'][ $_entry['x'] ] as $_entry['date']) { $_entry['link '] = $_entry['date']['calendar_title'].' ('; if($_entry['date']['calendar_allday']) { $_entry['link '] .= $BLM['all_day']; } else { $_entry['link '] .= $_entry['date']['calendar_start_time'].'–'; if($_entry['date']['calendar_start_date'] != $_entry['date']['calendar_end_date']) { $_entry['link '] .= $_entry['date']['calendar_end_date'].', '; } $_entry['link '] .= $_entry['date']['calendar_end_time']; } $_entry['link '] .= ')'; if($_entry['date']['calendar_range']) { $_entry['link '] = $BLM['repeat_list'.$_entry['date']['calendar_range']].': '.$_entry['link ']; } $_entry['link '] = html_specialchars($_entry['link ']); echo '

' . $_entry['link '] . ''; echo ''; echo ''; /* echo ''; */ echo '

'; } } else { echo ' '; } echo '
'; echo ''; echo ''; echo '