Skip to content

Commit

Permalink
Added google calendar support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Goryachev committed Dec 10, 2014
1 parent 19196a7 commit fc54613
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @category widgets
* @package yii2fullcalendar
*
* @version 1.0.0
* @version 1.1.0
*
* @access public
*
Expand All @@ -34,6 +34,23 @@ class Calendar extends \yii\base\Widget{

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
*
* @var boolean
*/
public $googleCalendar=false;

public function run(){
/* check id */
if(!isset($this->htmlOptions['id'])){
Expand All @@ -44,7 +61,13 @@ public function run(){
$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);
Expand Down
34 changes: 34 additions & 0 deletions GooglecalendarAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace goryachev\yii2fullcalendar;

/**
* Assets for Google calendar.
*
* @category assets
* @package yii2fullcalendar
*
* @version 1.0.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 GooglecalendarAsset extends \yii\web\AssetBundle {

public $sourcePath = '@vendor/bower/fullcalendar/dist';
public $js = [
'gcal.js'
];

public $depends = [
'yii\web\JqueryAsset',
'goryachev\yii2fullcalendar\FullcalendarAsset'
];

}

0 comments on commit fc54613

Please sign in to comment.