Хранилища Subversion ant

Редакция

Редакция 370 | Редакция 372 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
364 alex-w 1
<?php
2
/**
3
 *
4
 *  Codename: ant-ng - generator of sources.list for Debian and
5
 *  distributives, based on Debian
6
 *  http://alex-w.org.ru/p/antng/
7
 *
8
 *  Copyright (c) 2009 Alexander Wolf
9
 *  Dual licensed under the MIT and GNU LGPL licenses.
10
 *  http://alex-w.org.ru/p/antng/license
11
 *
12
 */
13
 
14
/**
15
 * Description of Template
16
 *
17
 * @author alexw
18
 */
365 alex-w 19
 //TODO Вместо Smarty лучше написать свой очень простой шаблонизатор - монстра использовать не целесообразно
364 alex-w 20
class Template {
21
    private $path   = NULL;
22
 
368 alex-w 23
    public function __construct($folder) {
364 alex-w 24
        $this->path = $folder;
25
    }
366 alex-w 26
 
368 alex-w 27
    public function display($name, $attrs = null) {
371 alex-w 28
        $fh = fopen($this->path.$name, "r+");
29
        $content = fread($fh, filesize($this->path.$name));
30
        fclose($fh);
370 alex-w 31
        foreach ($attrs as $attr) {
32
            $content = str_replace("{".$attr."}", $this->__get($attr), $content);
33
        }
34
 
35
        return $content;
364 alex-w 36
    }
37
 
368 alex-w 38
    public function assign($attr, $value) {
39
        return $this->self[$attr] = $value;
370 alex-w 40
    }    
41
 
42
    public function __get($attr = null) {
43
        return $this->self[$attr];
366 alex-w 44
    }
364 alex-w 45
}
46
?>