/** * Set data and parse for properties * * @param string data The data */ public function setData($data) { static $trans; parent::setData($data); // Get the NamespacePrefix $ns = $this->getNamespacePrefix(); // Select properties which should be set foreach (array(FALSE => $this->getNode('/' . $ns . ':propertyupdate/' . $ns . ':set/' . $ns . ':prop'), TRUE => $this->getNode('/' . $ns . ':propertyupdate/' . $ns . ':remove/' . $ns . ':prop')) as $remove => $propupdate) { if (!$propupdate) { continue; } // Copied from WebdavPropFindRequest::setData() foreach ($propupdate->children as $node) { $name = $node->getName(); $ns = 'xmlns'; $nsprefix = ''; if (($p = strpos($name, ':')) !== FALSE) { $ns .= ':' . ($nsprefix = substr($name, 0, $p)); $name = substr($name, $p + 1); } $p = new WebdavProperty($name, $this->decode($node->getContent())); if ($nsname = $node->getAttribute($ns)) { $p->setNamespaceName($nsname); if ($nsprefix) { $p->setNamespacePrefix($nsprefix); } } $this->addProperty($p, $remove); } } }
/** * Set data and parse for properties * * @param string data The data */ public function setData($data) { parent::setData($data); // Set properties if (!$this->getNode('/propfind/allprop') && ($propfind = $this->getNode('/propfind/prop'))) { foreach ($propfind->children as $node) { $name = $node->getName(); $ns = 'xmlns'; $nsprefix = ''; if (($p = strpos($name, ':')) !== FALSE) { $ns .= ':' . ($nsprefix = substr($name, 0, $p)); $name = substr($name, $p + 1); } $p = new WebdavProperty($name); if ($nsname = $node->getAttribute($ns)) { $p->setNamespaceName($nsname); if ($nsprefix) { $p->setNamespacePrefix($nsprefix); } } $this->addProperty($p); } } }
/** * Add Well Known Properties * */ protected function _calcProperties() { $etag = md5($this->href); $etag = sprintf('%s-%s-%s', substr($etag, 0, 7), substr($etag, 7, 4), substr($etag, 11, 8)); foreach (array('creationdate' => array('value' => $this->creationDate, 'ns' => 'DAV:'), 'getlastmodified' => array('value' => $this->modifiedDate, 'ns' => 'DAV:'), 'getcontentlength' => array('value' => $this->contentLength, 'ns' => 'DAV:'), 'getcontenttype' => array('value' => $this->contentType, 'ns' => 'DAV:'), 'isfolder' => array('value' => WEBDAV_COLLECTION == $this->resourceType, 'ns' => 'DAV:'), 'executable' => array('value' => WEBDAV_COLLECTION != $this->resourceType ? FALSE : NULL, 'ns' => 'http://apache.org/dav/props/'), 'displayname' => array('value' => basename($this->href), 'ns' => 'DAV:'), 'nautilus-treat-as-directory' => array('value' => WEBDAV_COLLECTION == $this->resourceType, 'ns' => 'http://services.eazel.com/namespaces'), 'getlastmodified' => array('value' => $this->modifiedDate, 'ns' => 'DAV:'), 'getetag' => array('value' => WEBDAV_COLLECTION != $this->resourceType ? $etag : NULL, 'ns' => 'DAV:')) as $name => $propDef) { if ($propDef['value'] === NULL) { continue; } $p = new WebdavProperty($name, $propDef['value']); $p->setNamespaceName($propDef['ns']); $p->setProtected(TRUE); $this->addProperty($p); } }