更新到 5.2 后第一次 SVN 提交。

[email protected]



git-svn-id: https://svn.code.sf.net/p/hawebs/svn@543 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-08-21 17:26:39 +00:00
parent d23e9e3a1e
commit 342a9e415e
127 changed files with 10886 additions and 0 deletions
@@ -0,0 +1,15 @@
Changelog for qCal, since Version 0.0.2
---------------------------------------------
January 14, 2010: v0.0.2
--------------------
* Integrated qCal_DateTime sub-components into the library.
* Removed old qCal_Date component (replaced by qCal_DateTime, qCal_DateV2,
which has been renamed qCal_Date, and qCal_Time)
* Added full documentation for the library at http://qcal.lukevisinoni.com/ as
well as inside the "docs" sub-folder.
* Added this changelog.
* Added README and VERSION files.
-- End of Changes --
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
+33
View File
@@ -0,0 +1,33 @@
qCal iCalendar Library for PHP5, by Luke Visinoni
-------------------------------------------------------------------------------
qCal is an object-oriented, open-source iCalendar library for PHP5.
It is released under the LGPL license.
Homepage: http://qcal.lukevisinoni.com/
Documentation: http://qcal.lukevisinoni.com/doku.php?id=start
Mailing List: http://groups.google.com/group/qcal
Bugs: http://code.google.com/p/qcal/issues/list
Repository: https://qcal.googlecode.com/svn/
Installation
------------
This library requires no installation. At least not in the traditional sense.
Simply upload to a path within PHP's include path and include
"lib/autoload.php".
For more info, visit http://qcal.lukevisinoni.com/doku.php?id=installation
Show your support!
------------------
If you use the library and would like to show your support, feel free to make a
donation. I accept donations via PayPal. You can send me money at the following
e-mail address.
[email protected]
I didn't write this library to make money, but I do appreciate donations. In
fact, those users who donate to the project are by far cooler than those who
don't. I like donors better than non-donors. LOL!
@@ -0,0 +1 @@
qCal-v0.0.2
@@ -0,0 +1,15 @@
<?php
/**
* Include this file if you want to use the __autoload feature rather than including
* all of the files manually. It will automatically register its autoload function
* with spl's autoload mechanism.
*/
require_once 'qCal/Loader.php';
function qCal_Autoloader($name) {
qCal_Loader::loadClass($name);
}
spl_autoload_register("qCal_Autoloader");
@@ -0,0 +1,5 @@
<?php
class qCal extends qCal_Component_Vcalendar {
// this is simply a facade to qCal_Component_Calendar, a shortcut
}
?>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,59 @@
<?php
/**
* Calendar Component
* This is the outer-most object in an icalendar file that represents
* the calendar as a whole. All other components must be nested within
* this component.
* @package qCal
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
* @todo Implement a method of NOT allowing more than one of properties
* such as METHOD to be set.
*
* RFC 2445 Definition
*
* The Calendaring and Scheduling Core Object is a collection of
* calendaring and scheduling information. Typically, this information
* will consist of a single iCalendar object. However, multiple
* iCalendar objects can be sequentially grouped together. The first
* line and last line of the iCalendar object MUST contain a pair of
* iCalendar object delimiter strings. The syntax for an iCalendar
* object is as follows:
*
* icalobject = 1*("BEGIN" ":" "VCALENDAR" CRLF
* icalbody
* "END" ":" "VCALENDAR" CRLF)
*
* The following is a simple example of an iCalendar object:
*
* BEGIN:VCALENDAR
* VERSION:2.0
* PRODID:-//hacksw/handcal//NONSGML v1.0//EN
* BEGIN:VEVENT
* DTSTART:19970714T170000Z
* DTEND:19970715T035959Z
* SUMMARY:Bastille Day Party
* END:VEVENT
* END:VCALENDAR
*/
class qCal_Component_Vcalendar extends qCal_Component {
protected $name = "VCALENDAR";
protected $requiredProperties = array('PRODID','VERSION');
/**
* vcalendar objects have a number of requirements defined in the RFC just as most other
* components do. Each has a global set of validation rules as well as their own set. This
* is the set of rules defined by the vcalendar object.
*/
public function doValidation() {
// @todo make sure that all tzids that are specified have a corresponding vtimezone
// look for tzids and make sure there are corresponding vtimezone components for each tzid
// In order to be sure I find all tzids, I need to search through the entire tree, so either
// I need a recursive getProperties() or I need to use a stack to find all of them.
}
}
@@ -0,0 +1,165 @@
<?php
/**
* Event Component
* @package qCal
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*
* RFC 2445 Definition
*
* Component Name: "VEVENT"
*
* Purpose: Provide a grouping of component properties that describe an
* event.
*
* Format Definition: A "VEVENT" calendar component is defined by the
* following notation:
*
* eventc = "BEGIN" ":" "VEVENT" CRLF
* eventprop *alarmc
* "END" ":" "VEVENT" CRLF
*
* eventprop = *(
*
* ; the following are optional,
* ; but MUST NOT occur more than once
*
* class / created / description / dtstart / geo /
* last-mod / location / organizer / priority /
* dtstamp / seq / status / summary / transp /
* uid / url / recurid /
*
* ; either 'dtend' or 'duration' may appear in
* ; a 'eventprop', but 'dtend' and 'duration'
* ; MUST NOT occur in the same 'eventprop'
*
* dtend / duration /
*
* ; the following are optional,
* ; and MAY occur more than once
*
* attach / attendee / categories / comment /
* contact / exdate / exrule / rstatus / related /
* resources / rdate / rrule / x-prop
*
* )
*
* Description: A "VEVENT" calendar component is a grouping of component
* properties, and possibly including "VALARM" calendar components, that
* represents a scheduled amount of time on a calendar. For example, it
* can be an activity; such as a one-hour long, department meeting from
* 8:00 AM to 9:00 AM, tomorrow. Generally, an event will take up time
* on an individual calendar. Hence, the event will appear as an opaque
* interval in a search for busy time. Alternately, the event can have
* its Time Transparency set to "TRANSPARENT" in order to prevent
* blocking of the event in searches for busy time.
*
* The "VEVENT" is also the calendar component used to specify an
* anniversary or daily reminder within a calendar. These events have a
* DATE value type for the "DTSTART" property instead of the default
* data type of DATE-TIME. If such a "VEVENT" has a "DTEND" property, it
* MUST be specified as a DATE value also. The anniversary type of
* "VEVENT" can span more than one date (i.e, "DTEND" property value is
* set to a calendar date after the "DTSTART" property value).
*
* The "DTSTART" property for a "VEVENT" specifies the inclusive start
* of the event. For recurring events, it also specifies the very first
* instance in the recurrence set. The "DTEND" property for a "VEVENT"
* calendar component specifies the non-inclusive end of the event. For
* cases where a "VEVENT" calendar component specifies a "DTSTART"
* property with a DATE data type but no "DTEND" property, the events
* non-inclusive end is the end of the calendar date specified by the
* "DTSTART" property. For cases where a "VEVENT" calendar component
* specifies a "DTSTART" property with a DATE-TIME data type but no
* "DTEND" property, the event ends on the same calendar date and time
* of day specified by the "DTSTART" property.
*
* The "VEVENT" calendar component cannot be nested within another
* calendar component. However, "VEVENT" calendar components can be
* related to each other or to a "VTODO" or to a "VJOURNAL" calendar
* component with the "RELATED-TO" property.
*
* Example: The following is an example of the "VEVENT" calendar
* component used to represent a meeting that will also be opaque to
* searches for busy time:
*
* BEGIN:VEVENT
* UID:[email protected]
* DTSTAMP:19970901T1300Z
* DTSTART:19970903T163000Z
* DTEND:19970903T190000Z
* SUMMARY:Annual Employee Review
* CLASS:PRIVATE
* CATEGORIES:BUSINESS,HUMAN RESOURCES
* END:VEVENT
*
* The following is an example of the "VEVENT" calendar component used
* to represent a reminder that will not be opaque, but rather
* transparent, to searches for busy time:
*
* BEGIN:VEVENT
* UID:[email protected]
* DTSTAMP:19970901T1300Z
* DTSTART:19970401T163000Z
* DTEND:19970402T010000Z
* SUMMARY:Laurel is in sensitivity awareness class.
* CLASS:PUBLIC
* CATEGORIES:BUSINESS,HUMAN RESOURCES
* TRANSP:TRANSPARENT
* END:VEVENT
*
* The following is an example of the "VEVENT" calendar component used
* to represent an anniversary that will occur annually. Since it takes
* up no time, it will not appear as opaque in a search for busy time;
* no matter what the value of the "TRANSP" property indicates:
*
* BEGIN:VEVENT
* UID:[email protected]
* DTSTAMP:19970901T1300Z
* DTSTART:19971102
* SUMMARY:Our Blissful Anniversary
* CLASS:CONFIDENTIAL
* CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION
* RRULE:FREQ=YEARLY
* END:VEVENT
*/
class qCal_Component_Vevent extends qCal_Component {
protected $name = "VEVENT";
protected $allowedComponents = array('VCALENDAR');
protected function doValidation() {
$properties = $this->getProperties();
$propnames = array_keys($properties);
if (in_array('DTEND', $propnames) && in_array('DURATION', $propnames)) {
throw new qCal_Exception_InvalidProperty('DTEND and DURATION cannot both occur in the same VEVENT component');
}
if (in_array('DTSTART', $propnames)) {
$dtstart = $this->getProperty('dtstart');
$dtstart = $dtstart[0];
// check that if dtstart is a DATE that dtend is a DATE
if ($dtstart->getType() == 'DATE') {
if (in_array('DTEND', $propnames)) {
$dtend = $this->getProperty('dtend');
$dtend = $dtend[0];
if ($dtend->getType() != 'DATE') {
throw new qCal_Exception_InvalidProperty('If DTSTART property is specified as a DATE property, so must DTEND');
}
}
}
// check that dtstart comes before dtend
if (in_array('DTEND', $propnames)) {
$dtend = $this->getProperty('dtend');
$dtend = $dtend[0];
$startdate = strtotime($dtstart->getValue());
$enddate = strtotime($dtend->getValue());
if ($startdate > $enddate) {
throw new qCal_Exception_InvalidProperty('DTSTART property must come before DTEND');
}
}
}
}
}
@@ -0,0 +1,137 @@
<?php
/**
* Freebusy Component
* @package qCal
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*
* RFC 2445 Definition
*
* Component Name: VFREEBUSY
*
* Purpose: Provide a grouping of component properties that describe
* either a request for free/busy time, describe a response to a request
* for free/busy time or describe a published set of busy time.
*
* Formal Definition: A "VFREEBUSY" calendar component is defined by the
* following notation:
*
* freebusyc = "BEGIN" ":" "VFREEBUSY" CRLF
* fbprop
* "END" ":" "VFREEBUSY" CRLF
*
* fbprop = *(
*
* ; the following are optional,
* ; but MUST NOT occur more than once
*
* contact / dtstart / dtend / duration / dtstamp /
* organizer / uid / url /
*
* ; the following are optional,
* ; and MAY occur more than once
*
* attendee / comment / freebusy / rstatus / x-prop
*
* )
*
* Description: A "VFREEBUSY" calendar component is a grouping of
* component properties that represents either a request for, a reply to
* a request for free or busy time information or a published set of
* busy time information.
*
* When used to request free/busy time information, the "ATTENDEE"
* property specifies the calendar users whose free/busy time is being
* requested; the "ORGANIZER" property specifies the calendar user who
* is requesting the free/busy time; the "DTSTART" and "DTEND"
* properties specify the window of time for which the free/busy time is
* being requested; the "UID" and "DTSTAMP" properties are specified to
* assist in proper sequencing of multiple free/busy time requests.
*
* When used to reply to a request for free/busy time, the "ATTENDEE"
* property specifies the calendar user responding to the free/busy time
* request; the "ORGANIZER" property specifies the calendar user that
* originally requested the free/busy time; the "FREEBUSY" property
* specifies the free/busy time information (if it exists); and the
*
* "UID" and "DTSTAMP" properties are specified to assist in proper
* sequencing of multiple free/busy time replies.
*
* When used to publish busy time, the "ORGANIZER" property specifies
* the calendar user associated with the published busy time; the
* "DTSTART" and "DTEND" properties specify an inclusive time window
* that surrounds the busy time information; the "FREEBUSY" property
* specifies the published busy time information; and the "DTSTAMP"
* property specifies the date/time that iCalendar object was created.
*
* The "VFREEBUSY" calendar component cannot be nested within another
* calendar component. Multiple "VFREEBUSY" calendar components can be
* specified within an iCalendar object. This permits the grouping of
* Free/Busy information into logical collections, such as monthly
* groups of busy time information.
*
* The "VFREEBUSY" calendar component is intended for use in iCalendar
* object methods involving requests for free time, requests for busy
* time, requests for both free and busy, and the associated replies.
*
* Free/Busy information is represented with the "FREEBUSY" property.
* This property provides a terse representation of time periods. One or
* more "FREEBUSY" properties can be specified in the "VFREEBUSY"
* calendar component.
*
* When present in a "VFREEBUSY" calendar component, the "DTSTART" and
* "DTEND" properties SHOULD be specified prior to any "FREEBUSY"
* properties. In a free time request, these properties can be used in
* combination with the "DURATION" property to represent a request for a
* duration of free time within a specified window of time.
*
* The recurrence properties ("RRULE", "EXRULE", "RDATE", "EXDATE") are
* not permitted within a "VFREEBUSY" calendar component. Any recurring
* events are resolved into their individual busy time periods using the
* "FREEBUSY" property.
*
* Example: The following is an example of a "VFREEBUSY" calendar
* component used to request free or busy time information:
*
* BEGIN:VFREEBUSY
* ORGANIZER:MAILTO:[email protected]
* ATTENDEE:MAILTO:[email protected]
* DTSTART:19971015T050000Z
* DTEND:19971016T050000Z
* DTSTAMP:19970901T083000Z
* END:VFREEBUSY
*
* The following is an example of a "VFREEBUSY" calendar component used
* to reply to the request with busy time information:
*
* BEGIN:VFREEBUSY
* ORGANIZER:MAILTO:[email protected]
* ATTENDEE:MAILTO:[email protected]
* DTSTAMP:19970901T100000Z
* FREEBUSY;VALUE=PERIOD:19971015T050000Z/PT8H30M,
* 19971015T160000Z/PT5H30M,19971015T223000Z/PT6H30M
* URL:http://host2.com/pub/busy/jpublic-01.ifb
* COMMENT:This iCalendar file contains busy time information for
* the next three months.
* END:VFREEBUSY
*
* The following is an example of a "VFREEBUSY" calendar component used
* to publish busy time information.
*
* BEGIN:VFREEBUSY
* ORGANIZER:[email protected]
* DTSTART:19980313T141711Z
* DTEND:19980410T141711Z
* FREEBUSY:19980314T233000Z/19980315T003000Z
* FREEBUSY:19980316T153000Z/19980316T163000Z
* FREEBUSY:19980318T030000Z/19980318T040000Z
* URL:http://www.host.com/calendar/busytime/jsmith.ifb
* END:VFREEBUSY
*/
class qCal_Component_Vfreebusy extends qCal_Component {
protected $name = "VFREEBUSY";
protected $allowedComponents = array('VCALENDAR');
}
@@ -0,0 +1,86 @@
<?php
/**
* Journal Component
* @package qCal
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*
* RFC 2445 Definition
*
* Component Name: VJOURNAL
*
* Purpose: Provide a grouping of component properties that describe a
* journal entry.
*
* Formal Definition: A "VJOURNAL" calendar component is defined by the
* following notation:
*
* journalc = "BEGIN" ":" "VJOURNAL" CRLF
* jourprop
* "END" ":" "VJOURNAL" CRLF
*
* jourprop = *(
*
* ; the following are optional,
* ; but MUST NOT occur more than once
*
* class / created / description / dtstart / dtstamp /
* last-mod / organizer / recurid / seq / status /
* summary / uid / url /
*
* ; the following are optional,
* ; and MAY occur more than once
*
* attach / attendee / categories / comment /
* contact / exdate / exrule / related / rdate /
* rrule / rstatus / x-prop
*
* )
*
* Description: A "VJOURNAL" calendar component is a grouping of
* component properties that represent one or more descriptive text
* notes associated with a particular calendar date. The "DTSTART"
* property is used to specify the calendar date that the journal entry
* is associated with. Generally, it will have a DATE value data type,
* but it can also be used to specify a DATE-TIME value data type.
* Examples of a journal entry include a daily record of a legislative
* body or a journal entry of individual telephone contacts for the day
* or an ordered list of accomplishments for the day. The "VJOURNAL"
* calendar component can also be used to associate a document with a
* calendar date.
*
* The "VJOURNAL" calendar component does not take up time on a
* calendar. Hence, it does not play a role in free or busy time
* searches - - it is as though it has a time transparency value of
* TRANSPARENT. It is transparent to any such searches.
*
* The "VJOURNAL" calendar component cannot be nested within another
* calendar component. However, "VJOURNAL" calendar components can be
* related to each other or to a "VEVENT" or to a "VTODO" calendar
* component, with the "RELATED-TO" property.
*
* Example: The following is an example of the "VJOURNAL" calendar
* component:
*
* BEGIN:VJOURNAL
* UID:[email protected]
* DTSTAMP:19970901T1300Z
* DTSTART;VALUE=DATE:19970317
* SUMMARY:Staff meeting minutes
* DESCRIPTION:1. Staff meeting: Participants include Joe\, Lisa
* and Bob. Aurora project plans were reviewed. There is currently
* no budget reserves for this project. Lisa will escalate to
* management. Next meeting on Tuesday.\n
* 2. Telephone Conference: ABC Corp. sales representative called
* to discuss new printer. Promised to get us a demo by Friday.\n
* 3. Henry Miller (Handsoff Insurance): Car was totaled by tree.
* Is looking into a loaner car. 654-2323 (tel).
* END:VJOURNAL
*/
class qCal_Component_Vjournal extends qCal_Component {
protected $name = "VJOURNAL";
protected $allowedComponents = array('VCALENDAR');
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,81 @@
<?php
/**
* Todo Component
* @package qCal
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*
* RFC 2445 Definition
*
* Component Name: VTODO
*
* Purpose: Provide a grouping of calendar properties that describe a
* to-do.
*
* Formal Definition: A "VTODO" calendar component is defined by the
* following notation:
*
* todoc = "BEGIN" ":" "VTODO" CRLF
* todoprop *alarmc
* "END" ":" "VTODO" CRLF
*
* todoprop = *(
*
* ; the following are optional,
* ; but MUST NOT occur more than once
*
* class / completed / created / description / dtstamp /
* dtstart / geo / last-mod / location / organizer /
* percent / priority / recurid / seq / status /
* summary / uid / url /
*
* ; either 'due' or 'duration' may appear in
* ; a 'todoprop', but 'due' and 'duration'
* ; MUST NOT occur in the same 'todoprop'
*
* due / duration /
*
* ; the following are optional,
* ; and MAY occur more than once
* attach / attendee / categories / comment / contact /
* exdate / exrule / rstatus / related / resources /
* rdate / rrule / x-prop
*
* )
*
* Description: A "VTODO" calendar component is a grouping of component
* properties and possibly "VALARM" calendar components that represent
* an action-item or assignment. For example, it can be used to
* represent an item of work assigned to an individual; such as "turn in
* travel expense today".
*
* The "VTODO" calendar component cannot be nested within another
* calendar component. However, "VTODO" calendar components can be
* related to each other or to a "VTODO" or to a "VJOURNAL" calendar
* component with the "RELATED-TO" property.
*
* A "VTODO" calendar component without the "DTSTART" and "DUE" (or
* "DURATION") properties specifies a to-do that will be associated with
* each successive calendar date, until it is completed.
*
* Example: The following is an example of a "VTODO" calendar component:
*
* BEGIN:VTODO
* UID:[email protected]
* DTSTAMP:19970901T1300Z
* DTSTART:19970415T133000Z
* DUE:19970416T045959Z
* SUMMARY:1996 Income Tax Preparation
* CLASS:CONFIDENTIAL
* CATEGORIES:FAMILY,FINANCE
* PRIORITY:1
* STATUS:NEEDS-ACTION
* END:VTODO
*/
class qCal_Component_Vtodo extends qCal_Component {
protected $name = "VTODO";
protected $allowedComponents = array('VCALENDAR');
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,190 @@
<?php
/**
* qCal_DateTime
*
* In order to perform all the complex date/time based math and logic required to
* implement the iCalendar spec, we need a complex date/time class. This class represents
* a specific point in time, including the time. Internally it makes use of qCal_Date and
* qCal_Time. If only a date or only a time needs to be represented, then one of those
* classes should be used.
*
* @package qCal_Date
* @
*/
class qCal_DateTime {
/**
* @var qCal_Date An object that represents the date
*/
protected $date;
/**
* @var qCal_Time An object that represents the time
*/
protected $time;
/**
* @var string The default string representation of datetime is a direct
* correlation to the date function's "c" metacharacter
*/
protected $format = "Y-m-d\TH:i:sP";
/**
* Class constructor
* @todo Make this default to "now"
* @todo It is possible that the timezone could put the date back (or forward?) a day. This does not account for that
*/
public function __construct($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null, $rollover = null) {
$date = new qCal_Date($year, $month, $day, $rollover);
$time = new qCal_Time($hour, $minute, $second, $timezone, $rollover);
$this->setDate($date);
$this->setTime($time);
}
/**
* Generate a datetime object via string
* @todo Should this accept qCal_Date and qCal_DateTime objects?
*/
public static function factory($datetime, $timezone = null) {
if (is_null($timezone) || !($timezone instanceof qCal_Timezone)) {
// @todo Make sure this doesn't cause any issues
// detect if we're working with a UTC string like "19970101T180000Z", where the Z means use UTC time
if (strtolower(substr($datetime, -1)) == "z") {
$timezone = "UTC";
}
$timezone = qCal_Timezone::factory($timezone);
}
// get the default timezone so we can set it back to it later
$tz = date_default_timezone_get();
// set the timezone to GMT temporarily
date_default_timezone_set("GMT");
// handles unix timestamp
if (is_integer($datetime) || ctype_digit((string) $datetime)) {
$timestamp = $datetime;
} else {
// handles just about any string representation of date/time (strtotime)
if (is_string($datetime) || empty($datetime)) {
if (!$timestamp = strtotime($datetime)) {
// if unix timestamp can't be created throw an exception
throw new qCal_DateTime_Exception("Invalid or ambiguous date/time string passed to qCal_DateTime::factory()");
}
}
}
if (!isset($timestamp)) {
throw new qCal_DateTime_Exception("Could not generate a qCal_DateTime object.");
}
list($year, $month, $day, $hour, $minute, $second) = explode("|", gmdate("Y|m|d|H|i|s", $timestamp));
// set the timezone back to what it was
date_default_timezone_set($tz);
return new qCal_DateTime($year, $month, $day, $hour, $minute, $second, $timezone);
}
/**
* Set the date component
*/
protected function setDate(qCal_Date $date) {
$this->date = $date;
}
/**
* Set the time component
*/
protected function setTime(qCal_Time $time) {
$this->time = $time;
}
/**
* Get time portion as object
*/
public function getTime() {
return $this->time;
}
/**
* Get date portion as object
*/
public function getDate() {
return $this->date;
}
/**
* Get unix timestamp
*/
public function getUnixTimestamp($useOffset = true) {
return $this->date->getUnixTimestamp() + $this->time->getTimestamp($useOffset);
}
/**
* Set the format to use when outputting as a string
*/
public function setFormat($format) {
$this->format = (string) $format;
return $this;
}
/**
* Format the date/time using PHP's date() function's meta-characters
* @todo It's obvious I need to find a better solution to formatting since I have repeated this method
* in three classes now...
*/
public function format($format) {
$escape = false;
$meta = str_split($format);
$output = array();
foreach($meta as $char) {
if ($char == '\\') {
$escape = true;
continue;
}
if (!$escape && $this->convertChar($char) != $char) {
$output[] = $this->convertChar($char);
} else {
$output[] = $char;
}
// reset this to false after every iteration that wasn't "continued"
$escape = false;
}
return implode($output);
}
/**
* convert character
*/
protected function convertChar($char) {
$char = $this->date->format($char);
$char = $this->time->format($char);
$char = $this->time->getTimezone()->format($char);
return $char;
}
/**
* Output date/time as string
*/
public function __toString() {
return $this->format($this->format);
}
/**
* Get date/time as UTC
*/
public function getUtc($humanReadable = false) {
if ($humanReadable) return gmdate('Y-m-d', $this->date->getUnixTimestamp()) . gmdate('\TH:i:s\Z', $this->time->getTimestamp());
else return gmdate('Ymd', $this->date->getUnixTimestamp()) . gmdate('\THis\Z', $this->time->getTimestamp());
}
}
@@ -0,0 +1,115 @@
<?php
/**
* Date duration
*
* @package qCal
* @subpackage qCal_DateTime
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*/
class qCal_DateTime_Duration {
// an array of how manys seconds are in a minute, hour, day, etc.
// IMPORTANT - don't change the order of these
protected $durations = array ('W' => 604800, 'D' => 86400, 'H' => 3600, 'M' => 60, 'S' => 1);
/**
* Duration in seconds
*/
protected $duration;
/**
* If this is negative, this will be a minus symbol. Positive doesn't need a sign, so it is just null
*/
protected $sign;
/**
* Constructor
*/
public function __construct($duration = null) {
$this->setDuration($duration);
}
/**
* Set duration - accepts an integer (amount of seconds) or an icalendar-formatted duration string
*/
public function setDuration($duration) {
$duration = strtoupper($duration);
// if plus or minus precedes number, remove it set in class
if (preg_match("/^[+-]/", (string) $duration, $matches)) {
if ($matches[0] == "-") $this->sign = "-";
$duration = str_split($duration);
array_shift($duration);
$duration = implode("", $duration);
}
if (ctype_digit($duration)) {
$this->duration = $duration;
} else {
// convert value to duration in seconds
preg_match('/^P([0-9]+[W])?([0-9]+[D])?T?([0-9]+[H])?([0-9]+[M])?([0-9]+[S])?$/i', $duration, $matches);
// remove first element (which is just entire the matched string)
array_shift($matches);
$seconds = 0;
foreach ($matches as $duration) {
if (empty($duration)) continue;
$seconds += $this->calculateSeconds($duration);
}
$this->duration = $seconds;
}
return $this;
}
/**
* Pass in a string like "15W" or "1D" and this will return how many seconds are in it
*/
protected function calculateSeconds($duration) {
$amnt = preg_replace("/[^0-9]/i", "", $duration);
$inc = preg_replace("/[^A-Z]/i", "", $duration);
return $this->durations[$inc] * $amnt;
}
/**
* Converts seconds to an icalendar-formatted duration string
*/
public function toICal() {
$total = $this->duration;
$return = "P";
// this is why order is important when defining $this->durations
foreach ($this->durations as $dur => $amnt) {
// how many "weeks" are in the value?
$quotient = (int) ($total / $amnt);
// get the remainder of the division
$remainder = $total - ($quotient*$amnt);
// now if we got a whole number as quotient, add this duration to the return string
if ($quotient) {
// if this is the first "time" duration, add the required T char
if ($dur == "H" || $dur == "M" || $dur == "S") {
if (!strpos($return, "T")) $return .= "T";
}
$return .= $quotient . $dur;
}
$total = $remainder;
}
return $this->sign . $return;
}
/**
* @todo Should this be the string representation? I dont really know.
*/
public function __toString() {
return $this->toICal();
}
/**
* Get duration in seconds
*/
public function getSeconds() {
return (integer) $this->sign . $this->duration;
}
}
@@ -0,0 +1,7 @@
<?php
/**
* qCal_Date is a sub-package of qCal, so it has its own exceptions.
*/
class qCal_DateTime_Exception extends qCal_Exception {
}
@@ -0,0 +1,12 @@
<?php
/**
* Invalid Date Exception - thrown when an invalid or ambiguous date is passed to qCal_Date::setDate()
* @package qCal
* @subpackage qCal_Date
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*/
class qCal_DateTime_Exception_InvalidDate extends qCal_DateTime_Exception {
}
@@ -0,0 +1,12 @@
<?php
/**
* Invalid Date Span Exception - thrown when somebody attempts to make a start date come after an end date
* @package qCal
* @subpackage qCal_Date
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*/
class qCal_DateTime_Exception_InvalidPeriod extends qCal_DateTime_Exception {
}
@@ -0,0 +1,12 @@
<?php
/**
* Invalid Date Recurrence Exception - thrown when somebody attempts to create an invalid recurrence
* @package qCal
* @subpackage qCal_Date
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*/
class qCal_DateTime_Exception_InvalidRecur extends qCal_DateTime_Exception {
}
@@ -0,0 +1,12 @@
<?php
/**
* Invalid Time Exception - thrown when an invalid or ambiguous time string is passed to qCal_Time::setTime()
* @package qCal
* @subpackage qCal_Date
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*/
class qCal_DateTime_Exception_InvalidTime extends qCal_DateTime_Exception {
}
@@ -0,0 +1,2 @@
<?php
class qCal_DateTime_Exception_InvalidTimezone extends qCal_DateTime_Exception {}
@@ -0,0 +1,6 @@
<?php
class qCal_DateTime_Exception_InvalidWeekday extends qCal_DateTime_Exception {
// w00t!
}
@@ -0,0 +1,62 @@
<?php
/**
* Date period object - rather than a point in time, this object represents a PERIOD of time. So,
* it consists of a start and end point in time
*
* @package qCal
* @subpackage qCal_Date
* @copyright Luke Visinoni ([email protected])
* @author Luke Visinoni ([email protected])
* @license GNU Lesser General Public License
*/
class qCal_DateTime_Period {
/**
* Start and end date/times
*/
protected $start, $end;
/**
* Constructor
*/
public function __construct($start, $end) {
if (!($start instanceof qCal_DateTime)) {
$start = qCal_DateTime::factory($start);
}
if (!($end instanceof qCal_DateTime)) {
$end = qCal_DateTime::factory($end);
}
$this->start = $start;
$this->end = $end;
if ($this->getSeconds() < 0) {
throw new qCal_DateTime_Exception_InvalidPeriod("The start date must come before the end date.");
}
}
/**
* Converts to how many seconds between the two. because this is the smallest increment
* used in this class, seconds are used to determine other increments
*/
public function getSeconds() {
return $this->end->getUnixTimestamp() - $this->start->getUnixTimestamp();
}
/**
* Returns start date
*/
public function getStart() {
return $this->start;
}
/**
* Returns end date
*/
public function getEnd() {
return $this->end;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,10 @@
<?php
class qCal_DateTime_Recur_Daily extends qCal_DateTime_Recur {
protected function doGetRecurrences($rules, $start, $end) {
// do stuff!
}
}
@@ -0,0 +1,10 @@
<?php
class qCal_DateTime_Recur_Hourly extends qCal_DateTime_Recur {
protected function doGetRecurrences($rules, $start, $end) {
// do stuff!
}
}

Some files were not shown because too many files have changed in this diff Show More