Редакция 372 | Редакция 374 | К новейшей редакции | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 372 | Редакция 373 | ||
---|---|---|---|
Строка 22... | Строка 22... | ||
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) { |
28 | $fh = fopen($this->path.$name, "r"); |
28 | $fh = fopen($this->path.$name, "r"); |
29 | $content = fread($fh, filesize($this->path.$name)); |
29 | $content = fread($fh, filesize($this->path.$name)); |
30 | fclose($fh); |
30 | fclose($fh); |
- | 31 | preg_match_all("/({[\d\w]+})/", $content, $matches); |
|
- | 32 | $tmpl = $matches[0]; |
|
31 | foreach ($attrs as $attr) { |
33 | for($i=0;$i<=count($tmpl);$i++) { |
32 | $content = str_replace("{".$attr."}", $this->__get($attr), $content); |
34 | $content = str_replace("{".$tmpl[$i]."}", $this->__get($tmpl[$i]), $content); |
33 | }
|
35 | }
|
34 | 36 | ||
35 | return $content; |
37 | echo $content; |
36 | }
|
38 | }
|
37 | 39 | ||
38 | public function assign($attr, $value) { |
40 | public function assign($attr, $value) { |
39 | return $this->self[$attr] = $value; |
41 | return $this->self[$attr] = $value; |
40 | }
|
42 | }
|