MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mfullcalendar.class
Ir para a documentação deste ficheiro.
1
<?php
39
class
MFullCalendar
extends
MDiv
40
{
41
private
$events;
42
private
$editable =
true
;
43
private
$dayClick;
44
private
$maxTime;
45
private
$minTime;
46
private
$hiddenDays;
47
private
$eventDrop;
48
private
$allDaySlot;
49
private
$eventResize;
50
private
$dayrender;
51
private
$externalDrop;
52
private
$defaultView;
53
60
private
$currentDate;
61
65
public
function
__construct
(
$name
)
66
{
67
parent::__construct(
$name
);
68
69
$this->page->addScript(
'jquery/jquery-ui.custom.min.js'
);
70
$this->page->addScript(
'fullcalendar/fullcalendar.min.js'
);
71
$this->page->addScript(
'fullcalendar/fullcalendar.js'
);
72
$this->page->addStyle(
'fullcalendar.css'
);
73
}
74
75
public
function
addEvent
($description, $start, $end =
null
,
$url
=
null
, $editable =
false
, $allDay =
false
, $durationEditable =
false
, $color =
'blue'
,
$id
=
null
, $pk =
null
)
76
{
77
$std =
new
stdClass();
78
79
$std->start = $start;
80
$std->end = $end;
81
$std->description = $description;
82
$std->url =
$url
;
83
$std->id =
$id
;
84
$std->editable = $editable;
85
$std->color = $color;
86
$std->allDay = $allDay;
87
$std->durationEditable = $durationEditable;
88
$std->pk = $pk;
89
$this->events[] = $std;
90
}
91
92
public
function
getCurrentDate
()
93
{
94
return
$this->currentDate;
95
}
96
97
public
function
setCurrentDate
($currentDate)
98
{
99
$this->currentDate = $currentDate;
100
}
101
105
protected
function
getCurrentDateJs
()
106
{
107
$js =
''
;
108
109
if
( strlen($this->currentDate) > 0 )
110
{
111
list($day, $month, $year) = explode(
'/'
, $this->currentDate);
112
113
$month = ($month - 1);
// Aparentemente precisa ser assim para o fullCalendar deixar o mes correto
114
115
$js =
"
116
year: {$year},
117
month: {$month},
118
date: {$day},"
;
119
}
120
121
return
$js;
122
}
123
124
protected
function
removeEvent
(
$id
)
125
{
126
$this->events[
$id
] =
null
;
127
}
128
129
public
function
getEvents
()
130
{
131
return
$this->events;
132
}
133
134
public
function
setEditable
($editable)
135
{
136
$this->editable = $editable;
137
}
138
139
public
function
setAjaxDayClick
($event, $responseElement, $validate =
true
, $args =
null
, $encodeValues =
true
)
140
{
141
$this->dayClick[
'event'
] = $event;
142
$this->dayClick[
'responseElement'
] = $responseElement;
143
$this->dayClick[
'validate'
] = $validate;
144
$this->dayClick[
'args'
] = $args;
145
$this->dayClick[
'encodeValues'
] = $encodeValues;
146
}
147
148
public
function
setAjaxEventDrop
($event, $responseElement, $validate =
true
, $args =
null
, $encodeValues =
true
)
149
{
150
$this->eventDrop[
'event'
] = $event;
151
$this->eventDrop[
'responseElement'
] = $responseElement;
152
$this->eventDrop[
'validate'
] = $validate;
153
$this->eventDrop[
'args'
] = $args;
154
$this->eventDrop[
'encodeValues'
] = $encodeValues;
155
}
156
157
public
function
setAjaxExternalDrop
($event, $responseElement, $validate =
true
, $args =
null
, $encodeValues =
true
)
158
{
159
$this->externalDrop[
'event'
] = $event;
160
$this->externalDrop[
'responseElement'
] = $responseElement;
161
$this->externalDrop[
'validate'
] = $validate;
162
$this->externalDrop[
'args'
] = $args;
163
$this->externalDrop[
'encodeValues'
] = $encodeValues;
164
}
165
166
public
function
setAjaxEventResize
($event, $responseElement, $validate =
true
, $args =
null
, $encodeValues =
true
)
167
{
168
$this->eventResize[
'event'
] = $event;
169
$this->eventResize[
'responseElement'
] = $responseElement;
170
$this->eventResize[
'validate'
] = $validate;
171
$this->eventResize[
'args'
] = $args;
172
$this->eventResize[
'encodeValues'
] = $encodeValues;
173
}
174
175
public
function
setMaxTime
($maxTime)
176
{
177
$this->maxTime = $maxTime;
178
}
179
180
public
function
setMinTime
($minTime)
181
{
182
$this->minTime = $minTime;
183
}
184
185
public
function
setHiddenDays
(array $days)
186
{
187
$this->hiddenDays = $days;
188
}
189
190
public
function
setAllDaySlot
($allDaySlot)
191
{
192
if
( $allDaySlot )
193
{
194
$this->allDaySlot =
'true'
;
195
}
196
else
197
{
198
$this->allDaySlot =
'false'
;
199
}
200
}
201
202
public
function
setDayRender
($date,
$style
, $value)
203
{
204
$this->dayrender[][$date] = array(
$style
=> $value);
205
}
206
207
public
function
setDefaultView
($defaultView)
208
{
209
$this->defaultView = $defaultView;
210
}
211
212
//
216
public
function
generate
()
217
{
218
$js =
"$(document).ready(function() {
219
220
$('#m_external-events div.external-event').each(function() {
221
222
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
223
// it doesn't need to have a start or end
224
var eventObject = {
225
title: $.trim($(this).text()) // use the element's text as the event title
226
};
227
228
// store the Event Object in the DOM element so we can get to it later
229
$(this).data('eventObject', eventObject);
230
231
// make the event draggable using jQuery UI
232
$(this).draggable({
233
zIndex: 999,
234
revert: true, // will cause the event to go back to its
235
revertDuration: 0 // original position after the drag
236
});
237
238
});
239
240
var date = new Date();
241
var d = date.getDate();
242
var m = date.getMonth();
243
var y = date.getFullYear();
244
245
$('#calendar').fullCalendar({
246
247
header: {
248
left: 'prev,next today',
249
center: 'title',
250
right: 'month,agendaWeek,agendaDay'
251
},
252
"
. $this->
getCurrentDateJs
() .
"
253
editable: true,
254
droppable: true,
255
viewDisplay: function(view) { document.cookie='fullcalendar_defaultView='+$('#calendar').fullCalendar('getView').name; },
256
timeFormat: 'H:mm',"
;
257
258
if
( strlen($this->maxTime) > 0 )
259
{
260
$js .=
"maxTime: '$this->maxTime',"
;
261
262
}
263
if
( strlen($this->defaultView) > 0 )
264
{
265
$js .=
"defaultView: '$this->defaultView',"
;
266
}
267
else
268
{
269
$cookieview = $_COOKIE[
'fullcalendar_defaultView'
];
270
if
( strlen($cookieview) > 0 )
271
{
272
$js .=
"defaultView: '$cookieview',"
;
273
}
274
}
275
if
( strlen($this->allDaySlot) > 0 )
276
{
277
$js .=
"allDaySlot: $this->allDaySlot,"
;
278
}
279
if
( strlen($this->minTime) > 0 )
280
{
281
$js .=
"minTime: '$this->minTime',"
;
282
}
283
if
( count($this->hiddenDays) > 0 )
284
{
285
$hiddenDays = implode(
','
, $this->hiddenDays);
286
287
$js .=
"hiddenDays: [{$hiddenDays}],"
;
288
}
289
290
if
( is_array($this->dayClick) )
291
{
292
$js .= $this->
getDayClick
();
293
}
294
295
if
( is_array($this->externalDrop) )
296
{
297
$js .= $this->
getExternalDrop
();
298
}
299
300
if
( is_array($this->eventDrop) )
301
{
302
$js .= $this->
getEventDrop
();
303
}
304
305
if
(is_array($this->eventResize) )
306
{
307
$js .= $this->
getEventResize
();
308
}
309
310
if
( count( $this->events ) > 0 )
311
{
312
$js .=
' events: ['
;
313
foreach
( $this->events as $cod=>$event )
314
{
315
//editable: bloqueia a movimentação, edição somente no popup
316
$js .=
"{ editable: '"
.$event->editable.
"', title: '"
.addslashes($event->description).
"', start: '"
.$event->start.
"', color: '"
.$event->color.
"', allDay: '"
.$event->allDay.
"', durationEditable: '"
.$event->durationEditable.
"',"
;
317
if
( strlen($event->url) > 0 )
318
{
319
$js .=
'url: "'
.$event->url.
'",'
;
320
}
321
if
( strlen($event->end) > 0 )
322
{
323
$js .=
'end: "'
.$event->end.
'",'
;
324
}
325
if
( strlen($event->id) > 0 )
326
{
327
$js .=
'id: "'
.$event->id.
'",'
;
328
}
329
if
( strlen($event->pk) > 0 )
330
{
331
$js .=
'pk: "'
.$event->pk.
'",'
;
332
}
333
$js .=
"},"
;
334
}
335
$js .=
"],"
;
336
}
337
338
$js .=
"}); });"
;
339
340
if
( strpos(
MIOLO::getInstance
()->getTheme()->
id
,
"sbootstrap"
) ===
false
)
341
{
342
$this->page->AddStyleCode(
'
343
body {
344
margin-top: 40px;
345
text-align: center;
346
font-size: 14px;
347
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
348
}
349
350
#calendar {
351
width: 600px;
352
margin: 0 auto;
353
}
354
'
);
355
}
356
357
$this->page->addJsCode($js);
358
359
return
parent::generate();
360
}
361
366
protected
function
getDayClick
()
367
{
368
$otherArgs =
""
;
369
$js .=
" dayClick: function(date, allDay, jsEvent, view) { "
;
370
$js .=
"saguDoAjax('"
. $this->dayClick[
'event'
] .
"','"
. $this->dayClick[
'responseElement'
] .
"','"
. ($this->dayClick[
'validate'
] ?
'true'
:
'false'
) .
"',"
;
371
372
if
( count($this->dayClick[
'args'
]) > 0 )
373
{
374
foreach
( $this->dayClick[
'args'
] as $key => $val )
375
{
376
$value =
''
;
377
$value .= $val;
378
$otherArgs .=
'&'
. $key .
'='
. ($this->dayClick[
'encodeValues'
] ? urlencode($value) : $value);
379
}
380
}
381
$js .= $otherArgs.
"'&date='+$.fullCalendar.formatDate(date, 'dd/MM/yyyy')+'&time='+$.fullCalendar.formatDate(date, 'HH:mm')+'&allDay='+allDay+'&jsEvent='+jsEvent+'&view='+view.name);"
;
382
$js .=
"return false;"
;
383
$js .=
" },"
;
384
385
return
$js;
386
}
387
388
protected
function
getExternalDrop
()
389
{
390
$otherArgs =
""
;
391
$js .=
" drop: function(date, allDay, jsEvent, ui) {"
;
392
$js .=
"saguDoAjax('"
. $this->externalDrop[
'event'
] .
"','"
. $this->externalDrop[
'responseElement'
] .
"','"
. ($this->externalDrop[
'validate'
] ?
'true'
:
'false'
) .
"',"
;
393
394
if
( count($this->externalDrop[
'args'
]) > 0 )
395
{
396
foreach
( $this->externalDrop[
'args'
] as $key => $val )
397
{
398
$value =
''
;
399
$value .= $val;
400
$otherArgs .=
"'&"
. $key .
"'="
. ($this->externalDrop[
'encodeValues'
] ? urlencode($value) : $value);
401
}
402
}
403
$js .= $otherArgs.
"'&date='+$.fullCalendar.formatDate(date, 'dd/MM/yyyy')+'&time='+$.fullCalendar.formatDate(date, 'HH:mm')+'&event.allDay='+allDay+'&ofertacomponentecurricularid='+this.id+'&view='+$('#calendar').fullCalendar('getView').name);"
;
404
$js .=
"return true;"
;
405
$js .=
" },"
;
406
407
return
$js;
408
}
409
410
protected
function
getEventDrop
()
411
{
412
$otherArgs =
""
;
413
$js .=
" eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {"
;
414
$js .=
"saguDoAjax('"
. $this->eventDrop[
'event'
] .
"','"
. $this->eventDrop[
'responseElement'
] .
"','"
. ($this->eventDrop[
'validate'
] ?
'true'
:
'false'
) .
"',"
;
415
416
if
( count($this->eventDrop[
'args'
]) > 0 )
417
{
418
foreach
( $this->eventDrop[
'args'
] as $key => $val )
419
{
420
$value =
''
;
421
$value .= $val;
422
$otherArgs .=
"'&"
. $key .
"'="
. ($this->eventDrop[
'encodeValues'
] ? urlencode($value) : $value);
423
}
424
}
425
$js .= $otherArgs.
"'&date='+$.fullCalendar.formatDate(event.start, 'dd/MM/yyyy')+'&time='+$.fullCalendar.formatDate(event.start, 'HH:mm')+'&event.allDay='+allDay+'&id='+event.id+'&pk='+event.pk+'&view='+view.name);"
;
426
$js .=
"return true;"
;
427
$js .=
" },"
;
428
429
return
$js;
430
}
431
432
protected
function
getEventResize
()
433
{
434
$otherArgs =
""
;
435
$js .=
" eventResize: function( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) {"
;
436
$js .=
"saguDoAjax('"
. $this->eventResize[
'event'
] .
"','"
. $this->eventResize[
'responseElement'
] .
"','"
. ($this->eventResize[
'validate'
] ?
'true'
:
'false'
) .
"',"
;
437
438
if
( count($this->eventResize[
'args'
]) > 0 )
439
{
440
foreach
( $this->eventResize[
'args'
] as $key => $val )
441
{
442
$value =
''
;
443
$value .= $val;
444
$otherArgs .=
"'&"
. $key .
"'="
. ($this->eventResize[
'encodeValues'
] ? urlencode($value) : $value);
445
}
446
}
447
$js .= $otherArgs.
"'&dateStart='+$.fullCalendar.formatDate(event.start, 'dd/MM/yyyy')+'&dateEnd='+$.fullCalendar.formatDate(event.end, 'dd/MM/yyyy')+'&timeStart='+$.fullCalendar.formatDate(event.start, 'HH:mm')+'&timeEnd='+$.fullCalendar.formatDate(event.end, 'HH:mm')+'&id='+event.id+'&pk='+event.pk+'&view='+view.name);"
;
448
$js .=
"return true;"
;
449
$js .=
" },"
;
450
451
return
$js;
452
}
453
}
454
?>
MComponent\$name
$name
Definição
mcomponent.class:17
MControl\$style
$style
Definição
mcontrol.class:90
MControl\$id
$id
Definição
mcontrol.class:69
MDiv
Definição
blockcontrols.class:23
MFullCalendar
Definição
mfullcalendar.class:40
MFullCalendar\setDefaultView
setDefaultView($defaultView)
Definição
mfullcalendar.class:207
MFullCalendar\removeEvent
removeEvent($id)
Definição
mfullcalendar.class:124
MFullCalendar\setMinTime
setMinTime($minTime)
Definição
mfullcalendar.class:180
MFullCalendar\getExternalDrop
getExternalDrop()
Definição
mfullcalendar.class:388
MFullCalendar\setAllDaySlot
setAllDaySlot($allDaySlot)
Definição
mfullcalendar.class:190
MFullCalendar\setAjaxDayClick
setAjaxDayClick($event, $responseElement, $validate=true, $args=null, $encodeValues=true)
Definição
mfullcalendar.class:139
MFullCalendar\setAjaxEventResize
setAjaxEventResize($event, $responseElement, $validate=true, $args=null, $encodeValues=true)
Definição
mfullcalendar.class:166
MFullCalendar\getDayClick
getDayClick()
Definição
mfullcalendar.class:366
MFullCalendar\__construct
__construct($name)
Definição
mfullcalendar.class:65
MFullCalendar\setAjaxExternalDrop
setAjaxExternalDrop($event, $responseElement, $validate=true, $args=null, $encodeValues=true)
Definição
mfullcalendar.class:157
MFullCalendar\getEvents
getEvents()
Definição
mfullcalendar.class:129
MFullCalendar\getCurrentDateJs
getCurrentDateJs()
Definição
mfullcalendar.class:105
MFullCalendar\getEventResize
getEventResize()
Definição
mfullcalendar.class:432
MFullCalendar\setHiddenDays
setHiddenDays(array $days)
Definição
mfullcalendar.class:185
MFullCalendar\setCurrentDate
setCurrentDate($currentDate)
Definição
mfullcalendar.class:97
MFullCalendar\generate
generate()
Definição
mfullcalendar.class:216
MFullCalendar\setDayRender
setDayRender($date, $style, $value)
Definição
mfullcalendar.class:202
MFullCalendar\addEvent
addEvent($description, $start, $end=null, $url=null, $editable=false, $allDay=false, $durationEditable=false, $color='blue', $id=null, $pk=null)
Definição
mfullcalendar.class:75
MFullCalendar\setAjaxEventDrop
setAjaxEventDrop($event, $responseElement, $validate=true, $args=null, $encodeValues=true)
Definição
mfullcalendar.class:148
MFullCalendar\setMaxTime
setMaxTime($maxTime)
Definição
mfullcalendar.class:175
MFullCalendar\setEditable
setEditable($editable)
Definição
mfullcalendar.class:134
MFullCalendar\getCurrentDate
getCurrentDate()
Definição
mfullcalendar.class:92
MFullCalendar\getEventDrop
getEventDrop()
Definição
mfullcalendar.class:410
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
$url
$url
Definição
base.php:2
classes
ui
controls
mfullcalendar.class
Gerado por
1.10.0