created new Theme data class for theme stuff, added custom page view, added view select for page edit screen

pull/84/head
Ro 3 years ago
parent bbfe37597a
commit a8355b2da4

@ -12,6 +12,7 @@ include "../brain/data/Session.inc.php";
include "../brain/data/Member.inc.php";
include "../brain/data/Auth.inc.php";
include "../brain/data/Render.inc.php";
include "../brain/data/Themes.inc.php";
include "../brain/utility/StringTools.inc.php";
include "../brain/utility/FileUploader.inc.php";
include "../brain/utility/DocTools.inc.php";

@ -21,7 +21,7 @@ class DashControl
if (Session::active()) {
$config = new Settings();
$settings = $config->getSettings();
$themes = $config->getThemes();
$themes = (new Themes())->getThemes(); //$config->getThemes();
$template = "dash/settings.twig";
$member = Session::get("member");
$form_token = Session::get("form_token");
@ -103,13 +103,14 @@ class DashControl
$mode = $args["third"];
if ($mode == "edit") {
$uuid = $args["fourth"];
$customPages = (new Themes())->getCustomViews();
$pageOptions = [
"title" => "Fipamo | Edit Page",
"page" => (new Book("../content/pages"))->findPageById($uuid),
"mode" => $mode,
"token" => Session::get("form_token"),
"status" => Session::active(),
"views" => $customPages,
];
} else {
$pageOptions = [

@ -6,7 +6,6 @@ class Settings
{
private $folks;
private static $tags;
private $themes = [];
private static $settings;
public function __construct()
@ -18,14 +17,6 @@ class Settings
file_get_contents("../config/settings.json"),
true
);
$_themes = glob("../content/themes/*", GLOB_ONLYDIR);
foreach ($_themes as $theme) {
array_push(
$this->themes,
json_decode(file_get_contents($theme . "/theme.json"), true)
);
}
}
public static function sync($data)
@ -101,11 +92,6 @@ class Settings
DocTools::writeSettings("../config/settings.json", $settings);
}
public function getThemes()
{
return $this->themes;
}
public function getFolks($key = null)
{
if (isset($key)) {

@ -0,0 +1,41 @@
<?php
class Themes
{
private $themes = [];
public function __construct()
{
$_themes = glob("../content/themes/*", GLOB_ONLYDIR);
foreach ($_themes as $theme) {
array_push(
$this->themes,
json_decode(file_get_contents($theme . "/theme.json"), true)
);
}
}
public function getThemes()
{
return $this->themes;
}
public function getCustomViews()
{
$settings = (new Settings())->getSettings();
$currentTheme = $settings["global"]["theme"];
$folder = "../content/themes/" . $currentTheme;
$files = array_filter(glob("$folder/*twig"), "is_file");
$views = [];
foreach ($files as $file) {
$path = explode("/", $file);
$fileName = $path[4];
if (str_contains($fileName, "page")) {
$page = explode(".", $fileName);
$views[] = $page[0];
}
}
return $views;
}
}

@ -32,4 +32,15 @@
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
</svg>
</button>
<label>View Template</label>
<select>
{% for view in views %}
{% if view == page['layout'] %}
<option value={{ view }} selected>{{ view }}</option>
{% else %}
<option value={{ view }}>{{ view }}</option>
{% endif %}
{% endfor %}
</select>
</div>

@ -0,0 +1,35 @@
{% extends "fipamo-default/frame.twig" %}
{% block title %}
{{ title }}
{% endblock %}
{% block mainContent %}
<section>
<div class="page-title">
<span>{{title}}</span>
</div>
</section>
<article>
<div class="page">
<p>{{content | raw}}</p>
<div>
{{meta['who']}} dropped this {{ meta['when'] }}<br />
<strong>tags: </strong>
{% for tag in meta['tags'] %}
{% if dynamicRender is defined %}
{% if dynamicRender %}
<a href="{{ "/tags/"~tag.slug }}">{{ tag.label }}</a>
{% else %}
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
{% endif %}
{% else %}
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
{% endif %}
{% endfor %}
</div>
</div>
</article>
{% endblock %}
Loading…
Cancel
Save