Exemplo n.º 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;
 }
Exemplo n.º 2
0
 public function testGetImageName()
 {
     $url = new Url('http://localhost/EvaThumber/thumb/d/demo,w_100.jpg');
     $url->setUrlScriptName('/EvaThumber/index.php');
     $this->assertEquals('demo.jpg', $url->getImageName());
     $url = new Url('http://localhost/');
     $this->assertEquals('', $url->getImageName());
     $url = new Url('http://localhost/thumb/d/demo.jpg');
     $this->assertEquals('demo.jpg', $url->getImageName());
     $url = new Url('http://localhost/thumb/d/demo,w_100,,,.jpg');
     $this->assertEquals('demo.jpg', $url->getImageName());
     $url = new Url('http://localhost/thumb/d/demo...,w_100,,,.jpg');
     $this->assertEquals('demo....jpg', $url->getImageName());
     $url = new Url('http://localhost/thumb/d/demo,w_100....jpg');
     $this->assertEquals('demo.jpg', $url->getImageName());
 }