aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJack Bates <jablko@users.sourceforge.net>2006-04-23 20:09:50 +0000
committerJack Bates <jablko@users.sourceforge.net>2006-04-23 20:09:50 +0000
commitaf1a7d974b0f8616faca9073a734de51fbd5ea04 (patch)
tree0f9d5d05395ccea8bec6f6091a6a25ae0bc1310f /lib
parent6997e17242bbb5a6d41de5cbf94cdfb2e739cbd3 (diff)
downloadphpicalendar-af1a7d974b0f8616faca9073a734de51fbd5ea04.tar.gz
phpicalendar-af1a7d974b0f8616faca9073a734de51fbd5ea04.tar.bz2
phpicalendar-af1a7d974b0f8616faca9073a734de51fbd5ea04.zip
* Fixed "value" syntax problem
* Fixed start offset problem * Some code tidying
Diffstat (limited to 'lib')
-rw-r--r--lib/HTTP/CalDAV/Tools/ICalendarParser.php64
-rw-r--r--lib/bennu/iCalendar_components.php8
-rw-r--r--lib/bennu/iCalendar_parameters.php5
-rw-r--r--lib/bennu/iCalendar_properties.php13
4 files changed, 54 insertions, 36 deletions
diff --git a/lib/HTTP/CalDAV/Tools/ICalendarParser.php b/lib/HTTP/CalDAV/Tools/ICalendarParser.php
index 803b5de..1d80d8d 100644
--- a/lib/HTTP/CalDAV/Tools/ICalendarParser.php
+++ b/lib/HTTP/CalDAV/Tools/ICalendarParser.php
@@ -20,7 +20,7 @@
* @author Jack Bates <ms419@freezone.co.uk>
* @copyright 2006 The PHP Group
* @license PHP License 3.0 http://www.php.net/license/3_0.txt
- * @version CVS: $Id: ICalendarParser.php,v 1.2 2006/04/22 22:50:24 jablko Exp $
+ * @version CVS: $Id: ICalendarParser.php,v 1.3 2006/04/23 20:09:50 jablko Exp $
* @link http://pear.php.net/package/HTTP_CalDAV_Server
* @see HTTP_WebDAV_Server
*/
@@ -35,7 +35,7 @@
* @author Jack Bates <ms419@freezone.co.uk>
* @copyright 2006 The PHP Group
* @license PHP License 3.0 http://www.php.net/license/3_0.txt
- * @version CVS: $Id: ICalendarParser.php,v 1.2 2006/04/22 22:50:24 jablko Exp $
+ * @version CVS: $Id: ICalendarParser.php,v 1.3 2006/04/23 20:09:50 jablko Exp $
* @link http://pear.php.net/package/HTTP_CalDAV_Server
* @see HTTP_WebDAV_Server
*/
@@ -50,12 +50,28 @@ class ICalendarParser
var $_handle;
/**
+ * Line of input
+ *
+ * @var string
+ * @access private
+ */
+ var $_line;
+
+ /**
+ * Offset of line
+ *
+ * @var int
+ * @access private
+ */
+ var $_offset;
+
+ /**
* Success state flag
*
* @var bool
* @access public
*/
- var $success = false;
+ var $success = true;
/**
* Parsed components are collected here in post-order
@@ -82,12 +98,12 @@ class ICalendarParser
var $_compStack = array();
/**
- * Begin offset stack for tracking begin offsets of nested components
+ * Begin offset stack for tracking start offsets of nested components
*
* @var array
* @access private
*/
- var $_beginOffsetStack = array();
+ var $_startOffsetStack = array();
/**
* Offsets stack for parsing within specific ranges
@@ -115,6 +131,21 @@ class ICalendarParser
var $_filterStack = array();
/**
+ * Parse RFC2445 date-time
+ *
+ * May eventually get moved someplace more appropriate
+ * TODO Timezone support
+ *
+ * @param string RFC2445 date-time
+ * @return int timestamp
+ * @access public
+ */
+ function datetime_to_timestamp($datetime)
+ {
+ return gmmktime(substr($datetime, 9, 2), substr($datetime, 11, 2), substr($datetime, 13, 2), substr($datetime, 4, 2), substr($datetime, 6, 2), substr($datetime, 0, 4));
+ }
+
+ /**
* Constructor
*
* @param resource input stream handle
@@ -123,15 +154,16 @@ class ICalendarParser
function ICalendarParser($handle, $offsets=null, $value=null, $filters=null)
{
$this->_handle = $handle;
- $this->success = true;
$this->_offsetStack[] = $offsets;
- $this->_valueStack[] = $value;
+
+ // FIXME Separate comps & props stacks?
+ $this->_valueStack[] = array('comps' => $value);
$this->_filterStack[] = $filters;
while ($this->success &&
- ($offset = ftell($this->_handle)) !== false &&
- ($line = fgets($this->_handle, 4096)) !== false) {
+ ($this->_offset = ftell($this->_handle)) !== false &&
+ ($this->_line = fgets($this->_handle, 4096)) !== false) {
if (is_array($this->_offsetStack[count($this->_offsetStack) - 1]['offsets'])) {
- if ($offset > $this->_offsetStack[count($this->_offsetStack) - 1]['offsets'][0][1]) {
+ if ($this->_offset > $this->_offsetStack[count($this->_offsetStack) - 1]['offsets'][0][1]) {
if (array_shift($this->_offsetStack[count($this->_offsetStack) - 1]['offsets']) !== null) {
if (fseek($this->_offsetStack[count($this->_offsetStack) - 1]['offsets'][0][0])) {
$this->success = false;
@@ -157,10 +189,10 @@ class ICalendarParser
}
}
- $line = explode(':', trim($line));
+ $line = explode(':', trim($this->_line));
if ($line[0] == 'BEGIN') {
- $this->_beginComp($line[1]);
+ $this->_startComp($line[1]);
continue;
}
@@ -187,7 +219,7 @@ class ICalendarParser
}
}
- function _beginComp($name)
+ function _startComp($name)
{
if (is_array($this->_valueStack[count($this->_valueStack) - 1]['comps']) &&
!isset($this->_valueStack[count($this->_valueStack) - 1]['comps'][$name])) {
@@ -218,7 +250,7 @@ class ICalendarParser
}
$this->_compStack[] = new $class;
- $this->_beginOffsetStack[] = $offset;
+ $this->_startOffsetStack[] = $this->_offset;
$this->_offsetStack[] = $this->_offsetStack[count($this->_offsetStack) - 1]['comps'][$name];
$this->_valueStack[] = $this->_valueStack[count($this->_valueStack) - 1]['comps'][$name];
$this->_filterStack[] = $this->_filterStack[count($this->_filterStack) - 1]['comps'][$name];
@@ -236,7 +268,7 @@ class ICalendarParser
if ($filter['name'] == 'time-range') {
if ($filter['value']['start'] > $this->_compStack[count($this->_compStack) - 1]->properties['DTEND'][0]->value || $filter['value']['end'] < $this->_compStack[count($this->_compStack) - 1]->properties['DTSTART'][0]->value) {
array_pop($this->_compStack);
- array_pop($this->_beginOffsetStack);
+ array_pop($this->_startOffsetStack);
array_pop($this->_offsetStack);
array_pop($this->_valueStack);
array_pop($this->_filterStack);
@@ -257,7 +289,7 @@ class ICalendarParser
}
$this->comps[] = array_pop($this->_compStack);
- $this->offsets[] = array(array_pop($this->_beginOffsetStack), $offset);
+ $this->offsets[] = array(array_pop($this->_startOffsetStack), $offset);
array_pop($this->_offsetStack);
array_pop($this->_valueStack);
array_pop($this->_filterStack);
diff --git a/lib/bennu/iCalendar_components.php b/lib/bennu/iCalendar_components.php
index 13abac5..4b51f58 100644
--- a/lib/bennu/iCalendar_components.php
+++ b/lib/bennu/iCalendar_components.php
@@ -1,4 +1,4 @@
-<?php // $Id: iCalendar_components.php,v 1.2 2006/04/13 21:14:17 jablko Exp $
+<?php // $Id: iCalendar_components.php,v 1.3 2006/04/23 20:09:50 jablko Exp $
/**
* BENNU - PHP iCalendar library
@@ -9,7 +9,7 @@
* See http://bennu.sourceforge.net/ for more information and downloads.
*
* @author Ioannis Papaioannou
- * @version $Id: iCalendar_components.php,v 1.2 2006/04/13 21:14:17 jablko Exp $
+ * @version $Id: iCalendar_components.php,v 1.3 2006/04/23 20:09:50 jablko Exp $
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/
@@ -205,7 +205,6 @@ class iCalendar_component {
return $string;
}
-
}
class iCalendar extends iCalendar_component {
@@ -227,7 +226,6 @@ class iCalendar extends iCalendar_component {
);
parent::construct();
}
-
}
class iCalendar_event extends iCalendar_component {
@@ -306,7 +304,6 @@ class iCalendar_event extends iCalendar_component {
}
return true;
}
-
}
class iCalendar_todo extends iCalendar_component {
@@ -388,7 +385,6 @@ class iCalendar_timezone extends iCalendar_component {
parent::construct();
}
-
}
// REMINDER: DTEND must be later than DTSTART for all components which support both
diff --git a/lib/bennu/iCalendar_parameters.php b/lib/bennu/iCalendar_parameters.php
index ab96654..70d528c 100644
--- a/lib/bennu/iCalendar_parameters.php
+++ b/lib/bennu/iCalendar_parameters.php
@@ -1,4 +1,4 @@
-<?php // $Id: iCalendar_parameters.php,v 1.1 2006/04/13 05:10:24 jablko Exp $
+<?php // $Id: iCalendar_parameters.php,v 1.2 2006/04/23 20:09:50 jablko Exp $
/**
* BENNU - PHP iCalendar library
@@ -9,7 +9,7 @@
* See http://bennu.sourceforge.net/ for more information and downloads.
*
* @author Ioannis Papaioannou
- * @version $Id: iCalendar_parameters.php,v 1.1 2006/04/13 05:10:24 jablko Exp $
+ * @version $Id: iCalendar_parameters.php,v 1.2 2006/04/23 20:09:50 jablko Exp $
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/
@@ -234,7 +234,6 @@ class iCalendar_parameter {
function undo_value_formatting($parameter, $value) {
}
-
}
?>
diff --git a/lib/bennu/iCalendar_properties.php b/lib/bennu/iCalendar_properties.php
index bec729e..d19cbf7 100644
--- a/lib/bennu/iCalendar_properties.php
+++ b/lib/bennu/iCalendar_properties.php
@@ -1,4 +1,4 @@
-<?php // $Id: iCalendar_properties.php,v 1.1 2006/04/13 05:10:24 jablko Exp $
+<?php // $Id: iCalendar_properties.php,v 1.2 2006/04/23 20:09:50 jablko Exp $
/**
* BENNU - PHP iCalendar library
@@ -9,7 +9,7 @@
* See http://bennu.sourceforge.net/ for more information and downloads.
*
* @author Ioannis Papaioannou
- * @version $Id: iCalendar_properties.php,v 1.1 2006/04/13 05:10:24 jablko Exp $
+ * @version $Id: iCalendar_properties.php,v 1.2 2006/04/23 20:09:50 jablko Exp $
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/
@@ -282,7 +282,6 @@ class iCalendar_property_version extends iCalendar_property {
function is_valid_value($value) {
return($value === '2.0' || $value === 2.0);
}
-
}
// 4.8.1 Descriptive Component Properties
@@ -430,7 +429,6 @@ class iCalendar_property_geo extends iCalendar_property {
return false;
}
-
}
class iCalendar_property_location extends iCalendar_property {
@@ -466,7 +464,6 @@ class iCalendar_property_percent_complete extends iCalendar_property {
$value = intval($value);
return ($value >= 0 && $value <= 100);
}
-
}
class iCalendar_property_priority extends iCalendar_property {
@@ -533,7 +530,6 @@ class iCalendar_property_status extends iCalendar_property {
return in_array($value, $allowed);
}
-
}
class iCalendar_property_summary extends iCalendar_property {
@@ -818,7 +814,6 @@ class iCalendar_property_attendee extends iCalendar_property {
return false;
}
-
}
class iCalendar_property_contact extends iCalendar_property {
@@ -902,7 +897,6 @@ class iCalendar_property_recurrence_id extends iCalendar_property {
return true;
}
-
}
class iCalendar_property_related_to extends iCalendar_property {
@@ -979,7 +973,6 @@ class iCalendar_property_exdate extends iCalendar_property {
return true;
}
-
}
class iCalendar_property_exrule extends iCalendar_property {
@@ -1021,7 +1014,6 @@ class iCalendar_property_rdate extends iCalendar_property {
return true;
}
-
}
class iCalendar_property_rrule extends iCalendar_property {
@@ -1277,7 +1269,6 @@ class iCalendar_property_request_status extends iCalendar_property {
return false;
}
-
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy