aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-04-27 10:56:24 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-04-28 20:21:34 +0200
commitc832f91ca41490f69f478045c86038f9ef4a5cb5 (patch)
treeb371e504c04660bbabb79721c5db7b086888ec01 /app/class
parentd66de69ba57f00079ab8d5e4b9a1d1f73093e76a (diff)
downloadwcms-c832f91ca41490f69f478045c86038f9ef4a5cb5.tar.gz
wcms-c832f91ca41490f69f478045c86038f9ef4a5cb5.zip
move fonts into media
move global css into media
Diffstat (limited to 'app/class')
-rw-r--r--app/class/Colors.php2
-rw-r--r--app/class/Config.php2
-rw-r--r--app/class/Controller.php2
-rw-r--r--app/class/Controlleradmin.php2
-rw-r--r--app/class/Controllerfont.php2
-rw-r--r--app/class/Controllermedia.php18
-rw-r--r--app/class/Model.php38
-rw-r--r--app/class/Modelmedia.php2
-rw-r--r--app/class/Modelpage.php2
9 files changed, 29 insertions, 41 deletions
diff --git a/app/class/Colors.php b/app/class/Colors.php
index bdea98e..731fbac 100644
--- a/app/class/Colors.php
+++ b/app/class/Colors.php
@@ -5,7 +5,7 @@ namespace Wcms;
class Colors extends Item
{
- protected $file = Model::CSS_DIR . 'tagcolors.css';
+ protected $file = Model::ASSETS_CSS_DIR . 'tagcolors.css';
protected $rawcss = "";
diff --git a/app/class/Config.php b/app/class/Config.php
index 45ba86f..c982827 100644
--- a/app/class/Config.php
+++ b/app/class/Config.php
@@ -435,7 +435,7 @@ abstract class Config
public static function setinterfacecss($interfacecss)
{
- if (is_string($interfacecss) && file_exists(Model::CSS_DIR . $interfacecss)) {
+ if (is_string($interfacecss) && file_exists(Model::ASSETS_CSS_DIR . $interfacecss)) {
self::$interfacecss = $interfacecss;
} else {
self::$interfacecss = null;
diff --git a/app/class/Controller.php b/app/class/Controller.php
index 46c9ee0..7bfa3a2 100644
--- a/app/class/Controller.php
+++ b/app/class/Controller.php
@@ -67,7 +67,7 @@ class Controller
$commonsparams['router'] = $this->router;
$commonsparams['user'] = $this->user;
$commonsparams['pagelist'] = $this->pagemanager->list();
- $commonsparams['css'] = Model::csspath();
+ $commonsparams['css'] = Model::assetscsspath();
$commonsparams['now'] = new DateTimeImmutable();
return $commonsparams;
}
diff --git a/app/class/Controlleradmin.php b/app/class/Controlleradmin.php
index ec437fa..d87427b 100644
--- a/app/class/Controlleradmin.php
+++ b/app/class/Controlleradmin.php
@@ -45,7 +45,7 @@ class Controlleradmin extends Controller
public function update()
{
- accessfile(Model::GLOBAL_CSS_FILE);
+ accessfile(Model::GLOBAL_CSS_FILE, true);
$globalcss = file_put_contents(Model::GLOBAL_CSS_FILE, $_POST['globalcss']);
diff --git a/app/class/Controllerfont.php b/app/class/Controllerfont.php
index 7df1a2f..eb8caa2 100644
--- a/app/class/Controllerfont.php
+++ b/app/class/Controllerfont.php
@@ -18,7 +18,7 @@ class Controllerfont extends Controller
public function desktop()
{
if ($this->user->iseditor()) {
- Model::dircheck(Model::FONT_DIR);
+ dircheck(Model::FONT_DIR);
$fontlist = $this->fontmanager->getfontlist();
diff --git a/app/class/Controllermedia.php b/app/class/Controllermedia.php
index 95b4f9b..6a585eb 100644
--- a/app/class/Controllermedia.php
+++ b/app/class/Controllermedia.php
@@ -2,7 +2,8 @@
namespace Wcms;
-use Exception;
+use \Exception;
+use \LogicException;
class Controllermedia extends Controller
{
@@ -24,14 +25,13 @@ class Controllermedia extends Controller
public function desktop()
{
if ($this->user->iseditor()) {
- if (!$this->mediamanager->dircheck(Model::MEDIA_DIR)) {
- throw new Exception("Media error : Cant create /media folder");
- }
- if (!$this->mediamanager->dircheck(Model::FAVICON_DIR)) {
- throw new Exception("Media error : Cant create /media/favicon folder");
- }
- if (!$this->mediamanager->dircheck(Model::THUMBNAIL_DIR)) {
- throw new Exception("Media error : Cant create /media/thumbnail folder");
+ try {
+ dircheck(Model::FONT_DIR);
+ dircheck(Model::THUMBNAIL_DIR);
+ dircheck(Model::FAVICON_DIR);
+ dircheck(Model::CSS_DIR);
+ } catch (\InvalidArgumentException $exception) {
+ throw new LogicException($exception->getMessage());
}
$mediaopt = new Medialist($_GET);
diff --git a/app/class/Model.php b/app/class/Model.php
index 7e891f1..60983bc 100644
--- a/app/class/Model.php
+++ b/app/class/Model.php
@@ -7,19 +7,19 @@ abstract class Model
public const CONFIG_FILE = 'config.json';
public const MAN_FILE = 'MANUAL.md';
- public const CSS_DIR = 'assets/css/';
- public const COLORS_FILE = self::CSS_DIR . 'tagcolors.css';
+ public const ASSETS_CSS_DIR = 'assets/css/';
+ public const COLORS_FILE = self::ASSETS_CSS_DIR . 'tagcolors.css';
public const JS_DIR = 'assets/js/';
public const ICONS_DIR = 'assets/icons/';
- public const FONT_DIR = 'fonts/';
public const MEDIA_DIR = 'media/';
public const FAVICON_DIR = self::MEDIA_DIR . 'favicon/';
public const THUMBNAIL_DIR = self::MEDIA_DIR . 'thumbnail/';
+ public const FONT_DIR = self::MEDIA_DIR . 'fonts/';
+ public const CSS_DIR = self::MEDIA_DIR . 'css/';
public const TEMPLATES_DIR = './app/view/templates/';
public const RENDER_DIR = 'assets/render/';
public const HTML_RENDER_DIR = 'render/';
- public const GLOBAL_DIR = 'assets/global/';
- public const GLOBAL_CSS_FILE = self::GLOBAL_DIR . 'global.css';
+ public const GLOBAL_CSS_FILE = self::CSS_DIR . 'global.css';
public const DATABASE_DIR = './database/';
public const PAGES_DIR = self::DATABASE_DIR . 'pages/';
@@ -81,9 +81,9 @@ abstract class Model
];
public const BOOKMARK_ICONS = [
- '🌘', '☂️', '⭐️', '✈️', '🚲', '💡', '💾', '💿', '💎', '🎞', ' ⚒', '💊', '📜', '📌', '🔍', '📦', '🔒',
- '📒', '🔓', '🌡', '☎️', '🖤', '✝️', '☢️', '✅', '🌐', '🌍', '✳️', '🏴', '😎', '👻', '💩', '👍', '⚡️', '🍸',
- '🍴', '⚽️', '🏭', '🚀', '⚓️'
+ '⭐️', '🖤', '🏴', '👍', '📌', '💡', '🌘', '☂️', '✈️', '🚲', '💾', '💿', '💎', '🎞', ' ⚒', '💊', '📜',
+ '📒', '🔓', '🌡', '☎️', '✝️', '☢️', '✅', '🌐', '🌍', '✳️', '🏴', '😎', '👻', '💩', '⚡️', '🍸', '🔍', '📦',
+ '🍴', '⚽️', '🏭', '🚀', '⚓️', '🔒'
];
public const LIST_STYLES = [
@@ -158,6 +158,11 @@ abstract class Model
return self::dirtopath(Model::CSS_DIR);
}
+ public static function assetscsspath()
+ {
+ return self::dirtopath(Model::ASSETS_CSS_DIR);
+ }
+
public static function jspath()
{
return self::dirtopath(Model::JS_DIR);
@@ -189,23 +194,6 @@ abstract class Model
}
/**
- * Check if dir exist. If not, create it
- *
- * @param string $dir Directory to check
- * @return bool return true if the dir already exist or was created succesfullt. Otherwise return false
- * @throws \InvalidArgumentException If folder creation is impossible
- */
- public static function dircheck(string $dir): bool
- {
- if (!is_dir($dir)) {
- if (!mkdir($dir)) {
- throw new \InvalidArgumentException("Cannot create directory : $dir");
- }
- }
- return true;
- }
-
- /**
*
*/
public static function mediatypes()
diff --git a/app/class/Modelmedia.php b/app/class/Modelmedia.php
index bd0ff03..2894783 100644
--- a/app/class/Modelmedia.php
+++ b/app/class/Modelmedia.php
@@ -117,7 +117,7 @@ class Modelmedia extends Model
public function listinterfacecss()
{
- $listinterfacecss = $this->globlist(self::CSS_DIR, ['css']);
+ $listinterfacecss = $this->globlist(self::ASSETS_CSS_DIR, ['css']);
$listinterfacecss = array_diff($listinterfacecss, ['edit.css', 'home.css', 'tagcolors.css']);
return $listinterfacecss;
}
diff --git a/app/class/Modelpage.php b/app/class/Modelpage.php
index 5968248..834ba01 100644
--- a/app/class/Modelpage.php
+++ b/app/class/Modelpage.php
@@ -17,7 +17,7 @@ class Modelpage extends Modeldb
{
$this->dbinit(Model::PAGES_DIR);
$this->storeinit(Config::pagetable());
- $this->dircheck(Model::HTML_RENDER_DIR);
+ dircheck($this::HTML_RENDER_DIR);
}
/**