Esempio n. 1
0
 /**
  * @expectedException InvalidArgumentException
  */
 function testParseClarkNotationFail()
 {
     Sabre_DAV_XMLUtil::parseClarkNotation('}foo');
 }
Esempio n. 2
0
 /**
  * Updates a list of properties on the server
  *
  * The list of properties must have clark-notation properties for the keys,
  * and the actual (string) value for the value. If the value is null, an
  * attempt is made to delete the property.
  *
  * @todo Must be building the request using the DOM, and does not yet
  *       support complex properties.
  * @param string $url
  * @param array $properties
  * @return void
  */
 public function propPatch($url, array $properties)
 {
     $body = '<?xml version="1.0"?>' . "\n";
     $body .= '<d:propertyupdate xmlns:d="DAV:">' . "\n";
     foreach ($properties as $propName => $propValue) {
         list($namespace, $elementName) = Sabre_DAV_XMLUtil::parseClarkNotation($propName);
         if ($propValue === null) {
             $body .= "<d:remove><d:prop>\n";
             if ($namespace === 'DAV:') {
                 $body .= '    <d:' . $elementName . ' />' . "\n";
             } else {
                 $body .= "    <x:" . $elementName . " xmlns:x=\"" . $namespace . "\"/>\n";
             }
             $body .= "</d:prop></d:remove>\n";
         } else {
             $body .= "<d:set><d:prop>\n";
             if ($namespace === 'DAV:') {
                 $body .= '    <d:' . $elementName . '>';
             } else {
                 $body .= "    <x:" . $elementName . " xmlns:x=\"" . $namespace . "\">";
             }
             // Shitty.. i know
             $body .= htmlspecialchars($propValue, ENT_NOQUOTES, 'UTF-8');
             if ($namespace === 'DAV:') {
                 $body .= '</d:' . $elementName . '>' . "\n";
             } else {
                 $body .= "</x:" . $elementName . ">\n";
             }
             $body .= "</d:prop></d:set>\n";
         }
     }
     $body .= '</d:propertyupdate>';
     $this->request('PROPPATCH', $url, $body, array('Content-Type' => 'application/xml'));
 }