예제 #1
0
    /**
     * Returns all tags for a given user
     *
     * @param string $user
     * @return array
     */
    private function requestTagsForUser($user)
    {
        try {
            $request = $this->client->createRequest('PROPFIND', $this->baseUrl . '/remote.php/dav/systemtags/', ['body' => '<?xml version="1.0"?>
<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
  <d:prop>
    <oc:id />
    <oc:display-name />
    <oc:user-visible />
    <oc:user-assignable />
  </d:prop>
</d:propfind>', 'auth' => [$user, $this->getPasswordForUser($user)], 'headers' => ['Content-Type' => 'application/json']]);
            $this->response = $this->client->send($request);
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            $this->response = $e->getResponse();
        }
        $tags = [];
        $service = new Sabre\Xml\Service();
        $parsed = $service->parse($this->response->getBody()->getContents());
        foreach ($parsed as $entry) {
            $singleEntry = $entry['value'][1]['value'][0]['value'];
            if (empty($singleEntry[0]['value'])) {
                continue;
            }
            $tags[$singleEntry[0]['value']] = ['display-name' => $singleEntry[1]['value'], 'user-visible' => $singleEntry[2]['value'], 'user-assignable' => $singleEntry[3]['value']];
        }
        return $tags;
    }
예제 #2
0
    function testMapValueObject()
    {
        $input = <<<XML
<?xml version="1.0"?>
<order xmlns="http://sabredav.org/ns">
 <id>1234</id>
 <amount>99.99</amount>
 <description>black friday deal</description>
 <status>
  <id>5</id>
  <label>processed</label>
 </status>
</order>

XML;
        $ns = 'http://sabredav.org/ns';
        $orderService = new \Sabre\Xml\Service();
        $orderService->mapValueObject('{' . $ns . '}order', 'Sabre\\Xml\\Order');
        $orderService->mapValueObject('{' . $ns . '}status', 'Sabre\\Xml\\OrderStatus');
        $orderService->namespaceMap[$ns] = null;
        $order = $orderService->parse($input);
        $expected = new Order();
        $expected->id = 1234;
        $expected->amount = 99.98999999999999;
        $expected->description = 'black friday deal';
        $expected->status = new OrderStatus();
        $expected->status->id = 5;
        $expected->status->label = 'processed';
        $this->assertEquals($expected, $order);
        $writtenXml = $orderService->writeValueObject($order);
        $this->assertEquals($input, $writtenXml);
    }
예제 #3
0
파일: grb2osm.php 프로젝트: gplv2/grb2osm
    /*
    afdak
    ingezonken garagetoegang
    loopbrug
    trap
    uitbreiding
    verdieping
    verheven garagetoegang
    zichtbare onderkeldering
    */
    $search = array('LBLTYPE', 'OIDN', 'OPNDATUM', 'hoofdgebouw', 'bijgebouw', 'afdak', 'ingezonken garagetoegang', 'verheven garagetoegang');
    $replace = array('building', 'source:geometry:oidn', 'source:geometry:date', 'house', 'shed', 'roof', 'garage1', 'garage2');
    $xml = str_replace($search, $replace, $xml);
    $osmtool->logtrace(3, sprintf("[%s] - Done.", __METHOD__));
    $osmtool->logtrace(3, sprintf("[%s] - Parsing XML ...", __METHOD__));
    $service = new Sabre\Xml\Service();
    $result = $service->parse($xml, 'osm');
    $osmtool->logtrace(3, sprintf("[%s] - Done ...", __METHOD__));
} else {
    $osmtool->logtrace(3, sprintf("[%s] - File %s not found", __METHOD__, $osm_file));
    exit;
}
/*

  Ways look like this in the file:

  <way id='-14375' action='modify' visible='true'>
  <nd ref='-14369' />
  <nd ref='-14370' />
  <nd ref='-14371' />
  <nd ref='-14372' />
예제 #4
0
    /**
     * @Then As :user load all the comments of the file named :fileName it should return :statusCode
     */
    public function asLoadloadAllTheCommentsOfTheFileNamedItShouldReturn($user, $fileName, $statusCode)
    {
        $fileId = $this->getFileIdForPath($fileName);
        $url = $this->baseUrl . '/remote.php/dav/comments/files/' . $fileId . '/';
        try {
            $client = new \GuzzleHttp\Client();
            $res = $client->createRequest('REPORT', $url, ['body' => '<?xml version="1.0" encoding="utf-8" ?>
<oc:filter-comments xmlns:D="DAV:" xmlns:oc="http://owncloud.org/ns">
    <oc:limit>200</oc:limit>
    <oc:offset>0</oc:offset>
</oc:filter-comments>
', 'auth' => [$user, '123456'], 'headers' => ['Content-Type' => 'application/json']]);
            $res = $client->send($res);
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            $res = $e->getResponse();
        }
        if ($res->getStatusCode() !== (int) $statusCode) {
            throw new \Exception("Response status code was not {$statusCode} (" . $res->getStatusCode() . ")");
        }
        if ($res->getStatusCode() === 207) {
            $service = new Sabre\Xml\Service();
            $this->response = $service->parse($res->getBody()->getContents());
            $this->commentId = (int) $this->response[0]['value'][2]['value'][0]['value'][0]['value'];
        }
    }
예제 #5
-1
 /**
  * @Then The webdav checksum should be empty
  */
 public function theWebdavChecksumShouldBeEmpty()
 {
     $service = new Sabre\Xml\Service();
     $parsed = $service->parse($this->response->getBody()->getContents());
     /*
      * Fetch the checksum array
      * Maybe we want to do this a bit cleaner ;)
      */
     $status = $parsed[0]['value'][1]['value'][1]['value'];
     if ($status !== 'HTTP/1.1 404 Not Found') {
         throw new \Exception("Expected 'HTTP/1.1 404 Not Found', got " . $status);
     }
 }