This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec_managementjs.class.php
226 lines (214 loc) · 7.46 KB
/
ec_managementjs.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
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
<?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]>, Ugoku <[email protected]>
*
* @copyright Copyright (c) 2007-2009 Luke Howell, 2013 Ugoku
*
* @license GPLv3 {@link http://www.gnu.org/licenses/gpl}
* @filesource
*/
/*
--------------------------------------------------------------------------
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_ManagementJS'))
{
require_once (EVENTSCALENDARCLASSPATH.'/ec_db.class.php');
/**
* Dashboard calendar management content.
*
* @package WP-Events-Calendar
*/
class EC_ManagementJS
{
var $db;
function __construct()
{
$this->db = new EC_DB();
}
/**
* Outputs the data for each day that has an event.
*
* The class provides the data and JS necessary to produce
* tooltips and data management such as deletes and edits.
*
* @param int $m month
* @param int $y year
*/
function calendarData($m, $y)
{
$options = get_option('optionsEventsCalendar');
$lastDay = date('t', mktime(0, 0, 0, $m, 1, $y));
for ($d = 1; $d <= $lastDay; $d++)
{
$sqldate = date('Y-m-d', mktime(0, 0, 0, $m, $d, $y));
foreach ($this->db->getDaysEvents($sqldate) as $e)
{
$output = '';
$id = $d . '-' . $e->id;
$title = $e->eventTitle;
$description = preg_replace('#\r?\n#', '<br>', $e->eventDescription);
$location = isset ($e->eventLocation) ? $e->eventLocation : '';
$linkout = isset ($e->eventLinkout) ? $e->eventLinkout : '';
$startDate = $e->eventStartDate;
$endDate = $e->eventEndDate;
$startTime = isset ($e->eventStartTime) ? $e->eventStartTime : '';
$endTime = isset ($e->eventEndTime) ? $e->eventEndTime : '';
$accessLevel = $e->accessLevel;
$PostID = isset ($e->postID) ? $e->postID : '';
$output .= '<p class="ec-mgmt-ttip">' . _x('Title','events-calendar') . ': ' . $title . '</p>';
$output .= '<p class="ec-mgmt-ttip">' . _x('Location','events-calendar') . ': ' . $location . '</p>';
$output .= '<p class="ec-mgmt-ttip">' . _x('Description','events-calendar') . ': ' . $description . '</p>';
$output .= '<p class="ec-mgmt-ttip">' . _x('Start Date','events-calendar') . ': ' . $startDate . '</p>';
$output .= '<p class="ec-mgmt-ttip">' . _x('Start Time','events-calendar') . ': ' . $startTime . '</p>';
$output .= '<p class="ec-mgmt-ttip">' . _x('End Date','events-calendar') . ': ' . $endDate . '</p>';
$output .= '<p class="ec-mgmt-ttip">' . _x('End Time','events-calendar') . ': ' . $endTime . '</p>';
$output .= '<p class="ec-mgmt-ttip">' . _x('Visibility','events-calendar') . ': ' . $accessLevel . '</p>';
$asslink = '';
if ($linkout !== '')
{
$output .= '<p class="ec-mgmt-ttip">' . _x('Link out','events-calendar') . " :" . $linkout . '</p>';
$asslink = '<img id=\"events-calendar-link-' . $d . '-' . $e->id . '\" src=\"' . EVENTSCALENDARIMAGESURL . '/link.png\" style=\"width:10px;height:10px;\" title=\"' . __("Associated link","events-calendar") . '\"> ';
}
$asspost = '';
if ($PostID > 0)
{
$ptitle = get_the_title ($PostID);
$output .= '<p class="ec-mgmt-ttip">'._x('Post','events-calendar')." ($PostID) : $ptitle.</p>";
$asspost = '<img id=\"events-calendar-post-' . $d . '-' . $e->id . '\" src=\"' . EVENTSCALENDARIMAGESURL . '/post.gif\" style=\"width:10px;height:10px;\" title=\"' . __("Associated post","events-calendar") . '\"> ';
}
if ($output !== '')
{
// make sure we don't double escape
if (preg_match("/\'|\"/", $output))
$output = stripslashes($output);
?>
<script>
(function($) {
$('#events-calendar-<?php echo $d;?>').append("<div id=\"events-calendar-container-<?php echo $id;?>\"><?php echo $asslink, $asspost;?><span id=\"events-calendar-<?php echo $id;?>\"><?php echo $title;?> </span><span class=\"link_delete\" id=\"events-calendar-delete-<?php echo $id;?>\" title=\"<?php _e('Delete','events-calendar');?>\">✗</span><\div>");
$('#events-calendar-<?php echo $id;?>')
.attr('title', '<?php echo addslashes($output);?>')
.click(function() {
top.location = "?page=events-calendar&EC_action=edit&EC_id=<?php echo $e->id;?>";
})
.tooltip({
delay:0,
track:true
});
$('#events-calendar-link-<?php echo $id;?>')
.mouseover(function() {
$(this).css('cursor', 'pointer');
})
.click(function() {
window.open('<?php echo $linkout;?>');
});
$('#events-calendar-post-<?php echo $id;?>')
.mouseover(function() {
$(this).css('cursor', 'pointer');
})
.click(function() {
window.open('<?php echo get_permalink($PostID);?>');
});
$('#events-calendar-delete-<?php echo $id;?>')
.mouseover(function() {
$(this).css('cursor', 'pointer');
})
.click(function() {
doDelete = confirm("<?php _e('Are you sure you want to delete the following event:\n','events-calendar');echo $e->eventTitle;?>");
if (doDelete) {
$.get("<?php bloginfo('siteurl');?>/wp-admin/admin.php?page=events-calendar",
{EC_action: "ajaxDelete", EC_id: <?php echo $e->id;?>},
function(data) {
for(d = 1; d <= <?php echo $lastDay;?>; d++) {
$('#events-calendar-container-' + d + '-<?php echo $e->id;?>')
.css('background', 'red')
.fadeOut(1000);
}
}
);
}
});
})(jQuery);
</script>
<?php
}
}
}
$this->calendarjs();
}
/**
* provides the javascript for the date and time pickers.
*/
function calendarjs()
{
global $loc_lang;
$options = get_option('optionsEventsCalendar');
if (false === stripos($options['timeFormatWidget'], 'a'))
$military = 'true';
else
$military = 'false';
?><?php /*
<script>
//jQuery.noConflict();
(function($) {
$("#EC_startDate").datepicker($.extend({},
$.datepicker.regional["<?php echo $loc_lang; ?>"], {
showOn: "button",
showStatus: true,
buttonImage: "<?php echo EVENTSCALENDARIMAGESURL."/calendar.gif";?>",
buttonImageOnly: true,
dateFormat: 'yy-mm-dd',
firstDay: <?php echo get_option('start_of_week');?>
}
));
$("#EC_endDate").datepicker($.extend({},
$.datepicker.regional["<?php echo $loc_lang; ?>"], {
showOn: "button",
showStatus: true,
buttonImage: "<?php echo EVENTSCALENDARIMAGESURL."/calendar.gif";?>",
buttonImageOnly: true,
dateFormat: 'yy-mm-dd',
firstDay: <?php echo get_option('start_of_week');?>
}
));
$("#EC_start_clockpick").clockpick({
military: <?php echo $military; ?>,
useBgiframe: true,
valuefield: 'EC_startTime',
starthour: '0',
endhour: '23',
layout: 'horizontal'
});
$("#EC_end_clockpick").clockpick({
military: <?php echo $military; ?>,
useBgiframe: true,
valuefield: 'EC_endTime',
starthour: '0',
endhour: '23',
layout: 'horizontal'
});
})(jQuery);
</script>*/?>
<?php
}
}
}
?>