]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #732 from ArthurHoaro/feature/theme-manager
authorArthur <arthur@hoa.ro>
Fri, 6 Jan 2017 10:40:54 +0000 (11:40 +0100)
committerGitHub <noreply@github.com>
Fri, 6 Jan 2017 10:40:54 +0000 (11:40 +0100)
Theme manager: improvements

1  2 
application/config/ConfigPhp.php
index.php

index 9dd9a65dd5c35ba25ce43185c808fb0740171b0e,2eb68d80a5b9d517a7f0eb36f112d0124df5b0e4..d7fd4baffa34d2fa3cec5bcb83f108c3571af97a
@@@ -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 = '<?php '. PHP_EOL;
          foreach (self::$ROOT_KEYS as $key) {
                  $configStr .= '$GLOBALS[\'' . $key . '\'] = ' . var_export($conf[$key], true) . ';' . PHP_EOL;
              }
          }
-         
          // Store all $conf['config']
          foreach ($conf['config'] as $key => $value) {
              $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL;
      /**
       * @inheritdoc
       */
 -    function getExtension()
 +    public function getExtension()
      {
          return '.php';
      }
diff --combined index.php
index 0639e85f32a82bf90de26f3087a496287d4a3d49,14754269f38dbbf9df72651f96fd2f282c464040..e553d1ddcfd3564f3a8abdeeb575a9f428ee248b
+++ 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']));
              $conf->set('api.secret', escape($_POST['apiSecret']));
              try {
                  $conf->write(isLoggedIn());
+                 invalidateCaches($conf->get('resource.page_cache'));
              }
              catch(Exception $e) {
                  error_log(
          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);