This repository has been archived by the owner on Sep 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar_menu_shortcodes.php
1143 lines (929 loc) · 32.5 KB
/
calendar_menu_shortcodes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Shortcodes for event calendar
*
*/
/**
* e107 Event calendar plugin
*
* Shortcodes for event calendar
*
* @package e107_plugins
* @subpackage event_calendar
*/
/*
TODO:
1. Good way of reading categories
2. Have 'currentMonth' flag (means 'current day' if $ds == 'one') ?
3. Check whether $prop should be calculated better
*/
if (!defined('e107_INIT'))
{
exit;
}
e107::lan('calendar_menu', e_LANGUAGE, false);
/*
Navigation Shortcodes
---------------------
EC_PREV_MONTH
EC_CURRENT_MONTH
EC_NEXT_MONTH
EC_PREV_YEAR
EC_NEXT_YEAR
EC_MONTH_LIST
Navigation Buttons
------------------
EC_NAV_BUT_ALLEVENTS
EC_NAV_BUT_VIEWCAT
EC_NAV_BUT_SUBSCRIPTION
EC_NAV_BUT_ENTEREVENT
EC_NAV_LINKCURRENTMONTH
EC_NAV_BUT_PRINTLISTS
Shortcodes for 'big' calendar display
-------------------------------------
EC_CALENDAR_CALENDAR_HEADER_DAY
EC_CALENDAR_CALENDAR_DAY_EVENT_HEADING
EC_CALENDAR_CALENDAR_DAY_TODAY_HEADING
EC_CALENDAR_CALENDAR_DAY_EMPTY_HEADING
EC_CALENDAR_CALENDAR_RECENT_ICON
Shortcodes for Event List
-------------------------
EC_EVENTLIST_CAPTION
Return event information
------------------------
EC_EVENT_LOCATION - event location
EC_EVENT_RECENT_ICON
EC_SHOWEVENT_IMAGE
EC_SHOWEVENT_INDICAT
EC_SHOWEVENT_HEADING
EC_IF_ALLDAY
EC_IF_SAMEDAY
EC_IFNOT_SAMEDAY
EC_IFNOT_ALLDAY
EC_EVENT_HEADING_DATE - date for heading
EC_EVENT_DATE_START - date for body
EC_EVENT_TIME_START
EC_EVENT_DATE_END
EC_EVENT_TIME_END
EC_EVENT_EVENT_DATE_TIME
EC_EVENT_TITLE
EC_EVENT_CAT_ICON
EC_EVENT_ID
EC_EVENT_DISPLAYSTYLE
EC_EVENT_DETAILS
EC_EVENT_CATEGORY
EC_EVENT_AUTHOR
EC_EVENT_CONTACT
EC_EVENT_THREAD
EC_EVENT_OPTIONS
EC_EC_EVENT_LINK
EC_EVENT_SHORT_DATE
Event Archive
-------------
EC_EVENTARCHIVE_CAPTION
EC_EVENTARCHIVE_DATE
EC_EVENTARCHIVE_DETAILS
EC_EVENTARCHIVE_HEADING
EC_EVENTARCHIVE_EMPTY
Forthcoming Events menu
-----------------------
EC_NEXT_EVENT_RECENT_ICON
EC_NEXT_EVENT_TIME
EC_NEXT_EVENT_DATE
EC_NEXT_EVENT_TITLE
EC_NEXT_EVENT_ICON
EC_NEXT_EVENT_GAP
Shortcodes for event calendar mailout
-------------------------------------
EC_MAIL_HEADING_DATE - event start date, optional parameter to format date (intended for headings etc)
EC_MAIL_DATE_START - event start date, optional parameter to format date (intended for body text)
EC_MAIL_DATE_START_ALLDAY - returns date only for all day events, otherwise empty string
EC_MAIL_DATE_START_TIMED - returns date only for 'timed' events, otherwise empty string
EC_MAIL_TIME_START - event start time
EC_MAIL_DATE_END - event end date (empty string if same as start date)
EC_MAIL_TIME_END - time at which event ends (empty string if all day)
EC_MAIL_TITLE - title of event
EC_MAIL_ID - event ID (in database)
EC_MAIL_DETAILS - event details
EC_MAIL_CATEGORY - event category text
EC_MAIL_LOCATION - use EC_EVENT_LOCATION
EC_MAIL_CONTACT - event contact
EC_MAIL_THREAD - forum thread
EC_MAIL_LINK - link to event detail on web site
EC_MAIL_SHORT_DATE - short date (day, month) for event start
EC_MAIL_SUBJECT - subject for mailout
List printing
-------------
EC_PR_LIST_TITLE
EC_PR_CAT_LIST
EC_PR_CHANGE_YEAR
EC_PR_CHANGE_MONTH
EC_NOW_TIME
EC_NOW_DATE
EC_PR_LIST_START
EC_PR_LIST_END
EC_PRINT_BUTTON
EC_IF_PRINT
EC_IFNOT_PRINT
EC_IF_DISPLAY
EC_IFNOT_DISPLAY
EC_IF_PDF
EC_IFNOT_PDF
*/
class plugin_calendar_menu_shortcodes extends e_shortcode
{
public $event; // Current event being displayed
public $ecalClass; // Pointer to event calendar class
public $headerDay = 0; // Day number for header
public $todayStart; // Start of current day
public $curDay; // Current day of month (1..31)
public $numEvents = 0; // Number of events to be expected in certain list formats
public $catFilter = '*'; // Event category filter
public $eventDisplayCodes = ''; // Set to be an array of options
public $ecOutputType = ''; // Used by printing routines
public $changeFlags = array(); // Used by printing routines
public $printVars = array(); // USed by printing routine
private $months = array(
EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6,
EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11
); // 'Long' month names
private $monthabb = array(
EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN,
EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC
); // 'Short' month names
private $days = array(
EC_LAN_DAY_1, EC_LAN_DAY_2, EC_LAN_DAY_3, EC_LAN_DAY_4, EC_LAN_DAY_5, EC_LAN_DAY_6, EC_LAN_DAY_7,
EC_LAN_DAY_8, EC_LAN_DAY_9, EC_LAN_DAY_10, EC_LAN_DAY_11, EC_LAN_DAY_12, EC_LAN_DAY_13, EC_LAN_DAY_14,
EC_LAN_DAY_15, EC_LAN_DAY_16, EC_LAN_DAY_17, EC_LAN_DAY_18, EC_LAN_DAY_19, EC_LAN_DAY_20, EC_LAN_DAY_21,
EC_LAN_DAY_22, EC_LAN_DAY_23, EC_LAN_DAY_24, EC_LAN_DAY_25, EC_LAN_DAY_26, EC_LAN_DAY_27, EC_LAN_DAY_28,
EC_LAN_DAY_29, EC_LAN_DAY_30, EC_LAN_DAY_31
); // Days of month (numbers)
private $nowDay; // Today
private $nowMonth;
private $nowYear;
private $day; // Day of month - often not used
private $month; // Month to display
private $year; // Year to display
private $previous; // Previous month - date stamp
private $next; // Next month - date stamp
private $monthStart;
private $monthEnd;
private $prevMonth;
private $nextMonth;
private $prevLink; // Previous year
private $py;
private $nextLink; // Next year
private $ny;
private $prop; // Start date for new event entry
private $ds = ''; // Display type for some shortcodes (mostly event listing)
private $ourDB; // For when we need a DB object
public function __construct()
{
}
/**
* Set the current date for calendar display
*
* Routine then calculates various values needed for shortcodes
*
* @param array $curDate - As returned by getdate()
*
* @return BOOLEAN TRUE
*/
public function setCalDate($curDate)
{
$this->ds = varset($curDate['ds'], '');
$this->day = varset($curDate['mday'], 0); // Day number being shown - rarely relevant
$this->month = $curDate['mon']; // Number of month being shown
$this->year = $curDate['year']; // Number of year being shown
$this->monthStart = gmmktime(0, 0, 0, $curDate['mon'], 1, $curDate['year']); // Start of month to be shown
$this->monthEnd = gmmktime(0, 0, 0, $curDate['mon'] + 1, 1, $curDate['year']) - 1; // End of month to be shown
// Calculate date code for previous month
$this->prevMonth = $curDate['mon'] - 1;
$prevYear = $curDate['year'];
if ($this->prevMonth == 0)
{
$this->prevMonth = 12;
$prevYear--;
}
$this->previous = gmmktime(0, 0, 0, $this->prevMonth, 1, $prevYear); // Previous month - Used by nav
// Calculate date code for next month
$this->nextMonth = $curDate['mon'] + 1;
$nextYear = $curDate['year'];
if ($this->nextMonth == 13)
{
$this->nextMonth = 1;
$nextYear++;
}
$this->next = gmmktime(0, 0, 0, $this->nextMonth, 1, $nextYear); // Next month - used by nav
$this->py = $curDate['year'] - 1; // Number of previous year for nav
$this->prevLink = gmmktime(0, 0, 0, $curDate['mon'], 1, $this->py);
$this->ny = $curDate['year'] + 1; // Number of next year for nav
$this->nextLink = gmmktime(0, 0, 0, $curDate['mon'], 1, $this->ny);
$this->prop = gmmktime(0, 0, 0, $curDate['mon'], $curDate['mday'], $curDate['year']); // Sets start date for new event entry
$this->nowMonth = $this->ecalClass->cal_date['mon'];
$this->nowYear = $this->ecalClass->cal_date['year'];
$this->nowDay = $this->ecalClass->cal_date['mday'];
return TRUE;
}
// Navigation shortcodes
public function sc_ec_prev_month($parm = '')
{
$class = (!empty($parm['class'])) ? $parm['class'] : '';
return "<a class='ec_prev_month {$class}' href='" . e_SELF . "?" . $this->previous . "'><< " . $this->months[($this->prevMonth - 1)] . "</a>";
}
public function sc_ec_next_month($parm = '')
{
$class = (!empty($parm['class'])) ? $parm['class'] : '';
return "<a class='ec_next_month {$class}' href='" . e_SELF . "?" . $this->next . "'> " . $this->months[($this->nextMonth - 1)] . " >></a>";
}
public function sc_ec_prev_year($parm = '')
{
$class = (!empty($parm['class'])) ? $parm['class'] : '';
return "<a class='ec_prev_year {$class}' href='" . e_SELF . "?" . $this->prevLink . "'><< " . $this->py . "</a>";
}
public function sc_ec_next_year($parm = '')
{
$class = (!empty($parm['class'])) ? $parm['class'] : '';
return "<a class='ec_next_year {$class}' href='" . e_SELF . "?" . $this->nextLink . "'>" . $this->ny . " >></a>";
}
public function sc_ec_month_list($parm = '')
{
$ret = '';
$class = (!empty($parm['class'])) ? $parm['class'] : '';
for ($ii = 0; $ii < 12; $ii++)
{
$monthJump = gmmktime(0, 0, 0, $ii + 1, 1, $this->year);
$ret .= "<a class='ec_month_list {$class}' href='" . e_SELF . "?" . $monthJump . "'>" . $this->monthabb[$ii] . "</a> ";
}
return $ret;
}
// Navigation buttons
public function sc_ec_current_month($parm = '')
{
if ($this->ecalClass->pref['eventpost_dateformat'] == 'my')
{
return $this->months[($this->month - 1)] . ' ' . $this->year;
}
return $this->year . ' ' . $this->months[($this->month - 1)];
}
public function sc_ec_nav_but_allevents($parm = '')
{
$allevents = (e_PAGE == "event.php" ? EC_LAN_96 : EC_LAN_93);
return "<input class='btn btn-calendar' type='submit' style='width:140px;' name='viewallevents' value='" . $allevents . "' title='" . $allevents . "' />";
}
public function sc_ec_nav_but_viewcat($parm = '')
{
return "<input type='hidden' name='do' value='vc' />";
}
public function sc_ec_nav_but_subscription($parm = '')
{
if (isset($this->ecalClass->pref['eventpost_asubs']) && ($this->ecalClass->pref['eventpost_asubs'] > 0) && USER)
{
return "<input class='btn btn-calendar' type='submit' style='width:140px;' name='subs' value='" . EC_LAN_123 . "' title='" . EC_LAN_182 . "' />";
}
return '';
}
public function sc_ec_nav_but_enterevent($parm = '')
{
$ret = "<input type='hidden' name='enter_new_val' value='" . $this->prop . "' />";
if ($this->ecalClass->cal_super || check_class($this->ecalClass->pref['eventpost_admin']))
{
$ret .= "<input class='btn btn-calendar' type='submit' style='width:140px;' name='doit' value='" . EC_LAN_94 . "' />";
}
return $ret;
}
public function sc_ec_nav_linkcurrentmonth($parm = '')
{
$ret = '';
if ($this->month != $this->nowMonth || $this->year != $this->nowYear || $this->ds == 'one')
{ // Just jump to current page without a query part - that will default to today
$ret = "<input class='btn btn-calendar' type='button' style='width:140px;' name='cur' value='" . EC_LAN_40 . "' onclick=\"javascript:document.location='" . e_SELF . "'\" />";
}
return $ret;
}
public function sc_ec_nav_but_printlists($parm = '')
{
if (isset($this->ecalClass->pref['eventpost_printlists']) && ($this->ecalClass->pref['eventpost_printlists'] > 0) && USER)
{
return "<input class='btn btn-calendar' type='submit' style='width:140px;' name='printlists' value='" . EC_LAN_164 . "' title='" . EC_LAN_183 . "' />";
}
else
{
return '';
return 'Cant print lists';
}
}
// Categories listing
public function sc_ec_nav_categories($parm = '')
{
if ($this->ourDB == NULL)
{
$this->ourDB = new db; // @todo use new method
}
($parm == 'nosubmit') ? $insert = '' : $insert = "onchange='this.form.submit()'";
$ret = "<select name='event_cat_ids' class='tbox form-control' style='width: 140px;display: inherit;' {$insert} >\n<option value='all'>" . EC_LAN_97 . "</option>\n";
$cal_arg = ($this->ecalClass->cal_super ? '' : " find_in_set(event_cat_class,'" . USERCLASS_LIST . "') AND ");
$cal_arg .= "(event_cat_name != '" . EC_DEFAULT_CATEGORY . "') ";
$this->ourDB->db_Select("event_cat", "*", $cal_arg);
while ($row = $this->ourDB->db_Fetch())
{
$selected = ($row['event_cat_id'] == $this->catFilter) ? " selected='selected'" : '';
$ret .= "<option class='tbox' value='" . $row['event_cat_id'] . "'{$selected}>" . $row['event_cat_name'] . "</option>\n";
}
$ret .= "</select>\n";
return $ret;
}
// Event information shortcodes
//-----------------------------
public function sc_ec_event_location($parm = '')
{
return $this->event['event_location'];
}
public function sc_ec_event_recent_icon()
{
return $this->sc_ec_calendar_calendar_recent_icon();
}
public function sc_ec_if_allday($parm = '')
{
if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return '';
return e107::getParser()->parseTemplate('{' . $parm . '}', FALSE, $this);
}
public function sc_ec_ifnot_allday($parm = '')
{
if ($this->event['event_allday']) return '';
if (trim($parm) == '') return '';
return e107::getParser()->parseTemplate('{' . $parm . '}', FALSE, $this);
}
public function sc_ec_ifnot_sameday($parm = '')
{
if (intval($this->event['event_end'] / 86400) == intval($this->event['event_start'] / 86400)) return '';
if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{' . $parm . '}', FALSE, $this);
}
public function sc_ec_if_sameday($parm = '')
{
if (intval($this->event['event_end'] / 86400) != intval($this->event['event_start'] / 86400)) return '';
if (!$this->event['event_allday']) return '';
if (trim($parm) == '') return;
return e107::getParser()->parseTemplate('{' . $parm . '}', FALSE, $this);
}
// Event mailout shortcodes
//--------------------------
public function sc_ec_mail_heading_date($parm)
{
if (isset($parm) && ($parm !== ""))
{
return strftime($parm, $this->event['event_start']);
}
else
{
return $this->ecalClass->event_date_string($this->event['event_start']);
}
}
public function sc_ec_mail_date_start($parm)
{
return $this->sc_ec_mail_heading_date($parm);
}
public function sc_ec_mail_date_start_allday($parm)
{
if ($this->event['event_allday'] != 1) return '';
return $this->sc_ec_mail_heading_date($parm);
}
public function sc_ec_mail_date_start_timed($parm)
{
if ($this->event['event_allday'] == 1) return '';
return $this->sc_ec_mail_heading_date($parm);
}
public function sc_ec_mail_time_start($parm)
{
if ($this->event['event_allday'] == 1) return '';
return $this->ecalClass->time_string($this->event['event_start']);
}
public function sc_ec_mail_date_end($parm = '')
{
if ($this->event['event_allday'] || ($this->event['event_end'] == $this->event['event_start'])) return '';
if ($parm !== '')
{
return strftime($parm, $this->event['event_end']);
}
return $this->ecalClass->event_date_string($this->event['event_end']);
}
public function sc_ec_mail_time_end($parm = '')
{
global $ecal_class;
if ($this->event['event_allday'] || ($this->event['event_end'] == $this->event['event_start'])) return '';
$endds = $ecal_class->time_string($this->event['event_end']);
return $endds;
}
public function sc_ec_mail_title($parm = '')
{
return $this->event['event_title'];
}
public function sc_ec_mail_id($parm = '')
{
return 'calevent' . $this->event['event_id'];
}
public function sc_ec_mail_details($parm = '')
{
return e107::getParser()->toHTML($this->event['event_details'], TRUE, 'E_BODY');
}
public function sc_ec_mail_category($parm = '')
{
return $this->event['event_cat_name'];
}
public function sc_ec_mail_contact($parm = '')
{
if ($this->event['event_contact'] == '') return '';
return e107::getParser()->toHTML($this->event['event_contact'], TRUE, 'LINKTEXT');
}
public function sc_ec_mail_thread($parm = '')
{
return $this->event['event_thread'];
}
public function sc_ec_mail_link($parm = '')
{
$cal_dayarray = getdate($this->event['event_start']);
$cal_linkut = gmmktime(0, 0, 0, $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']) . ".one"; // ALways need "one"
return ' ' . SITEURLBASE . e_PLUGIN_ABS . 'calendar_menu/event.php?' . $cal_linkut . ' ';
}
public function sc_ec_mail_short_date($parm = '')
{
return $this->ecalClass->next_date_string($this->event['event_start']);
}
// Codes can be used to return a LAN to help with multi-language
public function sc_ec_mail_subject($parm = '')
{
return EC_MAILOUT_SUBJECT;
}
//------------------------------------------
// CALENDAR CALENDAR - 'Big' calendar
//------------------------------------------
public function sc_ec_calendar_calendar_header_day($parm = '')
{
if (isset($this->ecalClass->pref['eventpost_lenday']) && $this->ecalClass->pref['eventpost_lenday'])
{
return "<strong>" . e107::getParser()->text_truncate($this->headerDay, $this->ecalClass->pref['eventpost_lenday'], '') . "</strong>";
}
else
{
return "<strong>" . $this->headerDay . "</strong>";
}
}
public function sc_ec_calendar_calendar_day_today_heading()
{
return "<b><a href='" . e_PLUGIN_ABS . "calendar_menu/event.php?" . $this->todayStart . "'>" . $this->days[($this->curDay - 1)] . "</a></b> <span class='smalltext'>[" . EC_LAN_TODAY . "]</span>";
}
public function sc_ec_calendar_calendar_day_event_heading()
{
return "<a href='" . e_PLUGIN_ABS . "calendar_menu/event.php?" . $this->todayStart . ".one'>" . $this->days[($this->curDay - 1)] . "</a>";
}
public function sc_ec_calendar_calendar_day_empty_heading()
{
return "<a href='" . e_PLUGIN_ABS . "calendar_menu/event.php?" . $this->todayStart . "'>" . $this->days[($this->curDay - 1)] . "</a>";
}
public function sc_ec_calendar_calendar_recent_icon()
{
if (!isset($this->event['is_recent'])) return '';
if (!$this->event['startofevent']) return ''; // Only display on first day of multi-day events
if (is_readable(EC_RECENT_ICON))
{
return "<img src='" . EC_RECENT_ICON_ABS . "' alt='' /> ";
}
return "R";
}
public function sc_ec_event_page_title()
{
switch ($this->ds)
{
case 'one':
return EC_LAN_80 . ': ' . $this->day . ' ' . $this->months[$this->month - 1];
// case 'event' : return EC_LAN_122.': '.$this->day.' '.$this->months[$this->month-1];
case 'event':
return EC_LAN_122;
default:
return EC_LAN_80;
}
}
public function sc_ec_showevent_image($parm = '')
{
//TODO review bullet
$img = '';
if ($this->event['event_cat_icon'])
{
// WARNING todo $this->event['imagesize' doesnt work!!!!
$w = varset($parm['w'], $this->event['imagesize']);
$h = varset($parm['h'], $this->event['imagesize']);
$parm = array("w" => $w, "h" => $h, "class" => "showevent_image img-responsive img-fluid");
//$img = "<img style='border:0' src='".e_PLUGIN_ABS.'calendar_menu/images/'.$this->event['event_cat_icon']."' alt='' height='".$this->event['imagesize']."' width='".$this->event['imagesize']."' />";
$img = $this->sc_ec_event_cat_icon($parm);
}
elseif (defined('BULLET'))
{
$img = '<img src="' . THEME_ABS . 'images/' . BULLET . '" alt="" class="icon" />';
}
elseif (file_exists(THEME . 'images/bullet2.gif'))
{
$img = '<img src="' . THEME_ABS . 'images/bullet2.gif" alt="" class="icon" />';
}
return $img;
}
public function sc_ec_showevent_indicat()
{
return $this->event['indicat'];
}
public function sc_ec_showevent_heading()
{
$linkut = mktime(0, 0, 0, $this->month, $this->curDay, $this->year);
$show_title = e107::getParser()->toHTML($this->event['event_title'], FALSE, 'TITLE'); // Remove entities in case need to truncate
if (isset($this->event['fulltopic']) && !$this->event['fulltopic'])
{
$show_title = e107::getParser()->text_truncate($show_title, 10, '...');
}
if ($this->event['startofevent'])
{
$eTitle = $this->event['event_title'];
if ($this->event['event_allday'] == 0)
{
$eTitle .= ' (' . $this->ecalClass->time_string($this->event['event_start']) . ')';
}
return "<b><a title='{$eTitle}' href='" . e_PLUGIN_ABS . 'calendar_menu/event.php?' . $linkut . '.event.' . $this->event['event_id'] . "'><span class='mediumtext'>" . $show_title . "</span></a></b>";
}
else
{
return "<a title='{$this->event['event_title']}' href='" . e_PLUGIN_ABS . 'calendar_menu/event.php?' . $linkut . '.event.' . $this->event['event_id'] . "'><span class='smalltext'>" . $show_title . "</span></a>";
}
}
public function sc_ec_eventlist_caption()
{
$ret = '';
if ($this->ds == 'one')
{
$ret = EC_LAN_111 . $this->months[$this->month - 1] . ' ' . $this->day;
}
elseif ($this->ds != 'event')
{
$ret = EC_LAN_112 . $this->months[$this->month - 1];
}
return $ret;
}
//---------------------------------------------------
// EVENT SHOWEVENT (Detail of individual events)
//---------------------------------------------------
public function sc_ec_event_heading_date()
{
return $this->ecalClass->event_date_string($this->event['event_start']);
}
// Same code as previous
public function sc_ec_event_date_start()
{
return $this->ecalClass->event_date_string($this->event['event_start']);
}
public function sc_ec_event_time_start()
{
if ($this->event['event_allday'] == 1) return '';
return $this->ecalClass->time_string($this->event['event_start']);
}
public function sc_ec_event_date_end()
{
if ($this->event['event_end'] == $this->event['event_start']) return '';
return $this->ecalClass->event_date_string($this->event['event_end']);
}
public function sc_ec_event_time_end()
{
if ($this->event['event_allday'] || ($this->event['event_end'] == $this->event['event_start'])) return '';
return $this->ecalClass->time_string($this->event['event_end']);
}
public function sc_ec_event_title()
{
return $this->event['event_title'];
}
public function sc_ec_event_cat_icon($parm = '')
{
if ($this->event['event_cat_icon'])
{
// WARNING TODO e107::getParser()->thumbWidth() doesn't work
$class = varset($parm['class'], 'event_cat_icon img-responsive img-fluid');
$w = vartrue($parm['w']) ? $parm['w'] : e107::getParser()->thumbWidth(); // 190; // 160;
$h = vartrue($parm['h']) ? $parm['h'] : e107::getParser()->thumbHeight(); // 130;
$opts = array(
'legacy' => "{e_PLUGIN}calendar_menu/images/'",
'class' => $class,
'alt' => $this->event['event_title'],
'w' => $w,
'h' => $h,
'x' => 1,
'crop' => 1
);
$fe_icon_file = e107::getParser()->toImage($this->event['event_cat_icon'], $opts);
return $fe_icon_file;
}
return '';
}
public function sc_ec_event_id()
{
return 'calevent' . $this->event['event_id'];
}
public function sc_ec_event_displaystyle()
{ // Returns initial state of expandable blocks
if (($this->ds == 'event') || ($this->ds == 'one'))
{
return ''; // Let block display
}
return 'display: none; ';
}
/**
* Display class for event display block - to manage expansion/contraction
* When displaying a single event, or a single day's events, block to be expanded
* For event lists, block to be contracted
*
* @param int $param - optional supplementary list of classes to apply
*
* @return string -
*/
public function sc_ec_event_displayclass($parm = '')
{
$class = empty($parm) ? "" : $parm;
if (($this->ds == 'event') || ($this->ds == 'one'))
{ // Single event or one day's events - block expanded
return " class='{$class}'";
}
return " class='e-show-if-js e-hideme {$class}'"; // Block contracted
// return " class='e-hide-if-js e-showme {$parm}'"; // Block contracted
}
public function sc_ec_event_details()
{
return e107::getParser()->toHTML($this->event['event_details'], TRUE, 'BODY');
}
public function sc_ec_event_category()
{
return $this->event['event_cat_name'];
}
public function sc_ec_event_author()
{
$lp = explode(".", $this->event['event_author'], 2); // Split into userid.username
if (preg_match("/[0-9]+/", $lp[0]))
{
$event_author_id = $lp[0];
$event_author_name = $lp[1];
}
if (USER)
{
return "<a href='" . e_HTTP . "user.php?id." . $event_author_id . "'>" . $event_author_name . "</a>";
}
return $event_author_name;
}
public function sc_ec_event_contact()
{
if ($this->event['event_contact'] == '') return '';
$tm = $this->event['event_contact'];
if (strpos($tm, '[') === FALSE)
{ // Add a bbcode if none exists
$tm = '[link=mailto:' . trim($tm) . ']' . substr($tm, 0, strpos($tm, '@')) . '[/link]';
}
return e107::getParser()->toHTML($tm, TRUE, 'LINKTEXT'); // Return obfuscated email link
}
public function sc_ec_event_thread()
{
if (isset($this->event['event_thread']) && ($this->event['event_thread'] != ''))
{
return "<a href='{$this->event['event_thread']}'><img src='" . e_IMAGE_ABS . "admin_images/forums_32.png' alt='' style='border:0; vertical-align:middle;' width='16' height='16' /></a> <a href='{$this->event['event_thread']}'>" . EC_LAN_39 . "</a>";
}
return '';
}
public function sc_ec_event_options()
{
$event_author_name = strstr(varset($this->event['event_author'], '0.??'), '.');
if (USERNAME == $event_author_name || $this->ecalClass->cal_super || check_class($this->ecalClass->pref['eventpost_admin']))
{
return "<a href='" . e_PLUGIN_ABS . "calendar_menu/event.php?ed." . $this->event['event_id'] . "'><img class='icon S16' src='" . e_IMAGE_ABS . "admin_images/edit_16.png' title='" . EC_LAN_35 . "' alt='" . EC_LAN_35 . "'/></a> <a href='" . e_PLUGIN_ABS . 'calendar_menu/event.php?de.' . $this->event['event_id'] . "'><img style='border:0;' src='" . e_IMAGE_ABS . "admin_images/delete_16.png' title='" . EC_LAN_36 . "' alt='" . EC_LAN_36 . "'/></a>";
}
}
public function sc_ec_ec_event_link()
{
$cal_dayarray = getdate($this->event['event_start']);
$cal_linkut = mktime(0, 0, 0, $cal_dayarray['mon'], $cal_dayarray['mday'], $cal_dayarray['year']) . '.one'; // ALways need "one"
return ' ' . e_PLUGIN_ABS . 'calendar_menu/event.php?' . $cal_linkut . ' ';
}
public function sc_ec_event_event_date_time()
{
$et = 0;
if (intval($this->event['event_end'] / 86400) == intval($this->event['event_start'] / 86400)) $et += 1;
if ($this->event['event_allday']) $et += 2;
if (is_array($this->eventDisplayCodes))
{
return e107::getParser()->parseTemplate($this->eventDisplayCodes[$et], FALSE, $this);
}
return '--** No template set **--';
}
public function sc_ec_event_short_date()
{
return $this->ecalClass->next_date_string($this->event['event_start']);
}
//------------------------------------------
// EVENT ARCHIVE (list of next events at bottom of event list)
//------------------------------------------
public function sc_ec_eventarchive_caption()
{
if ($this->numEvents == 0)
{
return EC_LAN_137;
}
return str_replace('-NUM-', $this->numEvents, EC_LAN_62);
}
public function sc_ec_eventarchive_date()
{
$startds = $this->ecalClass->event_date_string($this->event['event_start']);
return "<a href='" . e_PLUGIN_ABS . "calendar_menu/event.php?" . $this->event['event_start'] . '.event.' . $this->event['event_id'] . "'>" . $startds . "</a>";
}
public function sc_ec_eventarchive_details()
{
$number = 40;
$rowtext = e107::getParser()->toHTML($this->event['event_details'], TRUE, 'BODY');
$rowtext = strip_tags($rowtext);
$words = explode(' ', $rowtext);
$ret = implode(' ', array_slice($words, 0, $number));
if (count($words) > $number)
{
$ret .= ' ' . EC_LAN_133 . ' ';
}
return $ret;
}
public function sc_ec_eventarchive_empty()
{
return EC_LAN_37;
}
public function sc_ec_eventarchive_heading()
{
return $this->event['event_title'];
}
// FORTHCOMING EVENTS MENU
//---------------------------
function sc_ec_next_event_recent_icon()
{
if (!$this->ecalClass->pref['eventpost_fe_showrecent']) return;
if (!isset($this->event['is_recent'])) return;
if (is_readable(EC_RECENT_ICON))
{
return "<img src='" . EC_RECENT_ICON_ABS . "' alt='' /> ";
}
return '';
}
public function sc_ec_next_event_time()
{
if ($this->event['event_allday'] != 1)
{
return $this->ecalClass->time_string($this->event['event_start']);
}
return '';
}
public function sc_ec_next_event_date()
{
return $this->ecalClass->next_date_string($this->event['event_start']);
}
public function sc_ec_next_event_title()
{
if (isset($this->ecalClass->pref['eventpost_namelink']) && ($this->ecalClass->pref['eventpost_namelink'] == '2') && (isset($this->event['event_thread']) && ($this->event['event_thread'] != '')))
{
$fe_event_title = "<a href='" . $this->event['event_thread'] . "'>";
}
else
{
$fe_event_title = "<a href='" . e_PLUGIN_ABS . "calendar_menu/event.php?" . $this->event['event_start'] . ".event." . $this->event['event_id'] . "'>";
}
$fe_event_title .= $this->event['event_title'] . "</a>";
return $fe_event_title;
}
public function sc_ec_next_event_icon($parm = '')
{
$fe_icon_file = '';
if ($this->ecalClass->pref['eventpost_showcaticon'] == 1)
{
if ($this->event['event_cat_icon'])
{