-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec_day.class.php
139 lines (130 loc) · 6.25 KB
/
ec_day.class.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
<?php
/**
* This file contains WP Events Calendar plugin.
*
* This is the main WPEC file.
* @internal Complete the description.
*
* @package WP-Events-Calendar
* @since 1.0
*
* @autbor Luke Howell <[email protected]>
*
* @copyright Copyright (c) 2007-2009 Luke Howell
*
* @license GPLv3 {@link http://www.gnu.org/licenses/gpl}
* @filesource
*/
/*
--------------------------------------------------------------------------
$Id$
--------------------------------------------------------------------------
This file is part of the WordPress Events Calendar plugin project.
For questions, help, comments, discussion, etc., please join our
forum at {@link http://www.wp-eventscalendar.com/forum}. You can
also go to Luke's ({@link http://www.lukehowelll.com}) blog.
WP Events Calendar is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
if(!class_exists('EC_Day')):
/** Load the WPEC database class. */
require_once('ec_db.class.php');
/**
* Display the events of the day in a thickbox.
*
* @package WP-Events-Calendar
* @since 6.0
*/
class EC_Day {
/**
* Holds the $wpdb global object
* @var object
* @access private
*/
var $db;
/**
* Constructor.
*/
function EC_Day() {
// 6.5.2.2 commenting this. i don't understand why it's here.
// it loads functions unless they have been overriden by plugins.
// requiring it stops other plugins to overrride these functions.
// --laplix
//require_once(ABSWPINCLUDE.'/pluggable.php');
$this->db = new EC_DB();
}
/**
* Display the day events for the date $d.
* @param string $d date for which to shw events
*/
function display($d) {
?>
<link type="text/css" rel="stylesheet" href="<?php bloginfo('siteurl');?>/wp-includes/js/thickbox/thickbox.css" />
<link type="text/css" rel="stylesheet" href="<?php echo EVENTSCALENDARCSSURL;?>/events-calendar.css" />
<?php
$options = get_option('optionsEventsCalendar');
$events = $this->db->getDaysEvents($d);
list($ec_year, $ec_month, $ec_day) = explode("-", $d);
?>
<div id="EC_daysEvents">
<?php
foreach($events as $event) {
if(($event->accessLevel == 'public') || (current_user_can($event->accessLevel))) {
$title = stripslashes($event->eventTitle);
$description = preg_replace('#\r?\n#', '<br />', $event->eventDescription);
$description = stripslashes($description);
$location = stripslashes($event->eventLocation);
$PostID = isset($event->postID) ? $event->postID : '';
$linkout = isset($event->eventLinkout) ? $event->eventLinkout : '';
list($ec_startyear, $ec_startmonth, $ec_startday) = explode("-", $event->eventStartDate);
if(!is_null($event->eventStartTime) && !empty($event->eventStartTime)) {
list($ec_starthour, $ec_startminute, $ec_startsecond) = explode(":", $event->eventStartTime);
$startTime = date($options['timeFormatWidget'], mktime($ec_starthour, $ec_startminute, $ec_startsecond, $ec_startmonth, $ec_startday, $ec_startyear));
} else $startTime = null;
$startDate = date($options['dateFormatWidget'], mktime($ec_starthour, $ec_startminute, $ec_startsecond, $ec_startmonth, $ec_startday, $ec_startyear));
list($ec_endyear, $ec_endmonth, $ec_endday) = explode("-", $event->eventEndDate);
if($event->eventEndTime != null && !empty($event->eventEndTime)) {
list($ec_endhour, $ec_endminute, $ec_endsecond) = explode(":", $event->eventEndTime);
$endTime = date($options['timeFormatWidget'], mktime($ec_endhour, $ec_endminute, $ec_endsecond, $ec_endmonth, $ec_endday, $ec_endyear));
} else $endTime = null;
$endDate = date($options['dateFormatWidget'], mktime($ec_endhour, $ec_endminute, $ec_endsecond, $ec_endmonth, $ec_endday, $ec_endyear));
// Title
$output = '<p>'."\n".'<div for="EC_title" class="EC_title"><strong> '.$title.'</strong></div>'."\n";
// If Location
if(!empty($location) && !is_null($location)) $output .= '<div for="EC_location" class="EC_location"><strong> '._c('Location','events-calendar').':</strong> '.$location.'</div>'."\n";
// start time
if(!empty($startTime) && !is_null($startTime))
$output .='<div for="EC_time" class="EC_time"><strong> '.$startTime.'</strong> ';
// end Time
if((!empty($endTime) && !empty($startTime)) || (!is_null($endTime) && !is_null($startTime)))
$output .= _c('to','events-calendar').'<strong> '.$endTime.'</strong>';
// Description
$output .= '</div><div for="EC_description" class="EC_description"> '.$description.'</div>'."\n";
// If Star Date <> End Date
if($event->eventStartDate != $event->eventEndDate )
$output .= '<div for="EC_date" class="EC_date"><strong>'._c('Date range','events-calendar').'</strong></div>'._c('Since','events-calendar').' '.$startDate.' '._c('until','events-calendar').' '.$endDate."\n";
// Link outside the site if the link exist
if ($linkout != '')
$output .= '<div for="EC_linkout" class="EC_linkout_and_postid"><strong>'._c('Link out','events-calendar').'</strong></div><a href="'.$linkout.'" target="_parent">'.substr($linkout,0,37).'</a>';
// Link to a post when exist
if ($PostID != '') {
$IDtmp = get_post($PostID);
$ptitle = $IDtmp->post_title;
$output .= '<div for="EC_postid" class="EC_linkout_and_postid"><strong>'._c('Post','events-calendar').' ('.$PostID.')</strong></div><a href="'.get_permalink($PostID).'" target="_parent"/>'.stripslashes($ptitle).'</a><br />';
}
echo $output;
} // if
} // for each
} // function display
}
endif;
?>