4 * BENNU - PHP iCalendar library
5 * (c) 2005-2006 Ioannis Papaioannou (pj@moodle.org). All rights reserved.
7 * Released under the LGPL.
9 * See http://bennu.sourceforge.net/ for more information and downloads.
11 * @author Ioannis Papaioannou
13 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
16 class iCalendar_parameter
{
17 function multiple_values_allowed($parameter) {
19 case 'DELEGATED-FROM':
28 function default_value($parameter) {
30 case 'CUTYPE': return 'INDIVIDUAL';
31 case 'FBTYPE': return 'BUSY';
32 case 'PARTSTAT': return 'NEEDS-ACTION';
33 case 'RELATED': return 'START';
34 case 'RELTYPE': return 'PARENT';
35 case 'ROLE': return 'REQ-PARTICIPANT';
36 case 'RSVP': return 'FALSE';
41 function is_valid_value(&$parent_property, $parameter, $value) {
43 // These must all be a URI
46 return rfc2445_is_valid_value($value, RFC2445_TYPE_URI
);
49 // These must be CAL-ADDRESS, which is equivalent to URI
50 case 'DELEGATED-FROM':
54 return rfc2445_is_valid_value($value, RFC2445_TYPE_CAL_ADDRESS
);
57 // These are textual parameters, so the MUST NOT contain double quotes
59 return (strpos($value, '"') === false);
62 // These have enumerated legal values
64 $value = strtoupper($value);
65 return ($value == 'INDIVIDUAL' ||
$value == 'GROUP' ||
$value == 'RESOURCE' ||
$value == 'ROOM' ||
$value == 'UNKNOWN' ||
rfc2445_is_xname($value));
69 $value = strtoupper($value);
70 return ($value == '8BIT' ||
$value == 'BASE64' ||
rfc2445_is_xname($value));
74 $value = strtoupper($value);
75 return ($value == 'FREE' ||
$value == 'BUSY' ||
$value == 'BUSY-UNAVAILABLE' ||
$value == 'BUSY-TENTATIVE' ||
rfc2445_is_xname($value));
80 'TEXT' => array('PLAIN', 'RICHTEXT', 'ENRICHED', 'TAB-SEPARATED-VALUES', 'HTML', 'SGML',
81 'VND.LATEX-Z', 'VND.FMI.FLEXSTOR'),
82 'MULTIPART' => array('MIXED', 'ALTERNATIVE', 'DIGEST', 'PARALLEL', 'APPLEDOUBLE', 'HEADER-SET',
83 'FORM-DATA', 'RELATED', 'REPORT', 'VOICE-MESSAGE', 'SIGNED', 'ENCRYPTED',
85 'MESSAGE' => array('RFC822', 'PARTIAL', 'EXTERNAL-BODY', 'NEWS', 'HTTP'),
86 'APPLICATION' => array('OCTET-STREAM', 'POSTSCRIPT', 'ODA', 'ATOMICMAIL', 'ANDREW-INSET', 'SLATE',
87 'WITA', 'DEC-DX', 'DCA-RFT', 'ACTIVEMESSAGE', 'RTF', 'APPLEFILE',
88 'MAC-BINHEX40', 'NEWS-MESSAGE-ID', 'NEWS-TRANSMISSION', 'WORDPERFECT5.1',
89 'PDF', 'ZIP', 'MACWRITEII', 'MSWORD', 'REMOTE-PRINTING', 'MATHEMATICA',
90 'CYBERCASH', 'COMMONGROUND', 'IGES', 'RISCOS', 'ESHOP', 'X400-BP', 'SGML',
91 'CALS-1840', 'PGP-ENCRYPTED', 'PGP-SIGNATURE', 'PGP-KEYS', 'VND.FRAMEMAKER',
92 'VND.MIF', 'VND.MS-EXCEL', 'VND.MS-POWERPOINT', 'VND.MS-PROJECT',
93 'VND.MS-WORKS', 'VND.MS-TNEF', 'VND.SVD', 'VND.MUSIC-NIFF', 'VND.MS-ARTGALRY',
94 'VND.TRUEDOC', 'VND.KOAN', 'VND.STREET-STREAM', 'VND.FDF',
95 'SET-PAYMENT-INITIATION', 'SET-PAYMENT', 'SET-REGISTRATION-INITIATION',
96 'SET-REGISTRATION', 'VND.SEEMAIL', 'VND.BUSINESSOBJECTS',
97 'VND.MERIDIAN-SLINGSHOT', 'VND.XARA', 'SGML-OPEN-CATALOG', 'VND.RAPID',
98 'VND.ENLIVEN', 'VND.JAPANNET-REGISTRATION-WAKEUP',
99 'VND.JAPANNET-VERIFICATION-WAKEUP', 'VND.JAPANNET-PAYMENT-WAKEUP',
100 'VND.JAPANNET-DIRECTORY-SERVICE', 'VND.INTERTRUST.DIGIBOX', 'VND.INTERTRUST.NNCP'),
101 'IMAGE' => array('JPEG', 'GIF', 'IEF', 'G3FAX', 'TIFF', 'CGM', 'NAPLPS', 'VND.DWG', 'VND.SVF',
102 'VND.DXF', 'PNG', 'VND.FPX', 'VND.NET-FPX'),
103 'AUDIO' => array('BASIC', '32KADPCM', 'VND.QCELP'),
104 'VIDEO' => array('MPEG', 'QUICKTIME', 'VND.VIVO', 'VND.MOTOROLA.VIDEO', 'VND.MOTOROLA.VIDEOP')
106 $value = strtoupper($value);
107 if(rfc2445_is_xname($value)) {
110 @list
($type, $subtype) = explode('/', $value);
111 if(empty($type) ||
empty($subtype)) {
114 if(!isset($fmttypes[$type]) ||
!in_array($subtype, $fmttypes[$type])) {
121 $value = strtoupper($value);
122 $parts = explode('-', $value);
123 foreach($parts as $part) {
127 if(strspn($part, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') != strlen($part)) {
135 $value = strtoupper($value);
136 switch($parent_property->parent_component
) {
138 return ($value == 'NEEDS-ACTION' ||
$value == 'ACCEPTED' ||
$value == 'DECLINED' ||
$value == 'TENTATIVE'
139 ||
$value == 'DELEGATED' ||
rfc2445_is_xname($value));
142 return ($value == 'NEEDS-ACTION' ||
$value == 'ACCEPTED' ||
$value == 'DECLINED' ||
$value == 'TENTATIVE'
143 ||
$value == 'DELEGATED' ||
$value == 'COMPLETED' ||
$value == 'IN-PROCESS' ||
rfc2445_is_xname($value));
146 return ($value == 'NEEDS-ACTION' ||
$value == 'ACCEPTED' ||
$value == 'DECLINED' ||
rfc2445_is_xname($value));
153 $value = strtoupper($value);
154 return ($value == 'THISANDPRIOR' ||
$value == 'THISANDFUTURE');
158 $value = strtoupper($value);
159 return ($value == 'START' ||
$value == 'END');
163 $value = strtoupper($value);
164 return ($value == 'PARENT' ||
$value == 'CHILD' ||
$value == 'SIBLING' ||
rfc2445_is_xname($value));
168 $value = strtoupper($value);
169 return ($value == 'CHAIR' ||
$value == 'REQ-PARTICIPANT' ||
$value == 'OPT-PARTICIPANT' ||
$value == 'NON-PARTICIPANT' ||
rfc2445_is_xname($value));
173 $value = strtoupper($value);
174 return ($value == 'TRUE' ||
$value == 'FALSE');
181 return (strcspn($value, '";:,') == strlen($value));
185 $value = strtoupper($value);
186 return ($value == 'BINARY' ||
$value == 'BOOLEAN' ||
$value == 'CAL-ADDRESS' ||
$value == 'DATE' ||
187 $value == 'DATE-TIME' ||
$value == 'DURATION' ||
$value == 'FLOAT' ||
$value == 'INTEGER' ||
188 $value == 'PERIOD' ||
$value == 'RECUR' ||
$value == 'TEXT' ||
$value == 'TIME' ||
189 $value == 'URI' ||
$value == 'UTC-OFFSET' ||
rfc2445_is_xname($value));
194 function do_value_formatting($parameter, $value) {
196 // Parameters of type CAL-ADDRESS or URI MUST be double-quoted
199 case 'DELEGATED-FROM':
203 return '"'.$value.'"';
206 // Textual parameter types must be double quoted if they contain COLON, SEMICOLON
207 // or COMMA. Quoting always sounds easier and standards-conformant though.
209 return '"'.$value.'"';
212 // Parameters with enumerated legal values, just make them all caps
225 return strtoupper($value);
228 // Parameters we shouldn't be messing with
235 function undo_value_formatting($parameter, $value) {