From: Arthur Date: Fri, 6 Jan 2017 10:40:54 +0000 (+0100) Subject: Merge pull request #732 from ArthurHoaro/feature/theme-manager X-Git-Tag: v0.9.0~73 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=7418f7cb60524c3bfc2f240386b5e3e7eb9b3257;hp=-c;p=github%2Fshaarli%2FShaarli.git Merge pull request #732 from ArthurHoaro/feature/theme-manager Theme manager: improvements --- 7418f7cb60524c3bfc2f240386b5e3e7eb9b3257 diff --combined application/config/ConfigPhp.php index 9dd9a65d,2eb68d80..d7fd4baf --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php @@@ -41,6 -41,7 +41,7 @@@ class ConfigPhp implements ConfigI 'resource.log' => 'config.LOG_FILE', 'resource.update_check' => 'config.UPDATECHECK_FILENAME', 'resource.raintpl_tpl' => 'config.RAINTPL_TPL', + 'resource.theme' => 'config.theme', 'resource.raintpl_tmp' => 'config.RAINTPL_TMP', 'resource.thumbnails_cache' => 'config.CACHEDIR', 'resource.page_cache' => 'config.PAGECACHE', @@@ -71,7 -72,7 +72,7 @@@ /** * @inheritdoc */ - function read($filepath) + public function read($filepath) { if (! file_exists($filepath) || ! is_readable($filepath)) { return array(); @@@ -91,7 -92,7 +92,7 @@@ /** * @inheritdoc */ - function write($filepath, $conf) + public function write($filepath, $conf) { $configStr = ' $value) { $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL; @@@ -125,7 -126,7 +126,7 @@@ /** * @inheritdoc */ - function getExtension() + public function getExtension() { return '.php'; } diff --combined index.php index 0639e85f,14754269..e553d1dd --- a/index.php +++ b/index.php @@@ -79,6 -79,7 +79,7 @@@ require_once 'application/Utils.php' require_once 'application/PluginManager.php'; require_once 'application/Router.php'; require_once 'application/Updater.php'; + use \Shaarli\ThemeUtils; // Ensure the PHP version is supported try { @@@ -122,7 -123,7 +123,7 @@@ if (isset($_COOKIE['shaarli']) && !is_s $conf = new ConfigManager(); $conf->setEmpty('general.timezone', date_default_timezone_get()); $conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER))); - RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl'); // template directory + RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory $pluginManager = new PluginManager($conf); @@@ -617,7 -618,7 +618,7 @@@ function showDailyRSS($conf) $tpl->assign('links', $links); $tpl->assign('rssdate', escape($dayDate->format(DateTime::RSS))); $tpl->assign('hide_timestamps', $conf->get('privacy.hide_timestamps', false)); - $html = $tpl->draw('dailyrss', $return_string=true); + $html = $tpl->draw('dailyrss', true); echo $html . PHP_EOL; } @@@ -1124,6 -1125,7 +1125,7 @@@ function renderPage($conf, $pluginManag $conf->set('general.timezone', $tz); $conf->set('general.title', escape($_POST['title'])); $conf->set('general.header_link', escape($_POST['titleLink'])); + $conf->set('resource.theme', escape($_POST['theme'])); $conf->set('redirector.url', escape($_POST['redirector'])); $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection'])); $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault'])); @@@ -1134,6 -1136,7 +1136,7 @@@ $conf->set('api.secret', escape($_POST['apiSecret'])); try { $conf->write(isLoggedIn()); + invalidateCaches($conf->get('resource.page_cache')); } catch(Exception $e) { error_log( @@@ -1151,6 -1154,8 +1154,8 @@@ else // Show the configuration form. { $PAGE->assign('title', $conf->get('general.title')); + $PAGE->assign('theme', $conf->get('resource.theme')); + $PAGE->assign('theme_available', ThemeUtils::getThemes($conf->get('resource.raintpl_tpl'))); $PAGE->assign('redirector', $conf->get('redirector.url')); list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone')); $PAGE->assign('timezone_form', $timezone_form);