Change templates set through administration UI

This commit is contained in:
Knah Tsaeb 2016-12-07 11:58:25 +01:00 committed by ArthurHoaro
parent fc11ab2f29
commit adc4aee80f
41 changed files with 52 additions and 14 deletions

View file

@ -150,6 +150,7 @@ public static function checkResourcePermissions($conf)
'inc', 'inc',
'plugins', 'plugins',
$conf->get('resource.raintpl_tpl'), $conf->get('resource.raintpl_tpl'),
$conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme'),
) as $path) { ) as $path) {
if (! is_readable(realpath($path))) { if (! is_readable(realpath($path))) {
$errors[] = '"'.$path.'" directory is not readable'; $errors[] = '"'.$path.'" directory is not readable';

View file

@ -79,7 +79,7 @@ private function initialize()
$this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
$this->tpl->assign('token', getToken($this->conf)); $this->tpl->assign('token', getToken($this->conf));
// To be removed with a proper theme configuration. // To be removed with a proper theme configuration.
$this->tpl->assign('conf', $this->conf); $this->tpl->assign('theme', $this->conf->get('resource.theme', 'default'));
} }
/** /**

View file

@ -270,3 +270,13 @@ function normalize_spaces($string)
{ {
return preg_replace('/\s{2,}/', ' ', trim($string)); return preg_replace('/\s{2,}/', ' ', trim($string));
} }
function getAllTheme($raintpl_tpl)
{
$allTheme = glob($raintpl_tpl.'/*', GLOB_ONLYDIR);
foreach ($allTheme as $value) {
$themes[] = str_replace($raintpl_tpl.'/', '', $value);
}
return $themes;
}

View file

@ -299,6 +299,7 @@ protected function setDefaultValues()
$this->setEmpty('resource.log', 'data/log.txt'); $this->setEmpty('resource.log', 'data/log.txt');
$this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt'); $this->setEmpty('resource.update_check', 'data/lastupdatecheck.txt');
$this->setEmpty('resource.raintpl_tpl', 'tpl/'); $this->setEmpty('resource.raintpl_tpl', 'tpl/');
$this->setEmpty('resource.theme', 'default');
$this->setEmpty('resource.raintpl_tmp', 'tmp/'); $this->setEmpty('resource.raintpl_tmp', 'tmp/');
$this->setEmpty('resource.thumbnails_cache', 'cache'); $this->setEmpty('resource.thumbnails_cache', 'cache');
$this->setEmpty('resource.page_cache', 'pagecache'); $this->setEmpty('resource.page_cache', 'pagecache');

View file

@ -41,6 +41,7 @@ class ConfigPhp implements ConfigIO
'resource.log' => 'config.LOG_FILE', 'resource.log' => 'config.LOG_FILE',
'resource.update_check' => 'config.UPDATECHECK_FILENAME', 'resource.update_check' => 'config.UPDATECHECK_FILENAME',
'resource.raintpl_tpl' => 'config.RAINTPL_TPL', 'resource.raintpl_tpl' => 'config.RAINTPL_TPL',
'resource.theme' => 'config.theme',
'resource.raintpl_tmp' => 'config.RAINTPL_TMP', 'resource.raintpl_tmp' => 'config.RAINTPL_TMP',
'resource.thumbnails_cache' => 'config.CACHEDIR', 'resource.thumbnails_cache' => 'config.CACHEDIR',
'resource.page_cache' => 'config.PAGECACHE', 'resource.page_cache' => 'config.PAGECACHE',
@ -99,7 +100,7 @@ function write($filepath, $conf)
$configStr .= '$GLOBALS[\'' . $key . '\'] = ' . var_export($conf[$key], true) . ';' . PHP_EOL; $configStr .= '$GLOBALS[\'' . $key . '\'] = ' . var_export($conf[$key], true) . ';' . PHP_EOL;
} }
} }
// Store all $conf['config'] // Store all $conf['config']
foreach ($conf['config'] as $key => $value) { foreach ($conf['config'] as $key => $value) {
$configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL; $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL;

View file

@ -122,7 +122,8 @@
$conf = new ConfigManager(); $conf = new ConfigManager();
$conf->setEmpty('general.timezone', date_default_timezone_get()); $conf->setEmpty('general.timezone', date_default_timezone_get());
$conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER))); $conf->setEmpty('general.title', 'Shared links on '. escape(index_url($_SERVER)));
RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl'); // template directory $conf->setEmpty('resource.theme', 'default');
RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory
RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory
$pluginManager = new PluginManager($conf); $pluginManager = new PluginManager($conf);
@ -1124,6 +1125,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
$conf->set('general.timezone', $tz); $conf->set('general.timezone', $tz);
$conf->set('general.title', escape($_POST['title'])); $conf->set('general.title', escape($_POST['title']));
$conf->set('general.header_link', escape($_POST['titleLink'])); $conf->set('general.header_link', escape($_POST['titleLink']));
$conf->set('resource.theme', escape($_POST['theme']));
$conf->set('redirector.url', escape($_POST['redirector'])); $conf->set('redirector.url', escape($_POST['redirector']));
$conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection'])); $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection']));
$conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault'])); $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault']));
@ -1134,6 +1136,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
$conf->set('api.secret', escape($_POST['apiSecret'])); $conf->set('api.secret', escape($_POST['apiSecret']));
try { try {
$conf->write(isLoggedIn()); $conf->write(isLoggedIn());
invalidateCaches($conf->get('resource.page_cache'));
} }
catch(Exception $e) { catch(Exception $e) {
error_log( error_log(
@ -1151,6 +1154,8 @@ function renderPage($conf, $pluginManager, $LINKSDB)
else // Show the configuration form. else // Show the configuration form.
{ {
$PAGE->assign('title', $conf->get('general.title')); $PAGE->assign('title', $conf->get('general.title'));
$PAGE->assign('theme', $conf->get('resource.theme'));
$PAGE->assign('theme_available', getAllTheme($conf->get('resource.raintpl_tpl')));
$PAGE->assign('redirector', $conf->get('redirector.url')); $PAGE->assign('redirector', $conf->get('redirector.url'));
list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone')); list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone'));
$PAGE->assign('timezone_form', $timezone_form); $PAGE->assign('timezone_form', $timezone_form);

View file

@ -289,6 +289,7 @@ public function testCheckCurrentResourcePermissions()
$conf->set('resource.page_cache', 'pagecache'); $conf->set('resource.page_cache', 'pagecache');
$conf->set('resource.raintpl_tmp', 'tmp'); $conf->set('resource.raintpl_tmp', 'tmp');
$conf->set('resource.raintpl_tpl', 'tpl'); $conf->set('resource.raintpl_tpl', 'tpl');
$conf->set('resource.theme', 'default');
$conf->set('resource.update_check', 'data/lastupdatecheck.txt'); $conf->set('resource.update_check', 'data/lastupdatecheck.txt');
$this->assertEquals( $this->assertEquals(
@ -312,10 +313,12 @@ public function testCheckCurrentResourcePermissionsErrors()
$conf->set('resource.page_cache', 'null/pagecache'); $conf->set('resource.page_cache', 'null/pagecache');
$conf->set('resource.raintpl_tmp', 'null/tmp'); $conf->set('resource.raintpl_tmp', 'null/tmp');
$conf->set('resource.raintpl_tpl', 'null/tpl'); $conf->set('resource.raintpl_tpl', 'null/tpl');
$conf->set('resource.raintpl_theme', 'null/tpl/default');
$conf->set('resource.update_check', 'null/data/lastupdatecheck.txt'); $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
$this->assertEquals( $this->assertEquals(
array( array(
'"null/tpl" directory is not readable', '"null/tpl" directory is not readable',
'"null/tpl/default" directory is not readable',
'"null/cache" directory is not readable', '"null/cache" directory is not readable',
'"null/cache" directory is not writable', '"null/cache" directory is not writable',
'"null/data" directory is not readable', '"null/data" directory is not readable',

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>{include="includes"} <head>{include="includes"}
<link type="text/css" rel="stylesheet" href="../inc/awesomplete.css" /> <link type="text/css" rel="stylesheet" href="inc/awesomplete.css#" />
<script src="inc/awesomplete.min.js#"></script> <script src="inc/awesomplete.min.js#"></script>
</head> </head>
<body onload="document.changetag.fromtag.focus();"> <body onload="document.changetag.fromtag.focus();">

View file

@ -19,6 +19,23 @@
<td><input type="text" name="titleLink" id="titleLink" size="50" value="{$titleLink}"><br/><label <td><input type="text" name="titleLink" id="titleLink" size="50" value="{$titleLink}"><br/><label
for="titleLink">(default value is: ?)</label></td> for="titleLink">(default value is: ?)</label></td>
</tr> </tr>
<tr>
<td><b>Theme:</b></td>
<td>
<select name="theme" id="theme">
{loop="$theme_available"}
{if="$value===$theme"}
<option selected value="{$value}">{$value|ucfirst}</option>
{else}
<option value="{$value}">{$value|ucfirst}</option>
{/if}
{/loop}
</select>
<label for="theme">(default value is: Default)</label>
</td>
</tr>
<tr> <tr>
<td><b>Timezone:</b></td> <td><b>Timezone:</b></td>
<td>{$timezone_form}</td> <td>{$timezone_form}</td>

View file

@ -28,9 +28,9 @@
</div> </div>
<div class="dailyTitle"> <div class="dailyTitle">
<img src="../images/floral_left.png" width="51" height="50" class="nomobile" alt="floral_left"> <img src="../../images/floral_left.png" width="51" height="50" class="nomobile" alt="floral_left">
The Daily Shaarli The Daily Shaarli
<img src="../images/floral_right.png" width="51" height="50" class="nomobile" alt="floral_right"> <img src="../../images/floral_right.png" width="51" height="50" class="nomobile" alt="floral_right">
</div> </div>
<div class="dailyDate"> <div class="dailyDate">
@ -50,7 +50,7 @@
<div class="dailyEntry"> <div class="dailyEntry">
<div class="dailyEntryPermalink"> <div class="dailyEntryPermalink">
<a href="?{$value.shorturl}"> <a href="?{$value.shorturl}">
<img src="../images/squiggle2.png" width="25" height="26" title="permalink" alt="permalink"> <img src="../../images/squiggle2.png" width="25" height="26" title="permalink" alt="permalink">
</a> </a>
</div> </div>
{if="!$hide_timestamps || isLoggedIn()"} {if="!$hide_timestamps || isLoggedIn()"}
@ -94,7 +94,7 @@
{$value} {$value}
{/loop} {/loop}
</div> </div>
<div id="closing"><img src="../images/squiggle_closing.png" width="66" height="61" alt="-"></div> <div id="closing"><img src="../../images/squiggle_closing.png" width="66" height="61" alt="-"></div>
</div> </div>
{include="page.footer"} {include="page.footer"}
</body> </body>

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>{include="includes"} <head>{include="includes"}
<link type="text/css" rel="stylesheet" href="../inc/awesomplete.css" /> <link type="text/css" rel="stylesheet" href="inc/awesomplete.css#" />
</head> </head>
<body <body
{if="$link.title==''"}onload="document.linkform.lf_title.focus();" {if="$link.title==''"}onload="document.linkform.lf_title.focus();"

View file

Before

Width:  |  Height:  |  Size: 599 B

After

Width:  |  Height:  |  Size: 599 B

View file

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 124 KiB

View file

Before

Width:  |  Height:  |  Size: 650 B

After

Width:  |  Height:  |  Size: 650 B

View file

Before

Width:  |  Height:  |  Size: 813 B

After

Width:  |  Height:  |  Size: 813 B

View file

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 714 B

View file

@ -103,7 +103,7 @@ strong {
} }
#pageheader #logo { #pageheader #logo {
background-image: url('../images/logo.png'); background-image: url('../../../images/logo.png');
background-repeat: no-repeat; background-repeat: no-repeat;
float: left; float: left;
margin: 0 10px 0 10px; margin: 0 10px 0 10px;

View file

@ -6,9 +6,9 @@
<link rel="alternate" type="application/rss+xml" href="{$feedurl}?do=rss{$searchcrits}#" title="RSS Feed" /> <link rel="alternate" type="application/rss+xml" href="{$feedurl}?do=rss{$searchcrits}#" title="RSS Feed" />
<link rel="alternate" type="application/atom+xml" href="{$feedurl}?do=atom{$searchcrits}#" title="ATOM Feed" /> <link rel="alternate" type="application/atom+xml" href="{$feedurl}?do=atom{$searchcrits}#" title="ATOM Feed" />
<link href="images/favicon.ico#" rel="shortcut icon" type="image/x-icon" /> <link href="images/favicon.ico#" rel="shortcut icon" type="image/x-icon" />
<link type="text/css" rel="stylesheet" href="../inc/reset.css" /> <link type="text/css" rel="stylesheet" href="inc/reset.css" />
<link type="text/css" rel="stylesheet" href="../inc/shaarli.css" /> <link type="text/css" rel="stylesheet" href="inc/shaarli.css" />
{if="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="../inc/user.css" />{/if} {if="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="inc/user.css#" />{/if}
{loop="$plugins_includes.css_files"} {loop="$plugins_includes.css_files"}
<link type="text/css" rel="stylesheet" href="{$value}#"/> <link type="text/css" rel="stylesheet" href="{$value}#"/>
{/loop} {/loop}

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<link type="text/css" rel="stylesheet" href="../inc/awesomplete.css" /> <link type="text/css" rel="stylesheet" href="inc/awesomplete.css#" />
{include="includes"} {include="includes"}
</head> </head>
<body> <body>