Themes integrated as part of Template
@ -139,7 +139,7 @@
|
||||
private function recursive_generate_static($tree, $output_dir, $params, $base_url = '') {
|
||||
$params['base_url'] = $params['base_page'] = $base_url;
|
||||
$new_params = $params;
|
||||
$params['theme'] = DauxHelper::rebase_theme($params['theme'], $base_url);
|
||||
$params['theme'] = DauxHelper::rebase_theme($params['theme'], $base_url, $params['base_url'] . "themes/" . $params['theme']['name'] . '/');
|
||||
$params['image'] = str_replace('<base_url>', $base_url, $params['image']);
|
||||
if ($base_url !== '') $params['entry_page'] = $tree->first_page;
|
||||
foreach ($tree->value as $key => $node) {
|
||||
@ -220,9 +220,10 @@
|
||||
$params['piwik_analytics'] = ($p = $this->options['piwik_analytics']) ?
|
||||
DauxHelper::piwik_analytics($p, $this->options['piwik_analytics_id']) : '';
|
||||
|
||||
$params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'themes' .
|
||||
DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'],
|
||||
$params['local_base']);
|
||||
$params['template'] = $this->options['template'];
|
||||
$params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR .
|
||||
$this->options['template'] . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'],
|
||||
$this->local_base, $params['base_url'] . "templates/" . $params['template'] . "/themes/" . $this->options['theme'] . '/');
|
||||
break;
|
||||
|
||||
case Daux::LIVE_MODE:
|
||||
@ -249,9 +250,11 @@
|
||||
$params['piwik_analytics'] = ($p = $this->options['piwik_analytics']) ?
|
||||
DauxHelper::piwik_analytics($p, $this->options['piwik_analytics_id']) : '';
|
||||
|
||||
$params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'themes' .
|
||||
DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'],
|
||||
$params['local_base'], $mode);
|
||||
$params['template'] = $this->options['template'];
|
||||
$params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR .
|
||||
$this->options['template'] . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'],
|
||||
$this->local_base, $params['base_url'] . "templates/" . $params['template'] . "/themes/" . $this->options['theme'] . '/', $mode);
|
||||
|
||||
|
||||
if ($params['breadcrumbs'] = $this->options['breadcrumbs'])
|
||||
$params['breadcrumb_separator'] = $this->options['breadcrumb_separator'];
|
||||
@ -291,9 +294,10 @@
|
||||
$params['piwik_analytics'] = ($p = $this->options['piwik_analytics']) ?
|
||||
DauxHelper::piwik_analytics($p, $this->options['piwik_analytics_id']) : '';
|
||||
|
||||
$params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'themes' .
|
||||
DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'],
|
||||
$params['local_base'], $mode);
|
||||
$params['template'] = $this->options['template'];
|
||||
$params['theme'] = DauxHelper::configure_theme($this->local_base . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR .
|
||||
$this->options['template'] . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $this->options['theme'] . '.thm', $params['base_url'],
|
||||
$this->local_base, $params['base_url'] . "templates/" . $params['template'] . "/themes/" . $this->options['theme'] . '/', $mode);
|
||||
|
||||
if ($params['breadcrumbs'] = $this->options['breadcrumbs'])
|
||||
$params['breadcrumb_separator'] = $this->options['breadcrumb_separator'];
|
||||
|
@ -72,35 +72,41 @@
|
||||
return $request;
|
||||
}
|
||||
|
||||
public static function configure_theme($theme, $base_url, $local_base, $mode = Daux::LIVE_MODE) {
|
||||
public static function configure_theme($theme, $base_url, $local_base, $theme_url, $mode = Daux::LIVE_MODE) {
|
||||
$name = static::pathinfo($theme);
|
||||
if (is_file($theme)) {
|
||||
$theme = file_get_contents($theme);
|
||||
$theme = json_decode($theme, true);
|
||||
if (!$theme) $theme = array();
|
||||
} else $theme = array();
|
||||
$theme['name'] = $name['filename'];
|
||||
|
||||
if ($mode === Daux::LIVE_MODE) {
|
||||
if (!isset($theme['favicon'])) $theme['favicon'] = utf8_encode($base_url . 'img/favicon.png');
|
||||
else {
|
||||
$theme['favicon'] = utf8_encode(str_replace('<base_url>', $base_url, $theme['favicon']));
|
||||
$theme['favicon'] = str_replace('<theme_url>', $theme_url, $theme['favicon']);
|
||||
}
|
||||
|
||||
if (!isset($theme['css'])) $theme['css'] = array();
|
||||
else {
|
||||
foreach ($theme['css'] as $key => $css) {
|
||||
$theme['css'][$key] = utf8_encode(str_replace('<base_url>', $base_url, $css));
|
||||
$theme['css'][$key] = utf8_encode(str_replace('<theme_url>', $theme_url, $css));
|
||||
}
|
||||
}
|
||||
if (!isset($theme['fonts'])) $theme['fonts'] = array();
|
||||
else {
|
||||
foreach ($theme['fonts'] as $key => $font) {
|
||||
$theme['fonts'][$key] = utf8_encode(str_replace('<base_url>', $base_url, $font));
|
||||
$theme['fonts'][$key] = utf8_encode(str_replace('<theme_url>', $theme_url, $font));
|
||||
}
|
||||
}
|
||||
if (!isset($theme['js'])) $theme['js'] = array();
|
||||
else {
|
||||
foreach ($theme['js'] as $key => $js) {
|
||||
$theme['js'][$key] = utf8_encode(str_replace('<base_url>', $base_url, $js));
|
||||
$theme['js'][$key] = utf8_encode(str_replace('<theme_url>', $theme_url, $js));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -111,26 +117,33 @@
|
||||
}
|
||||
|
||||
if (!isset($theme['template'])) $theme['template'] = $local_base . DIRECTORY_SEPARATOR . 'templates' .
|
||||
DIRECTORY_SEPARATOR . 'default.tpl';
|
||||
DIRECTORY_SEPARATOR . 'default/default.tpl';
|
||||
else $theme['template'] = str_replace('<local_base>', $local_base, $theme['template']);
|
||||
if (!isset($theme['error-template'])) $theme['error-template'] = $local_base . DIRECTORY_SEPARATOR . 'templates' .
|
||||
DIRECTORY_SEPARATOR . 'error.tpl';
|
||||
DIRECTORY_SEPARATOR . 'default/error.tpl';
|
||||
else $theme['error-template'] = str_replace('<local_base>', $local_base, $theme['error-template']);
|
||||
if (!isset($theme['require-jquery'])) $theme['require-jquery'] = false;
|
||||
if (!isset($theme['bootstrap-js'])) $theme['bootstrap-js'] = false;
|
||||
|
||||
return $theme;
|
||||
}
|
||||
|
||||
public static function rebase_theme($theme, $base_url) {
|
||||
public static function rebase_theme($theme, $base_url, $theme_url) {
|
||||
$theme['favicon'] = utf8_encode(str_replace('<base_url>', $base_url, $theme['favicon']));
|
||||
$theme['favicon'] = str_replace('<theme_url>', $theme_url, $theme['favicon']);
|
||||
|
||||
foreach ($theme['css'] as $key => $css) {
|
||||
$theme['css'][$key] = utf8_encode(str_replace('<base_url>', $base_url, $css));
|
||||
$theme['css'][$key] = utf8_encode(str_replace('<theme_url>', $theme_url, $css));
|
||||
}
|
||||
foreach ($theme['fonts'] as $key => $font) {
|
||||
$theme['fonts'][$key] = utf8_encode(str_replace('<base_url>', $base_url, $font));
|
||||
$theme['fonts'][$key] = utf8_encode(str_replace('<theme_url>', $theme_url, $font));
|
||||
|
||||
}
|
||||
foreach ($theme['js'] as $key => $js) {
|
||||
$theme['js'][$key] = utf8_encode(str_replace('<base_url>', $base_url, $js));
|
||||
$theme['js'][$key] = utf8_encode(str_replace('<theme_url>', $theme_url, $js));
|
||||
}
|
||||
return $theme;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"favicon": "<base_url>themes/daux-blue/img/favicon-blue.png",
|
||||
"css": ["<base_url>themes/daux-blue/css/daux-blue.css"],
|
||||
"favicon": "<theme_url>img/favicon-blue.png",
|
||||
"css": ["<theme_url>css/daux-blue.css"],
|
||||
"fonts": ["//fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,cyrillic-ext,cyrillic"],
|
||||
"js": [],
|
||||
"require-jquery": true,
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"favicon": "<base_url>themes/daux-green/img/favicon-green.png",
|
||||
"css": ["<base_url>themes/daux-green/css/daux-green.css"],
|
||||
"favicon": "<theme_url>img/favicon-green.png",
|
||||
"css": ["<theme_url>css/daux-green.css"],
|
||||
"fonts": ["//fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,cyrillic-ext,cyrillic"],
|
||||
"js": [],
|
||||
"require-jquery": true,
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"favicon": "<base_url>themes/daux-navy/img/favicon-navy.png",
|
||||
"css": ["<base_url>themes/daux-navy/css/daux-navy.css"],
|
||||
"favicon": "<theme_url>img/favicon-navy.png",
|
||||
"css": ["<theme_url>css/daux-navy.css"],
|
||||
"fonts": ["//fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,cyrillic-ext,cyrillic"],
|
||||
"js": [],
|
||||
"require-jquery": true,
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"favicon": "<base_url>themes/daux-red/img/favicon-red.png",
|
||||
"css": ["<base_url>themes/daux-red/css/daux-red.css"],
|
||||
"favicon": "<theme_url>img/favicon-red.png",
|
||||
"css": ["<theme_url>css/daux-red.css"],
|
||||
"fonts": ["//fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,cyrillic-ext,cyrillic"],
|
||||
"js": [],
|
||||
"require-jquery": true,
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |