aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-11-29 00:03:00 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-11-29 00:03:00 +0100
commit6e3ad2f1355e5f474cc02ab3b9eebe881dbb04ee (patch)
treef41a8fcdb5a8ef412a408ae637defb2985f5d3b1 /app
parentafad95324de8f078e9f3dedc66df66b6c2eebe72 (diff)
downloadwcms-6e3ad2f1355e5f474cc02ab3b9eebe881dbb04ee.tar.gz
wcms-6e3ad2f1355e5f474cc02ab3b9eebe881dbb04ee.zip
fonts
Diffstat (limited to 'app')
-rw-r--r--app/class/controllerart.php1
-rw-r--r--app/class/controllerfont.php33
-rw-r--r--app/class/model.php17
-rw-r--r--app/class/modelfont.php53
-rw-r--r--app/class/modelrender.php4
-rw-r--r--app/class/routes.php2
-rw-r--r--app/view/templates/edittabs.php2
7 files changed, 103 insertions, 9 deletions
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
index f766d12..6740f9c 100644
--- a/app/class/controllerart.php
+++ b/app/class/controllerart.php
@@ -90,6 +90,7 @@ 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' => ''];
if ($artexist) {
diff --git a/app/class/controllerfont.php b/app/class/controllerfont.php
new file mode 100644
index 0000000..29064d2
--- /dev/null
+++ b/app/class/controllerfont.php
@@ -0,0 +1,33 @@
+<?php
+
+class Controllerfont extends Controller
+{
+
+ protected $fontmanager;
+
+ public function __construct($router)
+ {
+ parent::__construct($router);
+ $this->fontmanager = new Modelfont();
+
+ }
+
+ public function desktop()
+ {
+ var_dump($this->fontmanager->getfontlist());
+ }
+
+ public function render()
+ {
+ $this->fontmanager->renderfontface();
+ $this->routedirect('font');
+ }
+
+ public function addfont()
+ {
+
+ }
+}
+
+
+?> \ No newline at end of file
diff --git a/app/class/model.php b/app/class/model.php
index cd0733c..600e930 100644
--- a/app/class/model.php
+++ b/app/class/model.php
@@ -8,6 +8,7 @@ abstract class Model
const MEDIA_DIR = 'media' . DIRECTORY_SEPARATOR;
const TEMPLATES_DIR = '.'. DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
const RENDER_DIR = 'assets'. DIRECTORY_SEPARATOR . 'render' . DIRECTORY_SEPARATOR;
+ const GLOBAL_DIR = 'assets'. DIRECTORY_SEPARATOR . 'global' . DIRECTORY_SEPARATOR;
const DATABASE_DIR = '.' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR;
const MEDIA_EXTENSIONS = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac', 'pdf');
const MEDIA_TYPES = ['image', 'video', 'sound', 'other'];
@@ -23,6 +24,15 @@ abstract class Model
return DIRECTORY_SEPARATOR . $basepath . Model::RENDER_DIR;
}
+ public static function globalpath()
+ {
+ $basepath = '';
+ if(!empty(Config::basepath())) {
+ $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ }
+ return DIRECTORY_SEPARATOR . $basepath . Model::GLOBAL_DIR;
+ }
+
public static function csspath()
{
$basepath = '';
@@ -45,12 +55,9 @@ abstract class Model
{
$basepath = '';
if(!empty(Config::basepath())) {
- $basepath = Config::basepath() . DIRECTORY_SEPARATOR ;
+ $basepath = Config::basepath() . '/' ;
}
- $url = DIRECTORY_SEPARATOR . $basepath . Model::FONT_DIR;
- return $url;
+ return '/' . $basepath . str_replace('\\', '/',Model::FONT_DIR);
}
-
-
}
diff --git a/app/class/modelfont.php b/app/class/modelfont.php
index 11ce6dd..09f2ddd 100644
--- a/app/class/modelfont.php
+++ b/app/class/modelfont.php
@@ -2,10 +2,27 @@
class Modelfont extends Model
{
+
+ const FONT_TYPES = ['woff2', 'woff', 'otf', 'ttf', 'eot', 'svg'];
+
+
+ public function getfontlist()
+ {
+ return $this->fontlist($this->list());
+ }
+
+ public function renderfontface()
+ {
+ $list = $this->list();
+ $fontlist = $this->fontlist($list);
+ $fontface = $this->fontface($fontlist);
+ $this->write($fontface);
+ }
+
+
public function list()
{
- var_dump(Model::fontpath());
- if ($handle = opendir(Model::fontpath())) {
+ if ($handle = opendir(Model::FONT_DIR)) {
$list = [];
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
@@ -19,6 +36,38 @@ class Modelfont extends Model
return $list;
}
+
+ public function fontlist(array $list)
+ {
+ $fontlist = [];
+ $fonttypes = implode('|', $this::FONT_TYPES);
+ $regex = '#(.+)\.('.$fonttypes.')#';
+ foreach ($list as $font) {
+ if(preg_match($regex, $font, $out)) {
+ $fontlist[] = ['id' => $out[1], 'ext' =>$out[2]];
+ }
+ }
+
+ return $fontlist;
+ }
+
+ public function fontface(array $fontlist)
+ {
+ $fontface = '';
+ foreach ($fontlist as $font) {
+ $fontface .= '@font-face {' . PHP_EOL . 'font-family: ' . $font['id'] . ';' . PHP_EOL . ' src: url( ' . Model::fontpath() . $font['id'] .'.'. $font['ext'] . ');' . PHP_EOL . '}' . PHP_EOL . PHP_EOL;
+ }
+ return $fontface;
+ }
+
+
+ public function write(string $fontface)
+ {
+ $write = file_put_contents(Model::GLOBAL_DIR.'fonts.css', $fontface);
+ if($write !== false) {
+
+ }
+ }
}
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index 37bc741..4eab655 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -124,6 +124,8 @@ class Modelrender extends Modelart
$head .= '<title>' . $this->art->title() . '</title>' . PHP_EOL;
$head .= '<meta name="description" content="' . $this->art->description() . '" />' . PHP_EOL;
$head .= '<meta name="viewport" content="width=device-width" />' . PHP_EOL;
+ $head .= '<link href="' . Model::globalpath() . 'fonts.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href="' . Model::globalpath() . 'global.css" rel="stylesheet" />' . PHP_EOL;
if (isset($this->art->template('array')['quickcss'])) {
$tempaltequickcssart = $this->art->template('array')['quickcss'];
@@ -332,7 +334,7 @@ class Modelrender extends Modelart
$this->artlistsort($li, 'date', -1);
foreach ($li as $item ) {
if($item->id() === $this->art->id()) {
- $actual = ' actual';
+ $actual = ' actualpage';
} else {
$actual = '';
}
diff --git a/app/class/routes.php b/app/class/routes.php
index 2215b5f..e5175aa 100644
--- a/app/class/routes.php
+++ b/app/class/routes.php
@@ -18,6 +18,8 @@ class Routes
['POST', '/!co', 'Controllerconnect#log', 'log'],
['GET', '/!co', 'Controllerconnect#connect', 'connect'],
['GET', '/!m', 'Controllermedia#desktop', 'media'],
+ ['GET', '/!font', 'Controllerfont#desktop', 'font'],
+ ['GET', '/!font/render', 'Controllerfont#render', 'fontrender'],
['GET', '/[cid:art]/', 'Controllerart#read', 'artread/'],
['GET', '/[cid:art]', 'Controllerart#read', 'artread'],
['GET', '/[cid:art]/add', 'Controllerart#add', 'artadd'],
diff --git a/app/view/templates/edittabs.php b/app/view/templates/edittabs.php
index 62d86ad..6e1562a 100644
--- a/app/view/templates/edittabs.php
+++ b/app/view/templates/edittabs.php
@@ -7,7 +7,7 @@ foreach ($tablist as $key => $value) {
<input name="interface" type="radio" value="<?= $key ?>" id="tab<?= $key ?>" class="checkboxtab" <?= $key == $opentab ? 'checked' : '' ?> >
- <label for="tab<?= $key ?>" <?= empty($template[$key]) ? '' : 'title="'.$template[$key].'" ' ?> class="<?= empty($template[$key]) ? '' : 'template' ?> <?= empty($value) ? '' : 'edited' ?>"><?= $key ?> </label>
+ <label for="tab<?= $key ?>" <?= empty($template[$key]) ? '' : 'title="template : '.$template[$key].'" ' ?> class="<?= empty($template[$key]) ? '' : 'template' ?> <?= empty($value) ? '' : 'edited' ?>"><?= $key ?> </label>
<?php