当前位置: 首页>>代码示例>>PHP>>正文


PHP EasyRdf_Format::guessFormat方法代码示例

本文整理汇总了PHP中EasyRdf_Format::guessFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Format::guessFormat方法的具体用法?PHP EasyRdf_Format::guessFormat怎么用?PHP EasyRdf_Format::guessFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EasyRdf_Format的用法示例。


在下文中一共展示了EasyRdf_Format::guessFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addMock

 public function addMock($method, $uri, $body, $options = array())
 {
     $match = array();
     $match['method'] = $method;
     $match['uri'] = array();
     if (isset($options['callback'])) {
         $match['callback'] = $options['callback'];
         if (isset($options['callbackArgs'])) {
             $match['callbackArgs'] = $options['callbackArgs'];
         } else {
             $match['callbackArgs'] = array();
         }
     }
     if (!isset($uri)) {
         $match['uri'] = null;
     } else {
         $match['uri'] = strval($uri);
     }
     if ($body instanceof EasyRdf_Http_Response) {
         $response = $body;
     } else {
         if (isset($options['status'])) {
             $status = $options['status'];
         } else {
             $status = 200;
         }
         if (isset($options['headers'])) {
             $headers = $options['headers'];
         } else {
             $headers = array();
             $format = EasyRdf_Format::guessFormat($body);
             if (isset($format)) {
                 $headers['Content-Type'] = $format->getDefaultMimeType();
             }
             if (isset($body)) {
                 $headers['Content-Length'] = strlen($body);
             }
         }
         $response = new EasyRdf_Http_Response($status, $headers, $body);
     }
     $once = isset($options['once']) ? $options['once'] : false;
     $this->_mocks[] = array($match, $response, $once);
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:43,代码来源:MockClient.php

示例2: load

 /**
  * Load RDF data into the graph.
  *
  * If a URI is supplied, but no data then the data will
  * be fetched from the URI.
  *
  * The document type is optional and can be specified if it
  * can't be guessed or got from the HTTP headers.
  *
  * @param  string  $uri     The URI of the graph
  * @param  string  $data    Data for the graph
  * @param  string  $format  The document type of the data
  */
 public function load($uri, $data = null, $format = null)
 {
     if (!is_string($uri) or $uri == null or $uri == '') {
         throw new InvalidArgumentException("\$uri should be a string and cannot be null or empty");
     }
     if (!$data) {
         # No data was given - try and fetch data from URI
         # FIXME: prevent loading the same URI multiple times
         $client = self::getHttpClient();
         $client->setUri($uri);
         $client->setHeaders('Accept', EasyRdf_Format::getHttpAcceptHeader());
         $response = $client->request();
         if (!$response->isSuccessful()) {
             throw new EasyRdf_Exception("HTTP request for {$uri} failed: " . $response->getMessage());
         }
         $data = $response->getBody();
         if (!$format) {
             $format = $response->getHeader('Content-Type');
             $format = preg_replace('/;(.+)$/', '', $format);
         }
     }
     # Guess the format if it is Unknown
     if (!$format) {
         $format = EasyRdf_Format::guessFormat($data);
     }
     if (!$format) {
         throw new EasyRdf_Exception("Unable to load data of an unknown format.");
     }
     # Parse the data
     $format = EasyRdf_Format::getFormat($format);
     $parser = $format->newParser();
     return $parser->parse($this, $data, $format, $uri);
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:46,代码来源:Graph.php

示例3: parse

 /**
  * Parse some RDF data into the graph object.
  *
  * @param  string  $data    Data to parse for the graph
  * @param  string  $format  Optional format of the data
  * @param  string  $uri     The URI of the data to load
  */
 public function parse($data, $format = null, $uri = null)
 {
     $this->checkResourceParam($uri, true);
     if (!isset($format) or $format == 'guess') {
         // Guess the format if it is Unknown
         $format = EasyRdf_Format::guessFormat($data);
     } else {
         $format = EasyRdf_Format::getFormat($format);
     }
     if (!$format) {
         throw new EasyRdf_Exception("Unable to parse data of an unknown format.");
     }
     $parser = $format->newParser();
     return $parser->parse($this, $data, $format, $uri);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:Graph.php

示例4: testGuessFormatUnknown

 public function testGuessFormatUnknown()
 {
     $this->assertNull(EasyRdf_Format::guessFormat('blah blah blah'));
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:4,代码来源:FormatTest.php

示例5: getDataURLs

 /**
  * get the URLs from which the vocabulary data can be downloaded
  * @return array Array with MIME type as key, URL as value
  */
 public function getDataURLs()
 {
     $ret = array();
     $urls = $this->resource->allResources("void:dataDump");
     foreach ($urls as $url) {
         // first try dc:format and dc11:format
         $mimetypelit = $url->getLiteral('dc:format');
         if ($mimetypelit === null) {
             $mimetypelit = $url->getLiteral('dc11:format');
         }
         // if still not found, guess MIME type using file extension
         if ($mimetypelit !== null) {
             $mimetype = $mimetypelit->getValue();
         } else {
             $format = EasyRdf_Format::guessFormat(null, $url->getURI());
             if ($format === null) {
                 trigger_error("Could not guess format for <{$url}>.", E_USER_WARNING);
                 continue;
             }
             $mimetypes = array_keys($format->getMimeTypes());
             $mimetype = $mimetypes[0];
         }
         $ret[$mimetype] = $url->getURI();
     }
     return $ret;
 }
开发者ID:jneubert,项目名称:Skosmos,代码行数:30,代码来源:VocabularyConfig.php


注:本文中的EasyRdf_Format::guessFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。