-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calendar.php
76 lines (66 loc) · 2.08 KB
/
Calendar.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
<?php
namespace goryachev\yii2fullcalendar;
/**
* Fullcalendar plugin wrapper.
*
* @category widgets
* @package yii2fullcalendar
*
* @version 1.1.0
*
* @access public
*
* @author Alexander Goryachev <[email protected]>
* @copyright (c) 2014, Alexander Goryachev <[email protected]>
* @license http://opensource.org/licenses/BSD-3-Clause
* @link http://www.a-goryachev.ru
* @link https://github.com/a-goryachev
*
*/
class Calendar extends \yii\base\Widget{
/**
* Fullcalendar plugin options.
* @link http://fullcalendar.io/docs/
*
* All callback options (for example: 'viewRenderer', 'eventClick', etc)
* must be an \yii\web\JsExpression object or null.
*
* @var array
*/
public $pluginOptions=[];
public $htmlOptions=[];
/**
* Enable google calendar support.
*
* For using google calendar, set plugin options like below:
* <code>
* $pluginOptions['googleCalendarApiKey']=<YOUR API KEY>;
*
* $pluginOptions['events']['googleCalendarId']=<YOUR GOOGLE CALENDAR ID>
* </code>
*
* For more information, read fullcalendar documentation
* @link http://fullcalendar.io/docs/google_calendar/ Google calendar
* @since 1.1.0
* @var boolean
*/
public $googleCalendar=false;
public function run(){
/* check id */
if(!isset($this->htmlOptions['id'])){
$this->htmlOptions['id']=$this->getId();
}
/* check language */
if(!isset($pluginOptions['lang'])){
$this->pluginOptions['lang']=\Yii::$app->language;
}
FullcalendarAsset::register($this->getView());
/* google calendar */
if($this->googleCalendar===true){
GooglecalendarAsset::register($this->getView());
}
$pluginOptions=\yii\helpers\Json::encode($this->pluginOptions);
$this->getView()->registerJs('jQuery("#'.$this->getId().'").fullCalendar('.$pluginOptions.');');
return \yii\helpers\Html::tag('div', '', $this->htmlOptions);
}
}