Редакция 368 | Редакция 371 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 368 | Редакция 370 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | *
|
3 | *
|
4 | * Codename: ant-ng - generator of sources.list for Debian and
|
4 | * Codename: ant-ng - generator of sources.list for Debian and
|
5 | * distributives, based on Debian
|
5 | * distributives, based on Debian
|
6 | * http://alex-w.org.ru/p/antng/
|
6 | * http://alex-w.org.ru/p/antng/
|
7 | *
|
7 | *
|
8 | * Copyright (c) 2009 Alexander Wolf
|
8 | * Copyright (c) 2009 Alexander Wolf
|
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 | /**
|
14 | /**
|
15 | * Description of Template
|
15 | * Description of Template
|
16 | *
|
16 | *
|
17 | * @author alexw
|
17 | * @author alexw
|
18 | */
|
18 | */
|
19 | //TODO Вместо Smarty лучше написать свой очень простой шаблонизатор - монстра использовать не целесообразно
|
19 | //TODO Вместо Smarty лучше написать свой очень простой шаблонизатор - монстра использовать не целесообразно
|
20 | class Template { |
20 | class Template { |
21 | private $path = NULL; |
21 | private $path = NULL; |
22 | 22 | ||
23 | public function __construct($folder) { |
23 | public function __construct($folder) { |
24 | $this->path = $folder; |
24 | $this->path = $folder; |
25 | }
|
25 | }
|
26 | 26 | ||
27 | public function display($name, $attrs = null) { |
27 | public function display($name, $attrs = null) { |
- | 28 | $content = implode('',$this->path.$name); |
|
- | 29 | foreach ($attrs as $attr) { |
|
28 | //TODO написать функцию шаблонизатора
|
30 | $content = str_replace("{".$attr."}", $this->__get($attr), $content); |
- | 31 | }
|
|
- | 32 | ||
- | 33 | return $content; |
|
29 | }
|
34 | }
|
30 | 35 | ||
31 | public function assign($attr, $value) { |
36 | public function assign($attr, $value) { |
32 | return $this->self[$attr] = $value; |
37 | return $this->self[$attr] = $value; |
33 | }
|
38 | }
|
34 | 39 | ||
- | 40 | public function __get($attr = null) { |
|
- | 41 | return $this->self[$attr]; |
|
- | 42 | }
|
|
35 | }
|
43 | }
|
36 | ?>
|
44 | ?>
|
37 | 45 |