Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
64
PHPTAL/FileSource.php
Normal file
64
PHPTAL/FileSource.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
require_once PHPTAL_DIR.'PHPTAL/Source.php';
|
||||
require_once PHPTAL_DIR.'PHPTAL/SourceResolver.php';
|
||||
|
||||
/**
|
||||
* @package phptal
|
||||
*/
|
||||
class PHPTAL_FileSource implements PHPTAL_Source
|
||||
{
|
||||
public function __construct($path)
|
||||
{
|
||||
$this->_path = realpath($path);
|
||||
if ($this->_path === false) throw new PHPTAL_Exception("Unable to normalize path '$path'");
|
||||
}
|
||||
|
||||
public function getRealPath()
|
||||
{
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
public function getLastModifiedTime()
|
||||
{
|
||||
return filemtime($this->_path);
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return file_get_contents($this->_path);
|
||||
}
|
||||
|
||||
private $_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @package phptal
|
||||
*/
|
||||
class PHPTAL_FileSourceResolver implements PHPTAL_SourceResolver
|
||||
{
|
||||
public function __construct($repositories)
|
||||
{
|
||||
$this->_repositories = $repositories;
|
||||
}
|
||||
|
||||
public function resolve($path)
|
||||
{
|
||||
foreach ($this->_repositories as $repository){
|
||||
$file = $repository . DIRECTORY_SEPARATOR . $path;
|
||||
if (file_exists($file)){
|
||||
return new PHPTAL_FileSource($file);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($path)){
|
||||
return new PHPTAL_FileSource($path);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private $_repositories;
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue