From 13acdbd444b0ae26e83ab8cf62d60a7f59268545 Mon Sep 17 00:00:00 2001
From: vincent-peugnet Admin
';
+ if($this->user->isadmin()) {
+ $this->artmanager = new Modelart();
+ $artlist = $this->artmanager->list();
+ if(in_array(Config::defaultart(), $artlist)) {
+ $defaultartexist = true;
+ } else {
+ $defaultartexist = true;
+ }
+ $admin = ['artlist' => $artlist, 'defaultartexist' => $defaultartexist];
+ $this->showtemplate('admin', $admin);
+ }
}
- public function addtable()
+ public function update()
{
-
+ if(!isset($_POST['showeditmenu'])) {
+ $_POST['showeditmenu'] = false;
+ }
+ Config::hydrate($_POST);
+ if(Config::savejson() !== false) {
+ $this->routedirect('admin');
+ } else {
+ echo 'Can\'t write config file';
+ }
}
+
+
}
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index 67ec280..0dee8e7 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -90,14 +90,14 @@ class Controllerart extends Controller
$artexist = $this->importart();
$canread = $this->user->level() >= $this->art->secure();
$alerts = ['alertnotexist' => 'This page does not exist yet', 'alertprivate' => 'You cannot see this page'];
- $page = ['head' => '', 'body' => ''];
+ $page = ['head' => '', 'body' => ''];
if ($artexist) {
if ($this->art->daterender() < $this->art->datemodif()) {
$page = $this->renderart();
} else {
- $page = ['head' => $this->art->renderhead(), 'body' => $this->art->renderbody()];
+ $page = ['head' => $this->art->renderhead(), 'body' => $this->art->renderbody()];
}
$this->art->addaffcount();
$this->artmanager->update($this->art);
@@ -148,6 +148,16 @@ class Controllerart extends Controller
$this->setart($id, 'artadd');
if ($this->user->iseditor() && !$this->importart()) {
$this->art->reset();
+ if (!empty(Config::defaultart())) {
+ $defaultart = $this->artmanager->get(Config::defaultart());
+ if ($defaultart !== false) {
+ $defaultbody = $defaultart->body();
+ }
+ }
+ if(empty(Config::defaultart()) || $defaultart === false) {
+ $defaultbody = Config::defaultbody();
+ }
+ $this->art->setbody($defaultbody);
$this->artmanager->add($this->art);
$this->routedirect('artedit', ['art' => $this->art->id()]);
} else {
diff --git a/app/class/controllerfont.php b/app/class/controllerfont.php
index d85e60e..b1cd0d9 100644
--- a/app/class/controllerfont.php
+++ b/app/class/controllerfont.php
@@ -32,13 +32,17 @@ class Controllerfont extends Controller
public function add()
{
- var_dump($_FILES);
if(isset($_POST['fontname'])) {
$fontname = $_POST['fontname'];
} else {
$fontname = '';
}
- var_dump($this->fontmanager->upload($_FILES, 2 ** 16, $fontname));
+ $message = $this->fontmanager->upload($_FILES, 2 ** 16, $fontname);
+ if($message !== true) {
+ echo $message;
+ } else {
+ $this->render();
+ }
}
}
diff --git a/app/class/model.php b/app/class/model.php
index 600e930..4024f62 100644
--- a/app/class/model.php
+++ b/app/class/model.php
@@ -14,41 +14,42 @@ abstract class Model
const MEDIA_TYPES = ['image', 'video', 'sound', 'other'];
const TEXT_ELEMENTS = ['header', 'nav', 'section', 'aside', 'footer'];
+ const EDIT_SYMBOLS = ['pen', 'tool', 'none'];
public static function renderpath()
{
$basepath = '';
if(!empty(Config::basepath())) {
- $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ $basepath = Config::basepath() . '/' ;
}
- return DIRECTORY_SEPARATOR . $basepath . Model::RENDER_DIR;
+ return '/' . $basepath . Model::RENDER_DIR;
}
public static function globalpath()
{
$basepath = '';
if(!empty(Config::basepath())) {
- $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ $basepath = Config::basepath() . '/' ;
}
- return DIRECTORY_SEPARATOR . $basepath . Model::GLOBAL_DIR;
+ return '/' . $basepath . Model::GLOBAL_DIR;
}
public static function csspath()
{
$basepath = '';
if(!empty(Config::basepath())) {
- $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ $basepath = Config::basepath() . '/' ;
}
- return DIRECTORY_SEPARATOR . $basepath . Model::CSS_DIR;
+ return '/' . $basepath . Model::CSS_DIR;
}
public static function mediapath()
{
$basepath = '';
if(!empty(Config::basepath())) {
- $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ $basepath = Config::basepath() . '/' ;
}
- return DIRECTORY_SEPARATOR . $basepath . Model::MEDIA_DIR;
+ return '/' . $basepath . Model::MEDIA_DIR;
}
public static function fontpath()
diff --git a/app/class/modelart.php b/app/class/modelart.php
index 8117284..3fa2d48 100644
--- a/app/class/modelart.php
+++ b/app/class/modelart.php
@@ -17,12 +17,12 @@ class Modelart extends Modeldb
public function exist(Art2 $art)
{
$artdata = $this->artstore->get($art->id());
- if($artdata === false) {
+ if ($artdata === false) {
return false;
} else {
return true;
}
-
+
}
@@ -34,14 +34,15 @@ class Modelart extends Modeldb
$this->artstore->store($artdata);
}
+
public function get($id)
{
- if($id instanceof Art2) {
+ if ($id instanceof Art2) {
$id = $id->id();
}
- if(is_string($id)) {
+ if (is_string($id)) {
$artdata = $this->artstore->findById($id);
- if($artdata !== false) {
+ if ($artdata !== false) {
return new Art2($artdata);
} else {
return false;
@@ -54,6 +55,15 @@ class Modelart extends Modeldb
public function delete(Art2 $art)
{
$this->artstore->delete($art->id());
+ $this->unlink($art->id());
+ }
+
+
+ public function unlink(string $artid)
+ {
+ unlink(Model::RENDER_DIR . $artid . '.css');
+ unlink(Model::RENDER_DIR . $artid . '.quick.css');
+ unlink(Model::RENDER_DIR . $artid . '.js');
}
public function update(Art2 $art)
diff --git a/app/class/modelfont.php b/app/class/modelfont.php
index 4059096..213da11 100644
--- a/app/class/modelfont.php
+++ b/app/class/modelfont.php
@@ -95,7 +95,7 @@ class Modelfont extends Model
$extension_upload = strtolower($extension_upload);
$uploadok = move_uploaded_file($file['font']['tmp_name'], $this::FONT_DIR . $id . '.' . $extension_upload);
if ($uploadok) {
- $message = 'uploadok';
+ $message = true;
} else {
$message = 'uploaderror';
}
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index 4eab655..829c132 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -89,6 +89,8 @@ class Modelrender extends Modelart
return $body;
}
+
+
public function write()
{
file_put_contents(Model::RENDER_DIR . $this->art->id() . '.css', $this->art->css());
@@ -96,6 +98,8 @@ class Modelrender extends Modelart
file_put_contents(Model::RENDER_DIR . $this->art->id() . '.js', $this->art->javascript());
}
+
+
public function writetemplates()
{
if (array_key_exists('css', $this->art->template('array'))) {
@@ -158,6 +162,8 @@ class Modelrender extends Modelart
public function parser(string $text)
{
+ $text = str_replace('
+
+
+
+
+
+
+
+