Events Manager - Version 1.0

Version Description

Download this release

Release Info

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

Version 1.0

dbem-it_IT.mo ADDED
Binary file
dbem-it_IT.po ADDED
@@ -0,0 +1,404 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: events-manager\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-07-21 18:53+0100\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: Davide Benini <cno@cnomania.it>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-Language: Italian\n"
13
+ "X-Poedit-Country: ITALY\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-Basepath: /Users/davidebenini/Sites/testblog/wp-content/plugins/events-manager/\n"
16
+ "X-Poedit-KeywordsList: _e;__\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: dbem_calendar.php:123
20
+ msgid "M_Monday_initial"
21
+ msgstr "L"
22
+
23
+ #: dbem_calendar.php:123
24
+ msgid "T_Tuesday_initial"
25
+ msgstr "M"
26
+
27
+ #: dbem_calendar.php:123
28
+ msgid "W_Wednesday_initial"
29
+ msgstr "M"
30
+
31
+ #: dbem_calendar.php:123
32
+ msgid "T_Thursday_initial"
33
+ msgstr "G"
34
+
35
+ #: dbem_calendar.php:123
36
+ msgid "F_Friday_initial"
37
+ msgstr "V"
38
+
39
+ #: dbem_calendar.php:123
40
+ msgid "S_Saturday_initial"
41
+ msgstr "S"
42
+
43
+ #: dbem_calendar.php:123
44
+ msgid "S_Sunday_initial"
45
+ msgstr "D"
46
+
47
+ #: dbem_widgets.php:10
48
+ #: dbem_widgets.php:35
49
+ #: events-manager.php:42
50
+ #: events-manager.php:155
51
+ #: events-manager.php:161
52
+ #: events-manager.php:187
53
+ #: events-manager.php:198
54
+ msgid "Events"
55
+ msgstr "Eventi"
56
+
57
+ #: dbem_widgets.php:19
58
+ #: events-manager.php:675
59
+ msgid "No events"
60
+ msgstr "Nessun evento"
61
+
62
+ #: dbem_widgets.php:78
63
+ #: dbem_widgets.php:156
64
+ msgid "Title"
65
+ msgstr "Titolo"
66
+
67
+ #: dbem_widgets.php:82
68
+ msgid "Number of events"
69
+ msgstr "Numero di eventi"
70
+
71
+ #: dbem_widgets.php:86
72
+ msgid "Scope of the events"
73
+ msgstr "Ambito degli eventi"
74
+
75
+ #: dbem_widgets.php:88
76
+ #: events-manager.php:845
77
+ msgid "Future events"
78
+ msgstr "Eventi futuri"
79
+
80
+ #: dbem_widgets.php:89
81
+ #: events-manager.php:844
82
+ msgid "All events"
83
+ msgstr "Tutti gli eventi"
84
+
85
+ #: dbem_widgets.php:90
86
+ #: events-manager.php:843
87
+ msgid "Past events"
88
+ msgstr "Eventi passati"
89
+
90
+ #: dbem_widgets.php:94
91
+ msgid "Order of the events"
92
+ msgstr "Ordine degli eventi"
93
+
94
+ #: dbem_widgets.php:96
95
+ msgid "Ascendant"
96
+ msgstr "Ascendente"
97
+
98
+ #: dbem_widgets.php:97
99
+ msgid "Descendant"
100
+ msgstr "Discendente"
101
+
102
+ #: dbem_widgets.php:101
103
+ msgid "List item format"
104
+ msgstr "Formato degli elementi"
105
+
106
+ #: dbem_widgets.php:122
107
+ msgid "calendar"
108
+ msgstr "calendario "
109
+
110
+ #: dbem_widgets.php:176
111
+ #: dbem_widgets.php:177
112
+ msgid "Events List"
113
+ msgstr "Lista eventi"
114
+
115
+ #: dbem_widgets.php:178
116
+ #: dbem_widgets.php:179
117
+ msgid "Events Calendar"
118
+ msgstr "Calendario eventi"
119
+
120
+ #: events-manager.php:267
121
+ msgid "New event successfully inserted!"
122
+ msgstr "Nuovo evento inserito!"
123
+
124
+ #: events-manager.php:281
125
+ msgid "Event"
126
+ msgstr "Evento"
127
+
128
+ #: events-manager.php:281
129
+ msgid "updated"
130
+ msgstr "aggiornato"
131
+
132
+ #: events-manager.php:311
133
+ msgid "Insert New Event"
134
+ msgstr "Inserisci un nuovo evento"
135
+
136
+ #: events-manager.php:313
137
+ msgid "Edit Event"
138
+ msgstr "Modifica l'evento"
139
+
140
+ #: events-manager.php:350
141
+ msgid "Past Events"
142
+ msgstr "Eventi passati"
143
+
144
+ #: events-manager.php:353
145
+ msgid "All Events"
146
+ msgstr "Tutti gli eventi"
147
+
148
+ #: events-manager.php:356
149
+ msgid "Future Events"
150
+ msgstr "Eventi futuri"
151
+
152
+ #: events-manager.php:374
153
+ msgid "Event Manager Options"
154
+ msgstr "Opzioni di Events Manager"
155
+
156
+ #: events-manager.php:379
157
+ msgid "Default event list format"
158
+ msgstr "Formato predefinito della lista eventi"
159
+
160
+ #: events-manager.php:381
161
+ msgid "The format of any events in a list."
162
+ msgstr "Il formato di ciascun evento della lista."
163
+
164
+ #: events-manager.php:382
165
+ msgid "Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_VENUE</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_NOTES</code>. Use <code>#_LINKEDNAME</code> for the event name with a link to the given event page. Use #_URL to print the event URL and make your own customised links."
166
+ msgstr "Inserire uno o più dei seguenti segnaposto: <code>#_NAME</code>, <code>#_VENUE</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_NOTES</code>. Utilizzare <code>#_LINKEDNAME</code> per il nome dell'evento con un link alla pagina corrispondente. Utilizzare #_URL per visualizzare l'URL dell'evento e creare link personalizzati."
167
+
168
+ #: events-manager.php:383
169
+ msgid "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 # symbol before them, i.e. #m. #M, #j, etc. "
170
+ msgstr "Per inserire valori di data e ora, utilizzare i <a href=\"http://www.php.net/manual/it/function.date.php\">caratteri di stringa formato PHP</a> anteponendo ad essi un #, ad esempio #m. #M, #j, etc. "
171
+
172
+ #: events-manager.php:384
173
+ msgid "Use HTML tags as <code>li</code>, <code>br</code>, etc."
174
+ msgstr "Utilizzare liberamente tag HTML come <code>li</code>, <code>br</code>, ecc."
175
+
176
+ #: events-manager.php:387
177
+ msgid "Single event page title format"
178
+ msgstr "Formato del titolo della pagina eventi"
179
+
180
+ #: events-manager.php:390
181
+ msgid "The format of a single event page title."
182
+ msgstr "Il formato del titolo della pagina di un singolo evento."
183
+
184
+ #: events-manager.php:391
185
+ #: events-manager.php:399
186
+ #: events-manager.php:470
187
+ #: events-manager.php:501
188
+ msgid "Follow the previous formatting instructions."
189
+ msgstr "Seguire le istruzioni di formattazione precedenti."
190
+
191
+ #: events-manager.php:395
192
+ msgid "Default single event format"
193
+ msgstr "Fomato predefinito di un singolo evento"
194
+
195
+ #: events-manager.php:398
196
+ msgid "The format of a single eventy page."
197
+ msgstr "Il formati della pagina di un singolo evento."
198
+
199
+ #: events-manager.php:400
200
+ msgid "Use <code>#_MAP</code> to insert a map."
201
+ msgstr "Utilizzare <code>#_MAP</code> per inserire una mappa."
202
+
203
+ #: events-manager.php:408
204
+ msgid "Show events page in lists?"
205
+ msgstr "Mostrare la pagina degli eventi nelle liste?"
206
+
207
+ #: events-manager.php:410
208
+ #: events-manager.php:484
209
+ msgid "Yes"
210
+ msgstr "Sì"
211
+
212
+ #: events-manager.php:411
213
+ #: events-manager.php:485
214
+ msgid "No"
215
+ msgstr "No"
216
+
217
+ #: events-manager.php:412
218
+ msgid "Check this option if you want the events page to appear together with other pages in pages lists."
219
+ msgstr "Selezionare questa opzione se si vuole che la pagina degli eventi compaia nelle liste delle pagine."
220
+
221
+ #: events-manager.php:428
222
+ msgid "Events page title"
223
+ msgstr "Titolo della pagina degli eventi"
224
+
225
+ #: events-manager.php:431
226
+ msgid "The title on the multiple events page."
227
+ msgstr "Il titolo della pagina che contiene più eventi."
228
+
229
+ #: events-manager.php:443
230
+ msgid "RSS main title"
231
+ msgstr "Titolo principale dell'RSS"
232
+
233
+ #: events-manager.php:446
234
+ msgid "The main title of your RSS events feed."
235
+ msgstr "Il titolo principale del feed RSS degli eventi."
236
+
237
+ #: events-manager.php:450
238
+ msgid "RSS main description"
239
+ msgstr "Descrizione principale dell'RSS"
240
+
241
+ #: events-manager.php:453
242
+ msgid "The main description of your RSS events feed."
243
+ msgstr "La descrizione principale del feed RSS degli eventi."
244
+
245
+ #: events-manager.php:458
246
+ msgid "RSS title format"
247
+ msgstr "Formato del titolo dell'RSS"
248
+
249
+ #: events-manager.php:461
250
+ msgid "The format of the title of each item in the events RSS feed."
251
+ msgstr "Il formato del titolo di ciascun elemento nel feed RSS."
252
+
253
+ #: events-manager.php:466
254
+ msgid "RSS description format"
255
+ msgstr "Formato della descrizione nell'RSS"
256
+
257
+ #: events-manager.php:469
258
+ msgid "The format of the description of each item in the events RSS feed."
259
+ msgstr "Il formato della descrizione di ciascun elemento nel feed RSS."
260
+
261
+ #: events-manager.php:482
262
+ msgid "Enable Google Maps integration?"
263
+ msgstr "Abilitare l'integrazione con Google Maps?"
264
+
265
+ #: events-manager.php:486
266
+ msgid "Check this option to enable Goggle Map integration."
267
+ msgstr "Selezionare questa opzione per abilitare l'integrazione con Google Maps."
268
+
269
+ #: events-manager.php:491
270
+ msgid "Google Maps API Key"
271
+ msgstr "Chiave API di Google Maps"
272
+
273
+ #: events-manager.php:494
274
+ msgid "To display Google Maps you need a Google Maps API key. Don't worry, it's free, you can get one"
275
+ msgstr "Per visualizzare una mappa di Google Maps è necessaria una chiave API di Google Maps. Non preoccupatevi, è gratuita, è sufficiente andare su"
276
+
277
+ #: events-manager.php:494
278
+ msgid "here"
279
+ msgstr "questa pagina"
280
+
281
+ #: events-manager.php:498
282
+ msgid "Map text format"
283
+ msgstr "Formato del testo della mappa"
284
+
285
+ #: events-manager.php:500
286
+ msgid "The format the text appearing in the map cloud."
287
+ msgstr "Il fomato del testo del fumetto che appare sulla mappa."
288
+
289
+ #: events-manager.php:505
290
+ msgid "Save Changes"
291
+ msgstr "Salva le modifiche"
292
+
293
+ #: events-manager.php:839
294
+ msgid "New Event ..."
295
+ msgstr "Nuovo evento..."
296
+
297
+ #: events-manager.php:855
298
+ msgid "ID"
299
+ msgstr "ID"
300
+
301
+ #: events-manager.php:856
302
+ #: events-manager.php:963
303
+ msgid "Name"
304
+ msgstr "Nome"
305
+
306
+ #: events-manager.php:857
307
+ #: events-manager.php:994
308
+ msgid "Venue"
309
+ msgstr "Locale"
310
+
311
+ #: events-manager.php:858
312
+ #: events-manager.php:987
313
+ msgid "Town"
314
+ msgstr "Città"
315
+
316
+ #: events-manager.php:859
317
+ #: events-manager.php:1001
318
+ msgid "Address"
319
+ msgstr "Indirizzo"
320
+
321
+ #: events-manager.php:860
322
+ msgid "Date"
323
+ msgstr "Data"
324
+
325
+ #: events-manager.php:861
326
+ msgid "Time"
327
+ msgstr "Ora"
328
+
329
+ #: events-manager.php:863
330
+ msgid "Latitude"
331
+ msgstr "Latitudine"
332
+
333
+ #: events-manager.php:864
334
+ msgid "Longitude"
335
+ msgstr "Longitudine"
336
+
337
+ #: events-manager.php:866
338
+ msgid "Actions"
339
+ msgstr "Azioni"
340
+
341
+ #: events-manager.php:927
342
+ msgid "Edit"
343
+ msgstr "Modifica"
344
+
345
+ #: events-manager.php:928
346
+ msgid "Are you sure?"
347
+ msgstr "Sei sicuro?"
348
+
349
+ #: events-manager.php:928
350
+ msgid "Delete"
351
+ msgstr "Elimina"
352
+
353
+ #: events-manager.php:966
354
+ msgid "The event name. Example: Birthday party"
355
+ msgstr "Il nome dell'evento. Esempio: festa di compleanno."
356
+
357
+ #: events-manager.php:970
358
+ msgid "Day and Time"
359
+ msgstr "Giorno e ora."
360
+
361
+ #: events-manager.php:976
362
+ msgid "The event day and time. Example: 21/11/2009 - 21:30"
363
+ msgstr "Giorno e ora dell'evento. Esempio: 21/11/2009 - 21:30"
364
+
365
+ #: events-manager.php:982
366
+ msgid "Map not found"
367
+ msgstr "Mappa non trovata"
368
+
369
+ #: events-manager.php:990
370
+ msgid "The event town. Example: Verona. If you' using the Google Map integration and want to avoid geotagging ambiguities include the country as well. Example: Verona, Italy"
371
+ msgstr "La città dell'evento. Esempio: Verona. Se si utilizza Google Map e si vogliono evitare ambiguità, inserire anche lo stato. Esempio: Verona, Italy"
372
+
373
+ #: events-manager.php:997
374
+ msgid "The venue where the event takes place. Example: Arena"
375
+ msgstr "Il locale dove avviene l'evento. Esempio: Arena"
376
+
377
+ #: events-manager.php:1004
378
+ msgid "The address of the venue. Example: Via Mazzini 22"
379
+ msgstr "L'indirizzo del locale. Esempio: Via Mazzini 22"
380
+
381
+ #: events-manager.php:1008
382
+ msgid "Notes"
383
+ msgstr "Note"
384
+
385
+ #: events-manager.php:1011
386
+ msgid "Notes about the event"
387
+ msgstr "Note sull'evento"
388
+
389
+ #: events-manager.php:1016
390
+ msgid "Submit Event"
391
+ msgstr "Invia evento"
392
+
393
+ #: events-manager.php:1274
394
+ msgid "You cannot enable Google Maps integration without setting an appropriate API key."
395
+ msgstr "Non è possibile abilitare l'integrazione con Google Maps senza impostare una chiave API."
396
+
397
+ #~ msgid ""
398
+ #~ "You are about to delete this event.\\n 'Cancel' to stop, 'OK' to delete."
399
+ #~ msgstr ""
400
+ #~ "Stai per cancellare questo evento.\\n \\'Cancel\\' per annullare "
401
+ #~ "l'opererazione, \\'Ok\\' per cancellare."
402
+ #~ msgid "Widget Title"
403
+ #~ msgstr "Titolo"
404
+
dbem_calendar.php ADDED
@@ -0,0 +1,279 @@
1
+ <?php
2
+
3
+ function dbem_get_calendar($month="") {
4
+
5
+ global $wpdb;
6
+ // if (!($month))
7
+ $date = mktime(0,0,0,date('m'), date('d'), date('Y'));
8
+ $day = date('d', $date);
9
+ $month = date('m', $date);
10
+ $year = date('Y', $date);
11
+ // Get the first day of the month
12
+ $month_start = mktime(0,0,0,$month, 1, $year);
13
+ // Get friendly month name
14
+
15
+ $month_name = mysql2date('M', "$year-$month-$day 00:00:00");
16
+ // Figure out which day of the week
17
+ // the month starts on.
18
+ $month_start_day = date('D', $month_start);
19
+ switch($month_start_day){
20
+ case "Sun": $offset = 6; break;
21
+ case "Mon": $offset = 0; break;
22
+ case "Tue": $offset = 1; break;
23
+ case "Wed": $offset = 2; break;
24
+ case "Thu": $offset = 3; break;
25
+ case "Fri": $offset = 4; break;
26
+ case "Sat": $offset = 5; break;
27
+ }
28
+
29
+ // determine how many days are in the last month.
30
+ if($month == 1) {
31
+ $num_days_last = dbem_days_in_month(12, ($year -1));
32
+ } else {
33
+ $num_days_last = dbem_days_in_month(($month-1), $year);
34
+ }
35
+ // determine how many days are in the current month.
36
+ $num_days_current = dbem_days_in_month($month, $year);
37
+ // Build an array for the current days
38
+ // in the month
39
+ for($i = 1; $i <= $num_days_current; $i++){
40
+ $num_days_array[] = mktime(0,0,0,date('m'), $i, date('Y'));
41
+ }
42
+ // Build an array for the number of days
43
+ // in last month
44
+ for($i = 1; $i <= $num_days_last; $i++){
45
+ $num_days_last_array[] = $i;
46
+ }
47
+ // If the $offset from the starting day of the
48
+ // week happens to be Sunday, $offset would be 0,
49
+ // so don't need an offset correction.
50
+
51
+ if($offset > 0){
52
+ $offset_correction = array_slice($num_days_last_array, -$offset, $offset);
53
+ $new_count = array_merge($offset_correction, $num_days_array);
54
+ $offset_count = count($offset_correction);
55
+ }
56
+
57
+ // The else statement is to prevent building the $offset array.
58
+ else {
59
+ $offset_count = 0;
60
+ $new_count = $num_days_array;
61
+ }
62
+ // count how many days we have with the two
63
+ // previous arrays merged together
64
+ $current_num = count($new_count);
65
+
66
+ // Since we will have 5 HTML table rows (TR)
67
+ // with 7 table data entries (TD)
68
+ // we need to fill in 35 TDs
69
+ // so, we will have to figure out
70
+ // how many days to appened to the end
71
+ // of the final array to make it 35 days.
72
+
73
+
74
+ if($current_num > 35){
75
+ $num_weeks = 6;
76
+ $outset = (42 - $current_num);
77
+ } elseif($current_num < 35){
78
+ $num_weeks = 5;
79
+ $outset = (35 - $current_num);
80
+ }
81
+ if($current_num == 35){
82
+ $num_weeks = 5;
83
+ $outset = 0;
84
+ }
85
+ // Outset Correction
86
+ for($i = 1; $i <= $outset; $i++){
87
+ $new_count[] = $i;
88
+ }
89
+ // Now let's "chunk" the $all_days array
90
+ // into weeks. Each week has 7 days
91
+ // so we will array_chunk it into 7 days.
92
+ $weeks = array_chunk($new_count, 7);
93
+
94
+
95
+
96
+ // Build Previous and Next Links
97
+ $previous_link = "<a href=\"".$_SERVER['PHP_SELF']."?date=";
98
+ if($month == 1){
99
+ $previous_link .= mktime(0,0,0,12,$day,($year -1));
100
+ } else {
101
+ $previous_link .= mktime(0,0,0,($month -1),$day,$year);
102
+ }
103
+ $previous_link .= "\">&lt;&lt; Prev</a>";
104
+
105
+ $next_link = "<a href=\"".$_SERVER['PHP_SELF']."?date=";
106
+ if($month == 12){
107
+ $next_link .= mktime(0,0,0,1,$day,($year + 1));
108
+ } else {
109
+ $next_link .= mktime(0,0,0,($month +1),$day,$year);
110
+ }
111
+ $next_link .= "\">Next >></a>";
112
+
113
+ $calendar="<div id='dbem-calendar'>";
114
+
115
+ // Build the heading portion of the calendar table
116
+ $calendar .= "<table id='dbem-calendar-table'>\n".
117
+ "<thead>\n<tr>\n".
118
+ "<td colspan='7'>$month_name $year</td>\n".
119
+ "</tr>\n</thead>\n".
120
+ "<tr class='days-names'>\n".
121
+ "<td>".__('M_Monday_initial')."</td><td>".__('T_Tuesday_initial')."</td><td>".__('W_Wednesday_initial')."</td><td>".__('T_Thursday_initial')."</td><td>".__('F_Friday_initial')."</td><td>".__('S_Saturday_initial')."</td><td>".__('S_Sunday_initial')."</td>\n".
122
+ "</tr>\n";
123
+
124
+ // Now we break each key of the array
125
+ // into a week and create a new table row for each
126
+ // week with the days of that week in the table data
127
+
128
+ $i = 0;
129
+ foreach($weeks as $week){
130
+ $calendar .= "<tr>\n";
131
+ foreach($week as $d){
132
+ if($i < $offset_count){ //if it is PREVIOUS month
133
+ $calendar .= "<td class='eventless-pre'>$d</td>\n";
134
+ }
135
+ if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)){ // if it is THIS month
136
+ $fullday=$d;
137
+ $d=date('j', $d);
138
+ $day_link = "$d";
139
+ if($date == mktime(0,0,0,$month,$d,$year)){
140
+ $calendar .= "<td class='eventless-today'>$d</td>\n";
141
+ } else {
142
+ $calendar .= "<td class='eventless'>$day_link</td>\n";
143
+ }
144
+ } elseif(($outset > 0)) { //if it is NEXT month
145
+ if(($i >= ($num_weeks * 7) - $outset)){
146
+ $calendar .= "<td class='eventless-post'>$d</td>\n";
147
+ }
148
+ }
149
+ $i++;
150
+ }
151
+ $calendar .= "</tr>\n";
152
+ }
153
+ // $calendar .= "<tr>\n".
154
+ // "<td colspan='7'>\n".
155
+ // "<table align='center'>\n".
156
+ // "<tr class='month-navigation'>\n".
157
+ // "<td class='previous-month' colspan='2' align='left'>$previous_link</td>\n".
158
+ // "<td colspan='3'>&nbsp;</td>".
159
+ // "<td class='next-month' colspan='2' align='right'>$next_link</td>\n".
160
+ // "</tr>\n".
161
+ // "</table>\n".
162
+ // "</td>\n</tr>\n";
163
+ $calendar .= " </table>\n</div>";
164
+
165
+ // query the database for events in this time span
166
+ if ($month == 1) {
167
+ $month_pre=12;
168
+ $month_post=2;
169
+ $year_pre=$year-1;
170
+ $year_post=$year;
171
+ } elseif($month == 12) {
172
+ $month_pre=11;
173
+ $month_post=1;
174
+ $year_pre=$year;
175
+ $year_post=$year+1;
176
+ } else {
177
+ $month_pre=$month-1;
178
+ $month_post=$month+1;
179
+ $year_pre=$year;
180
+ $year_post=$year;
181
+ }
182
+ $limit_pre=mktime(0,0,0,$month_pre, 1 , $year_pre);
183
+ $limit_post=mktime(0,0,0,$month_post, 30 , $year_post);
184
+ $events=$wpdb->get_results("SELECT event_id,
185
+ event_name,
186
+ event_venue,
187
+ event_town,
188
+ event_province,
189
+ event_time,
190
+ DATE_FORMAT(event_time, '%w') AS 'event_weekday_n',
191
+ DATE_FORMAT(event_time, '%e') AS 'event_day',
192
+ DATE_FORMAT(event_time, '%c') AS 'event_month_n',
193
+ DATE_FORMAT(event_time, '%Y') AS 'event_year',
194
+ DATE_FORMAT(event_time, '%k') AS 'event_hh',
195
+ DATE_FORMAT(event_time, '%i') AS 'event_mm'
196
+ FROM ".$wpdb->prefix."events WHERE UNIX_TIMESTAMP(event_time) > $limit_pre AND UNIX_TIMESTAMP(event_time) < $limit_post ORDER BY event_time");
197
+ //----- DEBUG ------------
198
+ //foreach($events as $event) { //DEBUG
199
+ // $calendar .= ("$event->event_day / $event->event_month_n - $event->event_name<br/>");
200
+ //}
201
+ // ------------------
202
+ // inserts the events
203
+ $events_page = get_option('dbem_events_page');
204
+ if($events){
205
+ foreach($events as $event) {
206
+ if ($event->event_month_n == $month_pre) {
207
+ $calendar=str_replace("<td class='eventless-pre'>$event->event_day</td>","<td class='eventful-pre'><a href='?page_id=$events_page&amp;event_id="."$event->event_id'>$event->event_day</a></td>",$calendar);
208
+ } elseif($event->event_month_n == $month_post) {
209
+ $calendar=str_replace("<td class='eventless-post'>$event->event_day</td>","<td class='eventful-post'><a href='?page_id=$events_page&amp;event_id="."$event->event_id'>$event->event_day</a></td>",$calendar);
210
+ } elseif($event->event_day == $day) {
211
+ $calendar=str_replace("<td class='eventless-today'>$event->event_day</td>","<td class='eventful-today'><a href='?page_id=$events_page&amp;event_id="."$event->event_id'>$event->event_day</a></td>",$calendar);
212
+ } else{
213
+ $calendar=str_replace("<td class='eventless'>$event->event_day</td>","<td class='eventful'><a href='?page_id=$events_page&amp;event_id="."$event->event_id'>$event->event_day</a></td>",$calendar);
214
+ }
215
+ }
216
+ }
217
+ $output=$calendar;
218
+
219
+ echo $output;
220
+ }
221
+
222
+ function dbem_days_in_month($month, $year) {
223
+ switch ($month) {
224
+ case (2):
225
+ if ($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0)) {
226
+ return 29;
227
+ } else {
228
+ return 28;
229
+ }
230
+ break;
231
+ case (4):
232
+ return 30;
233
+ break;
234
+ case (6):
235
+ return 30;
236
+ break;
237
+ case (9):
238
+ return 30;
239
+ break;
240
+ case (11):
241
+ return 30;
242
+ break;
243
+ default:
244
+ return 31;
245
+ break;
246
+ }
247
+ }
248
+
249
+ function dbem_calendar_style() {
250
+ ?>
251
+ <style type="text/css">
252
+ #dbem-calendar td {
253
+ padding: 2px 4px;
254
+ text-align: center;
255
+ }
256
+ #dbem-calendar tr.days-names {
257
+ font-weight: bold;
258
+ }
259
+ #dbem-calendar td.eventless-pre, #dbem-calendar td.eventless-post {
260
+ color: #ccc;
261
+ }
262
+ #dbem-calendar td.eventful a {
263
+ font-weight: bold;
264
+ color: #FD7E29;
265
+ }
266
+ #dbem-calendar td.eventless-today {
267
+ background-color: #CFCFCF;
268
+ }
269
+ #dbem-calendar thead {
270
+ font-size: 120%;
271
+ font-weight: bold;
272
+ }
273
+ </style>
274
+ <?php
275
+ }
276
+ add_action('wp_head', 'dbem_calendar_style');
277
+
278
+
279
+ ?>
dbem_widgets.php ADDED
@@ -0,0 +1,188 @@
1
+ <?php
2
+ // List widget
3
+ function widget_dbem_list($args) {
4
+ extract($args);
5
+
6
+ $options = get_option("widget_dbem_list");
7
+ if (!is_array( $options ))
8
+ {
9
+ $options = array(
10
+ 'title' => __('Events','dbem')
11
+ );
12
+ }
13
+
14
+ echo $before_widget;
15
+ echo $before_title;
16
+ echo $options['title'];
17
+ echo $after_title;
18
+ $events_list = dbem_get_events_list($options['limit'],$options['scope'],$options['order'] ,$options['format'], false);
19
+ if ($events_list == __('No events', 'dbem'))
20
+ $events_list = "<li>$events_list</li>";
21
+ echo "<ul>
22
+ $events_list
23
+ </ul>";
24
+
25
+ echo $after_widget;
26
+ }
27
+
28
+ function dbem_list_control()
29
+ {
30
+ $options = get_option("widget_dbem_list");
31
+
32
+ if (!is_array( $options ))
33
+ {
34
+ $options = array(
35
+ 'title' => _('Events', 'dbem'),
36
+ 'limit' => '5',
37
+ 'scope' => 'future',
38
+ 'order' => 'ASC',
39
+ 'format' => DEFAULT_WIDGET_EVENT_LIST_ITEM_FORMAT
40
+ );
41
+ }
42
+
43
+ if ($_POST['dbem_list-Submit'])
44
+ {
45
+ $options['title'] = htmlspecialchars($_POST['dbem_list-WidgetTitle']);
46
+ $options['limit'] = $_POST['dbem_list-WidgetLimit'];
47
+ $options['scope'] = $_POST['dbem_list-WidgetScope'];
48
+ $options['order'] = $_POST['dbem_list-WidgetOrder'];
49
+ $options['format'] = $_POST['dbem_list-WidgetFormat'];
50
+ update_option("widget_dbem_list", $options);
51
+ }
52
+
53
+ if ($options['scope'] == "all" )
54
+ $allSelected = "selected='selected'";
55
+ else
56
+ $allSelected = "";
57
+ if ($options['scope'] == "past" )
58
+ $pastSelected = "selected='selected'";
59
+ else
60
+ $pastSelected = "";
61
+ if ($options['scope'] == "future" )
62
+ $futureSelected = "selected='selected'";
63
+ else
64
+ $futureSelected = "";
65
+
66
+ if ($options['order'] == "ASC" )
67
+ $ASCSelected = "selected='selected'";
68
+ else
69
+ $ASCSelected = "";
70
+ if ($options['order'] == "DESC" )
71
+ $DESCSelected = "selected='selected'";
72
+ else
73
+ $DESCSelected = "";
74
+
75
+
76
+ ?>
77
+ <p>
78
+ <label for="dbem_list-WidgetTitle"><?php _e('Title'); ?>: </label>
79
+ <input type="text" id="dbem_list-WidgetTitle" name="dbem_list-WidgetTitle" value="<?php echo $options['title'];?>" />
80
+ </p>
81
+ <p>
82
+ <label for="dbem_list-WidgetTitle"><?php _e('Number of events','dbem'); ?>: </label>
83
+ <input type="text" id="dbem_list-WidgetLimit" name="dbem_list-WidgetLimit" value="<?php echo $options['limit'];?>" />
84
+ </p>
85
+ <p>
86
+ <label for="dbem_list-WidgetScope"><?php _e('Scope of the events','dbem'); ?>:</label><br/>
87
+ <select name="dbem_list-WidgetScope" >
88
+ <option value="future" <?php echo $futureSelected; ?>><?php _e('Future events','dbem'); ?></option>
89
+ <option value="all" <?php echo $allSelected; ?>><?php _e('All events','dbem'); ?></option>
90
+ <option value="past" <?php echo $pastSelected; ?>><?php _e('Past events','dbem'); ?>:</option>
91
+ </select>
92
+ </p>
93
+ <p>
94
+ <label for="dbem_list-WidgetOrder"><?php _e('Order of the events','dbem'); ?>:</label><br/>
95
+ <select name="dbem_list-WidgetOrder" >
96
+ <option value="ASC" <?php echo $ASCSelected; ?>><?php _e('Ascendant','dbem'); ?></option>
97
+ <option value="DESC" <?php echo $DESCSelected; ?>><?php _e('Descendant','dbem'); ?>:</option>
98
+ </select>
99
+ </p>
100
+ <p>
101
+ <label for="dbem_list-WidgetTitle"><?php _e('List item format','dbem'); ?>:</label>
102
+ <textarea id="dbem_list-WidgetFormat" name="dbem_list-WidgetFormat" rows="5" cols="24"><?php echo $options['format'];?></textarea>
103
+ </p>
104
+ <input type="hidden" id="dbem_list-Submit" name="dbem_list-Submit" value="1" />
105
+ <?php
106
+ }
107
+
108
+ // Calendar widget
109
+
110
+
111
+
112
+
113
+
114
+
115
+ function widget_dbem_calendar($args) {
116
+ extract($args);
117
+
118
+ $options = get_option("widget_dbem_calendar");
119
+ if (!is_array( $options ))
120
+ {
121
+ $options = array(
122
+ 'title' => _e('calendar','dbem')
123
+ );
124
+ }
125
+
126
+ echo $before_widget;
127
+ echo $before_title;
128
+ echo $options['title'];
129
+ echo $after_title;
130
+ //Our Widget Content
131
+ $current_month = date("m");
132
+
133
+ dbem_get_calendar($current_month);
134
+ echo $after_widget;
135
+ }
136
+
137
+ function dbem_calendar_control()
138
+ {
139
+ $options = get_option("widget_dbem_calendar");
140
+
141
+ if (!is_array( $options ))
142
+ {
143
+ $options = array(
144
+ 'title' => 'Calendar',
145
+ );
146
+ }
147
+
148
+ if ($_POST['dbem_calendar-Submit'])
149
+ {
150
+ $options['title'] = htmlspecialchars($_POST['dbem_calendar-WidgetTitle']);
151
+ update_option("widget_dbem_calendar", $options);
152
+ }
153
+
154
+ ?>
155
+ <p>
156
+ <label for="dbem_calendar-WidgetTitle"><?php _e('Title'); ?>:</label>
157
+ <input type="text" id="dbem_calendar-WidgetTitle" name="dbem_calendar-WidgetTitle" value="<?php echo $options['title'];?>" />
158
+ <input type="hidden" id="dbem_calendar-Submit" name="dbem_calendar-Submit" value="1" />
159
+ </p>
160
+ <?php
161
+ }
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ // widgets registration
172
+ function dbem_list_init()
173
+ {
174
+ // $widget_ops = array('classname' => 'widget_dbem_list', 'description' => __( "A list of the events") );
175
+ // wp_register_sidebar_widget('widget_dbem_list', __('Events List'), 'widget_dbem_list', $widget_ops);
176
+ register_sidebar_widget(__('Events List', 'dbem'), 'widget_dbem_list');
177
+ register_widget_control(__('Events List', 'dbem'), 'dbem_list_control', 200, 200 );
178
+ register_sidebar_widget(__('Events Calendar','dbem'), 'widget_dbem_calendar');
179
+ register_widget_control(__('Events Calendar','dbem'), 'dbem_calendar_control', 300, 200 );
180
+ }
181
+ add_action("plugins_loaded", "dbem_list_init");
182
+
183
+
184
+
185
+
186
+
187
+
188
+ ?>
events-manager.php ADDED
@@ -0,0 +1,1395 @@
1
+ <?php
2
+ /*
3
+ Plugin Name: Events Manager
4
+ Version: 1.0
5
+ Plugin URI: http://davidebenini.it/wordpress-plugins/events-manager/
6
+ Description: Manage events specifying precise spatial data (Venue, Town, Province, etc).
7
+ Author: Davide Benini
8
+ Author URI: http://www.davidebenini.it/blog
9
+ */
10
+
11
+ /*
12
+ Copyright (c) 2008, Davide Benini. $Revision: 1 $
13
+
14
+ This program is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU General Public License
16
+ as published by the Free Software Foundation; either version 2
17
+ of the License, or (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
+ */
28
+
29
+ /*************************************************/
30
+ include("dbem_calendar.php");
31
+ include("dbem_widgets.php");
32
+ // Setting constants
33
+ define('TBNAME','events'); //TABLE NAME
34
+ define('DEFAULT_EVENT_PAGE_NAME', 'Events');
35
+ define('DBEM_PAGE','<!--DBEM_EVENTS_PAGE-->'); //EVENTS PAGE
36
+ define('MIN_CAPABILITY', 'edit_posts'); // Minimum user level to access calendars
37
+ define('SETTING_CAPABILITY', 'activate_plugins'); // Minimum user level to access calendars
38
+ define('DEFAULT_EVENT_LIST_ITEM_FORMAT', '<li>#j #M #Y - #H:#i<br/> #_LINKEDNAME<br/>#_TOWN </li>');
39
+ define('DEFAULT_SINGLE_EVENT_FORMAT', '<p>#j #M #Y - #H:#i</p><p>#_TOWN</p>');
40
+ define('DEFAULT_EVENTS_PAGE_TITLE',__('Events','dbem') ) ;
41
+ define('DEFAULT_EVENT_PAGE_TITLE_FORMAT', ' #_NAME');
42
+ define('DEFAULT_RSS_DESCRIPTION_FORMAT',"#j #M #y - #H:#i <br/>#_VENUE <br/>#_ADDRESS <br/>#_TOWN");
43
+ define('DEFAULT_RSS_TITLE_FORMAT',"#_NAME");
44
+ define('DEFAULT_MAP_TEXT_FORMAT', '<strong>#_VENUE</strong><p>#_ADDRESS</p><p>#_TOWN</p>');
45
+ define('DEFAULT_WIDGET_EVENT_LIST_ITEM_FORMAT','#_LINKEDNAME<ul><li>#j #M #y</li><li>#_TOWN</li></ul></li>');
46
+ // DEBUG constant for developing
47
+ // if you are hacking this plugin, set to TRUE, alog will show in admin pages
48
+ define('DEBUG', false);
49
+
50
+ load_plugin_textdomain('dbem', "/wp-content/plugins/events-manager/");
51
+ // To enable activation through the activate function
52
+ register_activation_hook(__FILE__,'events-manager');
53
+
54
+ // Execute the install script when the plugin is installed
55
+ add_action('activate_events-manager/events-manager.php','dbem_install');
56
+
57
+ // filters for general events field (corresponding to those of "the _title")
58
+ add_filter('dbem_general', 'wptexturize');
59
+ add_filter('dbem_general', 'convert_chars');
60
+ add_filter('dbem_general', 'trim');
61
+ // filters for the notes field (corresponding to those of "the _content")
62
+ add_filter('dbem_notes', 'wptexturize');
63
+ add_filter('dbem_notes', 'convert_smilies');
64
+ add_filter('dbem_notes', 'convert_chars');
65
+ add_filter('dbem_notes', 'wpautop');
66
+ add_filter('dbem_notes', 'prepend_attachment');
67
+ // RSS general filters
68
+ add_filter('dbem_general_rss', 'strip_tags');
69
+ add_filter('dbem_general_rss', 'ent2ncr', 8);
70
+ add_filter('dbem_general_rss', 'wp_specialchars');
71
+ // RSS content filter
72
+ add_filter('dbem_notes_rss', 'convert_chars', 8);
73
+ add_filter('dbem_notes_rss', 'ent2ncr', 8);
74
+
75
+ add_filter('dbem_notes_map', 'convert_chars', 8);
76
+ add_filter('dbem_notes_map', 'js_escape');
77
+
78
+ /* Creating the wp_events table to store event data*/
79
+ function dbem_install() {
80
+ global $wpdb, $user_level;
81
+ $table_name = $wpdb->prefix.TBNAME;
82
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
83
+ // check the user is allowed to make changes
84
+ // get_currentuserinfo();
85
+ // if ($user_level < 8) { return; }
86
+
87
+ // Creating the events table
88
+ $sql = "CREATE TABLE ".$table_name." (
89
+ event_id mediumint(9) NOT NULL AUTO_INCREMENT,
90
+ event_author mediumint(9) NOT NULL,
91
+ event_name tinytext NOT NULL,
92
+ event_time datetime NOT NULL,
93
+ event_venue tinytext NOT NULL,
94
+ event_address tinytext NOT NULL,
95
+ event_town tinytext NOT NULL,
96
+ event_province tinytext,
97
+ event_notes text NOT NULL,
98
+ event_latitude float DEFAULT NULL,
99
+ event_longitude float DEFAULT NULL,
100
+ UNIQUE KEY (event_id)
101
+ );";
102
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
103
+ dbDelta($sql);
104
+ //-------------- DEBUG CODE to insert a few events n the new table
105
+ // get the current timestamp into an array
106
+ $timestamp = time();
107
+ $date_time_array = getdate($timestamp);
108
+
109
+ $hours = $date_time_array['hours'];
110
+ $minutes = $date_time_array['minutes'];
111
+ $seconds = $date_time_array['seconds'];
112
+ $month = $date_time_array['mon'];
113
+ $day = $date_time_array['mday'];
114
+ $year = $date_time_array['year'];
115
+
116
+ // use mktime to recreate the unix timestamp
117
+ // adding 19 hours to $hours
118
+ $in_one_week = strftime('%Y-%m-%d 21:30:00', mktime($hours,$minutes,$seconds,$month,$day+7,$year));
119
+ $in_four_weeks = strftime('%Y-%m-%d 16:00:00',mktime($hours,$minutes,$seconds,$month,$day+28,$year));
120
+ $in_one_year = strftime('%Y-%m-%d 22:00:00',mktime($hours,$minutes,$seconds,$month,$day,$year+1));
121
+
122
+ $wpdb->query("INSERT INTO ".$wpdb->prefix."events (event_name, event_venue, event_address, event_time, event_town)
123
+ VALUES ('Monster gig','Wembley stadium', 'Wembley', '$in_one_week','London')");
124
+ $wpdb->query("INSERT INTO ".$wpdb->prefix."events (event_name, event_venue,event_address, event_time, event_town)
125
+ VALUES ('Fiesta Mexicana','Hard Rock Cafe', '1501 Broadway', '$in_four_weeks','New York')");
126
+ $wpdb->query("INSERT INTO ".$wpdb->prefix."events (event_name, event_venue,event_address, event_time, event_town)
127
+ VALUES ('Gladiators fight','Arena', 'Piazza Bra', '$in_one_year','Verona')");
128
+ }
129
+
130
+
131
+
132
+ $events_page_id = get_option('dbem_events_page') ;
133
+ if ($events_page_id != "" ) {
134
+ query_posts("page_id=$events_page_id");
135
+ $count = 0;
136
+ while(have_posts()) { the_post();
137
+ $count++;
138
+ }
139
+ if ($count == 0)
140
+ dbem_create_events_page();
141
+ } else {
142
+ dbem_create_events_page();
143
+ }
144
+ //if (get_option('dbem_events_page'))
145
+ //$event_page_id = get_option('dbem_events_page');
146
+ //dbem_create_events_page();
147
+ // Adding plugin options
148
+ $event_list_item_format = get_option('dbem_event_list_item_format');
149
+ if (empty($event_list_item_format))
150
+ update_option('dbem_event_list_item_format', DEFAULT_EVENT_LIST_ITEM_FORMAT);
151
+
152
+ $single_event_format = get_option('dbem_single_event_format');
153
+ if (empty($single_event_format))
154
+ update_option('dbem_single_event_format', DEFAULT_SINGLE_EVENT_FORMAT);
155
+
156
+ $event_page_title_format = get_option('dbem_event_page_title_format');
157
+ if (empty($event_page_title_format))
158
+ update_option('dbem_event_page_title_format', DEFAULT_EVENT_PAGE_TITLE_FORMAT);
159
+
160
+ $list_events_page = get_option('dbem_list_events_page');
161
+ if (empty($list_events_page))
162
+ update_option('dbem_list_events_page', 0);
163
+
164
+ $events_page_title = get_option('dbem_events_page_title');
165
+ if (empty($events_page_title))
166
+ update_option('dbem_events_page_title', DEFAULT_EVENTS_PAGE_TITLE);
167
+
168
+ $map_text_format = get_option('dbem_map_text_format');
169
+ if (empty($map_text_format))
170
+ update_option('dbem_map_text_format', DEFAULT_MAP_TEXT_FORMAT);
171
+
172
+ $rss_main_title = get_option('dbem_rss_main_title');
173
+ if (empty($rss_main_title)) {
174
+ $default_rss_main_title = get_bloginfo('title')." - ".__('Events');
175
+ update_option('dbem_rss_main_title', $default_rss_main_title);
176
+ }
177
+
178
+ $rss_main_description = get_option('dbem_rss_main_description');
179
+ if (empty($rss_main_description)) {
180
+ $default_rss_main_description = get_bloginfo('description')." - ".__('Events');
181
+ update_option('dbem_rss_main_description', $default_rss_main_description);
182
+ }
183
+
184
+ $rss_description_format = get_option('dbem_rss_description_format');
185
+ if (empty($rss_description_format))
186
+ update_option('dbem_rss_description_format', DEFAULT_RSS_DESCRIPTION_FORMAT);
187
+
188
+ $rss_title_format = get_option('dbem_rss_title_format');
189
+ if (empty($rss_title_format))
190
+ update_option('dbem_rss_title_format', DEFAULT_RSS_TITLE_FORMAT);
191
+
192
+ $gmap_is_active = get_option('dbem_gmap_is_active');
193
+ if(empty($gmap_is_active))
194
+ update_option('dbem_gmap_is_active', 0);
195
+
196
+ $gmap_key = get_option('dbem_gmap_key');
197
+ if (empty($gmap_key))
198
+ update_option('dbem_gmap_key', '');
199
+
200
+ }
201
+
202
+ function dbem_create_events_page(){
203
+ echo "inserimento pagina";
204
+ global $wpdb,$current_user;
205
+ $page_name= DEFAULT_EVENT_PAGE_NAME;
206
+ $sql= "INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_type, post_content, post_title, post_name, post_modified, post_modified_gmt, comment_count) VALUES ($current_user->ID, '$now', '$now_gmt', 'page','CONTENTS', '$page_name', '".$wpdb->escape(__('Events','dbem'))."', '$now', '$now_gmt', '0')";
207
+ // echo($sql);
208
+ $wpdb->query($sql);
209
+
210
+ update_option('dbem_events_page', mysql_insert_id());
211
+ }
212
+
213
+ // Create the Manage Events and the Options submenus
214
+ add_action('admin_menu','dbem_create_events_submenu');
215
+ function dbem_create_events_submenu () {
216
+ if(function_exists('add_submenu_page')) {
217
+ add_submenu_page('edit.php',__('Events', 'dbem'),__('Events', 'dbem'),MIN_CAPABILITY,'eventmanager.php',dbem_events_subpanel);
218
+ // add_options_page('Events Manager','Events Manager',MIN_LEVEL,'eventmanager.php',dbem_options_subpanel);
219
+ add_options_page('Events manager', 'Events Manager', SETTING_CAPABILITY, __FILE__, dbem_options_subpanel);
220
+
221
+ }
222
+ }
223
+
224
+ // Events manager page
225
+ function dbem_events_subpanel() {
226
+
227
+
228
+
229
+ global $wpdb;
230
+ $action=$_GET['action'];
231
+ $element=$_GET['event_id'];
232
+ $scope=$_GET['scope'];
233
+ $offset=$_GET['offset'];
234
+ $order=$_GET['order'];
235
+ if ($order == "")
236
+ $order = "ASC";
237
+ if ($offset=="")
238
+ $offset = "0";
239
+
240
+ // Debug code, to make sure I get the correct page
241
+ //$event_page_id=get_option('dbem_event_page');
242
+ if (DEBUG) {
243
+ echo "<div class='debug'>\n
244
+ \t<h3>Debug log</h3>\n";
245
+ echo "<p>action = $action $element</p>\n";
246
+
247
+ }
248
+ // DELETE action
249
+ if ($action == 'delete_event') {
250
+ $sql="DELETE FROM ".$wpdb->prefix."events WHERE event_id='"."$element"."'";
251
+ if (DEBUG)
252
+ echo $sql;
253
+ // TODO eventual error if ID in non-existant
254
+ $wpdb->query($sql);
255
+ if (DEBUG)
256
+ echo "</div>"; // end of debug div
257
+ $events = dbem_get_events("", "future");
258
+ dbem_events_table($events, 10,"Future events");
259
+ }
260
+ // UPDATE or CREATE action
261
+ if ($action == 'update_event') {
262
+ // This script gets executed whenever has inserted a new event or updated an old one
263
+ $event = array();
264
+ $event['event_name']=$_POST[event_name];
265
+ $event['event_day']=$_POST[event_day];
266
+ $event['event_month']=$_POST[event_month];
267
+ $event['event_year']=$_POST[event_year];
268
+ $event['event_hh']=$_POST[event_hh];
269
+ $event['event_mm']=$_POST[event_mm];
270
+ $event['event_venue']=$_POST[event_venue];
271
+ $event['event_address']=$_POST[event_address];
272
+ $event['event_town']=$_POST[event_town];
273
+ $event['event_province']=$_POST[event_province];
274
+ $event['event_latitude']=$_POST[event_latitude];
275
+ $event['event_longitude']=$_POST[event_longitude];
276
+ $event['event_notes']=$_POST[event_notes];
277
+ $datetime="'{$event['event_year']}-{$event['event_month']}-{$event['event_day']} {$event['event_hh']}:{$event['event_mm']}:00'";
278
+ // $datetime="$event_day-$event_month-$event_year $event_hh:$event_mm:00";
279
+ $validation_result = dbem_validate_event($event);
280
+ if ( $validation_result == "OK") {
281
+ // validation successful
282
+ if(!$element) {
283
+ // INSERT new event
284
+ $sql="INSERT INTO ".$wpdb->prefix."events (event_name, event_venue, event_town, event_address, event_province, event_time, event_latitude, event_longitude, event_notes)
285
+ VALUES ('".$event['event_name']."','".$event['event_venue']."','".$event['event_town']."','".$event['event_address']."','".$event['event_province']."',".$datetime.",'".$event['event_latitude']."','".$event['event_longitude']."','".$event['event_notes']."');";
286
+ $feedback_message = __('New event successfully inserted!','dbem');
287
+ } else {
288
+ // UPDATE old event
289
+ $sql="UPDATE ".$wpdb->prefix."events
290
+ SET event_name='".$event['event_name']."', ".
291
+ "event_venue='".$event['event_venue']."',".
292
+ "event_town='".$event['event_town']."',".
293
+ "event_address='".$event['event_address']."',".
294
+ "event_province='".$event['event_province']."',".
295
+ "event_latitude='".$event['event_latitude']."',".
296
+ "event_longitude='".$event['event_longitude']."',".
297
+ "event_notes='".$event['event_notes']."',".
298
+ "event_time=$datetime ".
299
+ "WHERE event_id="."$element";
300
+ $feedback_message = __('Event','dbem')." $element ".__('updated','dbem')."!";
301
+ }
302
+ if (DEBUG)
303
+ echo "SQL = $sql";
304
+ if (DEBUG)
305
+ echo "</div>"; // end of debug
306
+
307
+ $wpdb->query($sql);
308
+ echo "<div id='message' class='updated fade'>
309
+ <p>$feedback_message</p>
310
+ </div>";
311
+ $events = dbem_get_events("", "future");
312
+ dbem_events_table($events, 10, "Future events");
313
+ } else {
314
+ // validation unsuccessful
315
+
316
+ echo $event['name'];
317
+ if (DEBUG)
318
+ echo "<p>NON VALIDO: $validation_result</p>";
319
+ if (DEBUG)
320
+ echo "</div>"; // end of debug
321
+ echo "<div id='message' class='error '>
322
+ <p>Ach, there's a problem here: $validation_result</p>
323
+ </div>";
324
+ dbem_event_form($event,"Edit event $element" ,$element);
325
+
326
+ }
327
+ }
328
+ if ($action == 'edit_event') {
329
+ if (!$element) {
330
+ $title=__("Insert New Event", 'dbem');
331
+ } else {
332
+ $title=__("Edit Event", 'dbem')." $element";
333
+ }
334
+ // If a edit operation was requested queries the event table
335
+ $sql='SELECT event_id,
336
+ event_name,
337
+ event_venue,
338
+ event_address,
339
+ event_town,
340
+ event_province,
341
+ DATE_FORMAT(event_time, "%e") AS "event_day",
342
+ DATE_FORMAT(event_time, "%c") AS "event_month",
343
+ DATE_FORMAT(event_time, "%Y") AS "event_year",
344
+ DATE_FORMAT(event_time, "%k") AS "event_hh",
345
+ DATE_FORMAT(event_time, "%i") AS "event_mm",
346
+ event_latitude,
347
+ event_longitude,
348
+ event_notes
349
+ FROM '.$wpdb->prefix.'events WHERE event_id="'.$element.'";';
350
+ $event=$wpdb->get_row($sql, ARRAY_A);
351
+ // Enter new events and updates old ones
352
+ // DEBUG: echo"Nome: $event->event_name";
353
+ if (DEBUG) {
354
+ echo "</div>";
355
+ }
356
+
357
+ dbem_event_form($event, $title, $element);
358
+
359
+ }
360
+ if ($action == ""){
361
+ // No action, only showing the events list
362
+ if (DEBUG)
363
+ echo "\t<p>No UPDATE, INSERT or DELETE action performed</p>\n
364
+ </div>";
365
+
366
+
367
+ switch ($scope) {
368
+ case "past":
369
+ $title = __('Past Events','dbem');
370
+ break;
371
+ case "all":
372
+ $title = __('All Events','dbem');
373
+ break;
374
+ default:
375
+ $title = __('Future Events','dbem');
376
+ $scope = "future";
377
+ }
378
+ $limit = 10;
379
+ $events = dbem_get_events($limit, $scope, $order,$offset);
380
+
381
+ dbem_events_table($events, $limit, $title);
382
+
383
+ }
384
+
385
+
386
+ }
387
+
388
+ // Function composing the options subpanel
389
+ function dbem_options_subpanel() {
390
+
391
+ ?>
392
+ <div class="wrap">
393
+ <h2><?php _e('Event Manager Options','dbem'); ?></h2>
394
+ <form id="dbem_options_form" method="post" action="options.php">
395
+ <?php wp_nonce_field('update-options'); ?>
396
+ <table class="form-table">
397
+ <tr valign="top">
398
+ <th scope="row"><?php _e('Default event list format','dbem')?></th>
399
+ <td><textarea name="dbem_event_list_item_format" id="dbem_event_list_item_format" rows="6" cols="60"><?php echo (get_option('dbem_event_list_item_format'));?></textarea><br/>
400
+ <?php _e('The format of any events in a list.','dbem')?><br/>
401
+ <?php _e('Insert one or more of the following placeholders: <code>#_NAME</code>, <code>#_VENUE</code>, <code>#_ADDRESS</code>, <code>#_TOWN</code>, <code>#_NOTES</code>. Use <code>#_LINKEDNAME</code> for the event name with a link to the given event page. Use #_URL to print the event URL and make your own customised links.','dbem')?>
402
+ <?php _e('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 # symbol before them, i.e. #m. #M, #j, etc. ','dbem')?><br/>
403
+ <?php _e('Use HTML tags as <code>li</code>, <code>br</code>, etc.','dbem')?></td>
404
+ </tr>
405
+ <tr valign="top">
406
+ <th scope="row"><?php _e('Single event page title format','dbem');?></th>
407
+ <td>
408
+ <input name="dbem_event_page_title_format" type="text" id="dbem_event_page_title_format" style="width: 95%" value="<?php echo get_option('dbem_event_page_title_format'); ?>" size="45" /><br />
409
+ <?php _e('The format of a single event page title.','dbem')?><br/>
410
+ <?php _e('Follow the previous formatting instructions.','dbem')?>
411
+ </td>
412
+ </tr>
413
+ <tr valign="top">
414
+ <th scope="row"><?php _e('Default single event format','dbem')?></th>
415
+ <td>
416
+ <textarea name="dbem_single_event_format" id="dbem_single_event_format" rows="6" cols="60"><?php echo (get_option('dbem_single_event_format'));?></textarea><br/>
417
+ <?php _e('The format of a single eventy page.','dbem')?><br/>
418
+ <?php _e('Follow the previous formatting instructions.','dbem')?><br/>
419
+ <?php _e('Use <code>#_MAP</code> to insert a map.','dbem')?>
420
+ </td>
421
+ </tr>
422
+
423
+
424
+ <?php $list_events_page = get_option('dbem_list_events_page'); ?>
425
+
426
+ <tr valign="top">
427
+ <th scope="row"><?php _e('Show events page in lists?','dbem'); ?></th>
428
+ <td>
429
+ <input id="dbem_list_events_page" name="dbem_list_events_page" type="radio" value="1" <?php if($list_events_page) echo "checked='checked'"; ?> /><?php _e('Yes'); ?> <br />
430
+ <input name="dbem_list_events_page" type="radio" value="0" <?php if(!$list_events_page) echo "checked='checked'"; ?> /><?php _e('No'); ?> <br />
431
+ <?php _e('Check this option if you want the events page to appear together with other pages in pages lists.','dbem')?>
432
+ </td>
433
+ </tr>
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+ <tr valign="top">
447
+ <th scope="row"><?php _e('Events page title','dbem'); ?></th>
448
+ <td>
449
+ <input name="dbem_events_page_title" type="text" id="dbem_events_page_title" style="width: 95%" value="<?php echo get_option('dbem_events_page_title'); ?>" size="45" /><br />
450
+ <?php _e('The title on the multiple events page.','dbem')?>
451
+ </td>
452
+ </tr>
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+ <tr valign="top">
462
+ <th scope="row"><?php _e('RSS main title','dbem'); ?></th>
463
+ <td>
464
+ <input name="dbem_rss_main_title" type="text" id="dbem_rss_main_title" style="width: 95%" value="<?php echo get_option('dbem_rss_main_title'); ?>" size="45" /><br />
465
+ <?php _e('The main title of your RSS events feed.','dbem')?>
466
+
467
+ </td>
468
+ </tr> <tr valign="top">
469
+ <th scope="row"><?php _e('RSS main description','dbem'); ?></th>
470
+ <td>
471
+ <input name="dbem_rss_main_description" type="text" id="dbem_rss_main_description" style="width: 95%" value="<?php echo get_option('dbem_rss_main_description'); ?>" size="45" /><br />
472
+ <?php _e('The main description of your RSS events feed.','dbem')?>
473
+
474
+ </td>
475
+ </tr>
476
+ <tr valign="top">
477
+ <th scope="row"><?php _e('RSS title format','dbem'); ?></th>
478
+ <td>
479
+ <input name="dbem_rss_title_format" type="text" id="dbem_rss_title_format" style="width: 95%" value="<?php echo get_option('dbem_rss_title_format'); ?>" size="45" /><br />
480
+ <?php _e('The format of the title of each item in the events RSS feed.','dbem')?>
481
+
482
+ </td>
483
+ </tr>
484
+ <tr valign="top">
485
+ <th scope="row"><?php _e('RSS description format','dbem'); ?></th>
486
+ <td>
487
+ <input name="dbem_rss_description_format" type="text" id="dbem_rss_description_format" style="width: 95%" value="<?php echo get_option('dbem_rss_description_format'); ?>" size="45" /><br />
488
+ <?php _e('The format of the description of each item in the events RSS feed.','dbem')?>
489
+ <?php _e('Follow the previous formatting instructions.','dbem')?><br/>
490
+ </td>
491
+ </tr>
492
+
493
+
494
+
495
+
496
+
497
+
498
+ <?php $gmap_is_active = get_option('dbem_gmap_is_active'); ?>
499
+
500
+ <tr valign="top">
501
+ <th scope="row"><?php _e('Enable Google Maps integration?','dbem'); ?></th>
502
+ <td>
503
+ <input id="dbem_gmap_is_active_yes" name="dbem_gmap_is_active" type="radio" value="1" <?php if($gmap_is_active) echo "checked='checked'"; ?> /><?php _e('Yes'); ?> <br />
504
+ <input name="dbem_gmap_is_active" type="radio" value="0" <?php if(!$gmap_is_active) echo "checked='checked'"; ?> /> <?php _e('No'); ?> <br />
505
+ <?php _e('Check this option to enable Goggle Map integration.','dbem')?>
506
+ </td>
507
+ </tr>
508
+
509
+ <tr valign="top">
510
+ <th scope="row"><?php _e('Google Maps API Key','dbem'); ?></th>
511
+ <td>
512
+ <input name="dbem_gmap_key" type="text" id="dbem_gmap_key" style="width: 95%" value="<?php echo get_option('dbem_gmap_key'); ?>" size="45" /><br />
513
+ <?php _e("To display Google Maps you need a Google Maps API key. Don't worry, it's free, you can get one", "dbem");?> <a href="http://code.google.com/apis/maps/signup.html"><?php _e("here",'dbem')?></a>.
514
+ </td>
515
+ </tr>
516
+ <tr valign="top">
517
+ <th scope="row"><?php _e('Map text format','dbem')?></th>
518
+ <td><textarea name="dbem_map_text_format" id="dbem_map_text_format" rows="6" cols="60"><?php echo (get_option('dbem_map_text_format'));?></textarea><br/>
519
+ <?php _e('The format the text appearing in the map cloud.','dbem')?><br/>
520
+ <?php _e('Follow the previous formatting instructions.','dbem')?></td>
521
+ </tr>
522
+ </table>
523
+ <p class="submit">
524
+ <input type="submit" id="dbem_options_submit" name="Submit" value="<?php _e('Save Changes') ?>" />
525
+ </p>
526
+ <input type="hidden" name="action" value="update" />
527
+ <input type="hidden" name="page_options" value="dbem_event_list_item_format,dbem_event_page_title_format,dbem_single_event_format,dbem_list_events_page,dbem_events_page_title, dbem_gmap_is_active, dbem_rss_main_title, dbem_rss_main_description, dbem_rss_title_format, dbem_rss_description_format, dbem_gmap_key, dbem_map_text_format" />
528
+
529
+
530
+ </form>
531
+ </div>
532
+ <?php
533
+
534
+
535
+ }
536
+
537
+
538
+
539
+
540
+ //This is the content of the event page
541
+ function dbem_events_page_content() {
542
+
543
+ global $wpdb;
544
+ if (isset($_REQUEST['event_id']) && $_REQUEST['event_id'] != '') {
545
+ // single event page
546
+ $event_ID=$_REQUEST['event_id'];
547
+ $event= dbem_get_event($event_ID);
548
+ $single_event_format = get_option('dbem_single_event_format');
549
+ $page_body = dbem_replace_placeholders($single_event_format, $event);
550
+ return $page_body;
551
+ } else {
552
+ // Multiple events page
553
+ $stored_format = get_option('dbem_event_list_item_format');
554
+ $events_body = dbem_get_events_list(10, "future", "ASC", $stored_format, $false);
555
+ return $events_body;
556
+
557
+ }
558
+ }
559
+
560
+ // filter function to call the event page when appropriate
561
+ function dbem_filter_events_page($data) {
562
+
563
+ // $table_name = $wpdb->prefix .TBNAME;
564
+ // $start = strpos($data, DBEM_PAGE);
565
+ $events_page_id = get_option('dbem_events_page');
566
+ if (is_page($events_page_id) ) {
567
+ return dbem_events_page_content();
568
+ } else {
569
+ return $data;
570
+ }
571
+ }
572
+ add_filter('the_content','dbem_filter_events_page');
573
+
574
+ function dbem_events_page_title($data) {
575
+ $events_page_id = get_option('dbem_events_page');
576
+ $events_page = get_page($events_page_id);
577
+ $events_page_title = $events_page->post_title;
578
+ if (($data == $events_page_title) && (is_page($events_page_id))) {
579
+ if (isset($_REQUEST['event_id']) && $_REQUEST['event_id'] != '') {
580
+ // single event page
581
+ $event_ID=$_REQUEST['event_id'];
582
+ $event= dbem_get_event($event_ID);
583
+ $stored_page_title_format = get_option('dbem_event_page_title_format');
584
+ $page_title = dbem_replace_placeholders($stored_page_title_format, $event);
585
+ return $page_title;
586
+ } else {
587
+ // Multiple events page
588
+ $page_title = get_option('dbem_events_page_title');
589
+ return $page_title;
590
+
591
+ }
592
+
593
+ } else {
594
+ return $data;
595
+ }
596
+
597
+ }
598
+ // to make sure that in pages lists the title is dbem_events_page_title, and not overwritten by the previous filter
599
+ add_filter('the_title','dbem_events_page_title');
600
+ add_filter('single_post_title','dbem_events_page_title');
601
+
602
+ function dbem_filter_get_pages($data) {
603
+ $output = array();
604
+ $events_page_id = get_option('dbem_events_page');
605
+ for ($i = 0; $i < count($data); ++$i) {
606
+ if ($data[$i]->ID == $events_page_id) {
607
+ $list_events_page = get_option('dbem_list_events_page');
608
+ if($list_events_page) {
609
+ $data[$i]->post_title = get_option('dbem_events_page_title')."&nbsp;";
610
+ $output[] = $data[$i];
611
+ }
612
+ } else {
613
+ $output[] = $data[$i];
614
+ }
615
+ }
616
+ return $output;
617
+ }
618
+ add_filter('get_pages', 'dbem_filter_get_pages');
619
+
620
+
621
+
622
+ //
623
+ // TODO: ROBA NUOVA DA RIORDINARE
624
+ // ADMIN CSS for debug
625
+ function dbem_admin_css() {
626
+ $css = "
627
+ <style type='text/css'>
628
+ .debug{
629
+ color: green;
630
+ background: #B7F98C;
631
+ margin: 15px;
632
+ padding: 10px;
633
+ border: 1px solid #629948;
634
+ }
635
+ .switch-tab {
636
+ background: #aaa;
637
+ width: 100px;
638
+ float: right;
639
+ text-align: center;
640
+ margin: 3px 1px 0 5px;
641
+ padding: 2px;
642
+ }
643
+ .switch-tab a {
644
+ color: #fff;
645
+ text-decoration: none;
646
+ }
647
+ .switch-tab a:hover {
648
+ color: #D54E21;
649
+
650
+ }
651
+ #events-pagination {
652
+ text-align: center;
653
+
654
+ }
655
+ #events-pagination a {
656
+ margin: 0 20px 0 20px;
657
+ text-decoration: none;
658
+ width: 80px;
659
+ padding: 3px 0;
660
+ background: #FAF4B7;
661
+ border: 1px solid #ccc;
662
+ border-top: none;
663
+ }
664
+ #new-event {
665
+ float: left;
666
+
667
+ }
668
+ </style>";
669
+ echo $css;
670
+ }
671
+
672
+ add_action('admin_print_scripts','dbem_admin_css');
673
+
674
+ // exposed function, for theme makers
675
+ function dbem_get_events_list($limit="3", $scope="future", $order="ASC", $format='', $display=true) {
676
+ if ($scope == "")
677
+ $scope = "future";
678
+ if ($order != "DESC")
679
+ $order = "ASC";
680
+ if ($format == '')
681
+ $format = get_option('dbem_event_list_item_format');
682
+ $events = dbem_get_events($limit, $scope, $order);
683
+ $output = "";
684
+ if (!empty($events)) {
685
+ foreach ($events as $event){
686
+ // $localised_date = mysql2date("j M Y", $event->event_time);
687
+
688
+
689
+
690
+ $output .= dbem_replace_placeholders($format, $event);
691
+ }
692
+ } else {
693
+ $output = __('No events', 'dbem');
694
+ }
695
+ if ($display)
696
+ echo $output;
697
+ else
698
+ return $output;
699
+ }
700
+
701
+ function dbem_get_events_page($justurl=false) {
702
+ $page_link = get_permalink(get_option("dbem_events_page")) ;
703
+ if($justurl) {
704
+ echo $page_link;
705
+ } else {
706
+ $page_title = get_option("dbem_events_page_title") ;
707
+ echo "<a href='$page_link' title='$page_title'>$page_title</a>";
708
+ }
709
+
710
+ }
711
+
712
+ function dbem_replace_placeholders($format, $event, $target="html") {
713
+ $event_string = $format;
714
+ preg_match_all("/#_?[A-Za-z]+/", $format, $placeholders);
715
+ foreach($placeholders[0] as $result) {
716
+ // matches alla fields placeholder
717
+ if (preg_match('/#_MAP/', $result)) {
718
+ $gmap_is_active = get_option('dbem_gmap_is_active');
719
+ if ($gmap_is_active) {
720
+ $map_div = "<div id='event-map' style='width: 450px; height: 300px; background: green;'></div>" ;
721
+ } else {
722
+ $map_div = "";
723
+ }
724
+ $event_string = str_replace($result, $map_div , $event_string );
725
+ }
726
+ if (preg_match('/#_LINKEDNAME/', $result)) {
727
+ $events_page_id = get_option('dbem_events_page');
728
+ $event_page_link = get_permalink($events_page_id);
729
+ if (stristr($event_page_link, "?"))
730
+ $joiner = "&amp;";
731
+ else
732
+ $joiner = "?";
733
+ $event_string = str_replace($result, "<a href='".get_permalink($events_page_id).$joiner."event_id=$event->event_id' title='$event->event_name'>$event->event_name</a>" , $event_string );
734
+ }
735
+ if (preg_match('/#_URL/', $result)) {
736
+ $events_page_id = get_option('dbem_events_page');
737
+ $event_page_link = get_permalink($events_page_id);
738
+ if (stristr($event_page_link, "?"))
739
+ $joiner = "&amp;";
740
+ else
741
+ $joiner = "?";
742
+ $event_string = str_replace($result, get_permalink($events_page_id).$joiner."event_id=$event->event_id" , $event_string );
743
+ }
744
+ if (preg_match('/#_(NAME|VENUE|ADDRESS|TOWN|PROVINCE|NOTES)/', $result)) {
745
+ $field = "event_".ltrim(strtolower($result), "#_");
746
+ $field_value = $event->{$field};
747
+ if ($field == "event_notes") {
748
+ if ($target == "html")
749
+ $field_value = apply_filters('dbem_notes', $field_value);
750
+ else
751
+ if ($target == "map")
752
+ $field_value = apply_filters('dbem_notes_map', $field_value);
753
+ else
754
+ $field_value = apply_filters('dbem_notes_rss', $field_value);
755
+ } else {
756
+ if ($target == "html")
757
+ $field_value = apply_filters('dbem_general', $field_value);
758
+ else
759
+ $field_value = apply_filters('dbem_general_rss', $field_value);
760
+ }
761
+ $event_string = str_replace($result, $field_value , $event_string );
762
+ }
763
+ // matches all PHP time placeholders
764
+ if (preg_match('/#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/', $result)) {
765
+ $event_string = str_replace($result, mysql2date(ltrim($result, "#"), $event->event_time),$event_string );
766
+ }
767
+ }
768
+ return $event_string;
769
+
770
+ }
771
+ // main function querying the database event table
772
+ function dbem_get_events($limit="",$scope="future",$order="ASC", $offset="") {
773
+ global $wpdb;
774
+
775
+ if ($limit != "")
776
+ $limit = "LIMIT $limit";
777
+ if ($offset != "")
778
+ $offset = "OFFSET $offset";
779
+
780
+ if (($scope != "past") && ($scope !="all"))
781
+ $scope = "future";
782
+
783
+ $timestamp = time();
784
+ $date_time_array = getdate($timestamp);
785
+ $hours = $date_time_array['hours'];
786
+ $minutes = $date_time_array['minutes'];
787
+ $seconds = $date_time_array['seconds'];
788
+ $month = $date_time_array['mon'];
789
+ $day = $date_time_array['mday'];
790
+ $year = $date_time_array['year'];
791
+ $today = strftime('%Y-%m-%d 00:00:00', mktime($hours,$minutes,$seconds,$month,$day,$year));
792
+
793
+
794
+
795
+
796
+ if ($scope == "future")
797
+ $temporal_condition = "WHERE event_time >= '$today'" ;
798
+ if ($scope == "past")
799
+ $temporal_condition = "WHERE event_time < '$today'" ;
800
+ if ($scope == "all")
801
+ $temporal_condition = "";
802
+
803
+ $sql = "SELECT event_id,
804
+ event_name,
805
+ event_venue,
806
+ event_address,
807
+ event_town,
808
+ event_province,
809
+ DATE_FORMAT(event_time, '%e') AS 'event_day',
810
+ DATE_FORMAT(event_time, '%Y') AS 'event_year',
811
+ DATE_FORMAT(event_time, '%k') AS 'event_hh',
812
+ DATE_FORMAT(event_time, '%i') AS 'event_mm',
813
+ event_time,
814
+ event_latitude,
815
+ event_longitude,
816
+ event_notes
817
+ FROM ".$wpdb->prefix."events
818
+ $temporal_condition
819
+ ORDER BY event_time $order
820
+ $limit
821
+ $offset";
822
+
823
+
824
+ $events = $wpdb->get_results($sql);
825
+
826
+ return $events;
827
+ }
828
+ function dbem_get_event($event_id) {
829
+ global $wpdb;
830
+ $sql = "SELECT event_id,
831
+ event_name,
832
+ event_venue,
833
+ event_address,
834
+ event_town,
835
+ event_province,
836
+ DATE_FORMAT(event_time, '%e') AS 'event_day',
837
+ DATE_FORMAT(event_time, '%Y') AS 'event_year',
838
+ DATE_FORMAT(event_time, '%k') AS 'event_hh',
839
+ DATE_FORMAT(event_time, '%i') AS 'event_mm',
840
+ event_time,
841
+ event_latitude,
842
+ event_longitude,
843
+ event_notes
844
+ FROM ".$wpdb->prefix."events
845
+ WHERE event_id = $event_id";
846
+
847
+
848
+ $event = $wpdb->get_row($sql);
849
+
850
+ return $event;
851
+ }
852
+ function dbem_events_table($events, $limit, $title) {
853
+
854
+
855
+ if (isset($_GET['scope']))
856
+ $scope = $_GET['scope'];
857
+ else
858
+ $scope = "future";
859
+ if (($scope != "past") && ($scope != "all"))
860
+ $scope = "future";
861
+ $events_count = count(dbem_get_events("",$scope));
862
+
863
+ if (isset($_GET['offset']))
864
+ $offset = $_GET['offset'];
865
+
866
+
867
+ ?>
868
+ <div class="wrap">
869
+
870
+ <h2><?php echo $title; ?></h2>
871
+ <div id='new-event' class='switch-tab'><a href="<?php bloginfo('wpurl')?>/wp-admin/edit.php?page=eventmanager.php&amp;action=edit_event"><?php _e('New Event ...', 'dbem');?></a></div>
872
+ <?php
873
+
874
+ $link = array();
875
+ $link['past'] = "<a href='".get_bloginfo('url')."/wp-admin/edit.php?page=eventmanager.php&amp;scope=past&amp;order=desc'>".__('Past events','dbem')."</a>";
876
+ $link['all'] = " <a href='".get_bloginfo('url')."/wp-admin/edit.php?page=eventmanager.php&amp;scope=all&amp;order=desc'>".__('All events','dbem')."</a>";
877
+ $link['future'] = " <a href='".get_bloginfo('url')."/wp-admin/edit.php?page=eventmanager.php&amp;scope=future'>".__('Future events','dbem')."</a>";
878
+ foreach ($link as $key => $value) {
879
+ if ($key != $scope)
880
+ echo "<div class='switch-tab'>".$link[$key]."</div>";
881
+ } ?>
882
+
883
+
884
+ <table class="widefat">
885
+ <thead>
886
+ <tr>
887
+ <th><?php _e('ID', 'dbem');?></th>
888
+ <th><?php _e('Name', 'dbem');?></th>
889
+ <th><?php _e('Venue', 'dbem');?></th>
890
+ <th><?php _e('Town', 'dbem');?></th>
891
+ <th><?php _e('Address', 'dbem');?></th>
892
+ <th><?php _e('Date', 'dbem');?></th>
893
+ <th><?php _e('Time', 'dbem');?></th>
894
+ <?php if (false) { ?>
895
+ <th><?php _e('Latitude', 'dbem');?></th>
896
+ <th><?php _e('Longitude', 'dbem');?></th>
897
+ <?php } ?>
898
+ <th colspan="2"><?php _e('Actions', 'dbem');?></th>
899
+ </tr>
900
+ </thead>
901
+ <tbody>
902
+ <?php
903
+ $i =1;
904
+ foreach ($events as $event){
905
+ $class = ($i % 2) ? ' class="alternate"' : '';
906
+ $month = mysql2date('M', $event->event_time);
907
+ $weekday = mysql2date('D', $event->event_time);
908
+ $style = "";
909
+
910
+ $timestamp = time();
911
+ $date_time_array = getdate($timestamp);
912
+ $this_hours = $date_time_array['hours'];
913
+ $this_minutes = $date_time_array['minutes'];
914