Private
Public Access
76 lines
2.6 KiB
PHP
76 lines
2.6 KiB
PHP
<?php
|
|
|
|
function theme_option($key, $default = null)
|
|
{
|
|
return cfg('theme/'.$key, $default);
|
|
}
|
|
|
|
function theme_html_class($extra_class = '')
|
|
{
|
|
$classes = array('no-js');
|
|
if(cfg('theme/mode') === 'dark')
|
|
$classes[] = 'dark-theme';
|
|
if($extra_class !== '')
|
|
$classes[] = $extra_class;
|
|
return trim(implode(' ', $classes));
|
|
}
|
|
|
|
function theme_render_head($overrides = array())
|
|
{
|
|
$theme_path = (string)cfg('theme/path');
|
|
$theme_path_common = 'themes/common/';
|
|
$description = first($overrides['description'] ?? false, cfg('theme/meta_description'), 'Search and browse Zeal docsets');
|
|
$theme_color = first($overrides['theme_color'] ?? false, cfg('theme/theme_color'), '#0f172a');
|
|
$apple_icon = url_root().ltrim($theme_path, '/').'icon.png';
|
|
?>
|
|
<meta charset="utf-8">
|
|
<title><?= first(URL::$route['page-title'] ?? false, cfg('site/default_page_title')).' | '.cfg('site/name') ?></title>
|
|
<meta name="description" content="<?= asafe((string)$description) ?>">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="<?= asafe((string)$theme_color) ?>">
|
|
<link rel="apple-touch-icon" href="<?= $apple_icon ?>">
|
|
<link rel="icon" type="image/png" sizes="32x32" href="<?= $apple_icon ?>">
|
|
<?php
|
|
include_css($theme_path.'css/style.css');
|
|
include_css('themes/common/css/docset-viewer.css');
|
|
include_js('js/u-query.js');
|
|
include_js('js/site.js');
|
|
foreach((array)($overrides['extra_css'] ?? array()) as $extra_css)
|
|
include_css($extra_css);
|
|
foreach((array)($overrides['extra_js'] ?? array()) as $extra_js)
|
|
include_js($extra_js);
|
|
}
|
|
|
|
function theme_render_global_controls($embed_mode, $options = array())
|
|
{
|
|
return;
|
|
}
|
|
|
|
function theme_menu_href($menu_key, $menu_item)
|
|
{
|
|
if(!empty($menu_item['external']))
|
|
return '/'.ltrim((string)$menu_key, '/');
|
|
return URL::Link((string)$menu_key);
|
|
}
|
|
|
|
function theme_render_standard_nav($options = array())
|
|
{
|
|
$nav_class = trim((string)($options['nav_class'] ?? ''));
|
|
?><nav<?= $nav_class !== '' ? ' class="'.asafe($nav_class).'"' : '' ?>>
|
|
<div class="nav-menu">
|
|
<a href="<?= URL::Link('') ?>" class="brand">Docset Viewer</a>
|
|
<?php foreach((array)cfg('menu') as $menu_key => $menu_item) if(empty($menu_item['hidden'])) { ?>
|
|
<a href="<?= theme_menu_href($menu_key, $menu_item) ?>"><?= safe($menu_item['title']) ?></a>
|
|
<?php } ?>
|
|
</div>
|
|
</nav><?php
|
|
}
|
|
|
|
function theme_render_footer($text = null, $options = array())
|
|
{
|
|
if(!empty($options['embed_mode']))
|
|
return;
|
|
$footer_text = first($text, cfg('theme/footer_text'), cfg('site/name'));
|
|
?><footer><div style="max-width: 1200px; margin: 0 auto; padding: 0 1rem;"><p><?= safe((string)$footer_text) ?></p></div></footer><?php
|
|
}
|