diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2024-01-31 06:11:00 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2024-01-31 20:45:40 +0300 |
commit | c0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch) | |
tree | 2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /skin | |
parent | 48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff) |
make it simple, but not simpler
Diffstat (limited to 'skin')
-rw-r--r-- | skin/admin.skin.php | 8 | ||||
-rw-r--r-- | skin/base.skin.php | 17 | ||||
-rw-r--r-- | skin/error.skin.php | 27 |
3 files changed, 18 insertions, 34 deletions
diff --git a/skin/admin.skin.php b/skin/admin.skin.php index b2d9bb4..d2fc148 100644 --- a/skin/admin.skin.php +++ b/skin/admin.skin.php @@ -135,8 +135,8 @@ function postForm($ctx, $form_url = !$is_edit ? '/write/' : $post_url.'edit/'; $html = <<<HTML -{$ctx->if_true($error_code, '<div class="form-error">'.$ctx->lang('err_blog_'.$error_code).'</div>')} -{$ctx->if_true($saved, '<div class="form-success">'.$ctx->lang('info_saved').'</div>')} +{$ctx->if_true($error_code, fn() => '<div class="form-error">'.$ctx->lang('err_blog_'.$error_code).'</div>')} +{$ctx->if_true($saved, fn() => '<div class="form-success">'.$ctx->lang('info_saved').'</div>')} <table cellpadding="0" cellspacing="0" class="blog-write-table"> <tr> <td id="form_first_cell"> @@ -228,8 +228,8 @@ function pageForm($ctx, bool $visible = false): array { $form_url = '/'.$short_name.'/'.($is_edit ? 'edit' : 'create').'/'; $html = <<<HTML -{$ctx->if_true($error_code, '<div class="form-error">'.$ctx->lang('err_pages_'.$error_code).'</div>')} -{$ctx->if_true($saved, '<div class="form-success">'.$ctx->lang('info_saved').'</div>')} +{$ctx->if_true($error_code, fn() => '<div class="form-error">'.$ctx->lang('err_pages_'.$error_code).'</div>')} +{$ctx->if_true($saved, fn() => '<div class="form-success">'.$ctx->lang('info_saved').'</div>')} <table cellpadding="0" cellspacing="0" class="blog-write-table"> <tr> <td id="form_first_cell"> diff --git a/skin/base.skin.php b/skin/base.skin.php index d39a0a8..d583ffe 100644 --- a/skin/base.skin.php +++ b/skin/base.skin.php @@ -2,9 +2,6 @@ namespace skin\base; -use admin; -use RequestDispatcher; - function layout($ctx, $title, $unsafe_body, $static, $meta, $js, $opts, $exec_time, $unsafe_lang, $theme) { global $config; $app_config = json_encode([ @@ -15,9 +12,13 @@ $app_config = json_encode([ $body_class = []; if ($opts['full_width']) - $body_class = 'full-width'; + $body_class[] = 'full-width'; else if ($opts['wide']) - $body_class = 'wide'; + $body_class[] = 'wide'; +if (!empty($body_class)) + $body_class = implode(' ', $body_class); +else + $body_class = ''; return <<<HTML <!doctype html> @@ -196,7 +197,7 @@ $items = [ ['url' => '/misc/', 'label' => 'misc'], ['url' => '/contacts/', 'label' => 'contacts'], ]; -if (\admin::isAdmin()) +if (\is_admin()) $items[] = ['url' => '/admin/', 'label' => 'admin']; // here, items are rendered using for_each, so that there are no gaps (whitespaces) between tags @@ -226,9 +227,9 @@ HTML; // TODO rewrite this fcking crap function renderLogo($ctx, array $path_map = [], array $link_map = []): string { - $uri = RequestDispatcher::path(); + $uri = request_path(); - if (!admin::isAdmin()) { + if (!is_admin()) { $prompt_sign = '<span class="head-logo-dolsign">$</span>'; } else { $prompt_sign = '<span class="head-logo-dolsign is_root">#</span>'; diff --git a/skin/error.skin.php b/skin/error.skin.php index 5276bfa..8f7e4c7 100644 --- a/skin/error.skin.php +++ b/skin/error.skin.php @@ -4,34 +4,17 @@ namespace skin\error; use Stringable; -function forbidden($ctx, $message) { - return $ctx->common(403, 'Forbidden', $message); -} - -function not_found($ctx, $message) { - return $ctx->common(404, 'Not Found', $message); -} - -function unauthorized($ctx, $message) { - return $ctx->common(401, 'Unauthorized', $message); -} - -function not_implemented($ctx, $message) { - return $ctx->common(501, 'Not Implemented', $message); -} - -function common($ctx, - int $code, - string|Stringable $title, - string|Stringable|null $message = null) { +function http_error($ctx, + int $code, + string|Stringable $title, + string|Stringable|null $message = null) { return <<<HTML <html> <head><title>$code $title</title></head> <body> <center><h1>$code $title</h1></center> - <hr> {$ctx->if_true($message, - '<p align="center">'.$message.'</p>' + '<hr><p align="center">'.$message.'</p>' )} </body> </html> |