Events Manager - Version 2.1

Version Description

Download this release

Release Info

Developer nutsmuggler
Plugin Icon 128x128 Events Manager
Version 2.1
Comparing to
See all releases

Code changes from version 2.0rc2 to 2.1

dbem.js CHANGED
@@ -29,4 +29,58 @@ function update_booking_data () {
29
$j(document).ready( function() {
30
// Managing bookings delete operations
31
$j('a.bookingdelbutton').click(remove_booking);
32
});
29
$j(document).ready( function() {
30
// Managing bookings delete operations
31
$j('a.bookingdelbutton').click(remove_booking);
32
+ });
33
+
34
+ jQuery(document).ready( function($) {
35
+ jQuery('#mtm_add_tag').click( function(event){
36
+ event.preventDefault();
37
+ //Get All meta rows
38
+ var metas = jQuery('#mtm_body').children();
39
+ //Copy first row and change values
40
+ var metaCopy = jQuery(metas[0]).clone(true);
41
+ newId = metas.length + 1;
42
+ metaCopy.attr('id', 'mtm_'+newId);
43
+ metaCopy.find('a').attr('rel', newId);
44
+ metaCopy.find('[name=mtm_1_ref]').attr({
45
+ name:'mtm_'+newId+'_ref' ,
46
+ value:''
47
+ });
48
+ metaCopy.find('[name=mtm_1_content]').attr({
49
+ name:'mtm_'+newId+'_content' ,
50
+ value:''
51
+ });
52
+ metaCopy.find('[name=mtm_1_name]').attr({
53
+ name:'mtm_'+newId+'_name' ,
54
+ value:''
55
+ });
56
+ //Insert into end of file
57
+ jQuery('#mtm_body').append(metaCopy);
58
+ //Duplicate the last entry, remove values and rename id
59
+ });
60
+
61
+ jQuery('#mtm_body a').click( function(event){
62
+ event.preventDefault();
63
+ //Only remove if there's more than 1 meta tag
64
+ if(jQuery('#mtm_body').children().length > 1){
65
+ //Remove the item
66
+ jQuery(jQuery(this).parent().parent().get(0)).remove();
67
+ //Renumber all the items
68
+ jQuery('#mtm_body').children().each( function(i){
69
+ metaCopy = jQuery(this);
70
+ oldId = metaCopy.attr('id').replace('mtm_','');
71
+ newId = i+1;
72
+ metaCopy.attr('id', 'mtm_'+newId);
73
+ metaCopy.find('a').attr('rel', newId);
74
+ metaCopy.find('[name=mtm_'+ oldId +'_ref]').attr('name', 'mtm_'+newId+'_ref');
75
+ metaCopy.find('[name=mtm_'+ oldId +'_content]').attr('name', 'mtm_'+newId+'_content');
76
+ metaCopy.find('[name=mtm_'+ oldId +'_name]').attr( 'name', 'mtm_'+newId+'_name');
77
+ });
78
+ }else{
79
+ metaCopy = jQuery(jQuery(this).parent().parent().get(0));
80
+ metaCopy.find('[name=mtm_1_ref]').attr('value', '');
81
+ metaCopy.find('[name=mtm_1_content]').attr('value', '');
82
+ metaCopy.find('[name=mtm_1_name]').attr( 'value', '');
83
+ alert("If you don't want any meta tags, just leave the text boxes blank and submit");
84
+ }
85
+ });
86
});
dbem_UI_helpers.php CHANGED
@@ -31,7 +31,7 @@ function dbem_options_input_text($title, $name, $description) {
31
<tr valign="top" id='<?php echo $name;?>_row'>
32
<th scope="row"><?php _e($title, 'dbem') ?></th>
33
<td>
34
- <input name="<?php echo $name ?>" type="text" id="<?php echo $title ?>" style="width: 95%" value="<?php echo get_option($name); ?>" size="45" /><br />
35
<?php _e($description, 'dbem') ?>
36
</td>
37
</tr>
31
<tr valign="top" id='<?php echo $name;?>_row'>
32
<th scope="row"><?php _e($title, 'dbem') ?></th>
33
<td>
34
+ <input name="<?php echo $name ?>" type="text" id="<?php echo $title ?>" style="width: 95%" value="<?php echo htmlspecialchars(get_option($name)); ?>" size="45" /><br />
35
<?php _e($description, 'dbem') ?>
36
</td>
37
</tr>
dbem_calendar.php CHANGED
@@ -1,34 +1,41 @@
1
<?php
2
-
3
function dbem_get_calendar_shortcode($atts) {
4
extract(shortcode_atts(array(
5
'month' => '',
6
'year' => '',
7
), $atts));
8
- $result = dbem_get_calendar("month={$month}&year={$year}&echo=0");
9
return $result;
10
}
11
add_shortcode('events_calendar', 'dbem_get_calendar_shortcode');
12
13
function dbem_get_calendar($args="") {
14
- $defaults = array(
15
'month' => '',
16
- 'echo' => 1
17
- );
18
- $r = wp_parse_args( $args, $defaults );
19
- extract( $r, EXTR_SKIP );
20
$month = $r['month'];
21
$echo = $r['echo'];
22
23
global $wpdb;
24
if(isset($_GET['calmonth']) && $_GET['calmonth'] != '') {
25
- $month = $_GET['calmonth'] ;
26
} else {
27
if ($month == '')
28
$month = date('m');
29
}
30
if(isset($_GET['calyear']) && $_GET['calyear'] != '') {
31
- $year = $_GET['calyear'] ;
32
} else {
33
if ($year == '')
34
$year = date('Y');
@@ -45,15 +52,20 @@ function dbem_get_calendar($args="") {
45
// Figure out which day of the week
46
// the month starts on.
47
$month_start_day = date('D', $month_start);
48
- switch($month_start_day){
49
- case "Sun": $offset = 6; break;
50
- case "Mon": $offset = 0; break;
51
- case "Tue": $offset = 1; break;
52
- case "Wed": $offset = 2; break;
53
- case "Thu": $offset = 3; break;
54
- case "Fri": $offset = 4; break;
55
- case "Sat": $offset = 5; break;
56
- }
57
58
// determine how many days are in the last month.
59
if($month == 1) {
@@ -66,7 +78,7 @@ function dbem_get_calendar($args="") {
66
// Build an array for the current days
67
// in the month
68
for($i = 1; $i <= $num_days_current; $i++){
69
- $num_days_array[] = mktime(0,0,0,date('m'), $i, date('Y'));
70
}
71
// Build an array for the number of days
72
// in last month
@@ -131,8 +143,9 @@ function dbem_get_calendar($args="") {
131
} else {
132
$back_month = $month -1;
133
$back_year = $year;
134
- }
135
- $previous_link = "<a class='prev-month' href=\"".$base_link."calmonth={$back_month}&amp;calyear={$back_year} \">&lt;&lt;</a>";
136
137
if($month == 12){
138
$next_month = 1;
@@ -141,14 +154,26 @@ function dbem_get_calendar($args="") {
141
$next_month = $month + 1;
142
$next_year = $year;
143
}
144
- $next_link = "<a class='next-month' href=\"".$base_link."calmonth={$next_month}&amp;calyear={$next_year} \">&gt;&gt;</a>";
145
- $random = (rand(100,200));
146
- $calendar="<div class='dbem-calendar' id='dbem-calendar-$random'><div style='display:none' class='month_n'>$month</div><div class='year_n' style='display:none' >$year</div>";
147
-
148
- $days_initials = "<td>".dbem_translate_and_trim("Monday")."</td><td>".dbem_translate_and_trim("Tuesday")."</td><td>".dbem_translate_and_trim("Wednesday")."</td><td>".dbem_translate_and_trim("Thursday")."</td><td>".dbem_translate_and_trim("Friday")."</td><td>".dbem_translate_and_trim("Saturday")."</td><td>".dbem_translate_and_trim("Sunday")."</td>\n";
149
150
// Build the heading portion of the calendar table
151
- $calendar .= "<table class='dbem-calendar-table'>\n".
152
"<thead>\n<tr>\n".
153
"<td>$previous_link</td><td class='month_name' colspan='5'>$month_name $year</td><td>$next_link</td>\n".
154
"</tr>\n</thead>\n".
@@ -159,38 +184,41 @@ function dbem_get_calendar($args="") {
159
// Now we break each key of the array
160
// into a week and create a new table row for each
161
// week with the days of that week in the table data
162
-
163
$i = 0;
164
foreach($weeks as $week){
165
- $calendar .= "<tr>\n";
166
- foreach($week as $d){
167
- if($i < $offset_count){ //if it is PREVIOUS month
168
- $calendar .= "<td class='eventless-pre'>$d</td>\n";
169
- }
170
- if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)){ // if it is THIS month
171
- $fullday=$d;
172
$d=date('j', $d);
173
$day_link = "$d";
174
- // Apllying this patch http://davidebenini.it/events-manager-forum/topic.php?id=73; was
175
- //if($date == mktime(0,0,0,$month,$d,$year)){
176
- if(($date == mktime(0,0,0,$month,$d,$year)) && (date('F') == $month_name)) {
177
- $calendar .= "<td class='eventless-today'>$d</td>\n";
178
- } else {
179
- $calendar .= "<td class='eventless'>$day_link</td>\n";
180
}
181
- } elseif(($outset > 0)) { //if it is NEXT month
182
- if(($i >= ($num_weeks * 7) - $outset)){
183
- $calendar .= "<td class='eventless-post'>$d</td>\n";
184
- }
185
- }
186
- $i++;
187
}
188
$calendar .= "</tr>\n";
189
- }
190
191
$calendar .= " </table>\n</div>";
192
193
- // query the database for events in this time span
194
if ($month == 1) {
195
$month_pre=12;
196
$month_post=2;
@@ -211,68 +239,106 @@ function dbem_get_calendar($args="") {
211
$limit_post=date("Y-m-d", mktime(0,0,0,$month_post, 30 , $year_post));
212
$events_table = $wpdb->prefix.EVENTS_TBNAME;
213
$sql = "SELECT event_id,
214
- event_name,
215
- event_start_date,
216
- DATE_FORMAT(event_start_date, '%w') AS 'event_weekday_n',
217
- DATE_FORMAT(event_start_date, '%e') AS 'event_day',
218
- DATE_FORMAT(event_start_date, '%c') AS 'event_month_n',
219
- DATE_FORMAT(event_start_time, '%Y') AS 'event_year',
220
- DATE_FORMAT(event_start_time, '%k') AS 'event_hh',
221
- DATE_FORMAT(event_start_time, '%i') AS 'event_mm'
222
- FROM $events_table WHERE event_start_date BETWEEN '$limit_pre' AND '$limit_post' ORDER BY event_start_date";
223
224
- $events=$wpdb->get_results($sql);
225
226
//----- DEBUG ------------
227
//foreach($events as $event) { //DEBUG
228
// $calendar .= ("$event->event_day / $event->event_month_n - $event->event_name<br/>");
229
//}
230
// ------------------
231
- // inserts the events
232
- // $eventful_months= array();
233
- // if($events){
234
- // foreach($events as $event) {
235
- // if($eventful_months[$event->event_month_n]){
236
- // $eventful_months[$event->event_month_n][] = $event;
237
- // } else {
238
- // $eventful_months[$event->event_month_n] = array($event);
239
- // }
240
- // }
241
- // $eventful_days = array();
242
- // foreach($eventful_months as $month) {
243
- // print_r($month);
244
- // $eventful_days[$month] = array();
245
- //
246
- // foreach($month as $event) {
247
- // // if($eventful_days[$month][$event->event_day]){
248
- // // $eventful_days[$month][$event->event_day][] = $event;
249
- // // } else {
250
- // // $eventful_days[$month][$event->event_day] = array($event);
251
- // // }
252
- //
253
- // }
254
- // }
255
- //
256
- //
257
- //
258
- // }
259
- // print_r("ECCO: <br/><pre>");
260
- // print_r($eventful_days);
261
- // print_r("</pre>");
262
- $events_page = get_option('dbem_events_page');
263
- if($events){
264
- foreach($events as $event) {
265
- if ($event->event_month_n == $month_pre) {
266
- $calendar=str_replace("<td class='eventless-pre'>$event->event_day</td>","<td class='eventful-pre'><a href='?page_id=$events_page&amp;calendar_day="."$event->event_start_date'>$event->event_day</a></td>",$calendar);
267
- } elseif($event->event_month_n == $month_post) {
268
- $calendar=str_replace("<td class='eventless-post'>$event->event_day</td>","<td class='eventful-post'><a href='?page_id=$events_page&amp;calendar_day="."$event->event_start_date'>$event->event_day</a></td>",$calendar);
269
- } elseif($event->event_day == $day) {
270
- $calendar=str_replace("<td class='eventless-today'>$event->event_day</td>","<td class='eventful-today'><a href='?page_id=$events_page&amp;calendar_day="."$event->event_start_date'>$event->event_day</a></td>",$calendar);
271
- } else{
272
- $calendar=str_replace("<td class='eventless'>$event->event_day</td>","<td class='eventful'><a href='?page_id=$events_page&amp;calendar_day="."$event->event_start_date'>$event->event_day</a></td>",$calendar);
273
}
274
}
275
- }
276
$output=$calendar;
277
if ($echo)
278
echo $output;
@@ -334,7 +400,7 @@ function dbem_calendar_style() {
334
</style>
335
<?php
336
}
337
- add_action('wp_head', 'dbem_calendar_style');
338
339
function dbem_translate_and_trim($string, $length = 1) {
340
return substr(__($string), 0, $length);
@@ -353,33 +419,41 @@ function dbem_ajaxize_calendar()
353
function initCalendar() {
354
$j('a.prev-month').click(function(e){
355
e.preventDefault();
356
- tableDiv = $j(this).parents('table').parent();
357
- prevMonthCalendar(tableDiv);
358
} );
359
$j('a.next-month').click(function(e){
360
e.preventDefault();
361
- tableDiv = $j(this).parents('table').parent();
362
- nextMonthCalendar(tableDiv);
363
} );
364
}
365
- function prevMonthCalendar(tableDiv) {
366
month_n = tableDiv.children('div.month_n').html();
367
year_n = tableDiv.children('div.year_n').html();
368
- parseInt(month_n) == 1 ? prevMonth = 12 : prevMonth = parseInt(month_n) - 1 ;
369
- if (parseInt(month_n) == 1)
370
- year_n = parseInt(year_n) -1;
371
- $j.get("<?php bloginfo('url'); ?>", {ajaxCalendar: 'true', calmonth: prevMonth, calyear: year_n}, function(data){
372
tableDiv.html(data);
373
initCalendar();
374
});
375
}
376
- function nextMonthCalendar(tableDiv) {
377
month_n = tableDiv.children('div.month_n').html();
378
year_n = tableDiv.children('div.year_n').html();
379
- parseInt(month_n) == 12 ? nextMonth = 1 : nextMonth = parseInt(month_n) + 1 ;
380
- if (parseInt(month_n) == 12)
381
- year_n = parseInt(year_n) + 1;
382
- $j.get("<?php bloginfo('url'); ?>", {ajaxCalendar: 'true', calmonth: nextMonth, calyear: year_n}, function(data){
383
tableDiv.html(data);
384
initCalendar();
385
});
@@ -388,7 +462,7 @@ function dbem_ajaxize_calendar()
388
// function reloadCalendar(e) {
389
// // e.preventDefault();
390
// console.log($j(this).parents('table'));
391
- // $j.get("<?php bloginfo('url'); ?>", {ajax: 'true'}, function(data){
392
// tableDiv = table.parent();
393
// tableDiv.html(data);
394
// });
@@ -403,9 +477,10 @@ add_action('wp_head', 'dbem_ajaxize_calendar');
403
404
function dbem_filter_calendar_ajax() {
405
if(isset($_GET['ajaxCalendar']) && $_GET['ajaxCalendar'] == true) {
406
- $month = $_GET['month'];
407
- $year = $_GET['year'];
408
- dbem_get_calendar('echo=1');
409
die();
410
}
411
}
@@ -414,7 +489,7 @@ add_action('init','dbem_filter_calendar_ajax');
414
function dbem_full_calendar() {
415
echo "<p>Demo di <code>dbem_full_calendar</code></p>" ;
416
echo '<div id="jMonthCalendar"></div>';
417
- dbem_get_calendar();
418
}
419
420
1
<?php
2
function dbem_get_calendar_shortcode($atts) {
3
extract(shortcode_atts(array(
4
+ 'full' => 0,
5
'month' => '',
6
'year' => '',
7
+ 'long_events' => 0
8
), $atts));
9
+ $result = dbem_get_calendar("full={$full}&month={$month}&year={$year}&echo=0&long_events={$long_events}");
10
return $result;
11
}
12
add_shortcode('events_calendar', 'dbem_get_calendar_shortcode');
13
14
function dbem_get_calendar($args="") {
15
+ $defaults = array(
16
+ 'full' => 0,
17
'month' => '',
18
+ 'echo' => 1,
19
+ 'long_events' => 0
20
+ );
21
+ $r = wp_parse_args( $args, $defaults );
22
+ extract( $r, EXTR_SKIP );
23
+ $full = $r['full'];
24
$month = $r['month'];
25
$echo = $r['echo'];
26
27
+ $week_starts_on_sunday = get_option('dbem_week_starts_sunday');
28
+ $start_of_week = get_option('start_of_week');
29
+
30
global $wpdb;
31
if(isset($_GET['calmonth']) && $_GET['calmonth'] != '') {
32
+ $month = dbem_sanitize_request($_GET['calmonth']) ;
33
} else {
34
if ($month == '')
35
$month = date('m');
36
}
37
if(isset($_GET['calyear']) && $_GET['calyear'] != '') {
38
+ $year = dbem_sanitize_request($_GET['calyear']) ;
39
} else {
40
if ($year == '')
41
$year = date('Y');
52
// Figure out which day of the week
53
// the month starts on.
54
$month_start_day = date('D', $month_start);
55
+
56
+ switch($month_start_day){
57
+ case "Sun": $offset = 0; break;
58
+ case "Mon": $offset = 1; break;
59
+ case "Tue": $offset = 2; break;
60
+ case "Wed": $offset = 3; break;
61
+ case "Thu": $offset = 4; break;
62
+ case "Fri": $offset = 5; break;
63
+ case "Sat": $offset = 6; break;
64
+ }
65
+
66
+ $offset -= $start_of_week;
67
+ if($offset<0)
68
+ $offset += 7;
69
70
// determine how many days are in the last month.
71
if($month == 1) {
78
// Build an array for the current days
79
// in the month
80
for($i = 1; $i <= $num_days_current; $i++){
81
+ $num_days_array[] = mktime(0,0,0,$month, $i, $year);
82
}
83
// Build an array for the number of days
84
// in last month
143
} else {
144
$back_month = $month -1;
145
$back_year = $year;
146
+ }
147
+ $full ? $link_extra_class = "full-link" : $link_extra_class = '';
148
+ $previous_link = "<a class='prev-month $link_extra_class' href=\"".$base_link."calmonth={$back_month}&amp;calyear={$back_year} \">&lt;&lt;</a>";
149
150
if($month == 12){
151
$next_month = 1;
154
$next_month = $month + 1;
155
$next_year = $year;
156
}
157
+ $next_link = "<a class='next-month $link_extra_class' href=\"".$base_link."calmonth={$next_month}&amp;calyear={$next_year} \">&gt;&gt;</a>";
158
+ $random = (rand(100,200));
159
+ $full ? $class = 'dbem-calendar-full' : $class='dbem-calendar';
160
+ $calendar="<div class='$class' id='dbem-calendar-$random'><div style='display:none' class='month_n'>$month</div><div class='year_n' style='display:none' >$year</div>";
161
162
+ $weekdays = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
163
+ $n = 0 ;
164
+ while( $n < $start_of_week ) {
165
+ $last_day = array_shift($weekdays);
166
+ $weekdays[]= $last_day;
167
+ $n++;
168
+ }
169
+
170
+ $days_initials = "";
171
+ foreach($weekdays as $weekday) {
172
+ $days_initials .= "<td>".dbem_translate_and_trim($weekday)."</td>";
173
+ }
174
+ $full ? $fullclass = 'fullcalendar' : $fullclass='';
175
// Build the heading portion of the calendar table
176
+ $calendar .= "<table class='dbem-calendar-table $fullclass'>\n".
177
"<thead>\n<tr>\n".
178
"<td>$previous_link</td><td class='month_name' colspan='5'>$month_name $year</td><td>$next_link</td>\n".
179
"</tr>\n</thead>\n".
184
// Now we break each key of the array
185
// into a week and create a new table row for each
186
// week with the days of that week in the table data
187
+
188
$i = 0;
189
foreach($weeks as $week){
190
+ $calendar .= "<tr>\n";
191
+ foreach($week as $d){
192
+ if($i < $offset_count){ //if it is PREVIOUS month
193
+ $calendar .= "<td class='eventless-pre'>$d</td>\n";
194
+ }
195
+ if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)){ // if it is THIS month
196
+ $fullday=$d;
197
$d=date('j', $d);
198
$day_link = "$d";
199
+ // original :
200
+ //if($date == mktime(0,0,0,$month,$d,$year)){
201
+ // proposed patch (http://davidebenini.it/events-manager-forum/topic.php?id=73 )
202
+ // if(($date == mktime(0,0,0,$month,$d,$year)) && (date('F') == $month_name)) {
203
+ // my solution:
204
+ if($d == date('j') && $month == date('m') && $year == date('Y')) {
205
+ $calendar .= "<td class='eventless-today'>$d</td>\n";
206
+ } else {
207
+ $calendar .= "<td class='eventless'>$day_link</td>\n";
208
+ }
209
+ } elseif(($outset > 0)) { //if it is NEXT month
210
+ if(($i >= ($num_weeks * 7) - $outset)){
211
+ $calendar .= "<td class='eventless-post'>$d</td>\n";
212
}
213
+ }
214
+ $i++;
215
}
216
$calendar .= "</tr>\n";
217
+ }
218
219
$calendar .= " </table>\n</div>";
220
221
+ // query the database for events in this time span
222
if ($month == 1) {
223
$month_pre=12;
224
$month_post=2;
239
$limit_post=date("Y-m-d", mktime(0,0,0,$month_post, 30 , $year_post));
240
$events_table = $wpdb->prefix.EVENTS_TBNAME;
241
$sql = "SELECT event_id,
242
+ event_name,
243
+ event_start_date,
244
+ event_start_time,
245
+ event_end_date,
246
+ DATE_FORMAT(event_start_date, '%w') AS 'event_weekday_n',
247
+ DATE_FORMAT(event_start_date, '%e') AS 'event_day',
248
+ DATE_FORMAT(event_start_date, '%c') AS 'event_month_n',
249
+ DATE_FORMAT(event_start_time, '%Y') AS 'event_year',
250
+ DATE_FORMAT(event_start_time, '%k') AS 'event_hh',
251
+ DATE_FORMAT(event_start_time, '%i') AS 'event_mm'
252
+ FROM $events_table
253
+ WHERE (event_start_date BETWEEN '$limit_pre' AND '$limit_post') OR (event_end_date BETWEEN '$limit_pre' AND '$limit_post') ORDER BY event_start_date";
254
255
+ $events=$wpdb->get_results($sql, ARRAY_A);
256
257
//----- DEBUG ------------
258
//foreach($events as $event) { //DEBUG
259
// $calendar .= ("$event->event_day / $event->event_month_n - $event->event_name<br/>");
260
//}
261
// ------------------
262
+
263
+ $eventful_days= array();
264
+ if($events){
265
+ //Go through the events and slot them into the right d-m index
266
+ foreach($events as $event) {
267
+ if( $long_events ){
268
+ //If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day
269
+ $event_start_date = strtotime($event['event_start_date']);
270
+ $event_end_date = strtotime($event['event_end_date']);
271
+ while( $event_start_date <= $event_end_date ){
272
+ $event_eventful_date = date('Y-m-d', $event_start_date);
273
+ //Only show events on the day that they start
274
+ if( is_array($eventful_days[$event_eventful_date]) ){
275
+ $eventful_days[$event_eventful_date][] = $event;
276
+ } else {
277
+ $eventful_days[$event_eventful_date] = array($event);
278
+ }
279
+ $event_start_date += (60*60*24);
280
+ }
281
+ }else{
282
+ //Only show events on the day that they start
283
+ if( is_array($eventful_days[$event['event_start_date']]) ){
284
+ $eventful_days[$event['event_start_date']][] = $event;
285
+ } else {
286
+ $eventful_days[$event['event_start_date']] = array($event);
287
+ }
288
+ }
289
}
290
}
291
+
292
+ $event_format = get_option('dbem_full_calendar_event_format');
293
+ $event_title_format = get_option('dbem_small_calendar_event_title_format');
294
+ $event_title_separator_format = get_option('dbem_small_calendar_event_title_separator');
295
+ $cells = array() ;
296
+ foreach($eventful_days as $day_key => $events) {
297
+ //Set the date into the key
298
+ $event_date = explode('-', $day_key);
299
+ $cells[$day_key]['day'] = ltrim($event_date[2],'0');
300
+ $cells[$day_key]['month'] = $event_date[1];
301
+ $events_titles = array();
302
+ foreach($events as $event) {
303
+ $events_titles[] = dbem_replace_placeholders($event_title_format, $event);
304
+ }
305
+ $link_title = implode($event_title_separator_format,$events_titles);
306
+
307
+ $events_page_id = get_option('dbem_events_page');
308
+ $event_page_link = get_permalink($events_page_id);
309
+ if (stristr($event_page_link, "?"))
310
+ $joiner = "&amp;";
311
+ else
312
+ $joiner = "?";
313
+
314
+
315
+ $cells[$day_key]['cell'] = "<a title='$link_title' href='".$event_page_link.$joiner."calendar_day={$day_key}'>{$cells[$day_key]['day']}</a>";
316
+ if ($full) {
317
+ $cells[$day_key]['cell'] .= "<ul>";
318
+
319
+ foreach($events as $event) {
320
+ $cells[$day_key]['cell'] .= dbem_replace_placeholders($event_format, $event);
321
+ }
322
+ $cells[$day_key]['cell'] .= "</ul>";
323
+ }
324
+ }
325
+
326
+ // print_r($cells);
327
+
328
+ if($events){
329
+ foreach($cells as $cell) {
330
+ if ($cell['month'] == $month_pre) {
331
+ $calendar=str_replace("<td class='eventless-pre'>".$cell['day']."</td>","<td class='eventful-pre'>".$cell['cell']."</td>",$calendar);
332
+ } elseif($cell['month'] == $month_post) {
333
+ $calendar=str_replace("<td class='eventless-post'>".$cell['day']."</td>","<td class='eventful-post'>".$cell['cell']."</td>",$calendar);
334
+ } elseif($cell['day'] == $day && $cell['month'] == date('m')) {
335
+ $calendar=str_replace("<td class='eventless-today'>".$cell['day']."</td>","<td class='eventful-today'>".$cell['cell']."</td>",$calendar);
336
+ } elseif( $cell['month'] == $month ){
337
+ $calendar=str_replace("<td class='eventless'>".$cell['day']."</td>","<td class='eventful'>".$cell['cell']."</td>",$calendar);
338
+ }
339
+ }
340
+ }
341
+
342
$output=$calendar;
343
if ($echo)
344
echo $output;
400
</style>
401
<?php
402
}
403
+ //add_action('wp_head', 'dbem_calendar_style');
404
405
function dbem_translate_and_trim($string, $length = 1) {
406
return substr(__($string), 0, $length);
419
function initCalendar() {
420
$j('a.prev-month').click(function(e){
421
e.preventDefault();
422
+ tableDiv = $j(this).parents('table').parent();
423
+ ($j(this).hasClass('full-link')) ? fullcalendar = 1 : fullcalendar = 0;
424
+ prevMonthCalendar(tableDiv, fullcalendar);
425
} );
426
$j('a.next-month').click(function(e){
427
e.preventDefault();
428
+ tableDiv = $j(this).parents('table').parent();
429
+ ($j(this).hasClass('full-link')) ? fullcalendar = 1 : fullcalendar = 0;
430
+ nextMonthCalendar(tableDiv, fullcalendar);
431
} );
432
}
433
+ function prevMonthCalendar(tableDiv, fullcalendar) {
434
+ if (fullcalendar === undefined) {
435
+ fullcalendar = 0;
436
+ }
437
month_n = tableDiv.children('div.month_n').html();
438
year_n = tableDiv.children('div.year_n').html();
439
+ parseInt(month_n) == 1 ? prevMonth = 12 : prevMonth = parseInt(month_n,10) - 1 ;
440
+ if (parseInt(month_n,10) == 1)
441
+ year_n = parseInt(year_n,10) -1;
442
+ $j.get("<?php bloginfo('wpurl'); ?>", {ajaxCalendar: 'true', calmonth: prevMonth, calyear: year_n, full: fullcalendar}, function(data){
443
tableDiv.html(data);
444
initCalendar();
445
});
446
}
447
+ function nextMonthCalendar(tableDiv, fullcalendar) {
448
+ if (fullcalendar === undefined) {
449
+ fullcalendar = 0;
450
+ }
451
month_n = tableDiv.children('div.month_n').html();
452
year_n = tableDiv.children('div.year_n').html();
453
+ parseInt(month_n,10) == 12 ? nextMonth = 1 : nextMonth = parseInt(month_n,10) + 1 ;
454
+ if (parseInt(month_n,10) == 12)
455
+ year_n = parseInt(year_n,10) + 1;
456
+ $j.get("<?php bloginfo('wpurl'); ?>", {ajaxCalendar: 'true', calmonth: nextMonth, calyear: year_n, full : fullcalendar}, function(data){
457
tableDiv.html(data);
458
initCalendar();
459
});
462
// function reloadCalendar(e) {
463
// // e.preventDefault();
464
// console.log($j(this).parents('table'));
465
+ // $j.get("<?php bloginfo('wpurl'); ?>", {ajax: 'true'}, function(data){
466
// tableDiv = table.parent();
467
// tableDiv.html(data);
468
// });
477
478
function dbem_filter_calendar_ajax() {
479
if(isset($_GET['ajaxCalendar']) && $_GET['ajaxCalendar'] == true) {
480
+ (isset($_GET['full']) && $_GET['full'] == 1) ? $full = 1 : $full = 0;
481
+ $month = dbem_sanitize_request($_GET['month']);
482
+ $year = dbem_sanitize_request($_GET['year']);
483
+ dbem_get_calendar('echo=1&full='.$full);
484
die();
485
}
486
}
489
function dbem_full_calendar() {
490
echo "<p>Demo di <code>dbem_full_calendar</code></p>" ;
491
echo '<div id="jMonthCalendar"></div>';
492
+ dbem_get_calendar("full=1");
493
}
494
495
dbem_events.php CHANGED
@@ -1,2214 +1,2288 @@
1
- <?php
2
-
3
- function dbem_new_event_page() {
4
-
5
- $title = __ ( "Insert New Event", 'dbem' );
6
- dbem_event_form ( $event, $title, $element );
7
-
8
- }
9
-
10
- function dbem_events_subpanel() {
11
- global $wpdb;
12
- $action = $_GET ['action'];
13
- $action2 = $_GET ['action2'];
14
- $event_ID = $_GET ['event_id'];
15
- $recurrence_ID = $_GET ['recurrence_id'];
16
- $scope = $_GET ['scope'];
17
- $offset = $_GET ['offset'];
18
- $order = $_GET ['order'];
19
- $selectedEvents = $_GET ['events'];
20
-
21
- // Disable Hello to new user if requested
22
- if (isset ( $_GET ['disable_hello_to_user'] ) && $_GET ['disable_hello_to_user'] == 'true')
23
- update_option ( 'dbem_hello_to_user', 0 );
24
-
25
- if ($order == "")
26
- $order = "ASC";
27
- if ($offset == "")
28
- $offset = "0";
29
- $event_table_name = $wpdb->prefix . EVENTS_TBNAME;
30
- // Debug code, to make sure I get the correct page
31
-
32
-
33
- // DELETE action
34
- if ($action == 'deleteEvents') {
35
- // $sql="DELETE FROM ".$event_table_name." WHERE event_id='"."$event_ID"."'";
36
-
37
-
38
- // TODO eventual error if ID in non-existant
39
- //$wpdb->query($sql);
40
- foreach ( $selectedEvents as $event_ID ) {
41
- dbem_delete_event ( $event_ID );
42
- }
43
-
44
- $events = dbem_get_events ( "", "future" );
45
- dbem_events_table ( $events, 10, "Future events" );
46
- }
47
- // UPDATE or CREATE action
48
- if ($action == 'update_event' || $action == 'update_recurrence') {
49
-
50
- $event = array ();
51
- $location = array ();
52
-
53
- $event ['event_name'] = stripslashes ( $_POST [event_name] );
54
- // Set event end time to event time if not valid
55
- // if (!_dbem_is_date_valid($event['event_end_date']))
56
- // $event['event_end_date'] = $event['event-date'];
57
- $event ['event_start_date'] = $_POST [event_date];
58
- $event ['event_end_date'] = $_POST [event_end_date];
59
- //$event['event_start_time'] = $_POST[event_hh].":".$_POST[event_mm].":00";
60
- //$event['event_end_time'] = $_POST[event_end_hh].":".$_POST[event_end_mm].":00";
61
- $event ['event_start_time'] = date ( "G:i:00", strtotime ( $_POST ['event_start_time'] ) );
62
- $event ['event_end_time'] = date ( "G:i:00", strtotime ( $_POST ['event_end_time'] ) );
63
- $recurrence ['recurrence_name'] = $event ['event_name'];
64
- $recurrence ['recurrence_start_date'] = $event ['event_start_date'];
65
- $recurrence ['recurrence_end_date'] = $event ['event_end_date'];
66
- $recurrence ['recurrence_start_time'] = $event ['event_start_time'];
67
- $recurrence ['recurrence_end_time'] = $event ['event_end_time'];
68
- $recurrence ['recurrence_id'] = $_POST [recurrence_id];
69
- $recurrence ['recurrence_freq'] = $_POST [recurrence_freq];
70
- $recurrence ['recurrence_freq'] == 'weekly' ? $recurrence [recurrence_byday] = implode ( ",", $_POST ['recurrence_bydays'] ) : $recurrence ['recurrence_byday'] = $_POST [recurrence_byday];
71
- $_POST ['recurrence_interval'] == "" ? $recurrence ['recurrence_interval'] = 1 : $recurrence ['recurrence_interval'] = $_POST ['recurrence_interval'];
72
- $recurrence ['recurrence_byweekno'] = $_POST [recurrence_byweekno];
73
-
74
- $event ['event_rsvp'] = $_POST ['event_rsvp'];
75
- $event ['event_seats'] = $_POST ['event_seats'];
76
-
77
- if (isset ( $_POST ['event_contactperson_id'] ) && $_POST ['event_contactperson_id'] != '' && $_POST ['event_contactperson_id'] != '-1') {
78
-
79
- $event ['event_contactperson_id'] = $_POST ['event_contactperson_id'];
80
- $recurrence ['event_contactperson_id'] = $_POST ['event_contactperson_id'];
81
- }
82
-
83
- if (! _dbem_is_time_valid ( $event_end_time ))
84
- $event_end_time = $event_time;
85
-
86
- $location ['location_name'] = $_POST [location_name];
87
- $location ['location_address'] = $_POST [location_address];
88
- $location ['location_town'] = $_POST [location_town];
89
- $location ['location_latitude'] = $_POST [location_latitude];
90
- $location ['location_longitude'] = $_POST [location_longitude];
91
- $location ['location_description'] = "";
92
- /* Marcus Begin Edit */
93
- //switched to WP TinyMCE field
94
- //$event ['event_notes'] = stripslashes ( $_POST [event_notes] );
95
- $event ['event_notes'] = stripslashes ( $_POST ['content'] );
96
- /* Marcus End Edit */
97
- $recurrence ['recurrence_notes'] = $event ['event_notes'];
98
- $validation_result = dbem_validate_event ( $event );
99
-
100
- if ($validation_result == "OK") {
101
- // validation successful
102
-
103
- $related_location = dbem_get_identical_location ( $location );
104
- // print_r($related_location);
105
- if ($related_location) {
106
- $event ['location_id'] = $related_location ['location_id'];
107
- $recurrence ['location_id'] = $related_location ['location_id'];
108
- } else {
109
-
110
- $new_location = dbem_insert_location ( $location );
111
- $event ['location_id'] = $new_location ['location_id'];
112
- $recurrence ['location_id'] = $new_location ['location_id'];
113
- //print_r($new_location);
114
-
115
-
116
- }
117
-
118
- if (! $event_ID && ! $recurrence_ID) {
119
- // there isn't anything
120
- if ($_POST ['repeated_event']) {
121
-
122
- //insert new recurrence
123
- dbem_insert_recurrent_event ( $event, $recurrence );
124
- $feedback_message = __ ( 'New recurrent event inserted!', 'dbem' );
125
- } else {
126
- // INSERT new event
127
- $wpdb->insert ( $event_table_name, $event );
128
- $feedback_message = __ ( 'New event successfully inserted!', 'dbem' );
129
- }
130
- } else {
131
- // something exists
132
- if ($recurrence_ID) {
133
- // UPDATE old recurrence
134
- $recurrence ['recurrence_id'] = $recurrence_ID;
135
- //print_r($recurrence);
136
- if (dbem_update_recurrence ( $recurrence ))
137
- $feedback_message = __ ( 'Recurrence updated!', 'dbem' );
138
- else
139
- $feedback_message = __ ( 'Something went wrong with the recurrence update...', 'dbem' );
140
-
141
- } else {
142
- // UPDATE old event
143
- // unlink from recurrence in case it was generated by one
144
- $event ['recurrence_id'] = null;
145
- $where ['event_id'] = $event_ID;
146
- $wpdb->update ( $event_table_name, $event, $where );
147
- $feedback_message = "'" . $event ['event_name'] . "' " . __ ( 'updated', 'dbem' ) . "!";
148
- }
149
- }
150
-
151
- /* Marcus Begin Edit */
152
- //Save the category if selected
153
- if( is_numeric($_POST['event_category_id']) ){
154
- $insert_id = (! $event_ID && ! $recurrence_ID) ? $wpdb->insert_id : $event_ID;
155
- $wpdb->update ( $event_table_name, array("event_category_id" => $_POST['event_category_id']), array('event_id' => $insert_id) );
156
- }
157
- /* Marcus End Edit */
158
-
159
- //$wpdb->query($sql);
160
- echo "<div id='message' class='updated fade'>
161
- <p>$feedback_message</p>
162
- </div>";
163
- $events = dbem_get_events ( "", "future" );
164
- dbem_events_table ( $events, 10, "Future events" );
165
- } else {
166
- // validation unsuccessful
167
-
168
- echo "<div id='message' class='error '>
169
- <p>" . __ ( "Ach, there's a problem here:", "dbem" ) . " $validation_result</p>
170
- </div>";
171
- dbem_event_form ( $event, "Edit event $event_ID", $event_ID );
172
-
173
- }
174
- }
175
- if ($action == 'edit_event') {
176
- if (! $event_ID) {
177
- $title = __ ( "Insert New Event", 'dbem' );
178
- } else {
179
- $event = dbem_get_event ( $event_ID );
180
- $title = __ ( "Edit Event", 'dbem' ) . " '" . $event ['event_name'] . "'";
181
- }
182
-
183
- //$event=$wpdb->get_row($sql, ARRAY_A);
184
- // Enter new events and updates old ones
185
- // DEBUG: echo"Nome: $event->event_name";
186
-
187
-
188
- dbem_event_form ( $event, $title, $event_ID );
189
-
190
- }
191
- /* Marcus Begin Edit */
192
- //Add duplicate event if requested
193
- if ($action == 'duplicate_event') {
194
- dbem_duplicate_event ( $event_ID );
195
- }
196
- /* Marcus End Edit */
197
- if ($action == 'edit_recurrence') {
198
-
199
- $event_ID = $_GET ['recurrence_id'];
200
- $recurrence = dbem_get_recurrence ( $event_ID );
201
- $title = __ ( "Reschedule", 'dbem' ) . " '" . $recurrence ['recurrence_name'] . "'";
202
- dbem_event_form ( $recurrence, $title, $event_ID );
203
-
204
- }
205
-
206
- if ($action == 'update_recurrence') {
207
- //print_r($recurrence);
208
- //die('update recurrence!');
209
- }
210
-
211
- if ($action == "-1" || $action == "") {
212
- // No action, only showing the events list
213
-
214
-
215
- switch ($scope) {
216
- case "past" :
217
- $title = __ ( 'Past Events', 'dbem' );
218
- break;
219
- case "all" :
220
- $title = __ ( 'All Events', 'dbem' );
221
- break;
222
- default :
223
- $title = __ ( 'Future Events', 'dbem' );
224
- $scope = "future";
225
- }
226
- $limit = 20;
227
- $events = dbem_get_events ( $limit, $scope, $order, $offset );
228
-
229
- dbem_events_table ( $events, $limit, $title );
230
-
231
- }
232
-
233
- }
234
- // array of all pages, bypasses the filter I set up :)
235
- function dbem_get_all_pages() {
236
- global $wpdb;
237
- $query = "SELECT id, post_title FROM " . $wpdb->prefix . "posts WHERE post_type = 'page';";
238
- $pages = $wpdb->get_results ( $query, ARRAY_A );
239
- $output = array ();
240
- foreach ( $pages as $page ) {
241
- $output [$page ['id']] = $page ['post_title'];
242
- }
243
- return $output;
244
- }
245
-
246
- // Function composing the options subpanel
247
- function dbem_options_subpanel() {
248
- // dbem_options_register();
249
-
250
-
251
- ?>
252
- <div class="wrap">
253
- <div id='icon-options-general' class='icon32'><br />
254
- </div>
255
- <h2><?php
256
- _e ( 'Event Manager Options', 'dbem' );
257
- ?></h2>
258
- <form id="dbem_options_form" method="post" action="options.php">
259
- <h3><?php
260
- _e ( 'Events page', 'dbem' );
261
- ?></h3>
262
- <table class="form-table">
263
- <?php
264
- dbem_options_select ( __ ( 'Events page' ), 'dbem_events_page', dbem_get_all_pages (), __ ( 'This option allows you to select which page to use as an events page' ) );
265
- dbem_options_radio_binary ( __ ( 'Display calendar in events page?', 'dbem' ), 'dbem_display_calendar_in_events_page', __ ( 'This options allows to display the calendar in the events page, instead of the default list. It is recommended not to display both the calendar widget and a calendar page.' ) )?>
266
- </table>
267
- <h3><?php
268
- _e ( 'Events format', 'dbem' );
269
- ?></h3>
270
- <table class="form-table">
271
- <?php
272
- /* Marcus Begin Edit */
273
- dbem_options_textarea ( __ ( 'Default event list format', 'dbem' ), 'dbem_event_list_item_format', __ ( 'The format of any events in a list.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_LOCATION</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_NOTES</code>.<br/> Use <code>#_LINKEDNAME</code> for the event name with a link to the given event page.<br/> Use <code>#_EVENTPAGEURL</code> to print the event page URL and make your own customised links.<br/> Use <code>#_LOCATIONPAGEURL</code> to print the location page URL and make your own customised links.<br/>To insert date and time values, use <a href="http://www.php.net/manual/en/function.date.php">PHP time format characters</a> with a <code>#</code> symbol before them, i.e. <code>#m</code>, <code>#M</code>, <code>#j</code>, etc.<br/> For the end time, put <code>#@</code> in front of the character, ie. <code>#@h</code>, <code>#@i</code>, etc.<br/> You can also create a date format without prepending <code>#</code> by wrapping it in #_{} or #@_{} (e.g. <code>#_{d/m/Y}</code>). If there is no end date, the value is not shown.<br/> Feel free to use HTML tags as <code>li</code>, <code>br</code> and so on.', 'dbem' ) );
274
- /* Marcus End Edit */
275
- dbem_options_input_text ( __ ( 'Single event page title format', 'dbem' ), 'dbem_event_page_title_format', __ ( 'The format of a single event page title. Follow the previous formatting instructions.', 'dbem' ) );
276
- dbem_options_textarea ( __ ( 'Default single event format', 'dbem' ), 'dbem_single_event_format', __ ( 'The format of a single event page.<br/>Follow the previous formatting instructions. <br/>Use <code>#_MAP</code> to insert a map.<br/>Use <code>#_CONTACTNAME</code>, <code>#_CONTACTEMAIL</code>, <code>#_CONTACTPHONE</code> to insert respectively the name, e-mail address and phone number of the designated contact person. <br/>Use <code>#_ADDBOOKINGFORM</code> to insert a form to allow the user to respond to your events reserving one or more places (RSVP).<br/> Use <code>#_REMOVEBOOKINGFORM</code> to insert a form where users, inserting their name and e-mail address, can remove their bookings.', 'dbem' ) );
277
- dbem_options_radio_binary ( __ ( 'Show events page in lists?', 'dbem' ), 'dbem_list_events_page', __ ( 'Check this option if you want the events page to appear together with other pages in pages lists.', 'dbem' ) );
278
- dbem_options_input_text ( __ ( 'Events page title', 'dbem' ), 'dbem_events_page_title', __ ( 'The title on the multiple events page.', 'dbem' ) );
279
- dbem_options_input_text ( __ ( 'No events message', 'dbem' ), 'dbem_no_events_message', __ ( 'The message displayed when no events are available.', 'dbem' ) );
280
- dbem_options_textarea ( __ ( 'Map text format', 'dbem' ), 'dbem_map_text_format', __ ( 'The format the text appearing in the event page map cloud.<br/>Follow the previous formatting instructions.', 'dbem' ) );
281
- ?>
282
- </table>
283
-
284
- <h3><?php
285
- _e ( 'Locations format', 'dbem' );
286
- ?></h3>
287
- <table class="form-table"><?php
288
- dbem_options_input_text ( __ ( 'Single location page title format', 'dbem' ), 'dbem_location_page_title_format', __ ( 'The format of a single location page title.<br/>Follow the previous formatting instructions.', 'dbem' ) );
289
- dbem_options_textarea ( __ ( 'Default single location page format', 'dbem' ), 'dbem_single_location_format', __ ( 'The format of a single location page.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_DESCRIPTION</code>.<br/> Use <code>#_MAP</code> to display a map of the event location, and <code>#_IMAGE</code> to display an image of the location.<br/> Use <code>#_NEXTEVENTS</code> to insert a list of the upcoming events, <code>#_PASTEVENTS</code> for a list of past events, <code>#_ALLEVENTS</code> for a list of all events taking place in this location.', 'dbem' ) );
290
- dbem_options_textarea ( __ ( 'Default location baloon format', 'dbem' ), 'dbem_location_baloon_format', __ ( 'The format of of the text appearing in the baloon describing the location in the map.<br/>Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_DESCRIPTION</code> or <code>#_IMAGE</code>.', 'dbem' ) );
291
- dbem_options_textarea ( __ ( 'Default location event list format', 'dbem' ), 'dbem_location_event_list_item_format', __ ( 'The format of the events the list inserted in the location page through the <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> element. <br/> Follow the events formatting instructions', 'dbem' ) );
292
- dbem_options_textarea ( __ ( 'Default no events message', 'dbem' ), 'dbem_location_no_events_message', __ ( 'The message to be displayed in the list generated by <code>#_NEXTEVENTS</code>, <code>#_PASTEVENTS</code> and <code>#_ALLEVENTS</code> when no events are available.', 'dbem' ) );
293
-
294
- ?>
295
- </table>
296
-
297
- <h3><?php
298
- _e ( 'RSS feed format', 'dbem' );
299
- ?></h3>
300
- <table class="form-table"><?php
301
-
302
- dbem_options_input_text ( __ ( 'RSS main title', 'dbem' ), 'dbem_rss_main_title', __ ( 'The main title of your RSS events feed.', 'dbem' ) );
303
- dbem_options_input_text ( __ ( 'RSS main description', 'dbem' ), 'dbem_rss_main_description', __ ( 'The main description of your RSS events feed.', 'dbem' ) );
304
- dbem_options_input_text ( __ ( 'RSS title format', 'dbem' ), 'dbem_rss_title_format', __ ( 'The format of the title of each item in the events RSS feed.', 'dbem' ) );
305
- dbem_options_input_text ( __ ( 'RSS description format', 'dbem' ), 'dbem_rss_description_format', __ ( 'The format of the description of each item in the events RSS feed. Follow the previous formatting instructions.', 'dbem' ) );
306
- ?>
307
- </table>
308
-
309
- <h3><?php
310
- _e ( 'Maps and geotagging', 'dbem' );
311
- ?></h3>
312
- <table class='form-table'>
313
- <?php
314
- $gmap_is_active = get_option ( 'dbem_gmap_is_active' );
315
- ?>
316
-
317
- <tr valign="top">
318
- <th scope="row"><?php
319
- _e ( 'Enable Google Maps integration?', 'dbem' );
320
- ?></th>
321
- <td><input id="dbem_gmap_is_active_yes" name="dbem_gmap_is_active"
322
- type="radio" value="1"
323
- <?php
324
- if ($gmap_is_active)
325
- echo "checked='checked'";
326
- ?> /><?php
327
- _e ( 'Yes' );
328
- ?> <br />
329
- <input name="dbem_gmap_is_active" type="radio" value="0"
330
- <?php
331
- if (! $gmap_is_active)
332
- echo "checked='checked'";
333
- ?> /> <?php
334
- _e ( 'No' );
335
- ?> <br />
336
- <?php
337
- _e ( 'Check this option to enable Goggle Map integration.', 'dbem' )?>
338
- </td>
339
- </tr>
340
- <?php
341
- dbem_options_input_text ( __ ( 'Google Maps API Key', 'dbem' ), 'dbem_gmap_key', sprintf ( __ ( "To display Google Maps you need a Google Maps API key. Don't worry, it's free, you can get one <a href='%s'>here</a>.", 'dbem' ), 'http://code.google.com/apis/maps/signup.html' ) );
342
- ?>
343
- </table>
344
-
345
- <h3><?php
346
- _e ( 'RSVP and bookings', 'dbem' );
347
- ?></h3>
348
- <table class='form-table'>
349
- <?php
350
- dbem_options_select ( __ ( 'Default contact person', 'dbem' ), 'dbem_default_contact_person', dbem_get_indexed_users (), __ ( 'Select the default contact person. This user will be employed whenever a contact person is not explicitly specified for an event', 'dbem' ) );
351
- dbem_options_radio_binary ( __ ( 'Enable the RSVP e-mail notifications?', 'dbem' ), 'dbem_rsvp_mail_notify_is_active', __ ( 'Check this option if you want to receive an email when someone books places for your events.', 'dbem' ) );
352
- dbem_options_textarea ( __ ( 'Contact person email format', 'dbem' ), 'dbem_contactperson_email_body', __ ( 'The format or the email which will be sent to the contact person. Follow the events formatting instructions. <br/>Use <code>#_RESPNAME</code>, <code>#_RESPEMAIL</code> and <code>#_RESPPHONE</code> to display respectively the name, e-mail, address and phone of the respondent.<br/>Use <code>#_SPACES</code> to display the number of spaces reserved by the respondent.<br/> Use <code>#_BOOKEDSEATS</code> and <code>#_AVAILABLESEATS</code> to display respectively the number of booked and available seats.', 'dbem' ) );
353
- dbem_options_textarea ( __ ( 'Contact person email format', 'dbem' ), 'dbem_respondent_email_body', __ ( 'The format or the email which will be sent to reposdent. Follow the events formatting instructions. <br/>Use <code>#_RESPNAME</code> to display the name of the respondent.<br/>Use <code>#_CONTACTNAME</code> and <code>#_CONTACTMAIL</code> a to display respectively the name and e-mail of the contact person.<br/>Use <code>#_SPACES</code> to display the number of spaces reserved by the respondent.', 'dbem' ) );
354
- dbem_options_input_text ( __ ( 'Notification sender name', 'dbem' ), 'dbem_mail_sender_name', __ ( "Insert the display name of the notification sender.", 'dbem' ) );
355
- dbem_options_input_text ( __ ( 'Notification sender address', 'dbem' ), 'dbem_mail_sender_address', __ ( "Insert the address of the notification sender. It must corresponds with your gmail account user", 'dbem' ) );
356
- dbem_options_input_text ( __ ( 'Default notification receiver address', 'dbem' ), 'dbem_mail_receiver_address', __ ( "Insert the address of the receiver of your notifications", 'dbem' ) );
357
- dbem_options_input_text ( 'Mail sending port', 'dbem_rsvp_mail_port', __ ( "The port through which you e-mail notifications will be sent. Make sure the firewall doesn't block this port", 'dbem' ) );
358
- dbem_options_select ( __ ( 'Mail sending method', 'dbem' ), 'dbem_rsvp_mail_send_method', array ('smtp' => 'SMTP', 'mail' => __ ( 'PHP mail function', 'dbem' ), 'sendmail' => 'Sendmail', 'qmail' => 'Qmail' ), __ ( 'Select the method to send email notification.', 'dbem' ) );
359
- dbem_options_radio_binary ( __ ( 'Use SMTP authentication?', 'dbem' ), 'dbem_rsvp_mail_SMTPAuth', __ ( 'SMTP authenticatio is often needed. If you use GMail, make sure to set this parameter to Yes', 'dbem' ) );
360
- dbem_options_input_text ( 'SMTP host', 'dbem_smtp_host', __ ( "The SMTP host. Usually it corresponds to 'localhost'. If you use GMail, set this value to 'ssl://smtp.gmail.com:465'.", 'dbem' ) );
361
- dbem_options_input_text ( __ ( 'SMTP username', 'dbem' ), 'dbem_smtp_username', __ ( "Insert the username to be used to access your SMTP server.", 'dbem' ) );
362
- dbem_options_input_password ( __ ( 'SMTP password', 'dbem' ), "dbem_smtp_password", __ ( "Insert the password to be used to access your SMTP server", 'dbem' ) );
363
- ?>
364
-
365
-
366
-
367
- </table>
368
-
369
- <h3><?php
370
- _e ( 'Images size', 'dbem' );
371
- ?></h3>
372
- <table class='form-table'> <?php
373
- dbem_options_input_text ( __ ( 'Maximum width (px)', 'dbem' ), 'dbem_image_max_width', __ ( 'The maximum allowed width for images uploades', 'dbem' ) );
374
- dbem_options_input_text ( __ ( 'Maximum height (px)', 'dbem' ), 'dbem_image_max_height', __ ( "The maximum allowed width for images uploaded, in pixels", 'dbem' ) );
375
- dbem_options_input_text ( __ ( 'Maximum size (bytes)', 'dbem' ), 'dbem_image_max_size', __ ( "The maximum allowed size for images uploaded, in pixels", 'dbem' ) );
376
- ?>
377
- </table>
378
-
379
-
380
-
381
- <p class="submit"><input type="submit" id="dbem_options_submit"
382
- name="Submit" value="<?php
383
- _e ( 'Save Changes' )?>" /></p>
384
-
385
-
386
- <?php
387
- settings_fields ( 'dbem-options' );
388
- ?>
389
- </form>
390
- </div>
391
- <?php
392
-
393
- }
394
-
395
- //This is the content of the event page
396
- function dbem_events_page_content() {
397
- global $wpdb;
398
- if (isset ( $_REQUEST ['location_id'] ) && $_REQUEST ['location_id'] |= '') {
399
-
400
- $location = dbem_get_location ( $_REQUEST ['location_id'] );
401
- $single_location_format = get_option ( 'dbem_single_location_format' );
402
- $page_body = dbem_replace_locations_placeholders ( $single_location_format, $location );
403
- return $page_body;
404
-
405
- }
406
- if (isset ( $_REQUEST ['event_id'] ) && $_REQUEST ['event_id'] != '') {
407
- // single event page
408
- $event_ID = $_REQUEST ['event_id'];
409
- $event = dbem_get_event ( $event_ID );
410
- $single_event_format = get_option ( 'dbem_single_event_format' );
411
- $page_body = dbem_replace_placeholders ( $single_event_format, $event );
412
- return $page_body;
413
- } elseif (isset ( $_REQUEST ['calendar_day'] ) && $_REQUEST ['calendar_day'] != '') {
414
-
415
- $date = $_REQUEST ['calendar_day'];
416
- $events_N = dbem_events_count_for ( $date );
417
- // $_GET['scope'] ? $scope = $_GET['scope']: $scope = "future";
418
- // $stored_format = get_option('dbem_event_list_item_format');
419
- // $events_body = dbem_get_events_list(10, $scope, "ASC", $stored_format, $false);
420
- if ($events_N > 1) {
421
- $_GET ['calendar_day'] ? $scope = $_GET ['calendar_day'] : $scope = "future";
422
- $stored_format = get_option ( 'dbem_event_list_item_format' );
423
- $events_body = "<ul class='dbem_events_list'>" . dbem_get_events_list ( 10, $scope, "ASC", $stored_format, $false ) . "</ul>";
424
- return $events_body;
425
- } else {
426
- $events = dbem_get_events ( "", $_REQUEST ['calendar_day'] );
427
- $event = $events [0];
428
- $single_event_format = get_option ( 'dbem_single_event_format' );
429
- $page_body = dbem_replace_placeholders ( $single_event_format, $event );
430
- return $page_body;
431
- }
432
- return $events_body;
433
- } else {
434
- // Multiple events page
435
- $_GET ['scope'] ? $scope = $_GET ['scope'] : $scope = "future";
436
- $stored_format = get_option ( 'dbem_event_list_item_format' );
437
- if (get_option ( 'dbem_display_calendar_in_events_page' ))
438
- $events_body = dbem_get_calendar ();
439
- else
440
- $events_body = $events_body = "<ul class='dbem_events_list'>" . dbem_get_events_list ( 10, $scope, "ASC", $stored_format, $false ) . "</ul>";
441
- return $events_body;
442
-
443
- }
444
- }
445
- function dbem_events_count_for($date) {
446
- global $wpdb;
447
- $table_name = $wpdb->prefix . EVENTS_TBNAME;
448
- $sql = "SELECT COUNT(*) FROM $table_name WHERE event_start_date like '$date';";
449
- return $wpdb->get_var ( $sql );
450
- }
451
-
452
- // filter function to call the event page when appropriate
453
- function dbem_filter_events_page($data) {
454
-
455
- // $table_name = $wpdb->prefix .EVENTS_TBNAME;
456
- // $start = strpos($data, DBEM_PAGE);
457
-
458
-
459
- $is_events_post = (get_the_ID () == get_option ( 'dbem_events_page' ));
460
- $events_page_id = get_option ( 'dbem_events_page' );
461
- if (is_page ( $events_page_id ) && $is_events_post) {
462
- return dbem_events_page_content ();
463
- } else {
464
- return $data;
465
- }
466
- }
467
- add_filter ( 'the_content', 'dbem_filter_events_page' );
468
-
469
- function dbem_events_page_title($data) {
470
- $events_page_id = get_option ( 'dbem_events_page' );
471
- $events_page = get_page ( $events_page_id );
472
- $events_page_title = $events_page->post_title;
473
-
474
- if (($data == $events_page_title) && (is_page ( $events_page_id ))) {
475
- if (isset ( $_REQUEST ['calendar_day'] ) && $_REQUEST ['calendar_day'] != '') {
476
-
477
- $date = $_REQUEST ['calendar_day'];
478
- $events_N = dbem_events_count_for ( $date );
479
-
480
- if ($events_N == 1) {
481
- $events = dbem_get_events ( "", $_REQUEST ['calendar_day'] );
482
- $event = $events [0];
483
- $stored_page_title_format = get_option ( 'dbem_event_page_title_format' );
484
- $page_title = dbem_replace_placeholders ( $stored_page_title_format, $event );
485
- return $page_title;
486
- }
487
-
488
- }
489
-
490
- if (isset ( $_REQUEST ['location_id'] ) && $_REQUEST ['location_id'] |= '') {
491
- $location = dbem_get_location ( $_REQUEST ['location_id'] );
492
- $stored_page_title_format = get_option ( 'dbem_location_page_title_format' );
493
- $page_title = dbem_replace_locations_placeholders ( $stored_page_title_format, $location );
494
- return $page_title;
495
- }
496
- if (isset ( $_REQUEST ['event_id'] ) && $_REQUEST ['event_id'] != '') {
497
- // single event page
498
- $event_ID = $_REQUEST ['event_id'];
499
- $event = dbem_get_event ( $event_ID );
500
- $stored_page_title_format = get_option ( 'dbem_event_page_title_format' );
501
- $page_title = dbem_replace_placeholders ( $stored_page_title_format, $event );
502
- return $page_title;
503
- } else {
504
- // Multiple events page
505
- $page_title = get_option ( 'dbem_events_page_title' );
506
- return $page_title;
507
-
508
- }
509
-
510
- } else {
511
- return $data;
512
- }
513
-
514
- }
515
- // to make sure that in pages lists the title is dbem_events_page_title, and not overwritten by the previous filter
516
- add_filter ( 'the_title', 'dbem_events_page_title' );
517
- add_filter ( 'single_post_title', 'dbem_events_page_title' );
518
-
519
- function dbem_filter_get_pages($data) {
520
- $output = array ();
521
- $events_page_id = get_option ( 'dbem_events_page' );
522
- for($i = 0; $i < count ( $data ); ++ $i) {
523
- if ($data [$i]->ID == $events_page_id) {
524
- $list_events_page = get_option ( 'dbem_list_events_page' );
525
- if ($list_events_page) {
526
- $data [$i]->post_title = get_option ( 'dbem_events_page_title' ) . "&nbsp;";
527
- $output [] = $data [$i];
528
- }
529
- } else {
530
- $output [] = $data [$i];
531
- }
532
- }
533
- return $output;
534
- }
535
- add_filter ( 'get_pages', 'dbem_filter_get_pages' );
536
-
537
- //
538
- // TODO: ROBA NUOVA DA RIORDINARE
539
- // ADMIN CSS for debug
540
- function dbem_admin_css() {
541
- $css = "
542
- <style type='text/css'>
543
- .debug{
544
- color: green;
545
- background: #B7F98C;
546
- margin: 15px;
547
- padding: 10px;
548
- border: 1px solid #629948;
549
- }
550
- .switch-tab {
551
- background: #aaa;
552
- width: 100px;
553
- float: right;
554
- text-align: center;
555
- margin: 3px 1px 0 5px;
556
- padding: 2px;
557
- }
558
- .switch-tab a {
559
- color: #fff;
560
- text-decoration: none;
561
- }
562
- .switch-tab a:hover {
563
- color: #D54E21;
564
-
565
- }
566
- #events-pagination {
567
- text-align: center;
568
-
569
- }
570
- #events-pagination a {
571
- margin: 0 20px 0 20px;
572
- text-decoration: none;
573
- width: 80px;
574
- padding: 3px 0;
575
- background: #FAF4B7;
576
- border: 1px solid #ccc;
577
- border-top: none;
578
- }
579
- #new-event {
580
- float: left;
581
-
582
- }
583
- </style>";
584
- echo $css;
585
- }
586
-
587
- add_action ( 'admin_print_scripts', 'dbem_admin_css' );
588
-
589
- // TEMPLATE TAGS
590
-
591
-
592
- // exposed function, for theme makers
593
- /* Marcus Begin Edit */
594
- //Added a category option to the get events list method and shortcode
595
- function dbem_get_events_list($limit = "3", $scope = "future", $order = "ASC", $format = '', $echo = 1, $category = '') {
596
- if (strpos ( $limit, "=" )) {
597
- // allows the use of arguments without breaking the legacy code
598
- $defaults = array ('limit' => 3, 'scope' => 'future', 'order' => 'ASC', 'format' => '', 'echo' => 1 , 'category' => '');
599
-
600
- $r = wp_parse_args ( $limit, $defaults );
601
- extract ( $r, EXTR_SKIP );
602
- $limit = $r ['limit'];
603
- $scope = $r ['scope'];
604
- $order = $r ['order'];
605
- $format = $r ['format'];
606
- $echo = $r ['echo'];
607
- $category = (is_numeric($r ['category'])) ? $r ['category'] : '' ;
608
- }
609
- if ($scope == "")
610
- $scope = "future";
611
- if ($order != "DESC")
612
- $order = "ASC";
613
- if ($format == '')
614
- $format = get_option ( 'dbem_event_list_item_format' );
615
- $events = dbem_get_events ( $limit, $scope, $order, '', '', $category );
616
- $output = "";
617
- if (! empty ( $events )) {
618
- foreach ( $events as $event ) {
619
- // $localised_date = mysql2date("j M Y", $event->event_time);
620
-
621
-
622
- $output .= dbem_replace_placeholders ( $format, $event );
623
- }
624
- } else {
625
- $output = "<li class='dbem-no-events'>" . get_option ( 'dbem_no_events_message' ) . "</li>";
626
- }
627
- if ($echo)
628
- echo $output;
629
- else
630
- return $output;
631
- }
632
-
633
- function dbem_get_events_list_shortcode($atts) {
634
- extract ( shortcode_atts ( array ('limit' => 3, 'scope' => 'future', 'order' => 'ASC', 'format' => '', 'category' => '' ), $atts ) );
635
- $result = dbem_get_events_list ( "limit=$limit&scope=$scope&order=$order&format=$format&echo=0&category=$category" );
636
- return $result;
637
- }
638
- add_shortcode ( 'events_list', 'dbem_get_events_list_shortcode' );
639
- /* Marcus End Edit*/
640
-
641
- function dbem_get_events_page($justurl = 0, $echo = 1, $text = '') {
642
- if (strpos ( $justurl, "=" )) {
643
- // allows the use of arguments without breaking the legacy code
644
- $defaults = array ('justurl' => 0, 'text' => '', 'echo' => 1 );
645
-
646
- $r = wp_parse_args ( $justurl, $defaults );
647
- extract ( $r, EXTR_SKIP );
648
- $justurl = $r ['justurl'];
649
- $text = $r ['text'];
650
- $echo = $r ['echo'];
651
- }
652
-
653
- $page_link = get_permalink ( get_option ( "dbem_events_page" ) );
654
- if ($justurl) {
655
- $result = $page_link;
656
- } else {
657
- if ($text == '')
658
- $text = get_option ( "dbem_events_page_title" );
659
- $result = "<a href='$page_link' title='$text'>$text</a>";
660
- }
661
- if ($echo)
662
- echo $result;
663
- else
664
- return $result;
665
-
666
- }
667
- function dbem_get_events_page_shortcode($atts) {
668
- extract ( shortcode_atts ( array ('justurl' => 0, 'text' => '' ), $atts ) );
669
- $result = dbem_get_events_page ( "justurl=$justurl&text=$text&echo=0" );
670
- return $result;
671
- }
672
- add_shortcode ( 'events_page', 'dbem_get_events_page_shortcode' );
673
-
674
- function dbem_are_events_available($scope = "future") {
675
- if ($scope == "")
676
- $scope = "future";
677
- $events = dbem_get_events ( 1, $scope );
678
-
679
- if (empty ( $events ))
680
- return FALSE;
681
- else
682
- return TRUE;
683
- }
684
-
685
- // Returns true if the page in question is the events page
686
- function dbem_is_events_page() {
687
- $events_page_id = get_option ( 'dbem_events_page' );
688
- return is_page ( $events_page_id );
689
- }
690
-
691
- function dbem_is_single_event_page() {
692
- return (dbem_is_events_page () && (isset ( $_REQUEST ['event_id'] ) && $_REQUEST ['event_id'] != ''));
693
- }
694
-
695
- function dbem_is_multiple_events_page() {
696
- return (dbem_is_events_page () && ! (isset ( $_REQUEST ['event_id'] ) && $_REQUEST ['event_id'] != ''));
697
- }
698
-
699
- // main function querying the database event table
700
- /* Marcus Begin Edit */
701
- //Added extra method option for cateogry
702
- function dbem_get_events($limit = "", $scope = "future", $order = "ASC", $offset = "", $location_id = "", $category = '') {
703
- /* Marcus End Edit */
704
- global $wpdb;
705
-
706
- $events_table = $wpdb->prefix . EVENTS_TBNAME;
707
- if ($limit != "")
708
- $limit = "LIMIT $limit";
709
- if ($offset != "")
710
- $offset = "OFFSET $offset";
711
- if ($order = "")
712
- $order = "ASC";
713
-
714
- $timestamp = time ();
715
- $date_time_array = getdate ( $timestamp );
716
- $hours = $date_time_array ['hours'];
717
- $minutes = $date_time_array ['minutes'];
718
- $seconds = $date_time_array ['seconds'];
719
- $month = $date_time_array ['mon'];
720
- $day = $date_time_array ['mday'];
721
- $year = $date_time_array ['year'];
722
- $today = strftime ( '%Y-%m-%d', mktime ( $hours, $minutes, $seconds, $month, $day, $year ) );
723
-
724
- $conditions = array ();
725
- if (preg_match ( "/^[0-9]{4}-[0-9]{2}-[0-9]{2}#x2F;", $scope )) {
726
- $conditions [] = " event_start_date like '$scope'";
727
- } else {
728
- if (($scope != "past") && ($scope != "all"))
729
- $scope = "future";
730
- if ($scope == "future")
731
- /* Marcus Begin Edit */
732
- //This is so events with future dates are counted too
733
- $conditions [] = " event_start_date >= '$today' OR (event_end_date >= '$today' AND event_end_date != '0000-00-00' AND event_end_date IS NOT NULL)";
734
- /* Marcus End Edit */
735
- if ($scope == "past")
736
- $conditions [] = " event_start_date < '$today'";
737
- }
738
-
739
- if ($location_id != "")
740
- $conditions [] = " location_id = $location_id";
741
-
742
- /* Marcus Begin Edit */
743
- if ($category != '' && is_numeric($category)){
744
- $conditions [] = " event_category_id = $category";
745
- }
746
- /* Marcus End Edit */
747
-
748
- $where = implode ( " AND ", $conditions );
749
- if ($where != "")
750
- $where = " WHERE " . $where;
751
-
752
- $sql = "SELECT event_id,
753
- event_name,
754
- DATE_FORMAT(event_start_time, '%e') AS 'event_day',
755
- DATE_FORMAT(event_start_time, '%Y') AS 'event_year',
756
- DATE_FORMAT(event_start_time, '%k') AS 'event_hh',
757
- DATE_FORMAT(event_start_time, '%i') AS 'event_mm',
758
- DATE_FORMAT(event_end_time, '%e') AS 'event_end_day',
759
- DATE_FORMAT(event_end_time, '%Y') AS 'event_end_year',
760
- DATE_FORMAT(event_end_time, '%k') AS 'event_end_hh',
761
- DATE_FORMAT(event_end_time, '%i') AS 'event_end_mm',
762
- event_start_date,
763
- event_end_date,
764
- event_start_time,
765
- event_end_time,
766
- event_notes,
767
- event_rsvp,
768
- recurrence_id,
769
- location_id,
770
- event_contactperson_id
771
- FROM $events_table
772
- $where
773
- ORDER BY event_start_date $order
774
- $limit
775
- $offset";
776
-
777
- $wpdb->show_errors = true;
778
- $events = $wpdb->get_results ( $sql, ARRAY_A );
779
- if (! empty ( $events )) {
780
- //$wpdb->print_error();
781
- $inflated_events = array ();
782
- foreach ( $events as $this_event ) {
783
-
784
- $this_location = dbem_get_location ( $this_event ['location_id'] );
785
- $this_event ['location_name'] = $this_location ['location_name'];
786
- $this_event ['location_address'] = $this_location ['location_address'];
787
- $this_event ['location_town'] = $this_location ['location_town'];
788
- array_push ( $inflated_events, $this_event );
789
- }
790
-
791
- return $inflated_events;
792
- } else {
793
- return null;
794
- }
795
- }
796
-
797
- function dbem_get_event($event_id) {
798
- global $wpdb;
799
- $events_table = $wpdb->prefix . EVENTS_TBNAME;
800
- $sql = "SELECT event_id,
801
- event_name,
802
- DATE_FORMAT(event_start_date, '%Y-%m-%e') AS 'event_date',
803
- DATE_FORMAT(event_start_date, '%e') AS 'event_day',
804
- DATE_FORMAT(event_start_date, '%m') AS 'event_month',
805
- DATE_FORMAT(event_start_date, '%Y') AS 'event_year',
806
- DATE_FORMAT(event_start_time, '%k') AS 'event_hh',
807
- DATE_FORMAT(event_start_time, '%i') AS 'event_mm',
808
- DATE_FORMAT(event_start_time, '%h:%i%p') AS 'event_start_12h_time',
809
- DATE_FORMAT(event_start_time, '%H:%i') AS 'event_start_24h_time',
810
- DATE_FORMAT(event_end_time, '%Y-%m-%e') AS 'event_end_date',
811
- DATE_FORMAT(event_end_time, '%e') AS 'event_end_day',
812
- DATE_FORMAT(event_end_time, '%m') AS 'event_end_month',
813
- DATE_FORMAT(event_end_time, '%Y') AS 'event_end_year',
814
- DATE_FORMAT(event_end_time, '%k') AS 'event_end_hh',
815
- DATE_FORMAT(event_end_time, '%i') AS 'event_end_mm',
816
- DATE_FORMAT(event_end_time, '%h:%i%p') AS 'event_end_12h_time',
817
- DATE_FORMAT(event_end_time, '%H:%i') AS 'event_end_24h_time',
818
- event_start_date,
819
- event_end_date,
820
- event_start_time,
821
- event_end_time,
822
- event_notes,
823
- event_rsvp,
824
- event_seats,
825
- recurrence_id,
826
- location_id,
827
- event_contactperson_id
828
- FROM $events_table
829
- WHERE event_id = $event_id";
830
-
831
- //$wpdb->show_errors(true);
832
- $event = $wpdb->get_row ( $sql, ARRAY_A );
833
- //$wpdb->print_error();
834
- $location = dbem_get_location ( $event ['location_id'] );
835
- $event ['location_name'] = $location ['location_name'];
836
- $event ['location_address'] = $location ['location_address'];
837
- $event ['location_town'] = $location ['location_town'];
838
- $event ['location_latitude'] = $location ['location_latitude'];
839
- $event ['location_longitude'] = $location ['location_longitude'];
840
- $event ['location_image_url'] = $location ['location_image_url'];
841
- return $event;
842
- }
843
-
844
- function dbem_hello_to_new_user() {
845
- $current_user = wp_get_current_user ();
846
- $advice = sprintf ( __ ( "<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We hope you like it around here.</p>
847
- <p>Now it's time to insert events lists through <a href='%s' title='Widgets page'>widgets</a>, <a href='%s' title='Template tags documentation'>template tags</a> or <a href='%s' title='Shortcodes documentation'>shortcodes</a>.</p>
848
- <p>By the way, have you taken a look at the <a href='%s' title='Change settings'>Settings page</a>? That's where you customize the way events and locations are displayed.</p>
849
- <p>What? Tired of seeing this advice? I hear you, <a href='%s' title='Don't show this advice again'>click here</a> and you won't see this again!</p>", 'dbem' ), $current_user->display_name, get_bloginfo ( 'url' ) . '/wp-admin/widgets.php', 'http://davidebenini.it/wordpress-plugins/events-manager#template-tags', 'http://davidebenini.it/wordpress-plugins/events-manager#shortcodes', get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager-options', get_bloginfo ( 'url' ) . '/wp-admin/admin.php?page=events-manager/events-manager.php&disable_hello_to_user=true' );
850
- ?>
851
- <div id="message" class="updated">
852
- <?php
853
- echo $advice;
854
- ?>
855
- </div>
856
- <?php
857
- }
858
-
859
- function dbem_events_table($events, $limit, $title) {
860
- if (isset ( $_GET ['scope'] ))
861
- $scope = $_GET ['scope'];
862
- else
863
- $scope = "future";
864
- if (($scope != "past") && ($scope != "all"))
865
- $scope = "future";
866
- $events_count = count ( dbem_get_events ( "", $scope ) );
867
-
868
- if (isset ( $_GET ['offset'] ))
869
- $offset = $_GET ['offset'];
870
-
871
- $use_events_end = get_option ( 'dbem_use_event_end' );
872
-
873
- ?>
874
-
875
- <div class="wrap">
876
- <div id="icon-events" class="icon32"><br />
877
- </div>
878
- <h2><?php
879
- echo $title;
880
- ?></h2>
881
-
882
- <?php
883
- $say_hello = get_option ( 'dbem_hello_to_user' );
884
- if ($say_hello == 1)
885
- dbem_hello_to_new_user ();
886
-
887
- ?>
888
- <!--<div id='new-event' class='switch-tab'><a href="<?php
889
- bloginfo ( 'wpurl' )?>/wp-admin/edit.php?page=events-manager/events-manager.php&amp;action=edit_event"><?php
890
- _e ( 'New Event ...', 'dbem' );
891
- ?></a></div>-->
892
- <?php
893
-
894
- $link = array ();
895
- $link ['past'] = "<a href='" . get_bloginfo ( 'url' ) . "/wp-admin/edit.php?page=events-manager/events-manager.php&amp;scope=past&amp;order=desc'>" . __ ( 'Past events', 'dbem' ) . "</a>";
896
- $link ['all'] = " <a href='" . get_bloginfo ( 'url' ) . "/wp-admin/edit.php?page=events-manager/events-manager.php&amp;scope=all&amp;order=desc'>" . __ ( 'All events', 'dbem' ) . "</a>";
897
- $link ['future'] = " <a href='" . get_bloginfo ( 'url' ) . "/wp-admin/edit.php?page=events-manager/events-manager.php&amp;scope=future'>" . __ ( 'Future events', 'dbem' ) . "</a>";
898
-
899
- $scope_names = array ();
900
- $scope_names ['past'] = __ ( 'Past events', 'dbem' );
901
- $scope_names ['all'] = __ ( 'All events', 'dbem' );
902
- $scope_names ['future'] = __ ( 'Future events', 'dbem' );
903
-
904
- ?>
905
-
906
- <form id="posts-filter" action="" method="get"><input type='hidden'
907
- name='page' value='events-manager/events-manager.php' />
908
- <ul class="subsubsub">
909
- <li><a href='edit.php' class="current"><?php
910
- _e ( 'Total', 'dbem' );
911
- ?> <span
912
- class="count">(<?php
913
- echo (count ( $events ));
914
- ?>)</span></a></li>
915
- </ul>
916
-
917
-
918
- <div class="tablenav">
919
-
920
- <div class="alignleft actions"><select name="action">
921
- <option value="-1" selected="selected"><?php
922
- _e ( 'Bulk Actions' );
923
- ?></option>
924
- <option value="deleteEvents"><?php
925
- _e ( 'Delete selected' );
926
- ?></option>
927
-
928
- </select> <input type="submit" value="<?php
929
- _e ( 'Apply' );
930
- ?>"
931
- name="doaction2" id="doaction2" class="button-secondary action" /> <select
932
- name="scope">
933
-
934
- <?php
935
- foreach ( $scope_names as $key => $value ) {
936
- $selected = "";
937
- if ($key == $scope)
938
- $selected = "selected='selected'";
939
- echo "<option value='$key' $selected>$value</option> ";
940
- }
941
- ?>
942
- </select> <input id="post-query-submit" class="button-secondary"
943
- type="submit" value="<?php
944
- _e ( 'Filter' )?>" /></div>
945
- <div class="clear"></div>
946
- <?php
947
- if (empty ( $events )) {
948
- // TODO localize
949
- echo "no events";
950
- } else {
951
- ?>
952
-
953
- <table class="widefat">
954
- <thead>
955
- <tr>
956
- <th class='manage-column column-cb check-column' scope='col'><input
957
- class='select-all' type="checkbox" value='1' /></th>
958
- <th><?php
959
- _e ( 'Name', 'dbem' );
960
- ?></th>
961
- <?php /* Marcus Begin Edit */ ?>
962
- <th></th>
963
- <?php /* Marcus End Edit */ ?>
964
- <th><?php
965
- _e ( 'Location', 'dbem' );
966
- ?></th>
967
- <th colspan="2"><?php
968
- _e ( 'Date and time', 'dbem' );
969
- ?></th>
970
- </tr>
971
- </thead>
972
- <tbody>
973
- <?php
974
- $i = 1;
975
- foreach ( $events as $event ) {
976
- $class = ($i % 2) ? ' class="alternate"' : '';
977
- // FIXME set to american
978
- $localised_date = mysql2date ( __ ( 'D d M Y' ), $event ['event_start_date'] );
979
- $style = "";
980
- $today = date ( "Y-m-d" );
981
-
982
- $location_summary = "<b>" . $event ['location_name'] . "</b><br/>" . $event ['location_address'] . " - " . $event ['location_town'];
983
-
984
- if ($event ['event_start_date'] < $today)
985
- $style = "style ='background-color: #FADDB7;'";
986
- ?>
987
- <tr <?php
988
- echo "$class $style";
989
- ?>>
990
-
991
- <td><input type='checkbox' class='row-selector'
992
- value='<?php
993
- echo $event ['event_id'];
994
- ?>' name='events[]' /></td>
995
- <td><strong><a class="row-title"
996
- href="<?php
997
- bloginfo ( 'wpurl' )?>/wp-admin/edit.php?page=events-manager/events-manager.php&amp;action=edit_event&amp;event_id=<?php
998
- echo $event ['event_id'];
999
- ?>"><?php
1000
- echo ($event ['event_name']);
1001
- ?></a></strong>
1002
- </td>
1003
- <td>
1004
- <?php /* Marcus Begin Edit */ ?>
1005
- <a
1006
- href="<?php
1007
- bloginfo ( 'wpurl' )?>/wp-admin/edit.php?page=events-manager/events-manager.php&amp;action=duplicate_event&amp;event_id=<?php
1008
- echo $event ['event_id'];
1009
- ?>"
1010
- title="<?php
1011
- _e ( 'Duplicate this event', 'dbem' );
1012
- ?>"><strong>+</strong></a>
1013
- <?php /* Marcus End Edit */ ?>
1014
- </td>
1015
- <td>
1016
-
1017
- <?php
1018
- echo $location_summary;
1019
- ?>
1020
-
1021
- </td>
1022
-
1023
- <td>
1024
- <?php
1025
- echo $localised_date;
1026
- ?><br />
1027
-
1028
- <?php
1029
- echo substr ( $event ['event_start_time'], 0, 5 ) . " - " . substr ( $event ['event_end_time'], 0, 5 );
1030
- ?>
1031
- </td>
1032
- <td>
1033
- <?php
1034
- if ($event ['recurrence_id']) {
1035
- $recurrence = dbem_get_recurrence ( $event [recurrence_id] );
1036
- ?>
1037
-
1038
- <b><?php
1039
- echo $recurrence ['recurrence_description'];
1040
- ?> <br />
1041
- <a
1042
- href="<?php
1043
- bloginfo ( 'wpurl' )?>/wp-admin/edit.php?page=events-manager/events-manager.php&amp;action=edit_recurrence&amp;recurrence_id=<?php
1044
- echo $recurrence ['recurrence_id'];
1045
- ?>"><?php
1046
- _e ( 'Reschedule', 'dbem' );
1047
- ?></a></b>
1048
-
1049
-
1050
- <?php
1051
- }
1052
- ?>
1053
- </td>
1054
-
1055
-
1056
- <?php
1057
- echo '</tr>';
1058
- $i ++;
1059
- }
1060
- ?>
1061
-
1062
-
1063
-
1064
-
1065
-
1066
- </tbody>
1067
- </table>
1068
- <?php
1069
- } // end of table ?>
1070
-
1071
- <div class='tablenav'>
1072
- <div class="alignleft actions"><br class='clear' />
1073
- </div>
1074
- <br class='clear' />
1075
- </div>
1076
-
1077
- </form>
1078
- </div>
1079
- </div>
1080
-
1081
- <?php
1082
- if ($events_count > $limit) {
1083
- $backward = $offset + $limit;
1084
- $forward = $offset - $limit;
1085
- if (DEBUG)
1086
- echo "COUNT = $count BACKWARD = $backward FORWARD = $forward<br> -- OFFSET = $offset";
1087
- echo "<div id='events-pagination'> ";
1088
- if ($backward < $events_count)
1089
- echo "<a style='float: left' href='" . get_bloginfo ( 'url' ) . "/wp-admin/edit.php?page=events-manager/events-manager.php&amp;scope=$scope&offset=$backward'>&lt;&lt;</a>";
1090
- if ($forward >= 0)
1091
- echo "<a style='float: right' href='" . get_bloginfo ( 'url' ) . "/wp-admin/edit.php?page=events-manager/events-manager.php&amp;scope=$scope&offset=$forward'>&gt;&gt;</a>";
1092
- echo "</div>";
1093
- }
1094
- ?>
1095
-
1096
- </div>
1097
- <?php
1098
- }
1099
- function dbem_event_form($event, $title, $element) {
1100
-
1101
- global $localised_date_formats;
1102
- // change prefix according to event/recurrence
1103
- $_GET ['action'] == "edit_recurrence" ? $pref = "recurrence_" : $pref = "event_";
1104
-
1105
- $_GET ['action'] == "edit_recurrence" ? $form_destination = "edit.php?page=events-manager/events-manager.php&amp;action=update_recurrence&amp;recurrence_id=" . $element : $form_destination = "edit.php?page=events-manager/events-manager.php&amp;action=update_event&amp;event_id=" . $element;
1106
-
1107
- $locale_code = substr ( get_locale (), 0, 2 );
1108
- $localised_date_format = $localised_date_formats [$locale_code];
1109
-
1110
- $hours_locale = "24";
1111
- // Setting 12 hours format for those countries using it
1112
- if (preg_match ( "/en|sk|zh|us|uk/", $locale_code ))
1113
- $hours_locale = "12";
1114
-
1115
- $localised_example = str_replace ( "yy", "2008", str_replace ( "mm", "11", str_replace ( "dd", "28", $localised_date_format ) ) );
1116
- $localised_end_example = str_replace ( "yy", "2008", str_replace ( "mm", "11", str_replace ( "dd", "28", $localised_date_format ) ) );
1117
-
1118
- if ($event [$pref . 'start_date'] != "") {
1119
- preg_match ( "/(\d{4})-(\d{2})-(\d{2})/", $event [$pref . 'start_date'], $matches );
1120
- $year = $matches [1];
1121
- $month = $matches [2];
1122
- $day = $matches [3];
1123
- $localised_date = str_replace ( "yy", $year, str_replace ( "mm", $month, str_replace ( "dd", $day, $localised_date_format ) ) );
1124
- } else {
1125
- $localised_date = "";
1126
- }
1127
- if ($event [$pref . 'end_date'] != "") {
1128
- preg_match ( "/(\d{4})-(\d{2})-(\d{2})/", $event [$pref . 'end_date'], $matches );
1129
- $end_year = $matches [1];
1130
- $end_month = $matches [2];
1131
- $end_day = $matches [3];
1132
- $localised_end_date = str_replace ( "yy", $end_year, str_replace ( "mm", $end_month, str_replace ( "dd", $end_day, $localised_date_format ) ) );
1133
- } else {
1134
- $localised_end_date = "";
1135
- }
1136
- // if($event[$pref.'rsvp'])
1137
- // echo (dbem_bookings_table($event[$pref.'id']));
1138
-
1139
-
1140
- $freq_options = array ("daily" => __ ( 'Daily', 'dbem' ), "weekly" => __ ( 'Weekly', 'dbem' ), "monthly" => __ ( 'Monthly', 'dbem' ) );
1141
- $days_names = array (1 => __ ( 'Mon' ), 2 => __ ( 'Tue' ), 3 => __ ( 'Wed' ), 4 => __ ( 'Thu' ), 5 => __ ( 'Fri' ), 6 => __ ( 'Sat' ), 7 => __ ( 'Sun' ) );
1142
- $saved_bydays = explode ( ",", $event ['recurrence_byday'] );
1143
- $weekno_options = array ("1" => __ ( 'first', 'dbem' ), '2' => __ ( 'second', 'dbem' ), '3' => __ ( 'third', 'dbem' ), '4' => __ ( 'fourth', 'dbem' ), '-1' => __ ( 'last', 'dbem' ) );
1144
-
1145
- $event [$pref . 'rsvp'] ? $event_RSVP_checked = "checked='checked'" : $event_RSVP_checked = '';
1146
-
1147
- ?>
1148
- <form id="eventForm" method="post" action="<?php echo $form_destination; ?>">
1149
- <div class="wrap">
1150
- <div id="icon-events" class="icon32"><br /></div>
1151
- <h2><?php echo $title; ?></h2>
1152
- <?php
1153
- if ($event ['recurrence_id']) {
1154
- ?>
1155
- <p id='recurrence_warning'>
1156
- <?php
1157
- if (isset ( $_GET ['action'] ) && ($_GET ['action'] == 'edit_recurrence')) {
1158
- _e ( 'WARNING: This is a recurrence.', 'dbem' )?>
1159
- <br />
1160
- <?php
1161
- _e ( 'Modifying these data all the events linked to this recurrence will be rescheduled', 'dbem' );
1162
-
1163
- } else {
1164
- _e ( 'WARNING: This is a recurring event.', 'dbem' );
1165
- _e ( 'If you change these data and save, this will become an independent event.', 'dbem' );
1166
- }
1167
- ?>
1168
- </p>
1169
- <?php
1170
- }
1171
- ?>
1172
- <?php
1173
- /* Marcus Begin Edit */
1174
- //This is an edit for WP 2.8 for styling fix
1175
- ?>
1176
- <div id="poststuff" class="metabox-holder has-right-sidebar">
1177
- <!-- SIDEBAR -->
1178
- <div id="side-info-column" class='inner-sidebar'>
1179
- <div id='side-sortables'>
1180
- <!-- recurrence postbox -->
1181
- <div class="postbox ">
1182
- <div class="handlediv" title="Fare clic per cambiare."><br />
1183
- </div>
1184
- <h3 class='hndle'><span>
1185
- <?php
1186
- _e ( "Recurrence", 'dbem' );
1187
- ?>
1188
- </span></h3>
1189
- <div class="inside">
1190
- <?php
1191
- if (! $event ['event_id']) {
1192
- ?>
1193
- <?php
1194
- if ($event ['recurrence_id'] != "")
1195
- $recurrence_YES = "checked='checked'";
1196
-
1197
- ?>
1198
- <p>
1199
- <input id="event-recurrence" type="checkbox"
1200
- name="repeated_event" value="1" <?php
1201
- echo $recurrence_YES;
1202
- ?> />
1203
- <?php
1204
- _e ( 'Repeated event', 'dbem' );
1205
- ?>
1206
- </p>
1207
- <div id="event_recurrence_pattern">
1208
- <p>Frequency:
1209
- <select id="recurrence-frequency" name="recurrence_freq">
1210
- <?php
1211
- dbem_option_items ( $freq_options, $event [$pref . 'freq'] );
1212
- ?>
1213
- </select>
1214
- </p>
1215
- <p>
1216
- <?php
1217
- _e ( 'Every', 'dbem' )?>
1218
- <input id="recurrence-interval" name='recurrence_interval'
1219
- size='2' value='<?php
1220
- echo $event ['recurrence_interval'];
1221
- ?>'>
1222
- </input>
1223
- <span class='interval-desc' id="interval-daily-singular">
1224
- <?php _e ( 'day', 'dbem' )?>
1225
- </span> <span class='interval-desc' id="interval-daily-plural">
1226
- <?php _e ( 'days', 'dbem' ) ?>
1227
- </span> <span class='interval-desc' id="interval-weekly-singular">
1228
- <?php _e ( 'week', 'dbem' )?>
1229
- </span> <span class='interval-desc' id="interval-weekly-plural">
1230
- <?php _e ( 'weeks', 'dbem' )?>
1231
- </span> <span class='interval-desc' id="interval-monthly-singular">
1232
- <?php _e ( 'month', 'dbem' )?>
1233
- </span> <span class='interval-desc' id="interval-monthly-plural">
1234
- <?php _e ( 'months', 'dbem' )?>
1235
- </span> </p>
1236
- <p class="alternate-selector" id="weekly-selector">
1237
- <?php dbem_checkbox_items ( 'recurrence_bydays[]', $days_names, $saved_bydays );
1238
- ?>
1239
- </p>
1240
- <p class="alternate-selector" id="monthly-selector">
1241
- <?php
1242
- _e ( 'Every', 'dbem' )?>
1243
- <select id="monthly-modifier" name="recurrence_byweekno">
1244
- <?php
1245
- dbem_option_items ( $weekno_options, $event ['recurrence_byweekno'] );
1246
- ?>
1247
- </select>
1248
- <select id="recurrence-weekday"
1249
- name="recurrence_byday">
1250
- <?php
1251
- dbem_option_items ( $days_names, $event ['recurrence_byday'] );
1252
- ?>
1253
- </select>
1254
- &nbsp;</p>
1255
- </div>
1256
- <p id="recurrence-tip">
1257
- <?php
1258
- _e ( 'Check if your event happens more than once according to a regular pattern', 'dbem' )?>
1259
- </p>
1260
- <?php
1261
- } else {
1262
-
1263
- if (! $event ['recurrence_id']) {
1264
- echo "<p>" . __ ( 'This is\'t a recurrent event', 'dbem' ) . ".</p>";
1265
- } else {
1266
-
1267
- $recurrence = dbem_get_recurrence ( $event ['recurrence_id'] );
1268
- ?>
1269
- <p>
1270
- <?php
1271
- echo $recurrence ['recurrence_description'];
1272
- ?>
1273
- <br />
1274
- <a
1275
- href="<?php
1276
- bloginfo ( 'wpurl' )?>/wp-admin/edit.php?page=events-manager/events-manager.php&amp;action=edit_recurrence&amp;recurrence_id=<?php
1277
- echo $recurrence ['recurrence_id'];
1278
- ?>">
1279
- <?php
1280
- _e ( 'Reschedule', 'dbem' );
1281
- ?>
1282
- </a></p>
1283
- <?php
1284
- }
1285
- ?>
1286
- <?php
1287
- }
1288
- ?>
1289
- </div>
1290
- </div>
1291
- <div class="postbox ">
1292
- <div class="handlediv" title="Fare clic per cambiare."><br />
1293
- </div>
1294
- <h3 class='hndle'><span>
1295
- <?php
1296
- _e ( 'Contact Person', 'dbem' );
1297
- ?>
1298
- </span></h3>
1299
- <div class="inside">
1300
- <p>Contact:
1301
- <?php
1302
- wp_dropdown_users ( array ('name' => 'event_contactperson_id', 'show_option_none' => __ ( "Select...", 'dbem' ), 'selected' => $event ['event_contactperson_id'] ) );
1303
- ?>
1304
- </p>
1305
- </div>
1306
- </div>
1307
- <div class="postbox ">
1308
- <div class="handlediv" title="Fare clic per cambiare."><br />
1309
- </div>
1310
- <h3 class='hndle'><span>RSVP</span></h3>
1311
- <div class="inside">
1312
- <p>
1313
- <input id="rsvp-checkbox" name='event_rsvp' value='1' type='checkbox'
1314
- <?php
1315
- echo $event_RSVP_checked?> />
1316
- <?php
1317
- _e ( 'Enable registration for this event', 'dbem' )?>
1318
- </p>
1319
- <div id='rsvp-data'>
1320
- <?php
1321
- if ($event ['event_contactperson_id'] != NULL)
1322
- $selected = $event ['event_contactperson_id'];
1323
- else
1324
- $selected = '0';
1325
- ?>
1326
- <p>
1327
- <?php
1328
- _e ( 'Spaces' );
1329
- ?>
1330
- :
1331
- <input id="seats-input" type="text"
1332
- name="event_seats" size='5' value="<?php
1333
- echo $event [$pref . 'seats']?>" />
1334
- </p>
1335
- <?php
1336
- if ($event ['event_rsvp']) {
1337
- ?>
1338
- <?php
1339
- dbem_bookings_compact_table ( $event [$pref . 'id'] );
1340
- ?>
1341
- <?php
1342
- }
1343
- ?>
1344
- </div>
1345
- </div>
1346
- </div>
1347
- <?
1348
- /* Marcus Begin Edit */
1349
- //adding the category selection box
1350
- ?>
1351
- <div class="postbox ">
1352
- <div class="handlediv" title="Fare clic per cambiare."><br />
1353
- </div>
1354
- <h3 class='hndle'><span>
1355
- <?php _e ( 'Category', 'dbem' ); ?>
1356
- </span></h3>
1357
- <div class="inside">
1358
- <p>Category:
1359
- <select name="event_category_id">
1360
- <?php
1361
- $categories = dbem_get_categories();
1362
- ?>
1363
- <option value="">Select...</option>
1364
- <?php
1365
- foreach ( $categories as $category ){
1366
- $event_category = dbem_get_event_category($event['event_id']);
1367
- $selected = ($category['category_id'] == $event_category['category_id']) ? "selected='selected'": '';
1368
- ?>
1369
- <option value="<?= $category['category_id'] ?>" <?= $selected ?>>
1370
- <?= $category['category_name'] ?>
1371
- </option>
1372
- <?
1373
- }
1374
- ?>
1375
- </select>
1376
- </p>
1377
- </div>
1378
- </div>
1379
- </div>
1380
- <? /* Marcus End Edit */ ?>
1381
- </div>
1382
- <!-- END OF SIDEBAR -->
1383
- <div id="post-body">
1384
- <div id="post-body-content">
1385
- <? /* Marcus End Edit */ ?>
1386
- <div id="event_name" class="stuffbox">
1387
- <h3>
1388
- <?php
1389
- _e ( 'Name', 'dbem' );
1390
- ?>
1391
- </h3>
1392
- <div class="inside">
1393
- <input type="text" name="event_name"
1394
- value="<?php
1395
- echo $event [$pref . 'name']?>" />
1396
- <br />
1397
- <?php
1398
- _e ( 'The event name. Example: Birthday party', 'dbem' )?>
1399
- </div>
1400
- </div>
1401
- <div id="event_start_date" class="stuffbox">
1402
- <h3 id='event-date-title'>
1403
- <?php
1404
- _e ( 'Event date', 'dbem' );
1405
- ?>
1406
- </h3>
1407
- <h3 id='recurrence-dates-title'>
1408
- <?php
1409
- _e ( 'Recurrence dates', 'dbem' );
1410
- ?>
1411
- </h3>
1412
- <div class="inside">
1413
- <input id="localised-date" type="text"
1414
- name="localised_event_date" value="<?php
1415
- echo $localised_date?>"
1416
- style="display: none;" />
1417
- <input id="date-to-submit" type="text"
1418
- name="event_date" value="<?php
1419
- echo $event [$pref . 'start_date']?>"
1420
- style="background: #FCFFAA" />
1421
- <input id="localised-end-date"
1422
- type="text" name="localised_event_end_date"
1423
- value="<?php
1424
- echo $localised_end_date?>" style="display: none;" />
1425
- <input
1426
- id="end-date-to-submit" type="text" name="event_end_date"
1427
- value="<?php
1428
- echo $event [$pref . 'end_date']?>"
1429
- style="background: #FCFFAA" />
1430
- <br />
1431
- <span id='event-date-explanation'>
1432
- <?php
1433
- _e ( 'The event date.', 'dbem' );
1434
- /* Marcus Begin Edit */
1435
- echo " ";
1436
- _e ( 'When not reoccurring, this event spans between the beginning and end date.', 'dbem' );
1437
- /* Marcus End Edit */
1438
- ?>
1439
- </span><span
1440
- id='recurrence-dates-explanation'>
1441
- <?php
1442
- _e ( 'The recurrence beginning and end date.', 'dbem' );
1443
- ?>
1444
- </span> </div>
1445
- </div>
1446
- <div id="event_end_day" class="stuffbox">
1447
- <h3>
1448
- <?php
1449
- _e ( 'Event time', 'dbem' );
1450
- ?>
1451
- </h3>
1452
- <div class="inside">
1453
- <input id="start-time" type="text" size="8"
1454
- maxlength="8" name="event_start_time"
1455
- value="<?php
1456
- echo $event [$pref . 'start_' . $hours_locale . "h_time"];
1457
- ?>" />
1458
- -
1459
- <input id="end-time" type="text" size="8" maxlength="8"
1460
- name="event_end_time"
1461
- value="<?php
1462
- echo $event [$pref . 'end_' . $hours_locale . "h_time"];
1463
- ?>" />
1464
- <br />
1465
- <?php
1466
- _e ( 'The time of the event beginning and end', 'dbem' )?>
1467
- . </div>
1468
- </div>
1469
- <div id="location_coordinates" class="stuffbox" style='display: none;'>
1470
- <h3>
1471
- <?php
1472
- _e ( 'Coordinates', 'dbem' );
1473
- ?>
1474
- </h3>
1475
- <div class="inside">
1476
- <input id='location-latitude'
1477
- name='location_latitude' type='text'
1478
- value='<?php
1479
- echo $event ['location_latitude'];
1480
- ?>' size='15' />
1481
- -
1482
- <input
1483
- id='location-longitude' name='location_longitude' type='text'
1484
- value='<?php
1485
- echo $event ['location_longitude'];
1486
- ?>' size='15' />
1487
- </div>
1488
- </div>
1489
- <div id="location_name" class="stuffbox">
1490
- <h3>
1491
- <?php
1492
- _e ( 'Location', 'dbem' );
1493
- ?>
1494
- </h3>
1495
- <div class="inside">
1496
- <table id="dbem-location-data">
1497
- <tr>
1498
- <th><?php
1499
- _e ( 'Name:' )?>
1500
- &nbsp;</th>
1501
- <td><input id="location-name" type="text" name="location_name"
1502
- value="<?php
1503
- echo $event ['location_name']?>" /></td>
1504
- <?php
1505
- $gmap_is_active = get_option ( 'dbem_gmap_is_active' );
1506
- ?>
1507
- <?php
1508
- if ($gmap_is_active) {
1509
- ?>
1510
- <td rowspan='6'><div id='map-not-found'
1511
- style='width: 400px; font-size: 140%; text-align: center; margin-top: 100px; display: hide'>
1512
- <p>
1513
- <?php
1514
- _e ( 'Map not found' );
1515
- ?>
1516
- </p>
1517
- </div>
1518
- <div id='event-map'
1519
- style='width: 400px; height: 300px; background: green; display: hide; margin-right: 8px'></div></td>
1520
- <?php
1521
- }
1522
- ; // end of IF_GMAP_ACTIVE ?>
1523
- </tr>
1524
- <tr>
1525
- <td colspan='2'><p>
1526
- <?php
1527
- _e ( 'The name of the location where the event takes place. You can use the name of a venue, a square, etc', 'dbem' )?>
1528
- </p></td>
1529
- </tr>
1530
- <tr>
1531
- <th><?php
1532
- _e ( 'Address:' )?>
1533
- &nbsp;</th>
1534
- <td><input id="location-address" type="text" name="location_address"
1535
- value="<?php
1536
- echo $event ['location_address'];
1537
- ?>" /></td>
1538
- </tr>
1539
- <tr>
1540
- <td colspan='2'><p>
1541
- <?php
1542
- _e ( 'The address of the location where the event takes place. Example: 21, Dominick Street', 'dbem' )?>
1543
- </p></td>
1544
- </tr>
1545
- <tr>
1546
- <th><?php
1547
- _e ( 'Town:' )?>
1548
- &nbsp;</th>
1549
- <td><input id="location-town" type="text" name="location_town"
1550
- value="<?php
1551
- echo $event ['location_town']?>" /></td>
1552
- </tr>
1553
- <tr>
1554
- <td colspan='2'><p>
1555
- <?php
1556
- _e ( 'The town where the location is located. If you\'re using the Google Map integration and want to avoid geotagging ambiguities include the country in the town field. Example: Verona, Italy.', 'dbem' )?>
1557
- </p></td>
1558
- </tr>
1559
- </table>
1560
- </div>
1561
- </div>
1562
- <div id="event_notes" class="postbox">
1563
- <h3>
1564
- <?php
1565
- _e ( 'Details', 'dbem' );
1566
- ?>
1567
- </h3>
1568
- <div class="inside">
1569
- <? /* Marcus Begin Edit */ ?>
1570
- <!-- Currently deactivated for editor test
1571
- <textarea name="event_notes" rows="8" cols="60">
1572
- <?php
1573
- echo $event [$pref . 'notes'];
1574
- ?>
1575
- </textarea>
1576
- -->
1577
- <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
1578
- <?php the_editor($event [$pref . 'notes']); ?>
1579
- </div>
1580
- <? /* Marcus End Edit */ ?>
1581
- <br />
1582
- <?php
1583
- _e ( 'Details about the event', 'dbem' )?>
1584
- </div>
1585
- </div>
1586
- </div>
1587
- <p class="submit">
1588
- <input type="submit" name="events_update"
1589
- value="<?php
1590
- _e ( 'Submit Event', 'dbem' );
1591
- ?> &raquo;" />
1592
- </p>
1593
- </div>
1594
- </div>
1595
- </div>
1596
- </form>
1597
- <?php
1598
- }
1599
-
1600
- function dbem_validate_event($event) {
1601
- // Only for emergencies, when JS is disabled
1602
- // TODO make it fully functional without JS
1603
- global $required_fields;
1604
- $errors = Array ();
1605
- foreach ( $required_fields as $field ) {
1606
- if ($event [$field] == "") {
1607
- $errors [] = $field;
1608
- }
1609
- }
1610
- $error_message = "";
1611
- if (count ( $errors ) > 0)
1612
- $error_message = __ ( 'Missing fields: ' ) . implode ( ", ", $errors ) . ". ";
1613
- if ($_POST ['repeated_event'] == "1" && $_POST ['event_end_date'] == "")
1614
- $error_message .= __ ( 'Since the event is repeated, you must specify an event date.', 'dbem' );
1615
- if ($error_message != "")
1616
- return $error_message;
1617
- else
1618
- return "OK";
1619
-
1620
- }
1621
-
1622
- function _dbem_is_date_valid($date) {
1623
- $year = substr ( $date, 0, 4 );
1624
- $month = substr ( $date, 5, 2 );
1625
- $day = substr ( $date, 8, 2 );
1626
- return (checkdate ( $month, $day, $year ));
1627
- }
1628
- function _dbem_is_time_valid($time) {
1629
- $result = preg_match ( "/([01]\d|2[0-3])(:[0-5]\d)/", $time );
1630
-
1631
- return ($result);
1632
- }
1633
- // Enqueing jQuery script to make sure it's loaded
1634
- function dbem_enque_scripts() {
1635
- wp_enqueue_script ( 'jquery' );
1636
- // wp_enqueue_script('datepicker','/wp-content/plugins/events-manager/jquery-ui-datepicker/jquery-ui-personalized-1.6b.js', array('jquery') );
1637
- }
1638
- add_action ( 'template_redirect', 'dbem_enque_scripts' );
1639
-
1640
- function url_exists($url) {
1641
-
1642
- if ((strpos ( $url, "http" )) === false)
1643
- $url = "http://" . $url;
1644
- // FIXME ripristina la linea seguente e VEDI DI SISTEMARE!!!!
1645
- // if (is_array(@get_headers($url))) {
1646
- if (true)
1647
- return true;
1648
- else
1649
- return false;
1650
- }
1651
-
1652
- // General script to make sure hidden fields are shown when containing data
1653
- function dbem_admin_general_script() {
1654
- ?>
1655
- <script
1656
- src="<?php
1657
- bloginfo ( 'url' );
1658
- ?>/wp-content/plugins/events-manager/dbem.js"
1659
- type="text/javascript"></script>
1660
- <script
1661
- src="<?php
1662
- bloginfo ( 'url' );
1663
- ?>/wp-content/plugins/events-manager/js/jquery-ui-datepicker/ui.datepicker.js"
1664
- type="text/javascript"></script>
1665
- <script
1666
- src="<?php
1667
- bloginfo ( 'url' );
1668
- ?>/wp-content/plugins/events-manager/js/timeentry/jquery.timeentry.js"
1669
- type="text/javascript"></script>
1670
- <?php
1671
-
1672
- // Check if the locale is there and loads it
1673
- $locale_code = substr ( get_locale (), 0, 2 );
1674
-
1675
- $show24Hours = 'true';
1676
- // Setting 12 hours format for those countries using it
1677
- if (preg_match ( "/en|sk|zh|us|uk/", $locale_code ))
1678
- $show24Hours = 'false';
1679
-
1680
- $locale_file = get_bloginfo ( 'url' ) . "/wp-content/plugins/events-manager/js/jquery-ui-datepicker/i18n/ui.datepicker-$locale_code.js";
1681
- if (url_exists ( $locale_file )) {
1682
- ?>
1683
- <script
1684
- src="<?php
1685
- bloginfo ( 'url' );
1686
- ?>/wp-content/plugins/events-manager/js/jquery-ui-datepicker/i18n/ui.datepicker-<?php
1687
- echo $locale_code;
1688
- ?>.js"
1689
- type="text/javascript"></script>
1690
- <?php
1691
- }
1692
- ?>
1693
-
1694
-
1695
- <style type='text/css' media='all'>
1696
- @import
1697
- "<?php
1698
- bloginfo ( 'url' );
1699
- ?>/wp-content/plugins/events-manager/js/jquery-ui-datepicker/ui.datepicker.css"
1700
- ;
1701
- </style>
1702
- <script type="text/javascript">
1703
- //<![CDATA[
1704
- // TODO: make more general, to support also latitude and longitude (when added)
1705
- $j=jQuery.noConflict();
1706
-
1707
- function updateIntervalDescriptor () {
1708
- $j(".interval-desc").hide();
1709
- var number = "-plural";
1710
- if ($j('input#recurrence-interval').val() == 1 || $j('input#recurrence-interval').val() == "")
1711
- number = "-singular"
1712
- var descriptor = "span#interval-"+$j("select#recurrence-frequency").val()+number;
1713
- $j(descriptor).show();
1714
- }
1715
- function updateIntervalSelectors () {
1716
- $j('p.alternate-selector').hide();
1717
- $j('p#'+ $j('select#recurrence-frequency').val() + "-selector").show();
1718
- //$j('p.recurrence-tip').hide();
1719
- //$j('p#'+ $j(this).val() + "-tip").show();
1720
- }
1721
- function updateShowHideRecurrence () {
1722
- if($j('input#event-recurrence').attr("checked")) {
1723
- $j("#event_recurrence_pattern").fadeIn();
1724
- /* Marcus Begin Edit */
1725
- //Edited this and the one below so dates always can have an end date
1726
- //$j("input#localised-end-date").fadeIn();
1727
- /* Marcus End Edit */
1728
- $j("#event-date-explanation").hide();
1729
- $j("#recurrence-dates-explanation").show();
1730
- $j("h3#recurrence-dates-title").show();
1731
- $j("h3#event-date-title").hide();
1732
- } else {
1733
- $j("#event_recurrence_pattern").hide();
1734
- /* Marcus Begin Edit */
1735
- //$j("input#localised-end-date").hide();
1736
- /* Marcus End Edit */
1737
- $j("#recurrence-dates-explanation").hide();
1738
- $j("#event-date-explanation").show();
1739
- $j("h3#recurrence-dates-title").hide();
1740
- $j("h3#event-date-title").show();
1741
- }
1742
- }
1743
-
1744
- function updateShowHideRsvp () {
1745
- if($j('input#rsvp-checkbox').attr("checked")) {
1746
- $j("div#rsvp-data").fadeIn();
1747
- } else {
1748
- $j("div#rsvp-data").hide();
1749
- }
1750
- }
1751
-
1752
- $j(document).ready( function() {
1753
- locale_format = "ciao";
1754
-
1755
- $j("#recurrence-dates-explanation").hide();
1756
- $j("#localised-date").show();
1757
- /* Marcus Begin Edit */
1758
- $j("#localised-end-date").show();
1759
- /* Marcus End Edit */
1760
-
1761
- $j("#date-to-submit").hide();
1762
- $j("#end-date-to-submit").hide();
1763
- $j("#localised-date").datepicker($j.extend({},
1764
- ($j.datepicker.regional["it"],
1765
- {altField: "#date-to-submit",
1766
- altFormat: "yy-mm-dd"})));
1767
- $j("#localised-end-date").datepicker($j.extend({},
1768
- ($j.datepicker.regional["it"],
1769
- {altField: "#end-date-to-submit",
1770
- altFormat: "yy-mm-dd"})));
1771
-
1772
-
1773
-
1774
-
1775
-
1776
-
1777
- $j("#start-time").timeEntry({spinnerImage: '', show24Hours: <?php
1778
- echo $show24Hours;
1779
- ?> });
1780
- $j("#end-time").timeEntry({spinnerImage: '', show24Hours: <?php
1781
- echo $show24Hours;
1782
- ?>});
1783
-
1784
-
1785
-
1786
-
1787
-
1788
- $j('input.select-all').change(function(){
1789
- if($j(this).is(':checked'))
1790
- $j('input.row-selector').attr('checked', true);
1791
- else
1792
- $j('input.row-selector').attr('checked', false);
1793
- });
1794
- // TODO: NOT WORKING FOR SOME REASON, val() gives me 2 instead of 'smtp'...
1795
- // console.log($j('select[name:dbem_rsvp_mail_send_method]').val());
1796
- // if ($j('select[name:dbem_rsvp_mail_send_method]').val() != "smtp") {
1797
- // $j('tr#dbem_smtp_host_row').hide();
1798
- // $j('tr#dbem_rsvp_mail_SMTPAuth_row').hide();
1799
- // $j('tr#dbem_smtp_username_row').hide();
1800
- // $j('tr#dbem_smtp_password_row').hide();
1801
- // }
1802
- //
1803
- // $j('select[name:dbem_rsvp_mail_send_method]').change(function() {
1804
- // console.log($j(this).val());
1805
- // if($j(this).val() == "smtp") {
1806
- // $j('tr#dbem_smtp_host_row').show();
1807
- // $j('tr#dbem_rsvp_mail_SMTPAuth_row').show();
1808
- // $j('tr#dbem_smtp_username_row').show();
1809
- // $j('tr#dbem_smtp_password_row').show();
1810
- // } else {
1811
- // $j('tr#dbem_smtp_host_row').hide();
1812
- // $j('tr#dbem_rsvp_mail_SMTPAuth_row').hide();
1813
- // $j('tr#dbem_smtp_username_row').hide();
1814
- // $j('tr#dbem_smtp_password_row').hide();
1815
- // }
1816
-
1817
- //});
1818
- updateIntervalDescriptor();
1819
- updateIntervalSelectors();
1820
- updateShowHideRecurrence();
1821
- updateShowHideRsvp();
1822
- $j('input#event-recurrence').change(updateShowHideRecurrence);
1823
- $j('input#rsvp-checkbox').change(updateShowHideRsvp);
1824
- // recurrency elements
1825
- $j('input#recurrence-interval').keyup(updateIntervalDescriptor);
1826
- $j('select#recurrence-frequency').change(updateIntervalDescriptor);
1827
- $j('select#recurrence-frequency').change(updateIntervalSelectors);
1828
-
1829
- // hiding or showing notes according to their content
1830
- jQuery('.postbox h3').prepend('<a class="togbox">+</a> ');
1831
- // if(jQuery("textarea[@name=event_notes]").val()!="") {
1832
- // jQuery("textarea[@name=event_notes]").parent().parent().removeClass('closed');
1833
- // }
1834
- jQuery('#event_notes h3').click( function() {
1835
- jQuery(jQuery(this).parent().get(0)).toggleClass('closed');
1836
- });
1837
-
1838
- // users cannot submit the event form unless some fields are filled
1839
- function validateEventForm(){
1840
- errors = "";
1841
- var recurring = $j("input[@name=repeated_event]:checked").val();
1842
- requiredFields= new Array('event_name', 'localised_event_date', 'location_name','location_address','location_town');
1843
- var localisedRequiredFields = {'event_name':"<?php
1844
- _e ( 'Name', 'dbem' )?>", 'localised_event_date':"<?php
1845
- _e ( 'Date', 'dbem' )?>", 'location_name':"<?php
1846
- _e ( 'Location', 'dbem' )?>",'location_address':"<?php
1847
- _e ( 'Address', 'dbem' )?>",'location_town':"<?php
1848
- _e ( 'Town', 'dbem' )?>"};
1849
-
1850
- missingFields = new Array;
1851
- for (var i in requiredFields) {
1852
- if ($j("input[@name=" + requiredFields[i]+ "]").val() == 0) {
1853
- missingFields.push(localisedRequiredFields[requiredFields[i]]);
1854
- $j("input[@name=" + requiredFields[i]+ "]").css('border','2px solid red');
1855
- } else {
1856
- $j("input[@name=" + requiredFields[i]+ "]").css('border','1px solid #DFDFDF');
1857
-
1858
- }
1859
-
1860
- }
1861
-
1862
- // alert('ciao ' + recurring+ " end: " + $j("input[@name=localised_event_end_date]").val());
1863
- if (missingFields.length > 0) {
1864
-
1865
- errors = "<?php
1866
- echo _e ( 'Some required fields are missing:', 'dbem' )?> " + missingFields.join(", ") + ".\n";
1867
- }
1868
- if(recurring && $j("input[@name=localised_event_end_date]").val() == "") {
1869
- errors = errors + "<?php
1870
- _e ( 'Since the event is repeated, you must specify an end date', 'dbem' )?>.";
1871
- $j("input[@name=localised_event_end_date]").css('border','2px solid red');
1872
- } else {
1873
- $j("input[@name=localised_event_end_date]").css('border','1px solid #DFDFDF');
1874
- }
1875
- if(errors != "") {
1876
- alert(errors);
1877
- return false;
1878
- }
1879
- return true;
1880
- }
1881
-
1882
- $j('#eventForm').bind("submit", validateEventForm);
1883
-
1884
-
1885
- });
1886
- //]]>
1887
- </script>
1888
-
1889
- <?php
1890
- }
1891
- add_action ( 'admin_head', 'dbem_admin_general_script' );
1892
-
1893
- function dbem_admin_map_script() {
1894
- if ((isset ( $_REQUEST ['event_id'] ) && $_REQUEST ['event_id'] != '') || (isset ( $_REQUEST ['page'] ) && $_REQUEST ['page'] == 'locations') || (isset ( $_REQUEST ['page'] ) && $_REQUEST ['page'] == 'new_event') || (isset ( $_REQUEST ['action'] ) && $_REQUEST ['action'] == 'edit_recurrence')) {
1895
- if (! (isset ( $_REQUEST ['action'] ) && $_REQUEST ['action'] == 'dbem_delete')) {
1896
- // single event page
1897
-
1898
-
1899
- $event_ID = $_REQUEST ['event_id'];
1900
- $event = dbem_get_event ( $event_ID );
1901
-
1902
- if ($event ['location_town'] != '' || (isset ( $_REQUEST ['page'] ) && $_REQUEST ['page'] = 'locations')) {
1903
- $gmap_key = get_option ( 'dbem_gmap_key' );
1904
- if ($event ['location_address'] != "") {
1905
- $search_key = $event ['location_address'] . ", " . $event ['location_town'];
1906
- } else {
1907
- $search_key = $event ['location_name'] . ", " . $event ['location_town'];
1908
- }
1909
-
1910
- ?>
1911
- <style type="text/css">
1912
- /* div#location_town, div#location_address, div#location_name {
1913
- width: 480px;
1914
- }
1915
- table.form-table {
1916
- width: 50%;
1917
- } */
1918
- </style>
1919
- <script
1920
- src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php
1921
- echo $gmap_key;
1922
- ?>"
1923
- type="text/javascript"></script>
1924
- <script type="text/javascript">
1925
- //<![CDATA[
1926
- $j=jQuery.noConflict();
1927
-
1928
- function loadMap(location, town, address) {
1929
- if (GBrowserIsCompatible()) {
1930
- var map = new GMap2(document.getElementById("event-map"));
1931
- // map.addControl(new GScaleControl());
1932
- //map.setCenter(new GLatLng(37.4419, -122.1419), 13);
1933
- var geocoder = new GClientGeocoder();
1934
- if (address !="") {
1935
- searchKey = address + ", " + town;
1936
- } else {
1937
- searchKey = location + ", " + town;
1938
- }
1939
-
1940
- var search = "<?php
1941
- echo $search_key?>" ;
1942
- geocoder.getLatLng(
1943
- searchKey,
1944
- function(point) {
1945
- if (!point) {
1946
- $j("#event-map").hide();
1947
- $j('#map-not-found').show();
1948
- } else {
1949
- mapCenter= new GLatLng(point.lat()+0.01, point.lng()+0.005);
1950
- map.setCenter(mapCenter, 13);
1951
- var marker = new GMarker(point);
1952
- map.addOverlay(marker);
1953
- marker.openInfoWindowHtml('<strong>' + location +'</strong><p>' + address + '</p><p>' + town + '</p>');
1954
- $j('input#location-latitude').val(point.y);
1955
- $j('input#location-longitude').val(point.x);
1956
- $j("#event-map").show();
1957
- $j('#map-not-found').hide();
1958
- }
1959
- }
1960
- );
1961
- // map.addControl(new GSmallMapControl());
1962
- // map.addControl(new GMapTypeControl());
1963
-
1964
- }
1965
- }
1966
-
1967
- $j(document).ready(function() {
1968
- eventLocation = $j("input#location-name").val();
1969
- eventTown = $j("input#location-town").val();
1970
- eventAddress = $j("input#location-address").val();
1971
-
1972
- loadMap(eventLocation, eventTown, eventAddress);
1973
-
1974
- $j("input#location-name").blur(function(){
1975
- newEventLocation = $j("input#location-name").val();
1976
- if (newEventLocation !=eventLocation) {
1977
- loadMap(newEventLocation, eventTown, eventAddress);
1978
- eventLocation = newEventLocation;
1979
-
1980
- }
1981
- });
1982
- $j("input#location-town").blur(function(){
1983
- newEventTown = $j("input#location-town").val();
1984
- if (newEventTown !=eventTown) {
1985
- loadMap(eventLocation, newEventTown, eventAddress);
1986
- eventTown = newEventTown;
1987
- }
1988
- });
1989
- $j("input#location-address").blur(function(){
1990
- newEventAddress = $j("input#location-address").val();
1991
- if (newEventAddress != eventAddress) {
1992
- loadMap(eventLocation, eventTown, newEventAddress);
1993
- eventAddress = newEventAddress;
1994
- }
1995
- });
1996
-
1997
-
1998
-
1999
- });
2000
- $j(document).unload(function() {
2001
- GUnload();
2002
- });
2003
- //]]>
2004
- </script>
2005
- <?php
2006
- }
2007
- }
2008
- }
2009
- }
2010
- $gmap_is_active = get_option ( 'dbem_gmap_is_active' );
2011
- if ($gmap_is_active) {
2012
- add_action ( 'admin_head', 'dbem_admin_map_script' );
2013
-
2014
- }
2015
-
2016
- // Script to validate map options
2017
- function dbem_admin_options_script() {
2018
- if (isset ( $_REQUEST ['page'] ) && $_REQUEST ['page'] == 'events-manager-options') {
2019
- ?>
2020
- <script type="text/javascript">
2021
- //<![CDATA[
2022
- $j=jQuery.noConflict();
2023
-
2024
- $j(document).ready(function() {
2025
-
2026
- // users cannot enable Google Maps without an api key
2027
- function verifyOptionsForm(){
2028
- var gmap_is_active = $j("input[@name=dbem_gmap_is_active]:checked").val();
2029
- var gmap_key = $j("input[@name=dbem_gmap_key]").val();
2030
- if(gmap_is_active == '1' && (gmap_key == '')){
2031
- alert("<?php
2032
- _e ( 'You cannot enable Google Maps integration without setting an appropriate API key.' );
2033
- ?>");
2034
- $j("input[@name='dbem_gmap_is_active']:nth(1)").attr("checked","checked");
2035
-
2036
- return false;
2037
- } else {
2038
- return true;
2039
- }
2040
- }
2041
-
2042
- $j('#dbem_options_form').bind("submit", verifyOptionsForm);
2043
-
2044
-
2045
- });
2046
-
2047
-
2048
- //]]>
2049
- </script>
2050
-
2051
- <?php
2052
-
2053
- }
2054
-
2055
- }
2056
- add_action ( 'admin_head', 'dbem_admin_options_script' );
2057
-
2058
- function dbem_rss_link($justurl = 0, $echo = 1, $text = "RSS") {
2059
- if (strpos ( $justurl, "=" )) {
2060
- // allows the use of arguments without breaking the legacy code
2061
- $defaults = array ('justurl' => 0, 'echo' => 1, 'text' => 'RSS' );
2062
-
2063
- $r = wp_parse_args ( $justurl, $defaults );
2064
- extract ( $r, EXTR_SKIP );
2065
- $justurl = $r ['justurl'];
2066
- $echo = $r ['echo'];
2067
- $text = $r ['text'];
2068
- }</