# SabreTooth VObject library
[![Build Status](https://secure.travis-ci.org/evert/sabre-vobject.png?branch=master)](http://travis-ci.org/evert/sabre-vobject)
The VObject library allows you to easily parse and manipulate [iCalendar](https://tools.ietf.org/html/rfc5545)
and [vCard](https://tools.ietf.org/html/rfc6350) objects using PHP.
The goal of the VObject library is to create a very complete library, with an easy to use API.
This project is a spin-off from [SabreDAV](http://code.google.com/p/sabredav/), where it has
been used for several years. The VObject library has 100% unittest coverage.
# Installation
VObject requires PHP 5.3, and should be installed using composer.
The general composer instructions can be found on the [composer website](http://getcomposer.org/doc/00-intro.md composer website).
After that, just declare the vobject dependency as follows:
```
"require" : {
"sabre/vobject" : "2.0.*"
}
```
Then, run `composer.phar update` and you should be good.
# Usage
## Parsing
For our example, we will be using the following vcard:
```
BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 2.0//EN
N:Planck;Max;;;
FN:Max Planck
EMAIL;TYPE=WORK:mplanck@example.org
item1.TEL;TYPE=CELL:(+49)3144435678
item1.X-ABLabel:Private cell
item2.TEL;TYPE=WORK:(+49)5554564744
item2.X-ABLabel:Work
END:VCARD
```
If we want to just print out Max' full name, you can just use property access:
```php
use Sabre\VObject;
$card = VObject\Reader::read($data);
echo $card->FN;
```
## Changing properties
Creating properties is pretty similar. If we like to add his birthday, we just
set the property:
```php
$card->BDAY = '1858-04-23';
```
Note that in the previous example, we're actually updating any existing BDAY that
may already exist. If we want to add a new property, without overwriting the previous
we can do this with the `add` method.
```php
$card->add('EMAIL','max@example.org');
```
## Parameters
If we want to also specify that this is max' home email addresses, we can do this with
a third parameter:
```
$card->add('EMAIL', 'max@example'org', array('type' => 'HOME'));
```
If we want to read out all the email addresses and their type, this would look something
like this:
```
foreach($card->EMAIL as $email) {
echo $email['TYPE'], ' - ', $email;
}
```
## Groups
In our example, you can see that the TEL properties are prefixed. These are 'groups' and
allow you to group multiple related properties together. The group can be any user-defined
name.
This particular example as generated by the OS X addressbook, which uses the `X-ABLabel`
to allow the user to specify custom labels for properties. OS X addressbook uses groups
to tie the label to the property.
The VObject library simply ignores the group if you don't specify it, so this will work:
```php
foreach($card->TEL as $tel) {
echo $tel, "\n";
}
```
But if you would like to target a specific group + property, this is possible too:
```php
echo $card->{'ITEM1.TEL'};
```
So if you would like to show all the phone numbers, along with their custom label, the
following syntax is used:
```php
foreach($card->TEL as $tel) {
echo $card->{$tel->group . '.X-ABLABEL'}, ": ";
echo $tel, "\n";
}
```
## Serializing / Saving
If you want to generate your updated VObject, you can simply call the serialize() method.
```php
echo $card->serialize();
```
## Components
iCalendar, unlike vCards always have sub-components. Where vCards are often just a flat
list, iCalendar objects tend to have a tree-like structure. For the following paragraphs,
we will use the following object as the example:
```
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject 2.0//EN
BEGIN:VEVENT
SUMMARY:Curiosity landing
DTSTART:20120806T051439Z
LOCATION:Mars
END:VEVENT
END:VCALENDAR
```
Since events, tasks and journals are always in a sub component, this is also how we
access them.
```php
use Sabre\VObject;
$calendar = VObject\Reader::read($data);
echo $calendar->VEVENT->SUMMARY;
```
Adding components to a calendar is done with a factory method:
```php
$event = VObject\Component::create('VEVENT');
$calendar->add($event);
$event->SUMMARY = 'Curiosity launch';
$event->DTSTART = '20111126T150202Z';
$event->LOCATION = 'Cape Carnival';
```
By the way.. cloning also works as expected, as the entire structure is cloned along with it:
```php
$clonedEvent = clone $calendar->VEVENT[0];
$calendar->add($clonedEvent);
```
## Date and time handling
If you ever had to deal with iCalendar timezones, you know it can be complicated.
The way timezones are specified is flawed, which is something I may write an essay about some
day. VObject does its best to determine the correct timezone. Many standard formats
have been tested and verified, and special code has been implemented for special-casing
microsoft generated timezone information, and others.
To get a real php `DateTime` object, you can request this as follows:
```php
$event = $calendar->VEVENT;
$start = $event->DTSTART->getDateTime();
echo $start->format(\DateTime::W3C);
```
To set the property with a DateTime object, you can use the following syntax:
```php
$dateTime = new \DateTime('2012-08-07 23:53:00', new DateTimeZone('Europe/Amsterdam'));
$event->DTSTART->setDateTime($dateTime, VObject\Property\DateTime::DATE);
```
The second argument specifies the type of date you're setting. The following three
options exist:
1. `LOCAL` This is a floating time, with no timezone information. This basically specifies that the event happens in whatever the timezone's currently in. This would be encoded as `DTSTART;VALUE=DATE-TIME:20120807235300`
2. `UTC` This specifies that the time should be encoded as a UTC time. This is encoded as `DTSTART;VALUE=DATE-TIME:20120807205300Z`. Note the extra Z and the fact that it's two hours 'earlier'.
3. `LOCALTZ` specifies that it's supposed to be encoded in its local timezone. For example `DTSTART;VALUE=DATE-TIME;TZID=Europe/Amsterdam:20120807235300`.
4. `DATE` This is a date-only, and does not contain the time. In this case this would be encoded as `DTSTART;VALUE=DATE:20120807`.
A few important notes:
* When a `TZID` is specified, there should also be a matching `VTIMEZONE` object with all the timezone information. VObject cannot currently automatically embed this. However, in reality other clients seem to do fine without this information. Yet, for completeness, this will be added in the future.
* As mentioned, the timezone-determination process may sometimes fail. Report any issues you find, and I'll be quick to add workarounds!
## Recurrence rules
Recurrence rules allow events to recur, for example for a weekly meeting, or an anniversary.
This is done with the `RRULE` property. The `RRULE` property allows for a LOT of different
rules. VObject only implements the ones that actually appear in calendar software.
To read more about `RRULE` and all the options, check out [RFC5545](https://tools.ietf.org/html/rfc5545#section-3.8.5).
VObject supports the following options:
1. `UNTIL` for an end date.
2. `INTERVAL` for for example "every 2 days".
3. `COUNT` to stop recurring after x items.
4. `FREQ=DAILY` to recur every day, and `BYDAY` to limit it to certain days.
5. `FREQ=WEEKLY` to recur every week, `BYDAY` to expand this to multiple weekdays in every week and `WKST` to specify on which day the week starts.
6. `FREQ=MONTHLY` to recur every month, `BYMONTHDAY` to expand this to certain days in a month, `BYDAY` to expand it to certain weekdays occuring in a month, and `BYSETPOS` to limit the last two expansions.
7. `FREQ=YEARLY` to recur every year, `BYMONTH` to expand that to certain months in a year, and `BYDAY` and `BYWEEKDAY` to expand the `BYMONTH` rule even further.
VObject supports the `EXDATE` property for exclusions, but not yet the `RDATE` and `EXRULE`
properties. If you're interested in this, please file a github issue, as this will put it
on my radar.
This is a bit of a complex subject to go in excruciatin
没有合适的资源?快使用搜索试试~ 我知道了~
企业盘解决方案.zip
共745个文件
php:488个
png:63个
txt:36个
需积分: 3 0 下载量 196 浏览量
2024-01-15
10:49:06
上传
评论
收藏 28.16MB ZIP 举报
温馨提示
方案是为解决特定问题或达成特定目标而制定的一系列计划或步骤。它的作用是提供一种系统性的方法,以有效地应对挑战、优化流程或实现目标。以下是方案的主要作用: 问题解决: 方案的核心目标是解决问题。通过系统性的规划和执行,方案能够分析问题的根本原因,提供可行的解决方案,并引导实施过程,确保问题得到合理解决。 目标达成: 方案通常与明确的目标相关联,它提供了一种达成这些目标的计划。无论是企业战略、项目管理还是个人发展,方案的制定都有助于明确目标并提供达成目标的路径。 资源优化: 方案在设计时考虑了可用资源,以最大化其效用。通过明智的资源分配,方案可以在有限的资源条件下实现最大的效益,提高效率并减少浪费。 风险管理: 方案通常会对潜在的风险进行评估,并制定相应的风险管理策略。这有助于减轻潜在问题的影响,提高方案的可行性和可持续性。 决策支持: 方案提供了决策者所需的信息和数据,以便做出明智的决策。这种数据驱动的方法有助于减少不确定性,提高决策的准确性。 团队协作: 复杂的问题通常需要多个人的协同努力。方案提供了一个共同的框架,帮助团队成员理解各自的职责和任务,促进协作并确保整个团队朝着共同的目标努力。 监控与评估: 方案通常包括监控和评估的机制,以确保实施的有效性。通过定期的评估,可以及时调整方案,以适应变化的环境或新的挑战。 总体而言,方案的作用在于提供一种有序、有计划的方法,以解决问题、实现目标,并在实施过程中最大化资源利用和风险管理。
资源推荐
资源详情
资源评论
收起资源包目录
企业盘解决方案.zip (745个子文件)
bbb 3KB
ChangeLog 47KB
ChangeLog 2KB
apache2_vhost.conf 1KB
apache2_vhost_cgi.conf 752B
apache2_htaccess.conf 496B
bootstrap.min.css 88KB
bootstrap.min.css 88KB
bootstrap-responsive.min.css 9KB
bootstrap-responsive.min.css 9KB
style.css 6KB
ie6.min.css 5KB
ie6.min.css 5KB
style.css 3KB
jobs.epub 750KB
.htaccess 126B
.htaccess 76B
index.html 10KB
index.html 6KB
folder.html 6KB
front.html 4KB
default.tpl copy.html 3KB
default.tpl.html 3KB
login.html 2KB
index.tpl.html 2KB
index.tpl.html 2KB
info.tpl.html 2KB
admin_log.tpl.html 1KB
header.tpl.html 907B
default.tpl.html 796B
index.html 644B
default.tpl.html 307B
default.tpl.html 279B
info.tpl.html 113B
index.tpl.html 93B
mobile.tpl.html 80B
footer.tpl.html 64B
test.tpl.html 36B
index.tpl.html 35B
test.tpl.html 10B
test.html 0B
favicon.ico 4KB
2012-12-19 1145212060.jpeg 28KB
12385177_1342665966585_1920x1080.jpg 181KB
Windows_7_140387.jpg 139KB
teamdisk_pc.jpg 88KB
logo.jpg 5KB
logo.jpg 5KB
aaa.jpg 3KB
aaa.jpg 3KB
aaa.jpg 3KB
2013-5-9 14_25_54_teamdisk.jpg 3KB
bbb.jpg 3KB
teamdisk.jpg 3KB
bbb - 副本.jpg 3KB
bbb - 副本sss.jpg 3KB
aasssssasas.jpg 3KB
2013-5-9 14_30_24_bbb.jpg 3KB
2013-5-9 14_30_57_bbb.jpg 3KB
aaa.jpg 3KB
bbb.jpg 3KB
tooltip.jpg 2KB
home.jpg 1KB
login_bg.jpg 908B
login_bg.jpg 908B
head_bg.jpg 674B
bule_btn.jpg 672B
header_bg.jpg 666B
header_bg.jpg 666B
bbb - 副本.jpg 0B
bootstrap.min.js 21KB
bootstrap.min.js 21KB
script.js 15KB
ZeroClipboard.js 14KB
ZeroClipboard.js 14KB
jquery.ns.js 13KB
script.js 11KB
ZeroClipboard.min.js 8KB
ZeroClipboard.min.js 8KB
filedrag.js 7KB
html5.js 4KB
html5.js 4KB
app.js 2KB
app.js 2KB
jq.template.js 1KB
jq.template.js 1KB
jq.i18n.min.js 937B
jq.i18n.min.js 937B
app.js 919B
i18n.dict.js 732B
i18n.dict.js 732B
plugins.js 578B
plugins.js 578B
ie6.min.js 473B
ie6.min.js 473B
js.unit.js 291B
installed.json 1KB
composer.json 1KB
composer.json 876B
LICENSE 2KB
共 745 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
JJJ69
- 粉丝: 5960
- 资源: 5593
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功