Exemplo n.º 1
0
Arquivo: php.php Projeto: bmdevel/ezc
 /**
  * Processes the template with the variables added by the send() method.
  * The result of this action should be retrievable through the getResult() method.
  *
  * The $last parameter is set if the view handler is the last one in the
  * list of zones for a specific view.
  *
  * @param bool $last
  */
 public function process($last)
 {
     if (!file_exists($this->templateLocation)) {
         $fileName = ezcBaseFile::isAbsolutePath($this->templateLocation) ? $this->templateLocation : getcwd() . DIRECTORY_SEPARATOR . $this->templateLocation;
         throw new ezcBaseFileNotFoundException($fileName, 'php template');
     }
     ob_start();
     include $this->templateLocation;
     $this->result = ob_get_contents();
     ob_end_clean();
 }
Exemplo n.º 2
0
 /**
  * Check and return file
  *
  * Check for the files location, and return the absolute path to the file,
  * or thorw an exception, if the file could not be found.
  * 
  * @param string $file 
  * @return string
  */
 protected function getFile($file)
 {
     if (!ezcBaseFile::isAbsolutePath($file)) {
         // If path to file is not an absolute path, use the given relative
         // path relative to the currently processed document location.
         $file = $this->path . $file;
     }
     // @TODO: docutils performs automatic checks, that no system files
     // (like /etc/passwd) are included - do we want to do similar stuff
     // here?
     // Throw an exception, if we cannot find the referenced file
     if (!is_file($file) || !is_readable($file)) {
         throw new ezcBaseFileNotFoundException($file);
     }
     return $file;
 }
 public static function testAbsoluteLinux3()
 {
     if (ezcBaseFeatures::os() === 'Windows') {
         self::markTestSkipped('Test is for unix-like systems only');
     }
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt//winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:/winnt/winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:/winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c://winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:/table.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c:winnt'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('c//winnt.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//winnt.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('/winnt.sys'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('winnt.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//server/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////server/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//tequila/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////tequila/share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//tequila/thare/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////tequila/thare/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//server//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////server//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//tequila//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('////tequila//share/foo.sys'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('/etc/init.d/apache'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('//etc//init.d//apache'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('etc/init.d/apache'));
     self::assertEquals(false, ezcBaseFile::isAbsolutePath('etc//init.d//apache'));
 }
Exemplo n.º 4
0
 public static function testAbsoluteStreamWrapper()
 {
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('phar://test.phar/foo'));
     self::assertEquals(true, ezcBaseFile::isAbsolutePath('http://example.com/file'));
 }
Exemplo n.º 5
0
Arquivo: main.php Projeto: bmdevel/ezc
 /**
  * Tries to locate a file
  *
  * Tries to locate a file, referenced in a docbook document. If available
  * the document path is used a base for relative paths.
  *
  * @param string $file
  * @return string
  */
 public function locateFile($file)
 {
     if (!ezcBaseFile::isAbsolutePath($file)) {
         $file = $this->document->getPath() . $file;
     }
     if (!is_file($file)) {
         throw new ezcBaseFileNotFoundException($file);
     }
     return $file;
 }