#502 Change templates set through administration UI
This commit is contained in:
parent
bea80e43a3
commit
d33763a409
40 changed files with 59 additions and 29 deletions
|
@ -149,7 +149,7 @@ public static function checkResourcePermissions($conf)
|
|||
'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';
|
||||
|
|
|
@ -79,7 +79,7 @@ private function initialize()
|
|||
$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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ public function write($isLoggedIn)
|
|||
'general.title',
|
||||
'general.header_link',
|
||||
'privacy.default_private_links',
|
||||
'redirector.url',
|
||||
'redirector.url'
|
||||
);
|
||||
|
||||
// Only logged in user can alter config.
|
||||
|
@ -296,7 +296,7 @@ protected function setDefaultValues()
|
|||
$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');
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -172,7 +172,7 @@ <h3 id="resources">Resources</h3>
|
|||
<strong>updates</strong>: File path for the ran updates file.<br />
|
||||
<strong>log</strong>: Log file path.<br />
|
||||
<strong>update_check</strong>: Last update check file path.<br />
|
||||
<strong>raintpl_tpl</strong>: Templates directory.<br />
|
||||
<strong>theme</strong>: Templates directory.<br />
|
||||
<strong>raintpl_tmp</strong>: Template engine cache directory.<br />
|
||||
<strong>thumbnails_cache</strong>: Thumbnails cache directory.<br />
|
||||
<strong>page_cache</strong>: Shaarli's internal cache directory.<br />
|
||||
|
@ -220,7 +220,7 @@ <h2 id="configuration-file-example">Configuration file example</h2>
|
|||
<span class="dt">"log"</span><span class="fu">:</span> <span class="st">"data</span><span class="ch">\/</span><span class="st">log.txt"</span><span class="fu">,</span>
|
||||
<span class="dt">"update_check"</span><span class="fu">:</span> <span class="st">"data</span><span class="ch">\/</span><span class="st">lastupdatecheck.txt"</span><span class="fu">,</span>
|
||||
<span class="dt">"raintpl_tmp"</span><span class="fu">:</span> <span class="st">"tmp</span><span class="ch">\/</span><span class="st">"</span><span class="fu">,</span>
|
||||
<span class="dt">"raintpl_tpl"</span><span class="fu">:</span> <span class="st">"tpl</span><span class="ch">\/</span><span class="st">"</span><span class="fu">,</span>
|
||||
<span class="dt">"theme"</span><span class="fu">:</span> <span class="st">"tpl</span><span class="ch">\/</span><span class="st">"</span><span class="fu">,</span>
|
||||
<span class="dt">"thumbnails_cache"</span><span class="fu">:</span> <span class="st">"cache"</span><span class="fu">,</span>
|
||||
<span class="dt">"page_cache"</span><span class="fu">:</span> <span class="st">"pagecache"</span>
|
||||
<span class="fu">},</span>
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -120,7 +120,7 @@ <h2 id="raintpl-template">RainTPL template</h2>
|
|||
<li>There should now be a <code>my-template/</code> directory under the <code>tpl/</code> dir, containing directly all the template files.</li>
|
||||
</ul></li>
|
||||
<li><p>Edit <code>data/config.php</code> to have Shaarli use this template, e.g.</p>
|
||||
<div class="sourceCode"><pre class="sourceCode php"><code class="sourceCode php"><span class="kw">$GLOBALS</span><span class="ot">[</span><span class="st">'config'</span><span class="ot">[</span><span class="st">'RAINTPL_TPL'</span><span class="ot">]</span> = <span class="st">'tpl/my-template/'</span><span class="ot">;](</span><span class="st">'RAINTPL_TPL'</span><span class="ot">]</span>-=-<span class="st">'tpl/my-template/'</span><span class="ot">;</span>.html<span class="ot">)</span></code></pre></div></li>
|
||||
<div class="sourceCode"><pre class="sourceCode php"><code class="sourceCode php"><span class="kw">$GLOBALS</span><span class="ot">[</span><span class="st">'config'</span><span class="ot">[</span><span class="st">'theme'</span><span class="ot">]</span> = <span class="st">'tpl/my-template/'</span><span class="ot">;](</span><span class="st">'theme'</span><span class="ot">]</span>-=-<span class="st">'tpl/my-template/'</span><span class="ot">;</span>.html<span class="ot">)</span></code></pre></div></li>
|
||||
</ul>
|
||||
<h2 id="community-themes-templates">Community themes & templates</h2>
|
||||
<ul>
|
||||
|
|
|
@ -18,7 +18,7 @@ _WARNING - This feature is currently being worked on and will be improved in the
|
|||
- 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.
|
||||
```php
|
||||
$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
|
||||
|
|
|
@ -122,12 +122,12 @@
|
|||
$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
|
||||
$conf->setEmpty('resource.theme', 'Default');
|
||||
RainTPL::$tpl_dir = 'tpl/'.$conf->get('resource.theme').'/'; // template directory
|
||||
RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory
|
||||
|
||||
$pluginManager = new PluginManager($conf);
|
||||
$pluginManager->load($conf->get('general.enabled_plugins'));
|
||||
|
||||
date_default_timezone_set($conf->get('general.timezone', 'UTC'));
|
||||
|
||||
ob_start(); // Output buffering for the page cache.
|
||||
|
@ -1148,6 +1148,7 @@ function renderPage($conf, $pluginManager)
|
|||
$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']));
|
||||
|
@ -1173,6 +1174,8 @@ function renderPage($conf, $pluginManager)
|
|||
else // Show the configuration form.
|
||||
{
|
||||
$PAGE->assign('title', $conf->get('general.title'));
|
||||
$PAGE->assign('theme', $conf->get('resource.theme'));
|
||||
$PAGE->assign('theme_avaible', getAllTheme());
|
||||
$PAGE->assign('redirector', $conf->get('redirector.url'));
|
||||
list($timezone_form, $timezone_js) = generateTimeZoneForm($conf->get('general.timezone'));
|
||||
$PAGE->assign('timezone_form', $timezone_form);
|
||||
|
|
|
@ -288,7 +288,7 @@ public function testCheckCurrentResourcePermissions()
|
|||
$conf->set('resource.log', 'data/log.txt');
|
||||
$conf->set('resource.page_cache', 'pagecache');
|
||||
$conf->set('resource.raintpl_tmp', 'tmp');
|
||||
$conf->set('resource.raintpl_tpl', 'tpl');
|
||||
$conf->set('resource.theme', 'tpl');
|
||||
$conf->set('resource.update_check', 'data/lastupdatecheck.txt');
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -311,7 +311,7 @@ public function testCheckCurrentResourcePermissionsErrors()
|
|||
$conf->set('resource.log', 'null/data/log.txt');
|
||||
$conf->set('resource.page_cache', 'null/pagecache');
|
||||
$conf->set('resource.raintpl_tmp', 'null/tmp');
|
||||
$conf->set('resource.raintpl_tpl', 'null/tpl');
|
||||
$conf->set('resource.theme', 'null/tpl');
|
||||
$conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
|
||||
$this->assertEquals(
|
||||
array(
|
||||
|
|
|
@ -19,6 +19,23 @@
|
|||
<td><input type="text" name="titleLink" id="titleLink" size="50" value="{$titleLink}"><br/><label
|
||||
for="titleLink">(default value is: ?)</label></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><b>Theme:</b></td>
|
||||
<td>
|
||||
<select name="theme" id="theme">
|
||||
{loop="$theme_avaible"}
|
||||
{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>
|
||||
<td><b>Timezone:</b></td>
|
||||
<td>{$timezone_form}</td>
|
|
@ -28,9 +28,9 @@
|
|||
</div>
|
||||
|
||||
<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
|
||||
<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 class="dailyDate">
|
||||
|
@ -50,7 +50,7 @@
|
|||
<div class="dailyEntry">
|
||||
<div class="dailyEntryPermalink">
|
||||
<a href="?{$link.linkdate|smallHash}">
|
||||
<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>
|
||||
</div>
|
||||
{if="!$hide_timestamps || isLoggedIn()"}
|
||||
|
@ -94,7 +94,7 @@
|
|||
{$value}
|
||||
{/loop}
|
||||
</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>
|
||||
{include="page.footer"}
|
||||
</body>
|
|
@ -6,9 +6,9 @@
|
|||
<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 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/shaarli.css" />
|
||||
{if="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="../inc/user.css" />{/if}
|
||||
<link type="text/css" rel="stylesheet" href="reset.css" />
|
||||
<link type="text/css" rel="stylesheet" href="shaarli.css" />
|
||||
{if="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="../../inc/user.css" />{/if}
|
||||
{loop="$plugins_includes.css_files"}
|
||||
<link type="text/css" rel="stylesheet" href="{$value}#"/>
|
||||
{/loop}
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link type="text/css" rel="stylesheet" href="../inc/awesomplete.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../../inc/awesomplete.css" />
|
||||
{include="includes"}
|
||||
</head>
|
||||
<body>
|
|
@ -103,7 +103,7 @@ strong {
|
|||
}
|
||||
|
||||
#pageheader #logo {
|
||||
background-image: url('../images/logo.png');
|
||||
background-image: url('../../images/logo.png');
|
||||
background-repeat: no-repeat;
|
||||
float: left;
|
||||
margin: 0 10px 0 10px;
|
||||
|
@ -423,7 +423,7 @@ strong {
|
|||
}
|
||||
|
||||
#linklist li.private {
|
||||
background: url('../images/private.png') no-repeat 4px center;
|
||||
background: url('../../../images/private.png') no-repeat 4px center;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ strong {
|
|||
}
|
||||
|
||||
.linkdate a {
|
||||
background-image: url('../images/calendar.png');
|
||||
background-image: url('../../images/calendar.png');
|
||||
padding: 2px 0 3px 20px;
|
||||
background-repeat: no-repeat;
|
||||
text-decoration: none;
|
||||
|
@ -506,7 +506,7 @@ strong {
|
|||
height: 20px;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
background-image: url('../images/tag_blue.png');
|
||||
background-image: url('../../images/tag_blue.png');
|
||||
background-repeat: no-repeat;
|
||||
background-position: 3px center;
|
||||
background-color: #ffffff;
|
||||
|
@ -752,7 +752,7 @@ div.daily {
|
|||
/* Background paper texture by BashCorpo:
|
||||
http://www.bashcorpo.dk/textures.php
|
||||
http://bashcorpo.deviantart.com/art/Grungy-paper-texture-v-5-22966998 */
|
||||
background-image: url("../images/Paper_texture_v5_by_bashcorpo_w1000.jpg");
|
||||
background-image: url("../../images/Paper_texture_v5_by_bashcorpo_w1000.jpg");
|
||||
-webkit-background-size: cover;
|
||||
-moz-background-size: cover;
|
||||
-o-background-size: cover;
|
||||
|
@ -846,7 +846,7 @@ div.dailyEntryThumbnail {
|
|||
width: 100%;
|
||||
text-align: center;
|
||||
background-color: rgb(128, 128, 128);
|
||||
background: url(../images/50pc_transparent.png);
|
||||
background: url(../../images/50pc_transparent.png);
|
||||
padding: 4px 0px 2px 0px;
|
||||
}
|
||||
|
Loading…
Reference in a new issue