diff --git a/libs/daux.php b/libs/daux.php index 3fb106e..eb7278e 100644 --- a/libs/daux.php +++ b/libs/daux.php @@ -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, $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']; diff --git a/libs/daux_helper.php b/libs/daux_helper.php index 2f80068..d700b0b 100644 --- a/libs/daux_helper.php +++ b/libs/daux_helper.php @@ -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, $theme['favicon'])); + $theme['favicon'] = str_replace('', $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, $css)); + $theme['css'][$key] = utf8_encode(str_replace('', $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, $font)); + $theme['fonts'][$key] = utf8_encode(str_replace('', $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, $js)); + $theme['js'][$key] = utf8_encode(str_replace('', $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, $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, $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, $theme['favicon'])); + $theme['favicon'] = str_replace('', $theme_url, $theme['favicon']); + foreach ($theme['css'] as $key => $css) { $theme['css'][$key] = utf8_encode(str_replace('', $base_url, $css)); + $theme['css'][$key] = utf8_encode(str_replace('', $theme_url, $css)); } foreach ($theme['fonts'] as $key => $font) { $theme['fonts'][$key] = utf8_encode(str_replace('', $base_url, $font)); + $theme['fonts'][$key] = utf8_encode(str_replace('', $theme_url, $font)); + } foreach ($theme['js'] as $key => $js) { $theme['js'][$key] = utf8_encode(str_replace('', $base_url, $js)); + $theme['js'][$key] = utf8_encode(str_replace('', $theme_url, $js)); } return $theme; } diff --git a/templates/default.tpl b/templates/default/default.tpl similarity index 100% rename from templates/default.tpl rename to templates/default/default.tpl diff --git a/templates/error.tpl b/templates/default/error.tpl similarity index 100% rename from templates/error.tpl rename to templates/default/error.tpl diff --git a/themes/daux-blue.thm b/templates/default/themes/daux-blue.thm similarity index 59% rename from themes/daux-blue.thm rename to templates/default/themes/daux-blue.thm index 10fc3fe..0ccd2ba 100644 --- a/themes/daux-blue.thm +++ b/templates/default/themes/daux-blue.thm @@ -1,6 +1,6 @@ { - "favicon": "themes/daux-blue/img/favicon-blue.png", - "css": ["themes/daux-blue/css/daux-blue.css"], + "favicon": "img/favicon-blue.png", + "css": ["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, diff --git a/themes/daux-blue/css/daux-blue.css b/templates/default/themes/daux-blue/css/daux-blue.css similarity index 100% rename from themes/daux-blue/css/daux-blue.css rename to templates/default/themes/daux-blue/css/daux-blue.css diff --git a/themes/daux-blue/fonts/glyphicons-halflings-regular.eot b/templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from themes/daux-blue/fonts/glyphicons-halflings-regular.eot rename to templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.eot diff --git a/themes/daux-blue/fonts/glyphicons-halflings-regular.svg b/templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from themes/daux-blue/fonts/glyphicons-halflings-regular.svg rename to templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.svg diff --git a/themes/daux-blue/fonts/glyphicons-halflings-regular.ttf b/templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from themes/daux-blue/fonts/glyphicons-halflings-regular.ttf rename to templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.ttf diff --git a/themes/daux-blue/fonts/glyphicons-halflings-regular.woff b/templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from themes/daux-blue/fonts/glyphicons-halflings-regular.woff rename to templates/default/themes/daux-blue/fonts/glyphicons-halflings-regular.woff diff --git a/themes/daux-blue/img/favicon-blue.png b/templates/default/themes/daux-blue/img/favicon-blue.png similarity index 100% rename from themes/daux-blue/img/favicon-blue.png rename to templates/default/themes/daux-blue/img/favicon-blue.png diff --git a/themes/daux-green.thm b/templates/default/themes/daux-green.thm similarity index 58% rename from themes/daux-green.thm rename to templates/default/themes/daux-green.thm index b679f0c..01aaa97 100644 --- a/themes/daux-green.thm +++ b/templates/default/themes/daux-green.thm @@ -1,6 +1,6 @@ { - "favicon": "themes/daux-green/img/favicon-green.png", - "css": ["themes/daux-green/css/daux-green.css"], + "favicon": "img/favicon-green.png", + "css": ["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, diff --git a/themes/daux-green/css/daux-green.css b/templates/default/themes/daux-green/css/daux-green.css similarity index 100% rename from themes/daux-green/css/daux-green.css rename to templates/default/themes/daux-green/css/daux-green.css diff --git a/themes/daux-green/fonts/glyphicons-halflings-regular.eot b/templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from themes/daux-green/fonts/glyphicons-halflings-regular.eot rename to templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.eot diff --git a/themes/daux-green/fonts/glyphicons-halflings-regular.svg b/templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from themes/daux-green/fonts/glyphicons-halflings-regular.svg rename to templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.svg diff --git a/themes/daux-green/fonts/glyphicons-halflings-regular.ttf b/templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from themes/daux-green/fonts/glyphicons-halflings-regular.ttf rename to templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.ttf diff --git a/themes/daux-green/fonts/glyphicons-halflings-regular.woff b/templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from themes/daux-green/fonts/glyphicons-halflings-regular.woff rename to templates/default/themes/daux-green/fonts/glyphicons-halflings-regular.woff diff --git a/themes/daux-green/img/favicon-green.png b/templates/default/themes/daux-green/img/favicon-green.png similarity index 100% rename from themes/daux-green/img/favicon-green.png rename to templates/default/themes/daux-green/img/favicon-green.png diff --git a/themes/daux-navy.thm b/templates/default/themes/daux-navy.thm similarity index 59% rename from themes/daux-navy.thm rename to templates/default/themes/daux-navy.thm index aecc385..f86c54b 100644 --- a/themes/daux-navy.thm +++ b/templates/default/themes/daux-navy.thm @@ -1,6 +1,6 @@ { - "favicon": "themes/daux-navy/img/favicon-navy.png", - "css": ["themes/daux-navy/css/daux-navy.css"], + "favicon": "img/favicon-navy.png", + "css": ["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, diff --git a/themes/daux-navy/css/daux-navy.css b/templates/default/themes/daux-navy/css/daux-navy.css similarity index 100% rename from themes/daux-navy/css/daux-navy.css rename to templates/default/themes/daux-navy/css/daux-navy.css diff --git a/themes/daux-navy/fonts/glyphicons-halflings-regular.eot b/templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from themes/daux-navy/fonts/glyphicons-halflings-regular.eot rename to templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.eot diff --git a/themes/daux-navy/fonts/glyphicons-halflings-regular.svg b/templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from themes/daux-navy/fonts/glyphicons-halflings-regular.svg rename to templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.svg diff --git a/themes/daux-navy/fonts/glyphicons-halflings-regular.ttf b/templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from themes/daux-navy/fonts/glyphicons-halflings-regular.ttf rename to templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.ttf diff --git a/themes/daux-navy/fonts/glyphicons-halflings-regular.woff b/templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from themes/daux-navy/fonts/glyphicons-halflings-regular.woff rename to templates/default/themes/daux-navy/fonts/glyphicons-halflings-regular.woff diff --git a/themes/daux-navy/img/favicon-navy.png b/templates/default/themes/daux-navy/img/favicon-navy.png similarity index 100% rename from themes/daux-navy/img/favicon-navy.png rename to templates/default/themes/daux-navy/img/favicon-navy.png diff --git a/themes/daux-red.thm b/templates/default/themes/daux-red.thm similarity index 59% rename from themes/daux-red.thm rename to templates/default/themes/daux-red.thm index 1cbb8ad..c0d799b 100644 --- a/themes/daux-red.thm +++ b/templates/default/themes/daux-red.thm @@ -1,6 +1,6 @@ { - "favicon": "themes/daux-red/img/favicon-red.png", - "css": ["themes/daux-red/css/daux-red.css"], + "favicon": "img/favicon-red.png", + "css": ["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, diff --git a/themes/daux-red/css/daux-red.css b/templates/default/themes/daux-red/css/daux-red.css similarity index 100% rename from themes/daux-red/css/daux-red.css rename to templates/default/themes/daux-red/css/daux-red.css diff --git a/themes/daux-red/fonts/glyphicons-halflings-regular.eot b/templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from themes/daux-red/fonts/glyphicons-halflings-regular.eot rename to templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.eot diff --git a/themes/daux-red/fonts/glyphicons-halflings-regular.svg b/templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from themes/daux-red/fonts/glyphicons-halflings-regular.svg rename to templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.svg diff --git a/themes/daux-red/fonts/glyphicons-halflings-regular.ttf b/templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from themes/daux-red/fonts/glyphicons-halflings-regular.ttf rename to templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.ttf diff --git a/themes/daux-red/fonts/glyphicons-halflings-regular.woff b/templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from themes/daux-red/fonts/glyphicons-halflings-regular.woff rename to templates/default/themes/daux-red/fonts/glyphicons-halflings-regular.woff diff --git a/themes/daux-red/img/favicon-red.png b/templates/default/themes/daux-red/img/favicon-red.png similarity index 100% rename from themes/daux-red/img/favicon-red.png rename to templates/default/themes/daux-red/img/favicon-red.png