Exemple #1
0
 public function getSourcefile()
 {
     if ($this->sourcefile) {
         return $this->sourcefile;
     }
     $fileRootPath = $this->config->source_path;
     $filePath = $this->url->getImagePath();
     $fileName = $this->url->getImageName();
     if (is_dir($fileRootPath)) {
         if (!$fileName) {
             throw new Exception\InvalidArgumentException(sprintf("Request an empty filename"));
         }
         $sourcefile = $fileRootPath . $filePath . '/' . $fileName;
         $systemEncoding = $this->config->system_file_encoding;
         $sourcefile = urldecode($sourcefile);
         if ($systemEncoding || $systemEncoding != 'UTF-8') {
             $sourcefile = iconv('UTF-8', $this->config->system_file_encoding, $sourcefile);
         }
     } elseif (is_file($fileRootPath)) {
         if (!Feature\ZipReader::isSupport()) {
             throw new Exception\BadFunctionCallException(sprintf("Your system not support ZipArchive feature"));
         }
         $sourcefile = Feature\ZipReader::getStreamPath(urldecode($filePath . '/' . $fileName), $fileRootPath, $this->config->zip_file_encoding);
     } else {
         throw new Exception\IOException(sprintf("Source file not readable %s", $fileRootPath));
     }
     return $this->sourcefile = $sourcefile;
 }
Exemple #2
0
 public function testGetImagePath()
 {
     $url = new Url('http://localhost/EvaThumber/thumb/d/demo.jpg');
     $url->setUrlScriptName('/EvaThumber/index.php');
     $this->assertEquals('', $url->getImagePath());
     $url = new Url('http://localhost/EvaThumber/thumb/d/foo/demo.jpg');
     $url->setUrlScriptName('/EvaThumber/index.php');
     $this->assertEquals('/foo', $url->getImagePath());
     $url = new Url('http://localhost/EvaThumber/thumb/d/foo/bar/demo.jpg');
     $url->setUrlScriptName('/EvaThumber/index.php');
     $this->assertEquals('/foo/bar', $url->getImagePath());
     $url = new Url('http://localhost/thumb/d/foo');
     $this->assertEquals('', $url->getImagePath());
     $url = new Url('http://localhost/thumb/d/foo/');
     $this->assertEquals('/foo', $url->getImagePath());
 }