Хранилища Subversion ant

Редакция

Редакция 459 | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

Редакция 459 Редакция 463
Строка 9... Строка 9...
9
 *  Dual licensed under the MIT and GNU LGPL licenses.
9
 *  Dual licensed under the MIT and GNU LGPL licenses.
10
 *  http://alex-w.org.ru/p/antng/license
10
 *  http://alex-w.org.ru/p/antng/license
11
 *
11
 *
12
 */
12
 */
13
13
14
-
 
15
class Template {
14
class Template {
16
    private     $path   = NULL;
15
    private     $path   = NULL;
17
    protected   $self   = array();
16
    protected   $self   = array();
18
17
-
 
18
    /**
-
 
19
     * Конструктора класса Template - работа с шаблонами
-
 
20
     *
-
 
21
     * @author Alexander Wolf
-
 
22
     * @category Template
-
 
23
     *
-
 
24
     * @param string $folder
-
 
25
     */
19
    public function __construct($folder) {
26
    public function __construct($folder) {
20
        $this->path = $folder;
27
        $this->path = $folder;
21
    }
28
    }
22
   
29
-
 
30
    /**
-
 
31
     * Отображение шаблона
-
 
32
     *
-
 
33
     * @author Alexander Wolf
-
 
34
     * @category Template
-
 
35
     *
-
 
36
     * @param string $name
-
 
37
     */
23
    public function display($name) {
38
    public function display($name) {
24
        $fh = fopen($this->path.$name, "r");
39
        $fh = fopen($this->path.$name, "r");
25
        $content = fread($fh, filesize($this->path.$name));
40
        $content = fread($fh, filesize($this->path.$name));
26
        fclose($fh);
41
        fclose($fh);
27
        preg_match_all("/{([\d\w]+)}/", $content, $matches);
42
        preg_match_all("/{([\d\w]+)}/", $content, $matches);
Строка 31... Строка 46...
31
        }
46
        }
32
47
33
        echo $content;
48
        echo $content;
34
    }
49
    }
35
50
-
 
51
    /**
-
 
52
     * Связывание блока с визуальным отображением оного (назначение значения переменной)
-
 
53
     *
-
 
54
     * @author Alexander Wolf
-
 
55
     * @category Template
-
 
56
     *
-
 
57
     * @param string $attr
-
 
58
     * @param string $value
-
 
59
     * @return string
-
 
60
     */
36
    public function assign($attr, $value) {
61
    public function assign($attr, $value) {
37
        return $this->self[$attr<
62
        return $this->self[$attr] = $value;
38
63
    }    
39
64
-
 
65
    /**
-
 
66
     * Извлечение визуального вида блока по его имени (возвращение значения переменной)
-
 
67
     *
-
 
68
     * @author Alexander Wolf
-
 
69
     * @category Template
-
 
70
     *
-
 
71
     * @param string $attr
-
 
72
     * @return string
-
 
73
     */
40
74
    public function __get($attr = null) {
41
75
        return $this->self[$attr];
42
76
    }
43
77
}
44
78
?>