Much simpler start, using new XML structure framework.

This commit is contained in:
Andrew McMillan 2006-12-19 16:52:24 +13:00
parent 3d7fd51319
commit a347233cab

View File

@ -10,54 +10,32 @@
*/
dbg_error_log("PROPPATCH", "method handler");
// if ( ! $request->AllowedTo('write-properties') ) {
// $request->DoResponse( 403 );
// }
$tree - new XMLTree();
foreach( $request->xml_tags AS $k => $v ) {
$fulltag = $v['tag'];
dbg_error_log("PROPPATCH", "Handling %s", $fulltag);
// dbg_log_array( "PROPPATCH", 'values', $v, true );
if ( $v['type'] == "open" ) {
echo "Entering $fulltag\n";
if ( isset($current) ) {
echo "Type of \$current is ".gettype($current)."\n";
$child = new XMLElement($fulltag);
$child->SetParent($current);
$current->AddSubTag($child);
$current =& $child;
}
else {
echo "Root of tree is $fulltag\n";
$root = new XMLElement($fulltag);
$current =& $root;
}
}
else if ( $v['type'] == "close" ) {
echo "Leaving $fulltag\n";
$parent =& $current->GetParent();
$current =& $parent;
}
else if ( $v['type'] == "complete" ) {
$value = $v['value'];
printf( "Adding '%s' with content '%s'\n", $fulltag, $value );
$child = new XMLElement($fulltag, $value);
$current->AddSubTag($child);
}
else {
printf( "Unhandled type '%s' for tag '%s'\n", $v['type'], $v['tag'] );
}
// echo $root->Render(). "\n";
// switch ( $fulltag ) {
if ( ! $request->AllowedTo('write-properties') ) {
$request->DoResponse( 403 );
}
$position = 0;
$xmltree = BuildXMLTree( $request->xml_tags, $position);
echo $root->Render(). "\n";
echo $xmltree->Render();
if ( $xmltree->GetTag() != "DAV::PROPERTYUPDATE" ) {
$request->DoResponse( 403 );
}
$tmp = $xmltree->GetPath("/DAV::PROPERTYUPDATE/DAV::SET/DAV::PROP");
$settings = array();
foreach( $tmp AS $k => $v ) {
printf("Content of %s is type %s\n", $v->GetTag(), gettype($v->GetContent()) );
foreach( $v->GetContent() AS $k1 => $setting ) {
$settings[$setting->GetTag()] = $setting->GetContent();
}
}
foreach( $settings AS $setting => $value ) {
printf("Setting '%s' is set to '%s'\n", $setting, $value);
}
exit(0);