bnomei/kirby3-ics

生成 ICS 文件

1.0.7 2023-08-02 10:29 UTC

This package is auto-updated.

Last update: 2024-09-10 10:24:30 UTC


README

Release Downloads Build Status Coverage Status Maintainability Twitter

生成 ICS 文件。

商业用途


支持开源!

此插件免费,但如果您在商业项目中使用它,请考虑赞助我或捐款。
如果我的工作帮助您赚了钱,那么我得到一点回报似乎是公平的,对吧?

请善良。分享一点。谢谢。

—— Bruno
 

安装

  • 解压 master.zip 到文件夹 site/plugins/kirby3-ics
  • git submodule add https://github.com/bnomei/kirby3-ics.git site/plugins/kirby3-ics
  • composer require bnomei/kirby3-ics

用例

纯 PHP

// automatic id
$ics = new \Bnomei\ICS();
$id = $ics->id();

// or use custom id
$id = sha1('myUniqueID');

// provide custom options
$ics = new \Bnomei\ICS([
    Vcalendar::UNIQUE_ID => $id,
]);

// maybe reuse a static object identified by id
// otherwise it will be created now
$ics = \Bnomei\ICS::createOrLoad($id);

// get Vcalendar object...
$vcalendar = $ics->vcalendar();
// ... apply your ics data (see docs of lib)
// then retrieve the ics string
echo $ics;

页面方法

使用 ics()->vcalendar() 方法检索 Vcalender 对象,然后添加属性、事件和闹钟。请阅读 所使用库的原版文档 以了解可能的概述。

site/templates/default.php

$vcalendar = $page->ics()->vcalendar();

$vcalendar->setXprop(Vcalendar::X_WR_CALDESC, "This is a demo calendar");

$event1 = $vcalendar->newVevent()
    ->setTransp( Vcalendar::OPAQUE )
    ->setClass( Vcalendar::P_BLIC )
    ->setSequence( 1 )
    // describe the event
    ->setSummary( 'Scheduled meeting with five occurrences' )
    ->setDescription(
         'Agenda for the the meeting...',
         [ Vcalendar::ALTREP => 
             'CID:<FFFF__=0ABBE548DFE235B58f9e8a93d@coffeebean.com>' ]
    )
    ->setComment( 'It\'s going to be fun..' )
    // place the event
    ->setLocation( 'Kafé Ekorren Stockholm' )
    ->setGeo( '59.32206', '18.12485' )
    // set the time
    ->setDtstart(
        new DateTime(
            '20190421T090000',
            new DateTimezone( 'Europe/Stockholm' )
        )
    )
    ->setDtend(
        new DateTime(
            '20190421T100000',
            new DateTimezone( 'Europe/Stockholm' )
        )
    );

echo $page->ics();

提示:您可以使用页面方法 $page->ics() 获取页面的静态唯一对象。这使得在 页面模型页面控制器 中准备 ICS 成为可能,并在模板或 内容表示 中显示数据。查看 示例测试

内容表示

假设您在模型或控制器中准备了您的 ics 数据,您的内容表示可以像以下示例一样简短。

site/templates/default.ics.php

$page->ics()->download(
    $page->slug() . '.ics'
);

依赖项

免责声明

此插件提供“原样”且无任何保证。自行承担使用风险,并在生产环境中使用之前始终自行测试。如果您发现任何问题,请 创建新问题

许可

MIT

不建议在任何推广种族主义、性别歧视、恐同、动物虐待、暴力或其他任何形式仇恨言论的项目中使用此插件。

致谢

基于