specshaper / calendar-bundle
用于集成FullCalendar jQuery插件的Symfony2工具包。
Requires
- php: >=5.3.9
- eluceo/ical: ^0.9.0
- symfony/framework-bundle: ~2.8|~3.0
This package is auto-updated.
Last update: 2024-09-25 07:35:52 UTC
README
目前该工具包用于在https://www.parolla.ie和https://tools.parolla.ie的支付。
SpecShaperCalendarBundle为Symfony2框架提供了一个日历和预约包,利用fullcalendar jQuery插件。
功能包括
- 针对Symfony版本3.0.x编写
- 日历实体可以通过Doctrine ORM存储。
- 实体是映射的父类,允许你的AppBundle添加额外的关联。
- 生成事件以允许监听器类截获实体。
- FullCalendar jQuery前端可以创建、更新和调整事件。
警告
- 目前只实现了日历和事件。
- 此工具包尚未进行单元测试。
- 它仅在Symfony2 v3.0.1项目上运行,并未进行向后兼容性测试。
功能路线图
- 模态弹出窗口用于创建和修改事件
- 提供颜色选项
- 模态中侧边栏评论摘要
- 主页面中可选的侧边栏月度摘要
- 扩展触发的事件
- 与邮件发送器集成
待完成工作
- 为实体创建管理器。
- 在表单上提供自定义验证器
- 完全注释docBlocks
- 集成注释
- 将添加单元测试
- 需要后端和前端都的翻译文件
- 支持MongoDB/CouchDB ODM或Propel
文档
此工具包中的文档源存储在该工具包的Resources/doc/
文件夹中。
许可证
此工具包受MIT许可证的约束。请参阅工具包中的完整许可证。
Resources/meta/LICENSE
关于
CalendarBundle是SpecShaper用于管理项目预约的工具包。
它基于adesigns/calendar-bundle进行修改和扩展,并添加了额外的功能。
报告问题或功能请求
问题和功能请求在Github问题跟踪器中进行跟踪。
报告错误时,最好在基本项目中重现它,该基本项目使用Symfony标准版构建,以便工具包的开发者可以通过简单地克隆它并遵循一些步骤来重现问题。
安装
步骤1:下载工具包
打开命令控制台,进入你的项目目录,并执行以下命令以下载此工具包的最新稳定版本
$ composer require specshaper/calendar-bundle dev-master
此命令需要你全局安装Composer,如Composer文档中的安装章节中所述。
步骤2:启用工具包
然后,通过将其添加到项目中app/AppKernel.php
文件中注册的工具包列表来启用工具包
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new SpecShaper\CalendarBundle\SpecShaperCalendarBundle(), ); // ... } // ... }
步骤2:创建实体
此工具包需要实体与数据库交互并存储信息。
- 日历
- CalendarEvent
- CalendarReoccurance
- CalendarAttendee
- CalendarComment
Calendar实体
此工具包允许创建多个具有不同属性(如)的日历
- 本地时区
- 所有者
- 其他偏好
实体应扩展映射的基类。您可以根据应用程序的需要提供任何额外的实体代码。
<?php /** * AppBundle\Entity\Calendar.php * * @copyright (c) 2016, SpecShaper - All rights reserved */ namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use AppBundle\Entity\CalendarEvent; use SpecShaper\CalendarBundle\Model\Calendar as BaseCalendar; /** * A calendar entity to house information on the calendar container itself. * * The class extends the model class in the SpecShaperCalendarBundle. See link. * * @link https://github.com/mogilvie/CalendarBundle/blob/master/Model/Calendar.php * @author Mark Ogilvie <mark.ogilvie@specshaper.com> * * @ORM\Table(name="calendar_calendar") * @ORM\Entity */ class Calendar extends BaseCalendar { // Add your own relationships and properties here... /** * The events that belong in this Calendar. * * Required by SpecShaperCalendarBundle. * * @ORM\ManyToMany(targetEntity="CalendarEvent", mappedBy="calendar") */ protected $calendarEvents; /** * Constructor. * * Required by SpecShaperCalendarBundle to call the parent constructor on the * mapped superclass. * * Modify to suit your needs. */ public function __construct() { parent::__construct(); } }
日历事件实体
日历事件实体包含有关特定事件或事件系列的所有信息。例如:
- 事件的时间和持续时间。
- 文本内容
- 任何参与者
- 显示属性
实体应扩展映射的基类。您可以根据应用程序的需要提供任何额外的实体代码。
<?php /** * AppBundle\Entity\CalendarEvent.php * * @author Written by Mark Ogilvie <mark.ogilvie@specshaper.com>, 1 2016 */ namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use AppBundle\Entity\CalendarAttendee; use AppBundle\Entity\CalendarComment; use AppBundle\Entity\Calendar; use Symfony\Component\Validator\Constraints\Valid; use SpecShaper\CalendarBundle\Model\CalendarEvent as BaseEvent; use AppBundle\Entity\CalendarReoccurance; /** * A CalendarEvent is an appointment/meeting etc belonging to a Calendar. * * Be wary of confusion between a CalendarEvent entity and a thown events. * * @link https://github.com/mogilvie/CalendarBundle/blob/master/Model/CalendarComment.php * @author Mark Ogilvie <mark.ogilvie@specshaper.com> * * @ORM\Table(name="calendar_event") * @ORM\Entity */ class CalendarEvent extends BaseEvent { /** * The calendar that this event belongs in. * * Required by SpecShaperCalendarBundle. * * @ORM\ManyToMany(targetEntity="Calendar", inversedBy="calendarEvents") */ protected $calendar; /** * The people invited to this event. * * Required by SpecShaperCalendarBundle. * * @Valid * @ORM\OneToMany(targetEntity="CalendarAttendee", mappedBy="calendarEvent", cascade={"persist", "remove"}) */ protected $calendarAttendees; /** * Comments posted in response to this event. * * Required by SpecShaperCalendarBundle. * * @Valid * @ORM\OneToMany(targetEntity="CalendarComment", mappedBy="calendarEvent", cascade={"persist", "remove"}) */ protected $calendarComments; /** * Comments posted in response to this event. * * Required by SpecShaperCalendarBundle. * * @Valid * @ORM\ManyToOne(targetEntity="CalendarReoccurance", inversedBy="calendarEvent", cascade={"persist", "remove"}) */ protected $calendarReoccurance; /** * Constructor. * * Required by SpecShaperCalendarBundle to call the parent constructor on the * mapped superclass. * * Note that constructor for the arrays defined in this entity are already in the * parent mapped superclass construct and do not need to be created here. * * Modify to suit your needs. */ public function __construct() { parent::__construct(); } // Add your own relationships and properties below here.. }
日历重复事件实体
一个包含一系列日历事件重复信息的实体。
<?php /** * AppBundle\Entity\CalendarEvent.php * * @author Written by Mark Ogilvie <mark.ogilvie@specshaper.com>, 1 2016 */ namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use AppBundle\Entity\CalendarAttendee; use AppBundle\Entity\CalendarComment; use AppBundle\Entity\Calendar; use SpecShaper\CalendarBundle\Model\CalendarReoccurance as BaseReoccurance; /** * * @link https://github.com/mogilvie/CalendarBundle/blob/master/Model/CalendarComment.php * @author Mark Ogilvie <mark.ogilvie@specshaper.com> * * @ORM\Table(name="calendar_reoccurance") * @ORM\Entity */ class CalendarReoccurance extends BaseReoccurance { /** * @ORM\OneToMany(targetEntity="CalendarEvent", mappedBy="calendarReoccurance") */ protected $calendarEvents; /** * Constructor. * * Required by SpecShaperCalendarBundle to call the parent constructor on the * mapped superclass. * * Note that constructor for the arrays defined in this entity are already in the * parent mapped superclass construct and do not need to be created here. * * Modify to suit your needs. */ public function __construct() { parent::__construct(); } // Add your own relationships and properties below here.. }
日历参与者实体
该实体包含有关事件参与者的信息,例如:
- 参与者的电子邮件地址。
- 邀请状态
如果您有用户实体,应将参与者修改为包含对您的用户实体的引用。
实体应扩展映射的基类。您可以根据应用程序的需要提供任何额外的实体代码。
<?php /** * AppBundle\Entity\CalendarAttendee.php * * @author Written by Mark Ogilvie <mark.ogilvie@specshaper.com>, 1 2016 */ namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use AppBundle\Entity\CalendarEvent; use SpecShaper\CalendarBundle\Model\CalendarAttendee as BaseAttendee; /** * A CalendarAttendee is a entity who has been invited to a CalendarEvent. * * The class holds information relating to the status of the invitation. * * @link https://github.com/mogilvie/CalendarBundle/blob/master/Model/CalendarAttendee.php * @author Mark Ogilvie <mark.ogilvie@specshaper.com> * * @ORM\Table(name="calendar_attendee") * @ORM\Entity */ class CalendarAttendee extends BaseAttendee { /** * The calendar that this event belongs in. * * Required by SpecShaperCalendarBundle. * * @ORM\ManyToOne(targetEntity="CalendarEvent", inversedBy="calendarAttendees") */ protected $calendarEvent; // // /** // * Constructor. // * // * Required by SpecShaperCalendarBundle to call the parent constructor on the // * mapped superclass. // * // * Modify to suit your needs. // */ // public function __construct() // { // parent::__construct(); // } // Add your own relationships and properties below here.. }
日历评论实体
该实体包含有关事件的任何评论或消息
- 评论参与者的电子邮件地址。
- 消息
实体应扩展映射的基类。您可以根据应用程序的需要提供任何额外的实体代码。
<?php /** * AppBundle\Entity\CalendarComment.php * * @author Written by Mark Ogilvie <mark.ogilvie@specshaper.com>, 1 2016 */ namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use AppBundle\Entity\CalendarEvent; use SpecShaper\CalendarBundle\Model\CalendarComment as BaseComment; /** * Calendar comments are messages left on the CalendarEvent. * * @link https://github.com/mogilvie/CalendarBundle/blob/master/Model/CalendarComment.php * @author Mark Ogilvie <mark.ogilvie@specshaper.com> * * @ORM\Table(name="calendar_comment") * @ORM\Entity */ class CalendarComment extends BaseComment { /** * The calendar that this event belongs in. * * Required by SpecShaperCalendarBundle. * * @ORM\ManyToOne(targetEntity="CalendarEvent", inversedBy="calendarAttendees") */ protected $calendarEvent; /** * Constructor. * * Required by SpecShaperCalendarBundle to call the parent constructor on the * mapped superclass. * * Modify to suit your needs. */ public function __construct() { parent::__construct(); } // Add your own relationships and properties below here.. }
第3步:创建监听器
在您的应用程序中创建监听器以拦截由包触发的事件并修改/交互这些事件。
CalendarLoadEventsListener
当日历事件首次加载以及用户更改视图日期范围时抛出此事件。
用于查询和装饰要在日历中显示的日历事件。
CalendarNewEventListener
当在日历中创建日历事件时抛出此事件。
用于填充和装饰新的日历事件以定制它以适应您的应用程序。
CalendarRemoveEventListener
当日历事件被删除或移除时抛出此事件。
用于修改或删除日历事件以定制它以适应您的应用程序。
CalendarUpdateEventListener
当日历事件更新时抛出此事件。
用于修改或删除日历事件以定制它以适应您的应用程序。例如
- 发送电子邮件更新参与者。
- 更改关系。
有关可用监听器的更多详细信息,请参阅文档部分
CalendarGetAddressListener
当日历加载时抛出此事件。它允许提供电子邮件地址以供自动完成参与者电子邮件输入。
第4步:配置包
要配置最小设置,您需要定义ORM。目前只支持Doctrine。
然后将包指向您的自定义日历实体。
有关完整选项列表,请参阅完整文档。
// app/config/config.yml # Calendar configuration spec_shaper_calendar: db_driver: orm custom_classes: calendar_class: AppBundle\Entity\Calendar event_class: AppBundle\Entity\CalendarEvent attendee_class: AppBundle\Entity\CalendarAttendee comment_class: AppBundle\Entity\CalendarComment reoccurance_class: AppBundle\Entity\CalendarReoccurance
如果您尚未配置,您还需要启用翻译
// app/config/config.yml framework: translator: { fallbacks: ["%locale%"] }
第5步:定义路由
定义任何您喜欢的路由。可以通过定义一个由您的安全防火墙保护的前缀来将控制器放置在防火墙后面。
// app/config/routing.yml spec_shaper_calendar: resource: "@SpecShaperCalendarBundle/Resources/config/routing.yml" prefix: /
第6步:集成到您的twig模板之一
此包需要
- Jquery
- Moment
- Bootstrap
- DatePicker
- FullCalendar
通过包含twig模板生成到CSS和JS文件的链接。
一个典型的扩展包基本.html.twig的twig模板。
{# app/Resources/views/calendar/calendar.html.twig #} {% extends 'base.html.twig' %} {% block stylesheets %} {% include 'SpecShaperCalendarBundle:Calendar:styles.html.twig' %} <style> #calendar-holder{ width: 50%; height: 200px; } </style> {% endblock %} {% block body %} {% include 'SpecShaperCalendarBundle:Calendar:calendar.html.twig' %} {% endblock %} {% block javascripts %} {% include 'SpecShaperCalendarBundle:Calendar:javascript.html.twig' %} <script> Calendar.init({ loader: "{{ url('calendar_loader') }}", new: "{{url('event_new')}}", update: "{{ url('event_update', {'id' : 'PLACEHOLDER'} ) }}", updateDateTime: "{{ url('event_updatedatetime', {'id' : 'PLACEHOLDER'} ) }}", delete: "{{ url('event_delete', {'id' : 'PLACEHOLDER'} ) }}", deleteSeries: "{{ url('event_deleteseries', {'id' : 'PLACEHOLDER'} ) }}", }); </script> {% endblock %}
第7步:定制
使用实体来定制持久信息,并将日历与您的应用程序实体集成。
通过路由防火墙应用安全,或者为了更细粒度的安全控制,请使用事件监听器来管理访问。
在您的应用\Resources\SpecShaperCalendarBundle目录中覆盖twig模态和日历模板以更改模态显示。
复制并修改fullcalendar-settings.js文件以提供自定义javascript功能。或者简单地扩展您的twig模板javascript块。