ricgrangeia / yii2-fullcalendar
Yii2的fullcalendar小部件
v2.0.0
2023-04-21 10:18 UTC
Requires
- php: >=8.0
- yiisoft/yii2: >=2.0.9
- yiisoft/yii2-jui: >=2.0.6
Requires (Dev)
- roave/security-advisories: dev-latest
README
安装
安装此扩展的首选方式是通过 composer。
要安装,请运行
$ php composer.phar require ricgrangeia/yii2-fullcalendar
或添加
"ricgrangeia/yii2-fullcalendar": "*"
主要功能和变更
功能
- Yii2框架扩展 Yii2
- PHP 8.0 兼容
- 在日历中显示事件 Fullcalendar.io
- 通过拖放或点击日历手动添加事件
- 具有翻译(不完整)
变更
- v1.4.0 - 稳定,但组织不力
事件可以通过三种方式添加,PHP数组、JavaScript数组或JSON源
可拖拽事件的日历视图
PHP头部
use ricgrangeia\fullcalendar\Domain\Entity\Event; use ricgrangeia\fullcalendar\UI\Widget\Fullcalendar; use ricgrangeia\fullcalendar\UI\Widget\DraggableEvents;
HTML主体
<!-- Main content --> <section class="content"> <div class="container-fluid"> <div class="row"> <div class="col-md-3"> <div class="sticky-top mb-3"> <?= DraggableEvents::widget() ?> </div> </div> <!-- /.col --> <div class="col-md-9"> <div class="card card-primary"> <div class="card-body p-0"> <!-- THE CALENDAR --> <div id="calendar"></div> </div> <!-- /.card-body --> </div> <!-- /.card --> </div> <!-- /.col --> </div> <!-- /.row --> </div><!-- /.container-fluid --> </section> <!-- /.content -->
PHP
<?php $events = [ new Event([ 'title' => 'Appointment #' . rand(1, 999), 'start' => '2016-03-18T14:00:00', ]), // Everything editable new Event([ 'id' => uniqid(), 'title' => 'Appointment #' . rand(1, 999), 'start' => '2016-03-17T12:30:00', 'end' => '2016-03-17T13:30:00', 'editable' => true, 'startEditable' => true, 'durationEditable' => true, ]), // No overlap new Event([ 'id' => uniqid(), 'title' => 'Appointment #' . rand(1, 999), 'start' => '2016-03-17T15:30:00', 'end' => '2016-03-17T19:30:00', 'overlap' => false, // Overlap is default true 'editable' => true, 'startEditable' => true, 'durationEditable' => true, ]), // Only duration editable new Event([ 'id' => uniqid(), 'title' => 'Appointment #' . rand(1, 999), 'start' => '2016-03-16T11:00:00', 'end' => '2016-03-16T11:30:00', 'startEditable' => false, 'durationEditable' => true, ]), // Only start editable new Event([ 'id' => uniqid(), 'title' => 'Appointment #' . rand(1, 999), 'start' => '2016-03-15T14:00:00', 'end' => '2016-03-15T15:30:00', 'startEditable' => true, 'durationEditable' => false, ]), ]; ?> <?= Fullcalendar::widget([ 'options' => [ // id of the div that will be replaced with the calendar 'id' => 'calendar', 'language' => 'pt-pt', // Set Monday first day of the week, default is Sunday. 'firstDay' => Fullcalendar::MONDAY_FIRST, ], 'events' => $events, ]); ?>