Browse Source

Config page revamp

pull/436/head
danpros 4 years ago
parent
commit
2a64d44302
11 changed files with 970 additions and 65 deletions
  1. +1
    -5
      README.md
  2. +3
    -0
      config/config.ini.example
  3. +47
    -0
      system/admin/views/config-custom.html.php
  4. +56
    -0
      system/admin/views/config-metatags.html.php
  5. +95
    -0
      system/admin/views/config-performance.html.php
  6. +120
    -0
      system/admin/views/config-reading.html.php
  7. +146
    -0
      system/admin/views/config-widget.html.php
  8. +116
    -47
      system/admin/views/config.html.php
  9. +25
    -1
      system/admin/views/layout.html.php
  10. +341
    -1
      system/htmly.php
  11. +20
    -11
      system/includes/functions.php

+ 1
- 5
README.md View File

@ -43,6 +43,7 @@ Features
- Auto Update
- Post Draft
- i18n
- Menu builder
Requirements
------------
@ -267,11 +268,6 @@ Paragraph 1
Paragraph 2 etc.
```
Credit
------
* [Martin Angelov](http://tutorialzine.com)
* [Xiaoying Riley](http://themes.3rdwavemedia.com)
Contribute
----------
1. Fork and edit


+ 3
- 0
config/config.ini.example View File

@ -49,6 +49,9 @@ google.wmt.id = ""
; Google analytics
google.analytics.id = ""
; Google gtag analytics
google.gtag.id = ""
; Google reCaptcha
; https://www.google.com/recaptcha/admin. Options "false" and "true"


+ 47
- 0
system/admin/views/config-custom.html.php View File

@ -0,0 +1,47 @@
<h2>Your Custom Settings</h2>
<br>
<p><u>hint:</u> Use <code>Ctrl</code>/<code>CMD</code> + <code>F</code> to search for your config key or value.</p>
<p><u>pro tips:</u> You can creating custom config key and print out your config key value anywhere in your template.</p>
<p><code>&lt;?php echo config('your.key'); ?&gt;</code></p>
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<table class="table" id="config">
<tr>
<td><input type="text" class="form-control" name="newKey" placeholder="Your New Config Key"></td>
<td><input type="text" class="form-control" name="newValue" placeholder="Your New Value"></td>
</tr>
<?php
global $config_file;
$array = array(
"google.wmt" => "hallo",
);
if (file_exists($config_file)) {
$array = parse_ini_file($config_file, true);
}
function valueMaker($value)
{
if (is_string($value))
return htmlspecialchars($value);
if ($value === true)
return "true";
if ($value === false)
return "false";
if ($value == false)
return "0";
return (string)$value;
}
$configList = json_decode(file_get_contents('content/data/configList.json', true));
foreach ($array as $key => $value) {
if (!in_array($key, $configList)) {
echo '<tr>';
echo '<td><label for="' . $key . '">' . $key . '</label></td>';
echo '<td><input class="form-control" type="text" id="' . $key . '" name="-config-' . $key . '" value="' . valueMaker($value) . '"></td>';
echo '</tr>';
}
}
?>
</table>
<input type="submit" class="form-control btn-primary btn-sm" style="width:100px;">
</form>

+ 56
- 0
system/admin/views/config-metatags.html.php View File

@ -0,0 +1,56 @@
<?php
global $config_file;
$array = array();
if (file_exists($config_file)) {
$array = parse_ini_file($config_file, true);
}
?>
<h2>Metatags</h2>
<br><br>
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<div class="form-group row">
<label class="col-sm-2 col-form-label">Permalink</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-permalink.type" id="permalink.type1" value="default" <?php if (config('permalink.type') === 'default'):?>checked<?php endif;?>>
<label class="form-check-label" for="permalink.type1">
/year/month/your-post-slug
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-permalink.type" id="permalink.type1" value="post" <?php if (config('permalink.type') === 'post'):?>checked<?php endif;?>>
<label class="form-check-label" for="permalink.type2">
/post/your-post-slug
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="description.char" class="col-sm-2 col-form-label">Meta description character</label>
<div class="col-sm-10">
<input type="number" name="-config-description.char" class="form-control" id="description.char" value="<?php echo config('description.char');?>">
</div>
</div>
<br>
<h4>Sitemap</h4>
<hr>
<p>Valid values range from 0.0 to 1.0. See <a target="_blank" href="https://www.sitemaps.org/protocol.html">https://www.sitemaps.org/protocol.html</a></p>
<?php foreach($array as $key => $value) {?>
<?php if (stripos($key, 'sitemap.priority') !== false):?>
<div class="form-group row">
<label for="<?php echo $key;?>" class="col-sm-2 col-form-label"><?php echo $key;?></label>
<div class="col-sm-10">
<input step="any" type="number" name="-config-<?php echo $key;?>" class="form-control" id="<?php echo $key;?>" value="<?php echo $value;?>">
</div>
</div>
<?php endif; ?>
<?php } ?>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Save config</button>
</div>
</div>
</form>

+ 95
- 0
system/admin/views/config-performance.html.php View File

@ -0,0 +1,95 @@
<h2>Performance</h2>
<br><br>
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<div class="form-group row">
<label for="cache.expiration" class="col-sm-2 col-form-label">Cache expiration</label>
<div class="col-sm-10">
<input type="number" name="-config-cache.expiration" class="form-control" id="cache.expiration" value="<?php echo config('cache.expiration');?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Cache off</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-cache.off" id="cache.off1" value="true" <?php if (config('cache.off') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="cache.off1">
Yes (not recommended)
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-cache.off" id="cache.off2" value="false" <?php if (config('cache.off') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="cache.off2">
No
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Cache timestamp</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-cache.timestamp" id="cache.timestamp1" value="true" <?php if (config('cache.timestamp') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="cache.timestamp1">
Enable
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-cache.timestamp" id="cache.timestamp2" value="false" <?php if (config('cache.timestamp') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="generation.time2">
Disable
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Page generation time</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-generation.time" id="generation.time1" value="true" <?php if (config('generation.time') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="generation.time1">
Enable
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-generation.time" id="generation.time2" value="false" <?php if (config('generation.time') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="generation.time2">
Disable
</label>
</div>
</div>
</div>
</div>
<br>
<h4>Github pre-release</h4>
<hr>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Pre-release</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-prerelease" id="prerelease1" value="true" <?php if (config('prerelease') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="prerelease1">
Yes I'm in
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-prerelease" id="prerelease2" value="false" <?php if (config('prerelease') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="prerelease2">
Nope
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Save config</button>
</div>
</div>
</form>

+ 120
- 0
system/admin/views/config-reading.html.php View File

@ -0,0 +1,120 @@
<h2>Reading Settings</h2>
<br><br>
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<div class="form-group row">
<label class="col-sm-2 col-form-label">Front page displays</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-static.frontpage" id="static.frontpage1" value="false" <?php if (config('static.frontpage') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="static.frontpage1">
Your latest blog posts
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-static.frontpage" id="static.frontpage1" value="true" <?php if (config('static.frontpage') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="static.frontpage2">
Static page
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="posts.perpage" class="col-sm-2 col-form-label">Posts in front page show at most</label>
<div class="col-sm-10">
<input type="number" name="-config-posts.perpage" class="form-control" id="posts.perpage" value="<?php echo config('posts.perpage');?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Blog posts displayed as</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-teaser.type" id="teaser.type1" value="full" <?php if (config('teaser.type') === 'full'):?>checked<?php endif;?>>
<label class="form-check-label" for="teaser.type1">
Full post
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-teaser.type" id="teaser.type2" value="trimmed" <?php if (config('teaser.type') === 'trimmed'):?>checked<?php endif;?>>
<label class="form-check-label" for="teaser.type2">
Summary
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="teaser.char" class="col-sm-2 col-form-label">Summary character</label>
<div class="col-sm-10">
<input type="number" name="-config-teaser.char" class="form-control" id="teaser.char" value="<?php echo config('teaser.char');?>">
</div>
</div>
<div class="form-group row">
<label for="read.more" class="col-sm-2 col-form-label">Read more text</label>
<div class="col-sm-10">
<input type="text" name="-config-read.more" class="form-control" id="read.more" value="<?php echo config('read.more');?>" placeholder="Read more">
</div>
</div>
<br>
<h4>Posts index settings</h4>
<hr>
<div class="form-group row">
<label for="category.perpage" class="col-sm-2 col-form-label">Posts in category page at most</label>
<div class="col-sm-10">
<input type="number" name="-config-category.perpage" class="form-control" id="category.perpage" value="<?php echo config('category.perpage');?>">
</div>
</div>
<div class="form-group row">
<label for="archive.perpage" class="col-sm-2 col-form-label">Posts in archive page at most</label>
<div class="col-sm-10">
<input type="number" name="-config-archive.perpage" class="form-control" id="archive.perpage" value="<?php echo config('archive.perpage');?>">
</div>
</div>
<div class="form-group row">
<label for="tag.perpage" class="col-sm-2 col-form-label">Posts in tag page at most</label>
<div class="col-sm-10">
<input type="number" name="-config-tag.perpage" class="form-control" id="tag.perpage" value="<?php echo config('tag.perpage');?>">
</div>
</div>
<div class="form-group row">
<label for="search.perpage" class="col-sm-2 col-form-label">Posts in search result at most</label>
<div class="col-sm-10">
<input type="number" name="-config-search.perpage" class="form-control" id="search.perpage" value="<?php echo config('search.perpage');?>">
</div>
</div>
<div class="form-group row">
<label for="type.perpage" class="col-sm-2 col-form-label">Posts in type page at most</label>
<div class="col-sm-10">
<input type="number" name="-config-type.perpage" class="form-control" id="type.perpage" value="<?php echo config('type.perpage');?>">
</div>
</div>
<div class="form-group row">
<label for="profile.perpage" class="col-sm-2 col-form-label">Posts in profile page at most</label>
<div class="col-sm-10">
<input type="number" name="-config-profile.perpage" class="form-control" id="profile.perpage" value="<?php echo config('profile.perpage');?>">
</div>
</div>
<br>
<h4>RSS settings</h4>
<hr>
<div class="form-group row">
<label for="rss.count" class="col-sm-2 col-form-label">RSS feeds show the most recent</label>
<div class="col-sm-10">
<input type="number" name="-config-rss.count" class="form-control" id="rss.count" value="<?php echo config('rss.count');?>">
</div>
</div>
<div class="form-group row">
<label for="rss.char" class="col-sm-2 col-form-label">RSS character</label>
<div class="col-sm-10">
<input type="number" name="-config-rss.char" class="form-control" id="rss.char" value="<?php echo config('rss.char');?>">
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Save config</button>
</div>
</div>
</form>

+ 146
- 0
system/admin/views/config-widget.html.php View File

@ -0,0 +1,146 @@
<h2>Widget Settings</h2>
<br><br>
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<div class="form-group row">
<label for="related.count" class="col-sm-2 col-form-label">Related widget posts at most</label>
<div class="col-sm-10">
<input type="number" name="-config-related.count" class="form-control" id="related.count" value="<?php echo config('related.count');?>">
</div>
</div>
<div class="form-group row">
<label for="recent.count" class="col-sm-2 col-form-label">Recent posts widget at most</label>
<div class="col-sm-10">
<input type="number" name="-config-recent.count" class="form-control" id="recent.count" value="<?php echo config('recent.count');?>">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Popular posts widget</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-views.counter" id="views.counter1" value="true" <?php if (config('views.counter') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="views.counter1">
Enable popular posts widget
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-views.counter" id="views.counter2" value="false" <?php if (config('views.counter') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="views.counter2">
Disable popular posts widget
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="popular.count" class="col-sm-2 col-form-label">Popular posts widget at most</label>
<div class="col-sm-10">
<input type="number" name="-config-popular.count" class="form-control" id="popular.count" value="<?php echo config('popular.count');?>">
</div>
</div>
<br>
<h4>Comments</h4>
<hr>
<p>To using Disqus or Facebook comment you need to provide Disqus shortname or Facebook App ID.</p>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Comment system</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-comment.system" id="comment.system1" value="disable" <?php if (config('comment.system') === 'disable'):?>checked<?php endif;?>>
<label class="form-check-label" for="comment.system1">
Disabled
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-comment.system" id="comment.system2" value="disqus" <?php if (config('comment.system') === 'disqus'):?>checked<?php endif;?>>
<label class="form-check-label" for="comment.system2">
Disqus
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-comment.system" id="comment.system3" value="facebook" <?php if (config('comment.system') === 'facebook'):?>checked<?php endif;?>>
<label class="form-check-label" for="comment.system3">
Facebook
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="disqus.shortname" class="col-sm-2 col-form-label">Disqus shortname</label>
<div class="col-sm-10">
<input type="text" name="-config-disqus.shortname" class="form-control" id="disqus.shortname" value="<?php echo config('disqus.shortname');?>" placeholder="htmly">
</div>
</div>
<div class="form-group row">
<label for="fb.appid" class="col-sm-2 col-form-label">Facebook App ID</label>
<div class="col-sm-10">
<input type="text" name="-config-fb.appid" class="form-control" id="fb.appid" value="<?php echo config('fb.appid');?>" placeholder="12345abcde">
</div>
</div>
<br>
<h4>Recaptcha</h4>
<hr>
<p>Get one here <a target="_blank" href="https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Recaptcha</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-google.reCaptcha" id="google.reCaptcha1" value="true" <?php if (config('google.reCaptcha') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="google.reCaptcha1">
Enable recaptcha
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-google.reCaptcha" id="google.reCaptcha2" value="false" <?php if (config('google.reCaptcha') === 'false'):?>checked<?php endif;?>>
<label class="form-check-label" for="google.reCaptcha2">
Disable recaptcha
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="google.reCaptcha.public" class="col-sm-2 col-form-label">Site Key</label>
<div class="col-sm-10">
<input type="text" name="-config-google.reCaptcha.public" class="form-control" id="google.reCaptcha.public" value="<?php echo config('google.reCaptcha.public');?>" placeholder="12345abcde">
</div>
</div>
<div class="form-group row">
<label for="google.reCaptcha.private" class="col-sm-2 col-form-label">Secret Key</label>
<div class="col-sm-10">
<input type="text" name="-config-google.reCaptcha.private" class="form-control" id="google.reCaptcha.private" value="<?php echo config('google.reCaptcha.private');?>" placeholder="12345abcde">
</div>
</div>
<br>
<h4>Google Analytics</h4>
<hr>
<div class="form-group row">
<label for="google.gtag.id" class="col-sm-2 col-form-label">Universal Analytics (gtag.js)</label>
<div class="col-sm-10">
<input type="text" name="-config-google.gtag.id" class="form-control" id="google.gtag.id" value="<?php echo config('google.gtag.id');?>" placeholder="12345abcde">
</div>
</div>
<div class="form-group row">
<label for="google.analytics.id" class="col-sm-2 col-form-label">Google Analytics (legacy)</label>
<div class="col-sm-10">
<input type="text" name="-config-google.analytics.id" class="form-control" id="google.analytics.id" value="<?php echo config('google.analytics.id');?>" placeholder="12345abcde">
<small><em>This is legacy code. Usually new created analyics using gtag.js</em></small>
</div>
</div>
<div class="form-group row">
<label for="google.wmt.id" class="col-sm-2 col-form-label">Google Search Console</label>
<div class="col-sm-10">
<input type="text" name="-config-google.wmt.id" class="form-control" id="google.wmt.id" value="<?php echo config('google.wmt.id');?>" placeholder="12345abcde">
<small><em>For google-site-verification meta</em></small>
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Save config</button>
</div>
</div>
</form>

+ 116
- 47
system/admin/views/config.html.php View File

@ -1,48 +1,117 @@
<h2>Your Settings</h2>
<br>
<p><u>hint:</u> Use <code>Ctrl</code>/<code>CMD⌘</code> + <code>F</code> to search for your config key or value.</p>
<p><u>pro tips:</u> You can creating custom config key and print out your config key value anywhere in your template.</p>
<p><code>&lt;?php echo config('your.key'); ?&gt;</code></p>
<br>
<h2>General Settings</h2>
<br><br>
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<input class="form-control btn btn-primary btn-sm" type="submit" style="width:100px;">
<br><br>
<table class="table" id="config">
<tr>
<td><input type="text" class="form-control" name="newKey" placeholder="Your New Config Key"></td>
<td><input type="text" class="form-control" name="newValue" placeholder="Your New Value"></td>
</tr>
<?php
global $config_file;
$array = array(
"google.wmt" => "hallo",
);
if (file_exists($config_file)) {
$array = parse_ini_file($config_file, true);
}
function valueMaker($value)
{
if (is_string($value))
return htmlspecialchars($value);
if ($value === true)
return "true";
if ($value === false)
return "false";
if ($value == false)
return "0";
return (string)$value;
}
foreach ($array as $key => $value) {
echo '<tr>';
echo '<td><label for="' . $key . '">' . $key . '</label></td>';
echo '<td><input class="form-control" type="text" id="' . $key . '" name="-config-' . $key . '" value="' . valueMaker($value) . '"></td>';
echo '</tr>';
}
?>
</table>
<input type="submit" class="form-control btn-primary btn-sm" style="width:100px;">
</form>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<div class="form-group row">
<label for="site.url" class="col-sm-2 col-form-label">Address (URL)</label>
<div class="col-sm-10">
<input type="text" name="-config-site.url" class="form-control" id="site.url" value="<?php echo config('site.url');?>" placeholder="https://www.htmly.com">
</div>
</div>
<div class="form-group row">
<label for="blog.title" class="col-sm-2 col-form-label">Blog title</label>
<div class="col-sm-10">
<input type="text" name="-config-blog.title" class="form-control" id="blog.title" value="<?php echo config('blog.title');?>" placeholder="My HTMLy Blog">
</div>
</div>
<div class="form-group row">
<label for="blog.tagline" class="col-sm-2 col-form-label">Tagline</label>
<div class="col-sm-10">
<input type="text" name="-config-blog.tagline" class="form-control" id="blog.tagline" value="<?php echo config('blog.tagline');?>" placeholder="Databaseless PHP Blogging Platform">
<small><em>In a few words, explain what this blog is about.</em></small>
</div>
</div>
<div class="form-group row">
<label for="blog.description" class="col-sm-2 col-form-label">Description</label>
<div class="col-sm-10">
<textarea id="blog.description" name="-config-blog.description" class="form-control"><?php echo config('blog.description');?></textarea>
<small><em>In one paragraph, tell us more about your blog.</em></small>
</div>
</div>
<div class="form-group row">
<label for="blog.copyright" class="col-sm-2 col-form-label">Copyright</label>
<div class="col-sm-10">
<input type="text" name="-config-blog.copyright" class="form-control" id="blog.copyright" value="<?php echo config('blog.copyright');?>" placeholder="(c) Your name.">
</div>
</div>
<div class="form-group row">
<label for=language" class="col-sm-2 col-form-label">Language</label>
<div class="col-sm-10">
<select class="form-control" id="language" name="-config-language">
<?php foreach (glob('lang/*.ini') as $file) { ?>
<option value="<?php echo pathinfo($file)['filename'];?>" <?php if (config('language') === pathinfo($file)['filename']):?>selected<?php endif;?>><?php echo pathinfo($file)['filename'];?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group row">
<label for=language" class="col-sm-2 col-form-label">Timezone</label>
<div class="col-sm-10">
<select class="form-control" id="timezone" name="-config-timezone">
<?php foreach (timezone_identifiers_list() as $zone) { ?>
<option value="<?php echo $zone;?>" <?php if (config('timezone') === $zone):?>selected<?php endif;?>><?php echo $zone;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group row">
<?php $time = new DateTime('NOW'); $date = $time->format("Y-m-d H:i:s");?>
<label class="col-sm-2 col-form-label">Date Format</label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format1" value="%d %B %Y" <?php if (config('date.format') === '%d %B %Y'):?>checked<?php endif;?>>
<label class="form-check-label" for="date.format1">
<?php echo strftime('%d %B %Y', strtotime($date)); ?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format2" value="%B %d, %Y" <?php if (config('date.format') === '%B %d, %Y'):?>checked<?php endif;?>>
<label class="form-check-label" for="date.format2">
<?php echo strftime('%B %d, %Y', strtotime($date)); ?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format3" value="%d %b %Y" <?php if (config('date.format') === '%d %b %Y'):?>checked<?php endif;?>>
<label class="form-check-label" for="date.format3">
<?php echo strftime('%d %b %Y', strtotime($date)); ?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format4" value="%b %d, %Y" <?php if (config('date.format') === '%b %d, %Y'):?>checked<?php endif;?>>
<label class="form-check-label" for="date.format4">
<?php echo strftime('%b %d, %Y', strtotime($date)); ?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format5" value="%d/%m/%Y" <?php if (config('date.format') === '%d/%m/%Y'):?>checked<?php endif;?>>
<label class="form-check-label" for="date.format5">
<?php echo strftime('%d/%m/%Y', strtotime($date)); ?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format6" value="%m/%d/%Y" <?php if (config('date.format') === '%m/%d/%Y'):?>checked<?php endif;?>>
<label class="form-check-label" for="date.format6">
<?php echo strftime('%m/%d/%Y', strtotime($date)); ?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for=views.root" class="col-sm-2 col-form-label">Blog Theme</label>
<div class="col-sm-10">
<select class="form-control" id="views.root" name="-config-views.root">
<?php foreach (glob('themes/*/layout.html.php') as $folder) { ?>
<?php $theme = explode('/',pathinfo($folder)['dirname']); global $config_file; $this_config = parse_ini_file($config_file, true);?>
<option value="<?php echo pathinfo($folder)['dirname'];?>" <?php if ($this_config['views.root'] === pathinfo($folder)['dirname']):?>selected<?php endif;?>><?php echo $theme['1'];?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Save config</button>
</div>
</div>
</form>

+ 25
- 1
system/admin/views/layout.html.php View File

@ -103,7 +103,6 @@
</li>
</ul>
</li>
</li>
<li class="nav-item has-treeview menu-open">
<a href="#" class="nav-link">
<i class="nav-icon fa fa-cogs"></i>
@ -118,6 +117,31 @@
<p>Config</p>
</a>
</li>
<li class="nav-item">
<a href="<?php echo site_url();?>admin/config/reading" class="nav-link">
<p>Reading</p>
</a>
</li>
<li class="nav-item">
<a href="<?php echo site_url();?>admin/config/widget" class="nav-link">
<p>Widget</p>
</a>
</li>
<li class="nav-item">
<a href="<?php echo site_url();?>admin/config/metatags" class="nav-link">
<p>Metatags</p>
</a>
</li>
<li class="nav-item">
<a href="<?php echo site_url();?>admin/config/performance" class="nav-link">
<p>Performance</p>
</a>
</li>
<li class="nav-item">
<a href="<?php echo site_url();?>admin/config/custom" class="nav-link">
<p>Custom</p>
</a>
</li>
<li class="nav-item">
<a href="<?php echo site_url();?>admin/menu" class="nav-link">
<p>Menus</p>


+ 341
- 1
system/htmly.php View File

@ -1295,6 +1295,346 @@ post('/admin/config', function () {
die;
});
// Show Config page
get('/admin/config/custom', function () {
$user = $_SESSION[config("site.url")]['user'];
$role = user('role', $user);
if (login()) {
config('views.root', 'system/admin/views');
if ($role === 'admin') {
render('config-custom', array(
'title' => 'Config - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'admin-config',
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Config'
));
} else {
render('denied', array(
'title' => 'Config page - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'denied',
'breadcrumb' => '',
));
}
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Submitted Config page data
post('/admin/config/custom', function () {
error_reporting(E_ALL);
ini_set("display_errors", 1);
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if (login() && $proper) {
$newKey = from($_REQUEST, 'newKey');
$newValue = from($_REQUEST, 'newValue');
$new_config = array();
$new_Keys = array();
if (!empty($newKey)) {
$new_Keys[$newKey] = $newValue;
}
foreach ($_POST as $name => $value) {
if (substr($name, 0, 8) == "-config-") {
$name = str_replace("_", ".", substr($name, 8));
$new_config[$name] = $value;
}
}
save_config($new_config, $new_Keys);
$login = site_url() . 'admin/config/custom';
header("location: $login");
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Show Config page
get('/admin/config/reading', function () {
$user = $_SESSION[config("site.url")]['user'];
$role = user('role', $user);
if (login()) {
config('views.root', 'system/admin/views');
if ($role === 'admin') {
render('config-reading', array(
'title' => 'Config - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'admin-config',
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Config'
));
} else {
render('denied', array(
'title' => 'Config page - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'denied',
'breadcrumb' => '',
));
}
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Submitted Config page data
post('/admin/config/reading', function () {
error_reporting(E_ALL);
ini_set("display_errors", 1);
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if (login() && $proper) {
$newKey = from($_REQUEST, 'newKey');
$newValue = from($_REQUEST, 'newValue');
$new_config = array();
$new_Keys = array();
if (!empty($newKey)) {
$new_Keys[$newKey] = $newValue;
}
foreach ($_POST as $name => $value) {
if (substr($name, 0, 8) == "-config-") {
$name = str_replace("_", ".", substr($name, 8));
$new_config[$name] = $value;
}
}
save_config($new_config, $new_Keys);
$login = site_url() . 'admin/config/reading';
header("location: $login");
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Show Config page
get('/admin/config/widget', function () {
$user = $_SESSION[config("site.url")]['user'];
$role = user('role', $user);
if (login()) {
config('views.root', 'system/admin/views');
if ($role === 'admin') {
render('config-widget', array(
'title' => 'Config - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'admin-config',
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Config'
));
} else {
render('denied', array(
'title' => 'Config page - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'denied',
'breadcrumb' => '',
));
}
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Submitted Config page data
post('/admin/config/widget', function () {
error_reporting(E_ALL);
ini_set("display_errors", 1);
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if (login() && $proper) {
$newKey = from($_REQUEST, 'newKey');
$newValue = from($_REQUEST, 'newValue');
$new_config = array();
$new_Keys = array();
if (!empty($newKey)) {
$new_Keys[$newKey] = $newValue;
}
foreach ($_POST as $name => $value) {
if (substr($name, 0, 8) == "-config-") {
$name = str_replace("_", ".", substr($name, 8));
$new_config[$name] = $value;
}
}
save_config($new_config, $new_Keys);
$login = site_url() . 'admin/config/widget';
header("location: $login");
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Show Config page
get('/admin/config/metatags', function () {
$user = $_SESSION[config("site.url")]['user'];
$role = user('role', $user);
if (login()) {
config('views.root', 'system/admin/views');
if ($role === 'admin') {
render('config-metatags', array(
'title' => 'Config - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'admin-config',
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Config'
));
} else {
render('denied', array(
'title' => 'Config page - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'denied',
'breadcrumb' => '',
));
}
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Submitted Config page data
post('/admin/config/metatags', function () {
error_reporting(E_ALL);
ini_set("display_errors", 1);
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if (login() && $proper) {
$newKey = from($_REQUEST, 'newKey');
$newValue = from($_REQUEST, 'newValue');
$new_config = array();
$new_Keys = array();
if (!empty($newKey)) {
$new_Keys[$newKey] = $newValue;
}
foreach ($_POST as $name => $value) {
if (substr($name, 0, 8) == "-config-") {
$name = str_replace("_", ".", substr($name, 8));
$new_config[$name] = $value;
}
}
save_config($new_config, $new_Keys);
$login = site_url() . 'admin/config/metatags';
header("location: $login");
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Show Config page
get('/admin/config/performance', function () {
$user = $_SESSION[config("site.url")]['user'];
$role = user('role', $user);
if (login()) {
config('views.root', 'system/admin/views');
if ($role === 'admin') {
render('config-performance', array(
'title' => 'Config - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'admin-config',
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Config'
));
} else {
render('denied', array(
'title' => 'Config page - ' . blog_title(),
'description' => strip_tags(blog_description()),
'canonical' => site_url(),
'type' => 'is_admin-config',
'is_admin' => true,
'bodyclass' => 'denied',
'breadcrumb' => '',
));
}
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Submitted Config page data
post('/admin/config/performance', function () {
error_reporting(E_ALL);
ini_set("display_errors", 1);
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
if (login() && $proper) {
$newKey = from($_REQUEST, 'newKey');
$newValue = from($_REQUEST, 'newValue');
$new_config = array();
$new_Keys = array();
if (!empty($newKey)) {
$new_Keys[$newKey] = $newValue;
}
foreach ($_POST as $name => $value) {
if (substr($name, 0, 8) == "-config-") {
$name = str_replace("_", ".", substr($name, 8));
$new_config[$name] = $value;
}
}
save_config($new_config, $new_Keys);
$login = site_url() . 'admin/config/performance';
header("location: $login");
} else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Show Backup page
get('/admin/backup', function () {
if (login()) {
@ -1425,7 +1765,7 @@ post('/admin/menu', function () {
if (login()) {
$json = from($_REQUEST, 'json');
file_put_contents('content/data/menu.json', json_encode($json));
file_put_contents('content/data/menu.json', json_encode($json, JSON_UNESCAPED_UNICODE));
}
});


+ 20
- 11
system/includes/functions.php View File

@ -1950,27 +1950,36 @@ function publisher()
}
// Google Analytics
function analytics($analyticsDir = null)
function analytics()
{
$analytics = config('google.analytics.id');
if ($analyticsDir === null) {
$analyticsDir = '//www.google-analytics.com/analytics.js';
} else {
$analyticsDir = site_url() . 'themes/' . $analyticsDir . 'analytics.js';
}
$gtag = config('google.gtag.id');
$script = <<<EOF
<script>
(function (i,s,o,g,r,a,m) {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function () {
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','{$analyticsDir}','ga');
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{$analytics}', 'auto');
ga('send', 'pageview');
</script>
EOF;
if (!empty($analytics)) {
return $script;
}
$gtagScript = <<<EOF
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={$gtag}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{$gtag}');
</script>
EOF;
if (!empty($gtag)) {
return $gtagScript;
} elseif (!empty($analytics)) {
return $script;
}
}
function slashUrl($url) {
@ -2936,7 +2945,7 @@ function add_view($page)
} else {
$views[$page] = 1;
}
file_put_contents($filename, json_encode($views));
file_put_contents($filename, json_encode($views, JSON_UNESCAPED_UNICODE));
}
// Get the page views count


Loading…
Cancel
Save