From: <ja...@us...> - 2006-04-23 20:09:56
|
Update of /cvsroot/phpicalendar/phpicalendar/lib/HTTP/CalDAV/Tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8771/lib/HTTP/CalDAV/Tools Modified Files: ICalendarParser.php Log Message: * Fixed "value" syntax problem * Fixed start offset problem * Some code tidying Index: ICalendarParser.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/lib/HTTP/CalDAV/Tools/ICalendarParser.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ICalendarParser.php 22 Apr 2006 22:50:24 -0000 1.2 --- ICalendarParser.php 23 Apr 2006 20:09:50 -0000 1.3 *************** *** 51,54 **** --- 51,70 ---- /** + * Line of input + * + * @var string + * @access private + */ + var $_line; + + /** + * Offset of line + * + * @var int + * @access private + */ + var $_offset; + + /** * Success state flag * *************** *** 56,60 **** * @access public */ ! var $success = false; /** --- 72,76 ---- * @access public */ ! var $success = true; /** *************** *** 83,92 **** /** ! * Begin offset stack for tracking begin offsets of nested components * * @var array * @access private */ ! var $_beginOffsetStack = array(); /** --- 99,108 ---- /** ! * Begin offset stack for tracking start offsets of nested components * * @var array * @access private */ ! var $_startOffsetStack = array(); /** *************** *** 116,119 **** --- 132,150 ---- /** + * 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 * *************** *** 124,136 **** { $this->_handle = $handle; - $this->success = true; $this->_offsetStack[] = $offsets; ! $this->_valueStack[] = $value; $this->_filterStack[] = $filters; while ($this->success && ! ($offset = ftell($this->_handle)) !== false && ! ($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 (array_shift($this->_offsetStack[count($this->_offsetStack) - 1]['offsets']) !== null) { if (fseek($this->_offsetStack[count($this->_offsetStack) - 1]['offsets'][0][0])) { --- 155,168 ---- { $this->_handle = $handle; $this->_offsetStack[] = $offsets; ! ! // FIXME Separate comps & props stacks? ! $this->_valueStack[] = array('comps' => $value); $this->_filterStack[] = $filters; while ($this->success && ! ($this->_offset = ftell($this->_handle)) !== false && ! ($this->_line = fgets($this->_handle, 4096)) !== false) { if (is_array($this->_offsetStack[count($this->_offsetStack) - 1]['offsets'])) { ! 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])) { *************** *** 158,165 **** } ! $line = explode(':', trim($line)); if ($line[0] == 'BEGIN') { ! $this->_beginComp($line[1]); continue; } --- 190,197 ---- } ! $line = explode(':', trim($this->_line)); if ($line[0] == 'BEGIN') { ! $this->_startComp($line[1]); continue; } *************** *** 188,192 **** } ! function _beginComp($name) { if (is_array($this->_valueStack[count($this->_valueStack) - 1]['comps']) && --- 220,224 ---- } ! function _startComp($name) { if (is_array($this->_valueStack[count($this->_valueStack) - 1]['comps']) && *************** *** 219,223 **** $this->_compStack[] = new $class; ! $this->_beginOffsetStack[] = $offset; $this->_offsetStack[] = $this->_offsetStack[count($this->_offsetStack) - 1]['comps'][$name]; $this->_valueStack[] = $this->_valueStack[count($this->_valueStack) - 1]['comps'][$name]; --- 251,255 ---- $this->_compStack[] = new $class; ! $this->_startOffsetStack[] = $this->_offset; $this->_offsetStack[] = $this->_offsetStack[count($this->_offsetStack) - 1]['comps'][$name]; $this->_valueStack[] = $this->_valueStack[count($this->_valueStack) - 1]['comps'][$name]; *************** *** 237,241 **** 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->_offsetStack); array_pop($this->_valueStack); --- 269,273 ---- 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->_startOffsetStack); array_pop($this->_offsetStack); array_pop($this->_valueStack); *************** *** 258,262 **** $this->comps[] = array_pop($this->_compStack); ! $this->offsets[] = array(array_pop($this->_beginOffsetStack), $offset); array_pop($this->_offsetStack); array_pop($this->_valueStack); --- 290,294 ---- $this->comps[] = array_pop($this->_compStack); ! $this->offsets[] = array(array_pop($this->_startOffsetStack), $offset); array_pop($this->_offsetStack); array_pop($this->_valueStack); |