function format_date_range_part($gmt, $untimed, $only_use_time, $date_format, $time_format) { $default_format = "{$date_format} {$time_format}"; $format = $default_format; if ($untimed) { $format = $date_format; } else { if ($only_use_time) { $format = $time_format; } } return ICalEvents::fdate($format, $gmt); }
function printAdminPage() { global $wp_version; $icsOptions = $this->getAdminOptions(); if (isset($_POST['update_ICSImporterSettings'])) { $icsArray = array(); foreach ($_POST['icsFile'] as $k => $val) { if (!empty($val)) { //$key = (empty($_POST['icsFileKey'][$k])) ? $k+1 : $_POST['icsFileKey'][$k]; $icsArray[$k + 1] = $val; } } $icsOptions['ics_files'] = serialize($icsArray); $icsOptions['ics_file_default'] = $_POST['icsFileDefault']; $icsOptions['title'] = $_POST['icsTitle']; $icsOptions['event_limit'] = $_POST['icsEventLimit']; $icsOptions['limit_type'] = $_POST['icsLimitType']; $icsOptions['cache_time'] = $_POST['icsCacheTime']; $icsOptions['enable_cache'] = $_POST['icsEnableCache']; $icsOptions['time_format'] = $_POST['icsTimeFormat']; $icsOptions['date_format'] = $_POST['icsDateFormat']; $icsOptions['date_format_add_year'] = $_POST['icsDateFormatAddYear']; $icsOptions['gmt_start'] = $_POST['icsGmtStart']; $icsOptions['gmt_end'] = $_POST['icsGmtEnd']; $icsOptions['gmt_start_now'] = $_POST['icsGmtStartNow']; $icsOptions['custom_format'] = $_POST['icsCustomFormat']; $icsOptions['use_custom_format'] = $_POST['icsUseCustomFormat']; $icsOptions['calendar_num_events'] = $_POST['icsCalendarNumEvents']; $icsOptions['date_language'] = $_POST['icsDateLanguage']; $icsOptions['date_function'] = $_POST['icsDateFunction']; $icsOptions['show_next_prev'] = $_POST['icsShowNextPrev']; /* CALENDAR OPTIONS */ $icsOptions['cal_popups'] = $_POST['icsCalPopups']; $icsOptions['cal_startday'] = $_POST['icsCalStartDay']; $icsOptions['cal_permalinks'] = $_POST['icsCalPermalinks']; $icsOptions['cal_show_multiday'] = $_POST['icsCalMultiDay']; $icsOptions['cal_events_per_day'] = $_POST['icsCalEventsPerDay']; $icsOptions['cal_shrink'] = $_POST['icsCalShrink']; $icsOptions['cal_css_file'] = $_POST['icsCalCssFile']; $icsOptions['cal_event_download'] = $_POST['icsCalEventDownload']; $icsOptions['privacy_mode'] = $_POST['icsPrivacyMode']; $icsOptions['privacy_mode_name'] = $_POST['icsPrivacyModeName']; if (class_exists('ICalEvents')) { foreach ($icsArray as $val) { $ics_load_error[] = ICalEvents::update_cache($val); } } update_option($this->adminOptionsName, $icsOptions); ?> <div class="fade updated" id="message"><p><strong><?php _e("Settings Updated.", "WPICSImporter"); ?> </strong></p></div> <?php } foreach ($icsOptions as $key => $item) { $icsOptions[$key] = stripslashes($item); } ?> <style type="text/css"> .form-table th { white-space:nowrap; } <?php if ($wp_version < "2.5") { ?> .form-table { width:100%; } .form-table td { padding:10px; border-bottom:10px solid #FFFFFF; } .form-table tr { background:#EFEFEF; } .form-table th { border-bottom:10px solid #FFFFFF; text-align:left; padding:10px 25px 0 10px; } .ui-tabs-nav { margin:0 -13px 0 -13px; } .ui-tabs-nav .ui-tabs-selected a { color:#000000; font-weight:bold; } <?php } ?> </style> <div style="width:100%;"> <div class="wrap"> <?php if ($wp_version >= '2.7') { ?> <div class="icon32" id="icon-options-general"><br/></div><?php } ?> <h2>ICS Calendar</h2> <br /> <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?> "> <h3>General Settings</h3> <a href="javascript:void(0);" onclick="jQuery(this).next('div').toggle();">Installation Instructions</a> <div style="display:none; padding-left:20px; border:1px solid #CCC; "> <p>This plugin can only be used on a <b>Page</b>.</p> <h4>Event List</h4> <p> <b>[show-ics-events]</b> - shows the event list with default settings.<br /> <b>[show-ics-events=<i>num_events</i>]</b> - shows the specified number of events<br /> <b>[show-ics-events cal=<i>ics_num</i>,<i>ics_num</i>]</b> - show only events from the specified calendar file(s) </p> <h4>Event Calendar</h4> <p> <b>[show-ics-calendar]</b> - shows the calendar with default settings<br /> <b>[show-ics-calendar cal=<i>ics_num</i>,<i>ics_num</i>]</b> - shows the calendar using the specified calendar file(s) </p> </div> <table class="form-table"> <tr valign="top"><th scope="row" width="100">Calendar Title</th> <td> <input type="text" name="icsTitle" style="width: 250px; " value="<?php _e(stripslashes($icsOptions['title']), 'WPICSImporter'); ?> " /> </td></tr> <tr valign="top"><th scope="row">URL to ICS File(s)</th> <td> <?php $icsArray = unserialize($icsOptions['ics_files']); if (is_array($icsArray)) { foreach ($icsArray as $key => $val) { ?> <input type="text" name="icsFileKey[]" value="<?php _e($key, 'WPICSImporter'); ?> " style="width:40px;" disabled="disabled" /> <input type="text" name="icsFile[]" style="width: 80%; " value="<?php _e($val, 'WPICSImporter'); ?> " /><br /> <?php } } ?> <input type="text" id="addNewKey" name="icsFileKey[]" value="" style="width:40px;" value="<?php _e($key + 1, 'WPICSImporter'); ?> " disabled="disabled" /> <input type="text" id="addNewFile" name="icsFile[]" style="width: 80%; " value="" /> <?php if (isset($ics_load_error)) { foreach ($ics_load_error as $error) { if (!empty($error)) { echo '<br /><font color="#CC0000">' . $error . '</font>'; } } } ?> </td></tr> <tr valign="top"><th scope="row">Default Calendar</th> <td> <select name="icsFileDefault"> <?php foreach ($icsArray as $key => $val) { echo '<option value="' . $key . '" ' . ($icsOptions['ics_file_default'] == $key ? 'selected="selected"' : '') . '>Calendar #' . $key . '</option>' . "\n"; } echo '<option value="combine" ' . ($icsOptions['ics_file_default'] == 'combine' ? 'selected="selected"' : '') . '>Combine All Calendars</option>' . "\n"; ?> </select> Select the default calendar to show. </td></tr> <tr valign="top"><th scope="row">Cache Calendar File</th> <td> <label><input type="checkbox" name="icsEnableCache" value="true" <?php if ($icsOptions['enable_cache'] == "true") { echo 'CHECKED'; } ?> /> Enable caching to save the .ics file on my server.</label> <br /><small>The .ics file will be updated once per day. You can update it manually by clicking "Save Changes."</small> <!--<input disabled="disabled" type="text" name="icsCacheTime" style="width: 10%; " value="<?php _e($icsOptions['cache_time'], 'WPICSImporter'); ?> " /> Seconds <small>Set to 1 hour. [Feature coming soon.]</small>--> </td></tr> <tr valign="top"><th scope="row">Event Display Limit</th> <td> Show next <input type="text" name="icsEventLimit" style="width: 10%; " value="<?php _e($icsOptions['event_limit'], 'WPICSImporter'); ?> " /> <label><input type="radio" name="icsLimitType" value="events" <?php echo $icsOptions['limit_type'] == 'events' ? 'checked="checked"' : ''; ?> /> Events</label> <label><input type="radio" name="icsLimitType" value="days" <?php echo $icsOptions['limit_type'] == 'days' ? 'checked="checked"' : ''; ?> /> Days</label> <br /><small>Set to "0" to show all events.</small> </td></tr> <tr valign="top"> <th scope="row">Current Event Display</th> <td> <label><input type="checkbox" id="icsGmtStartNow_yes" name="icsGmtStartNow" value="true" <?php if ($icsOptions['gmt_start_now'] == "true") { echo 'CHECKED="checked"'; } ?> /> Show only upcoming event. (Only events in the future.)</label> <br /> From <input type="text" name="icsGmtStart" style="width: 100px; " value="<?php _e($icsOptions['gmt_start'], 'WPICSImporter'); ?> " /> to <input type="text" name="icsGmtEnd" style="width: 100px; " value="<?php _e($icsOptions['gmt_end'], 'WPICSImporter'); ?> " /> <br /><small>Use format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'. This is irrelevant if the Upcoming Events box is checked. Leave these blank if you want to show all events.</small> </td></tr> <tr valign="top"><th scope="row">Previous & Next</th> <td> <label><input type="radio" name="icsShowNextPrev" value="0" <?php if ($icsOptions['show_next_prev'] == '0') { echo ' checked="checked"'; } ?> /> Hide</label> <label><input type="radio" name="icsShowNextPrev" value="1" <?php if ($icsOptions['show_next_prev'] == '1') { echo ' checked="checked"'; } ?> /> Show</label> <br /><small>Whether or not to show buttons that allow users to view future events.</small> </td></tr> </table> <div<?php if ($wp_version >= "2.5") { print ' class="wrap"'; } ?> > <div class="submit"><input type="submit" class="button" name="update_ICSImporterSettings" value="<?php _e('Save Changes', 'WPICSImporter'); ?> " /></div> </div> <h3>Formatting</h3> <table class="form-table"> <tr valign="top"><th scope="row" width="100">Date Format</th> <td> <input type="text" name="icsDateFormat" style="width: 20%; " value="<?php _e($icsOptions['date_format'], 'WPICSImporter'); ?> " /> <b><?php echo ICalEvents::fdate($icsOptions['date_format'], time()); ?> </b> <br /><label><input type="checkbox" name="icsDateFormatAddYear" value="1" <?php if ($icsOptions['date_format_add_year'] == '1') { echo 'CHECKED="checked"'; } ?> /> Show year at the end of dates that are not within the current year.</label> <br /><small>Uses PHP <a target="_blank" href="http://us3.php.net/manual/en/function.date.php">Date Function</a> or <a href="http://us2.php.net/manual/en/function.strftime.php" target="_blank">strftime Function</a>.</small> </td></tr> <tr valign="top"><th scope="row">Time Format</th> <td> <input type="text" name="icsTimeFormat" style="width: 20%; " value="<?php _e($icsOptions['time_format'], 'WPICSImporter'); ?> " /> <b><?php echo ICalEvents::fdate($icsOptions['time_format'], time()); ?> </b> <small>Local Server Time</small> <br /><small>Uses PHP <a target="_blank" href="http://us3.php.net/manual/en/function.date.php">Date Function</a> or <a href="http://us2.php.net/manual/en/function.strftime.php" target="_blank">strftime Function</a>.</small> </td></tr> <tr valign="top"><th scope="row">Custom Event Format</th> <td> <p>Use custom format? <label><input type="radio" name="icsUseCustomFormat" value="true" <?php if ($icsOptions['use_custom_format'] == "true") { echo 'checked="checked"'; } ?> onclick="if(this.checked==true) { document.getElementById('ics_custom_format').style.display='block'; }" /> Yes</label> <label><input type="radio" name="icsUseCustomFormat" value="false" <?php if ($icsOptions['use_custom_format'] == "false") { echo 'checked="checked"'; } ?> onclick="if(this.checked==true) { document.getElementById('ics_custom_format').style.display='none'; }" /> No</label></p> <div id="ics_custom_format" style="display:<?php print $icsOptions['use_custom_format'] == "false" ? 'none' : 'block'; ?> ; "> <h5 style="margin-bottom:0;">Set Custom Format</h5> <textarea name="icsCustomFormat" style="width: 90%; height:100px; "><?php _e($icsOptions['custom_format'], 'WPICSImporter'); ?> </textarea> <br />Use <i>%date-time%</i>, <i>%start-date%</i>, <i>%start-time%</i>, <i>%end-date%</i>, <i>%end-time%</i>, <i>%event-title%</i>, <i>%description%</i> and <i>%location%</i>. </div> </td></tr> <tr valign="top"><th scope="row">Date Function</th> <td> <select name="icsDateFunction" style="width: 20%; " > <option value="strftime" <?php if ($icsOptions['date_function'] == 'strftime') { echo ' selected="selected"'; } ?> >Strftime Function</option> <option value="date" <?php if ($icsOptions['date_function'] == 'date') { echo ' selected="selected"'; } ?> >Date Function</option> </select> <br /><small>Uses PHP <a target="_blank" href="http://us3.php.net/manual/en/function.date.php">Date Function</a> or <a href="http://us2.php.net/manual/en/function.strftime.php" target="_blank">strftime Function</a>.</small> </td></tr> <tr valign="top"><th scope="row">Date Locale (Language)</th> <td> <input type="text" name="icsDateLanguage" style="width: 20%; " value="<?php _e($icsOptions['date_language'], 'WPICSImporter'); ?> " /> <br /><small>Use a comma to seperate multiple locales. This can only be used if the date function is set to 'strftime'.</small><br /> <?php ob_start(); system('locale -a'); $locales = ob_get_contents(); ob_end_clean(); $local = explode("\n", $locales); echo '<a href="javascript:void(0);" onclick="jQuery(\'#supported_locales\').toggle();">Show / Hide Supported Locales</a> - Only works on Linux'; echo '<div id="supported_locales" style="display:none; font-size:10px; ">'; foreach ($local as $key => $val) { echo $val . " | \n"; } echo '</div>'; ?> </td></tr> <tr valign="top"><th scope="row">Privacy Mode</th> <td> <p>Hide your event information? <label><input type="radio" name="icsPrivacyMode" value="1" <?php if ($icsOptions['privacy_mode'] == "1") { echo 'checked="checked"'; } ?> onclick="if(this.checked==true) { document.getElementById('ics_privacy_mode').style.display='block'; }" /> Yes</label> <label><input type="radio" name="icsPrivacyMode" value="0" <?php if ($icsOptions['privacy_mode'] == "0") { echo 'checked="checked"'; } ?> onclick="if(this.checked==true) { document.getElementById('ics_privacy_mode').style.display='none'; }" /> No</label></p> <div id="ics_privacy_mode" style="display:<?php print $icsOptions['privacy_mode'] == "0" ? 'none' : 'block'; ?> ; "> <h5 style="margin:0;">Set Privacy Event Title</h5> <input type="text" name="icsPrivacyModeName" style="width: 20%; " value="<?php _e($icsOptions['privacy_mode_name'], 'WPICSImporter'); ?> " /> <small>This will replace your event title</small> </div> </td></tr> </table> <h3>Calendar</h3> <table class="form-table"> <tr valign="top"><th scope="row">Show Calendar Popups</th> <td> <select name="icsCalPopups" style="width: 20%; " > <option value="none" <?php if ($icsOptions['cal_popups'] == 'none') { echo ' selected="selected"'; } ?> >Never</option> <option value="mouse-over" <?php if ($icsOptions['cal_popups'] == 'mouse-over') { echo ' selected="selected"'; } ?> >On Mouse Over</option> <option value="click" <?php if ($icsOptions['cal_popups'] == 'click') { echo ' selected="selected"'; } ?> >On Click</option> </select> <br /><small>When to show the popups</small> </td></tr> <tr valign="top"><th scope="row">Calendar Start Day</th> <td> <select name="icsCalStartDay" style="width: 20%; " > <?php $cal_days = array('0' => 'Sunday', '1' => 'Monday', '2' => 'Tuesday', '3' => 'Wednesday', '4' => 'Thursday', '5' => 'Friday', '6' => 'Saturday'); foreach ($cal_days as $key => $value) { echo '<option value="' . $key . '" ' . ($icsOptions['cal_startday'] == $key ? ' selected="selected"' : '') . '>' . $value . '</option>' . "\n"; } ?> </select> <br /><small>What day of the week would you like the calendar to start on?</small> </td></tr> <tr valign="top"><th scope="row">Events Per Cell</th> <td> <input type="text" name="icsCalEventsPerDay" style="width: 10%; " value="<?php _e($icsOptions['cal_events_per_day'], 'WPICSImporter'); ?> " /> <small>How many events to display per calendar cell.</small> </td></tr> <tr valign="top"><th scope="row">Events on Multiple Days</th> <td> <label><input type="radio" name="icsCalMultiDay" value="0" <?php if ($icsOptions['cal_show_multiday'] == '0') { echo ' checked="checked"'; } ?> /> One Day</label> <label><input type="radio" name="icsCalMultiDay" value="1" <?php if ($icsOptions['cal_show_multiday'] == '1') { echo ' checked="checked"'; } ?> /> Multiple Days</label> <br /><small>Whether or not to show multiday events on multiple days of the calendar, instead of just the first day.</small> </td></tr> <tr valign="top"><th scope="row">Calendar Permalinks</th> <td> <label><input type="radio" name="icsCalPermalinks" value="0" <?php if ($icsOptions['cal_permalinks'] == '0') { echo ' checked="checked"'; } ?> /> Hide</label> <label><input type="radio" name="icsCalPermalinks" value="1" <?php if ($icsOptions['cal_permalinks'] == '1') { echo ' checked="checked"'; } ?> /> Show</label> <br /><small>Whether or not to show permalinks in the calendar popups.</small> </td></tr> <tr valign="top"><th scope="row">Calendar Download Links</th> <td> <label><input type="radio" name="icsCalEventDownload" value="0" <?php if ($icsOptions['cal_event_download'] == '0') { echo ' checked="checked"'; } ?> /> Hide</label> <label><input type="radio" name="icsCalEventDownload" value="1" <?php if ($icsOptions['cal_event_download'] == '1') { echo ' checked="checked"'; } ?> /> Show</label> <br /><small>Allow users to download individual events to their own calendars.</small> </td></tr> <tr valign="top"><th scope="row">Shrink Calendar</th> <td> <label><input type="radio" name="icsCalShrink" value="0" <?php if ($icsOptions['cal_shrink'] == '0') { echo ' checked="checked"'; } ?> /> Always Show 6 Rows</label> <label><input type="radio" name="icsCalShrink" value="1" <?php if ($icsOptions['cal_shrink'] == '1') { echo ' checked="checked"'; } ?> /> Shrink Calendar Based on Month</label> <br /><small>Whether or not to shrink the height of the calendar based on the weeks in a given month.</small> </td></tr> </table> <div<?php if ($wp_version >= "2.5") { print ' class="wrap"'; } ?> > <div class="submit"><input type="submit" class="button-primary" name="update_ICSImporterSettings" value="<?php _e('Save Changes', 'WPICSImporter'); ?> " /></div> </div> <h3>Advanced</h3> <p>These settings are for advanced users. Please only change them if you know what you are doing.</p> <table class="form-table"> <tr valign="top"><th scope="row">Import CSS File</th> <td> <input type="text" name="icsCalCssFile" style="width: 50%; " value="<?php _e($icsOptions['cal_css_file'], 'WPICSImporter'); ?> " /><br /> <small>An absolute link to a CSS file to replace the one in this plugin. (ie: '/wordpress/css/my-ics-calendar-replacement.css')</small> </td></tr> </table> <div<?php if ($wp_version >= "2.5") { print ' class="wrap"'; } ?> > <div class="submit"><input type="submit" class="button" name="update_ICSImporterSettings" value="<?php _e('Save Changes', 'WPICSImporter'); ?> " /></div> </div> </form> </div> </div> <?php }
function showCalendar($options, $selected_date = NULL, $eventid = '', $eventdate = '', $cuid = '') { if ($selected_date != NULL) { $today = getdate(strtotime($selected_date)); } elseif (!empty($eventid)) { //$selectedEvent = ICalEvents::get_event($options['ics_file'], $eventid, $eventdate); //$pretoday = getdate($selectedEvent['StartTime']); //$today = getdate( mktime(0,0,0,$pretoday['mon'],1,$pretoday['year']) ); $today = getdate($eventdate); } else { $today = getdate(); } $fixed_locales = preg_replace('/ +/', '', $options['date_language']); $locales = explode(',', $fixed_locales); if (!setlocale(LC_ALL, $locales)) { //return "Locale Error"; exit; } $calArray = icsCalDisplay::getCalendarArray($today, $options); $icsArray = unserialize($options['ics_files']); if ($options['ics_file_default'] == 'combine') { $icsFile = $icsArray; } elseif (strstr($options['ics_file_default'], ',')) { $cals = explode(',', $options['ics_file_default']); foreach ($cals as $calid) { $icsFile[] = $icsArray[trim($calid)]; } } elseif (!empty($icsArray[$options['ics_file_default']])) { $icsFile = $icsArray[$options['ics_file_default']]; } else { $icsFile = array_shift($icsArray); } $events = ICalEvents::get_events($icsFile, $calArray[0], end($calArray) + 24 * 3600 + 1, NULL); if (is_array($events)) { foreach ($events as $event) { if ($options['cal_show_multiday'] == '1') { $days = ceil(($event['EndTime'] - $event['StartTime']) / (3600 * 24)); } else { $days = 1; } for ($i = 0; $i < $days; $i++) { $calEvents[date('Y-n-j', $event['StartTime'] + $i * 3600 * 24)][] = $event; } } } $calContent = '<table class="ics-calendar-table" cellspacing="1" cellpadding="1" width="100%">'; $calContent .= '<tr class="ics-calendar-days">' . "\n"; $calContentWeekdays = array(); for ($d = 1; $d <= 7; $d++) { $calContentWeekdays[] = strftime('%a', strtotime('2009-3-' . $d)); } //$calContentWeekdays = array('Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'); $dayHolder = array_splice($calContentWeekdays, $options['cal_startday']); $calContentWeekdays = array_merge($dayHolder, $calContentWeekdays); $calContent .= '<td>' . implode('</td><td>', $calContentWeekdays) . '</td></tr>' . "\n"; //foreach($calArray as $day){ // echo date('m-d-Y',$day)."<br>"; //} // Display the first calendar row with correct positioning //Get how many complete weeks are in the actual month $fullWeeks = floor(count($calArray) / 7); $lineWeeks = $options['cal_shrink'] == '1' ? ceil(count($calArray) / 7) : 6; $x = 0; for ($i = 0; $i < $lineWeeks; $i++) { $calContent .= '<tr>'; for ($j = 0; $j < 7; $j++) { $currDate = getdate($calArray[$x]); $x++; #increase to the next item in the array. $calContent .= "<td>"; //$calContent .= '<div id="ics-cell-'.$currDate['mon'].'-'.$currDate['mday'].'" class="ics-calendar-cell">'; $calContent .= '<div class="'; if ($currDate['mon'] == $today['mon']) { $calContent .= 'date-holder'; } else { $calContent .= 'old-date-holder'; } ##Current selected month, or outside the month. if ($currDate['mday'] == date('j', time()) && $currDate['year'] == date('Y', time()) && $currDate['mon'] == date('n', time())) { $calContent .= ' ics-calendar-today'; } #select the actual day. $calContent .= '">'; $eventsKey = $currDate['year'] . '-' . $currDate['mon'] . '-' . $currDate['mday']; /*------------>*/ $CAL_NUM_DISPLAY = $options['cal_events_per_day']; if (isset($calEvents) && array_key_exists($eventsKey, $calEvents)) { if (!function_exists('sortEvents')) { function sortEvents($a, $b) { if ($a['StartTime'] == $b['StartTime']) { return 0; } return $a['StartTime'] < $b['StartTime'] ? -1 : 1; } } usort($calEvents[$eventsKey], 'sortEvents'); //print_r($calEvents[$eventsKey]); if (count($calEvents[$eventsKey]) > $CAL_NUM_DISPLAY) { ### MORE button if there are too many events $calContent .= '<a class="ics-more-button" href="javascript:void(0);" tag="ics-cell-' . $currDate['mon'] . '-' . $currDate['mday'] . '">« ' . __('more', 'WPICSImporter') . '</a>'; ### Get events and place them in an enlarged box. $calContent .= '<div id="ics-cell-' . $currDate['mon'] . '-' . $currDate['mday'] . '" class="ics-calendar-more-box">'; $calContent .= '<div style="width:100%; text-align:right; "><span style="float:left; "><small><a href="javascript:void(0);" onclick="jQuery(\'#ics-cell-' . $currDate['mon'] . '-' . $currDate['mday'] . '\').hide()">« ' . __('close', 'WPICSImporter') . '</a></small></span> <strong>' . $currDate['mday'] . '</strong></div>'; foreach ($calEvents[$eventsKey] as $event) { $eventUID = 'ics_' . md5($event['UID']); $calContent .= '<div class="ics-calendar-event" icstag="' . $eventUID . $eventsKey . $cuid . '">'; $calContent .= $options['cal_popups'] == 'mouse-over' && !empty($event['attach']) ? '<a href="' . $event['attach'] . '" target="_blank">' . $event['Summary'] . '</a>' : $event['Summary']; $calContent .= '</div>'; } $calContent .= '</div>'; } $calContent .= '<strong>' . $currDate['mday'] . '</strong></div>'; $e = 0; //print '<pre>'; //print_r($calEvents); foreach ($calEvents[$eventsKey] as $key => $event) { if (!isset($event['SkipBox'])) { $eventUID = 'ics_' . md5($event['UID']); $showBoxNow = $eventid == $event['UID'] ? ' style="margin-top: 20px; display: block;"' : ''; $calContent .= '<div class="ics-calendar-event-box" id="' . $eventUID . $eventsKey . $cuid . '"' . $showBoxNow . '>'; $icsRequestURI = !empty($_GET['realPath']) ? base64_decode($_GET['realPath']) : $_SERVER['REQUEST_URI']; $icsRequestURI = preg_replace('/(\\?|&)?(icsevent|icsdate)=([^?=&]*)/i', '', $icsRequestURI); if ($options['cal_event_download'] == 1) { $icsEventLink = ICSCALENDAR_URLPATH . 'ajax-load.php?'; $icsEventLink .= 'downloadEvent=' . $event['UID'] . ''; $icsEventLink .= '&calendarID=' . $event['calID'] . ''; $calContent .= '<div class="ics-calendar-permalink"><a href="' . $icsEventLink . '">' . __('Download', 'WPICSImporter') . '</a></div> '; } if ($options['cal_permalinks'] == 1) { $icsPermalink = $icsRequestURI; $icsPermalink .= preg_match('/\\?/', $icsPermalink) ? '&' : '?'; //$icsPermalink .= 'icsevent='.$event['UID'].''; //$icsPermalink .= '&icsdate='.$event['StartTime'].''; $icsPermalink .= 'ics-perm=' . $event['UID'] . ''; $calContent .= '<div class="ics-calendar-permalink"><a href="' . $icsPermalink . '">' . __('Permalink', 'WPICSImporter') . '</a></div>'; } $calContent .= '<div>' . __('Event:', 'WPICSImporter') . ' <strong>' . ($options['cal_popups'] == 'click' && !empty($event['attach']) ? '<a href="' . $event['attach'] . '" target="_blank">' . $event['Summary'] . '</a>' : $event['Summary']) . '</strong><br />'; if (ICalEvents::is_all_day($event['StartTime'], $event['EndTime']) || isset($options['hide_time']) && $options['hide_time'] == 'true') { $formated_date = ICalEvents::fdate($options['date_format'], $event['StartTime']); } else { $formated_date = ICalEvents::format_date_range($event['StartTime'], $event['EndTime'], $event['Untimed'], $options['date_format'], $options['time_format']); } $calContent .= __('When:', 'WPICSImporter') . ' ' . $formated_date . '<br />'; if (!empty($event['Description'])) { $calContent .= __('Description:', 'WPICSImporter') . ' ' . $event['Description'] . '<br />'; } if (!empty($event['Location'])) { $calContent .= __('Location:', 'WPICSImporter') . ' ' . $event['Location'] . '<br />'; } $calContent .= '</div></div>'; } $e++; } for ($f = 0; $f < $CAL_NUM_DISPLAY; $f++) { $fevent = $calEvents[$eventsKey][$f]; if ($fevent['Summary'] != '') { $eventUID = 'ics_' . md5($fevent['UID']); $calContent .= '<div class="ics-calendar-event" icstag="' . $eventUID . $eventsKey . $cuid . '">'; $calContent .= $options['cal_popups'] == 'mouse-over' && !empty($fevent['attach']) ? '<a href="' . $fevent['attach'] . '" target="_blank">' . $fevent['Summary'] . '</a>' : $fevent['Summary']; $calContent .= '</div>'; } } } elseif ($x <= count($calArray)) { $calContent .= $currDate['mday'] . '</div>'; } else { $calContent .= '</div>'; } //$calContent .= '</div>'; $calContent .= "</td>" . "\n"; } $calContent .= '</tr>' . "\n"; } $calContent .= '</table>'; $calContent .= '<script type="text/javascript"> jQuery("#ics-prev-button' . $cuid . '").attr("month","' . date('Y-m-d', mktime(0, 0, 0, $today['mon'] - 1, 1, $today['year'])) . '"); jQuery("#ics-next-button' . $cuid . '").attr("month","' . date('Y-m-d', mktime(0, 0, 0, $today['mon'] + 1, 1, $today['year'])) . '"); jQuery("#ics-calendar-header-text' . $cuid . '").html("' . strftime("%B", mktime(0, 0, 0, $today['mon'], 1, $today['year'])) . ' ' . $today['year'] . ' "); '; if ($options['cal_popups'] == 'mouse-over') { $calContent .= ' jQuery().mousemove(function(e){ if(e.pageX > (jQuery(window).width()/2) ) { jQuery(".ics-calendar-event-box").css("left",e.pageX + 5 - jQuery(".ics-calendar-event-box").width()); } else { jQuery(".ics-calendar-event-box").css("left",e.pageX + 5); } jQuery(".ics-calendar-event-box").css("top",e.pageY + 5); });'; $calContent .= ' jQuery("div.ics-calendar-event").hover( function () { jQuery("#" + jQuery(this).attr("icstag")).show(); }, function () { jQuery("#" + jQuery(this).attr("icstag")).hide(); } );'; } elseif ($options['cal_popups'] == 'click') { $calContent .= ' jQuery("div.ics-calendar-event").click( function (e) { var $jObject = jQuery("#" + jQuery(this).attr("icstag")); var css = {}; css.marginTop = 20; if(jQuery(this).offset().left > (jQuery(window).width()/2) ) { css.marginLeft = -$jObject.width() } else { css.marginLeft = 0; } jQuery(".ics-calendar-event-box").hide(); $jObject.css(css).show(); e.stopPropagation(); } );'; $calContent .= ' jQuery(".ics-calendar-event-box").click(function(e) { e.stopPropagation(); } ); '; $calContent .= ' jQuery(document).click(function(e){ jQuery(".ics-calendar-event-box").hide(); });'; } $calContent .= ' jQuery("a.ics-more-button").click(function() { jQuery(".ics-calendar-more-box").hide(); jQuery("#"+jQuery(this).attr("tag")).show(); });'; //jQuery(".ics-calendar-more-box").mouseout(function() { jQuery(this).hide(); }); $calContent .= '</script>'; $calContent .= ''; return $calContent; }