/** * Returns the XML representation of a live property. * * Returns a DOMElement, representing the content of the given $property. * The newly created element is also appended as a child to the given * $parentElement. * * This method only takes care for {@link ezcWebdavGetContentTypeProperty} * and does not add the "charset=..." part to the generated XML output, * since Nautilus does not display this nicely. All other properties are * dispatched to the default {@link ezcWebdavPropertyHandler}. * * @param ezcWebdavLiveProperty $property * @param DOMElement $parentElement * @return DOMElement */ protected function serializeLiveProperty(ezcWebdavLiveProperty $property, DOMElement $parentElement) { switch (get_class($property)) { case 'ezcWebdavGetContentTypeProperty': $elementName = 'getcontenttype'; $elementValue = $property->mime !== null ? $property->mime : null; break; default: return parent::serializeLiveProperty($property, $parentElement); } $propertyElement = $parentElement->appendChild(ezcWebdavServer::getInstance()->xmlTool->createDomElement($parentElement->ownerDocument, $elementName, $property->namespace)); if ($elementValue instanceof DOMDocument) { $propertyElement->appendChild($dom->importNode($elementValue->documentElement, true)); } else { if (is_array($elementValue)) { foreach ($elementValue as $subValue) { $propertyElement->appendChild($subValue); } } else { if (is_scalar($elementValue)) { $propertyElement->nodeValue = $elementValue; } } } return $propertyElement; }
/** * Stores properties for a resource. * * Creates a new property storage file and stores the properties given for * the resource identified by $path. This depends on the affected resource * and the actual properties in the property storage. * * @param string $path * @param ezcWebdavBasicPropertyStorage $storage * @return void */ protected function storeProperties($path, ezcWebdavBasicPropertyStorage $storage) { $storagePath = $this->getPropertyStoragePath($path); // Create handler structure to read properties $handler = new ezcWebdavPropertyHandler($xml = new ezcWebdavXmlTool()); // Create new dom document with property storage for one namespace $doc = new DOMDocument('1.0'); $properties = $doc->createElement('properties'); $doc->appendChild($properties); // Store and store properties $handler->serializeProperties($storage, $properties); return $doc->save($storagePath); }
protected function storeProperties($path, ezcWebdavBasicPropertyStorage $storage) { $storagePath = $this->options->propertyStoragePath . '/properties-' . md5($path); print_debug("storeProperties method {$storagePath}\n"); // Create handler structure to read properties $handler = new ezcWebdavPropertyHandler($xml = new ezcWebdavXmlTool()); // Create new dom document with property storage for one namespace $doc = new DOMDocument('1.0'); $properties = $doc->createElement('properties'); $doc->appendChild($properties); $handler->serializeProperties($storage, $properties); print_debug("storeProperties method end\n"); return $doc->save($storagePath); }