diff options
author | n-peugnet <n.peugnet@free.fr> | 2019-11-04 23:31:31 +0100 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2019-11-05 19:06:40 +0100 |
commit | e802d5204b96d645ec3d40b81b4a8bdc6e0ee675 (patch) | |
tree | 8e6db5e36ad8f247b442583e1e9e5da2934f4b52 /app/class/modelfont.php | |
parent | f1f63f556c41c99d45cd610186b0982383eff375 (diff) | |
download | wcms-e802d5204b96d645ec3d40b81b4a8bdc6e0ee675.tar.gz wcms-e802d5204b96d645ec3d40b81b4a8bdc6e0ee675.zip |
refactor: switch to psr-4 autoloading
Diffstat (limited to 'app/class/modelfont.php')
-rw-r--r-- | app/class/modelfont.php | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/app/class/modelfont.php b/app/class/modelfont.php deleted file mode 100644 index 8e7645e..0000000 --- a/app/class/modelfont.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php - -class Modelfont extends Model -{ - - const FONT_TYPES = ['woff2', 'woff', 'otf', 'ttf', 'eot', 'svg']; - - public function fontdircheck() - { - if(!is_dir(Model::FONT_DIR)) { - return mkdir(Model::FONT_DIR); - } else { - return true; - } - } - - public function getfontlist() - { - return $this->fontlist($this->list()); - } - - public function getfonttypes() - { - $fonttypes = array_map(function ($ext) { - return '.' . $ext; - }, $this::FONT_TYPES); - return implode(', ', $fonttypes); - } - - public function renderfontface() - { - $list = $this->list(); - $fontlist = $this->fontlist($list); - $fontface = $this->fontface($fontlist); - $this->write($fontface); - } - - - public function list() - { - if ($handle = opendir(Model::FONT_DIR)) { - $list = []; - while (false !== ($entry = readdir($handle))) { - if ($entry != "." && $entry != "..") { - - $list[] = $entry; - - } - } - } - - 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], 'size' => filesize(Model::FONT_DIR . $font)]; - } - } - 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) { - - } - } - - public function upload(array $file, $maxsize = 2 ** 24, $id = null) - { - $message = 'runing'; - if (isset($file) and $file['font']['error'] == 0 and $file['font']['size'] < $maxsize) { - $infosfichier = pathinfo($file['font']['name']); - $extension_upload = $infosfichier['extension']; - $extensions_autorisees = $this::FONT_TYPES; - if (in_array($extension_upload, $extensions_autorisees)) { - if (!empty($id)) { - $id = strtolower(strip_tags($id)); - $id = str_replace(' ', '_', $id); - } else { - $id = $infosfichier['filename']; - } - if (!file_exists($this::FONT_DIR . $id . '.' . $extension_upload)) { - - $extension_upload = strtolower($extension_upload); - $uploadok = move_uploaded_file($file['font']['tmp_name'], $this::FONT_DIR . $id . '.' . $extension_upload); - if ($uploadok) { - $message = true; - } else { - $message = 'uploaderror'; - } - } else { - $message = 'filealreadyexist'; - - } - } - } else { - $message = 'filetoobig'; - - } - return $message; - } - - - - -} - - - - -?>
\ No newline at end of file |