From: <ja...@us...> - 2006-04-13 21:14:20
|
Update of /cvsroot/phpicalendar/phpicalendar/lib/HTTP/CalDAV In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18717/lib/HTTP/CalDAV Modified Files: Server.php Log Message: * Half way through filter support for calendar-query REPORTs * About to normalize report_response_helper with propfind_response_helper Index: Server.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/lib/HTTP/CalDAV/Server.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Server.php 13 Apr 2006 05:10:24 -0000 1.2 --- Server.php 13 Apr 2006 21:14:17 -0000 1.3 *************** *** 82,85 **** --- 82,86 ---- $options['props'] = $parser->props; + $options['filters'] = $parser->filters; return true; *************** *** 210,215 **** method_exists($this, 'get')) { ! $prop = $this->_calendarData($file['path'], ! $reqprop['value']); if (isset($prop)) { $status = '200 OK'; --- 211,215 ---- method_exists($this, 'get')) { ! $prop = $this->_calendarData($reqprop, $file, $options); if (isset($prop)) { $status = '200 OK'; *************** *** 289,301 **** } ! function _calendarData($path, $data=null, $filter=null) { ! if (is_array($data['comps']) && ! !isset($data['comps']['VCALENDAR'])) { ! return HTTP_CalDAV_Server::calDavProp('calendar-data'); ! } $options = array(); ! $options['path'] = $path; $status = $this->get($options); --- 289,298 ---- } ! function _calendarData($reqprop, $file, $options) { ! $filters = $options['filters']; $options = array(); ! $options['path'] = $file['path']; $status = $this->get($options); *************** *** 310,315 **** if ($options['mimetype'] != 'text/calendar') { ! return HTTP_CalDAV_Server::calDavProp('calendar-data', null, ! '403 Forbidden'); } --- 307,311 ---- if ($options['mimetype'] != 'text/calendar') { ! return; } *************** *** 322,336 **** } - if (($line = fgets($handle, 4096)) === false) { - return; - } - - if (trim($line) != 'BEGIN:VCALENDAR') { - return; - } - if (!($value = HTTP_CalDAV_Server::_parseComponent($handle, ! 'VCALENDAR', is_array($data['comps']) ? ! $data['comps']['VCALENDAR'] : null))) { return; } --- 318,323 ---- } if (!($value = HTTP_CalDAV_Server::_parseComponent($handle, ! $reqprop['value'], $filters))) { return; } *************** *** 339,370 **** } ! function _parseComponent($handle, $name, $data=null, $filter=null) { ! $className = 'iCalendar_' . ltrim(strtolower($name), 'v'); ! if ($name == 'VCALENDAR') { ! $className = 'iCalendar'; ! } ! ! if (!class_exists($className)) { ! return; ! } ! $component = new $className; ! while (($line = fgets($handle, 4096)) !== false) { $line = explode(':', trim($line)); if ($line[0] == 'END') { ! if ($line[1] != $name) { return; } ! return $component; } if ($line[0] == 'BEGIN') { ! if (is_array($data['comps']) && ! !isset($data['comps'][$line[1]])) { ! while (($l = fgets($handle, 4096)) !== false) { ! if (trim($l) == "END:$line[1]") { continue (2); } --- 326,379 ---- } ! function _parseComponent($handle, $value=null, $filters=null) { ! $components = array(); ! $compValues = array($value); ! $compFilters = array($filters); while (($line = fgets($handle, 4096)) !== false) { $line = explode(':', trim($line)); if ($line[0] == 'END') { ! if ($line[1] != $components[key($components)]->name) { return; } ! if (is_array($compFilters[key($compFilters)]['filters'])) { ! foreach ($compFilters[key($compFilters)]['filters'] as $filter) { ! print $filter['name']; ! if ($filter['name'] == 'time-range') { ! if ($filter['value']['start'] > $components[key($components)]->properties['DTEND'][0]->value || $filter['value']['end'] < $components[key($components)]->properties['DTSTART'][0]->value) { ! array_pop($compValues); ! array_pop($compFilters); ! continue; ! } ! } ! } ! } ! ! // If we're about to pop the root component, we ignore the rest ! // of our input ! if (count($components) == 1) { ! return array_pop($components); ! } ! ! if (!$components[key($components)]->add_component(array_pop($components))) { ! return; ! } ! ! array_pop($compValues); ! array_pop($compFilters); ! continue; } if ($line[0] == 'BEGIN') { ! $compName = $line[1]; ! var_dump($compName); ! var_dump($compValues); ! var_dump($compValues[key($compValues)]); ! if (is_array($compValues[key($compValues)]['comps']) && ! !isset($compValues[key($compValues)]['comps'][$compName])) { ! while (($line = fgets($handle, 4096)) !== false) { ! if (trim($line) == "END:$compName") { continue (2); } *************** *** 374,382 **** } ! if (!($childComponent = HTTP_CalDAV_Server::_parseComponent( ! $handle, $line[1], is_array($data['comps']) ? ! $data['comps'][$line[1]] : null))) { ! while (($l = fgets($handle, 4096)) !== false) { ! if (trim($l) == "END:$line[1]") { continue (2); } --- 383,394 ---- } ! $className = 'iCalendar_' . ltrim(strtolower($compName), 'v'); ! if ($line[1] == 'VCALENDAR') { ! $className = 'iCalendar'; ! } ! ! if (!class_exists($className)) { ! while (($line = fgets($handle, 4096)) !== false) { ! if (trim($line) == "END:$compName") { continue (2); } *************** *** 386,409 **** } ! if (!$component->add_component($childComponent)) { ! return; ! } ! continue; } $line[0] = explode(';=', $line[0]); ! $prop_name = array_shift($line[0]); if (is_array($data['props']) && ! !in_array($prop_name, $data['props'])) { continue; } $params = array(); ! while (($param_name = array_shift($line[0])) && ! ($param_value = array_shift($line[0]))) { ! $params[$param_name] = $param_value; } ! $component->add_property($prop_name, $line[1], $params); } } --- 398,422 ---- } ! $components[] = new $className; ! end($components); ! $compValues[] = $compValues[key($compValues)]['comps'][$compName]; ! end($components); ! $compFilters[] = $compFilters[key($compFilters)]['comps'][$compName]; ! end($components); continue; } $line[0] = explode(';=', $line[0]); ! $propName = array_shift($line[0]); if (is_array($data['props']) && ! !in_array($propName, $data['props'])) { continue; } $params = array(); ! while (!empty($line[0])) { ! $params[array_shift($line[0])] = array_shift($line[0]); } ! $components[key($components)]->add_property($propName, $line[1], $params); } } |