Редакция 374 |
Редакция 388 |
К новейшей редакции |
Авторство |
Сравнить с предыдущей |
Последнее изменение |
Открыть журнал
| Скачать
| RSS
<?php
/**
*
* Codename: ant-ng - generator of sources.list for Debian and
* distributives, based on Debian
* http://alex-w.org.ru/p/antng/
*
* Copyright (c) 2009 Alexander Wolf
* Dual licensed under the MIT and GNU LGPL licenses.
* http://alex-w.org.ru/p/antng/license
*
*/
/**
* Description of Template
*
* @author alexw
*/
//TODO Вместо Smarty лучше написать свой очень простой шаблонизатор - монстра использовать не целесообразно
class Template
{
private $path = NULL;
protected $self = array();
public function __construct
($folder) {
$this->path = $folder;
}
public function display
($name) {
$fh = fopen($this->path.$name, "r");
$content = fread($fh, filesize($this->path.$name));
fclose($fh);
preg_match_all("/{([\d\w]+)}/", $content, $matches);
$tmpl = $matches[1];
for($i=0;$i<=count($tmpl);$i++) {
$content = str_replace("{".$tmpl[$i]."}", $this->__get
($tmpl[$i]), $content);
}
echo $content;
}
public function assign
($attr, $value) {
return $this->self[$attr] = $value;
}
public function __get
($attr = null) {
return $this->self[$attr];
}
}
?>