From d33763a409bbc11198e56764f43093bb18eeb91f Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Wed, 7 Dec 2016 11:58:25 +0100 Subject: [PATCH] #502 Change templates set through administration UI --- application/ApplicationUtils.php | 2 +- application/PageBuilder.php | 2 +- application/Utils.php | 10 ++++++++++ application/config/ConfigManager.php | 4 ++-- application/config/ConfigPhp.php | 2 +- doc/Shaarli-configuration.html | 4 ++-- doc/Shaarli-configuration.md | 4 ++-- doc/Theming.html | 2 +- doc/Theming.md | 2 +- index.php | 7 +++++-- tests/ApplicationUtilsTest.php | 4 ++-- tpl/{ => Default}/404.html | 0 tpl/{ => Default}/addlink.html | 0 tpl/{ => Default}/changepassword.html | 0 tpl/{ => Default}/changetag.html | 0 tpl/{ => Default}/configure.html | 17 +++++++++++++++++ tpl/{ => Default}/daily.html | 8 ++++---- tpl/{ => Default}/dailyrss.html | 0 tpl/{ => Default}/editlink.html | 0 tpl/{ => Default}/export.bookmarks.html | 0 tpl/{ => Default}/export.html | 0 tpl/{ => Default}/feed.atom.html | 0 tpl/{ => Default}/feed.rss.html | 0 tpl/{ => Default}/import.html | 0 tpl/{ => Default}/includes.html | 6 +++--- tpl/{ => Default}/install.html | 0 tpl/{ => Default}/linklist.html | 2 +- tpl/{ => Default}/linklist.paging.html | 0 tpl/{ => Default}/loginform.html | 0 tpl/{ => Default}/opensearch.html | 0 tpl/{ => Default}/page.footer.html | 0 tpl/{ => Default}/page.header.html | 0 tpl/{ => Default}/page.html | 0 tpl/{ => Default}/picwall.html | 0 tpl/{ => Default}/pluginsadmin.html | 0 tpl/{ => Default}/readme.txt | 0 {inc => tpl/Default}/reset.css | 0 {inc => tpl/Default}/shaarli.css | 12 ++++++------ tpl/{ => Default}/tagcloud.html | 0 tpl/{ => Default}/tools.html | 0 40 files changed, 59 insertions(+), 29 deletions(-) rename tpl/{ => Default}/404.html (100%) rename tpl/{ => Default}/addlink.html (100%) rename tpl/{ => Default}/changepassword.html (100%) rename tpl/{ => Default}/changetag.html (100%) rename tpl/{ => Default}/configure.html (86%) rename tpl/{ => Default}/daily.html (88%) rename tpl/{ => Default}/dailyrss.html (100%) rename tpl/{ => Default}/editlink.html (100%) rename tpl/{ => Default}/export.bookmarks.html (100%) rename tpl/{ => Default}/export.html (100%) rename tpl/{ => Default}/feed.atom.html (100%) rename tpl/{ => Default}/feed.rss.html (100%) rename tpl/{ => Default}/import.html (100%) rename tpl/{ => Default}/includes.html (83%) rename tpl/{ => Default}/install.html (100%) rename tpl/{ => Default}/linklist.html (98%) rename tpl/{ => Default}/linklist.paging.html (100%) rename tpl/{ => Default}/loginform.html (100%) rename tpl/{ => Default}/opensearch.html (100%) rename tpl/{ => Default}/page.footer.html (100%) rename tpl/{ => Default}/page.header.html (100%) rename tpl/{ => Default}/page.html (100%) rename tpl/{ => Default}/picwall.html (100%) rename tpl/{ => Default}/pluginsadmin.html (100%) rename tpl/{ => Default}/readme.txt (100%) rename {inc => tpl/Default}/reset.css (100%) rename {inc => tpl/Default}/shaarli.css (98%) rename tpl/{ => Default}/tagcloud.html (100%) rename tpl/{ => Default}/tools.html (100%) diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php index 7f963e9..c0b03a3 100644 --- a/application/ApplicationUtils.php +++ b/application/ApplicationUtils.php @@ -149,7 +149,7 @@ class ApplicationUtils 'application', 'inc', 'plugins', - $conf->get('resource.raintpl_tpl'), + 'tpl/'.$conf->get('resource.theme'), ) as $path) { if (! is_readable(realpath($path))) { $errors[] = '"'.$path.'" directory is not readable'; diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 32c7f9f..7cddb71 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -79,7 +79,7 @@ class PageBuilder $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); $this->tpl->assign('token', getToken($this->conf)); // To be removed with a proper theme configuration. - $this->tpl->assign('conf', $this->conf); + $this->tpl->assign('conf', $this->conf->get('resource.theme', 'Default')); } /** diff --git a/application/Utils.php b/application/Utils.php index 0166ee2..d03af31 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -227,3 +227,13 @@ function autoLocale($headerLocale) } setlocale(LC_ALL, $attempts); } + +function getAllTheme() +{ + $allTheme = glob('tpl/*', GLOB_ONLYDIR); + foreach ($allTheme as $value) { + $themes[] = str_replace('tpl/', '', $value); + } + + return $themes; +} diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php index f5f753f..77804b8 100644 --- a/application/config/ConfigManager.php +++ b/application/config/ConfigManager.php @@ -189,7 +189,7 @@ class ConfigManager 'general.title', 'general.header_link', 'privacy.default_private_links', - 'redirector.url', + 'redirector.url' ); // Only logged in user can alter config. @@ -296,7 +296,7 @@ class ConfigManager $this->setEmpty('resource.updates', 'data/updates.txt'); $this->setEmpty('resource.log', 'data/log.txt'); $this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt'); - $this->setEmpty('resource.raintpl_tpl', 'tpl/'); + $this->setEmpty('resource.theme', 'Default'); $this->setEmpty('resource.raintpl_tmp', 'tmp/'); $this->setEmpty('resource.thumbnails_cache', 'cache'); $this->setEmpty('resource.page_cache', 'pagecache'); diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php index 27187b6..5752d37 100644 --- a/application/config/ConfigPhp.php +++ b/application/config/ConfigPhp.php @@ -40,7 +40,7 @@ class ConfigPhp implements ConfigIO 'resource.updates' => 'config.UPDATES_FILE', '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', diff --git a/doc/Shaarli-configuration.html b/doc/Shaarli-configuration.html index 6d717c6..3494506 100644 --- a/doc/Shaarli-configuration.html +++ b/doc/Shaarli-configuration.html @@ -172,7 +172,7 @@ It might be useful if your IP adress often changes.
updates: File path for the ran updates file.
log: Log file path.
update_check: Last update check file path.
-raintpl_tpl: Templates directory.
+theme: Templates directory.
raintpl_tmp: Template engine cache directory.
thumbnails_cache: Thumbnails cache directory.
page_cache: Shaarli's internal cache directory.
@@ -220,7 +220,7 @@ It might be useful if your IP adress often changes.
"log": "data\/log.txt", "update_check": "data\/lastupdatecheck.txt", "raintpl_tmp": "tmp\/", - "raintpl_tpl": "tpl\/", + "theme": "tpl\/", "thumbnails_cache": "cache", "page_cache": "pagecache" }, diff --git a/doc/Shaarli-configuration.md b/doc/Shaarli-configuration.md index 4a783c0..430bc5f 100644 --- a/doc/Shaarli-configuration.md +++ b/doc/Shaarli-configuration.md @@ -73,7 +73,7 @@ It might be useful if your IP adress often changes. **updates**: File path for the ran updates file. **log**: Log file path. **update_check**: Last update check file path. -**raintpl_tpl**: Templates directory. +**theme**: Templates directory. **raintpl_tmp**: Template engine cache directory. **thumbnails_cache**: Thumbnails cache directory. **page_cache**: Shaarli's internal cache directory. @@ -134,7 +134,7 @@ It might be useful if your IP adress often changes. "log": "data\/log.txt", "update_check": "data\/lastupdatecheck.txt", "raintpl_tmp": "tmp\/", - "raintpl_tpl": "tpl\/", + "theme": "tpl\/", "thumbnails_cache": "cache", "page_cache": "pagecache" }, diff --git a/doc/Theming.html b/doc/Theming.html index 13e6acf..13dda02 100644 --- a/doc/Theming.html +++ b/doc/Theming.html @@ -120,7 +120,7 @@ code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Inf
  • There should now be a my-template/ directory under the tpl/ dir, containing directly all the template files.
  • Edit data/config.php to have Shaarli use this template, e.g.

    -
    $GLOBALS['config'['RAINTPL_TPL'] = 'tpl/my-template/';]('RAINTPL_TPL']-=-'tpl/my-template/';.html)
  • +
    $GLOBALS['config'['theme'] = 'tpl/my-template/';]('theme']-=-'tpl/my-template/';.html)

    Community themes & templates