[Kolab-devel] PHP5 with kolab2...?
Andreas Hasenack
andreas at conectiva.com.br
Tue Aug 16 20:30:15 CEST 2005
On Mon, Aug 15, 2005 at 05:14:21PM -0300, Andreas Hasenack wrote:
> PHP Fatal error: Call to undefined function domxml_open_mem() in
> /var/www/html/kolab/freebusy/freebusy.class.php on line 338
>
> That function only exists for PHP4. There could be other errors related
> to PHP5, but this is the first obvious one I found.
Attached my first attempt at a patch to make freebusy in kolab2 use
php-dom (instead of php-domxml which is no longer available for PHP5).
I really don't know much php nor xml, so...
Things that come to mind:
- no error catching
- I couldn't find equivalents for all flags used in domxml_open_mem()
- during testing, a recurring event was different for one of the
participants: the creator had monday->saturday, while the lonely
participant had the whole week scheduled. I don't know if this patch
caused it and/or if it some other bad php5 interaction.
-------------- next part --------------
--- kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy.class.php.orig 2005-08-16 15:20:58.000000000 -0300
+++ kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy.class.php 2005-08-16 15:21:02.000000000 -0300
@@ -325,44 +325,52 @@
}
function getEventHash($xml_text) {
- $xmldoc = @domxml_open_mem($xml_text, DOMXML_LOAD_PARSING +
+/* $xmldoc = @domxml_open_mem($xml_text, DOMXML_LOAD_PARSING +
DOMXML_LOAD_COMPLETE_ATTRS + DOMXML_LOAD_SUBSTITUTE_ENTITIES +
DOMXML_LOAD_DONT_KEEP_BLANKS, $error);
-
+*/
+
+ $xmldoc = new DOMDocument;
+ $xmldoc->validateOnParse = true;
+ $xmldoc->preserveWhiteSpace = false;
+ $xmldoc->loadXML($xml_text);
+
+ /* XXX - how to catch errors in loadXML()?
if (!empty($error)) {
// There were errors parsing the XML data - abort
myLog( "Error parsing \"$xml_txt\": $error", RM_LOG_ERROR);
return false;
}
-
- $noderoot = $xmldoc->document_element();
- $childnodes = $noderoot->child_nodes();
+ */
+
+ $noderoot = $xmldoc->documentElement;
+ $childnodes = $noderoot->childNodes;
$event_hash = array();
// Build the event hash
foreach ($childnodes as $value) {
- //myLog("Looking at tag ".($value->tagname), RM_LOG_DEBUG);
- if( $value->tagname == 'recurrence' ) {
+ //myLog("Looking at tag ".($value->tagName), RM_LOG_DEBUG);
+ if( $value->tagName == 'recurrence' ) {
$rhash = array();
- $attrs = $value->attributes();
+ $attrs = $value->attributes;
foreach( $attrs as $attr ) {
//myLog("getEventHash setting rhash[".$attr->name."] = ".$attr->value, RM_LOG_DEBUG);
$rhash[$attr->name] = $attr->value;
}
- foreach( $value->child_nodes() as $v ) {
- if( $v->tagname == 'day' || $v->tagname == 'exclusion' ) {
- $rhash[$v->tagname][] = $v->get_content();
+ foreach( $value->childNodes as $v ) {
+ if( $v->tagName == 'day' || $v->tagName == 'exclusion' ) {
+ $rhash[$v->tagName][] = $v->nodeValue();
} else {
- $rhash[$v->tagname] = $v->get_content();
- if( $v->tagname == 'range' && $v->has_attribute('type') ) {
- $rhash['rangetype'] = $v->get_attribute('type');
+ $rhash[$v->tagName] = $v->nodeValue;
+ if( $v->tagName == 'range' && $v->hasAttribute('type') ) {
+ $rhash['rangetype'] = $v->getAttribute('type');
}
}
}
- $event_hash[$value->tagname] = $rhash;
+ $event_hash[$value->tagName] = $rhash;
} else {
- $event_hash[$value->tagname] = $value->get_content();
+ $event_hash[$value->tagName] = $value->nodeValue;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.kolab.org/pipermail/devel/attachments/20050816/fd1f86f9/attachment.sig>
More information about the devel
mailing list