Version Description
Download this release
Release Info
Developer | KieranOShea |
Plugin | Calendar |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.3
- calendar.php +741 -378
- readme.txt +2 -2
calendar.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.kieranoshea.com
|
|
5 |
Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
|
6 |
Author: Kieran O'Shea
|
7 |
Author URI: http://www.kieranoshea.com
|
8 |
-
Version: 1.
|
9 |
*/
|
10 |
|
11 |
/* Copyright 2008 Kieran O'Shea (email : kieran@kieranoshea.com)
|
@@ -30,9 +30,10 @@ $plugin_dir = basename(dirname(__FILE__));
|
|
30 |
load_plugin_textdomain( 'calendar','wp-content/plugins/'.$plugin_dir, $plugin_dir);
|
31 |
|
32 |
// Define the tables used in Calendar
|
33 |
-
|
34 |
-
define('
|
35 |
-
define('
|
|
|
36 |
|
37 |
// Check ensure calendar is installed and install it if not - required for
|
38 |
// the successful operation of most functions called from this point on
|
@@ -43,6 +44,7 @@ add_action('admin_menu', 'calendar_menu');
|
|
43 |
|
44 |
// Enable the ability for the calendar to be loaded from pages
|
45 |
add_filter('the_content','calendar_insert');
|
|
|
46 |
|
47 |
// Enable the ability for the lists to be loaded from pages
|
48 |
add_filter('the_content','upcoming_insert');
|
@@ -57,6 +59,7 @@ add_action('delete_user', 'deal_with_deleted_user');
|
|
57 |
// Add the widgets if we are using version 2.8
|
58 |
add_action('widgets_init', 'widget_init_calendar_today');
|
59 |
add_action('widgets_init', 'widget_init_calendar_upcoming');
|
|
|
60 |
|
61 |
// Before we get on with the functions, we need to define the initial style used for Calendar
|
62 |
|
@@ -138,10 +141,35 @@ function calendar_add_javascript()
|
|
138 |
// Function to deal with loading the calendar into pages
|
139 |
function calendar_insert($content)
|
140 |
{
|
141 |
-
if (preg_match('{CALENDAR}',$content))
|
142 |
{
|
143 |
-
$
|
144 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
return $content;
|
147 |
}
|
@@ -149,19 +177,33 @@ function calendar_insert($content)
|
|
149 |
// Functions to allow the widgets to be inserted into posts and pages
|
150 |
function upcoming_insert($content)
|
151 |
{
|
152 |
-
if (preg_match('{UPCOMING_EVENTS}',$content))
|
153 |
{
|
154 |
-
$
|
155 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
return $content;
|
158 |
}
|
159 |
function todays_insert($content)
|
160 |
{
|
161 |
-
if (preg_match('{TODAYS_EVENTS}',$content))
|
162 |
{
|
163 |
-
$
|
164 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
return $content;
|
167 |
}
|
@@ -178,26 +220,26 @@ function check_calendar()
|
|
178 |
global $wpdb, $initial_style;
|
179 |
|
180 |
// All this style info will go into the database on a new install
|
181 |
-
// This looks nice in the
|
182 |
$initial_style = " .calnk a:hover {
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
.calnk a:visited {
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
.calnk a {
|
194 |
text-decoration:none;
|
195 |
color:#000000;
|
196 |
border-bottom:1px dotted #000000;
|
197 |
-
|
198 |
.calnk a span {
|
199 |
display:none;
|
200 |
-
|
201 |
.calnk a:hover span {
|
202 |
color:#333333;
|
203 |
background:#F6F79B;
|
@@ -208,39 +250,41 @@ function check_calendar()
|
|
208 |
width:150px;
|
209 |
z-index:100;
|
210 |
line-height:1.2em;
|
211 |
-
|
212 |
-
|
213 |
-
border:
|
214 |
-
width:100
|
215 |
-
|
216 |
-
|
|
|
|
|
217 |
height:25px;
|
218 |
text-align:center;
|
219 |
border:1px solid #D6DED5;
|
220 |
background-color:#E4EBE3;
|
221 |
-
|
222 |
-
|
223 |
width:25%;
|
224 |
text-align:center;
|
225 |
-
|
226 |
-
|
227 |
width:25%;
|
228 |
text-align:center;
|
229 |
-
|
230 |
-
|
231 |
width:50%;
|
232 |
text-align:center;
|
233 |
font-weight:bold;
|
234 |
-
|
235 |
-
|
236 |
text-align:center;
|
237 |
width:25px;
|
238 |
height:25px;
|
239 |
font-size:0.8em;
|
240 |
border:1px solid #DFE6DE;
|
241 |
background-color:#EBF2EA;
|
242 |
-
|
243 |
-
|
244 |
text-align:center;
|
245 |
width:25px;
|
246 |
height:25px;
|
@@ -248,69 +292,65 @@ function check_calendar()
|
|
248 |
border:1px solid #DFE6DE;
|
249 |
background-color:#EBF2EA;
|
250 |
color:#FF0000;
|
251 |
-
|
252 |
-
|
253 |
vertical-align:text-top;
|
254 |
text-align:left;
|
255 |
width:60px;
|
256 |
height:60px;
|
257 |
border:1px solid #DFE6DE;
|
258 |
-
|
259 |
-
|
260 |
|
261 |
-
|
262 |
-
|
263 |
width:60px;
|
264 |
height:60px;
|
265 |
border:1px solid #E9F0E8;
|
266 |
-
|
267 |
-
|
268 |
color:#FF0000;
|
269 |
-
|
270 |
-
|
271 |
vertical-align:text-top;
|
272 |
text-align:left;
|
273 |
width:60px;
|
274 |
height:60px;
|
275 |
border:1px solid #BFBFBF;
|
276 |
background-color:#E4EBE3;
|
277 |
-
|
278 |
-
|
279 |
font-size:0.75em;
|
280 |
-
|
281 |
-
|
282 |
font-size:0.75em;
|
283 |
text-align:center;
|
284 |
-
|
285 |
-
|
286 |
height:25px;
|
287 |
text-align:center;
|
288 |
border:1px solid #D6DED5;
|
289 |
background-color:#E4EBE3;
|
290 |
-
|
291 |
-
|
292 |
-
margin:
|
293 |
-
|
294 |
-
|
295 |
-
.calendar-date-switcher input {
|
296 |
border:1px #D6DED5 solid;
|
297 |
-
|
298 |
-
|
|
|
299 |
border:1px #D6DED5 solid;
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
margin-top:10px;
|
304 |
-
padding:5px;
|
305 |
-
border:1px solid #D6DED5;
|
306 |
-
}
|
307 |
-
.calnk a:hover span span.event-title {
|
308 |
padding:0;
|
309 |
text-align:center;
|
310 |
font-weight:bold;
|
311 |
font-size:1.2em;
|
312 |
-
|
313 |
-
|
|
|
314 |
width:96%;
|
315 |
text-align:center;
|
316 |
height:1px;
|
@@ -318,8 +358,9 @@ function check_calendar()
|
|
318 |
margin-right:2%;
|
319 |
padding:0;
|
320 |
background-color:#000000;
|
321 |
-
|
322 |
-
|
|
|
323 |
width:96%;
|
324 |
text-align:center;
|
325 |
height:1px;
|
@@ -327,13 +368,43 @@ function check_calendar()
|
|
327 |
margin-right:2%;
|
328 |
padding:0;
|
329 |
background-color:#000000;
|
330 |
-
|
331 |
-
|
|
|
332 |
font-size:80%;
|
333 |
-
|
334 |
-
|
335 |
font-size:80%;
|
336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
|
338 |
|
339 |
// Assume this is not a new install until we prove otherwise
|
@@ -399,7 +470,7 @@ function check_calendar()
|
|
399 |
event_repeats INT(3) ,
|
400 |
event_author BIGINT(20) UNSIGNED ,
|
401 |
event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1 ,
|
402 |
-
event_link TEXT
|
403 |
PRIMARY KEY (event_id)
|
404 |
)";
|
405 |
$wpdb->get_results($sql);
|
@@ -471,7 +542,7 @@ function check_calendar()
|
|
471 |
$wpdb->get_results($sql);
|
472 |
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
|
473 |
$wpdb->get_results($sql);
|
474 |
-
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT
|
475 |
$wpdb->get_results($sql);
|
476 |
$sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
|
477 |
category_id INT(11) NOT NULL AUTO_INCREMENT,
|
@@ -491,7 +562,7 @@ function check_calendar()
|
|
491 |
$wpdb->get_results($sql);
|
492 |
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
|
493 |
$wpdb->get_results($sql);
|
494 |
-
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT
|
495 |
$wpdb->get_results($sql);
|
496 |
$sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
|
497 |
category_id INT(11) NOT NULL AUTO_INCREMENT,
|
@@ -508,16 +579,16 @@ function check_calendar()
|
|
508 |
}
|
509 |
|
510 |
// Used on the manage events admin page to display a list of events
|
511 |
-
function wp_events_display_list()
|
512 |
-
|
513 |
global $wpdb;
|
514 |
|
515 |
$events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " ORDER BY event_begin DESC");
|
516 |
|
517 |
if ( !empty($events) )
|
518 |
{
|
519 |
-
|
520 |
-
|
521 |
<thead>
|
522 |
<tr>
|
523 |
<th class="manage-column" scope="col"><?php _e('ID','calendar') ?></th>
|
@@ -533,7 +604,7 @@ function wp_events_display_list()
|
|
533 |
<th class="manage-column" scope="col"><?php _e('Delete','calendar') ?></th>
|
534 |
</tr>
|
535 |
</thead>
|
536 |
-
|
537 |
$class = '';
|
538 |
foreach ( $events as $event )
|
539 |
{
|
@@ -743,15 +814,27 @@ function wp_events_edit_form($mode='add', $event_id=false)
|
|
743 |
<tr>
|
744 |
<td><legend><?php _e('Recurring Events','calendar'); ?></legend></td>
|
745 |
<td> <?php
|
746 |
-
if ($data
|
747 |
-
|
|
|
748 |
$repeats = $data->event_repeats;
|
|
|
|
|
|
|
|
|
|
|
749 |
}
|
750 |
else
|
751 |
{
|
752 |
$repeats = 0;
|
753 |
}
|
754 |
|
|
|
|
|
|
|
|
|
|
|
|
|
755 |
if ($data->event_recur == "S")
|
756 |
{
|
757 |
$selected_s = 'selected="selected"';
|
@@ -772,6 +855,7 @@ function wp_events_edit_form($mode='add', $event_id=false)
|
|
772 |
{
|
773 |
$selected_u = 'selected="selected"';
|
774 |
}
|
|
|
775 |
?>
|
776 |
<?php _e('Repeats for','calendar'); ?>
|
777 |
<input type="text" name="event_repeats" class="input" size="1" value="<?php echo $repeats; ?>" />
|
@@ -857,11 +941,11 @@ if ( $action == 'add' )
|
|
857 |
if ((preg_match($date_format_one,$begin) || preg_match($date_format_two,$begin)) && (preg_match($date_format_one,$end) || preg_match($date_format_two,$end)))
|
858 |
{
|
859 |
// We know we have a valid year and month and valid integers for days so now we do a final check on the date
|
860 |
-
$begin_split =
|
861 |
$begin_y = $begin_split[0];
|
862 |
$begin_m = $begin_split[1];
|
863 |
$begin_d = $begin_split[2];
|
864 |
-
$end_split =
|
865 |
$end_y = $end_split[0];
|
866 |
$end_m = $end_split[1];
|
867 |
$end_d = $end_split[2];
|
@@ -952,7 +1036,7 @@ if ( $action == 'add' )
|
|
952 |
<div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
|
953 |
<?php
|
954 |
}
|
955 |
-
if ($start_date_ok
|
956 |
{
|
957 |
$sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
|
958 |
. "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
|
@@ -1018,11 +1102,11 @@ elseif ( $action == 'edit_save' )
|
|
1018 |
if ((preg_match($date_format_one,$begin) || preg_match($date_format_two,$begin)) && (preg_match($date_format_one,$end) || preg_match($date_format_two,$end)))
|
1019 |
{
|
1020 |
// We know we have a valid year and month and valid integers for days so now we do a final check on the date
|
1021 |
-
$begin_split =
|
1022 |
$begin_y = $begin_split[0];
|
1023 |
$begin_m = $begin_split[1];
|
1024 |
$begin_d = $begin_split[2];
|
1025 |
-
$end_split =
|
1026 |
$end_y = $end_split[0];
|
1027 |
$end_m = $end_split[1];
|
1028 |
$end_d = $end_split[2];
|
@@ -1113,7 +1197,7 @@ elseif ( $action == 'edit_save' )
|
|
1113 |
<div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
|
1114 |
<?php
|
1115 |
}
|
1116 |
-
if ($start_date_ok
|
1117 |
{
|
1118 |
$sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
|
1119 |
. "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
|
@@ -1193,7 +1277,7 @@ elseif ( $action == 'delete' )
|
|
1193 |
|
1194 |
<div class="wrap">
|
1195 |
<?php
|
1196 |
-
if ( $action == 'edit' || ($action == 'edit_save' && $error_with_saving
|
1197 |
{
|
1198 |
?>
|
1199 |
<h2><?php _e('Edit Event','calendar'); ?></h2>
|
@@ -1296,10 +1380,12 @@ function edit_calendar_config()
|
|
1296 |
$wpdb->get_results("UPDATE " . WP_CALENDAR_CONFIG_TABLE . " SET config_value = '".$enable_categories."' WHERE config_item='enable_categories'");
|
1297 |
|
1298 |
// Check to see if we are replacing the original style
|
1299 |
-
if (
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
|
|
|
|
1303 |
|
1304 |
echo "<div class=\"updated\"><p><strong>".__('Settings saved','calendar').".</strong></p></div>";
|
1305 |
}
|
@@ -1323,6 +1409,8 @@ function edit_calendar_config()
|
|
1323 |
}
|
1324 |
}
|
1325 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_author'");
|
|
|
|
|
1326 |
if (!empty($configs))
|
1327 |
{
|
1328 |
foreach ($configs as $config)
|
@@ -1338,6 +1426,8 @@ function edit_calendar_config()
|
|
1338 |
}
|
1339 |
}
|
1340 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_jump'");
|
|
|
|
|
1341 |
if (!empty($configs))
|
1342 |
{
|
1343 |
foreach ($configs as $config)
|
@@ -1353,6 +1443,8 @@ function edit_calendar_config()
|
|
1353 |
}
|
1354 |
}
|
1355 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_todays'");
|
|
|
|
|
1356 |
if (!empty($configs))
|
1357 |
{
|
1358 |
foreach ($configs as $config)
|
@@ -1368,6 +1460,8 @@ function edit_calendar_config()
|
|
1368 |
}
|
1369 |
}
|
1370 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_upcoming'");
|
|
|
|
|
1371 |
if (!empty($configs))
|
1372 |
{
|
1373 |
foreach ($configs as $config)
|
@@ -1391,6 +1485,8 @@ function edit_calendar_config()
|
|
1391 |
}
|
1392 |
}
|
1393 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_categories'");
|
|
|
|
|
1394 |
if (!empty($configs))
|
1395 |
{
|
1396 |
foreach ($configs as $config)
|
@@ -1405,6 +1501,11 @@ function edit_calendar_config()
|
|
1405 |
}
|
1406 |
}
|
1407 |
}
|
|
|
|
|
|
|
|
|
|
|
1408 |
if ($allowed_group == 'read') { $subscriber_selected='selected="selected"';}
|
1409 |
else if ($allowed_group == 'edit_posts') { $contributor_selected='selected="selected"';}
|
1410 |
else if ($allowed_group == 'publish_posts') { $author_selected='selected="selected"';}
|
@@ -1573,7 +1674,7 @@ function manage_categories()
|
|
1573 |
}
|
1574 |
else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'edit' && !isset($_POST['mode']))
|
1575 |
{
|
1576 |
-
$sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".mysql_escape_string($_GET['category_id']);
|
1577 |
$cur_cat = $wpdb->get_row($sql);
|
1578 |
?>
|
1579 |
<div class="wrap">
|
@@ -1609,7 +1710,19 @@ function manage_categories()
|
|
1609 |
echo "<div class=\"updated\"><p><strong>".__('Category edited successfully','calendar')."</strong></p></div>";
|
1610 |
}
|
1611 |
|
1612 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1613 |
{
|
1614 |
?>
|
1615 |
|
@@ -1689,10 +1802,10 @@ function manage_categories()
|
|
1689 |
echo '<p>'.__('There are no categories in the database - something has gone wrong!','calendar').'</p>';
|
1690 |
}
|
1691 |
|
1692 |
-
?>
|
1693 |
</div>
|
1694 |
|
1695 |
-
<?php
|
1696 |
}
|
1697 |
}
|
1698 |
|
@@ -1709,6 +1822,31 @@ function np_of_day($date)
|
|
1709 |
return $instance;
|
1710 |
}
|
1711 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1712 |
// Function to return a prefix which will allow the correct
|
1713 |
// placement of arguments into the query string.
|
1714 |
function permalink_prefix()
|
@@ -1728,63 +1866,68 @@ function permalink_prefix()
|
|
1728 |
}
|
1729 |
|
1730 |
// Configure the "Next" link in the calendar
|
1731 |
-
function next_link($cur_year,$cur_month)
|
1732 |
{
|
1733 |
$mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec');
|
1734 |
$next_year = $cur_year + 1;
|
1735 |
|
1736 |
if ($cur_month == 12)
|
1737 |
{
|
1738 |
-
|
|
|
1739 |
}
|
1740 |
else
|
1741 |
{
|
1742 |
$next_month = $cur_month + 1;
|
1743 |
$month = $mod_rewrite_months[$next_month];
|
1744 |
-
|
|
|
1745 |
}
|
1746 |
}
|
1747 |
|
1748 |
// Configure the "Previous" link in the calendar
|
1749 |
-
function prev_link($cur_year,$cur_month)
|
1750 |
{
|
1751 |
$mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec');
|
1752 |
$last_year = $cur_year - 1;
|
1753 |
|
1754 |
if ($cur_month == 1)
|
1755 |
{
|
1756 |
-
|
|
|
1757 |
}
|
1758 |
else
|
1759 |
{
|
1760 |
$next_month = $cur_month - 1;
|
1761 |
$month = $mod_rewrite_months[$next_month];
|
1762 |
-
|
|
|
1763 |
}
|
1764 |
}
|
1765 |
|
1766 |
// Print upcoming events
|
1767 |
-
function upcoming_events()
|
1768 |
{
|
1769 |
global $wpdb;
|
1770 |
-
|
1771 |
// Find out if we should be displaying upcoming events
|
1772 |
$display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming'",0,0);
|
1773 |
-
|
1774 |
if ($display == 'true')
|
1775 |
{
|
1776 |
// Get number of days we should go into the future
|
1777 |
$future_days = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming_days'",0,0);
|
1778 |
$day_count = 1;
|
1779 |
-
|
|
|
1780 |
while ($day_count < $future_days+1)
|
1781 |
{
|
1782 |
-
list($y,$m,$d) =
|
1783 |
-
$events = grab_events($y,$m,$d,'upcoming');
|
1784 |
usort($events, "time_cmp");
|
1785 |
if (count($events) != 0) {
|
1786 |
$output .= '<li>'.date_i18n(get_option('date_format'),mktime($day_count*24,0,0,date("m",ctwo()),date("d",ctwo()),date("Y",ctwo()))).'<ul>';
|
1787 |
-
}
|
1788 |
foreach($events as $event)
|
1789 |
{
|
1790 |
if ($event->event_time == '00:00:00') {
|
@@ -1812,7 +1955,7 @@ function upcoming_events()
|
|
1812 |
}
|
1813 |
|
1814 |
// Print todays events
|
1815 |
-
function todays_events()
|
1816 |
{
|
1817 |
global $wpdb;
|
1818 |
|
@@ -1822,7 +1965,7 @@ function todays_events()
|
|
1822 |
if ($display == 'true')
|
1823 |
{
|
1824 |
$output = '<ul>';
|
1825 |
-
$events = grab_events(date("Y",ctwo()),date("m",ctwo()),date("d",ctwo()),'todays');
|
1826 |
usort($events, "time_cmp");
|
1827 |
foreach($events as $event)
|
1828 |
{
|
@@ -1856,7 +1999,7 @@ function draw_events($events)
|
|
1856 |
{
|
1857 |
// We need to sort arrays of objects by time
|
1858 |
usort($events, "time_cmp");
|
1859 |
-
|
1860 |
// Now process the events
|
1861 |
foreach($events as $event)
|
1862 |
{
|
@@ -1865,17 +2008,59 @@ function draw_events($events)
|
|
1865 |
return $output;
|
1866 |
}
|
1867 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1868 |
// The widget to show todays events in the sidebar
|
1869 |
function widget_init_calendar_today() {
|
1870 |
// Check for required functions
|
1871 |
-
if (!function_exists('
|
1872 |
return;
|
1873 |
|
1874 |
function widget_calendar_today($args) {
|
1875 |
extract($args);
|
1876 |
-
$the_title = get_option('calendar_today_widget_title');
|
|
|
1877 |
$widget_title = empty($the_title) ? __('Today\'s Events','calendar') : $the_title;
|
1878 |
-
$the_events = todays_events();
|
1879 |
if ($the_events != '') {
|
1880 |
echo $before_widget;
|
1881 |
echo $before_title . $widget_title . $after_title;
|
@@ -1885,33 +2070,38 @@ function widget_init_calendar_today() {
|
|
1885 |
}
|
1886 |
|
1887 |
function widget_calendar_today_control() {
|
1888 |
-
$widget_title = get_option('calendar_today_widget_title');
|
1889 |
-
|
|
|
1890 |
update_option('calendar_today_widget_title',strip_tags($_POST['calendar_today_widget_title']));
|
|
|
1891 |
}
|
1892 |
?>
|
1893 |
<p>
|
1894 |
<label for="calendar_today_widget_title"><?php _e('Title','calendar'); ?>:<br />
|
1895 |
<input class="widefat" type="text" id="calendar_today_widget_title" name="calendar_today_widget_title" value="<?php echo $widget_title; ?>"/></label>
|
|
|
|
|
1896 |
</p>
|
1897 |
<?php
|
1898 |
}
|
1899 |
|
1900 |
-
|
1901 |
-
|
1902 |
}
|
1903 |
|
1904 |
// The widget to show todays events in the sidebar
|
1905 |
function widget_init_calendar_upcoming() {
|
1906 |
// Check for required functions
|
1907 |
-
if (!function_exists('
|
1908 |
return;
|
1909 |
|
1910 |
function widget_calendar_upcoming($args) {
|
1911 |
extract($args);
|
1912 |
-
$the_title = get_option('calendar_upcoming_widget_title');
|
|
|
1913 |
$widget_title = empty($the_title) ? __('Upcoming Events','calendar') : $the_title;
|
1914 |
-
$the_events = upcoming_events();
|
1915 |
if ($the_events != '') {
|
1916 |
echo $before_widget;
|
1917 |
echo $before_title . $widget_title . $after_title;
|
@@ -1921,23 +2111,26 @@ function widget_init_calendar_upcoming() {
|
|
1921 |
}
|
1922 |
|
1923 |
function widget_calendar_upcoming_control() {
|
1924 |
-
$widget_title = get_option('calendar_upcoming_widget_title');
|
1925 |
-
|
|
|
1926 |
update_option('calendar_upcoming_widget_title',strip_tags($_POST['calendar_upcoming_widget_title']));
|
|
|
1927 |
}
|
1928 |
?>
|
1929 |
<p>
|
1930 |
<label for="calendar_upcoming_widget_title"><?php _e('Title','calendar'); ?>:<br />
|
1931 |
<input class="widefat" type="text" id="calendar_upcoming_widget_title" name="calendar_upcoming_widget_title" value="<?php echo $widget_title; ?>"/></label>
|
|
|
|
|
1932 |
</p>
|
1933 |
<?php
|
1934 |
}
|
1935 |
|
1936 |
-
|
1937 |
-
|
1938 |
}
|
1939 |
|
1940 |
-
|
1941 |
// Used to draw an event to the screen
|
1942 |
function draw_event($event)
|
1943 |
{
|
@@ -1948,15 +2141,15 @@ function draw_event($event)
|
|
1948 |
// We check for this later
|
1949 |
$display_author = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_author'",0,0);
|
1950 |
$show_cat = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='enable_categories'",0,0);
|
1951 |
-
|
1952 |
if ($show_cat == 'true')
|
1953 |
{
|
1954 |
$sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".mysql_escape_string($event->event_category);
|
1955 |
$cat_details = $wpdb->get_row($sql);
|
1956 |
-
$style = "background-color:
|
1957 |
}
|
1958 |
|
1959 |
-
$header_details
|
1960 |
<span class="event-title-break"></span><br />';
|
1961 |
if ($event->event_time != "00:00:00")
|
1962 |
{
|
@@ -1974,243 +2167,194 @@ function draw_event($event)
|
|
1974 |
if ($event->event_link != '') { $linky = stripslashes($event->event_link); }
|
1975 |
else { $linky = '#'; }
|
1976 |
|
1977 |
-
$details = '<span class="calnk"><a href="'.$linky.'"
|
1978 |
|
1979 |
return $details;
|
1980 |
}
|
1981 |
|
1982 |
// Grab all events for the requested date from calendar
|
1983 |
-
function grab_events($y,$m,$d,$typing)
|
1984 |
{
|
1985 |
-
|
1986 |
|
1987 |
$arr_events = array();
|
1988 |
|
1989 |
// Get the date format right
|
1990 |
$date = $y . '-' . $m . '-' . $d;
|
1991 |
-
|
1992 |
-
// Firstly we check for conventional events. These will form the first instance of a recurring event
|
1993 |
-
// or the only instance of a one-off event
|
1994 |
-
$events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_begin <= '$date' AND event_end >= '$date' AND event_recur = 'S' ORDER BY event_id");
|
1995 |
-
if (!empty($events))
|
1996 |
-
{
|
1997 |
-
foreach($events as $event)
|
1998 |
-
{
|
1999 |
-
array_push($arr_events, $event);
|
2000 |
-
}
|
2001 |
-
}
|
2002 |
-
|
2003 |
-
// Even if there were results for that query, we may still have events recurring
|
2004 |
-
// from the past on this day. We now methodically check the for these events
|
2005 |
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
// Deal with forever recurring year events unioned with those that have a limit
|
2014 |
-
$events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0
|
2015 |
UNION ALL
|
2016 |
-
SELECT
|
2017 |
-
ORDER BY event_id");
|
2018 |
-
|
2019 |
-
if (!empty($events))
|
2020 |
-
{
|
2021 |
-
foreach($events as $event)
|
2022 |
-
{
|
2023 |
-
// This is going to get complex so lets setup what we would place in for
|
2024 |
-
// an event so we can drop it in with ease
|
2025 |
-
|
2026 |
-
// Technically we don't care about the years, but we need to find out if the
|
2027 |
-
// event spans the turn of a year so we can deal with it appropriately.
|
2028 |
-
$year_begin = date('Y',strtotime($event->event_begin));
|
2029 |
-
$year_end = date('Y',strtotime($event->event_end));
|
2030 |
-
|
2031 |
-
if ($year_begin == $year_end)
|
2032 |
-
{
|
2033 |
-
if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) &&
|
2034 |
-
date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
|
2035 |
-
{
|
2036 |
-
array_push($arr_events, $event);
|
2037 |
-
}
|
2038 |
-
}
|
2039 |
-
else if ($year_begin < $year_end)
|
2040 |
-
{
|
2041 |
-
if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) ||
|
2042 |
-
date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
|
2043 |
-
{
|
2044 |
-
array_push($arr_events, $event);
|
2045 |
-
}
|
2046 |
-
}
|
2047 |
-
}
|
2048 |
-
}
|
2049 |
-
|
2050 |
-
|
2051 |
-
/*
|
2052 |
-
The monthly code - just as easy because as long as the day of the month is correct, then we
|
2053 |
-
show the event
|
2054 |
-
*/
|
2055 |
-
|
2056 |
-
// The monthly events that never stop recurring unioned with those that do
|
2057 |
-
$events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0
|
2058 |
-
UNION ALL
|
2059 |
-
SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM event_begin))) <= event_repeats
|
2060 |
-
ORDER BY event_id");
|
2061 |
-
if (!empty($events))
|
2062 |
-
{
|
2063 |
-
foreach($events as $event)
|
2064 |
-
{
|
2065 |
-
// This is going to get complex so lets setup what we would place in for
|
2066 |
-
// an event so we can drop it in with ease
|
2067 |
-
|
2068 |
-
// Technically we don't care about the years or months, but we need to find out if the
|
2069 |
-
// event spans the turn of a year or month so we can deal with it appropriately.
|
2070 |
-
$month_begin = date('m',strtotime($event->event_begin));
|
2071 |
-
$month_end = date('m',strtotime($event->event_end));
|
2072 |
-
|
2073 |
-
if (($month_begin == $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2074 |
-
{
|
2075 |
-
if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
|
2076 |
-
date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
|
2077 |
-
{
|
2078 |
-
array_push($arr_events, $event);
|
2079 |
-
}
|
2080 |
-
}
|
2081 |
-
else if (($month_begin < $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2082 |
-
{
|
2083 |
-
if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
|
2084 |
-
date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
|
2085 |
-
{
|
2086 |
-
array_push($arr_events, $event);
|
2087 |
-
}
|
2088 |
-
}
|
2089 |
-
}
|
2090 |
-
}
|
2091 |
-
|
2092 |
-
|
2093 |
-
/*
|
2094 |
-
The month of Sundays code - events that repeat on every nth instance of a day
|
2095 |
-
*/
|
2096 |
-
|
2097 |
-
// The month of Sundays events that never stop recurring unioned with those that do
|
2098 |
-
$events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'U' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM event_begin) AND event_repeats = 0
|
2099 |
UNION ALL
|
2100 |
-
SELECT
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
$day_end_event = date('D',strtotime($event->event_end));
|
2115 |
-
$current_day = date('D',strtotime($date));
|
2116 |
-
$orig_diff = strtotime($event->event_end) - strtotime($event->event_begin);
|
2117 |
-
$cur_strto = strtotime($date);
|
2118 |
-
$plan = array();
|
2119 |
-
$plan['Mon'] = 1;
|
2120 |
-
$plan['Tue'] = 2;
|
2121 |
-
$plan['Wed'] = 3;
|
2122 |
-
$plan['Thu'] = 4;
|
2123 |
-
$plan['Fri'] = 5;
|
2124 |
-
$plan['Sat'] = 6;
|
2125 |
-
$plan['Sun'] = 7;
|
2126 |
-
|
2127 |
-
if (($month_begin == $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2128 |
-
{
|
2129 |
-
if (np_of_day($event->event_begin) == np_of_day($date) && $plan[$day_start_event] == $plan[$current_day])
|
2130 |
-
{
|
2131 |
-
if ($typing == 'calendar') { $cal_no[$event->event_id] = strtotime($date); }
|
2132 |
-
else if ($typing == 'upcoming') { $tod_no[$event->event_id] = strtotime($date); }
|
2133 |
-
else if ($typing == 'todays') { $tod_no[$event->event_id] = strtotime($date); }
|
2134 |
-
}
|
2135 |
-
if ($typing == 'calendar') { $week_no[$event->event_id] = $cal_no[$event->event_id]; }
|
2136 |
-
else if ($typing == 'upcoming') { $week_no[$event->event_id] = $tod_no[$event->event_id]; }
|
2137 |
-
else if ($typing == 'todays') { $week_no[$event->event_id] = $tod_no[$event->event_id]; }
|
2138 |
-
|
2139 |
-
if ((($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
|
2140 |
-
&& ((np_of_day($event->event_begin) == np_of_day($date) && $plan[$day_start_event] == $plan[$current_day] && $cur_strto-$week_no[$event->event_id] <= $orig_diff )
|
2141 |
-
|| (np_of_day($event->event_begin) == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)
|
2142 |
-
|| (np_of_day($event->event_begin)+1 == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)))
|
2143 |
-
{
|
2144 |
-
array_push($arr_events, $event);
|
2145 |
-
}
|
2146 |
-
}
|
2147 |
-
else if (($month_begin < $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2148 |
-
{
|
2149 |
-
if ((($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
|
2150 |
-
&& ((np_of_day($event->event_begin) == np_of_day($date) && $plan[$day_start_event] == $plan[$current_day] && $cur_strto-$week_no[$event->event_id] <= $orig_diff )
|
2151 |
-
|| (np_of_day($event->event_begin) == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)
|
2152 |
-
|| (np_of_day($event->event_begin)+1 == np_of_day($date) && ($plan[$day_start_event] < $plan[$current_day] || $plan[$current_day] <= $plan[$day_end_event]) && $cur_strto-$week_no[$event->event_id] <= $orig_diff)))
|
2153 |
-
{
|
2154 |
-
array_push($arr_events, $event);
|
2155 |
-
}
|
2156 |
-
}
|
2157 |
-
}
|
2158 |
-
}
|
2159 |
-
|
2160 |
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2167 |
|
2168 |
-
// The weekly events that never stop recurring unioned with those that do
|
2169 |
-
$events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats = 0
|
2170 |
-
UNION ALL
|
2171 |
-
SELECT * FROM " . WP_CALENDAR_TABLE . " WHERE event_recur = 'W' AND '$date' >= event_begin AND event_repeats != 0 AND (event_repeats*7) >= (TO_DAYS('$date') - TO_DAYS(event_end))
|
2172 |
-
ORDER BY event_id");
|
2173 |
-
if (!empty($events))
|
2174 |
-
{
|
2175 |
-
foreach($events as $event)
|
2176 |
-
{
|
2177 |
-
// This is going to get complex so lets setup what we would place in for
|
2178 |
-
// an event so we can drop it in with ease
|
2179 |
-
|
2180 |
-
// Now we are going to check to see what day the original event
|
2181 |
-
// fell on and see if the current date is both after it and on
|
2182 |
-
// the correct day. If it is, display the event!
|
2183 |
-
$day_start_event = date('D',strtotime($event->event_begin));
|
2184 |
-
$day_end_event = date('D',strtotime($event->event_end));
|
2185 |
-
$current_day = date('D',strtotime($date));
|
2186 |
-
|
2187 |
-
$plan = array();
|
2188 |
-
$plan['Mon'] = 1;
|
2189 |
-
$plan['Tue'] = 2;
|
2190 |
-
$plan['Wed'] = 3;
|
2191 |
-
$plan['Thu'] = 4;
|
2192 |
-
$plan['Fri'] = 5;
|
2193 |
-
$plan['Sat'] = 6;
|
2194 |
-
$plan['Sun'] = 7;
|
2195 |
-
|
2196 |
-
if ($plan[$day_start_event] > $plan[$day_end_event])
|
2197 |
-
{
|
2198 |
-
if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
|
2199 |
-
{
|
2200 |
-
array_push($arr_events, $event);
|
2201 |
-
}
|
2202 |
-
}
|
2203 |
-
else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event]))
|
2204 |
-
{
|
2205 |
-
if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event]))
|
2206 |
-
{
|
2207 |
-
array_push($arr_events, $event);
|
2208 |
-
}
|
2209 |
-
}
|
2210 |
-
|
2211 |
-
}
|
2212 |
-
}
|
2213 |
-
|
2214 |
return $arr_events;
|
2215 |
}
|
2216 |
|
@@ -2249,12 +2393,9 @@ function calendar_year_comparison($year)
|
|
2249 |
// Actually do the printing of the calendar
|
2250 |
// Compared to searching for and displaying events
|
2251 |
// this bit is really rather easy!
|
2252 |
-
function calendar()
|
2253 |
{
|
2254 |
-
|
2255 |
-
|
2256 |
-
// Clean up
|
2257 |
-
unset($week_no);
|
2258 |
|
2259 |
// Deal with the week not starting on a monday
|
2260 |
if (get_option('start_of_week') == 0)
|
@@ -2279,6 +2420,8 @@ function calendar()
|
|
2279 |
}
|
2280 |
|
2281 |
// Years get funny if we exceed 3000, so we use this check
|
|
|
|
|
2282 |
if ($_GET['yr'] <= 3000 && $_GET['yr'] >= 0 && (int)$_GET['yr'] != 0)
|
2283 |
{
|
2284 |
// This is just plain nasty and all because of permalinks
|
@@ -2312,6 +2455,7 @@ function calendar()
|
|
2312 |
$c_day = date("d",ctwo());
|
2313 |
}
|
2314 |
}
|
|
|
2315 |
// No valid year causes the calendar to default to today
|
2316 |
else
|
2317 |
{
|
@@ -2337,6 +2481,7 @@ function calendar()
|
|
2337 |
$days_in_month = date("t", mktime (0,0,0,$c_month,1,$c_year));
|
2338 |
|
2339 |
// Start the table and add the header and naviagtion
|
|
|
2340 |
$calendar_body .= '
|
2341 |
<table cellspacing="1" cellpadding="0" class="calendar-table">
|
2342 |
';
|
@@ -2385,6 +2530,8 @@ function calendar()
|
|
2385 |
$past = 30;
|
2386 |
$future = 30;
|
2387 |
$fut = 1;
|
|
|
|
|
2388 |
while ($past > 0)
|
2389 |
{
|
2390 |
$p .= ' <option value="';
|
@@ -2448,7 +2595,7 @@ function calendar()
|
|
2448 |
}
|
2449 |
$calendar_body .= '</tr>
|
2450 |
';
|
2451 |
-
|
2452 |
for ($i=1; $i<=$days_in_month;)
|
2453 |
{
|
2454 |
$calendar_body .= '<tr>
|
@@ -2461,16 +2608,15 @@ function calendar()
|
|
2461 |
}
|
2462 |
elseif ($i > $days_in_month )
|
2463 |
{
|
2464 |
-
|
2465 |
}
|
2466 |
-
|
2467 |
if ($go)
|
2468 |
{
|
2469 |
// Colours again, this time for the day numbers
|
2470 |
if (get_option('start_of_week') == 0)
|
2471 |
{
|
2472 |
// This bit of code is for styles believe it or not.
|
2473 |
-
$grabbed_events = grab_events($c_year,$c_month,$i,'calendar');
|
2474 |
$no_events_class = '';
|
2475 |
if (!count($grabbed_events))
|
2476 |
{
|
@@ -2481,7 +2627,7 @@ function calendar()
|
|
2481 |
}
|
2482 |
else
|
2483 |
{
|
2484 |
-
$grabbed_events = grab_events($c_year,$c_month,$i,'calendar');
|
2485 |
$no_events_class = '';
|
2486 |
if (!count($grabbed_events))
|
2487 |
{
|
@@ -2500,34 +2646,251 @@ function calendar()
|
|
2500 |
$calendar_body .= '</tr>
|
2501 |
';
|
2502 |
}
|
|
|
|
|
2503 |
$show_cat = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='enable_categories'",0,0);
|
2504 |
|
2505 |
if ($show_cat == 'true')
|
2506 |
{
|
2507 |
$sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " ORDER BY category_name ASC";
|
2508 |
$cat_details = $wpdb->get_results($sql);
|
2509 |
-
$calendar_body .= '<
|
2510 |
-
<
|
2511 |
-
<tr><td colspan="2"><strong>'.__('Category Key','calendar').'</strong></td></tr>
|
2512 |
';
|
2513 |
foreach($cat_details as $cat_detail)
|
2514 |
{
|
2515 |
-
$calendar_body .= '<tr><td style="background-color:'.$cat_detail->category_colour.'; width:20px; height:20px;"></td
|
|
|
2516 |
}
|
2517 |
$calendar_body .= '</table>
|
2518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2519 |
';
|
2520 |
}
|
2521 |
$calendar_body .= '</table>
|
2522 |
';
|
2523 |
|
2524 |
// A little link to yours truly. See the README if you wish to remove this
|
2525 |
-
$calendar_body .= '<div class="kjo-link" style="visibility:visible !important;display:block !important;"><p>'.__('Calendar
|
2526 |
';
|
2527 |
|
|
|
|
|
|
|
2528 |
// Phew! After that bit of string building, spit it all out.
|
2529 |
// The actual printing is done by the calling function.
|
2530 |
return $calendar_body;
|
|
|
2531 |
}
|
2532 |
|
2533 |
?>
|
5 |
Description: This plugin allows you to display a calendar of all your events and appointments as a page on your site.
|
6 |
Author: Kieran O'Shea
|
7 |
Author URI: http://www.kieranoshea.com
|
8 |
+
Version: 1.3
|
9 |
*/
|
10 |
|
11 |
/* Copyright 2008 Kieran O'Shea (email : kieran@kieranoshea.com)
|
30 |
load_plugin_textdomain( 'calendar','wp-content/plugins/'.$plugin_dir, $plugin_dir);
|
31 |
|
32 |
// Define the tables used in Calendar
|
33 |
+
global $wpdb;
|
34 |
+
define('WP_CALENDAR_TABLE', $wpdb->prefix . 'calendar');
|
35 |
+
define('WP_CALENDAR_CONFIG_TABLE', $wpdb->prefix . 'calendar_config');
|
36 |
+
define('WP_CALENDAR_CATEGORIES_TABLE', $wpdb->prefix . 'calendar_categories');
|
37 |
|
38 |
// Check ensure calendar is installed and install it if not - required for
|
39 |
// the successful operation of most functions called from this point on
|
44 |
|
45 |
// Enable the ability for the calendar to be loaded from pages
|
46 |
add_filter('the_content','calendar_insert');
|
47 |
+
add_filter('the_content','minical_insert');
|
48 |
|
49 |
// Enable the ability for the lists to be loaded from pages
|
50 |
add_filter('the_content','upcoming_insert');
|
59 |
// Add the widgets if we are using version 2.8
|
60 |
add_action('widgets_init', 'widget_init_calendar_today');
|
61 |
add_action('widgets_init', 'widget_init_calendar_upcoming');
|
62 |
+
add_action('widgets_init', 'widget_init_events_calendar');
|
63 |
|
64 |
// Before we get on with the functions, we need to define the initial style used for Calendar
|
65 |
|
141 |
// Function to deal with loading the calendar into pages
|
142 |
function calendar_insert($content)
|
143 |
{
|
144 |
+
if (preg_match('/\{CALENDAR*.+\}/',$content))
|
145 |
{
|
146 |
+
$cat_list = preg_split('/\{CALENDAR\;/',$content);
|
147 |
+
if (sizeof($cat_list) > 1) {
|
148 |
+
$cat_list = preg_split('/\}/',$cat_list[1]);
|
149 |
+
$cat_list = $cat_list[0];
|
150 |
+
$cal_output = calendar($cat_list);
|
151 |
+
} else {
|
152 |
+
$cal_output = calendar();
|
153 |
+
}
|
154 |
+
$content = preg_replace('/\{CALENDAR*.+\}/',$cal_output,$content);
|
155 |
+
}
|
156 |
+
return $content;
|
157 |
+
}
|
158 |
+
|
159 |
+
// Function to show a mini calendar in pages
|
160 |
+
function minical_insert($content)
|
161 |
+
{
|
162 |
+
if (preg_match('/\{MINICAL*.+\}/',$content))
|
163 |
+
{
|
164 |
+
$cat_list= preg_split('/\{MINICAL\;/',$content);
|
165 |
+
if (sizeof($cat_list) > 1) {
|
166 |
+
$cat_list = preg_split('/\}/',$cat_list[1]);
|
167 |
+
$cat_list= $cat_list[0];
|
168 |
+
$cal_output = minical($cat_list);
|
169 |
+
} else {
|
170 |
+
$cal_output = minical();
|
171 |
+
}
|
172 |
+
$content = preg_replace('/\{MINICAL*.+\}/',$cal_output,$content);
|
173 |
}
|
174 |
return $content;
|
175 |
}
|
177 |
// Functions to allow the widgets to be inserted into posts and pages
|
178 |
function upcoming_insert($content)
|
179 |
{
|
180 |
+
if (preg_match('/\{UPCOMING_EVENTS*.+\}/',$content))
|
181 |
{
|
182 |
+
$cat_list= preg_split('/\{UPCOMING_EVENTS\;/',$content);
|
183 |
+
if (sizeof($cat_list) > 1) {
|
184 |
+
$cat_list = preg_split('/\}/',$cat_list[1]);
|
185 |
+
$cat_list= $cat_list[0];
|
186 |
+
$cal_output = '<span class="page-upcoming-events">'.upcoming_events($cat_list).'</span>';
|
187 |
+
} else {
|
188 |
+
$cal_output = '<span class="page-upcoming-events">'.upcoming_events().'</span>';
|
189 |
+
}
|
190 |
+
$content = preg_replace('/\{UPCOMING_EVENTS*.+\}/',$cal_output,$content);
|
191 |
}
|
192 |
return $content;
|
193 |
}
|
194 |
function todays_insert($content)
|
195 |
{
|
196 |
+
if (preg_match('/\{TODAYS_EVENTS*.+\}/',$content))
|
197 |
{
|
198 |
+
$cat_list= preg_split('/\{TODAYS_EVENTS\;/',$content);
|
199 |
+
if (sizeof($cat_list) > 1) {
|
200 |
+
$cat_list = preg_split('/\}/',$cat_list[1]);
|
201 |
+
$cat_list= $cat_list[0];
|
202 |
+
$cal_output = '<span class="page-todays-events">'.todays_events($cat_list).'</span>';
|
203 |
+
} else {
|
204 |
+
$cal_output = '<span class="page-todays-events">'.todays_events().'</span>';
|
205 |
+
}
|
206 |
+
$content = preg_replace('/\{TODAYS_EVENTS*.+\}/',$cal_output,$content);
|
207 |
}
|
208 |
return $content;
|
209 |
}
|
220 |
global $wpdb, $initial_style;
|
221 |
|
222 |
// All this style info will go into the database on a new install
|
223 |
+
// This looks nice in the TwentyTen theme
|
224 |
$initial_style = " .calnk a:hover {
|
225 |
+
background-position:0 0;
|
226 |
+
text-decoration:none;
|
227 |
+
color:#000000;
|
228 |
+
border-bottom:1px dotted #000000;
|
229 |
+
}
|
230 |
.calnk a:visited {
|
231 |
+
text-decoration:none;
|
232 |
+
color:#000000;
|
233 |
+
border-bottom:1px dotted #000000;
|
234 |
+
}
|
235 |
.calnk a {
|
236 |
text-decoration:none;
|
237 |
color:#000000;
|
238 |
border-bottom:1px dotted #000000;
|
239 |
+
}
|
240 |
.calnk a span {
|
241 |
display:none;
|
242 |
+
}
|
243 |
.calnk a:hover span {
|
244 |
color:#333333;
|
245 |
background:#F6F79B;
|
250 |
width:150px;
|
251 |
z-index:100;
|
252 |
line-height:1.2em;
|
253 |
+
}
|
254 |
+
.calendar-table {
|
255 |
+
border:0 !important;
|
256 |
+
width:100% !important;
|
257 |
+
border-collapse:separate !important;
|
258 |
+
border-spacing:2px !important;
|
259 |
+
}
|
260 |
+
.calendar-heading {
|
261 |
height:25px;
|
262 |
text-align:center;
|
263 |
border:1px solid #D6DED5;
|
264 |
background-color:#E4EBE3;
|
265 |
+
}
|
266 |
+
.calendar-next {
|
267 |
width:25%;
|
268 |
text-align:center;
|
269 |
+
}
|
270 |
+
.calendar-prev {
|
271 |
width:25%;
|
272 |
text-align:center;
|
273 |
+
}
|
274 |
+
.calendar-month {
|
275 |
width:50%;
|
276 |
text-align:center;
|
277 |
font-weight:bold;
|
278 |
+
}
|
279 |
+
.normal-day-heading {
|
280 |
text-align:center;
|
281 |
width:25px;
|
282 |
height:25px;
|
283 |
font-size:0.8em;
|
284 |
border:1px solid #DFE6DE;
|
285 |
background-color:#EBF2EA;
|
286 |
+
}
|
287 |
+
.weekend-heading {
|
288 |
text-align:center;
|
289 |
width:25px;
|
290 |
height:25px;
|
292 |
border:1px solid #DFE6DE;
|
293 |
background-color:#EBF2EA;
|
294 |
color:#FF0000;
|
295 |
+
}
|
296 |
+
.day-with-date {
|
297 |
vertical-align:text-top;
|
298 |
text-align:left;
|
299 |
width:60px;
|
300 |
height:60px;
|
301 |
border:1px solid #DFE6DE;
|
302 |
+
}
|
303 |
+
.no-events {
|
304 |
|
305 |
+
}
|
306 |
+
.day-without-date {
|
307 |
width:60px;
|
308 |
height:60px;
|
309 |
border:1px solid #E9F0E8;
|
310 |
+
}
|
311 |
+
span.weekend {
|
312 |
color:#FF0000;
|
313 |
+
}
|
314 |
+
.current-day {
|
315 |
vertical-align:text-top;
|
316 |
text-align:left;
|
317 |
width:60px;
|
318 |
height:60px;
|
319 |
border:1px solid #BFBFBF;
|
320 |
background-color:#E4EBE3;
|
321 |
+
}
|
322 |
+
span.event {
|
323 |
font-size:0.75em;
|
324 |
+
}
|
325 |
+
.kjo-link {
|
326 |
font-size:0.75em;
|
327 |
text-align:center;
|
328 |
+
}
|
329 |
+
.calendar-date-switcher {
|
330 |
height:25px;
|
331 |
text-align:center;
|
332 |
border:1px solid #D6DED5;
|
333 |
background-color:#E4EBE3;
|
334 |
+
}
|
335 |
+
.calendar-date-switcher form {
|
336 |
+
margin:2px;
|
337 |
+
}
|
338 |
+
.calendar-date-switcher input {
|
|
|
339 |
border:1px #D6DED5 solid;
|
340 |
+
margin:0;
|
341 |
+
}
|
342 |
+
.calendar-date-switcher select {
|
343 |
border:1px #D6DED5 solid;
|
344 |
+
margin:0;
|
345 |
+
}
|
346 |
+
.calnk a:hover span span.event-title {
|
|
|
|
|
|
|
|
|
|
|
347 |
padding:0;
|
348 |
text-align:center;
|
349 |
font-weight:bold;
|
350 |
font-size:1.2em;
|
351 |
+
margin-left:0px;
|
352 |
+
}
|
353 |
+
.calnk a:hover span span.event-title-break {
|
354 |
width:96%;
|
355 |
text-align:center;
|
356 |
height:1px;
|
358 |
margin-right:2%;
|
359 |
padding:0;
|
360 |
background-color:#000000;
|
361 |
+
margin-left:0px;
|
362 |
+
}
|
363 |
+
.calnk a:hover span span.event-content-break {
|
364 |
width:96%;
|
365 |
text-align:center;
|
366 |
height:1px;
|
368 |
margin-right:2%;
|
369 |
padding:0;
|
370 |
background-color:#000000;
|
371 |
+
margin-left:0px;
|
372 |
+
}
|
373 |
+
.page-upcoming-events {
|
374 |
font-size:80%;
|
375 |
+
}
|
376 |
+
.page-todays-events {
|
377 |
font-size:80%;
|
378 |
+
}
|
379 |
+
.calendar-table table,tbody,tr,td {
|
380 |
+
margin:0 !important;
|
381 |
+
padding:0 !important;
|
382 |
+
}
|
383 |
+
table.calendar-table {
|
384 |
+
margin-bottom:5px !important;
|
385 |
+
}
|
386 |
+
.cat-key {
|
387 |
+
width:100%;
|
388 |
+
margin-top:30px;
|
389 |
+
padding:5px;
|
390 |
+
border:0 !important;
|
391 |
+
}
|
392 |
+
.cal-separate {
|
393 |
+
border:0 !important;
|
394 |
+
margin-top:10px;
|
395 |
+
}
|
396 |
+
table.cat-key {
|
397 |
+
margin-top:5px !important;
|
398 |
+
border:1px solid #DFE6DE !important;
|
399 |
+
border-collapse:separate !important;
|
400 |
+
border-spacing:4px !important;
|
401 |
+
margin-left:2px !important;
|
402 |
+
width:99.5% !important;
|
403 |
+
margin-bottom:5px !important;
|
404 |
+
}
|
405 |
+
.cat-key td {
|
406 |
+
border:0 !important;
|
407 |
+
}";
|
408 |
|
409 |
|
410 |
// Assume this is not a new install until we prove otherwise
|
470 |
event_repeats INT(3) ,
|
471 |
event_author BIGINT(20) UNSIGNED ,
|
472 |
event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1 ,
|
473 |
+
event_link TEXT ,
|
474 |
PRIMARY KEY (event_id)
|
475 |
)";
|
476 |
$wpdb->get_results($sql);
|
542 |
$wpdb->get_results($sql);
|
543 |
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
|
544 |
$wpdb->get_results($sql);
|
545 |
+
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT";
|
546 |
$wpdb->get_results($sql);
|
547 |
$sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
|
548 |
category_id INT(11) NOT NULL AUTO_INCREMENT,
|
562 |
$wpdb->get_results($sql);
|
563 |
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_category BIGINT(20) UNSIGNED NOT NULL DEFAULT 1";
|
564 |
$wpdb->get_results($sql);
|
565 |
+
$sql = "ALTER TABLE ".WP_CALENDAR_TABLE." ADD COLUMN event_link TEXT ";
|
566 |
$wpdb->get_results($sql);
|
567 |
$sql = "CREATE TABLE " . WP_CALENDAR_CATEGORIES_TABLE . " (
|
568 |
category_id INT(11) NOT NULL AUTO_INCREMENT,
|
579 |
}
|
580 |
|
581 |
// Used on the manage events admin page to display a list of events
|
582 |
+
function wp_events_display_list(){
|
583 |
+
|
584 |
global $wpdb;
|
585 |
|
586 |
$events = $wpdb->get_results("SELECT * FROM " . WP_CALENDAR_TABLE . " ORDER BY event_begin DESC");
|
587 |
|
588 |
if ( !empty($events) )
|
589 |
{
|
590 |
+
?>
|
591 |
+
<table class="widefat page fixed" width="100%" cellpadding="3" cellspacing="3">
|
592 |
<thead>
|
593 |
<tr>
|
594 |
<th class="manage-column" scope="col"><?php _e('ID','calendar') ?></th>
|
604 |
<th class="manage-column" scope="col"><?php _e('Delete','calendar') ?></th>
|
605 |
</tr>
|
606 |
</thead>
|
607 |
+
<?php
|
608 |
$class = '';
|
609 |
foreach ( $events as $event )
|
610 |
{
|
814 |
<tr>
|
815 |
<td><legend><?php _e('Recurring Events','calendar'); ?></legend></td>
|
816 |
<td> <?php
|
817 |
+
if (isset($data)) {
|
818 |
+
if ($data->event_repeats != NULL)
|
819 |
+
{
|
820 |
$repeats = $data->event_repeats;
|
821 |
+
}
|
822 |
+
else
|
823 |
+
{
|
824 |
+
$repeats = 0;
|
825 |
+
}
|
826 |
}
|
827 |
else
|
828 |
{
|
829 |
$repeats = 0;
|
830 |
}
|
831 |
|
832 |
+
$selected_s = '';
|
833 |
+
$selected_w = '';
|
834 |
+
$selected_m = '';
|
835 |
+
$selected_y = '';
|
836 |
+
$selected_u = '';
|
837 |
+
if (isset($data)) {
|
838 |
if ($data->event_recur == "S")
|
839 |
{
|
840 |
$selected_s = 'selected="selected"';
|
855 |
{
|
856 |
$selected_u = 'selected="selected"';
|
857 |
}
|
858 |
+
}
|
859 |
?>
|
860 |
<?php _e('Repeats for','calendar'); ?>
|
861 |
<input type="text" name="event_repeats" class="input" size="1" value="<?php echo $repeats; ?>" />
|
941 |
if ((preg_match($date_format_one,$begin) || preg_match($date_format_two,$begin)) && (preg_match($date_format_one,$end) || preg_match($date_format_two,$end)))
|
942 |
{
|
943 |
// We know we have a valid year and month and valid integers for days so now we do a final check on the date
|
944 |
+
$begin_split = explode('-',$begin);
|
945 |
$begin_y = $begin_split[0];
|
946 |
$begin_m = $begin_split[1];
|
947 |
$begin_d = $begin_split[2];
|
948 |
+
$end_split = explode('-',$end);
|
949 |
$end_y = $end_split[0];
|
950 |
$end_m = $end_split[1];
|
951 |
$end_d = $end_split[2];
|
1036 |
<div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
|
1037 |
<?php
|
1038 |
}
|
1039 |
+
if (isset($start_date_ok) && isset($end_date_ok) && isset($time_ok) && isset($url_ok) && isset($title_ok) && isset($recurring_ok))
|
1040 |
{
|
1041 |
$sql = "INSERT INTO " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
|
1042 |
. "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
|
1102 |
if ((preg_match($date_format_one,$begin) || preg_match($date_format_two,$begin)) && (preg_match($date_format_one,$end) || preg_match($date_format_two,$end)))
|
1103 |
{
|
1104 |
// We know we have a valid year and month and valid integers for days so now we do a final check on the date
|
1105 |
+
$begin_split = explode('-',$begin);
|
1106 |
$begin_y = $begin_split[0];
|
1107 |
$begin_m = $begin_split[1];
|
1108 |
$begin_d = $begin_split[2];
|
1109 |
+
$end_split = explode('-',$end);
|
1110 |
$end_y = $end_split[0];
|
1111 |
$end_m = $end_split[1];
|
1112 |
$end_d = $end_split[2];
|
1197 |
<div class="error"><p><strong><?php _e('Error','calendar'); ?>:</strong> <?php _e('The repetition value must be 0 unless a type of recurrance is selected in which case the repetition value must be 0 or higher','calendar'); ?></p></div>
|
1198 |
<?php
|
1199 |
}
|
1200 |
+
if (isset($start_date_ok) && isset($end_date_ok) && isset($time_ok) && isset($url_ok) && isset($title_ok) && isset($recurring_ok))
|
1201 |
{
|
1202 |
$sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_title='" . mysql_escape_string($title)
|
1203 |
. "', event_desc='" . mysql_escape_string($desc) . "', event_begin='" . mysql_escape_string($begin)
|
1277 |
|
1278 |
<div class="wrap">
|
1279 |
<?php
|
1280 |
+
if ( $action == 'edit' || ($action == 'edit_save' && isset($error_with_saving)))
|
1281 |
{
|
1282 |
?>
|
1283 |
<h2><?php _e('Edit Event','calendar'); ?></h2>
|
1380 |
$wpdb->get_results("UPDATE " . WP_CALENDAR_CONFIG_TABLE . " SET config_value = '".$enable_categories."' WHERE config_item='enable_categories'");
|
1381 |
|
1382 |
// Check to see if we are replacing the original style
|
1383 |
+
if (isset($_POST['reset_styles'])) {
|
1384 |
+
if (mysql_escape_string($_POST['reset_styles']) == 'on')
|
1385 |
+
{
|
1386 |
+
$wpdb->get_results("UPDATE " . WP_CALENDAR_CONFIG_TABLE . " SET config_value = '".$initial_style."' WHERE config_item='calendar_style'");
|
1387 |
+
}
|
1388 |
+
}
|
1389 |
|
1390 |
echo "<div class=\"updated\"><p><strong>".__('Settings saved','calendar').".</strong></p></div>";
|
1391 |
}
|
1409 |
}
|
1410 |
}
|
1411 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_author'");
|
1412 |
+
$yes_disp_author = '';
|
1413 |
+
$no_disp_author = '';
|
1414 |
if (!empty($configs))
|
1415 |
{
|
1416 |
foreach ($configs as $config)
|
1426 |
}
|
1427 |
}
|
1428 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_jump'");
|
1429 |
+
$yes_disp_jump = '';
|
1430 |
+
$no_disp_jump = '';
|
1431 |
if (!empty($configs))
|
1432 |
{
|
1433 |
foreach ($configs as $config)
|
1443 |
}
|
1444 |
}
|
1445 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_todays'");
|
1446 |
+
$yes_disp_todays = '';
|
1447 |
+
$no_disp_todays = '';
|
1448 |
if (!empty($configs))
|
1449 |
{
|
1450 |
foreach ($configs as $config)
|
1460 |
}
|
1461 |
}
|
1462 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_upcoming'");
|
1463 |
+
$yes_disp_upcoming = '';
|
1464 |
+
$no_disp_upcoming = '';
|
1465 |
if (!empty($configs))
|
1466 |
{
|
1467 |
foreach ($configs as $config)
|
1485 |
}
|
1486 |
}
|
1487 |
$configs = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_categories'");
|
1488 |
+
$yes_enable_categories = '';
|
1489 |
+
$no_enable_categories = '';
|
1490 |
if (!empty($configs))
|
1491 |
{
|
1492 |
foreach ($configs as $config)
|
1501 |
}
|
1502 |
}
|
1503 |
}
|
1504 |
+
$subscriber_selected = '';
|
1505 |
+
$contributor_selected = '';
|
1506 |
+
$author_selected = '';
|
1507 |
+
$editor_selected = '';
|
1508 |
+
$admin_selected = '';
|
1509 |
if ($allowed_group == 'read') { $subscriber_selected='selected="selected"';}
|
1510 |
else if ($allowed_group == 'edit_posts') { $contributor_selected='selected="selected"';}
|
1511 |
else if ($allowed_group == 'publish_posts') { $author_selected='selected="selected"';}
|
1674 |
}
|
1675 |
else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'edit' && !isset($_POST['mode']))
|
1676 |
{
|
1677 |
+
$sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".int(mysql_escape_string($_GET['category_id']));
|
1678 |
$cur_cat = $wpdb->get_row($sql);
|
1679 |
?>
|
1680 |
<div class="wrap">
|
1710 |
echo "<div class=\"updated\"><p><strong>".__('Category edited successfully','calendar')."</strong></p></div>";
|
1711 |
}
|
1712 |
|
1713 |
+
$get_mode = 0;
|
1714 |
+
$post_mode = 0;
|
1715 |
+
if (isset($_GET['mode'])) {
|
1716 |
+
if ($_GET['mode'] == 'edit') {
|
1717 |
+
$get_mode = 1;
|
1718 |
+
}
|
1719 |
+
}
|
1720 |
+
if (isset($_POST['mode'])) {
|
1721 |
+
if ($_POST['mode'] == 'edit') {
|
1722 |
+
$post_mode = 1;
|
1723 |
+
}
|
1724 |
+
}
|
1725 |
+
if ($get_mode != 1 || $post_mode == 1)
|
1726 |
{
|
1727 |
?>
|
1728 |
|
1802 |
echo '<p>'.__('There are no categories in the database - something has gone wrong!','calendar').'</p>';
|
1803 |
}
|
1804 |
|
1805 |
+
?>
|
1806 |
</div>
|
1807 |
|
1808 |
+
<?php
|
1809 |
}
|
1810 |
}
|
1811 |
|
1822 |
return $instance;
|
1823 |
}
|
1824 |
|
1825 |
+
// Function to provide date of the nth day passed (eg. 2nd Sunday)
|
1826 |
+
function dt_of_sun($date,$instance,$day)
|
1827 |
+
{
|
1828 |
+
$plan = array();
|
1829 |
+
$plan['Mon'] = 1;
|
1830 |
+
$plan['Tue'] = 2;
|
1831 |
+
$plan['Wed'] = 3;
|
1832 |
+
$plan['Thu'] = 4;
|
1833 |
+
$plan['Fri'] = 5;
|
1834 |
+
$plan['Sat'] = 6;
|
1835 |
+
$plan['Sun'] = 7;
|
1836 |
+
$proper_date = date('Y-m-d',strtotime($date));
|
1837 |
+
$begin_month = substr($proper_date,0,8).'01';
|
1838 |
+
$offset = $plan[date('D',strtotime($begin_month))];
|
1839 |
+
$result_day = 0;
|
1840 |
+
$recon = 0;
|
1841 |
+
if (($day-($offset)) < 0) { $recon = 7; }
|
1842 |
+
if ($instance == 1) { $result_day = $day-($offset-1)+$recon; }
|
1843 |
+
else if ($instance == 2) { $result_day = $day-($offset-1)+$recon+7; }
|
1844 |
+
else if ($instance == 3) { $result_day = $day-($offset-1)+$recon+14; }
|
1845 |
+
else if ($instance == 4) { $result_day = $day-($offset-1)+$recon+21; }
|
1846 |
+
else if ($instance == 5) { $result_day = $day-($offset-1)+$recon+28; }
|
1847 |
+
return substr($proper_date,0,8).$result_day;
|
1848 |
+
}
|
1849 |
+
|
1850 |
// Function to return a prefix which will allow the correct
|
1851 |
// placement of arguments into the query string.
|
1852 |
function permalink_prefix()
|
1866 |
}
|
1867 |
|
1868 |
// Configure the "Next" link in the calendar
|
1869 |
+
function next_link($cur_year,$cur_month,$minical = false)
|
1870 |
{
|
1871 |
$mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec');
|
1872 |
$next_year = $cur_year + 1;
|
1873 |
|
1874 |
if ($cur_month == 12)
|
1875 |
{
|
1876 |
+
if ($minical) { $rlink = ''; } else { $rlink = __('Next','calendar'); }
|
1877 |
+
return '<a href="' . permalink_prefix() . 'month=jan&yr=' . $next_year . '">'.$rlink.' »</a>';
|
1878 |
}
|
1879 |
else
|
1880 |
{
|
1881 |
$next_month = $cur_month + 1;
|
1882 |
$month = $mod_rewrite_months[$next_month];
|
1883 |
+
if ($minical) { $rlink = ''; } else { $rlink = __('Next','calendar'); }
|
1884 |
+
return '<a href="' . permalink_prefix() . 'month='.$month.'&yr=' . $cur_year . '">'.$rlink.' »</a>';
|
1885 |
}
|
1886 |
}
|
1887 |
|
1888 |
// Configure the "Previous" link in the calendar
|
1889 |
+
function prev_link($cur_year,$cur_month,$minical = false)
|
1890 |
{
|
1891 |
$mod_rewrite_months = array(1=>'jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec');
|
1892 |
$last_year = $cur_year - 1;
|
1893 |
|
1894 |
if ($cur_month == 1)
|
1895 |
{
|
1896 |
+
if ($minical) { $llink = ''; } else { $llink = __('Prev','calendar'); }
|
1897 |
+
return '<a href="' . permalink_prefix() . 'month=dec&yr='. $last_year .'">« '.$llink.'</a>';
|
1898 |
}
|
1899 |
else
|
1900 |
{
|
1901 |
$next_month = $cur_month - 1;
|
1902 |
$month = $mod_rewrite_months[$next_month];
|
1903 |
+
if ($minical) { $llink = ''; } else { $llink = __('Prev','calendar'); }
|
1904 |
+
return '<a href="' . permalink_prefix() . 'month='.$month.'&yr=' . $cur_year . '">« '.$llink.'</a>';
|
1905 |
}
|
1906 |
}
|
1907 |
|
1908 |
// Print upcoming events
|
1909 |
+
function upcoming_events($cat_list = '')
|
1910 |
{
|
1911 |
global $wpdb;
|
1912 |
+
|
1913 |
// Find out if we should be displaying upcoming events
|
1914 |
$display = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming'",0,0);
|
1915 |
+
|
1916 |
if ($display == 'true')
|
1917 |
{
|
1918 |
// Get number of days we should go into the future
|
1919 |
$future_days = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_upcoming_days'",0,0);
|
1920 |
$day_count = 1;
|
1921 |
+
|
1922 |
+
$output = '';
|
1923 |
while ($day_count < $future_days+1)
|
1924 |
{
|
1925 |
+
list($y,$m,$d) = explode("-",date("Y-m-d",mktime($day_count*24,0,0,date("m",ctwo()),date("d",ctwo()),date("Y",ctwo()))));
|
1926 |
+
$events = grab_events($y,$m,$d,'upcoming',$cat_list);
|
1927 |
usort($events, "time_cmp");
|
1928 |
if (count($events) != 0) {
|
1929 |
$output .= '<li>'.date_i18n(get_option('date_format'),mktime($day_count*24,0,0,date("m",ctwo()),date("d",ctwo()),date("Y",ctwo()))).'<ul>';
|
1930 |
+
}
|
1931 |
foreach($events as $event)
|
1932 |
{
|
1933 |
if ($event->event_time == '00:00:00') {
|
1955 |
}
|
1956 |
|
1957 |
// Print todays events
|
1958 |
+
function todays_events($cat_list = '')
|
1959 |
{
|
1960 |
global $wpdb;
|
1961 |
|
1965 |
if ($display == 'true')
|
1966 |
{
|
1967 |
$output = '<ul>';
|
1968 |
+
$events = grab_events(date("Y",ctwo()),date("m",ctwo()),date("d",ctwo()),'todays',$cat_list);
|
1969 |
usort($events, "time_cmp");
|
1970 |
foreach($events as $event)
|
1971 |
{
|
1999 |
{
|
2000 |
// We need to sort arrays of objects by time
|
2001 |
usort($events, "time_cmp");
|
2002 |
+
$output = '';
|
2003 |
// Now process the events
|
2004 |
foreach($events as $event)
|
2005 |
{
|
2008 |
return $output;
|
2009 |
}
|
2010 |
|
2011 |
+
// The widget to show the mini calendar
|
2012 |
+
function widget_init_events_calendar() {
|
2013 |
+
// Check for required functions
|
2014 |
+
if (!function_exists('wp_register_sidebar_widget'))
|
2015 |
+
return;
|
2016 |
+
|
2017 |
+
function widget_events_calendar($args) {
|
2018 |
+
extract($args);
|
2019 |
+
$the_title = stripslashes(get_option('events_calendar_widget_title'));
|
2020 |
+
$the_cats = stripslashes(get_option('events_calendar_widget_cats'));
|
2021 |
+
$widget_title = empty($the_title) ? __('Calendar','calendar') : $the_title;
|
2022 |
+
$the_events = minical($the_cats);
|
2023 |
+
if ($the_events != '') {
|
2024 |
+
echo $before_widget;
|
2025 |
+
echo $before_title . $widget_title . $after_title;
|
2026 |
+
echo '<br />'.$the_events;
|
2027 |
+
echo $after_widget;
|
2028 |
+
}
|
2029 |
+
}
|
2030 |
+
|
2031 |
+
function widget_events_calendar_control() {
|
2032 |
+
$widget_title = stripslashes(get_option('events_calendar_widget_title'));
|
2033 |
+
$widget_cats = stripslashes(get_option('events_calendar_widget_cats'));
|
2034 |
+
if (isset($_POST['events_calendar_widget_title']) || isset($_POST['events_calendar_widget_cats'])) {
|
2035 |
+
update_option('events_calendar_widget_title',strip_tags($_POST['events_calendar_widget_title']));
|
2036 |
+
update_option('events_calendar_widget_cats',strip_tags($_POST['events_calendar_widget_cats']));
|
2037 |
+
}
|
2038 |
+
?>
|
2039 |
+
<p>
|
2040 |
+
<label for="events_calendar_widget_title"><?php _e('Title','calendar'); ?>:<br />
|
2041 |
+
<input class="widefat" type="text" id="events_calendar_widget_title" name="events_calendar_widget_title" value="<?php echo $widget_title; ?>"/></label>
|
2042 |
+
<label for="events_calendar_widget_cats"><?php _e('Comma separated category id list','calendar'); ?>:<br />
|
2043 |
+
<input class="widefat" type="text" id="events_calendar_widget_cats" name="events_calendar_widget_cats" value="<?php echo $widget_cats; ?>"/></label>
|
2044 |
+
</p>
|
2045 |
+
<?php
|
2046 |
+
}
|
2047 |
+
|
2048 |
+
wp_register_sidebar_widget('events_calendar',__('Calendar','calendar'),'widget_events_calendar',array('description'=>'A calendar of your events'));
|
2049 |
+
wp_register_widget_control('events_calendar','events_calendar','widget_events_calendar_control');
|
2050 |
+
}
|
2051 |
+
|
2052 |
// The widget to show todays events in the sidebar
|
2053 |
function widget_init_calendar_today() {
|
2054 |
// Check for required functions
|
2055 |
+
if (!function_exists('wp_register_sidebar_widget'))
|
2056 |
return;
|
2057 |
|
2058 |
function widget_calendar_today($args) {
|
2059 |
extract($args);
|
2060 |
+
$the_title = stripslashes(get_option('calendar_today_widget_title'));
|
2061 |
+
$the_cats = stripslashes(get_option('calendar_today_widget_cats'));
|
2062 |
$widget_title = empty($the_title) ? __('Today\'s Events','calendar') : $the_title;
|
2063 |
+
$the_events = todays_events($the_cats);
|
2064 |
if ($the_events != '') {
|
2065 |
echo $before_widget;
|
2066 |
echo $before_title . $widget_title . $after_title;
|
2070 |
}
|
2071 |
|
2072 |
function widget_calendar_today_control() {
|
2073 |
+
$widget_title = stripslashes(get_option('calendar_today_widget_title'));
|
2074 |
+
$widget_cats = stripslashes(get_option('calendar_today_widget_cats'));
|
2075 |
+
if (isset($_POST['calendar_today_widget_title']) || isset($_POST['calendar_today_widget_cats'])) {
|
2076 |
update_option('calendar_today_widget_title',strip_tags($_POST['calendar_today_widget_title']));
|
2077 |
+
update_option('calendar_today_widget_cats',strip_tags($_POST['calendar_today_widget_cats']));
|
2078 |
}
|
2079 |
?>
|
2080 |
<p>
|
2081 |
<label for="calendar_today_widget_title"><?php _e('Title','calendar'); ?>:<br />
|
2082 |
<input class="widefat" type="text" id="calendar_today_widget_title" name="calendar_today_widget_title" value="<?php echo $widget_title; ?>"/></label>
|
2083 |
+
<label for="calendar_today_widget_cats"><?php _e('Comma separated category id list','calendar'); ?>:<br />
|
2084 |
+
<input class="widefat" type="text" id="calendar_today_widget_cats" name="calendar_today_widget_cats" value="<?php echo $widget_cats; ?>"/></label>
|
2085 |
</p>
|
2086 |
<?php
|
2087 |
}
|
2088 |
|
2089 |
+
wp_register_sidebar_widget('todays_events_calendar',__('Today\'s Events','calendar'),'widget_calendar_today',array('description'=>'A list of your events today'));
|
2090 |
+
wp_register_widget_control('todays_events_calendar','todays_events_calendar','widget_calendar_today_control');
|
2091 |
}
|
2092 |
|
2093 |
// The widget to show todays events in the sidebar
|
2094 |
function widget_init_calendar_upcoming() {
|
2095 |
// Check for required functions
|
2096 |
+
if (!function_exists('wp_register_sidebar_widget'))
|
2097 |
return;
|
2098 |
|
2099 |
function widget_calendar_upcoming($args) {
|
2100 |
extract($args);
|
2101 |
+
$the_title = stripslashes(get_option('calendar_upcoming_widget_title'));
|
2102 |
+
$the_cats = stripslashes(get_option('calendar_upcoming_widget_cats'));
|
2103 |
$widget_title = empty($the_title) ? __('Upcoming Events','calendar') : $the_title;
|
2104 |
+
$the_events = upcoming_events($the_cats);
|
2105 |
if ($the_events != '') {
|
2106 |
echo $before_widget;
|
2107 |
echo $before_title . $widget_title . $after_title;
|
2111 |
}
|
2112 |
|
2113 |
function widget_calendar_upcoming_control() {
|
2114 |
+
$widget_title = stripslashes(get_option('calendar_upcoming_widget_title'));
|
2115 |
+
$widget_cats = stripslashes(get_option('calendar_upcoming_widget_cats'));
|
2116 |
+
if (isset($_POST['calendar_upcoming_widget_title']) || isset($_POST['calendar_upcoming_widget_cats'])) {
|
2117 |
update_option('calendar_upcoming_widget_title',strip_tags($_POST['calendar_upcoming_widget_title']));
|
2118 |
+
update_option('calendar_upcoming_widget_cats',strip_tags($_POST['calendar_upcoming_widget_cats']));
|
2119 |
}
|
2120 |
?>
|
2121 |
<p>
|
2122 |
<label for="calendar_upcoming_widget_title"><?php _e('Title','calendar'); ?>:<br />
|
2123 |
<input class="widefat" type="text" id="calendar_upcoming_widget_title" name="calendar_upcoming_widget_title" value="<?php echo $widget_title; ?>"/></label>
|
2124 |
+
<label for="calendar_upcoming_widget_cats"><?php _e('Comma separated category id list','calendar'); ?>:<br />
|
2125 |
+
<input class="widefat" type="text" id="calendar_upcoming_widget_cats" name="calendar_upcoming_widget_cats" value="<?php echo $widget_cats; ?>"/></label>
|
2126 |
</p>
|
2127 |
<?php
|
2128 |
}
|
2129 |
|
2130 |
+
wp_register_sidebar_widget('upcoming_events_calendar',__('Upcoming Events','calendar'),'widget_calendar_upcoming',array('description'=>'A list of your upcoming events'));
|
2131 |
+
wp_register_widget_control('upcoming_events_calendar','upcoming_events_calendar','widget_calendar_upcoming_control');
|
2132 |
}
|
2133 |
|
|
|
2134 |
// Used to draw an event to the screen
|
2135 |
function draw_event($event)
|
2136 |
{
|
2141 |
// We check for this later
|
2142 |
$display_author = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='display_author'",0,0);
|
2143 |
$show_cat = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='enable_categories'",0,0);
|
2144 |
+
$style = '';
|
2145 |
if ($show_cat == 'true')
|
2146 |
{
|
2147 |
$sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".mysql_escape_string($event->event_category);
|
2148 |
$cat_details = $wpdb->get_row($sql);
|
2149 |
+
$style = 'style="background-color:'.stripslashes($cat_details->category_colour).';"';
|
2150 |
}
|
2151 |
|
2152 |
+
$header_details = '<span class="event-title" '.$style.'>'.stripslashes($event->event_title).'</span><br />
|
2153 |
<span class="event-title-break"></span><br />';
|
2154 |
if ($event->event_time != "00:00:00")
|
2155 |
{
|
2167 |
if ($event->event_link != '') { $linky = stripslashes($event->event_link); }
|
2168 |
else { $linky = '#'; }
|
2169 |
|
2170 |
+
$details = '<span class="calnk"><a href="'.$linky.'" '.$style.'>' . stripslashes($event->event_title) . '<span '.$style.'>' . $header_details . '' . stripslashes($event->event_desc) . '</span></a></span>';
|
2171 |
|
2172 |
return $details;
|
2173 |
}
|
2174 |
|
2175 |
// Grab all events for the requested date from calendar
|
2176 |
+
function grab_events($y,$m,$d,$typing,$cat_list = '')
|
2177 |
{
|
2178 |
+
global $wpdb;
|
2179 |
|
2180 |
$arr_events = array();
|
2181 |
|
2182 |
// Get the date format right
|
2183 |
$date = $y . '-' . $m . '-' . $d;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2184 |
|
2185 |
+
// Format the category list
|
2186 |
+
if ($cat_list == '') { $cat_sql = ''; }
|
2187 |
+
else { $cat_sql = 'AND event_category in ('.$cat_list.')'; }
|
2188 |
+
|
2189 |
+
// The collated SQL code
|
2190 |
+
$sql = "SELECT a.*,'Normal' AS type FROM " . WP_CALENDAR_TABLE . " AS a WHERE a.event_begin <= '$date' AND a.event_end >= '$date' AND a.event_recur = 'S' ".$cat_sql."
|
|
|
|
|
|
|
2191 |
UNION ALL
|
2192 |
+
SELECT b.*,'Yearly' AS type FROM " . WP_CALENDAR_TABLE . " AS b WHERE b.event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM b.event_begin) AND b.event_repeats = 0 ".$cat_sql."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2193 |
UNION ALL
|
2194 |
+
SELECT c.*,'Yearly' AS type FROM " . WP_CALENDAR_TABLE . " AS c WHERE c.event_recur = 'Y' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM c.event_begin) AND c.event_repeats != 0 AND (EXTRACT(YEAR FROM '$date')-EXTRACT(YEAR FROM c.event_begin)) <= c.event_repeats ".$cat_sql."
|
2195 |
+
UNION ALL
|
2196 |
+
SELECT d.*,'Monthly' AS type FROM " . WP_CALENDAR_TABLE . " AS d WHERE d.event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM d.event_begin) AND d.event_repeats = 0 ".$cat_sql."
|
2197 |
+
UNION ALL
|
2198 |
+
SELECT e.*,'Monthly' AS type FROM " . WP_CALENDAR_TABLE . " AS e WHERE e.event_recur = 'M' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM e.event_begin) AND e.event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM e.event_begin))) <= e.event_repeats ".$cat_sql."
|
2199 |
+
UNION ALL
|
2200 |
+
SELECT f.*,'MonthSun' AS type FROM " . WP_CALENDAR_TABLE . " AS f WHERE f.event_recur = 'U' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM f.event_begin) AND f.event_repeats = 0 ".$cat_sql."
|
2201 |
+
UNION ALL
|
2202 |
+
SELECT g.*,'MonthSun' AS type FROM " . WP_CALENDAR_TABLE . " AS g WHERE g.event_recur = 'U' AND EXTRACT(YEAR FROM '$date') >= EXTRACT(YEAR FROM g.event_begin) AND g.event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '$date'),EXTRACT(YEAR_MONTH FROM g.event_begin))) <= g.event_repeats ".$cat_sql."
|
2203 |
+
UNION ALL
|
2204 |
+
SELECT h.*,'Weekly' AS type FROM " . WP_CALENDAR_TABLE . " AS h WHERE h.event_recur = 'W' AND '$date' >= h.event_begin AND h.event_repeats = 0 ".$cat_sql."
|
2205 |
+
UNION ALL
|
2206 |
+
SELECT i.*,'Weekly' AS type FROM " . WP_CALENDAR_TABLE . " AS i WHERE i.event_recur = 'W' AND '$date' >= i.event_begin AND i.event_repeats != 0 AND (i.event_repeats*7) >= (TO_DAYS('$date') - TO_DAYS(i.event_end)) ".$cat_sql."
|
2207 |
+
ORDER BY event_id";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2208 |
|
2209 |
+
// Run the collated code
|
2210 |
+
$events =$wpdb->get_results($sql);
|
2211 |
+
if (!empty($events))
|
2212 |
+
{
|
2213 |
+
foreach($events as $event)
|
2214 |
+
{
|
2215 |
+
if ($event->type == 'Normal')
|
2216 |
+
{
|
2217 |
+
array_push($arr_events, $event);
|
2218 |
+
}
|
2219 |
+
else if ($event->type == 'Yearly')
|
2220 |
+
{
|
2221 |
+
// This is going to get complex so lets setup what we would place in for
|
2222 |
+
// an event so we can drop it in with ease
|
2223 |
+
|
2224 |
+
// Technically we don't care about the years, but we need to find out if the
|
2225 |
+
// event spans the turn of a year so we can deal with it appropriately.
|
2226 |
+
$year_begin = date('Y',strtotime($event->event_begin));
|
2227 |
+
$year_end = date('Y',strtotime($event->event_end));
|
2228 |
+
|
2229 |
+
if ($year_begin == $year_end)
|
2230 |
+
{
|
2231 |
+
if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) &&
|
2232 |
+
date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
|
2233 |
+
{
|
2234 |
+
array_push($arr_events, $event);
|
2235 |
+
}
|
2236 |
+
}
|
2237 |
+
else if ($year_begin < $year_end)
|
2238 |
+
{
|
2239 |
+
if (date('m-d',strtotime($event->event_begin)) <= date('m-d',strtotime($date)) ||
|
2240 |
+
date('m-d',strtotime($event->event_end)) >= date('m-d',strtotime($date)))
|
2241 |
+
{
|
2242 |
+
array_push($arr_events, $event);
|
2243 |
+
}
|
2244 |
+
}
|
2245 |
+
}
|
2246 |
+
else if ($event->type == 'Monthly')
|
2247 |
+
{
|
2248 |
+
// This is going to get complex so lets setup what we would place in for
|
2249 |
+
// an event so we can drop it in with ease
|
2250 |
+
|
2251 |
+
// Technically we don't care about the years or months, but we need to find out if the
|
2252 |
+
// event spans the turn of a year or month so we can deal with it appropriately.
|
2253 |
+
$month_begin = date('m',strtotime($event->event_begin));
|
2254 |
+
$month_end = date('m',strtotime($event->event_end));
|
2255 |
+
|
2256 |
+
if (($month_begin == $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2257 |
+
{
|
2258 |
+
if (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) &&
|
2259 |
+
date('d',strtotime($event->event_end)) >= date('d',strtotime($date)))
|
2260 |
+
{
|
2261 |
+
array_push($arr_events, $event);
|
2262 |
+
}
|
2263 |
+
}
|
2264 |
+
else if (($month_begin < $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2265 |
+
{
|
2266 |
+
if ( ($event->event_begin <= date('Y-m-d',strtotime($date))) && (date('d',strtotime($event->event_begin)) <= date('d',strtotime($date)) ||
|
2267 |
+
date('d',strtotime($event->event_end)) >= date('d',strtotime($date))) )
|
2268 |
+
{
|
2269 |
+
array_push($arr_events, $event);
|
2270 |
+
}
|
2271 |
+
}
|
2272 |
+
}
|
2273 |
+
else if ($event->type == 'MonthSun')
|
2274 |
+
{
|
2275 |
+
// This used to be complex but writing the dt_of_sun() function helped loads!
|
2276 |
+
|
2277 |
+
// Technically we don't care about the years or months, but we need to find out if the
|
2278 |
+
// event spans the turn of a year or month so we can deal with it appropriately.
|
2279 |
+
$month_begin = date('m',strtotime($event->event_begin));
|
2280 |
+
$month_end = date('m',strtotime($event->event_end));
|
2281 |
+
|
2282 |
+
// Setup some variables and get some values
|
2283 |
+
$dow = date('w',strtotime($event->event_begin));
|
2284 |
+
if ($dow == 0) { $dow = 7; }
|
2285 |
+
$start_ent_this = dt_of_sun($date,np_of_day($event->event_begin),$dow);
|
2286 |
+
$start_ent_prev = dt_of_sun(date('Y-m-d',strtotime($date.'-1 month')),np_of_day($event->event_begin),$dow);
|
2287 |
+
$len_ent = strtotime($event->event_end)-strtotime($event->event_begin);
|
2288 |
+
|
2289 |
+
// The grunt work
|
2290 |
+
if (($month_begin == $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2291 |
+
{
|
2292 |
+
// The checks
|
2293 |
+
if (strtotime($event->event_begin) <= strtotime($date) && strtotime($event->event_end) >= strtotime($date)) // Handle the first occurance
|
2294 |
+
{
|
2295 |
+
array_push($arr_events, $event);
|
2296 |
+
}
|
2297 |
+
else if (strtotime($start_ent_this) <= strtotime($date) && strtotime($date) <= strtotime($start_ent_this)+$len_ent) // Now remaining items
|
2298 |
+
{
|
2299 |
+
array_push($arr_events, $event);
|
2300 |
+
}
|
2301 |
+
}
|
2302 |
+
else if (($month_begin < $month_end) && (strtotime($event->event_begin) <= strtotime($date)))
|
2303 |
+
{
|
2304 |
+
// The checks
|
2305 |
+
if (strtotime($event->event_begin) <= strtotime($date) && strtotime($event->event_end) >= strtotime($date)) // Handle the first occurance
|
2306 |
+
{
|
2307 |
+
array_push($arr_events, $event);
|
2308 |
+
}
|
2309 |
+
else if (strtotime($start_ent_prev) <= strtotime($date) && strtotime($date) <= strtotime($start_ent_prev)+$len_ent) // Remaining items from prev month
|
2310 |
+
{
|
2311 |
+
array_push($arr_events, $event);
|
2312 |
+
}
|
2313 |
+
else if (strtotime($start_ent_this) <= strtotime($date) && strtotime($date) <= strtotime($start_ent_this)+$len_ent) // Remaining items starting this month
|
2314 |
+
{
|
2315 |
+
array_push($arr_events, $event);
|
2316 |
+
}
|
2317 |
+
}
|
2318 |
+
}
|
2319 |
+
else if ($event->type == 'Weekly')
|
2320 |
+
{
|
2321 |
+
// This is going to get complex so lets setup what we would place in for
|
2322 |
+
// an event so we can drop it in with ease
|
2323 |
+
|
2324 |
+
// Now we are going to check to see what day the original event
|
2325 |
+
// fell on and see if the current date is both after it and on
|
2326 |
+
// the correct day. If it is, display the event!
|
2327 |
+
$day_start_event = date('D',strtotime($event->event_begin));
|
2328 |
+
$day_end_event = date('D',strtotime($event->event_end));
|
2329 |
+
$current_day = date('D',strtotime($date));
|
2330 |
+
|
2331 |
+
$plan = array();
|
2332 |
+
$plan['Mon'] = 1;
|
2333 |
+
$plan['Tue'] = 2;
|
2334 |
+
$plan['Wed'] = 3;
|
2335 |
+
$plan['Thu'] = 4;
|
2336 |
+
$plan['Fri'] = 5;
|
2337 |
+
$plan['Sat'] = 6;
|
2338 |
+
$plan['Sun'] = 7;
|
2339 |
+
|
2340 |
+
if ($plan[$day_start_event] > $plan[$day_end_event])
|
2341 |
+
{
|
2342 |
+
if (($plan[$day_start_event] <= $plan[$current_day]) || ($plan[$current_day] <= $plan[$day_end_event]))
|
2343 |
+
{
|
2344 |
+
array_push($arr_events, $event);
|
2345 |
+
}
|
2346 |
+
}
|
2347 |
+
else if (($plan[$day_start_event] < $plan[$day_end_event]) || ($plan[$day_start_event]== $plan[$day_end_event]))
|
2348 |
+
{
|
2349 |
+
if (($plan[$day_start_event] <= $plan[$current_day]) && ($plan[$current_day] <= $plan[$day_end_event]))
|
2350 |
+
{
|
2351 |
+
array_push($arr_events, $event);
|
2352 |
+
}
|
2353 |
+
}
|
2354 |
+
}
|
2355 |
+
}
|
2356 |
+
}
|
2357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2358 |
return $arr_events;
|
2359 |
}
|
2360 |
|
2393 |
// Actually do the printing of the calendar
|
2394 |
// Compared to searching for and displaying events
|
2395 |
// this bit is really rather easy!
|
2396 |
+
function calendar($cat_list = '')
|
2397 |
{
|
2398 |
+
global $wpdb;
|
|
|
|
|
|
|
2399 |
|
2400 |
// Deal with the week not starting on a monday
|
2401 |
if (get_option('start_of_week') == 0)
|
2420 |
}
|
2421 |
|
2422 |
// Years get funny if we exceed 3000, so we use this check
|
2423 |
+
if (isset($_GET['yr']))
|
2424 |
+
{
|
2425 |
if ($_GET['yr'] <= 3000 && $_GET['yr'] >= 0 && (int)$_GET['yr'] != 0)
|
2426 |
{
|
2427 |
// This is just plain nasty and all because of permalinks
|
2455 |
$c_day = date("d",ctwo());
|
2456 |
}
|
2457 |
}
|
2458 |
+
}
|
2459 |
// No valid year causes the calendar to default to today
|
2460 |
else
|
2461 |
{
|
2481 |
$days_in_month = date("t", mktime (0,0,0,$c_month,1,$c_year));
|
2482 |
|
2483 |
// Start the table and add the header and naviagtion
|
2484 |
+
$calendar_body = '';
|
2485 |
$calendar_body .= '
|
2486 |
<table cellspacing="1" cellpadding="0" class="calendar-table">
|
2487 |
';
|
2530 |
$past = 30;
|
2531 |
$future = 30;
|
2532 |
$fut = 1;
|
2533 |
+
$f = '';
|
2534 |
+
$p = '';
|
2535 |
while ($past > 0)
|
2536 |
{
|
2537 |
$p .= ' <option value="';
|
2595 |
}
|
2596 |
$calendar_body .= '</tr>
|
2597 |
';
|
2598 |
+
$go = FALSE;
|
2599 |
for ($i=1; $i<=$days_in_month;)
|
2600 |
{
|
2601 |
$calendar_body .= '<tr>
|
2608 |
}
|
2609 |
elseif ($i > $days_in_month )
|
2610 |
{
|
2611 |
+
$go = FALSE;
|
2612 |
}
|
|
|
2613 |
if ($go)
|
2614 |
{
|
2615 |
// Colours again, this time for the day numbers
|
2616 |
if (get_option('start_of_week') == 0)
|
2617 |
{
|
2618 |
// This bit of code is for styles believe it or not.
|
2619 |
+
$grabbed_events = grab_events($c_year,$c_month,$i,'calendar',$cat_list);
|
2620 |
$no_events_class = '';
|
2621 |
if (!count($grabbed_events))
|
2622 |
{
|
2627 |
}
|
2628 |
else
|
2629 |
{
|
2630 |
+
$grabbed_events = grab_events($c_year,$c_month,$i,'calendar',$cat_list);
|
2631 |
$no_events_class = '';
|
2632 |
if (!count($grabbed_events))
|
2633 |
{
|
2646 |
$calendar_body .= '</tr>
|
2647 |
';
|
2648 |
}
|
2649 |
+
$calendar_body .= '</table>
|
2650 |
+
';
|
2651 |
$show_cat = $wpdb->get_var("SELECT config_value FROM ".WP_CALENDAR_CONFIG_TABLE." WHERE config_item='enable_categories'",0,0);
|
2652 |
|
2653 |
if ($show_cat == 'true')
|
2654 |
{
|
2655 |
$sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " ORDER BY category_name ASC";
|
2656 |
$cat_details = $wpdb->get_results($sql);
|
2657 |
+
$calendar_body .= '<table class="cat-key">
|
2658 |
+
<tr><td colspan="2" class="cat-key-cell"><strong>'.__('Category Key','calendar').'</strong></td></tr>
|
|
|
2659 |
';
|
2660 |
foreach($cat_details as $cat_detail)
|
2661 |
{
|
2662 |
+
$calendar_body .= '<tr><td style="background-color:'.$cat_detail->category_colour.'; width:20px; height:20px;" class="cat-key-cell"></td>
|
2663 |
+
<td class="cat-key-cell"> '.$cat_detail->category_name.'</td></tr>';
|
2664 |
}
|
2665 |
$calendar_body .= '</table>
|
2666 |
+
';
|
2667 |
+
}
|
2668 |
+
|
2669 |
+
// A little link to yours truly. See the README if you wish to remove this
|
2670 |
+
$calendar_body .= '<div class="kjo-link" style="visibility:visible !important;display:block !important;"><p>'.__('Calendar developed and supported by ', 'calendar').'<a href="http://www.kieranoshea.com">Kieran O\'Shea</a></p></div>
|
2671 |
+
';
|
2672 |
+
|
2673 |
+
// Phew! After that bit of string building, spit it all out.
|
2674 |
+
// The actual printing is done by the calling function.
|
2675 |
+
return $calendar_body;
|
2676 |
+
}
|
2677 |
+
|
2678 |
+
// Used to create a hover will all a day's events in for minical
|
2679 |
+
function minical_draw_events($events,$day_of_week = '')
|
2680 |
+
{
|
2681 |
+
// We need to sort arrays of objects by time
|
2682 |
+
usort($events, "time_cmp");
|
2683 |
+
// Only show anything if there are events
|
2684 |
+
$output = '';
|
2685 |
+
if (count($events)) {
|
2686 |
+
// Setup the wrapper
|
2687 |
+
$output = '<span class="calnk"><a href="#" style="background-color:#F6F79B;">'.$day_of_week.'<span>';
|
2688 |
+
// Now process the events
|
2689 |
+
foreach($events as $event)
|
2690 |
+
{
|
2691 |
+
if ($event->event_time == '00:00:00') { $the_time = 'all day'; } else { $the_time = 'at '.date(get_option('time_format'), strtotime(stripslashes($event->event_time))); }
|
2692 |
+
$output .= '* <strong>'.$event->event_title.'</strong> '.$the_time.'<br />';
|
2693 |
+
}
|
2694 |
+
// The tail
|
2695 |
+
$output .= '</span></a></span>';
|
2696 |
+
} else {
|
2697 |
+
$output .= $day_of_week;
|
2698 |
+
}
|
2699 |
+
return $output;
|
2700 |
+
}
|
2701 |
+
|
2702 |
+
function minical($cat_list = '') {
|
2703 |
+
|
2704 |
+
global $wpdb;
|
2705 |
+
|
2706 |
+
// Deal with the week not starting on a monday
|
2707 |
+
if (get_option('start_of_week') == 0)
|
2708 |
+
{
|
2709 |
+
$name_days = array(1=>__('Su','calendar'),__('Mo','calendar'),__('Tu','calendar'),__('We','calendar'),__('Th','calendar'),__('Fr','calendar'),__('Sa','calendar'));
|
2710 |
+
}
|
2711 |
+
// Choose Monday if anything other than Sunday is set
|
2712 |
+
else
|
2713 |
+
{
|
2714 |
+
$name_days = array(1=>__('Mo','calendar'),__('Tu','calendar'),__('We','calendar'),__('Th','calendar'),__('Fr','calendar'),__('Sa','calendar'),__('Su','calendar'));
|
2715 |
+
}
|
2716 |
+
|
2717 |
+
// Carry on with the script
|
2718 |
+
$name_months = array(1=>__('January','calendar'),__('February','calendar'),__('March','calendar'),__('April','calendar'),__('May','calendar'),__('June','calendar'),__('July','\
|
2719 |
+
calendar'),__('August','calendar'),__('September','calendar'),__('October','calendar'),__('November','calendar'),__('December','calendar'));
|
2720 |
+
|
2721 |
+
// If we don't pass arguments we want a calendar that is relevant to today
|
2722 |
+
if (empty($_GET['month']) || empty($_GET['yr']))
|
2723 |
+
{
|
2724 |
+
$c_year = date("Y",ctwo());
|
2725 |
+
$c_month = date("m",ctwo());
|
2726 |
+
$c_day = date("d",ctwo());
|
2727 |
+
}
|
2728 |
+
|
2729 |
+
// Years get funny if we exceed 3000, so we use this check
|
2730 |
+
if (isset($_GET['yr']))
|
2731 |
+
{
|
2732 |
+
if ($_GET['yr'] <= 3000 && $_GET['yr'] >= 0 && (int)$_GET['yr'] != 0)
|
2733 |
+
{
|
2734 |
+
// This is just plain nasty and all because of permalinks
|
2735 |
+
// which are no longer used, this will be cleaned up soon
|
2736 |
+
if ($_GET['month'] == 'jan' || $_GET['month'] == 'feb' || $_GET['month'] == 'mar' || $_GET['month'] == 'apr' || $_GET['month'] == 'may' || $_GET['month'] == 'jun' || $_GET['month'] == 'jul' || $_GET['month'] == 'aug' || $_GET['month'] == 'sept' || $_GET['month'] == 'oct' || $_GET['month'] == 'nov' || $_GET['month'] == 'dec')
|
2737 |
+
{
|
2738 |
+
|
2739 |
+
// Again nasty code to map permalinks into something
|
2740 |
+
// databases can understand. This will be cleaned up
|
2741 |
+
$c_year = mysql_escape_string($_GET['yr']);
|
2742 |
+
if ($_GET['month'] == 'jan') { $t_month = 1; }
|
2743 |
+
else if ($_GET['month'] == 'feb') { $t_month = 2; }
|
2744 |
+
else if ($_GET['month'] == 'mar') { $t_month = 3; }
|
2745 |
+
else if ($_GET['month'] == 'apr') { $t_month = 4; }
|
2746 |
+
else if ($_GET['month'] == 'may') { $t_month = 5; }
|
2747 |
+
else if ($_GET['month'] == 'jun') { $t_month = 6; }
|
2748 |
+
else if ($_GET['month'] == 'jul') { $t_month = 7; }
|
2749 |
+
else if ($_GET['month'] == 'aug') { $t_month = 8; }
|
2750 |
+
else if ($_GET['month'] == 'sept') { $t_month = 9; }
|
2751 |
+
else if ($_GET['month'] == 'oct') { $t_month = 10; }
|
2752 |
+
else if ($_GET['month'] == 'nov') { $t_month = 11; }
|
2753 |
+
else if ($_GET['month'] == 'dec') { $t_month = 12; }
|
2754 |
+
$c_month = $t_month;
|
2755 |
+
$c_day = date("d",ctwo());
|
2756 |
+
}
|
2757 |
+
// No valid month causes the calendar to default to today
|
2758 |
+
else
|
2759 |
+
{
|
2760 |
+
$c_year = date("Y",ctwo());
|
2761 |
+
$c_month = date("m",ctwo());
|
2762 |
+
$c_day = date("d",ctwo());
|
2763 |
+
}
|
2764 |
+
}
|
2765 |
+
}
|
2766 |
+
// No valid year causes the calendar to default to today
|
2767 |
+
else
|
2768 |
+
{
|
2769 |
+
$c_year = date("Y",ctwo());
|
2770 |
+
$c_month = date("m",ctwo());
|
2771 |
+
$c_day = date("d",ctwo());
|
2772 |
+
}
|
2773 |
+
|
2774 |
+
// Fix the days of the week if week start is not on a monday
|
2775 |
+
if (get_option('start_of_week') == 0)
|
2776 |
+
{
|
2777 |
+
$first_weekday = date("w",mktime(0,0,0,$c_month,1,$c_year));
|
2778 |
+
$first_weekday = ($first_weekday==0?1:$first_weekday+1);
|
2779 |
+
}
|
2780 |
+
// Otherwise assume the week starts on a Monday. Anything other
|
2781 |
+
// than Sunday or Monday is just plain odd
|
2782 |
+
else
|
2783 |
+
{
|
2784 |
+
$first_weekday = date("w",mktime(0,0,0,$c_month,1,$c_year));
|
2785 |
+
$first_weekday = ($first_weekday==0?7:$first_weekday);
|
2786 |
+
}
|
2787 |
+
|
2788 |
+
$days_in_month = date("t", mktime (0,0,0,$c_month,1,$c_year));
|
2789 |
+
|
2790 |
+
// Start the table and add the header and naviagtion
|
2791 |
+
$calendar_body = '';
|
2792 |
+
$calendar_body .= '<div style="width:200px;"><table cellspacing="1" cellpadding="0" class="calendar-table">
|
2793 |
+
';
|
2794 |
+
|
2795 |
+
|
2796 |
+
// The header of the calendar table and the links. Note calls to link functions
|
2797 |
+
$calendar_body .= '<tr>
|
2798 |
+
<td colspan="7" class="calendar-heading" style="height:0;">
|
2799 |
+
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
2800 |
+
<tr>
|
2801 |
+
<td class="calendar-prev">' . prev_link($c_year,$c_month,true) . '</td>
|
2802 |
+
<td class="calendar-month">'.$name_months[(int)$c_month].' '.$c_year.'</td>
|
2803 |
+
<td class="calendar-next">' . next_link($c_year,$c_month,true) . '</td>
|
2804 |
+
</tr>
|
2805 |
+
</table>
|
2806 |
+
</td>
|
2807 |
+
</tr>
|
2808 |
+
';
|
2809 |
+
|
2810 |
+
// Print the headings of the days of the week
|
2811 |
+
$calendar_body .= '<tr>
|
2812 |
+
';
|
2813 |
+
for ($i=1; $i<=7; $i++)
|
2814 |
+
{
|
2815 |
+
// Colours need to be different if the starting day of the week is different
|
2816 |
+
if (get_option('start_of_week') == 0)
|
2817 |
+
{
|
2818 |
+
$calendar_body .= ' <td class="'.($i<7&&$i>1?'normal-day-heading':'weekend-heading').'" style="height:0;">'.$name_days[$i].'</td>
|
2819 |
+
';
|
2820 |
+
}
|
2821 |
+
else
|
2822 |
+
{
|
2823 |
+
$calendar_body .= ' <td class="'.($i<6?'normal-day-heading':'weekend-heading').'" style="height:0;">'.$name_days[$i].'</td>
|
2824 |
+
';
|
2825 |
+
}
|
2826 |
+
}
|
2827 |
+
$calendar_body .= '</tr>
|
2828 |
+
';
|
2829 |
+
$go = FALSE;
|
2830 |
+
for ($i=1; $i<=$days_in_month;)
|
2831 |
+
{
|
2832 |
+
$calendar_body .= '<tr>
|
2833 |
+
';
|
2834 |
+
for ($ii=1; $ii<=7; $ii++)
|
2835 |
+
{
|
2836 |
+
if ($ii==$first_weekday && $i==1)
|
2837 |
+
{
|
2838 |
+
$go = TRUE;
|
2839 |
+
}
|
2840 |
+
elseif ($i > $days_in_month )
|
2841 |
+
{
|
2842 |
+
$go = FALSE;
|
2843 |
+
}
|
2844 |
+
if ($go)
|
2845 |
+
{
|
2846 |
+
// Colours again, this time for the day numbers
|
2847 |
+
if (get_option('start_of_week') == 0)
|
2848 |
+
{
|
2849 |
+
// This bit of code is for styles believe it or not.
|
2850 |
+
$grabbed_events = grab_events($c_year,$c_month,$i,'calendar',$cat_list);
|
2851 |
+
$no_events_class = '';
|
2852 |
+
if (!count($grabbed_events))
|
2853 |
+
{
|
2854 |
+
$no_events_class = ' no-events';
|
2855 |
+
}
|
2856 |
+
$calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'" style="height:0;"><span '.($ii<7&&$ii>1?'':'class="weekend"').'>'.minical_draw_events($grabbed_events,$i++).'</span></td>
|
2857 |
+
';
|
2858 |
+
}
|
2859 |
+
else
|
2860 |
+
{
|
2861 |
+
$grabbed_events = grab_events($c_year,$c_month,$i,'calendar',$cat_list);
|
2862 |
+
$no_events_class = '';
|
2863 |
+
if (!count($grabbed_events))
|
2864 |
+
{
|
2865 |
+
$no_events_class = ' no-events';
|
2866 |
+
}
|
2867 |
+
$calendar_body .= ' <td class="'.(date("Ymd", mktime (0,0,0,$c_month,$i,$c_year))==date("Ymd",ctwo())?'current-day':'day-with-date').$no_events_class.'" style="height:0;"><span '.($ii<6?'':'class="weekend"').'>'.minical_draw_events($grabbed_events,$i++).'</span></td>
|
2868 |
+
';
|
2869 |
+
}
|
2870 |
+
}
|
2871 |
+
else
|
2872 |
+
{
|
2873 |
+
$calendar_body .= ' <td class="day-without-date" style="height:0;"> </td>
|
2874 |
+
';
|
2875 |
+
}
|
2876 |
+
}
|
2877 |
+
$calendar_body .= '</tr>
|
2878 |
';
|
2879 |
}
|
2880 |
$calendar_body .= '</table>
|
2881 |
';
|
2882 |
|
2883 |
// A little link to yours truly. See the README if you wish to remove this
|
2884 |
+
$calendar_body .= '<div class="kjo-link" style="visibility:visible !important;display:block !important;"><p>'.__('Calendar by ', 'calendar').'<a href="http://www.kieranoshea.com">Kieran O\'Shea</a></p></div>
|
2885 |
';
|
2886 |
|
2887 |
+
// Closing div
|
2888 |
+
$calendar_body .= '</div>
|
2889 |
+
';
|
2890 |
// Phew! After that bit of string building, spit it all out.
|
2891 |
// The actual printing is done by the calling function.
|
2892 |
return $calendar_body;
|
2893 |
+
|
2894 |
}
|
2895 |
|
2896 |
?>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: KieranOShea
|
|
3 |
Donate link: http://www.kieranoshea.com
|
4 |
Tags: calendar, dates, times, events
|
5 |
Requires at least: 2.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
A simple but effective Calendar plugin for WordPress that allows you to
|
10 |
manage your events and appointments and display them to the world.
|
3 |
Donate link: http://www.kieranoshea.com
|
4 |
Tags: calendar, dates, times, events
|
5 |
Requires at least: 2.0
|
6 |
+
Tested up to: 3.2.1
|
7 |
+
Stable tag: 1.3
|
8 |
|
9 |
A simple but effective Calendar plugin for WordPress that allows you to
|
10 |
manage your events and appointments and display them to the world.
|