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


PHP Kurogo::tempFile方法代码示例

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


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

示例1: retrieveResponse

 protected function retrieveResponse()
 {
     if (!class_exists('ZipArchive')) {
         throw new KurogoException("class ZipArchive (php-zip) not available");
     }
     $tmpFile = Kurogo::tempFile();
     // this is the same as parent
     if (!($this->requestURL = $this->url())) {
         throw new KurogoDataException("URL could not be determined");
     }
     $this->requestParameters = $this->parameters();
     // the following are private functions in URLDataRetriever
     //$this->requestMethod = $this->setContextMethod();
     //$this->requestHeaders = $this->setContextHeaders();
     //$this->requestData = $this->setContextData();
     Kurogo::log(LOG_INFO, "Retrieving {$this->requestURL}", 'url_retriever');
     // the creation of $data is different from parent
     copy($this->requestURL, $tmpFile);
     $zip = new ZipArchive();
     $zip->open($tmpFile);
     $data = $zip->getFromIndex(0);
     unlink($tmpFile);
     // this is the same as parent
     $http_response_header = isset($http_response_header) ? $http_response_header : array();
     $response = $this->initResponse();
     $response->setRequest($this->requestMethod, $this->requestURL, $this->requestParameters, $this->requestHeaders, null);
     $response->setResponse($data);
     $response->setResponseHeaders($http_response_header);
     Kurogo::log(LOG_DEBUG, sprintf("Returned status %d and %d bytes", $response->getCode(), strlen($data)), 'url_retriever');
     return $response;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:31,代码来源:KMZDataRetriever.php

示例2: retrieveResponse

 protected function retrieveResponse()
 {
     $response = $this->initResponse();
     if (strpos($this->fileStem, '.zip') !== false) {
         if (!class_exists('ZipArchive')) {
             throw new KurogoException("class ZipArchive (php-zip) not available");
         }
         $response->setContext('zipped', true);
         $zip = new ZipArchive();
         if (strpos($this->fileStem, 'http') === 0 || strpos($this->fileStem, 'ftp') === 0) {
             $tmpFile = Kurogo::tempFile();
             copy($this->fileStem, $tmpFile);
             $zip->open($tmpFile);
         } else {
             $zip->open($this->fileStem);
         }
         // locate valid shapefile components
         $shapeNames = array();
         for ($i = 0; $i < $zip->numFiles; $i++) {
             if (preg_match('/(.+)\\.(shp|dbf|prj)$/', $zip->getNameIndex($i), $matches)) {
                 $shapeName = $matches[1];
                 $extension = $matches[2];
                 if (!isset($shapeNames[$shapeName])) {
                     $shapeNames[$shapeName] = array();
                 }
                 $shapeNames[$shapeName][] = $extension;
             }
         }
         $responseData = array();
         foreach ($shapeNames as $shapeName => $extensions) {
             if (in_array('dbf', $extensions) && in_array('shp', $extensions)) {
                 $fileData = array('dbf' => $zip->getFromName("{$shapeName}.dbf"), 'shp' => $zip->getFromName("{$shapeName}.shp"));
                 if (in_array('prj', $extensions)) {
                     $prjData = $zip->getFromName("{$shapeName}.prj");
                     $fileData['projection'] = new MapProjection($prjData);
                 }
                 $responseData[$shapeName] = $fileData;
             }
         }
         $response->setResponse($responseData);
     } elseif (realpath_exists("{$this->fileStem}.shp") && realpath_exists("{$this->fileStem}.dbf")) {
         $response->setContext('zipped', false);
         $response->setContext('shp', "{$this->fileStem}.shp");
         $response->setContext('dbf', "{$this->fileStem}.dbf");
         if (realpath_exists("{$this->fileStem}.prj")) {
             $prjData = file_get_contents("{$this->fileStem}.prj");
             $response->setContext('projection', new MapProjection($prjData));
         }
     } else {
         throw new KurogoDataException("Cannot find {$this->fileStem}");
     }
     return $response;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:53,代码来源:ShapefileDataRetriever.php

示例3: retrieveResponse

 protected function retrieveResponse()
 {
     if (!class_exists('ZipArchive')) {
         throw new KurogoException("class ZipArchive (php-zip) not available");
     }
     $tmpFile = Kurogo::tempFile();
     // this is the same as parent
     if (!($this->requestURL = $this->url())) {
         throw new KurogoDataException("URL could not be determined");
     }
     Kurogo::log(LOG_INFO, "Retrieving {$this->requestURL}", 'url_retriever');
     // get data from parent request and save to temp file which we will
     // unzip and return
     $response = parent::retrieveResponse();
     file_put_contents($tmpFile, $response->getResponse());
     $zip = new ZipArchive();
     if (!$zip->open($tmpFile)) {
         throw new KurogoDataException("Could not open zip file");
     }
     $targetFile = $this->targetFile();
     if ($targetFile) {
         $index = $zip->locateName($targetFile);
     } else {
         $index = 0;
     }
     if ($index === false) {
         // $zip->locateName failed
         throw new KurogoDataException("Could not locate {$this->targetFile} in zip archive");
     }
     $data = $zip->getFromIndex($index);
     unlink($tmpFile);
     $zip->close();
     $response->setResponse($data);
     Kurogo::log(LOG_DEBUG, sprintf("Returned status %d and %d bytes", $response->getCode(), strlen($data)), 'url_retriever');
     return $response;
 }
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:36,代码来源:ZipURLDataRetriever.php

示例4: retrieveData

 protected function retrieveData($url)
 {
     if (strpos($url, '.kmz') !== false) {
         if (!class_exists('ZipArchive')) {
             throw new KurogoException("class ZipArchive (php-zip) not available");
         }
         $tmpFile = Kurogo::tempFile();
         copy($url, $tmpFile);
         $zip = new ZipArchive();
         $zip->open($tmpFile);
         $contents = $zip->getFromIndex(0);
         unlink($tmpFile);
         return $contents;
         // this is false on failure, same as file_get_contents
     }
     return parent::retrieveData($url);
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:17,代码来源:MapDataController.php


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