<?php def_alias('bu::layout', 'l'); def_accessor('title'); def_accessor('keywords'); def_accessor('description'); def('show_404', function () { write_log("404", RAW_HTTP_STRING); header("Status: 404 Not Found"); draw_page('Страница не найдена', view('404')); }); def('draw_page', function ($title, $content) { title($title); echo dview('layout/default', $content); });
<?php if (!path()) { draw_page('Поваренная книга программиста', dview('index_content', main_categories())); } elseif (is_category_path(path()) && is_category_exists(path())) { is_need_cache(true); $category = new Category(path()); keywords($category->keywords()); draw_page($category->getTitle(), dview('one_category', $category)); } elseif (is_example_path(path()) && is_example_exists(path())) { is_need_cache(true); $example = new Example(path()); keywords($example->keywords()); draw_page($example->prop('desc'), view('path_block', ['id' => $example->id()]) . view('one_example', ['data' => $example, 'show_link' => true])); } else { show_404(); }
<? echo dview('big-page', $_SERVER['REMOTE_ADDR']);
<?php echo dview('example', $data); ?> <? if($data->link()): ?> <?php echo cehr(); ?> <div id="links"> <? if(is_array($data->link())): ?> Источники: <br> <? foreach($data->link() as $v):?> <?php echo nice_link($v); ?> <br> <?endforeach ?> <? else: ?> Источник: <br> <?php echo nice_link($data->link()); ?> <? endif ?> </div> <? endif ?> <? if($data->prop('author')): ?> <?php echo cehr();
<?php function write_log($file, $txt) { $f = fopen('log/' . $file, 'a+'); fwrite($f, date('c') . " " . $txt . "\n"); fclose($f); } def('path', function () { return implode('/', bu::path()); }); def_alias('bu::path', 'pth'); def_alias('bu::view', 'view'); def('dview', function ($pth, $data) { return view($pth, array('data' => $data)); }); def('map_dview', function ($tpl, $array, $separator = '') { return implode($separator, map(function ($v) use($tpl) { return dview($tpl, $v); }, $array)); }); def_sprintfer('cehr', '<div style="cehr"><center>-----------</center></div>');
public function content() { return dview('example-formats/' . $this->format(), $this); }