Event Calendar WD – Responsive Event Calendar plugin - Version 1.0.68

Version Description

  • Fixed: List view pagination
  • Fixed: Week view start
Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 Event Calendar WD – Responsive Event Calendar plugin
Version 1.0.68
Comparing to
See all releases

Code changes from version 1.0.67 to 1.0.68

ecwd.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Event Calendar WD
4
  * Plugin URI: https://web-dorado.com/products/wordpress-event-calendar-wd.html
5
  * Description: Event Calendar WD is an easy event management and planning tool with advanced features.
6
- * Version: 1.0.67
7
  * Author: WebDorado
8
  * Author URI: http://web-dorado.com
9
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
3
  * Plugin Name: Event Calendar WD
4
  * Plugin URI: https://web-dorado.com/products/wordpress-event-calendar-wd.html
5
  * Description: Event Calendar WD is an easy event management and planning tool with advanced features.
6
+ * Version: 1.0.68
7
  * Author: WebDorado
8
  * Author URI: http://web-dorado.com
9
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
ecwd_admin_class.php CHANGED
@@ -6,7 +6,7 @@
6
  class ECWD_Admin {
7
 
8
  protected static $instance = null;
9
- protected $version = '1.0.67';
10
  protected $ecwd_page = null;
11
  protected $notices = null;
12
 
6
  class ECWD_Admin {
7
 
8
  protected static $instance = null;
9
+ protected $version = '1.0.68';
10
  protected $ecwd_page = null;
11
  protected $notices = null;
12
 
ecwd_class.php CHANGED
@@ -6,7 +6,7 @@
6
  */
7
  class ECWD {
8
 
9
- protected $version = '1.0.67';
10
  protected $plugin_name = 'event-calendar-wd';
11
  protected $prefix = 'ecwd';
12
  protected static $instance = null;
6
  */
7
  class ECWD {
8
 
9
+ protected $version = '1.0.68';
10
  protected $plugin_name = 'event-calendar-wd';
11
  protected $prefix = 'ecwd';
12
  protected static $instance = null;
includes/calendar-class.php CHANGED
@@ -1,1071 +1,1007 @@
1
  <?php
2
 
3
- class Calendar {
4
-
5
- public $weekstartday = 0; // week start day (0-6 e.g. 0 = Sunday, 1 = Monday, etc.)
6
- public $monthselector = true; // month/year select box (true=show selector,false=show month name)
7
- public $yearoffset = 5; // monthselector range of years (int)
8
- public $weeknumbers = false; // adds a column for week numbers (left,right,false)
9
- public $weeknumrotate = true; // rotate weeknumbers 90 degrees *currently only firefox is supported* (true,false)
10
- public $weeknames = 2; // controls how weekdays are displayed. (1=full,2=abbrev,3=single char)
11
- public $monthnames = 1; // controls how months are displayed. (1=full,2=abbrev)
12
- public $basecolor = '7D9AC0'; // base color for color scheme (hex)
13
- public $color = 'blue'; // color for color scheme (hex)
14
- public $minilinkbase = ''; // base url for links on mini calendar (blank=disabled)
15
- public $eventlistbg = '10738B'; // event list view bg color (hex)
16
- public $eventemptytext = 'No additional details for this event.'; // default text in event view when details is empty (string)
17
- public $dateformat = 'Y.m.d'; // default date format (passed to php date() public function)
18
- public $list_date_format = 'd.F.l'; // default date format (passed to php date() public function)
19
- public $timeformat = 'H:i'; // default time format (passed to php date() public function)
20
- public $font = '"Lucida Grande","Lucida Sans Unicode",sans-serif'; // font used to display the calendar (any css supported value)
21
- public $linktarget = 'parent'; // link target frame or window (e.g. 'parent.frameName'. Use '_blank' for new window/tab)
22
- public $listlimit = false; // limit the number of events in list and mini-list (false or int e.g. 10)
23
- public $listtitle = ''; //'Event List'; // Title shown when displaying full event list
24
- public $widget = 0;
25
- public $search_params = array();
26
- public $categories = array();
27
- public $tags = array();
28
- public $venues = array();
29
- public $organizers = array();
30
- public $displays = array('full', 'list', 'week', 'day');
31
- public $filters = array('categories', 'tags', 'venues', 'organizers');
32
- public $event_search = 'yes';
33
- public $displaysName;
34
- public $eventlinktarget;
35
- public $event_popup = "no";
36
- //--------------------------------------------------------------------------------------------
37
- // Weekday names/abbreviations (array must start with Sunday=0)
38
- //--------------------------------------------------------------------------------------------
39
-
40
- public $weekdate;
41
- public $weekdays = array(
42
- "Sunday",
43
- "Monday",
44
- "Tuesday",
45
- "Wednesday",
46
- "Thursday",
47
- "Friday",
48
- "Saturday"
49
- );
50
- public $abbrevweekdays = array(
51
- "Sun",
52
- "Mon",
53
- "Tue",
54
- "Wed",
55
- "Thu",
56
- "Fri",
57
- "Sat"
58
- );
59
- public $weekdayschar = array(
60
- "Su",
61
- "Mo",
62
- "Tu",
63
- "We",
64
- "Th",
65
- "Fr",
66
- "Sa"
67
- );
68
- //--------------------------------------------------------------------------------------------
69
- // Other publics used. (No need to edit below here)
70
- //--------------------------------------------------------------------------------------------
71
-
72
- public $jd, $year, $month, $day, $displaytype, $numdaysinmonth, $monthstartday, $monthname, $previousmonth, $nextmonth;
73
- public $events = array();
74
-
75
- // types: mini,full,list,mini-list,(default=full)
76
- public function __construct($type = 'full', $date = '', $staticdisplaytype = false, $widget = 0, $limit = false, $page = 1, $displays = null, $filters = null, $event_search = 'yes', $ecwd_views = array(), $preview) {
77
- // static displaytype
78
- add_filter( 'format_content', 'wptexturize' );
79
- add_filter( 'format_content', 'convert_smilies' );
80
- add_filter( 'format_content', 'wpautop' );
81
- add_filter( 'format_content', 'shortcode_unautop' );
82
- add_filter( 'format_content', 'prepend_attachment' );
83
- global $wp_version;
84
- if(isset($wp_version)){
85
- if ( version_compare($wp_version, '4.4', '>=' ) ) {
86
- add_filter( 'format_content', 'wp_make_content_images_responsive' );
 
 
 
 
 
 
 
 
 
87
  }
88
- }
89
- global $ecwd_options;
90
- $this->eventemptytext = isset($ecwd_options['event_default_description']) ? $ecwd_options['event_default_description'] : $this->eventemptytext;
91
- if (isset($ecwd_options['date_format']) && $ecwd_options['date_format'] != '') {
92
- if (isset($ecwd_options['date_format'])) {
93
- $this->dateformat = $ecwd_options['date_format'];
94
  }
95
- }
96
- if (isset($ecwd_options['list_date_format']) && $ecwd_options['list_date_format'] != '') {
97
- $this->list_date_format = $ecwd_options['list_date_format'];
98
- }
99
- if (isset($ecwd_options['time_format']) && $ecwd_options['time_format'] != '') {
100
- $this->timeformat = $ecwd_options['time_format'];
101
- }
102
-
103
- $this->eventlinktarget .= (isset($ecwd_options['events_new_tab']) && $ecwd_options['events_new_tab'] == 1 ? ' target="_blank" ' : '');
104
-
105
- $this->timeformat .= (isset($ecwd_options['time_type']) ? ' ' . $ecwd_options['time_type'] : '');
106
- if (isset($ecwd_options['time_type']) && $ecwd_options['time_type'] != '') {
107
- $this->timeformat = str_replace('H', 'g', $this->timeformat);
108
- $this->timeformat = str_replace('h', 'g', $this->timeformat);
109
- }
110
- if (isset($ecwd_options['week_starts']) && $ecwd_options['week_starts'] != '') {
111
- $this->weekstartday = $ecwd_options['week_starts'];
112
- }
113
- if ($preview == false) {
114
- if (isset($ecwd_options['events_in_popup']) && $ecwd_options['events_in_popup'] == '1') {
115
- $this->event_popup = "yes";
116
  }
117
- }
118
- $this->widget = $widget;
119
- $this->page = $page;
120
-
121
- if ($displays && is_array($displays) && $displays[0] != '') {
122
- $displays = array_unique($displays);
123
- if (( $key = array_search('none', $displays) ) !== false) {
124
- unset($displays[$key]);
125
  }
126
- $this->displays = $displays;
127
- }
128
- if ($filters && is_array($filters) && $filters[0] != '') {
129
- $filters = array_unique($filters);
130
- if (( $key = array_search('none', $filters) ) !== false) {
131
- unset($filters[$key]);
132
  }
133
- $this->filters = $filters;
134
- }
135
- if ($staticdisplaytype === true) {
136
- $this->displaytype = $type;
137
- } else {
138
- // calendar display type
139
- if ($type != '' && !isset($_REQUEST['t'])) {
140
- $this->displaytype = $type; // if type is not set in querystring set type to passed value
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  } else {
142
- $this->displaytype = $_REQUEST['t']; // else set to type passed in querystring
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  }
145
 
146
- // calendar date
147
- if ($date == '' && !isset($_REQUEST['date'])) {
148
- $date = date('Y-n-j');
149
- } // set to todays date if no value is set
150
- if (isset($_REQUEST['date']) && $_REQUEST['date'] != '') {
151
- $date = $_REQUEST['date'];
152
- } // check if date is in the querystring
153
- $date = date('Y-n-j', strtotime($date)); // format the date for parsing
154
- $date_part = explode('-', $date); // separate year/month/day
155
- $year = $date_part[0];
156
- $month = $date_part[1];
157
- $day = $date_part[2];
158
- if (!is_archive() && isset($_REQUEST['y']) && $_REQUEST['y'] != '') {
159
- $year = $_REQUEST['y'];
160
- } // if year is set in querystring it takes precedence
161
- if (!is_archive() && isset($_REQUEST['m']) && $_REQUEST['m'] != '') {
162
- $month = $_REQUEST['m'];
163
- } // if month is set in querystring it takes precedence
164
- if (!is_archive() && isset($_REQUEST['d']) && $_REQUEST['d'] != '') {
165
- $day = $_REQUEST['d'];
166
- } // if day is set in querystring it takes precedence
167
- // make sure we have year/month/day as int
168
- if ($year == '') {
169
- $year = date('Y');
170
- }
171
- if ($month == '') {
172
- $month = date('n'); // set to january if year is known
173
  }
174
- if ($day == '') {
175
- $day = date('j'); // set to the 1st is year and month is known
176
- }
177
-
178
- $this->date = $date;
179
- $this->month = (int) $month;
180
- $this->year = (int) $year;
181
- $this->day = (int) $day;
182
-
183
- // find out the number of days in the month
184
- $this->numdaysinmonth = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year);
185
-
186
- // create a calendar object
187
- $this->jd = cal_to_jd(CAL_GREGORIAN, $this->month, date(1), $this->year);
188
-
189
- // get the month start day as an int (0 = Sunday, 1 = Monday, etc)
190
- $this->monthstartday = jddayofweek($this->jd, 0);
191
-
192
- // get the month as a name
193
- $this->monthname = __(Date('F', strtotime($this->date)), 'ecwd');
194
-
195
- //get weekdate
196
- $this->weekdate = $this->getWeekFirstDayDate($this->date);
197
 
198
- //get month date
199
- $this->monthdate = $this->getMonthDate($this->date);
200
-
201
- //get day date
202
- $this->daydate = $this->getDayDate($this->date);
203
-
204
- $this->displaysName = array(
205
- 'full' => array('name' => __('Month', 'ecwd'), 'date' => $this->monthdate),
206
- 'mini' => array('name' => __('Month', 'ecwd'), 'date' => $this->monthdate),
207
- 'list' => array('name' => __('List', 'ecwd'), 'date' => $this->monthdate),
208
- 'week' => array(
209
- 'name' => __('Week', 'ecwd'),
210
- 'date' => $this->weekdate
211
- ),
212
- 'day' => array(
213
- 'name' => __('Day', 'ecwd'),
214
- 'date' => $this->daydate
215
- ),
216
- );
217
- $this->event_search = $event_search;
218
- $this->listlimit = $limit;
219
- }
220
-
221
- // header area for all displaytypes
222
-
223
- public function month_selector() {
224
- $html = '';
225
-
226
-
227
- return $html;
228
- }
229
-
230
- public function add_terms($type = 'categories', $terms) {
231
- if (is_array($terms)) {
232
- $this->$type = $terms;
233
  }
234
- }
235
-
236
- public function addEvent($arr) {
237
- $this->events[] = $arr;
238
- }
239
 
240
- public function addEvents($arr) {
241
- $this->events = $arr;
242
- }
243
-
244
- // next month link
245
-
246
- public function dateDiff($beginDate, $endDate) {
247
- if ($endDate == '') {
248
- return 0;
249
  }
250
- $fromDate = date('Y-n-j', strtotime($beginDate));
251
- $toDate = date('Y-n-j', strtotime($endDate));
252
- // echo $fromDate.'----'.$toDate.'<br />';
253
- $date_parts1 = explode('-', $fromDate);
254
- $date_parts2 = explode('-', $toDate);
255
-
256
-
257
- $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
258
- $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
259
-
260
- return $end_date - $start_date;
261
- }
262
 
263
- // previous month link
264
-
265
- public function showcal() {
266
- global $cal_ID;
267
- global $ecwd_options;
268
- $html = '';
269
- $start_date = strtotime($this->year . '-' . $this->month . '-1');
270
- $end_date = date('Y-m-t', strtotime($this->date));
271
-
272
- $html .= $this->calendar_head(); // set table head
273
- $this->seted_days = array();
274
- if (!in_array($this->displaytype, array(
275
- "list",
276
- "mini-list",
277
- "week",
278
- 'day',
279
- ))
280
- ) { // mini and full cal
281
- $html .= '<tr>';
282
-
283
- // render week number on left
284
- if ($this->weeknumbers == 'left' && $this->monthstartday != $this->weekstartday) {
285
- $html .= '<td class="week-number"><span>' . date('W', strtotime($this->year . '-' . $this->month)) . '</span></td>';
286
- }
287
-
288
- // render previous month cells
289
- $emptycells = 0;
290
-
291
- $numinrow = 7;
292
 
293
- // adjust for weekstartdays
294
- $weekstartadjust = $this->monthstartday - $this->weekstartday;
295
- if ($weekstartadjust < 0) {
296
- $weekstartadjust = $weekstartadjust + $numinrow;
297
  }
 
 
 
 
 
 
 
 
 
298
 
299
- for ($counter = 0; $counter < $weekstartadjust; $counter ++) {
300
- if ($counter == 0) {
301
- $thisclass = 'day-without-date week-start';
302
- } // only on first
303
- else {
304
- $thisclass = 'day-without-date';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  }
306
- if ($this->displaytype == 'full') {
307
- $html .= $this->calendar_cell(__($this->previousmonth, 'ecwd'), $thisclass);
308
- } else {
309
- $html .= $this->calendar_cell('&nbsp;', $thisclass);
 
 
 
310
  }
311
- $emptycells ++;
312
- }
313
-
314
- // render days
315
- $rowcounter = $emptycells;
316
- $weeknumadjust = $numinrow - ( $this->monthstartday - $this->weekstartday );
317
-
318
- for ($counter = 1; $counter <= $this->numdaysinmonth; $counter ++) {
319
-
320
- $date = $this->year . '-' . $this->month . '-' . $counter;
321
- // render week number on left
322
- if ($this->weeknumbers == 'left' && $this->weekstartday == $this->getDay($date, 0)) {
323
- $adjustweek = $this->calcDate($date, '+' . $weeknumadjust, 'day');
324
- $adjustweek = $adjustweek['year'] . '-' . $adjustweek['month'] . '-' . $adjustweek['day'];
325
- $html .= '<td class="week-number"><span>' . date('W', strtotime($adjustweek)) . '</span></td>';
326
  }
327
- $rowcounter ++;
328
- $html .= $this->calendar_cell($counter, 'day-with-date', $date);
329
- if ($rowcounter % $numinrow == 0) {
330
- // render week number on right
331
- if ($this->weeknumbers == 'right') {
332
- $html .= '<td class="week-number"><span>' . date('W', strtotime($date)) . '</span></td>';
 
 
 
 
333
  }
334
- $html .= "</tr>";
335
- if ($counter < $this->numdaysinmonth) {
336
- $html .= "<tr>";
 
 
 
 
 
 
 
 
 
337
  }
338
- $rowcounter = 0;
339
  }
340
- }
341
-
342
- // render next month cells
343
- $numcellsleft = $numinrow - $rowcounter;
344
- if ($numcellsleft != $numinrow) {
345
- for ($counter = 0; $counter < $numcellsleft; $counter ++) {
346
- if ($this->displaytype == 'full') {
347
- $html .= $this->calendar_cell($this->nextmonth, 'day-without-date');
348
- } else {
349
- $html .= $this->calendar_cell('&nbsp;', 'day-without-date');
350
  }
351
- $emptycells ++;
352
  }
353
- }
354
-
355
- // render week number on right
356
- if ($this->weeknumbers == 'right' && $numcellsleft != 7) {
357
- $html .= '<td class="week-number" style="border-bottom:1px solid #' . $this->bordercolor . ';"><span>' . date('W', strtotime($date)) . '</span></td>';
358
- }
359
-
360
- $html .= '</tr>';
361
- } elseif ($this->displaytype == 'week') {
362
- $html .= '<ul class="week-event-list">';
363
- $currentWeek = $this->rangeWeek($this->year . '-' . $this->month . '-' . $this->day);
364
- $date = $currentWeek['start'];
365
-
366
- while (strtotime($date) <= strtotime($currentWeek['end'])) {
367
- $html .= '<li>' . $this->calendar_cell(date('d', strtotime($date)), 'day-with-date', date('Y-n-j', strtotime($date))) . '</li>';
368
- $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
369
- }
370
- $html .= '</ul>';
371
- } elseif ($this->displaytype == 'day') {
372
- $html .= '<ul class="day-event-list">';
373
- $html .= '<li>' . $this->calendar_cell(date('d', strtotime($this->year . '-' . $this->month . '-' . $this->day)), 'day-with-date', date('Y-n-j', strtotime($this->year . '-' . $this->month . '-' . $this->day))) . '</li>';
374
- $html .= '</ul>';
375
- } elseif ($this->displaytype == '4day') {
376
- $html .= '<ul class="day4-event-list">';
377
- $days = $this->range4Days($this->year . '-' . $this->month . '-' . $this->day);
378
- $date = $days['start'];
379
- while (strtotime($date) <= strtotime($days['end'])) {
380
- $html .= '<li>' . $this->calendar_cell(date('d', strtotime($date)), 'day-with-date', date('Y-n-j', strtotime($date))) . '</li>';
381
- //$this->
382
- $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
383
- }
384
- $html .= '</ul>';
385
- } else { // event list and map
386
- if (count($this->events) > 0) {
387
- // $events = array();
388
- // foreach ($this->events as $date_events){
389
- // $events[] = $date_events;
390
- // }
391
- //
392
- // $this->events= $events;// = $this->arraySort($this->events, 'from');
393
- }
394
- if ($this->displaytype == 'map') {
395
-
396
- } else {
397
- $pages = 0;
398
- $page = $this->page;
399
- $html .= '<ul class="ecwd_list">';
400
- $page_index = 0;
401
- $ev_counts = 0;
402
-
403
- $events_for_list = $this->events;
404
- /* if (!isset($ecwd_options['long_events']) || (isset($ecwd_options['long_events']) && $ecwd_options['long_events'] == '0')) {
405
- $events_for_list = array(
406
- $start_date => $events_for_list,
407
- );
408
- } */
409
-
410
- foreach ($events_for_list as $date_key => $events) {
411
 
412
- foreach ($events as $event) {
413
- if ($date_key >= $start_date && $date_key <= strtotime($end_date)) {
414
- if ($page_index >= $page * $this->listlimit) {
415
- break 1;
416
- }
417
- if ($page_index >= (($page - 1) * $this->listlimit)) {
418
- if ($this->displaytype == 'list') { // full event list
419
- $image_class = '';
420
- $image = $this->getAndReplaceFirstImage($event['details']);
421
- if (!has_post_thumbnail($event['id']) && $event['image'] == "") {
422
- $image_class = "ecwd-no-image";
423
- }
424
- $html .= '<li class="' . $image_class . '" itemscope itemtype="http://schema.org/Event">';
425
- if (!$this->widget) {
426
- $html .= '<div class="ecwd-list-date resp" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', $date_key) . '">' . __(date('d', $date_key), 'ecwd') . '</div>';
427
- //$html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container"><div class="ecwd-list-date web">' . date('d', strtotime($event['from'])) . '.' . __(date('F', strtotime($event['from'])), 'ecwd') . '.' . __(date('l', strtotime($event['from'])), 'ecwd') . '</div>';
428
- $event_date = ( ( $this->list_date_format !== 'd.F.l' ) ? date($this->list_date_format, $date_key) : ( date('d', $date_key) . '.' . __(date('F', $date_key), 'ecwd') . '.' . __(date('l', $date_key), 'ecwd') ) );
429
- if ($this->list_date_format !== 'd.F.l') {
430
- $month_name = date('F', strtotime($event['from']));
431
- $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
 
 
 
 
 
432
  }
433
-
434
-
435
- $html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container"><div class="ecwd-list-date web">' . $event_date . '</div>';
436
- $html .= '<div class="ecwd-img">';
437
- if (get_the_post_thumbnail($event['id']) || $event['image']) {
438
- if (get_the_post_thumbnail($event['id'])) {
439
- $html .= get_the_post_thumbnail($event['id']);
440
- } else {
441
- $html .= '<img src="' . $event['image'] . '" />';
442
  }
443
- } elseif ($image['image'] != null) {
444
- $html .= '<img src="' . $image['image'] . '" />';
445
- $event['details'] = $image['content'];
446
- }
447
- $html .= '</div></div></div>';
448
- } else {
449
- $html .= '<div class="ecwd-list-date" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', strtotime($event['starttime'])) . '">' . __(date('d', strtotime($event['from'])), 'ecwd') . '</div>';
450
- }
451
- $html .= '<div class="event-main-content">';
452
- if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
453
- $html .= '<h3 class="event-title" itemprop="name"><span start-date-data="' . $event['from'] . '" class="ecwd_open_event_popup event' . $event['id'] . '" style="color:' . $event['color'] . ';">' . $event['title'] . '</span></h3>';
454
- } else if ($event['permalink'] != '') {
455
- $html .= '<h3 class="event-title" itemprop="name"><a href="' . $event['permalink'] . '" ' . $this->eventlinktarget . ' itemprop="url" style="color:' . $event['color'] . ';">' . $event['title'] . '</a></h3>';
456
- } else {
457
- $html .= '<h3 class="event-title" style="color:' . $event['color'] . ';" itemprop="name">' . $event['title'] . '</h3>';
458
- }
459
- $html .= '<div class="ecwd-list-date-cont">';
460
-
461
- if (isset($event['all_day_event']) && $event['all_day_event'] == 1) {
462
- $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . __('All day', 'ecwd');
463
- $eventtime .= '</span>';
464
- $eventtime .= '</div>';
465
- } else {
466
- if ($event['starttime'] != '') { // event details - hidden until clicked (full)
467
- $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . date($this->timeformat, strtotime($event['starttime']));
468
- if ($event['endtime'] != '' && strtotime($event['endtime']) != strtotime($event['starttime'])) {
469
- $eventtime .= "-" . date($this->timeformat, strtotime($event['endtime']));
470
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  $eventtime .= '</span>';
472
  $eventtime .= '</div>';
 
 
 
 
 
 
 
 
 
473
  }
474
- }
475
- $html .= $eventtime;
476
- if ($event['from'] != '') { // event details - hidden until clicked (full)
477
- $eventdate = '<div class="ecwd-date"><span class="metainfo"> ' . date($this->dateformat, strtotime($event['from']));
478
- if ($event['to'] != '' && strtotime($event['to']) !== strtotime($event['from'])) {
479
- $eventdate .= "-" . date($this->dateformat, strtotime($event['to']));
 
 
 
480
  }
481
- $eventdate .= '</span>';
482
- $eventdate .= '</div>';
483
- $html .= $eventdate;
484
- }
485
- $html .= '</div>';
486
- if (isset($event['organizers']) && count($event['organizers']) > 0) {
487
- $html .= '<div class="event-organizers"><div class="ecwd-org-cont">';
488
- foreach ($event['organizers'] as $organizer) {
489
- $html .= '<div class="event-organizer" itemprop="organizer"> <a href="' . $organizer['permalink'] . '">' . $organizer['name'] . '</a></div>';
490
  }
491
- $html .= '</div></div>';
492
- }
493
-
494
- if ($event['location'] !== '') {
495
- $html .= '<div class="event-venue" itemprop="location" itemscope itemtype="http://schema.org/Place"><div class="ecwd-org-cont">
496
  <span itemprop="name">';
497
- if (isset($event['venue']['name'])) {
498
- $html .= '<a href="' . $event['venue']['permalink'] . '">' . $event['venue']['name'] . '</a>';
499
- }
500
- $html .= '</span>
501
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
502
- ' . ( $event['location'] ? $event['location'] : "" ) . '
503
  </div>
504
  </div>
505
  </div>';
506
- }
507
- $desc = $event['details'] ? $event['details'] : $this->eventemptytext;
508
- $desc = apply_filters('format_content', $desc);
509
- $html .= '<div class="event-content" itemprop="description">' . $desc . '</div></div>';
510
- } else { // mini event list
511
- $html .= '<li style="background:' . $event['color'] . ';"';
512
- if ($this->minilinkbase !== false) { // enable link (good for linking to full calendar)
513
- $html .= ' class="event-link"';
514
- if ($this->linktarget == '_blank') {
515
- $html .= ' onClick="window.open(\'' . $this->minilinkbase . '\', \'_blank\')"';
516
- } else {
517
- $html .= ' onClick="' . $this->linktarget . '.location=\'' . $this->minilinkbase . '\'"';
518
  }
519
- } else if ($event['link'] != '') { // enable link (links to event url)
520
- $html .= ' class="event-link"';
521
- if ($this->linktarget == '_blank') {
522
- $html .= 'onClick="window.open(\'' . $event['link'] . '\', \'_blank\')"';
523
- } else {
524
- $html .= ' onClick="' . $this->linktarget . '.location=\'' . $event['link'] . '\'"';
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  }
526
  }
 
527
  }
528
- $html .= '</li>';
529
  }
530
- $page_index++;
531
  }
532
  }
533
- }
534
-
535
- if ($this->listlimit !== false && $this->listlimit != 0) {
536
- $offset = ( $page - 1 ) * $this->listlimit;
537
- $pages = ceil($ev_counts / $this->listlimit);
538
- }
539
-
540
- if (count($this->events) <= 0) { // if events array is empty
541
- $html .= '<li >';
542
- $html .= '<div class="event-content">' . __('No Events', 'ecwd') . '</div>';
543
- $html .= '</li>';
544
- }
545
-
546
- $html .= '</ul>';
547
- ///PAGINATION////
548
- if ($pages > 1) {
549
- $html .= '<div class="ecwd-pagination">';
550
- if ($this->page > 1) {
551
- $html .= '<span class="cpage-span"><a href="?date=' . $this->year . '-' . $this->month . '&t=' . $this->displaytype . '&cpage=' . ( $this->page - 1 ) . '" class="cpage" rel="noindex, nofollow">...</a></span>';
552
  }
553
- for ($i = ( $this->page - 3 ); $i < ( $this->page + 4 ); $i ++) {
554
- if ($i <= $pages and $i >= 1) {
555
- if ($this->page == $i) {
556
- $html .= '<span class="cpage-span"><span class="page">' . $i . '</span></span>';
557
- } else {
558
- $html .= '<span class="cpage-span"><a href="?date=' . $this->year . '-' . $this->month . '&t=' . $this->displaytype . '&cpage=' . $i . '" class="cpage" rel="noindex, nofollow">' . $i . '</a></span>';
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  }
560
  }
 
 
 
 
561
  }
562
- if ($this->page < $pages) {
563
- $html .= '<span class="cpage-span"><a href="?date=' . $this->year . '-' . $this->month . '&t=' . $this->displaytype . '&cpage=' . ( $this->page + 1 ) . '" class="cpage" rel="noindex, nofollow">...</a></span>';
564
- }
565
- $html .= '</div>';
566
  }
567
  }
 
 
 
 
568
  }
569
- $html .= $this->calendar_foot();
570
-
571
- // remove tabs, line breaks, vertical tabs, null-byte
572
- $html = $this->stripWhitespace($html);
573
-
574
- return $html;
575
- }
576
-
577
- // month/year select box
578
-
579
- public function calendar_head($content = '') {
580
- global $cal_ID;
581
-
582
- $html = '';
583
- $html .= '<div class="calendar-head ecwd_calendar_prev_next">';
584
- $html .= $this->cal_previous(); // previous month link
585
- $previous_year = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-1', 'year');
586
- $previous_dateparam = $previous_year['year'] . '-' . $previous_year['month'] . '-' . $previous_year['day'];
587
 
588
- $next_year = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+1', 'year');
589
- $next_dateparam = $next_year['year'] . '-' . $next_year['month'] . '-' . $next_year['day'];
590
- if ($this->displaytype == 'week') {
591
- $previous_dateparam = $this->getWeekFirstDayDate($previous_year['year'] . '-' . $previous_year['month'] . '-' . $previous_year['day']);
592
- $next_dateparam = $this->getWeekFirstDayDate($next_year['year'] . '-' . $next_year['month'] . '-' . $next_year['day']);
593
- }
594
- $html .= '<div class="current-month">
 
 
 
 
 
 
 
 
595
  <a href="?date=' . $previous_dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow"><</a>&nbsp;
596
  ' . $this->year . '
597
  &nbsp;<a href="?date=' . $next_dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow">></a>
598
  <div>';
599
- if ($this->displaytype !== 'week' && $this->displaytype !== '4day' && $this->displaytype !== 'day') {
600
-
601
- $html .= __($this->monthname, 'ecwd');
602
- } else {
603
- if ($this->displaytype !== 'day') {
604
- if ($this->displaytype == 'week') {
605
- $currentDays = $this->rangeWeek($this->year . '-' . $this->month . '-' . $this->day);
 
 
 
606
  } else {
607
- $currentDays = $this->range4Days($this->year . '-' . $this->month . '-' . $this->day);
608
  }
609
-
610
- $html .= __($this->getMonth($currentDays['start']), 'ecwd') . ' ' . date('d', strtotime($currentDays['start'])) . ' - ' . __($this->getMonth($currentDays['end']), 'ecwd') . ' ' . date('d', strtotime($currentDays['end']));
611
- } else {
612
- $html .= __($this->monthname, 'ecwd') . ' ' . $this->day;
613
  }
614
- }
615
-
616
-
617
- $html .= ' </div>
618
  </div>';
619
-
620
-
621
- $html .= $this->cal_next(); // next month link
622
- $html .= '</div>';
623
- $html .= $this->cal_viewmode();
624
-
625
- if (!in_array($this->displaytype, array(
626
- "list",
627
- "mini-list",
628
- 'day',
629
- 'week'
630
- ))
631
- ) { // mini and full cal
632
- $html .= '
633
  <table class="ecwd_calendar_container ' . $this->displaytype . ' cal_' . $this->color . '" cellpadding="0" cellspacing="0" border="0">
634
 
635
  <tr>';
636
- // render week number on left
637
- if ($this->weeknumbers == 'left') {
638
- $html .= '<td rowspan="2" class="week-number">&nbsp;</td>';
639
- }
640
-
641
- // render week number on right
642
- if ($this->weeknumbers == 'right') {
643
- $html .= '<td rowspan="2" class="week-number">&nbsp;</td>';
644
- }
645
- $html .= '
646
  </tr>
647
  <tr>';
648
- if ($this->weeknames == 1) {
649
- $weekdays = $this->weekdays; // full
650
- } else if ($this->weeknames == 3 || $this->displaytype == 'mini') {
651
- $weekdays = $this->weekdayschar; // single char
652
- } else {
653
- $weekdays = $this->abbrevweekdays; // 3 char
654
- }
655
- for ($i = 0; $i < count($weekdays); $i ++) {
656
- $di = ( $i + $this->weekstartday ) % 7;
657
- $weekday = $weekdays[$di];
658
- if ($i == 0) {
659
- $thisclass = 'normal-day-heading week-start';
660
  } else {
661
- $thisclass = 'normal-day-heading';
662
  }
663
- $html .= $this->calendar_cell(__($weekday, 'ecwd'), $thisclass); // calendar cells for full & mini
664
- }
665
- $html .= '
 
 
 
 
 
 
 
 
666
  </tr>
667
  ';
668
- } else { // event list
669
- $html .= '<div class="ecwd_calendar_container ' . $this->displaytype . '">';
 
 
 
 
 
 
 
670
 
671
- if ($this->displaytype == 'list') {
672
- if ($this->listtitle != '') {
673
- $html .= '<h2 class="list-title">' . $this->listtitle . '</h2>';
674
  }
675
- } elseif ($this->displaytype == 'day') {
676
- //$this->day = ;
677
- } elseif ($this->displaytype == 'week') {
678
-
679
  }
680
- //$html .= '</div>';
681
  }
682
 
683
- return $html;
684
- }
685
-
686
- // calendar cells for mini and full displaytypes
687
-
688
- public function cal_previous() {
689
- global $cal_ID;
690
- $previous = $this->calcDate($this->year . '-' . $this->month, '-1', 'month');
691
- $dateparam = $previous['year'] . '-' . $previous['month'];
692
- $prev_date = '';
693
- if ($this->displaytype == 'day') {
694
- $previous = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-1', 'day');
695
- $dateparam = $previous['year'] . '-' . $previous['month'] . '-' . $previous['day'];
696
- $prev_date = $previous['day'];
697
- } elseif ($this->displaytype == '4day') {
698
- $previous = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-4', 'day');
699
- $dateparam = $previous['year'] . '-' . $previous['month'] . '-' . $previous['day'];
700
- $prev_date = $previous['day'];
701
- } elseif ($this->displaytype == 'week') {
702
- $previous = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-1', 'week');
703
- $dateparam = $previous['year'] . '-' . $previous['month'] . '-' . $previous['day'];
704
- $prev_date = $previous['day'];
 
 
 
 
 
705
  }
706
 
707
- $this->previousmonth = ( $this->getMonth($previous['year'] . '-' . $previous['month'], $this->monthnames) );
708
- if ($this->widget == 1) {
709
- $previoustext = '<span><</span>';
710
- } else {
711
- $previoustext = '<span><</span><span class="month-name"> ' . __($this->previousmonth, 'ecwd') . ' ' . $prev_date . '</span>';
 
 
 
 
 
 
 
 
712
  }
713
 
714
- $html = '<div class="previous"><a href="?date=' . $dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow">' . $previoustext . '</a></div>';
715
 
716
- return $html;
717
- }
 
 
718
 
719
- // calendar footer for all displaytypes
 
 
 
 
 
 
 
720
 
721
- public function calcDate($startdate, $increment, $unit) {
722
- if ($unit == 'month') {
723
- $startdate = date('Y-m-15', strtotime($startdate));
 
 
724
  }
725
- $date = date("Y-n-j", strtotime(date("Y-n-j", strtotime($startdate)) . " " . $increment . " " . $unit));
726
- $date = explode('-', $date);
727
- $newdate = array(
728
- 'year' => $date[0],
729
- 'month' => $date[1],
730
- 'day' => $date[2]
731
- );
732
 
733
- return $newdate;
734
- }
735
 
736
- public function getWeekFirstDayDate($date) {
737
- if (strtotime($date) == strtotime(date('Y-m-d'))) {
738
- return date('Y-n-j', strtotime(strtolower($this->weekdays[$this->weekstartday]) . " this week", strtotime($date)));
739
- } else {
740
- $first_monday_of_month = strtotime('First ' . $this->weekdays[$this->weekstartday] . ' of ' . date('F o', strtotime($date)));
741
- if (date('Y-n-j', $first_monday_of_month) == '1970-1-1' || date('Y-n-j', $first_monday_of_month) == '1969-12-31') {
742
- $first_monday_of_month = strtotime(date('Y-m-d', strtotime(date('F o', strtotime($date)) . ' first ' . $this->weekdays[$this->weekstartday])));
743
  }
744
- if (date('j', $first_monday_of_month) > 1) {
745
- $previous_monday = strtotime("-1 week", $first_monday_of_month);
 
 
 
 
 
746
 
747
- return date('Y-n-j', $previous_monday);
 
 
748
  } else {
749
- return date('Y-n-j', $first_monday_of_month);
 
 
 
 
 
 
750
  }
751
  }
752
- }
753
 
754
- public function getMonthDate($date) {
755
- if ($this->displaytype == 'week' && strtotime($date) !== strtotime(date('Y-m-d'))) {
756
- return date('Y-n-j', strtotime("+1 week", strtotime($date)));
757
- } elseif ($this->displaytype == '4day' && strtotime($date) !== strtotime(date('Y-m-d'))) {
758
- return date('Y-n-j', strtotime("+3 day", strtotime($date)));
 
759
  }
760
 
761
- return $date;
762
- }
763
-
764
- public function getDayDate($date) {
765
- if (strtotime($date) == strtotime(date('Y-m-d'))) {
766
- return $date;
767
- } else {
768
- if ($this->displaytype == 'full' || $this->displaytype == 'month' || $this->displaytype == 'mini' || $this->displaytype == 'list') {
769
- return date('Y-n-j', strtotime(date('Y-m-1'), strtotime($date)));
 
 
 
 
 
 
770
  } elseif ($this->displaytype == 'week') {
771
- return date('Y-n-j', strtotime(strtolower($this->weekdays[$this->weekstartday]) . " this week", strtotime($date)));
 
 
 
 
 
 
772
  } else {
773
- return $date;
 
774
  }
 
 
775
  }
776
- }
777
-
778
- // add an event to the events array
779
-
780
- public function getMonth($date, $type = 1) {
781
- $date = date('Y-n-j', strtotime($date));
782
- $date_parts = explode('-', $date);
783
- $jd = cal_to_jd(CAL_GREGORIAN, $date_parts[1], $date_parts[2], $date_parts[0]);
784
-
785
- return __(jdmonthname($jd, $type));
786
- }
787
-
788
- // pulls everything together and returns the calendar for all displaytypes
789
 
790
- public function cal_next() {
791
- global $cal_ID;
792
- $html = '';
793
-
794
- $next = $this->calcDate($this->year . '-' . $this->month . '-1', '+ 1', 'month');
795
- $next_date = '';
796
- $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
797
- if ($this->displaytype == 'day') {
798
- $next = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+1', 'day');
799
- $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
800
- $next_date = $next['day'];
801
- } elseif ($this->displaytype == '4day') {
802
- $next = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+4', 'day');
803
- $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
804
- $next_date = $next['day'];
805
- } elseif ($this->displaytype == 'week') {
806
- $next = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+1', 'week');
807
- $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
808
- $next_date = $next['day'];
809
- }
810
- $this->nextmonth = ( $this->getMonth($next['year'] . '-' . $next['month'], $this->monthnames) );
811
-
812
- if ($this->widget == 1) {
813
- $nexttext = '<span>></span>';
814
- } else {
815
- $divider = $this->monthselector === false ? '&nbsp;|&nbsp;' : '';
816
- $nexttext = '<span class="month-name">' . $next_date . ' ' . $divider . __($this->nextmonth, 'ecwd') . ' </span><span>></span>';
817
- }
818
- $html = '<div class="next"><a href="?date=' . $dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow">' . $nexttext . '</a></div>';
819
-
820
- return $html;
821
- }
822
-
823
- //--------------------------------------------------------------------------------------------
824
- // Helper Functions
825
- //--------------------------------------------------------------------------------------------
826
- //
827
-
828
- public function cal_viewmode() {
829
- $monthType = ( $this->widget == 1 ) ? 'mini' : 'full';
830
-
831
- if ($this->widget == 1) {
832
- $html = ' <div class="ecwd_calendar_view_dropdown cal_tabs_' . $this->color . '" ><a class="ecwd-dropdown-toggle" data-toggle="ecwd-dropdown">';
833
- $html .= $this->displaysName[$this->displaytype]['name'];
834
- $html .= '</a>';
835
-
836
- $widgetDisplays = array('mini', 'list', 'week', 'day');
837
-
838
- $html .= '<div class="ecwd-dropdown-menu">';
839
- foreach ($widgetDisplays as $display) {
840
- if ($display !== 'none' && isset($this->displaysName[$display])) {
841
- $html .= '<div class="type">' . '<a href="?date=' . $this->displaysName[$display]['date'] . '&t=' . $display . '" rel="noindex, nofollow">' . $this->displaysName[$display]['name'] . '</a>' . '</div>';
842
  }
843
- }
844
-
845
- $html .= '</div></div>';
846
- } else {
847
- $html = ' <div class="ecwd_calendar_view_tabs cal_tabs_' . $this->color . '" >';
848
- $html .= '<div class="filter-container">
849
  <div class="filter-arrow-left">&laquo;</div>
850
  <div class="filter-arrow-right">&raquo;</div>';
851
-
852
-
853
- if (count($this->displays) > 1) {
854
- $html .= '<ul>';
855
- foreach ($this->displays as $display) {
856
- if ($display !== 'none' && isset($this->displaysName[$display])) {
857
- $html .= '<li class="type';
858
- if ($this->displaytype == $display) {
859
- $html .= ' ecwd-selected-mode';
860
- $html .= '">' . '<a>' . $this->displaysName[$display]['name'] . '</a>' . '</li>';
861
- } else {
862
- $html .= '">' . '<a href="?date=' . $this->displaysName[$display]['date'] . '&t=' . $display . '" rel="noindex, nofollow">' . $this->displaysName[$display]['name'] . '</a>' . '</li>';
863
  }
864
  }
 
865
  }
866
- $html .= '</ul>';
867
- }
868
- $html .= '</div>';
869
- if ($this->event_search == 'yes') {
870
- $svalue = '';
871
- if (isset($this->search_params['query']) && $this->search_params['query']) {
872
- $svalue = $this->search_params['query'];
873
- }
874
- $html .= '<div class="ecwd-search">
875
- <input class="ecwd-search" name="search" type="text" value="' . $svalue . '">'
876
- . '<button class="btn btn-default ecwd-search-submit"><span class="glyphicon glyphicon-search"></span><i class="fa fa-search"></i></button>
877
  </div>';
 
 
878
  }
879
- $html .= '</div>';
880
- }
881
-
882
- return $html;
883
- }
884
-
885
- // returns month from passed date (string), $type: 0=number,1=full(January,February,etc),2=abbreviation(Jan,Feb,etc)
886
-
887
- public function calendar_cell($day, $class, $date = '', $style = '') {
888
- global $cal_ID, $ecwd_options;
889
-
890
- $addclass = '';
891
-
892
- if (strpos($class, 'normal-day-heading') !== false) {
893
- $tag = 'th';
894
- } else {
895
- $tag = 'td';
896
  }
897
- if ($day != '') {
898
- $bgColor = '';
899
- $cellevents = array();
900
- if (!$date && is_int($day)) {
901
- $date = $this->year . '-' . $this->month . '-' . $day;
902
- }
903
 
904
- if (isset($this->events[strtotime($date)])) {
905
- $all_events = array_reverse($this->events[strtotime($date)]);
 
 
 
 
906
  } else {
907
- $all_events = array();
908
  }
909
-
910
- if (is_array($all_events) && $date) { // events array populated from addEvent()
911
- foreach ($all_events as $event) {
912
- //echo $event['from'].'------'.$event['title'].'<br />';
913
- $color = $event['color'];
914
- $title = $event['title'];
915
- $link = $event['link'];
916
- $eventdate = $event['date'];
917
- $from = strtotime($event['from']);
918
- $to = strtotime($event['to']);
919
- $starttime = $event['starttime'];
920
- $endtime = $event['endtime'];
921
- $details = $event['details'];
922
- $location = $event['location'];
923
- $venue = $event['venue'];
924
- $organizers = $event['organizers'];
925
- $terms = $event['terms'];
926
- $all_day_event = $event['all_day_event'];
927
- $permalink = $event['permalink'];
928
- $image = $event['image'];
929
- $latlong = $event['latlong'];
930
- $id = $event['id'];
931
-
932
- if ($date == date('Y-n-j', strtotime($eventdate))) {
933
- $cellevents[] = array(
934
- 'color' => $color,
935
- 'title' => $title,
936
- 'link' => $link,
937
- 'date' => $eventdate,
938
- 'from' => $from,
939
- 'to' => $to,
940
- 'id' => $id,
941
- 'starttime' => $starttime,
942
- 'endtime' => $endtime,
943
- 'details' => $details,
944
- 'location' => $location,
945
- 'all_day_event' => $all_day_event,
946
- 'latlong' => $latlong,
947
- 'terms' => $terms,
948
- 'venue' => $venue,
949
- 'organizers' => $organizers,
950
- 'permalink' => $permalink,
951
- 'image' => $image,
952
- );
953
- }
954
  }
955
- }
956
-
957
-
958
-
959
- // sort by starttime for the cell
960
- if (count($cellevents) > 0) {
961
- $cellevents = $this->arraySort($cellevents, 'starttime');
962
- }
963
-
964
- if ($date == date('Y-n-j')) {
965
- $addclass .= ' current-day'; // if processing the current day
966
- }
967
-
968
- if (in_array($this->getDay($date), array(
969
- 'Saturday',
970
- 'Sunday'
971
- ))) {
972
- $addclass .= ' weekend'; // if a weekend
973
- }
974
-
975
- if ($this->getDay($date, 0) == $this->weekstartday) {
976
- $addclass .= ' week-start'; // if the weekstartday
977
- }
978
-
979
- if ($this->arraySearch($date, $cellevents) !== false) {
980
- $addclass .= ' has-events'; // if the date has events
981
- } else if (strpos($class, 'normal-day-heading') === false) {
982
- $addclass .= ' no-events'; // no events
983
- }
984
-
985
- $combinedclass = $class . $addclass; // combine all classes
986
-
987
- $html = '<' . $tag . ' class="' . $combinedclass . '" data-date="' . $date . '"';
988
-
989
- // check/set links for mini calendar
990
- if ($this->minilinkbase != '' && $this->displaytype == 'mini') {
991
- if ($this->linktarget == '_blank') {
992
- $html .= ' onClick="window.open(\'' . $this->minilinkbase . '?date=' . $date . '\', \'_blank\')"';
993
  } else {
994
- $html .= ' onClick="' . $this->linktarget . '.location=\'' . $this->minilinkbase . '?date=' . $date . '\'"';
995
  }
996
- }
997
- }
998
- if ($style) {
999
- $html .= ' style="' . $style . '"';
1000
- }
1001
- if ($this->displaytype == 'mini') {
1002
- $content = $day;
1003
- } elseif ($this->widget && $this->displaytype != 'mini') {
1004
- $content = '<div class="ecwd-week-date">' . date('d', strtotime($date)) . '</div>';
1005
- } elseif (( $this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day' ) && !$this->widget) {
1006
- //here
1007
- $event_date = ( ( $this->list_date_format !== 'd.F.l' ) ? date($this->list_date_format, strtotime($date)) : ( date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd') ) );
1008
- if ($this->list_date_format !== 'd.F.l') {
1009
- $month_name = date('F', strtotime($date));
1010
- $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
1011
- }
1012
- $content = '<div class="ecwd-week-date resp" itemprop="startDate" content="' . date('Y-m-d', strtotime($date)) . '">' . __(date('d', strtotime($date)), 'ecwd') . '</div><div class="ecwd-week-date web"">' . $event_date . '</div>';
1013
- } else {
1014
- $content = '<div class="day-number">' . $day . '</div>'; // day number or prev/next month cell content
1015
- }
1016
-
1017
-
1018
- if (count($cellevents) > 0) {
1019
- $content .= '<ul class="events">';
1020
- $eventcontent = '';
1021
- foreach ($cellevents as $i => $cellevent) {
1022
- //echo $cellevent['date'].'-------'.$cellevent['title'].'<br />';
1023
- //if (!array_key_exists($cellevent['id'], $this->seted_days)) {
1024
- $li_class = '';
1025
- if ($i > 2 && $this->displaytype !== 'mini') {
1026
- $li_class = 'inmore';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1027
  }
1028
- //var_dump($cellevent);
1029
- $eventcontent .= '<li itemscope itemtype="http://schema.org/Event" style="';
1030
- if (is_array($cellevent['terms'])) {
1031
- if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1032
- $eventcontent .= 'background-color: ' . $cellevent['color'] . '; ';
 
 
 
 
 
 
 
 
1033
  }
1034
  }
1035
- $eventcontent .= '" class="' . $li_class . ' ' . $i;
1036
- if (isset($cellevent['terms']['ecwd_taxonomy_image']) && $cellevent['terms']['ecwd_taxonomy_image'] == '') {
1037
- $eventcontent .= ' no-cat-image ';
 
 
 
 
 
 
 
 
 
 
 
1038
  }
1039
- $eventcontent .= '">';
1040
- if ($this->displaytype != 'mini') {
1041
- if (isset($cellevent['terms']['ecwd_taxonomy_image']) && $this->displaytype != 'mini') {
1042
- if ($cellevent['terms']['ecwd_taxonomy_image'] != '') {
1043
- $eventcontent .= '<img class="ecwd-event-cat-icon" src="' . $cellevent['terms']['ecwd_taxonomy_image'] . '" />';
1044
- }/* elseif (isset($cellevent['color'])){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1045
  $eventcontent .= ' <span class="event-metalabel" style="background:' . $cellevent['color'] . '"></span>';
1046
  } */
 
 
 
 
 
 
 
 
1047
  }
1048
- if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1049
-
1050
- $eventcontent .= '<span start-date-data="' . $event['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '" itemprop="name">' . $cellevent['title'] . '</span>';
1051
- } elseif ($cellevent['permalink']) {
1052
- $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . '><span itemprop="name">' . $cellevent['title'] . '</span></a>';
1053
- } else {
1054
- $eventcontent .= '<span itemprop="name">' . $cellevent['title'] . '</span>';
 
1055
  }
1056
- }
1057
- $this->seted_days[$cellevent['id']] = $date;
1058
- $ecwd_settings_general = get_option("ecwd_settings_general");
1059
- $show_events_detail_hover = true;
1060
- if($ecwd_settings_general && isset($ecwd_settings_general["show_events_detail"])){
1061
- $show_events_detail = $ecwd_settings_general["show_events_detail"];
1062
- if(intval($show_events_detail)===0){
1063
- $show_events_detail_hover = false;
1064
  }
1065
- }
1066
- if ($show_events_detail_hover) {
1067
- echo "<input type='hidden' class='show_event_hover_info'>";
1068
- }
1069
  $eventcontent .= '<div class="event-details-container"><div class="ecwd-event-arrow"></div><div class="event-details">';
1070
  if ($cellevent['title'] != '') {
1071
  $eventcontent .= '<div class="event-details-title">';
@@ -1164,12 +1100,10 @@ class Calendar {
1164
  // } else {
1165
  // //$eventcontent .= $cellevent['title'];
1166
  // }
1167
- }
1168
-
1169
- $content .= apply_filters('format_content', $eventcontent);
1170
-
1171
- if ($i > 2 && $this->displaytype !== 'mini') {
1172
- $content .= '<li class="ecwd-calendar-more-event">
1173
  <span class="ecwd-calendar-event-add">
1174
  <span class="more_events_link">' . __('More events', 'ecwd') . '</span>
1175
  </span>
@@ -1178,297 +1112,267 @@ class Calendar {
1178
  <input type="hidden" class="ecwd-more-event-title" value="' . date($this->dateformat, strtotime($date)) . '" />
1179
  </div>
1180
  </li>';
1181
- }
1182
-
1183
- $content .= '</ul>';
1184
-
1185
-
1186
- if ($this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day') {
1187
- if (count($cellevents) > 0) {
1188
- $html = '';
1189
- if (!$this->widget) {
1190
- $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, strtotime($date)) : (date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd')));
1191
- if ($this->list_date_format !== 'd.F.l') {
1192
- $month_name = date('F', strtotime($date));
1193
- $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
1194
- }
1195
-
1196
-
1197
- $html = '<div class="ecwd-week-date resp" style="background:#' . $this->eventlistbg . '" itemprop="startDate" content="' . date('Y-m-d', strtotime($date)) . 'T' . date('H:i', strtotime($date)) . '">' . date('d', strtotime($date)) . '</div><div class="ecwd-week-date web"">' . $event_date . '</div>';
1198
- } else {
1199
- $html = '<div class="ecwd-week-date">' . date('d', strtotime($date)) . '</div>';
1200
- }
1201
- $html .= '<div class="event-main-content">';
1202
- foreach ($cellevents as $cellevent) {
1203
-
1204
- $image_class = '';
1205
- $cellevent['details'] = $cellevent['details'] == '' ? $this->eventemptytext : $cellevent['details'];
1206
- $image = $this->getAndReplaceFirstImage($cellevent['details']);
1207
- if (!has_post_thumbnail($cellevent['id']) && $cellevent['image'] == "") {
1208
- $image_class = "ecwd-no-image";
1209
- }
1210
- $html .= '<div class="event-container ' . $image_class . '" itemprop="event">';
1211
  if (!$this->widget) {
1212
- $html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container">';
1213
- $html .= '<div class="ecwd-img">';
1214
- if (get_the_post_thumbnail($cellevent['id']) || $cellevent['image']) {
1215
-
1216
- if (get_the_post_thumbnail($cellevent['id'])) {
1217
- $html .= get_the_post_thumbnail($cellevent['id']);
1218
- } else {
1219
- $html .= '<img src="' . $cellevent['image'] . '" />';
1220
- }
1221
- } elseif ($image['image'] != null) {
1222
- $html .= '<img src="' . $image['image'] . '" />';
1223
- $cellevent['details'] = $image['content'];
1224
  }
1225
- $html .= '</div></div></div>';
 
 
1226
  }
1227
- if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1228
- $html .= '<h3 class="event-title" itemprop="name"><span start-date-data="' . $cellevent['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '"';
1229
- if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1230
- $html .= ' style="color:' . $cellevent['color'] . ';"';
1231
- }
1232
- $html .= '>' . $cellevent['title'] . '</span></h3>';
1233
- } else if ($cellevent['permalink'] != '') {
1234
- $html .= '<h3 class="event-title" itemprop="name"> <a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget;
1235
- if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1236
- $html .= ' style="color:' . $cellevent['color'] . ';"';
1237
  }
1238
- $html .= '>' . $cellevent['title'] . '</a></h3>';
1239
- } else {
1240
- $html .= '<h3 class="event-title" itemprop="name"';
1241
-
1242
- if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1243
- $html .= 'style="color:' . $cellevent['color'] . ';"';
 
 
 
 
 
 
 
 
 
1244
  }
1245
- $html .= '>' . $cellevent['title'] . '</h3>';
1246
- }
1247
- $html .= '<div class="ecwd-list-date-cont">';
1248
- if (isset($cellevent['all_day_event']) && $cellevent['all_day_event'] == 1) {
1249
- $eventtime = '<div class="ecwd-time"><span class="metainfo event-time" itemprop="startDate" content="' . date('Y-m-d', $cellevent['from']) . 'T' . date('H:i', strtotime($cellevent['starttime'])) . '"> ' . __('All day', 'ecwd');
1250
- $eventtime .= '</span>';
1251
- $eventtime .= '</div>';
1252
- $html .= $eventtime;
1253
- } else {
1254
-
1255
- if ($cellevent['starttime'] != '') { // event details - hidden until clicked (full)
1256
- $eventtime = '<div class="ecwd-time"><span class="metainfo event-time" itemprop="startDate" content="' . date('Y-m-d', $cellevent['from']) . 'T' . date('H:i', strtotime($cellevent['starttime'])) . '"> ' . date($this->timeformat, strtotime($cellevent['starttime']));
1257
- if ($cellevent['endtime'] != '' && $cellevent['endtime'] != $cellevent['starttime']) {
1258
- $eventtime .= "-" . date($this->timeformat, strtotime($cellevent['endtime']));
 
 
1259
  }
 
 
 
 
 
1260
  $eventtime .= '</span>';
1261
  $eventtime .= '</div>';
1262
  $html .= $eventtime;
 
 
 
 
 
 
 
 
 
 
1263
  }
1264
- }
1265
- if ($cellevent['from'] != '') {
1266
- $eventdate = '<div class="ecwd-date"><span class="metainfo" itemprop="startDate" content="' . date('Y-m-d', $cellevent['from']) . 'T' . date('H:i', strtotime($cellevent['starttime'])) . '"> ' . date($this->dateformat, $cellevent['from']);
1267
- if ($cellevent['to'] != '' && $cellevent['to'] != $cellevent['from']) {
1268
- $eventdate .= "-" . date($this->dateformat, $cellevent['to']);
1269
- }
1270
- $eventdate .= '</span>';
1271
- $eventdate .= '</div>';
1272
- $html .= $eventdate;
1273
- }
1274
- $html .= '</div>';
1275
- if (isset($cellevent['organizers']) && count($cellevent['organizers']) > 0) {
1276
- $html .= '<div class="event-organizers">';
1277
- foreach ($cellevent['organizers'] as $organizer) {
1278
- $html .= '<div class="event-organizer" itemprop="organizer"> <a href="' . $organizer['permalink'] . '">' . $organizer['name'] . '</a></div>';
1279
  }
1280
  $html .= '</div>';
1281
- }
1282
- if ($cellevent['location'] != '') {
1283
- $html .= '<div class="event-venue" itemprop="location" itemscope itemtype="http://schema.org/Place">
1284
- <span itemprop="name">';
1285
- if (isset($cellevent['venue']['name'])) {
1286
- $html .= '<a href="' . $cellevent['venue']['permalink'] . '">' . $cellevent['venue']['name'] . '</a>';
1287
  }
1288
- $html .= '</span>
 
 
 
 
 
 
1289
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
1290
  <span itemprop="streetAddress">' . $cellevent['location'] . '</span>
1291
  </div>
1292
  </div>';
 
 
 
 
1293
  }
1294
- $desc = $cellevent['details'] ? $cellevent['details'] : $this->eventemptytext;
1295
- $desc = apply_filters('format_content', $desc);
1296
- $html .= '<div class="event-content" itemprop="description">' . $desc . '</div></div>';
1297
  }
1298
- $html .= '</div>';
1299
-
1300
- return $html;
 
1301
  }
1302
  }
1303
- } else {
1304
- if ($this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day') {
1305
- $content .= '<div class="event-main-content no-events">' . __('No events', 'ecwd') . '</div>';
1306
- }
1307
  }
1308
 
1309
- $html .= '>' . $content . '</td>';
1310
-
1311
- return $html;
1312
- }
1313
-
1314
- public function arraySort($a, $subkey) {
1315
-
1316
- foreach ($a as $k => $v) {
1317
- $b[$k] = strtolower($v[$subkey]);
1318
- }
1319
- asort($b);
1320
- foreach ($b as $key => $val) {
1321
- $c[] = $a[$key];
1322
  }
1323
- return $c;
1324
- }
1325
 
1326
- // add/subtract day,week,month,days from startdate
1327
-
1328
- public function getDay($date, $type = 1) {
1329
- $date = date('Y-n-j', strtotime($date));
1330
- $date_parts = explode('-', $date);
1331
- $jd = cal_to_jd(CAL_GREGORIAN, $date_parts[1], $date_parts[2], $date_parts[0]);
1332
-
1333
- return jddayofweek($jd, $type);
1334
- }
1335
-
1336
- // recursive array search returns the key of occurance (int) or false if not found
1337
 
1338
- public function arraySearch($needle, $haystack, $index = null) {
1339
- $aIt = new RecursiveArrayIterator($haystack);
1340
- $it = new RecursiveIteratorIterator($aIt);
1341
- while ($it->valid()) {
1342
- if (( ( isset($index) AND ( $it->key() == $index ) ) OR ( !isset($index) ) ) AND ( $it->current() == $needle )) {
1343
- return $aIt->key();
 
 
 
1344
  }
1345
- $it->next();
1346
  }
1347
 
1348
- return false;
1349
- }
1350
-
1351
- public function getKey($array, $member, $value) {
1352
- foreach ($array as $k => $v) {
1353
- if ($v->$member == $value) {
1354
- return $k;
1355
  }
 
1356
  }
1357
 
1358
- return false;
1359
- }
1360
-
1361
- //return current week start and end dates
1362
-
1363
- public function rangeWeek($datestr) {
1364
- date_default_timezone_set(date_default_timezone_get());
1365
- $res['start'] = date("Y-m-d", strtotime($datestr));
1366
- $res['end'] = date("Y-m-d", strtotime("+6 day", strtotime($datestr)));
1367
-
1368
- return $res;
1369
- }
1370
-
1371
- public function range4Days($date) {
1372
- date_default_timezone_set(date_default_timezone_get());
1373
- $res['start'] = date("Y-m-d", strtotime($date));
1374
- $res['end'] = date("Y-m-d", strtotime("+3 day", strtotime($date)));
1375
-
1376
- return $res;
1377
- }
1378
-
1379
- public function calendar_foot() {
1380
- if (in_array($this->displaytype, array(
1381
- 'full',
1382
- 'mini'
1383
- ))) {
1384
- $html = '</table>';
1385
- } else {
1386
- $html = '</div>';
1387
  }
1388
 
1389
- return $html;
1390
- }
1391
-
1392
- // Removes tabs, line breaks, vertical tabs, null-byte. Everything but a regular space.
1393
-
1394
- public function stripWhitespace($c) {
1395
- $c = str_replace(array(
1396
- "\n",
1397
- "\r",
1398
- "\t",
1399
- "\o",
1400
- "\xOB"
1401
- ), '', $c);
1402
-
1403
- return trim($c);
1404
- }
1405
-
1406
- // sorts an associative array by values of passed key
1407
-
1408
- public function hex2RGB($hexStr, $returnAsString = false, $seperator = ',') {
1409
- $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // check hex string
1410
- $rgbArray = array();
1411
- if (strlen($hexStr) == 6) { // if a proper hex code e.g. #RRGGBB
1412
- $colorVal = hexdec($hexStr);
1413
- $rgbArray['red'] = 0xFF & ( $colorVal >> 0x10 );
1414
- $rgbArray['green'] = 0xFF & ( $colorVal >> 0x8 );
1415
- $rgbArray['blue'] = 0xFF & $colorVal;
1416
- } elseif (strlen($hexStr) == 3) { // if shorthand notation e.g #RGB
1417
- $rgbArray['red'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2));
1418
- $rgbArray['green'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2));
1419
- $rgbArray['blue'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2));
1420
- } else {
1421
- return false; // invalid hex color code
1422
  }
1423
 
1424
- // returns the rgb string or the associative array
1425
- return $returnAsString ? implode($seperator, $rgbArray) : $rgbArray;
1426
- }
1427
-
1428
- public function getAndReplaceFirstImage($content) {
1429
- global $ecwd_options;
1430
- $first_img = '';
1431
- if($ecwd_options){
1432
- if(!isset($ecwd_options["move_first_image"]) || intval($ecwd_options["move_first_image"])===0){
1433
- return array(
1434
- 'image' => "",
1435
- 'content' => $content
1436
- );
1437
  }
1438
- }
1439
- ob_start();
1440
- ob_end_clean();
1441
- $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
1442
- if (isset($matches [1] [0])) {
1443
- $first_img = $matches [1] [0];
1444
  }
1445
 
1446
- if (empty($first_img)) { //Defines a default image
1447
- return false;
1448
- } else {
1449
- //preg_replace('/<img[^>]+\>/i', '', $content);
1450
- $content = $this->replaceFirstImage($content);
 
 
 
 
 
1451
  }
1452
 
1453
- return array(
1454
- 'image' => $first_img,
1455
- 'content' => $content
1456
- );
1457
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1458
 
1459
- public function replaceFirstImage($content) {
1460
- $content = preg_replace("/<img[^>]+\>/i", " ", $content, 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1461
 
1462
- return $content;
1463
- }
 
 
1464
 
1465
- public function cal_days_in_month() {
1466
- $date_str = $this->year . '-' . $this->month . '-01';
1467
- $date = date('t', strtotime($date_str));
 
 
1468
 
1469
- return intval($date);
1470
  }
1471
 
1472
- }
1473
-
1474
- // end class
1
  <?php
2
 
3
+ class Calendar {
4
+
5
+ public $weekstartday = 0; // week start day (0-6 e.g. 0 = Sunday, 1 = Monday, etc.)
6
+ public $monthselector = true; // month/year select box (true=show selector,false=show month name)
7
+ public $yearoffset = 5; // monthselector range of years (int)
8
+ public $weeknumbers = false; // adds a column for week numbers (left,right,false)
9
+ public $weeknumrotate = true; // rotate weeknumbers 90 degrees *currently only firefox is supported* (true,false)
10
+ public $weeknames = 2; // controls how weekdays are displayed. (1=full,2=abbrev,3=single char)
11
+ public $monthnames = 1; // controls how months are displayed. (1=full,2=abbrev)
12
+ public $basecolor = '7D9AC0'; // base color for color scheme (hex)
13
+ public $color = 'blue'; // color for color scheme (hex)
14
+ public $minilinkbase = ''; // base url for links on mini calendar (blank=disabled)
15
+ public $eventlistbg = '10738B'; // event list view bg color (hex)
16
+ public $eventemptytext = 'No additional details for this event.'; // default text in event view when details is empty (string)
17
+ public $dateformat = 'Y.m.d'; // default date format (passed to php date() public function)
18
+ public $list_date_format = 'd.F.l'; // default date format (passed to php date() public function)
19
+ public $timeformat = 'H:i'; // default time format (passed to php date() public function)
20
+ public $font = '"Lucida Grande","Lucida Sans Unicode",sans-serif'; // font used to display the calendar (any css supported value)
21
+ public $linktarget = 'parent'; // link target frame or window (e.g. 'parent.frameName'. Use '_blank' for new window/tab)
22
+ public $listlimit = false; // limit the number of events in list and mini-list (false or int e.g. 10)
23
+ public $listtitle = ''; //'Event List'; // Title shown when displaying full event list
24
+ public $widget = 0;
25
+ public $search_params = array();
26
+ public $categories = array();
27
+ public $tags = array();
28
+ public $venues = array();
29
+ public $organizers = array();
30
+ public $displays = array(
31
+ 'full',
32
+ 'list',
33
+ 'week',
34
+ 'day'
35
+ );
36
+ public $filters = array(
37
+ 'categories',
38
+ 'tags',
39
+ 'venues',
40
+ 'organizers'
41
+ );
42
+ public $event_search = 'yes';
43
+ public $displaysName;
44
+ public $eventlinktarget;
45
+ public $event_popup = "no";
46
+ //--------------------------------------------------------------------------------------------
47
+ // Weekday names/abbreviations (array must start with Sunday=0)
48
+ //--------------------------------------------------------------------------------------------
49
+ public $weekdate;
50
+ public $weekdays = array(
51
+ "Sunday",
52
+ "Monday",
53
+ "Tuesday",
54
+ "Wednesday",
55
+ "Thursday",
56
+ "Friday",
57
+ "Saturday"
58
+ );
59
+ public $abbrevweekdays = array(
60
+ "Sun",
61
+ "Mon",
62
+ "Tue",
63
+ "Wed",
64
+ "Thu",
65
+ "Fri",
66
+ "Sat"
67
+ );
68
+ public $weekdayschar = array(
69
+ "Su",
70
+ "Mo",
71
+ "Tu",
72
+ "We",
73
+ "Th",
74
+ "Fr",
75
+ "Sa"
76
+ );
77
+ //--------------------------------------------------------------------------------------------
78
+ // Other publics used. (No need to edit below here)
79
+ //--------------------------------------------------------------------------------------------
80
+ public $jd, $year, $month, $day, $displaytype, $numdaysinmonth, $monthstartday, $monthname, $previousmonth, $nextmonth;
81
+ public $events = array();
82
+
83
+ // types: mini,full,list,mini-list,(default=full)
84
+ public function __construct ($type = 'full', $date = '', $staticdisplaytype = false, $widget = 0, $limit = false, $page = 1, $displays = null, $filters = null, $event_search = 'yes', $ecwd_views = array(), $preview) {
85
+ // static displaytype
86
+ add_filter('format_content', 'wptexturize');
87
+ add_filter('format_content', 'convert_smilies');
88
+ add_filter('format_content', 'wpautop');
89
+ add_filter('format_content', 'shortcode_unautop');
90
+ add_filter('format_content', 'prepend_attachment');
91
+ global $wp_version;
92
+ if (isset($wp_version)) {
93
+ if (version_compare($wp_version, '4.4', '>=')) {
94
+ add_filter('format_content', 'wp_make_content_images_responsive');
95
+ }
96
  }
97
+ global $ecwd_options;
98
+ $this->eventemptytext = isset($ecwd_options['event_default_description']) ? $ecwd_options['event_default_description'] : $this->eventemptytext;
99
+ if (isset($ecwd_options['date_format']) && $ecwd_options['date_format'] != '') {
100
+ if (isset($ecwd_options['date_format'])) {
101
+ $this->dateformat = $ecwd_options['date_format'];
102
+ }
103
  }
104
+ if (isset($ecwd_options['list_date_format']) && $ecwd_options['list_date_format'] != '') {
105
+ $this->list_date_format = $ecwd_options['list_date_format'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
+ if (isset($ecwd_options['time_format']) && $ecwd_options['time_format'] != '') {
108
+ $this->timeformat = $ecwd_options['time_format'];
 
 
 
 
 
 
109
  }
110
+ $this->eventlinktarget .= (isset($ecwd_options['events_new_tab']) && $ecwd_options['events_new_tab'] == 1 ? ' target="_blank" ' : '');
111
+ $this->timeformat .= (isset($ecwd_options['time_type']) ? ' ' . $ecwd_options['time_type'] : '');
112
+ if (isset($ecwd_options['time_type']) && $ecwd_options['time_type'] != '') {
113
+ $this->timeformat = str_replace('H', 'g', $this->timeformat);
114
+ $this->timeformat = str_replace('h', 'g', $this->timeformat);
 
115
  }
116
+ if (isset($ecwd_options['week_starts']) && $ecwd_options['week_starts'] != '') {
117
+ $this->weekstartday = $ecwd_options['week_starts'];
118
+ }
119
+ if ($preview == false) {
120
+ if (isset($ecwd_options['events_in_popup']) && $ecwd_options['events_in_popup'] == '1') {
121
+ $this->event_popup = "yes";
122
+ }
123
+ }
124
+ $this->widget = $widget;
125
+ $this->page = $page;
126
+ if ($displays && is_array($displays) && $displays[0] != '') {
127
+ $displays = array_unique($displays);
128
+ if (($key = array_search('none', $displays)) !== false) {
129
+ unset($displays[$key]);
130
+ }
131
+ $this->displays = $displays;
132
+ }
133
+ if ($filters && is_array($filters) && $filters[0] != '') {
134
+ $filters = array_unique($filters);
135
+ if (($key = array_search('none', $filters)) !== false) {
136
+ unset($filters[$key]);
137
+ }
138
+ $this->filters = $filters;
139
+ }
140
+ if ($staticdisplaytype === true) {
141
+ $this->displaytype = $type;
142
  } else {
143
+ // calendar display type
144
+ if ($type != '' && !isset($_REQUEST['t'])) {
145
+ $this->displaytype = $type; // if type is not set in querystring set type to passed value
146
+ } else {
147
+ $this->displaytype = $_REQUEST['t']; // else set to type passed in querystring
148
+ }
149
+ }
150
+ // calendar date
151
+ if ($date == '' && !isset($_REQUEST['date'])) {
152
+ $date = date('Y-n-j');
153
+ } // set to todays date if no value is set
154
+ if (isset($_REQUEST['date']) && $_REQUEST['date'] != '') {
155
+ $date = $_REQUEST['date'];
156
+
157
+ } // check if date is in the querystring
158
+ $date = date('Y-n-j', strtotime($date)); // format the date for parsing
159
+
160
+ $date_part = explode('-', $date); // separate year/month/day
161
+ $year = $date_part[0];
162
+ $month = $date_part[1];
163
+ $day = $date_part[2];
164
+
165
+ if (!is_archive() && isset($_REQUEST['y']) && $_REQUEST['y'] != '') {
166
+ $year = $_REQUEST['y'];
167
+ } // if year is set in querystring it takes precedence
168
+ if (!is_archive() && isset($_REQUEST['m']) && $_REQUEST['m'] != '') {
169
+ $month = $_REQUEST['m'];
170
+ } // if month is set in querystring it takes precedence
171
+ if (!is_archive() && isset($_REQUEST['d']) && $_REQUEST['d'] != '') {
172
+ $day = $_REQUEST['d'];
173
+ } // if day is set in querystring it takes precedence
174
+ // make sure we have year/month/day as int
175
+ if ($year == '') {
176
+ $year = date('Y');
177
  }
178
+ if ($month == '') {
179
+ $month = date('n'); // set to january if year is known
180
+ }
181
+ if ($day == '') {
182
+ $day = date('j'); // set to the 1st is year and month is known
183
+ }
184
+ $this->date = $date;
185
+ $this->month = (int)$month;
186
+ $this->year = (int)$year;
187
+ $this->day = (int)$day;
188
+ // find out the number of days in the month
189
+ $this->numdaysinmonth = cal_days_in_month(CAL_GREGORIAN, $this->month, $this->year);
190
+ // create a calendar object
191
+ $this->jd = cal_to_jd(CAL_GREGORIAN, $this->month, date(1), $this->year);
192
+ // get the month start day as an int (0 = Sunday, 1 = Monday, etc)
193
+ $this->monthstartday = jddayofweek($this->jd, 0);
194
+ // get the month as a name
195
+ $this->monthname = __(Date('F', strtotime($this->date)), 'ecwd');
196
+ //get weekdate
197
+ $this->weekdate = $this->getWeekFirstDayDate($this->date);
198
+ //get month date
199
+ $this->monthdate = $this->getMonthDate($this->date);
200
+ //get day date
201
+ $this->daydate = $this->getDayDate($this->date);
202
+ $this->displaysName = array(
203
+ 'full' => array(
204
+ 'name' => __('Month', 'ecwd'),
205
+ 'date' => $this->monthdate
206
+ ),
207
+ 'mini' => array(
208
+ 'name' => __('Month', 'ecwd'),
209
+ 'date' => $this->monthdate
210
+ ),
211
+ 'list' => array(
212
+ 'name' => __('List', 'ecwd'),
213
+ 'date' => $this->monthdate
214
+ ),
215
+ 'week' => array(
216
+ 'name' => __('Week', 'ecwd'),
217
+ 'date' => $this->weekdate
218
+ ),
219
+ 'day' => array(
220
+ 'name' => __('Day', 'ecwd'),
221
+ 'date' => $this->daydate
222
+ ),
223
+ );
224
+ $this->event_search = $event_search;
225
+ $this->listlimit = $limit;
226
  }
227
 
228
+ // header area for all displaytypes
229
+ public function month_selector () {
230
+ $html = '';
231
+ return $html;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
 
234
+ public function add_terms ($type = 'categories', $terms) {
235
+ if (is_array($terms)) {
236
+ $this->$type = $terms;
237
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
 
 
 
 
 
239
 
240
+ public function addEvent ($arr) {
241
+ $this->events[] = $arr;
 
 
 
 
 
 
 
242
  }
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
+ public function addEvents ($arr) {
245
+ $this->events = $arr;
246
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
 
248
+ // next month link
249
+ public function dateDiff ($beginDate, $endDate) {
250
+ if ($endDate == '') {
251
+ return 0;
252
  }
253
+ $fromDate = date('Y-n-j', strtotime($beginDate));
254
+ $toDate = date('Y-n-j', strtotime($endDate));
255
+ // echo $fromDate.'----'.$toDate.'<br />';
256
+ $date_parts1 = explode('-', $fromDate);
257
+ $date_parts2 = explode('-', $toDate);
258
+ $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
259
+ $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
260
+ return $end_date - $start_date;
261
+ }
262
 
263
+ // previous month link
264
+ public function showcal () {
265
+ global $cal_ID;
266
+ global $ecwd_options;
267
+ $html = '';
268
+ $start_date = strtotime($this->year . '-' . $this->month . '-1');
269
+ $end_date = date('Y-m-t', strtotime($this->date));
270
+ $html .= $this->calendar_head(); // set table head
271
+ $this->seted_days = array();
272
+ if (!in_array($this->displaytype, array(
273
+ "list",
274
+ "mini-list",
275
+ "week",
276
+ 'day',
277
+ ))
278
+ ) { // mini and full cal
279
+ $html .= '<tr>';
280
+ // render week number on left
281
+ if ($this->weeknumbers == 'left' && $this->monthstartday != $this->weekstartday) {
282
+ $html .= '<td class="week-number"><span>' . date('W', strtotime($this->year . '-' . $this->month)) . '</span></td>';
283
  }
284
+ // render previous month cells
285
+ $emptycells = 0;
286
+ $numinrow = 7;
287
+ // adjust for weekstartdays
288
+ $weekstartadjust = $this->monthstartday - $this->weekstartday;
289
+ if ($weekstartadjust < 0) {
290
+ $weekstartadjust = $weekstartadjust + $numinrow;
291
  }
292
+ for ($counter = 0; $counter < $weekstartadjust; $counter++) {
293
+ if ($counter == 0) {
294
+ $thisclass = 'day-without-date week-start';
295
+ } // only on first
296
+ else {
297
+ $thisclass = 'day-without-date';
298
+ }
299
+ if ($this->displaytype == 'full') {
300
+ $html .= $this->calendar_cell(__($this->previousmonth, 'ecwd'), $thisclass);
301
+ } else {
302
+ $html .= $this->calendar_cell('&nbsp;', $thisclass);
303
+ }
304
+ $emptycells++;
 
 
305
  }
306
+ // render days
307
+ $rowcounter = $emptycells;
308
+ $weeknumadjust = $numinrow - ($this->monthstartday - $this->weekstartday);
309
+ for ($counter = 1; $counter <= $this->numdaysinmonth; $counter++) {
310
+ $date = $this->year . '-' . $this->month . '-' . $counter;
311
+ // render week number on left
312
+ if ($this->weeknumbers == 'left' && $this->weekstartday == $this->getDay($date, 0)) {
313
+ $adjustweek = $this->calcDate($date, '+' . $weeknumadjust, 'day');
314
+ $adjustweek = $adjustweek['year'] . '-' . $adjustweek['month'] . '-' . $adjustweek['day'];
315
+ $html .= '<td class="week-number"><span>' . date('W', strtotime($adjustweek)) . '</span></td>';
316
  }
317
+ $rowcounter++;
318
+ $html .= $this->calendar_cell($counter, 'day-with-date', $date);
319
+ if ($rowcounter % $numinrow == 0) {
320
+ // render week number on right
321
+ if ($this->weeknumbers == 'right') {
322
+ $html .= '<td class="week-number"><span>' . date('W', strtotime($date)) . '</span></td>';
323
+ }
324
+ $html .= "</tr>";
325
+ if ($counter < $this->numdaysinmonth) {
326
+ $html .= "<tr>";
327
+ }
328
+ $rowcounter = 0;
329
  }
 
330
  }
331
+ // render next month cells
332
+ $numcellsleft = $numinrow - $rowcounter;
333
+ if ($numcellsleft != $numinrow) {
334
+ for ($counter = 0; $counter < $numcellsleft; $counter++) {
335
+ if ($this->displaytype == 'full') {
336
+ $html .= $this->calendar_cell($this->nextmonth, 'day-without-date');
337
+ } else {
338
+ $html .= $this->calendar_cell('&nbsp;', 'day-without-date');
339
+ }
340
+ $emptycells++;
341
  }
 
342
  }
343
+ // render week number on right
344
+ if ($this->weeknumbers == 'right' && $numcellsleft != 7) {
345
+ $html .= '<td class="week-number" style="border-bottom:1px solid #' . $this->bordercolor . ';"><span>' . date('W', strtotime($date)) . '</span></td>';
346
+ }
347
+ $html .= '</tr>';
348
+ } elseif ($this->displaytype == 'week') {
349
+ $html .= '<ul class="week-event-list">';
350
+ $currentWeek = $this->rangeWeek($this->year . '-' . $this->month . '-' . $this->day);
351
+ $date = $currentWeek['start'];
352
+ while (strtotime($date) <= strtotime($currentWeek['end'])) {
353
+ $html .= '<li>' . $this->calendar_cell(date('d', strtotime($date)), 'day-with-date', date('Y-n-j', strtotime($date))) . '</li>';
354
+ $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
355
+ }
356
+ $html .= '</ul>';
357
+ } elseif ($this->displaytype == 'day') {
358
+ $html .= '<ul class="day-event-list">';
359
+ $html .= '<li>' . $this->calendar_cell(date('d', strtotime($this->year . '-' . $this->month . '-' . $this->day)), 'day-with-date', date('Y-n-j', strtotime($this->year . '-' . $this->month . '-' . $this->day))) . '</li>';
360
+ $html .= '</ul>';
361
+ } elseif ($this->displaytype == '4day') {
362
+ $html .= '<ul class="day4-event-list">';
363
+ $days = $this->range4Days($this->year . '-' . $this->month . '-' . $this->day);
364
+ $date = $days['start'];
365
+ while (strtotime($date) <= strtotime($days['end'])) {
366
+ $html .= '<li>' . $this->calendar_cell(date('d', strtotime($date)), 'day-with-date', date('Y-n-j', strtotime($date))) . '</li>';
367
+ //$this->
368
+ $date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
369
+ }
370
+ $html .= '</ul>';
371
+ } else { // event list and map
372
+ if (count($this->events) > 0) {
373
+ // $events = array();
374
+ // foreach ($this->events as $date_events){
375
+ // $events[] = $date_events;
376
+ // }
377
+ //
378
+ // $this->events= $events;// = $this->arraySort($this->events, 'from');
379
+ }
380
+ if ($this->displaytype == 'map') {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
 
382
+ } else {
383
+ $pages = 0;
384
+ $page = $this->page;
385
+ $html .= '<ul class="ecwd_list">';
386
+ $page_index = 0;
387
+ $ev_counts = 0;
388
+ $events_for_list = $this->events;
389
+ /* if (!isset($ecwd_options['long_events']) || (isset($ecwd_options['long_events']) && $ecwd_options['long_events'] == '0')) {
390
+ $events_for_list = array(
391
+ $start_date => $events_for_list,
392
+ );
393
+ } */
394
+ foreach ($events_for_list as $date_key => $events) {
395
+ $ev_counts += count($events);
396
+ foreach ($events as $event) {
397
+ if ($date_key >= $start_date && $date_key <= strtotime($end_date)) {
398
+ if ($page_index >= $page * $this->listlimit) {
399
+ break 1;
400
+ }
401
+ if ($page_index >= (($page - 1) * $this->listlimit)) {
402
+ if ($this->displaytype == 'list') { // full event list
403
+ $image_class = '';
404
+ $image = $this->getAndReplaceFirstImage($event['details']);
405
+ if (!has_post_thumbnail($event['id']) && $event['image'] == "") {
406
+ $image_class = "ecwd-no-image";
407
  }
408
+ $html .= '<li class="' . $image_class . '" itemscope itemtype="http://schema.org/Event">';
409
+ if (!$this->widget) {
410
+ $html .= '<div class="ecwd-list-date resp" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', $date_key) . '">' . __(date('d', $date_key), 'ecwd') . '</div>';
411
+ //$html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container"><div class="ecwd-list-date web">' . date('d', strtotime($event['from'])) . '.' . __(date('F', strtotime($event['from'])), 'ecwd') . '.' . __(date('l', strtotime($event['from'])), 'ecwd') . '</div>';
412
+ $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, $date_key) : (date('d', $date_key) . '.' . __(date('F', $date_key), 'ecwd') . '.' . __(date('l', $date_key), 'ecwd')));
413
+ if ($this->list_date_format !== 'd.F.l') {
414
+ $month_name = date('F', strtotime($event['from']));
415
+ $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
 
416
  }
417
+ $html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container"><div class="ecwd-list-date web">' . $event_date . '</div>';
418
+ $html .= '<div class="ecwd-img">';
419
+ if (get_the_post_thumbnail($event['id']) || $event['image']) {
420
+ if (get_the_post_thumbnail($event['id'])) {
421
+ $html .= get_the_post_thumbnail($event['id']);
422
+ } else {
423
+ $html .= '<img src="' . $event['image'] . '" />';
424
+ }
425
+ } elseif ($image['image'] != null) {
426
+ $html .= '<img src="' . $image['image'] . '" />';
427
+ $event['details'] = $image['content'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  }
429
+ $html .= '</div></div></div>';
430
+ } else {
431
+ $html .= '<div class="ecwd-list-date" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', strtotime($event['starttime'])) . '">' . __(date('d', strtotime($event['from'])), 'ecwd') . '</div>';
432
+ }
433
+ $html .= '<div class="event-main-content">';
434
+ if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
435
+ $html .= '<h3 class="event-title" itemprop="name"><span start-date-data="' . $event['from'] . '" class="ecwd_open_event_popup event' . $event['id'] . '" style="color:' . $event['color'] . ';">' . $event['title'] . '</span></h3>';
436
+ } else if ($event['permalink'] != '') {
437
+ $html .= '<h3 class="event-title" itemprop="name"><a href="' . $event['permalink'] . '" ' . $this->eventlinktarget . ' itemprop="url" style="color:' . $event['color'] . ';">' . $event['title'] . '</a></h3>';
438
+ } else {
439
+ $html .= '<h3 class="event-title" style="color:' . $event['color'] . ';" itemprop="name">' . $event['title'] . '</h3>';
440
+ }
441
+ $html .= '<div class="ecwd-list-date-cont">';
442
+ if (isset($event['all_day_event']) && $event['all_day_event'] == 1) {
443
+ $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . __('All day', 'ecwd');
444
  $eventtime .= '</span>';
445
  $eventtime .= '</div>';
446
+ } else {
447
+ if ($event['starttime'] != '') { // event details - hidden until clicked (full)
448
+ $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . date($this->timeformat, strtotime($event['starttime']));
449
+ if ($event['endtime'] != '' && strtotime($event['endtime']) != strtotime($event['starttime'])) {
450
+ $eventtime .= "-" . date($this->timeformat, strtotime($event['endtime']));
451
+ }
452
+ $eventtime .= '</span>';
453
+ $eventtime .= '</div>';
454
+ }
455
  }
456
+ $html .= $eventtime;
457
+ if ($event['from'] != '') { // event details - hidden until clicked (full)
458
+ $eventdate = '<div class="ecwd-date"><span class="metainfo"> ' . date($this->dateformat, strtotime($event['from']));
459
+ if ($event['to'] != '' && strtotime($event['to']) !== strtotime($event['from'])) {
460
+ $eventdate .= "-" . date($this->dateformat, strtotime($event['to']));
461
+ }
462
+ $eventdate .= '</span>';
463
+ $eventdate .= '</div>';
464
+ $html .= $eventdate;
465
  }
466
+ $html .= '</div>';
467
+ if (isset($event['organizers']) && count($event['organizers']) > 0) {
468
+ $html .= '<div class="event-organizers"><div class="ecwd-org-cont">';
469
+ foreach ($event['organizers'] as $organizer) {
470
+ $html .= '<div class="event-organizer" itemprop="organizer"> <a href="' . $organizer['permalink'] . '">' . $organizer['name'] . '</a></div>';
471
+ }
472
+ $html .= '</div></div>';
 
 
473
  }
474
+ if ($event['location'] !== '') {
475
+ $html .= '<div class="event-venue" itemprop="location" itemscope itemtype="http://schema.org/Place"><div class="ecwd-org-cont">
 
 
 
476
  <span itemprop="name">';
477
+ if (isset($event['venue']['name'])) {
478
+ $html .= '<a href="' . $event['venue']['permalink'] . '">' . $event['venue']['name'] . '</a>';
479
+ }
480
+ $html .= '</span>
481
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
482
+ ' . ($event['location'] ? $event['location'] : "") . '
483
  </div>
484
  </div>
485
  </div>';
 
 
 
 
 
 
 
 
 
 
 
 
486
  }
487
+ $desc = $event['details'] ? $event['details'] : $this->eventemptytext;
488
+ $desc = apply_filters('format_content', $desc);
489
+ $html .= '<div class="event-content" itemprop="description">' . $desc . '</div></div>';
490
+ } else { // mini event list
491
+ $html .= '<li style="background:' . $event['color'] . ';"';
492
+ if ($this->minilinkbase !== false) { // enable link (good for linking to full calendar)
493
+ $html .= ' class="event-link"';
494
+ if ($this->linktarget == '_blank') {
495
+ $html .= ' onClick="window.open(\'' . $this->minilinkbase . '\', \'_blank\')"';
496
+ } else {
497
+ $html .= ' onClick="' . $this->linktarget . '.location=\'' . $this->minilinkbase . '\'"';
498
+ }
499
+ } else if ($event['link'] != '') { // enable link (links to event url)
500
+ $html .= ' class="event-link"';
501
+ if ($this->linktarget == '_blank') {
502
+ $html .= 'onClick="window.open(\'' . $event['link'] . '\', \'_blank\')"';
503
+ } else {
504
+ $html .= ' onClick="' . $this->linktarget . '.location=\'' . $event['link'] . '\'"';
505
+ }
506
  }
507
  }
508
+ $html .= '</li>';
509
  }
510
+ $page_index++;
511
  }
 
512
  }
513
  }
514
+ if ($this->listlimit !== false && $this->listlimit != 0) {
515
+ $offset = ($page - 1) * $this->listlimit;
516
+ $pages = ceil($ev_counts / $this->listlimit);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
  }
518
+ if (count($this->events) <= 0) { // if events array is empty
519
+ $html .= '<li >';
520
+ $html .= '<div class="event-content">' . __('No Events', 'ecwd') . '</div>';
521
+ $html .= '</li>';
522
+ }
523
+ $html .= '</ul>';
524
+ ///PAGINATION////
525
+ if ($pages > 1) {
526
+ $html .= '<div class="ecwd-pagination">';
527
+ if ($this->page > 1) {
528
+ $html .= '<span class="cpage-span"><a href="?date=' . $this->year . '-' . $this->month . '&t=' . $this->displaytype . '&cpage=' . ($this->page - 1) . '" class="cpage" rel="noindex, nofollow">...</a></span>';
529
+ }
530
+ for ($i = ($this->page - 3); $i < ($this->page + 4); $i++) {
531
+ if ($i <= $pages and $i >= 1) {
532
+ if ($this->page == $i) {
533
+ $html .= '<span class="cpage-span"><span class="page">' . $i . '</span></span>';
534
+ } else {
535
+ $html .= '<span class="cpage-span"><a href="?date=' . $this->year . '-' . $this->month . '&t=' . $this->displaytype . '&cpage=' . $i . '" class="cpage" rel="noindex, nofollow">' . $i . '</a></span>';
536
+ }
537
  }
538
  }
539
+ if ($this->page < $pages) {
540
+ $html .= '<span class="cpage-span"><a href="?date=' . $this->year . '-' . $this->month . '&t=' . $this->displaytype . '&cpage=' . ($this->page + 1) . '" class="cpage" rel="noindex, nofollow">...</a></span>';
541
+ }
542
+ $html .= '</div>';
543
  }
 
 
 
 
544
  }
545
  }
546
+ $html .= $this->calendar_foot();
547
+ // remove tabs, line breaks, vertical tabs, null-byte
548
+ $html = $this->stripWhitespace($html);
549
+ return $html;
550
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
 
552
+ // month/year select box
553
+ public function calendar_head ($content = '') {
554
+ global $cal_ID;
555
+ $html = '';
556
+ $html .= '<div class="calendar-head ecwd_calendar_prev_next">';
557
+ $html .= $this->cal_previous(); // previous month link
558
+ $previous_year = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-1', 'year');
559
+ $previous_dateparam = $previous_year['year'] . '-' . $previous_year['month'] . '-' . $previous_year['day'];
560
+ $next_year = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+1', 'year');
561
+ $next_dateparam = $next_year['year'] . '-' . $next_year['month'] . '-' . $next_year['day'];
562
+ if ($this->displaytype == 'week') {
563
+ $previous_dateparam = $this->getWeekFirstDayDate($previous_year['year'] . '-' . $previous_year['month'] . '-' . $previous_year['day']);
564
+ $next_dateparam = $this->getWeekFirstDayDate($next_year['year'] . '-' . $next_year['month'] . '-' . $next_year['day']);
565
+ }
566
+ $html .= '<div class="current-month">
567
  <a href="?date=' . $previous_dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow"><</a>&nbsp;
568
  ' . $this->year . '
569
  &nbsp;<a href="?date=' . $next_dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow">></a>
570
  <div>';
571
+ if ($this->displaytype !== 'week' && $this->displaytype !== '4day' && $this->displaytype !== 'day') {
572
+ $html .= __($this->monthname, 'ecwd');
573
+ } else {
574
+ if ($this->displaytype !== 'day') {
575
+ if ($this->displaytype == 'week') {
576
+ $currentDays = $this->rangeWeek($this->year . '-' . $this->month . '-' . $this->day);
577
+ } else {
578
+ $currentDays = $this->range4Days($this->year . '-' . $this->month . '-' . $this->day);
579
+ }
580
+ $html .= __($this->getMonth($currentDays['start']), 'ecwd') . ' ' . date('d', strtotime($currentDays['start'])) . ' - ' . __($this->getMonth($currentDays['end']), 'ecwd') . ' ' . date('d', strtotime($currentDays['end']));
581
  } else {
582
+ $html .= __($this->monthname, 'ecwd') . ' ' . $this->day;
583
  }
 
 
 
 
584
  }
585
+ $html .= ' </div>
 
 
 
586
  </div>';
587
+ $html .= $this->cal_next(); // next month link
588
+ $html .= '</div>';
589
+ $html .= $this->cal_viewmode();
590
+ if (!in_array($this->displaytype, array(
591
+ "list",
592
+ "mini-list",
593
+ 'day',
594
+ 'week'
595
+ ))
596
+ ) { // mini and full cal
597
+ $html .= '
 
 
 
598
  <table class="ecwd_calendar_container ' . $this->displaytype . ' cal_' . $this->color . '" cellpadding="0" cellspacing="0" border="0">
599
 
600
  <tr>';
601
+ // render week number on left
602
+ if ($this->weeknumbers == 'left') {
603
+ $html .= '<td rowspan="2" class="week-number">&nbsp;</td>';
604
+ }
605
+ // render week number on right
606
+ if ($this->weeknumbers == 'right') {
607
+ $html .= '<td rowspan="2" class="week-number">&nbsp;</td>';
608
+ }
609
+ $html .= '
 
610
  </tr>
611
  <tr>';
612
+ if ($this->weeknames == 1) {
613
+ $weekdays = $this->weekdays; // full
614
+ } else if ($this->weeknames == 3 || $this->displaytype == 'mini') {
615
+ $weekdays = $this->weekdayschar; // single char
 
 
 
 
 
 
 
 
616
  } else {
617
+ $weekdays = $this->abbrevweekdays; // 3 char
618
  }
619
+ for ($i = 0; $i < count($weekdays); $i++) {
620
+ $di = ($i + $this->weekstartday) % 7;
621
+ $weekday = $weekdays[$di];
622
+ if ($i == 0) {
623
+ $thisclass = 'normal-day-heading week-start';
624
+ } else {
625
+ $thisclass = 'normal-day-heading';
626
+ }
627
+ $html .= $this->calendar_cell(__($weekday, 'ecwd'), $thisclass); // calendar cells for full & mini
628
+ }
629
+ $html .= '
630
  </tr>
631
  ';
632
+ } else { // event list
633
+ $html .= '<div class="ecwd_calendar_container ' . $this->displaytype . '">';
634
+ if ($this->displaytype == 'list') {
635
+ if ($this->listtitle != '') {
636
+ $html .= '<h2 class="list-title">' . $this->listtitle . '</h2>';
637
+ }
638
+ } elseif ($this->displaytype == 'day') {
639
+ //$this->day = ;
640
+ } elseif ($this->displaytype == 'week') {
641
 
 
 
 
642
  }
643
+ //$html .= '</div>';
 
 
 
644
  }
645
+ return $html;
646
  }
647
 
648
+ // calendar cells for mini and full displaytypes
649
+ public function cal_previous () {
650
+ global $cal_ID;
651
+ $previous = $this->calcDate($this->year . '-' . $this->month, '-1', 'month');
652
+ $dateparam = $previous['year'] . '-' . $previous['month'];
653
+ $prev_date = '';
654
+ if ($this->displaytype == 'day') {
655
+ $previous = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-1', 'day');
656
+ $dateparam = $previous['year'] . '-' . $previous['month'] . '-' . $previous['day'];
657
+ $prev_date = $previous['day'];
658
+ } elseif ($this->displaytype == '4day') {
659
+ $previous = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-4', 'day');
660
+ $dateparam = $previous['year'] . '-' . $previous['month'] . '-' . $previous['day'];
661
+ $prev_date = $previous['day'];
662
+ } elseif ($this->displaytype == 'week') {
663
+ $previous = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '-1', 'week');
664
+ $dateparam = $previous['year'] . '-' . $previous['month'] . '-' . $previous['day'];
665
+ $prev_date = $previous['day'];
666
+ }
667
+ $this->previousmonth = ($this->getMonth($previous['year'] . '-' . $previous['month'], $this->monthnames));
668
+ if ($this->widget == 1) {
669
+ $previoustext = '<span><</span>';
670
+ } else {
671
+ $previoustext = '<span><</span><span class="month-name"> ' . __($this->previousmonth, 'ecwd') . ' ' . $prev_date . '</span>';
672
+ }
673
+ $html = '<div class="previous"><a href="?date=' . $dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow">' . $previoustext . '</a></div>';
674
+ return $html;
675
  }
676
 
677
+ // calendar footer for all displaytypes
678
+ public function calcDate ($startdate, $increment, $unit) {
679
+ if ($unit == 'month') {
680
+ $startdate = date('Y-m-15', strtotime($startdate));
681
+ }
682
+ $date = date("Y-n-j", strtotime(date("Y-n-j", strtotime($startdate)) . " " . $increment . " " . $unit));
683
+ $date = explode('-', $date);
684
+ $newdate = array(
685
+ 'year' => $date[0],
686
+ 'month' => $date[1],
687
+ 'day' => $date[2]
688
+ );
689
+ return $newdate;
690
  }
691
 
692
+ public function getWeekFirstDayDate($date) {
693
 
694
+ if (strtotime($date) == strtotime(date('Y-m-d'))) {
695
+ if ($this->weekstartday == 0) {
696
+ return date('Y-n-j', strtotime(strtolower($this->weekdays[$this->weekstartday]) . " previous week", strtotime($date)));
697
+ }
698
 
699
+ return date('Y-n-j', strtotime(strtolower($this->weekdays[$this->weekstartday]) . " this week", strtotime($date)));
700
+ } else {
701
+ $first_monday_of_month = strtotime('First ' . $this->weekdays[$this->weekstartday] . ' of ' . date('F o', strtotime($date)));
702
+ if (date('Y-n-j', $first_monday_of_month) == '1970-1-1' || date('Y-n-j', $first_monday_of_month) == '1969-12-31') {
703
+ $first_monday_of_month = strtotime(date('Y-m-d', strtotime(date('F o', strtotime($date)) . ' first ' . $this->weekdays[$this->weekstartday])));
704
+ }
705
+ if (date('j', $first_monday_of_month) > 1) {
706
+ $previous_monday = strtotime("-1 week", $first_monday_of_month);
707
 
708
+ return date('Y-n-j', $previous_monday);
709
+ } else {
710
+ return date('Y-n-j', $first_monday_of_month);
711
+ }
712
+ }
713
  }
 
 
 
 
 
 
 
714
 
 
 
715
 
716
+ public function getMonthDate ($date) {
717
+ if(date('m',strtotime($date)) === date('m')){
718
+ return date('Y-n-j');
 
 
 
 
719
  }
720
+ if ($this->displaytype == 'week' && strtotime($date) !== strtotime(date('Y-m-d'))) {
721
+ return date('Y-n-j', strtotime("+1 week", strtotime($date)));
722
+ } elseif ($this->displaytype == '4day' && strtotime($date) !== strtotime(date('Y-m-d'))) {
723
+ return date('Y-n-j', strtotime("+3 day", strtotime($date)));
724
+ }
725
+ return $date;
726
+ }
727
 
728
+ public function getDayDate ($date) {
729
+ if (strtotime($date) == strtotime(date('Y-m-d'))) {
730
+ return $date;
731
  } else {
732
+ if ($this->displaytype == 'full' || $this->displaytype == 'month' || $this->displaytype == 'mini' || $this->displaytype == 'list') {
733
+ return date('Y-n-j', strtotime(date('Y-m-1'), strtotime($date)));
734
+ } elseif ($this->displaytype == 'week') {
735
+ return date('Y-n-j', strtotime(strtolower($this->weekdays[$this->weekstartday]) . " this week", strtotime($date)));
736
+ } else {
737
+ return $date;
738
+ }
739
  }
740
  }
 
741
 
742
+ // add an event to the events array
743
+ public function getMonth ($date, $type = 1) {
744
+ $date = date('Y-n-j', strtotime($date));
745
+ $date_parts = explode('-', $date);
746
+ $jd = cal_to_jd(CAL_GREGORIAN, $date_parts[1], $date_parts[2], $date_parts[0]);
747
+ return __(jdmonthname($jd, $type));
748
  }
749
 
750
+ // pulls everything together and returns the calendar for all displaytypes
751
+ public function cal_next () {
752
+ global $cal_ID;
753
+ $html = '';
754
+ $next = $this->calcDate($this->year . '-' . $this->month . '-1', '+ 1', 'month');
755
+ $next_date = '';
756
+ $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
757
+ if ($this->displaytype == 'day') {
758
+ $next = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+1', 'day');
759
+ $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
760
+ $next_date = $next['day'];
761
+ } elseif ($this->displaytype == '4day') {
762
+ $next = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+4', 'day');
763
+ $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
764
+ $next_date = $next['day'];
765
  } elseif ($this->displaytype == 'week') {
766
+ $next = $this->calcDate($this->year . '-' . $this->month . '-' . $this->day, '+1', 'week');
767
+ $dateparam = $next['year'] . '-' . $next['month'] . '-' . $next['day'];
768
+ $next_date = $next['day'];
769
+ }
770
+ $this->nextmonth = ($this->getMonth($next['year'] . '-' . $next['month'], $this->monthnames));
771
+ if ($this->widget == 1) {
772
+ $nexttext = '<span>></span>';
773
  } else {
774
+ $divider = $this->monthselector === false ? '&nbsp;|&nbsp;' : '';
775
+ $nexttext = '<span class="month-name">' . $next_date . ' ' . $divider . __($this->nextmonth, 'ecwd') . ' </span><span>></span>';
776
  }
777
+ $html = '<div class="next"><a href="?date=' . $dateparam . '&t=' . $this->displaytype . '" rel="noindex, nofollow">' . $nexttext . '</a></div>';
778
+ return $html;
779
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
780
 
781
+ //--------------------------------------------------------------------------------------------
782
+ // Helper Functions
783
+ //--------------------------------------------------------------------------------------------
784
+ //
785
+ public function cal_viewmode () {
786
+ $monthType = ($this->widget == 1) ? 'mini' : 'full';
787
+ if ($this->widget == 1) {
788
+ $html = ' <div class="ecwd_calendar_view_dropdown cal_tabs_' . $this->color . '" ><a class="ecwd-dropdown-toggle" data-toggle="ecwd-dropdown">';
789
+ $html .= $this->displaysName[$this->displaytype]['name'];
790
+ $html .= '</a>';
791
+ $widgetDisplays = array(
792
+ 'mini',
793
+ 'list',
794
+ 'week',
795
+ 'day'
796
+ );
797
+ $html .= '<div class="ecwd-dropdown-menu">';
798
+ foreach ($widgetDisplays as $display) {
799
+ if ($display !== 'none' && isset($this->displaysName[$display])) {
800
+ $html .= '<div class="type">' . '<a href="?date=' . $this->displaysName[$display]['date'] . '&t=' . $display . '" rel="noindex, nofollow">' . $this->displaysName[$display]['name'] . '</a>' . '</div>';
801
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
802
  }
803
+ $html .= '</div></div>';
804
+ } else {
805
+ $html = ' <div class="ecwd_calendar_view_tabs cal_tabs_' . $this->color . '" >';
806
+ $html .= '<div class="filter-container">
 
 
807
  <div class="filter-arrow-left">&laquo;</div>
808
  <div class="filter-arrow-right">&raquo;</div>';
809
+ if (count($this->displays) > 1) {
810
+ $html .= '<ul>';
811
+ foreach ($this->displays as $display) {
812
+
813
+ if ($display !== 'none' && isset($this->displaysName[$display])) {
814
+ $html .= '<li class="type';
815
+ if ($this->displaytype == $display) {
816
+ $html .= ' ecwd-selected-mode';
817
+ $html .= '">' . '<a>' . $this->displaysName[$display]['name'] . '</a>' . '</li>';
818
+ } else {
819
+ $html .= '">' . '<a href="?date=' . $this->displaysName[$display]['date'] . '&t=' . $display . '" rel="noindex, nofollow">' . $this->displaysName[$display]['name'] . '</a>' . '</li>';
820
+ }
821
  }
822
  }
823
+ $html .= '</ul>';
824
  }
825
+ $html .= '</div>';
826
+ if ($this->event_search == 'yes') {
827
+ $svalue = '';
828
+ if (isset($this->search_params['query']) && $this->search_params['query']) {
829
+ $svalue = $this->search_params['query'];
830
+ }
831
+ $html .= '<div class="ecwd-search">
832
+ <input class="ecwd-search" name="search" type="text" value="' . $svalue . '">' . '<button class="btn btn-default ecwd-search-submit"><span class="glyphicon glyphicon-search"></span><i class="fa fa-search"></i></button>
 
 
 
833
  </div>';
834
+ }
835
+ $html .= '</div>';
836
  }
837
+ return $html;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
838
  }
 
 
 
 
 
 
839
 
840
+ // returns month from passed date (string), $type: 0=number,1=full(January,February,etc),2=abbreviation(Jan,Feb,etc)
841
+ public function calendar_cell ($day, $class, $date = '', $style = '') {
842
+ global $cal_ID, $ecwd_options;
843
+ $addclass = '';
844
+ if (strpos($class, 'normal-day-heading') !== false) {
845
+ $tag = 'th';
846
  } else {
847
+ $tag = 'td';
848
  }
849
+ if ($day != '') {
850
+ $bgColor = '';
851
+ $cellevents = array();
852
+ if (!$date && is_int($day)) {
853
+ $date = $this->year . '-' . $this->month . '-' . $day;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
854
  }
855
+ if (isset($this->events[strtotime($date)])) {
856
+ $all_events = array_reverse($this->events[strtotime($date)]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
857
  } else {
858
+ $all_events = array();
859
  }
860
+ if (is_array($all_events) && $date) { // events array populated from addEvent()
861
+ foreach ($all_events as $event) {
862
+ //echo $event['from'].'------'.$event['title'].'<br />';
863
+ $color = $event['color'];
864
+ $title = $event['title'];
865
+ $link = $event['link'];
866
+ $eventdate = $event['date'];
867
+ $from = strtotime($event['from']);
868
+ $to = strtotime($event['to']);
869
+ $starttime = $event['starttime'];
870
+ $endtime = $event['endtime'];
871
+ $details = $event['details'];
872
+ $location = $event['location'];
873
+ $venue = $event['venue'];
874
+ $organizers = $event['organizers'];
875
+ $terms = $event['terms'];
876
+ $all_day_event = $event['all_day_event'];
877
+ $permalink = $event['permalink'];
878
+ $image = $event['image'];
879
+ $latlong = $event['latlong'];
880
+ $id = $event['id'];
881
+ if ($date == date('Y-n-j', strtotime($eventdate))) {
882
+ $cellevents[] = array(
883
+ 'color' => $color,
884
+ 'title' => $title,
885
+ 'link' => $link,
886
+ 'date' => $eventdate,
887
+ 'from' => $from,
888
+ 'to' => $to,
889
+ 'id' => $id,
890
+ 'starttime' => $starttime,
891
+ 'endtime' => $endtime,
892
+ 'details' => $details,
893
+ 'location' => $location,
894
+ 'all_day_event' => $all_day_event,
895
+ 'latlong' => $latlong,
896
+ 'terms' => $terms,
897
+ 'venue' => $venue,
898
+ 'organizers' => $organizers,
899
+ 'permalink' => $permalink,
900
+ 'image' => $image,
901
+ );
902
+ }
903
+ }
904
+ }
905
+ // sort by starttime for the cell
906
+ if (count($cellevents) > 0) {
907
+ $cellevents = $this->arraySort($cellevents, 'starttime');
908
+ }
909
+ if ($date == date('Y-n-j')) {
910
+ $addclass .= ' current-day'; // if processing the current day
911
+ }
912
+ if (in_array($this->getDay($date), array(
913
+ 'Saturday',
914
+ 'Sunday'
915
+ ))) {
916
+ $addclass .= ' weekend'; // if a weekend
917
+ }
918
+ if ($this->getDay($date, 0) == $this->weekstartday) {
919
+ $addclass .= ' week-start'; // if the weekstartday
920
  }
921
+ if ($this->arraySearch($date, $cellevents) !== false) {
922
+ $addclass .= ' has-events'; // if the date has events
923
+ } else if (strpos($class, 'normal-day-heading') === false) {
924
+ $addclass .= ' no-events'; // no events
925
+ }
926
+ $combinedclass = $class . $addclass; // combine all classes
927
+ $html = '<' . $tag . ' class="' . $combinedclass . '" data-date="' . $date . '"';
928
+ // check/set links for mini calendar
929
+ if ($this->minilinkbase != '' && $this->displaytype == 'mini') {
930
+ if ($this->linktarget == '_blank') {
931
+ $html .= ' onClick="window.open(\'' . $this->minilinkbase . '?date=' . $date . '\', \'_blank\')"';
932
+ } else {
933
+ $html .= ' onClick="' . $this->linktarget . '.location=\'' . $this->minilinkbase . '?date=' . $date . '\'"';
934
  }
935
  }
936
+ }
937
+ if ($style) {
938
+ $html .= ' style="' . $style . '"';
939
+ }
940
+ if ($this->displaytype == 'mini') {
941
+ $content = $day;
942
+ } elseif ($this->widget && $this->displaytype != 'mini') {
943
+ $content = '<div class="ecwd-week-date">' . date('d', strtotime($date)) . '</div>';
944
+ } elseif (($this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day') && !$this->widget) {
945
+ //here
946
+ $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, strtotime($date)) : (date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd')));
947
+ if ($this->list_date_format !== 'd.F.l') {
948
+ $month_name = date('F', strtotime($date));
949
+ $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
950
  }
951
+ $content = '<div class="ecwd-week-date resp" itemprop="startDate" content="' . date('Y-m-d', strtotime($date)) . '">' . __(date('d', strtotime($date)), 'ecwd') . '</div><div class="ecwd-week-date web"">' . $event_date . '</div>';
952
+ } else {
953
+ $content = '<div class="day-number">' . $day . '</div>'; // day number or prev/next month cell content
954
+ }
955
+ if (count($cellevents) > 0) {
956
+ $content .= '<ul class="events">';
957
+ $eventcontent = '';
958
+ foreach ($cellevents as $i => $cellevent) {
959
+ //echo $cellevent['date'].'-------'.$cellevent['title'].'<br />';
960
+ //if (!array_key_exists($cellevent['id'], $this->seted_days)) {
961
+ $li_class = '';
962
+ if ($i > 2 && $this->displaytype !== 'mini') {
963
+ $li_class = 'inmore';
964
+ }
965
+ //var_dump($cellevent);
966
+ $eventcontent .= '<li itemscope itemtype="http://schema.org/Event" style="';
967
+ if (is_array($cellevent['terms'])) {
968
+ if (isset($cellevent['color']) && $cellevent['color'] !== '') {
969
+ $eventcontent .= 'background-color: ' . $cellevent['color'] . '; ';
970
+ }
971
+ }
972
+ $eventcontent .= '" class="' . $li_class . ' ' . $i;
973
+ if (isset($cellevent['terms']['ecwd_taxonomy_image']) && $cellevent['terms']['ecwd_taxonomy_image'] == '') {
974
+ $eventcontent .= ' no-cat-image ';
975
+ }
976
+ $eventcontent .= '">';
977
+ if ($this->displaytype != 'mini') {
978
+ if (isset($cellevent['terms']['ecwd_taxonomy_image']) && $this->displaytype != 'mini') {
979
+ if ($cellevent['terms']['ecwd_taxonomy_image'] != '') {
980
+ $eventcontent .= '<img class="ecwd-event-cat-icon" src="' . $cellevent['terms']['ecwd_taxonomy_image'] . '" />';
981
+ }/* elseif (isset($cellevent['color'])){
982
  $eventcontent .= ' <span class="event-metalabel" style="background:' . $cellevent['color'] . '"></span>';
983
  } */
984
+ }
985
+ if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
986
+ $eventcontent .= '<span start-date-data="' . $event['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '" itemprop="name">' . $cellevent['title'] . '</span>';
987
+ } elseif ($cellevent['permalink']) {
988
+ $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . '><span itemprop="name">' . $cellevent['title'] . '</span></a>';
989
+ } else {
990
+ $eventcontent .= '<span itemprop="name">' . $cellevent['title'] . '</span>';
991
+ }
992
  }
993
+ $this->seted_days[$cellevent['id']] = $date;
994
+ $ecwd_settings_general = get_option("ecwd_settings_general");
995
+ $show_events_detail_hover = true;
996
+ if ($ecwd_settings_general && isset($ecwd_settings_general["show_events_detail"])) {
997
+ $show_events_detail = $ecwd_settings_general["show_events_detail"];
998
+ if (intval($show_events_detail) === 0) {
999
+ $show_events_detail_hover = false;
1000
+ }
1001
  }
1002
+ if ($show_events_detail_hover) {
1003
+ echo "<input type='hidden' class='show_event_hover_info'>";
 
 
 
 
 
 
1004
  }
 
 
 
 
1005
  $eventcontent .= '<div class="event-details-container"><div class="ecwd-event-arrow"></div><div class="event-details">';
1006
  if ($cellevent['title'] != '') {
1007
  $eventcontent .= '<div class="event-details-title">';
1100
  // } else {
1101
  // //$eventcontent .= $cellevent['title'];
1102
  // }
1103
+ }
1104
+ $content .= apply_filters('format_content', $eventcontent);
1105
+ if ($i > 2 && $this->displaytype !== 'mini') {
1106
+ $content .= '<li class="ecwd-calendar-more-event">
 
 
1107
  <span class="ecwd-calendar-event-add">
1108
  <span class="more_events_link">' . __('More events', 'ecwd') . '</span>
1109
  </span>
1112
  <input type="hidden" class="ecwd-more-event-title" value="' . date($this->dateformat, strtotime($date)) . '" />
1113
  </div>
1114
  </li>';
1115
+ }
1116
+ $content .= '</ul>';
1117
+ if ($this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day') {
1118
+ if (count($cellevents) > 0) {
1119
+ $html = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1120
  if (!$this->widget) {
1121
+ $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, strtotime($date)) : (date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd')));
1122
+ if ($this->list_date_format !== 'd.F.l') {
1123
+ $month_name = date('F', strtotime($date));
1124
+ $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
 
 
 
 
 
 
 
 
1125
  }
1126
+ $html = '<div class="ecwd-week-date resp" style="background:#' . $this->eventlistbg . '" itemprop="startDate" content="' . date('Y-m-d', strtotime($date)) . 'T' . date('H:i', strtotime($date)) . '">' . date('d', strtotime($date)) . '</div><div class="ecwd-week-date web"">' . $event_date . '</div>';
1127
+ } else {
1128
+ $html = '<div class="ecwd-week-date">' . date('d', strtotime($date)) . '</div>';
1129
  }
1130
+ $html .= '<div class="event-main-content">';
1131
+ foreach ($cellevents as $cellevent) {
1132
+ $image_class = '';
1133
+ $cellevent['details'] = $cellevent['details'] == '' ? $this->eventemptytext : $cellevent['details'];
1134
+ $image = $this->getAndReplaceFirstImage($cellevent['details']);
1135
+ if (!has_post_thumbnail($cellevent['id']) && $cellevent['image'] == "") {
1136
+ $image_class = "ecwd-no-image";
 
 
 
1137
  }
1138
+ $html .= '<div class="event-container ' . $image_class . '" itemprop="event">';
1139
+ if (!$this->widget) {
1140
+ $html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container">';
1141
+ $html .= '<div class="ecwd-img">';
1142
+ if (get_the_post_thumbnail($cellevent['id']) || $cellevent['image']) {
1143
+ if (get_the_post_thumbnail($cellevent['id'])) {
1144
+ $html .= get_the_post_thumbnail($cellevent['id']);
1145
+ } else {
1146
+ $html .= '<img src="' . $cellevent['image'] . '" />';
1147
+ }
1148
+ } elseif ($image['image'] != null) {
1149
+ $html .= '<img src="' . $image['image'] . '" />';
1150
+ $cellevent['details'] = $image['content'];
1151
+ }
1152
+ $html .= '</div></div></div>';
1153
  }
1154
+ if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1155
+ $html .= '<h3 class="event-title" itemprop="name"><span start-date-data="' . $cellevent['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '"';
1156
+ if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1157
+ $html .= ' style="color:' . $cellevent['color'] . ';"';
1158
+ }
1159
+ $html .= '>' . $cellevent['title'] . '</span></h3>';
1160
+ } else if ($cellevent['permalink'] != '') {
1161
+ $html .= '<h3 class="event-title" itemprop="name"> <a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget;
1162
+ if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1163
+ $html .= ' style="color:' . $cellevent['color'] . ';"';
1164
+ }
1165
+ $html .= '>' . $cellevent['title'] . '</a></h3>';
1166
+ } else {
1167
+ $html .= '<h3 class="event-title" itemprop="name"';
1168
+ if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1169
+ $html .= 'style="color:' . $cellevent['color'] . ';"';
1170
  }
1171
+ $html .= '>' . $cellevent['title'] . '</h3>';
1172
+ }
1173
+ $html .= '<div class="ecwd-list-date-cont">';
1174
+ if (isset($cellevent['all_day_event']) && $cellevent['all_day_event'] == 1) {
1175
+ $eventtime = '<div class="ecwd-time"><span class="metainfo event-time" itemprop="startDate" content="' . date('Y-m-d', $cellevent['from']) . 'T' . date('H:i', strtotime($cellevent['starttime'])) . '"> ' . __('All day', 'ecwd');
1176
  $eventtime .= '</span>';
1177
  $eventtime .= '</div>';
1178
  $html .= $eventtime;
1179
+ } else {
1180
+ if ($cellevent['starttime'] != '') { // event details - hidden until clicked (full)
1181
+ $eventtime = '<div class="ecwd-time"><span class="metainfo event-time" itemprop="startDate" content="' . date('Y-m-d', $cellevent['from']) . 'T' . date('H:i', strtotime($cellevent['starttime'])) . '"> ' . date($this->timeformat, strtotime($cellevent['starttime']));
1182
+ if ($cellevent['endtime'] != '' && $cellevent['endtime'] != $cellevent['starttime']) {
1183
+ $eventtime .= "-" . date($this->timeformat, strtotime($cellevent['endtime']));
1184
+ }
1185
+ $eventtime .= '</span>';
1186
+ $eventtime .= '</div>';
1187
+ $html .= $eventtime;
1188
+ }
1189
  }
1190
+ if ($cellevent['from'] != '') {
1191
+ $eventdate = '<div class="ecwd-date"><span class="metainfo" itemprop="startDate" content="' . date('Y-m-d', $cellevent['from']) . 'T' . date('H:i', strtotime($cellevent['starttime'])) . '"> ' . date($this->dateformat, $cellevent['from']);
1192
+ if ($cellevent['to'] != '' && $cellevent['to'] != $cellevent['from']) {
1193
+ $eventdate .= "-" . date($this->dateformat, $cellevent['to']);
1194
+ }
1195
+ $eventdate .= '</span>';
1196
+ $eventdate .= '</div>';
1197
+ $html .= $eventdate;
 
 
 
 
 
 
 
1198
  }
1199
  $html .= '</div>';
1200
+ if (isset($cellevent['organizers']) && count($cellevent['organizers']) > 0) {
1201
+ $html .= '<div class="event-organizers">';
1202
+ foreach ($cellevent['organizers'] as $organizer) {
1203
+ $html .= '<div class="event-organizer" itemprop="organizer"> <a href="' . $organizer['permalink'] . '">' . $organizer['name'] . '</a></div>';
1204
+ }
1205
+ $html .= '</div>';
1206
  }
1207
+ if ($cellevent['location'] != '') {
1208
+ $html .= '<div class="event-venue" itemprop="location" itemscope itemtype="http://schema.org/Place">
1209
+ <span itemprop="name">';
1210
+ if (isset($cellevent['venue']['name'])) {
1211
+ $html .= '<a href="' . $cellevent['venue']['permalink'] . '">' . $cellevent['venue']['name'] . '</a>';
1212
+ }
1213
+ $html .= '</span>
1214
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
1215
  <span itemprop="streetAddress">' . $cellevent['location'] . '</span>
1216
  </div>
1217
  </div>';
1218
+ }
1219
+ $desc = $cellevent['details'] ? $cellevent['details'] : $this->eventemptytext;
1220
+ $desc = apply_filters('format_content', $desc);
1221
+ $html .= '<div class="event-content" itemprop="description">' . $desc . '</div></div>';
1222
  }
1223
+ $html .= '</div>';
1224
+ return $html;
 
1225
  }
1226
+ }
1227
+ } else {
1228
+ if ($this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day') {
1229
+ $content .= '<div class="event-main-content no-events">' . __('No events', 'ecwd') . '</div>';
1230
  }
1231
  }
1232
+ $html .= '>' . $content . '</td>';
1233
+ return $html;
 
 
1234
  }
1235
 
1236
+ public function arraySort ($a, $subkey) {
1237
+ foreach ($a as $k => $v) {
1238
+ $b[$k] = strtolower($v[$subkey]);
1239
+ }
1240
+ asort($b);
1241
+ foreach ($b as $key => $val) {
1242
+ $c[] = $a[$key];
1243
+ }
1244
+ return $c;
 
 
 
 
1245
  }
 
 
1246
 
1247
+ // add/subtract day,week,month,days from startdate
1248
+ public function getDay ($date, $type = 1) {
1249
+ $date = date('Y-n-j', strtotime($date));
1250
+ $date_parts = explode('-', $date);
1251
+ $jd = cal_to_jd(CAL_GREGORIAN, $date_parts[1], $date_parts[2], $date_parts[0]);
1252
+ return jddayofweek($jd, $type);
1253
+ }
 
 
 
 
1254
 
1255
+ // recursive array search returns the key of occurance (int) or false if not found
1256
+ public function arraySearch ($needle, $haystack, $index = null) {
1257
+ $aIt = new RecursiveArrayIterator($haystack);
1258
+ $it = new RecursiveIteratorIterator($aIt);
1259
+ while ($it->valid()) {
1260
+ if (((isset($index) AND ($it->key() == $index)) OR (!isset($index))) AND ($it->current() == $needle)) {
1261
+ return $aIt->key();
1262
+ }
1263
+ $it->next();
1264
  }
1265
+ return false;
1266
  }
1267
 
1268
+ public function getKey ($array, $member, $value) {
1269
+ foreach ($array as $k => $v) {
1270
+ if ($v->$member == $value) {
1271
+ return $k;
1272
+ }
 
 
1273
  }
1274
+ return false;
1275
  }
1276
 
1277
+ //return current week start and end dates
1278
+ public function rangeWeek ($datestr) {
1279
+ date_default_timezone_set(date_default_timezone_get());
1280
+ $res['start'] = date("Y-m-d", strtotime($datestr));
1281
+ $res['end'] = date("Y-m-d", strtotime("+6 day", strtotime($datestr)));
1282
+ return $res;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1283
  }
1284
 
1285
+ public function range4Days ($date) {
1286
+ date_default_timezone_set(date_default_timezone_get());
1287
+ $res['start'] = date("Y-m-d", strtotime($date));
1288
+ $res['end'] = date("Y-m-d", strtotime("+3 day", strtotime($date)));
1289
+ return $res;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1290
  }
1291
 
1292
+ public function calendar_foot () {
1293
+ if (in_array($this->displaytype, array(
1294
+ 'full',
1295
+ 'mini'
1296
+ ))) {
1297
+ $html = '</table>';
1298
+ } else {
1299
+ $html = '</div>';
 
 
 
 
 
1300
  }
1301
+ return $html;
 
 
 
 
 
1302
  }
1303
 
1304
+ // Removes tabs, line breaks, vertical tabs, null-byte. Everything but a regular space.
1305
+ public function stripWhitespace ($c) {
1306
+ $c = str_replace(array(
1307
+ "\n",
1308
+ "\r",
1309
+ "\t",
1310
+ "\o",
1311
+ "\xOB"
1312
+ ), '', $c);
1313
+ return trim($c);
1314
  }
1315
 
1316
+ // sorts an associative array by values of passed key
1317
+ public function hex2RGB ($hexStr, $returnAsString = false, $seperator = ',') {
1318
+ $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // check hex string
1319
+ $rgbArray = array();
1320
+ if (strlen($hexStr) == 6) { // if a proper hex code e.g. #RRGGBB
1321
+ $colorVal = hexdec($hexStr);
1322
+ $rgbArray['red'] = 0xFF & ($colorVal >> 0x10);
1323
+ $rgbArray['green'] = 0xFF & ($colorVal >> 0x8);
1324
+ $rgbArray['blue'] = 0xFF & $colorVal;
1325
+ } elseif (strlen($hexStr) == 3) { // if shorthand notation e.g #RGB
1326
+ $rgbArray['red'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2));
1327
+ $rgbArray['green'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2));
1328
+ $rgbArray['blue'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2));
1329
+ } else {
1330
+ return false; // invalid hex color code
1331
+ }
1332
+ // returns the rgb string or the associative array
1333
+ return $returnAsString ? implode($seperator, $rgbArray) : $rgbArray;
1334
+ }
1335
 
1336
+ public function getAndReplaceFirstImage ($content) {
1337
+ global $ecwd_options;
1338
+ $first_img = '';
1339
+ if ($ecwd_options) {
1340
+ if (!isset($ecwd_options["move_first_image"]) || intval($ecwd_options["move_first_image"]) === 0) {
1341
+ return array(
1342
+ 'image' => "",
1343
+ 'content' => $content
1344
+ );
1345
+ }
1346
+ }
1347
+ ob_start();
1348
+ ob_end_clean();
1349
+ $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
1350
+ if (isset($matches [1] [0])) {
1351
+ $first_img = $matches [1] [0];
1352
+ }
1353
+ if (empty($first_img)) { //Defines a default image
1354
+ return false;
1355
+ } else {
1356
+ //preg_replace('/<img[^>]+\>/i', '', $content);
1357
+ $content = $this->replaceFirstImage($content);
1358
+ }
1359
+ return array(
1360
+ 'image' => $first_img,
1361
+ 'content' => $content
1362
+ );
1363
+ }
1364
 
1365
+ public function replaceFirstImage ($content) {
1366
+ $content = preg_replace("/<img[^>]+\>/i", " ", $content, 1);
1367
+ return $content;
1368
+ }
1369
 
1370
+ public function cal_days_in_month () {
1371
+ $date_str = $this->year . '-' . $this->month . '-01';
1372
+ $date = date('t', strtotime($date_str));
1373
+ return intval($date);
1374
+ }
1375
 
 
1376
  }
1377
 
1378
+ // end class
 
 
includes/ecwd-shortcodes.php CHANGED
@@ -35,7 +35,7 @@ function ecwd_shortcode($attr) {
35
 
36
  if($calendar_start_date !== null){
37
  $args['date'] = date('Y-m-d',$calendar_start_date);
38
- }
39
 
40
  $calendar_ids = explode(',', str_replace(' ', '', $id));
41
  $result = ecwd_print_calendar($calendar_ids, $display, $args);
35
 
36
  if($calendar_start_date !== null){
37
  $args['date'] = date('Y-m-d',$calendar_start_date);
38
+ }
39
 
40
  $calendar_ids = explode(',', str_replace(' ', '', $id));
41
  $result = ecwd_print_calendar($calendar_ids, $display, $args);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webdorado
3
  Donate link: https://web-dorado.com/products/wordpress-event-calendar-wd.html
4
  Tags: calendar, date, event, event calendar, events, events calendar, meeting, organizer, recurring, reservation, responsive, schedule
5
  Requires at least: 3.9
6
- Tested up to: 4.5
7
- Stable tag: 1.0.67
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -155,6 +155,10 @@ After downloading the ZIP file of the Event Calendar WD plugin,
155
 
156
  == Changelog ==
157
 
 
 
 
 
158
  = 1.0.67 =
159
  * Added: Calendar start date option
160
 
3
  Donate link: https://web-dorado.com/products/wordpress-event-calendar-wd.html
4
  Tags: calendar, date, event, event calendar, events, events calendar, meeting, organizer, recurring, reservation, responsive, schedule
5
  Requires at least: 3.9
6
+ Tested up to: 4.6
7
+ Stable tag: 1.0.68
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
155
 
156
  == Changelog ==
157
 
158
+ = 1.0.68 =
159
+ * Fixed: List view pagination
160
+ * Fixed: Week view start
161
+
162
  = 1.0.67 =
163
  * Added: Calendar start date option
164