diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/class/Controller.php | 2 | ||||
-rw-r--r-- | app/class/Controllerinfo.php | 18 | ||||
-rw-r--r-- | app/class/Controllermedia.php | 26 | ||||
-rw-r--r-- | app/class/Controllerpage.php | 14 | ||||
-rw-r--r-- | app/class/Medialist.php | 119 | ||||
-rw-r--r-- | app/class/Model.php | 7 | ||||
-rw-r--r-- | app/class/Modelmedia.php | 50 | ||||
-rw-r--r-- | app/class/Modelrender.php | 68 | ||||
-rw-r--r-- | app/class/Page.php | 16 | ||||
-rw-r--r-- | app/fn/fn.php | 24 | ||||
-rw-r--r-- | app/view/templates/admin.php | 355 | ||||
-rw-r--r-- | app/view/templates/editleftbar.php | 9 | ||||
-rw-r--r-- | app/view/templates/home.php | 4 | ||||
-rw-r--r-- | app/view/templates/homemenu.php | 5 | ||||
-rw-r--r-- | app/view/templates/info.php | 68 | ||||
-rw-r--r-- | app/view/templates/man.php | 320 | ||||
-rw-r--r-- | app/view/templates/media.php | 175 | ||||
-rw-r--r-- | app/view/templates/mediamenu.php | 80 | ||||
-rw-r--r-- | app/view/templates/navback.php | 54 | ||||
-rw-r--r-- | app/view/templates/user.php | 259 |
20 files changed, 784 insertions, 889 deletions
diff --git a/app/class/Controller.php b/app/class/Controller.php index 32ffc13..c3787b2 100644 --- a/app/class/Controller.php +++ b/app/class/Controller.php @@ -10,7 +10,7 @@ class Controller /** @var User */ protected $user; - /** @var Routes */ + /** @var \AltoRouter */ protected $router; /** @var Modeluser */ diff --git a/app/class/Controllerinfo.php b/app/class/Controllerinfo.php index af81caf..7b27cea 100644 --- a/app/class/Controllerinfo.php +++ b/app/class/Controllerinfo.php @@ -1,25 +1,31 @@ <?php namespace Wcms; +use Michelf\MarkdownExtra; class Controllerinfo extends Controller { - - public function __construct($render) { + public function __construct($render){ parent::__construct($render); } public function desktop() { if($this->user->iseditor()) { - $this->showtemplate('info', ['version' => getversion()]); - } - } + if(file_exists(Model::MAN_FILE)) { + $render = new Modelrender($this->router); + $htmlman = file_get_contents(Model::MAN_FILE); + $htmlman = $render->rendermanual($htmlman); - + $summary = $render->sumparser(2, 4); + $this->showtemplate('info', ['version' => getversion(), 'manual' => $htmlman, 'summary' => $summary]); + + } + } + } } diff --git a/app/class/Controllermedia.php b/app/class/Controllermedia.php index 5958289..8423d18 100644 --- a/app/class/Controllermedia.php +++ b/app/class/Controllermedia.php @@ -32,26 +32,22 @@ class Controllermedia extends Controller if (!$this->mediamanager->dircheck(Model::THUMBNAIL_DIR)) { throw new Exception("Media error : Cant create /media/thumbnail folder"); } + + $mediaopt = new Medialist($_GET); + if(empty($mediaopt->path())) { + $mediaopt->setpath(DIRECTORY_SEPARATOR . Model::MEDIA_DIR); + } - - $dir = rtrim($_GET['path'] ?? Model::MEDIA_DIR, DIRECTORY_SEPARATOR); - $sortby = isset($_GET['sortby']) ? $_GET['sortby'] : 'id'; - $order = isset($_GET['order']) ? $_GET['order'] : '1'; - $opt = ['dir' => $dir, 'sortby' => $sortby, 'order' => $order]; - - if(is_dir($dir)) { - $medialist = $this->mediamanager->getlistermedia($dir . DIRECTORY_SEPARATOR); - $faviconlist = $this->mediamanager->getlistermedia(Model::FAVICON_DIR); + if(is_dir($mediaopt->dir())) { + $medialist = $this->mediamanager->medialistopt($mediaopt); $dirlist = $this->mediamanager->listdir(Model::MEDIA_DIR); $pathlist = []; - $this->mediamanager->listpath($dirlist, '', $pathlist); - $this->mediamanager->medialistsort($medialist, $sortby, $order); - $this->showtemplate('media', ['medialist' => $medialist, 'faviconlist' => $faviconlist, 'dirlist' => $dirlist, 'pathlist' =>$pathlist, 'dir' => $dir, 'opt' => $opt]); + $this->showtemplate('media', ['medialist' => $medialist, 'dirlist' => $dirlist, 'pathlist' =>$pathlist, 'mediaopt' => $mediaopt]); } else { $this->routedirect('media'); } @@ -68,7 +64,7 @@ class Controllermedia extends Controller if (!empty($_FILES['file']['name'][0])) { $this->mediamanager->multiupload('file', $target); } - $this->redirect($this->router->generate('media') . '?path=' . $target); + $this->redirect($this->router->generate('media') . '?path=/' . $target); } else { $this->routedirect('home'); } @@ -81,7 +77,7 @@ class Controllermedia extends Controller $name = idclean($_POST['foldername']) ?? 'new-folder'; $this->mediamanager->adddir($dir, $name); } - $this->redirect($this->router->generate('media') . '?path=' . $dir . DIRECTORY_SEPARATOR . $name); + $this->redirect($this->router->generate('media') . '?path=/' . $dir . DIRECTORY_SEPARATOR . $name); } @@ -91,7 +87,7 @@ class Controllermedia extends Controller if(isset($_POST['deletefolder']) && intval($_POST['deletefolder']) && $this->user->issupereditor()) { $this->mediamanager->deletedir($_POST['dir']); } else { - $this->redirect($this->router->generate('media') . '?path=' . $_POST['dir']); + $this->redirect($this->router->generate('media') . '?path=/' . $_POST['dir']); exit; } } diff --git a/app/class/Controllerpage.php b/app/class/Controllerpage.php index e12d76e..75ac6cf 100644 --- a/app/class/Controllerpage.php +++ b/app/class/Controllerpage.php @@ -156,6 +156,7 @@ class Controllerpage extends Controller $filedir = Model::HTML_RENDER_DIR . $id . '.html'; if(file_exists($filedir)) { $html = file_get_contents($filedir); + sleep($this->page->sleep()); echo $html; } else { echo 'Please render this page'; @@ -203,9 +204,13 @@ class Controllerpage extends Controller public function log($id) { - $this->setpage($id, 'pagelog'); - $this->importpage(); - var_dump($this->page); + if($this->user->issupereditor()) { + $this->setpage($id, 'pagelog'); + $this->importpage(); + var_dump($this->page); + } else { + $this->routedirect('pageread/', ['page' => $id]); + } } public function add($id) @@ -216,6 +221,7 @@ class Controllerpage extends Controller if ($this->user->iseditor() && !$this->importpage()) { $this->page->reset(); + $this->page->addauthor($this->user->id()); if (!empty(Config::defaultpage())) { $defaultpage = $this->pagemanager->get(Config::defaultpage()); if ($defaultpage !== false) { @@ -236,7 +242,7 @@ class Controllerpage extends Controller public function confirmdelete($id) { $this->setpage($id, 'pageconfirmdelete'); - if ($this->user->iseditor() && $this->importpage()) { + if ($this->importpage() && ($this->user->issupereditor() || $this->page->authors() === [$this->user->id()] )) { $this->showtemplate('confirmdelete', ['page' => $this->page, 'pageexist' => true]); diff --git a/app/class/Medialist.php b/app/class/Medialist.php index da5ba4f..b208fef 100644 --- a/app/class/Medialist.php +++ b/app/class/Medialist.php @@ -7,8 +7,8 @@ class Medialist /** @var string full regex match */ protected $fullmatch; - /** @var string options */ - protected $options = ''; + /** @var string full filter code line */ + protected $filter = ''; /** @var string directory of media */ protected $path = ''; @@ -19,16 +19,20 @@ class Medialist /** @var int */ protected $order = 1; + /** @var array list of media type to display */ + protected $type = ['image', 'sound', 'video', 'other']; + /** @var int display media contents*/ protected $display = 1; /** @var int display download links*/ protected $links = 0; - /** @var string ouput html code generated*/ - protected $content = ''; + /** @var string display the file name of the file */ + protected $filename = 0; - const SORT_BY_OPTIONS = ['id', 'size', 'type']; + const SORT_BY_FILTER = ['id', 'size', 'type']; + const TYPES = ['image', 'sound', 'video', 'other']; @@ -39,8 +43,6 @@ class Medialist public function __construct(array $datas = []) { $this->hydrate($datas); - $this->readoptions(); - $this->generatecontent(); } public function hydrate($datas) @@ -54,16 +56,16 @@ class Medialist } } - public function readoptions() + public function readfilter() { - parse_str($this->options, $datas); + parse_str($this->filter, $datas); $this->hydrate($datas); } public function generatecontent() { $mediamanager = new Modelmedia(); - $medialist = $mediamanager->getlistermedia(Model::MEDIA_DIR . $this->path . '/'); + $medialist = $mediamanager->getlistermedia($this->dir(), $this->type); if (!$medialist) { $this->content = '<strong>RENDERING ERROR :</strong> path : <code>' . Model::MEDIA_DIR . $this->path . '/</code> does not exist'; return false; @@ -91,10 +93,50 @@ class Medialist $div .= '</div>' . PHP_EOL; - $this->content = $div; + return $div; + } + } - return true; + /** + * Generate link adress for table header + * + * @param string $sortby + * @return string link adress + */ + public function getsortbyadress(string $sortby) : string + { + if(!in_array($sortby, self::SORT_BY_FILTER)) { + $sortby = 'id'; } + if ($this->sortby === $sortby) { + $order = $this->order * -1; + } else { + $order = $this->order; + } + $query = ['path' => $this->path, 'sortby' => $sortby, 'order' => $order]; + if(array_diff( self::TYPES, $this->type) != []) { + $query['type'] = $this->type; + } + return '?' . urldecode(http_build_query($query)); + + } + + public function getpathadress(string $path) : string + { + $query = ['path' => '/' . $path, 'sortby' => $this->sortby, 'order' => $this->order]; + if(array_diff( self::TYPES, $this->type) != []) { + $query['type'] = $this->type; + } + return '?' . urldecode(http_build_query($query)); + } + + public function getquery() + { + $query = ['path' => $this->path, 'sortby' => $this->sortby, 'order' => $this->order]; + if(array_diff( self::TYPES, $this->type) != []) { + $query['type'] = $this->type; + } + return '%MEDIA?' . urldecode(http_build_query($query)). '%'; } @@ -106,17 +148,41 @@ class Medialist return $this->fullmatch; } - public function options() + public function filter() { - return $this->options; + return $this->filter; } - public function content() + /** + * @return string formated like `/media/<folder>` + */ + public function path() { - return $this->content; + return $this->path; } + /** + * @return string formated like `media/<folder>/` + */ + public function dir() + { + return ltrim($this->path, '/') . '/'; + } + + public function sortby() + { + return $this->sortby; + } + + public function order() + { + return $this->order; + } + public function type() + { + return $this->type; + } // __________________________________________________ S E T ____________________________________________________________ @@ -127,21 +193,25 @@ class Medialist } - public function setoptions(string $options) + public function setfilter(string $filter) { - if (!empty($options)) { - $this->options = $options; + if (!empty($filter)) { + $this->filter = $filter; } } public function setpath(string $path) { - $this->path = $path; + if(preg_match('%^\/' . rtrim(Model::MEDIA_DIR, DIRECTORY_SEPARATOR) . '%', $path)) { + $this->path = rtrim($path, DIRECTORY_SEPARATOR); + } elseif (!preg_match('%^\/%', $path)) { + $this->path = '/' . Model::MEDIA_DIR . rtrim($path, DIRECTORY_SEPARATOR); + } } public function setsortby(string $sortby) { - if (in_array($sortby, self::SORT_BY_OPTIONS)) { + if (in_array($sortby, self::SORT_BY_FILTER)) { $this->sortby = $sortby; } } @@ -152,4 +222,11 @@ class Medialist $this->order = $order; } } + + public function settype($type) + { + if(is_array($type)) { + $this->type = array_intersect(self::TYPES, array_unique($type)); + } + } } diff --git a/app/class/Model.php b/app/class/Model.php index 81ad626..913dc34 100644 --- a/app/class/Model.php +++ b/app/class/Model.php @@ -5,14 +5,15 @@ namespace Wcms; abstract class Model { - const CONFIG_FILE = 'config.json'; + const CONFIG_FILE = 'config.json'; + const MAN_FILE = 'MANUAL.md'; const CSS_DIR = 'assets' . DIRECTORY_SEPARATOR .'css' . DIRECTORY_SEPARATOR; const JS_DIR = 'assets' . DIRECTORY_SEPARATOR .'js' . DIRECTORY_SEPARATOR; const ICONS_DIR = 'assets' . DIRECTORY_SEPARATOR .'icons' . DIRECTORY_SEPARATOR; const FONT_DIR = 'fonts' . DIRECTORY_SEPARATOR; const MEDIA_DIR = 'media' . DIRECTORY_SEPARATOR; - const FAVICON_DIR = 'media' . DIRECTORY_SEPARATOR . 'favicon' . DIRECTORY_SEPARATOR; - const THUMBNAIL_DIR = 'media' . DIRECTORY_SEPARATOR . 'thumbnail' . DIRECTORY_SEPARATOR; + const FAVICON_DIR = self::MEDIA_DIR . 'favicon' . DIRECTORY_SEPARATOR; + const THUMBNAIL_DIR = self::MEDIA_DIR . 'thumbnail' . 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 HTML_RENDER_DIR = 'render' . DIRECTORY_SEPARATOR; diff --git a/app/class/Modelmedia.php b/app/class/Modelmedia.php index 6ac647f..d1da829 100644 --- a/app/class/Modelmedia.php +++ b/app/class/Modelmedia.php @@ -33,16 +33,23 @@ class Modelmedia extends Model } } + public function medialistopt(Medialist $mediaopt) + { + $medialist = $this->getlistermedia($mediaopt->dir(), $mediaopt->type()); + $this->medialistsort($medialist, $mediaopt->sortby(), $mediaopt->order()); + + return $medialist; + } + /** * Display a list of media * * @param string $path - * @param string $sortby - * @param string $order + * @param array $type * * @return array of Media objects */ - public function getlistermedia($dir, $type = "all") + public function getlistermedia($dir, $type = Model::MEDIA_TYPES) { if (is_dir($dir)) { if ($handle = opendir($dir)) { @@ -56,11 +63,7 @@ class Modelmedia extends Model $media->analyse(); - if (in_array($type, self::MEDIA_TYPES)) { - if ($media->type() == $type) { - $list[] = $media; - } - } else { + if (in_array($media->type(), $type)) { $list[] = $media; } } @@ -74,22 +77,6 @@ class Modelmedia extends Model } - - public function mediacompare($media1, $media2, $method = 'id', $order = 1) - { - $result = ($media1->$method() <=> $media2->$method()); - return $result * $order; - } - - public function buildsorter($sortby, $order) - { - return function ($media1, $media2) use ($sortby, $order) { - $result = $this->mediacompare($media1, $media2, $sortby, $order); - return $result; - }; - } - - /** * Sort an array of media * @@ -103,6 +90,21 @@ class Modelmedia extends Model $order = ($order === 1 || $order === -1) ? $order : 1; return usort($medialist, $this->buildsorter($sortby, $order)); } + + public function buildsorter($sortby, $order) + { + return function ($media1, $media2) use ($sortby, $order) { + $result = $this->mediacompare($media1, $media2, $sortby, $order); + return $result; + }; + } + + public function mediacompare($media1, $media2, $method = 'id', $order = 1) + { + $result = ($media1->$method() <=> $media2->$method()); + return $result * $order; + } + diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index 778b327..5a86d0b 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -36,6 +36,21 @@ class Modelrender extends Modelpage } } + /** + * Used to convert the markdown user manual to html document + * + * @param string $text Input text in markdown + * @return string html formated text + */ + public function rendermanual(string $text) : string + { + $text = $this->markdown($text); + $text = $this->headerid($text, 5); + return $text; + + } + + public function upage($id) { return $this->router->generate('pageread/', ['page' => $id]); @@ -308,7 +323,7 @@ class Modelrender extends Modelpage $text = $this->headerid($text); - $text = str_replace(self::SUMMARY, $this->sumparser($text), $text); + $text = str_replace(self::SUMMARY, $this->sumparser(), $text); $text = $this->wurl($text); $text = $this->wikiurl($text); @@ -384,11 +399,25 @@ class Modelrender extends Modelpage return $text; } - public function headerid($text) + /** + * Add Id to hrml header elements and store the titles in the `sum` parameter + * + * @param string $text Input html document to scan + * @param int $maxdeepness Maximum header deepness to look for. Min = 1 Max = 6 Default = 6 + * + * @return string text with id in header + */ + + public function headerid($text, int $maxdeepness = 6) { + if($maxdeepness > 6 || $maxdeepness < 1) { + $maxdeepness = 6; + } + + $sum = []; $text = preg_replace_callback( - '/<h([1-6])(\s+(\s*\w+="\w+")*)?\s*>(.+)<\/h[1-6]>/mU', + '/<h([1-' . $maxdeepness . '])(\s+(\s*\w+="\w+")*)?\s*>(.+)<\/h[1-' . $maxdeepness . ']>/mU', function ($matches) use (&$sum) { $cleanid = idclean($matches[4]); $sum[$cleanid][$matches[1]] = $matches[4]; @@ -437,34 +466,49 @@ class Modelrender extends Modelpage */ public function automedialist(string $text) { - preg_match_all('~\%MEDIA\?([a-zA-Z0-9\&=\-\/\%]*)\%~', $text, $out); + preg_match_all('~\%MEDIA\?([a-zA-Z0-9\[\]\&=\-\/\%]*)\%~', $text, $out); foreach ($out[0] as $key => $match) { - $matches[$key] = ['fullmatch' => $match, 'options' => $out[1][$key]]; + $matches[$key] = ['fullmatch' => $match, 'filter' => $out[1][$key]]; } if(isset($matches)) { foreach ($matches as $match) { $medialist = new Medialist($match); - $text = str_replace($medialist->fullmatch(), $medialist->content(), $text); + $medialist->readfilter(); + $text = str_replace($medialist->fullmatch(), $medialist->generatecontent(), $text); } } return $text; } - - function sumparser($text) + /** + * Generate a Summary based on header ids. Need to use `$this->headerid` before to scan text + * + * @param int $min Minimum header deepness to start the summary : Between 1 and 6. + * @param int $max Maximum header deepness to start the summary : Between 1 and 6. + * + * @return string html list with anchor link + */ + function sumparser(int $min = 1, int $max = 6) : string { - preg_match_all('#<h([1-6]) id="(\w+)">(.+)</h[1-6]>#iU', $text, $out); - + $min = $min >= 1 && $min <= 6 && $min <= $max ? $min : 1; + $end = $max >=1 && $max <= 6 && $max >= $min ? $max : 6; $sum = $this->sum; + $filteredsum = []; + foreach ($sum as $key => $menu) { + $deepness = array_keys($menu)[0]; + if($deepness >= $min && $deepness <= $max) { + $filteredsum[$key] = $menu; + } + } $sumstring = ''; $last = 0; - foreach ($sum as $title => $list) { + foreach ($filteredsum as $title => $list) { foreach ($list as $h => $link) { if ($h > $last) { for ($i = 1; $i <= ($h - $last); $i++) { @@ -633,7 +677,7 @@ class Modelrender extends Modelpage $optlist->parsehydrate($match['options']); $table2 = $modelhome->table2($this->pagelist, $optlist); - $content = '<ul>' . PHP_EOL ; + $content = '<ul class="pagelist">' . PHP_EOL ; foreach ($table2 as $page ) { $content .= '<li>' . PHP_EOL; $content .= '<a href="' . $this->upage($page->id()) . '">' . $page->title() . '</a>' . PHP_EOL; diff --git a/app/class/Page.php b/app/class/Page.php index 41cf0ab..170a057 100644 --- a/app/class/Page.php +++ b/app/class/Page.php @@ -43,6 +43,7 @@ class Page protected $visitcount; protected $editcount; protected $editby; + protected $sleep; const LEN = 255; @@ -112,6 +113,7 @@ class Page $this->setvisitcount(0); $this->seteditcount(0); $this->seteditby([]); + $this->setsleep(0); } public static function classvarlist() @@ -454,6 +456,11 @@ class Page return $this->editby; } + public function sleep($type = 'int') + { + return $this->sleep; + } + @@ -819,6 +826,15 @@ class Page return count($this->editby) > 0; } + public function setsleep($sleep) + { + $sleep = abs(intval($sleep)); + if($sleep > 180) { + $sleep = 180; + } + $this->sleep = $sleep; + } + /** * Merge new tag with actual tags * diff --git a/app/fn/fn.php b/app/fn/fn.php index ccccfb9..583227a 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -1,5 +1,7 @@ <?php +use Wcms\Medialist; + function readablesize($bytes) { $format = ' %d %s'; @@ -207,6 +209,28 @@ function array_diff_assoc_recursive($array1, $array2) { } +/** + * Generate a folder tree based on reccurive array + */ +function treecount(array $dir, string $dirname, int $deepness, string $path, string $currentdir, Medialist $mediaopt) +{ + if ($path . '/' === $currentdir) { + $folder = '├─📂<span id="currentdir">' . $dirname . '<span>'; + } else { + $folder = '├─📁' . $dirname; + } + echo '<tr>'; + echo '<td><a href="' . $mediaopt->getpathadress($path) . '">' . str_repeat(' ', $deepness) . $folder . '</a></td>'; + echo '<td>' . $dir['dirfilecount'] . '</td>'; + echo '</tr>'; + foreach ($dir as $key => $value) { + if (is_array($value)) { + treecount($value, $key, $deepness + 1, $path . DIRECTORY_SEPARATOR . $key, $currentdir, $mediaopt); + } + } +} + + diff --git a/app/view/templates/admin.php b/app/view/templates/admin.php index d8255ba..c201d90 100644 --- a/app/view/templates/admin.php +++ b/app/view/templates/admin.php @@ -12,277 +12,286 @@ <section> - <form action="<?= $this->url('adminupdate') ?>" method="post"> + <div class="block"> + <h1>Administration</h1> + + <div class="scroll"> + + <form action="<?= $this->url('adminupdate') ?>" method="post"> - <article> - <h1>Administration</h1> + <article> - <input type="submit" value="Update configuration"> - </article> - <article> + <input type="submit" value="Update configuration"> + </article> - <h2>Home page</h2> + <article> - <p>Here you can set the home-page view for visitors.</p> + <h2>Home page</h2> - <div class="radio"> - <input type="radio" name="homepage" value="default" id="default" <?= Wcms\Config::homepage() === 'default' ? 'checked' : '' ?>> - <label for="default">default</label> - </div> + <p>Here you can set the home-page view for visitors.</p> - <div class="radio"> - <input type="radio" name="homepage" value="search" id="searchbar" <?= Wcms\Config::homepage() === 'search' ? 'checked' : '' ?>> - <label for="searchbar">search bar</label> - </div> + <div class="radio"> + <input type="radio" name="homepage" value="default" id="default" <?= Wcms\Config::homepage() === 'default' ? 'checked' : '' ?>> + <label for="default">default</label> + </div> - <div class="radio"> - <input type="radio" name="homepage" value="redirect" id="redirect" <?= Wcms\Config::homepage() === 'redirect' ? 'checked' : '' ?>> - <label for="redirect">redirect to page</label> - </div> + <div class="radio"> + <input type="radio" name="homepage" value="search" id="searchbar" <?= Wcms\Config::homepage() === 'search' ? 'checked' : '' ?>> + <label for="searchbar">search bar</label> + </div> - <select name="homeredirect" id="homeredirect"> - <option value="" <?= Wcms\Config::homeredirect() === null ? 'selected' : '' ?>>--select page to redirect--</option> + <div class="radio"> + <input type="radio" name="homepage" value="redirect" id="redirect" <?= Wcms\Config::homepage() === 'redirect' ? 'checked' : '' ?>> + <label for="redirect">redirect to page</label> + </div> - <?php - foreach ($pagelist as $page) { - ?> - <option value="<?= $page ?>" <?= Wcms\Config::homeredirect() === $page ? 'selected' : '' ?>><?= $page ?></option> - <?php - } + <select name="homeredirect" id="homeredirect"> + <option value="" <?= Wcms\Config::homeredirect() === null ? 'selected' : '' ?>>--select page to redirect--</option> + + <?php + foreach ($pagelist as $page) { + ?> + <option value="<?= $page ?>" <?= Wcms\Config::homeredirect() === $page ? 'selected' : '' ?>><?= $page ?></option> + <?php + } - ?> - </select> + ?> + </select> - </article> + </article> - <article> + <article> - <h2>Page creation</h2> + <h2>Page creation</h2> - <p>What really happend when you create a new page</p> + <p>What really happend when you create a new page</p> - <label for="defaultprivacy">Default privacy</label> - <select name="defaultprivacy" id="defaultprivacy"> - <option value="0" <?= Wcms\Config::defaultprivacy() == 0 ? 'selected' : '' ?>>public</option> - <option value="1" <?= Wcms\Config::defaultprivacy() == 1 ? 'selected' : '' ?>>private</option> - <option value="2" <?= Wcms\Config::defaultprivacy() == 2 ? 'selected' : '' ?>>not published</option> - </select> + <label for="defaultprivacy">Default privacy</label> + <select name="defaultprivacy" id="defaultprivacy"> + <option value="0" <?= Wcms\Config::defaultprivacy() == 0 ? 'selected' : '' ?>>public</option> + <option value="1" <?= Wcms\Config::defaultprivacy() == 1 ? 'selected' : '' ?>>private</option> + <option value="2" <?= Wcms\Config::defaultprivacy() == 2 ? 'selected' : '' ?>>not published</option> + </select> - <label for="defaultpage">Or, create new page BODY based on an already existing one</label> - <select name="defaultpage" id="defaultpage"> - <option value="" <?= Wcms\Config::defaultpage() === '' || !$defaultpageexist ? 'selected' : '' ?>>--use default BODY element--</option> - <?php - foreach ($pagelist as $page) { + <label for="defaultpage">Or, create new page BODY based on an already existing one</label> + <select name="defaultpage" id="defaultpage"> + <option value="" <?= Wcms\Config::defaultpage() === '' || !$defaultpageexist ? 'selected' : '' ?>>--use default BODY element--</option> + <?php + foreach ($pagelist as $page) { + ?> + <option value="<?= $page ?>" <?= Wcms\Config::defaultpage() === $page ? 'selected' : '' ?>><?= $page ?></option> + <?php } + ?> + </select> + + <?php + if (empty(!$defaultpageexist || Wcms\Config::defaultpage())) { + ?> + <label for="defaultbody">Edit default BODY element</label> + <textarea name="defaultbody" id="defaultbody" cols="30" rows="10"><?= Wcms\Config::defaultbody() ?></textarea> + <?php + } ?> - <option value="<?= $page ?>" <?= Wcms\Config::defaultpage() === $page ? 'selected' : '' ?>><?= $page ?></option> - <?php } - ?> - </select> - <?php - if (empty(!$defaultpageexist || Wcms\Config::defaultpage())) { - ?> - <label for="defaultbody">Edit default BODY element</label> - <textarea name="defaultbody" id="defaultbody" cols="30" rows="10"><?= Wcms\Config::defaultbody() ?></textarea> - <?php - } - ?> + </article> - </article> + <article> - <article> + <h2>Alert pages</h2> - <h2>Alert pages</h2> + <h4>Common options</h4> - <h4>Common options</h4> + <label for="alerttitle">H1 Title</label> + <input type="text" name="alerttitle" id="alerttitle" value="<?= Wcms\Config::alerttitle() ?>"> - <label for="alerttitle">H1 Title</label> - <input type="text" name="alerttitle" id="alerttitle" value="<?= Wcms\Config::alerttitle() ?>"> + <label for="alertlink">Link to this page (for visitors)</label> + <select name="alertlink" id="alertlink"> + <option value="" <?= empty(Wcms\Config::alertlink()) ? 'selected' : '' ?>>--No link--</option> + <?php + foreach ($pagelist as $page) { + ?> + <option value="<?= $page ?>" <?= Wcms\Config::alertlink() === $page ? 'selected' : '' ?>><?= $page ?></option> + <?php } + ?> + </select> - <label for="alertlink">Link to this page (for visitors)</label> - <select name="alertlink" id="alertlink"> - <option value="" <?= empty(Wcms\Config::alertlink()) ? 'selected' : '' ?>>--No link--</option> - <?php - foreach ($pagelist as $page) { - ?> - <option value="<?= $page ?>" <?= Wcms\Config::alertlink() === $page ? 'selected' : '' ?>><?= $page ?></option> - <?php } - ?> - </select> + <label for="alertlinktext">Link text</label> + <input type="text" name="alertlinktext" id="alertlinktext" value="<?= Wcms\Config::alertlinktext() ?>"> - <label for="alertlinktext">Link text</label> - <input type="text" name="alertlinktext" id="alertlinktext" value="<?= Wcms\Config::alertlinktext() ?>"> + <h4>Un-existing</h4> - <h4>Un-existing</h4> + <label for="existnot">Text to show when a page does not exist yet.</label> + <i>This will also be shown as a tooltip over links.</i> + <input type="text" name="existnot" id="existnot" value="<?= Wcms\Config::existnot() ?>"> - <label for="existnot">Text to show when a page does not exist yet.</label> - <i>This will also be shown as a tooltip over links.</i> - <input type="text" name="existnot" id="existnot" value="<?= Wcms\Config::existnot() ?>"> + <div class="checkbox"> + <input type="hidden" name="existnotpass" value="0"> + <input type="checkbox" name="existnotpass" id="existnotpass" value="1" <?= Wcms\Config::existnotpass() ? 'checked' : '' ?>> + <label for="existnotpass">Ask for password</label> + </div> - <div class="checkbox"> - <input type="hidden" name="existnotpass" value="0"> - <input type="checkbox" name="existnotpass" id="existnotpass" value="1" <?= Wcms\Config::existnotpass() ? 'checked' : '' ?>> - <label for="existnotpass">Ask for password</label> - </div> + <h4>Private</h4> - <h4>Private</h4> + <label for="private">Text to show when a page is private.</label> + <input type="text" name="private" id="private" value="<?= Wcms\Config::private() ?>"> - <label for="private">Text to show when a page is private.</label> - <input type="text" name="private" id="private" value="<?= Wcms\Config::private() ?>"> + <div class="checkbox"> + <input type="hidden" name="privatepass" value="0"> + <input type="checkbox" name="privatepass" id="privatepass" value="1" <?= Wcms\Config::privatepass() ? 'checked' : '' ?>> + <label for="privatepass">Ask for password</label> + </div> - <div class="checkbox"> - <input type="hidden" name="privatepass" value="0"> - <input type="checkbox" name="privatepass" id="privatepass" value="1" <?= Wcms\Config::privatepass() ? 'checked' : '' ?>> - <label for="privatepass">Ask for password</label> - </div> + <h4>Not published</h4> - <h4>Not published</h4> + <label for="notpublished">Text to show when a page is not published.</label> + <input type="text" name="notpublished" id="notpublished" value="<?= Wcms\Config::notpublished() ?>"> - <label for="notpublished">Text to show when a page is not published.</label> - <input type="text" name="notpublished" id="notpublished" value="<?= Wcms\Config::notpublished() ?>"> + <div class="checkbox"> + <input type="hidden" name="notpublishedpass" value="0"> + <input type="checkbox" name="notpublishedpass" id="notpublishedpass" value="1" <?= Wcms\Config::notpublishedpass() ? 'checked' : '' ?>> + <label for="notpublishedpass">Ask for password</label> + </div> - <div class="checkbox"> - <input type="hidden" name="notpublishedpass" value="0"> - <input type="checkbox" name="notpublishedpass" id="notpublishedpass" value="1" <?= Wcms\Config::notpublishedpass() ? 'checked' : '' ?>> - <label for="notpublishedpass">Ask for password</label> - </div> + <h4>CSS</h4> - <h4>CSS</h4> + <div class="checkbox"> + <input type="hidden" name="alertcss" value="0"> + <input type="checkbox" name="alertcss" id="alertcss" value="1" <?= Wcms\Config::alertcss() ? 'checked' : '' ?>> + <label for="alertcss">Use global.css for those page as well</label> + </div> - <div class="checkbox"> - <input type="hidden" name="alertcss" value="0"> - <input type="checkbox" name="alertcss" id="alertcss" value="1" <?= Wcms\Config::alertcss() ? 'checked' : '' ?>> - <label for="alertcss">Use global.css for those page as well</label> - </div> + <p> + <i>You can use <code>body.alert</code> class to specify style.</i> + </p> - <p> - <i>You can use <code>body.alert</code> class to specify style.</i> - </p> + </article> + + + <article> + - </article> - - - <article> - + <h2>Render</h2> - <h2>Render</h2> + <div class="checkbox"> + <input type="hidden" name="reccursiverender" value="0"> + <input type="checkbox" name="reccursiverender" id="reccursiverender" value="1" <?= Wcms\Config::reccursiverender() ? 'checked' : '' ?>> + <label for="reccursiverender">Reccursive render</label> + </div> - <div class="checkbox"> - <input type="hidden" name="reccursiverender" value="0"> - <input type="checkbox" name="reccursiverender" id="reccursiverender" value="1" <?= Wcms\Config::reccursiverender() ? 'checked' : '' ?>> - <label for="reccursiverender">Reccursive render</label> - </div> + <h4>Links</h4> - <h4>Links</h4> + <div class="checkbox"> + <input type="hidden" name="externallinkblank" value="0"> + <input type="checkbox" name="externallinkblank" id="externallinkblank" value="1" <?= Wcms\Config::externallinkblank() ? 'checked' : '' ?>> + <label for="externallinkblank">Open external links in new tab</label> + </div> - <div class="checkbox"> - <input type="hidden" name="externallinkblank" value="0"> - <input type="checkbox" name="externallinkblank" id="externallinkblank" value="1" <?= Wcms\Config::externallinkblank() ? 'checked' : '' ?>> - <label for="externallinkblank">Open external links in new tab</label> - </div> + <div class="checkbox"> + <input type="hidden" name="internallinkblank" value="0"> + <input type="checkbox" name="internallinkblank" id="internallinkblank" value="1" <?= Wcms\Config::internallinkblank() ? 'checked' : '' ?>> + <label for="internallinkblank">Open internal links in new tab</label> + </div> - <div class="checkbox"> - <input type="hidden" name="internallinkblank" value="0"> - <input type="checkbox" name="internallinkblank" id="internallinkblank" value="1" <?= Wcms\Config::internallinkblank() ? 'checked' : '' ?>> - <label for="internallinkblank">Open internal links in new tab</label> - </div> + <i>(This modifications need re-rendering)</i> - <i>(This modifications need re-rendering)</i> + </article> - </article> + <article> - <article> + <h2>CSS</h2> - <h2>CSS</h2> + <label for="globalcss">Edit global css that will apply to every pages</label> + <textarea name="globalcss" id="globalcss" cols="30" rows="10"><?= $globalcss ?></textarea> - <label for="globalcss">Edit global css that will apply to every pages</label> - <textarea name="globalcss" id="globalcss" cols="30" rows="10"><?= $globalcss ?></textarea> + <label for="defaultfavicon">Default favicon</label> + <select name="defaultfavicon" id="defaultfavicon"> + <option value="">--no favicon--</option> + <?php + foreach ($faviconlist as $favicon) { + ?> + <option value="<?= $favicon ?>" <?= Wcms\Config::defaultfavicon() === $favicon ? 'selected' : '' ?>><?= $favicon ?></option> + <?php + } + ?> + </select> - <label for="defaultfavicon">Default favicon</label> - <select name="defaultfavicon" id="defaultfavicon"> - <option value="">--no favicon--</option> - <?php - foreach ($faviconlist as $favicon) { - ?> - <option value="<?= $favicon ?>" <?= Wcms\Config::defaultfavicon() === $favicon ? 'selected' : '' ?>><?= $favicon ?></option> - <?php - } - ?> - </select> + </article> - </article> + <article> - <article> + <h2>Interface</h2> - <h2>Interface</h2> + <p>Set interface Style</p> - <p>Set interface Style</p> + <select name="interfacecss" id="interfacecss"> + <option value="null">--default interface style---</option> + <?php + foreach ($interfacecsslist as $interfacecss) { + ?> + <option value="<?= $interfacecss ?>" <?= $interfacecss === Wcms\Config::interfacecss() ? 'selected' : '' ?>><?= $interfacecss ?></option> + <?php + } + ?> + </select> - <select name="interfacecss" id="interfacecss"> - <option value="null">--default interface style---</option> - <?php - foreach ($interfacecsslist as $interfacecss) { - ?> - <option value="<?= $interfacecss ?>" <?= $interfacecss === Wcms\Config::interfacecss() ? 'selected' : '' ?>><?= $interfacecss ?></option> - <?php - } - ?> - </select> + </article> - </article> + <article> - <article> + <h2>Tracking</h2> - <h2>Tracking</h2> + <label for="analytics">Google analytics Tracking ID</label> + <input type="text" name="analytics" id="analytics" value="<?= Wcms\Config::analytics() ?>"> - <label for="analytics">Google analytics Tracking ID</label> - <input type="text" name="analytics" id="analytics" value="<?= Wcms\Config::analytics() ?>"> + <i>(Need rendering to work)</i> - <i>(Need rendering to work)</i> + </article> - </article> + <article> + <input type="submit" value="Update configuration"> + </article> - <article> - <input type="submit" value="Update configuration"> - </article> + </form> - </form> + </div> + + </div> </section> diff --git a/app/view/templates/editleftbar.php b/app/view/templates/editleftbar.php index c901c14..8302090 100644 --- a/app/view/templates/editleftbar.php +++ b/app/view/templates/editleftbar.php @@ -152,7 +152,11 @@ </fieldset> </details> - <details id="advanced" <?= !empty($page->externalcss()) || !empty($page->customhead()) ? 'open' : '' ?>> + + + + + <details id="advanced" <?= !empty($page->externalcss()) || !empty($page->customhead()) || !empty($page->sleep()) ? 'open' : '' ?>> <summary>Advanced</summary> @@ -176,6 +180,9 @@ <label for="customhead">Custom head</label> <textarea name="customhead" wrap="off" spellcheck="false" rows="<?= $page->customhead('int') ?>"><?= $page->customhead() ?></textarea> + <label for="sleep">Sleep time (seconds)</label> + <input type="number" name="sleep" id="sleep" value="<?= $page->sleep() ?>" min="0" max="180"> + </fieldset> </details> diff --git a/app/view/templates/home.php b/app/view/templates/home.php index c47a3ec..ddf4e46 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -87,9 +87,9 @@ <tr> <?php if($user->issupereditor()) { ?><td class="hidephone"><input type="checkbox" name="pagesid[]" value="<?= $item->id() ?>" id="id_<?= $item->id() ?>" form="multi"></td><?php } ?> <td><label title="<?= $item->title() ?>" for="id_<?= $item->id() ?>"><?= $item->id() ?></label></td> - <td><a href="<?= $this->upage('pageedit', $item->id()) ?>"><img src="<?= Wcms\Model::iconpath() ?>edit.png" class="icon"></a></td> + <td><?php if($user->issupereditor() || in_array($user->id(), $item->authors())) { ?><a href="<?= $this->upage('pageedit', $item->id()) ?>"><img src="<?= Wcms\Model::iconpath() ?>edit.png" class="icon"></a><?php } ?></td> <td><a href="<?= $this->upage('pageread/', $item->id()) ?>" target="_blank"><img src="<?= Wcms\Model::iconpath() ?>read.png" class="icon"></a></td> - <td class="delete"><a href="<?= $this->upage('pagedelete', $item->id()) ?>">✖</a></td> + <td class="delete"><?php if($user->issupereditor() || $item->authors() === [$user->id()]) { ?><a href="<?= $this->upage('pagedelete', $item->id()) ?>">✖</a><?php } ?></td> <?php if ($user->issupereditor()) { ?> <td class="hidephone"><a href="<?= $this->upage('pagedownload', $item->id()) ?>" download><img src="<?= Wcms\Model::iconpath() ?>download.png" class="icon"></a></td> <?php } diff --git a/app/view/templates/homemenu.php b/app/view/templates/homemenu.php index 2ee1381..669f9f2 100644 --- a/app/view/templates/homemenu.php +++ b/app/view/templates/homemenu.php @@ -118,6 +118,11 @@ ?> </select> <label for="templatejavascript">Javascript</label> </br> + <strong>Advanced</strong> + </br> + <input type="number" name="datas[sleep]" id="sleep" min="0" max="180"> + <label for="sleep">Sleep time (seconds)</label> + </br> <strong>Author</strong> </br> <select name="addauthor" id="addauthor"> diff --git a/app/view/templates/info.php b/app/view/templates/info.php index f1ca1f9..9a5357e 100644 --- a/app/view/templates/info.php +++ b/app/view/templates/info.php @@ -10,44 +10,66 @@ <main class="info"> +<nav class="info"> + <div class="block"> + <div class="scroll"> -<section> + <h2>Version</h2> + <?= $version ?> -<article> -<h1>Info</h1> -<h2>Version</h2> + <h2>Links</h2> -<?= $version ?> + <ul> + <li><a href="https://github.com/vincent-peugnet/wcms" target="_blank">🐱👤 Github</a></li> + <li><a href="https://w-cms.top" target="_blank">🌵 Website</a></li> + </ul> -<h2>Links</h2> + <h2>Manual Summary</h2> -<ul> -<li><a href="https://github.com/vincent-peugnet/wcms" target="_blank">🐱👤 Github</a></li> -<li><a href="#manual">📕 Manual</a></li> -<li><a href="https://w-cms.top" target="_blank">🌵 Website</a></li> -</ul> + <?= $summary ?> + </div> + </div> + </div> +</nav> -<h2>About</h2> +<section class="info"> -<h3>W-cms was made using these open sources and free components :</h3> + <div class="block"> + <h1>Info</h1> + <div class="scroll"> + <article> -<ul> -<li><a href="https://github.com/jamesmoss/flywheel" target="_blank">🎡 James Moss's Flywheel Database</a> <i>as json noSQL flatfile database engine</i></li> -<li><a href="https://github.com/michelf/php-markdown" target="_blank">📝 Michel Fortin's Markdown Extra</a> <i>markdown library</i></li> -<li><a href="https://github.com/thephpleague/plates" target="_blank">🎨 Plates</a> <i>as templating engine</i></li> -<li><a href="https://github.com/dannyvankooten/AltoRouter">🐶 Alto Router</a> <i>as router engine</i></li> -</ul> -<h3>Special thanks to :</h3> -<a href="https://nicolas.club1.fr" target="_blank">🚲 Nicolas Peugnet</a> -</article> + <h2>About</h2> + + <h3>W-cms was made using these open sources and free components :</h3> + + <ul> + <li><a href="https://github.com/jamesmoss/flywheel" target="_blank">🎡 James Moss's Flywheel Database</a> <i>as json noSQL flatfile database engine</i></li> + <li><a href="https://github.com/michelf/php-markdown" target="_blank">📝 Michel Fortin's Markdown Extra</a> <i>markdown library</i></li> + <li><a href="https://github.com/thephpleague/plates" target="_blank">🎨 Plates</a> <i>as templating engine</i></li> + <li><a href="https://github.com/dannyvankooten/AltoRouter">🐶 Alto Router</a> <i>as router engine</i></li> + </ul> + + <h3>Special thanks to :</h3> + + <a href="https://nicolas.club1.fr" target="_blank">🚲 Nicolas Peugnet</a> + + </article> + + <article id="manual"> + <?= $manual ?> + </article> + + + </div> + </div> -<?php $this->insert('man') ?> </section> diff --git a/app/view/templates/man.php b/app/view/templates/man.php deleted file mode 100644 index deb81ee..0000000 --- a/app/view/templates/man.php +++ /dev/null @@ -1,320 +0,0 @@ - - -<nav> -<h2>Manual Summary</h2> -<ul> - <li><a href="#startup">Startup</a></li> - <ul> - - </ul> - <li><a href="#structure">Structure</a></li> - <ul> - <li><a href="#attributes">Page attributes</a></li> - <li><a href="#database">Database</a></li> - </ul> - <li><a href="#editor">Editor</a></li> - <ul> - <li><a href="#elementsyntax">Elements syntax</a></li> - <li><a href="#bodysyntax">Body syntax</a></li> - </ul> -</ul> - -</nav> - - - -<article id="manual"> - -<h2 id="manual">Manual</h2> - -<h3 id="startup">Startup</h3> - -<p>There is'nt a real start of anything when you're using W.</p> - -<p>Just type an adress in your web browser, after your W folder. You should see an empty page, not existing yet. You can login to create one at this adress. If you are already logged in, you can juste type <code><i>page_id</i>/add</code>, this will directly create a page at this adress.</p> - -<p>This <code><i>page_id</i></code> is the identifier of each page, you cant change it later, this is like a real solid adress, it cant move. It can only contain lowercase letters, numbers, hyphens or underscore charachters.</p> - -<p>No visitor can see the full list of pages you've created. The only way to see the whole map of your project, is to be conected at least as an editor, and go to the "homepage", the root adress where W is instaled.</p> - -<h3 id="structure">Structure</h3> - -<h4>Pages and IDs</h4> - -<p>The structure of website is very simple as there is no structure. It's you to link the pages together or not.</p> - -<p>A page is defined by a unique <code>id</code>. As it's created, you can access it typing <code>.../<i>your_page_id</i>/</code> or without slash <code>.../<i>your_page_id</i></code></p> - -<p>An ID can only contain lowercase letters, numbers, underscore and "-"</p> - - -<h4 id="attributes">Page attributes</h4> - -<h5>Id</h5> - -<p>Unique identifier, this is the url that point to your page</p> - -<h5>title</h5> - -<p>Page title, can use more complex characters than the ID element. It's printed in the explorer tab name. It's the official name of your page.</p> - -<h5>Description</h5> - -<p>The description attribute is a short informations about your page. It's used to create tooltip, when the mouse hover internal links.</p> - -<h5>Tag(s)</h5> - -<p>tags are used to create selections of pages. tags are one word only, sepparated by commas and whitespace.</p> - -<h5>Privacy level</h5> - -<p>Set the level of privacy of your page. -</br><strong>0</strong> -> public -</br><strong>1</strong> -> private <i>reserved to private readers</i> -</br><strong>2</strong> -> not published <i>Nobody but editors can see it.</i> </p> - - -<h5>Date & time</h5> - -<p>You can manualy set a date and time for each pages.</p> - -<h4 id="database">Database</h4> - -<p>All this pages are stored in your database, as a file by page. You can access them in the <code>.../database/<i>name_of_your_store</i>/</code></p> - - - - - - - - - - - -<h3 id="editor">Editor</h3> - -<p>W use the fives basics html elements to store your content</p> - -<ul> -<li>header</li> -<li>nav</li> -<li>aside</li> -<li>main</li> -<li>footer</li> -</ul> - -<p>You can use any of them, only one or all at the same time, as you prefer.</p> - -<h4 id="elementsyntax">Element syntax</h4> - -<p>In any of the five html element you can use to store content, you can use the following syntax, that is specific to W, extending the Markdown syntax :</p> - -<h5>quick internal link</h5> - -<p>You can create internal link very quickly, only by using the id of your page. The link text will be remplaced by the title associated with this page.</p> - -<blockquote> - [<i>page_id</i>] -</blockquote> - -<p>This will output :</p> - -<blockquote> -<a href="<i>page->url</i>" class="internal" title="<i>page->description</i>"><i>page->title</i></a> -</blockquote> - -<h5>Title shortcut</h5> - -<blockquote> - %TITLE% -</blockquote> - -<p>Will output the page <code>title</code> attribute. This can be usefull when templating, or including differents page element.</p> - - -<h5>Description shortcut</h5> - -<blockquote> - %DESCRIPTION% -</blockquote> - -<p>As for the title, this will output the <code>description</code> attribute of the page</p> - -<h5>Date shortcut</h5> - -<blockquote> - %DATE% %DATECREATION% %DATEMODIF% -</blockquote> - -<p>There are tree dates attributes that can be printed. The <strong>date</strong> attribute, will return the date that can be manualy set in the editor. <strong>datecreation</strong> will return the date of the page creation. <strong>datemodif</strong> will output the last editing date.</p> - - -<h5>Automatic summary</h5> - -<p>You can automatically generate summary, based on the page <code><h*></code> elements</p> - -<blockquote> - %SUMMARY% -</blockquote> - -<p>This will generate a classic <code><ul></code> html list.</p> - -<h5>Automatic list by tag</h5> - -<p>You can create a html list of links pointing to all the pages using this tag.</p> - -<blockquote> - %TAG:<i>__tag__</i>% -</blockquote> - -<p>Let's suppose we are in page3 and we have page2, page3, page5, using this tag, this will output :</p> - -<blockquote> -<ul id="<i>tag</i>"> -</br> -<li> -</br> -<a href="<i>2->url</i>" class="internal" title="<i>2->description</i>"><i>2->title</i></a> -</br> -</li> -</br> -<li> -</br> -<a href="<i>3->url</i>" class="internal actualpage" title="<i>3->description</i>"><i>3->title</i></a> -</br> -</li> -</br> -<li> -</br> -<a href="<i>5->url</i>" class="internal" title="<i>5->description</i>"><i>5->title</i></a> -</br> -</li> -</br> -</ul> -</blockquote> - -<p>The list is ordered by the <code>date</code> attribute, that you can set manualy for each page. You may have noticed that the actual page (page 3), has been specified using <code>.actualpage</code> class. This can be usefull to create a menu and highlight the current page.</p> - - -<h5>Article separator</h5> - -<p>You can use the <code>article</code> html element, by separating text using at least <code>====</code>. It is of course possible to use Markdown synthax inside those articles separators</p> - -<blockquote> -====</br></br> -<i>some text</i></br></br> -======<i>important</i></br></br> -<i>this is a longer text</i></br></br> -======</br></br> -</blockquote> - -<p>This will ouptut :</p> - -<blockquote> -<article></br> -<i>some text</i></br> -</article></br> -<article id="<i>important</i>"></br> -<i>this is a longer textt</i></br> -</article></br> -</blockquote> - - -<p>As you may have noticed, there is also the possibility to add a custom <code>id</code> to any of the articles created that way</p> - - -<h5>Media list</h5> - -<p>As it is too long adding all media of a folder one by one, you can just print the content of an entire folder using this method.</p> - -<blockquote> -%MEDIA:<i>__directory__</i> -</blockquote> - -<p>Just point to the good directory inside the media folder. This will output html list, creating image elements, audio players, video players, or just basic link, depending on the media type.</p> - - - - - - -<h4 id="bodysyntax">Body syntax</h4> - - - - -<h5>Basic including</h5> - -<blockquote>%HTML_ELEMENT%</blockquote> - - -<p>This will include the matching html element from your page's content in your page body. If there is nothing in the corresponding element, it won't print anything. The name of the html element as to be UPPERCASE.</p> - -<p>For example :</p> - -<blockquote> -%ASIDE% -</br> -</br> -%MAIN% -</blockquote> - -<p>Will output :</p> - -<blockquote> -<aside class="<i>page_id</i>"> -</br> -__the content of your aside__ -</br> - -</aside> -</br> -</br> -<main class="<i>page_id</i>"> -</br> -__the content of your main__ -</br> - -</main> - - -</blockquote> - -<p>You can also use one element multiple times.</p> - -<h5>Advanced includings</h5> - -<blockquote> - %<i>HTML_ELEMENT</i>:<i>page_id</i>% -</blockquote> - -<p>By doing this, you can include the <code>HTML_ELEMENT</code> of the page using this <code>page_id</code> id. You can even nest differents pages source by adding <code>page_id</code> separated by a dot, this would be like :</p> - -<blockquote> - %<i>HTML_ELEMENT</i>:<i>page1_id</i>+<i>page2_id</i>% -</blockquote> - -<p>And you can mix it with the original page content using <code>!</code> identifier</p> - -<blockquote> - %<i>HTML_ELEMENT</i>:<i>page3_id</i>+<i>!</i>% -</blockquote> - -<p>This will output :</p> - -<blockquote> - -<html_element class="<i>page3_id page_id</i>"> -</br> -__content of page1's html element__ -</br> -__content of this page html element__ -</br> -</html_element> - - - -</blockquote> - -</article> diff --git a/app/view/templates/media.php b/app/view/templates/media.php index be1ac7f..12d4a2f 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -7,122 +7,81 @@ <?php $this->insert('backtopbar', ['user' => $user, 'tab' => 'media', 'pagelist' => $pagelist]) ?> + <?php $this->insert('mediamenu', ['user' => $user, 'pathlist' => $pathlist, 'mediaopt' => $mediaopt]) ?> <main class="media"> -<div id="tree"> -<h2>Explorer</h2> - - -<table id="dirlsit"> -<tr><th>folder</th><th>files</th></tr> - -<?php - -function treecount(array $dir, string $dirname, int $deepness, string $path, string $currentdir, array $opt) -{ - if ($path === $currentdir) { - $folder = '├─📂<strong>' . $dirname . '<strong>'; - } else { - $folder = '├─📁' . $dirname; - } - echo '<tr>'; - echo '<td><a href="?path=' . $path . '&sortby=' . $opt['sortby'] . '&order=' . $opt['order'] . '">' . str_repeat(' ', $deepness) . $folder . '</a></td>'; - echo '<td>' . $dir['dirfilecount'] . '</td>'; - echo '</tr>'; - foreach ($dir as $key => $value) { - if (is_array($value)) { - treecount($value, $key, $deepness + 1, $path . DIRECTORY_SEPARATOR . $key, $currentdir, $opt); - } - } -} - -treecount($dirlist, 'media', 0, 'media', $dir, $opt); - -?> - - - -</table> -</div> - - -<div id="explorer"> - - -<h2><?= $dir ?></h2> - - -<details> - <summary>Print this content on your page</summary> - - <p> - <code>%MEDIA?path=<?= substr($dir, 6) ?>&sortby=<?= $opt['sortby'] ?>&order=<?= $opt['order'] ?>%</code> - </p> - -</details> - - - -<form id="folderadd" action="<?= $this->url('mediafolderadd') ?>" method="post"> - <label for="foldername">📂 New folder</label> - <input type="text" name="foldername" id="foldername" placeholder="folder name" required> - <input type="hidden" name="dir" value="<?= $dir ?>"> - <input type="submit" value="create folder"> -</form> - -<?php if($user->issupereditor()) { ?> - -<form action="<?= $this->url('mediafolderdelete') ?>" id="deletefolder" method="post" class="hidephone"> - <input type="hidden" name="dir" value="<?= $dir ?>/"> - <input type="checkbox" name="deletefolder" id="confirmdeletefolder" value="1"> - <label for="confirmdeletefolder">Delete folder and all it's content</label> - <input type="submit" value="delete folder" > -</form> - - -<?php } ?> - -<form id=addmedia action="<?= $this->url('mediaupload') ?>" method="post" enctype="multipart/form-data"> - <label for="file">🚀 Upload file(s)</label> - <input type='file' id="file" name='file[]' multiple required> - <input type="hidden" name="dir" value="<?= $dir ?>"> - <input type="submit" value="upload"> -</form> - - - -<?php if($user->issupereditor()) { ?> - -<form action="<?= $this->url('mediaedit') ?>" method="post" id="mediaedit"> - <input type="hidden" name="path" value="<?= $dir ?>"> - <label for="moveto">Selected medias :</label> - <select name="dir" id="moveto" > - <option selected>---select destination---</option> - <option value="<?= Wcms\Model::MEDIA_DIR ?>">/</option> - <?php - foreach ($pathlist as $path) { - echo '<option value="' . Wcms\Model::MEDIA_DIR . $path . '">' . $path . '</option>'; - } - ?> - </select> - <input type="submit" name="action" value="move" > - <input type="submit" name="action" value="delete" > -</form> - -<?php } ?> - +<nav class="media"> + <div class="block"> + <h2>Explorer</h2> + <div class="scroll"> + <table id="dirlsit"> + <tr><th>folder</th><th>files</th></tr> + + <?php + + + treecount($dirlist, 'media', 0, 'media', $mediaopt->dir(), $mediaopt); + + ?> + + </table> + </div> + + </div> +</nav> + +<div id="fildter"> + <div class="block"> + <h2>filter</h2> + <div class="scroll"> + <form action="" method="get"> + <fieldset> + <legend>Type</legend> + <ul> + <li><input type="checkbox" name="type[]" id="image" value="image" <?= in_array('image', $mediaopt->type()) ? 'checked' : '' ?>><label for="image">image</label></li> + <li><input type="checkbox" name="type[]" id="sound" value="sound" <?= in_array('sound', $mediaopt->type()) ? 'checked' : '' ?>><label for="sound">sound</label></li> + <li><input type="checkbox" name="type[]" id="video" value="video" <?= in_array('video', $mediaopt->type()) ? 'checked' : '' ?>><label for="video">video</label></li> + <li><input type="checkbox" name="type[]" id="other" value="other" <?= in_array('other', $mediaopt->type()) ? 'checked' : '' ?>><label for="other">other</label></li> + </ul> + </fieldset> + <fieldset> + <legend>Sort</legend> + <select name="sortby" id="sortby"> + <option value="id" <?= $mediaopt->sortby() === 'id' ? 'selected' : '' ?>>id</option> + <option value="type" <?= $mediaopt->sortby() === 'type' ? 'selected' : '' ?>>type</option> + <option value="size" <?= $mediaopt->sortby() === 'size' ? 'selected' : '' ?>>size</option> + </select> + </br> + <input type="radio" name="order" id="asc" value="1" <?= $mediaopt->order() == 1 ? 'checked' : '' ?>><label for="asc">ascending</label> + </br> + <input type="radio" name="order" id="desc" value="-1" <?= $mediaopt->order() == -1 ? 'checked' : '' ?>><label for="desc">descending</label> + </br> + </fieldset> + <input type="hidden" name="path" value="<?= $mediaopt->path() ?>"> + <input type="submit" value="filter"> + </form> + </div> + </div> + </div> + + + +<section> + <div class="block"> + +<h2>/<?= $mediaopt->dir() ?></h2> <table id="medialist"> <tr> <th>x</th> - <th><a href="?path=<?= $dir ?>&sortby=id&order=<?php echo ($opt['order'] * -1); ?>">id</a></th> + <th><a href="<?= $mediaopt->getsortbyadress('id') ?>">id</a></th> <th>ext</th> - <th><a href="?path=<?= $dir ?>&sortby=type&order=<?php echo ($opt['order'] * -1); ?>">type</a></th> - <th><a href="?path=<?= $dir ?>&sortby=size&order=<?php echo ($opt['order'] * -1); ?>">size</a></th> + <th><a href="<?= $mediaopt->getsortbyadress('type') ?>">type</a></th> + <th><a href="<?= $mediaopt->getsortbyadress('size') ?>">size</a></th> <th>width</th> <th>height</th> <th>lengh</th> @@ -136,7 +95,7 @@ foreach ($medialist as $media) { <td><input type="checkbox" name="id[]" value="<?= $media->getfulldir() ?>" form="mediaedit" id="media_<?= $media->id() ?>"></td> <td><label for="media_<?= $media->id() ?>"><?= $media->id() ?></label></td> <td><?= $media->extension() ?></td> - <td><a href="<?= $media->getfullpath() ?>" target="_blank"><?= $media->type() == 'image' ? '<span class="thumbnail">image 👁<img src="' . $media->getfullpath() . '"></span>' : $media->type() ?></a></td> + <td><a href="<?= $media->getfullpath() ?>" target="_blank"><?= $media->type() == 'image' ? '<span class="thumbnail">image 👁<img src="' . $media->getfullpath() . '"></span>' : $media->type() . '⧉' ?></a></td> <td><?= $media->size('hr') ?></td> <td><?= $media->width() ?></td> <td><?= $media->height() ?></td> @@ -144,15 +103,13 @@ foreach ($medialist as $media) { <td class="code"><code><?= $media->getcode() ?></code></td> </tr> <?php - } - - ?> </table> </div> +</section> </main> </body> diff --git a/app/view/templates/mediamenu.php b/app/view/templates/mediamenu.php new file mode 100644 index 0000000..560025a --- /dev/null +++ b/app/view/templates/mediamenu.php @@ -0,0 +1,80 @@ +<aside class="media hidephone"> + + <details> + <summary>File</summary> + <div class="submenu"> + <h2>Upload File(s)</h2> + <form id=addmedia action="<?= $this->url('mediaupload') ?>" method="post" enctype="multipart/form-data"> + <label for="file">🚀 Upload file(s)</label> + <input type='file' id="file" name='file[]' multiple required> + <input type="hidden" name="dir" value="<?= $mediaopt->dir() ?>"> + <input type="submit" value="upload"> + </form> + <h2>Folder</h2> + <form id="folderadd" action="<?= $this->url('mediafolderadd') ?>" method="post"> + <label for="foldername">📂 New folder</label> + <input type="text" name="foldername" id="foldername" placeholder="folder name" required> + <input type="hidden" name="dir" value="<?= $mediaopt->dir() ?>"> + <input type="submit" value="create folder"> + </form> + </div> + </details> + + + <details> + <summary>Edit</summary> + <div class="submenu"> + + <?php if($user->issupereditor()) { ?> + + <h2>Folder</h2> + <form action="<?= $this->url('mediafolderdelete') ?>" id="deletefolder" method="post" class="hidephone"> + <input type="hidden" name="dir" value="<?= $mediaopt->dir() ?>/"> + <input type="checkbox" name="deletefolder" id="confirmdeletefolder" value="1"> + <label for="confirmdeletefolder">Delete actual folder and all it's content</label> + </br> + <input type="submit" value="delete folder" > + </form> + + + <h2>Move</h2> + <form action="<?= $this->url('mediaedit') ?>" method="post" id="mediaedit"> + <input type="hidden" name="path" value="<?= $mediaopt->dir() ?>"> + <label for="moveto">Move selected medias to a new directory</label> + </br> + <select name="dir" id="moveto" > + <option selected>---select destination---</option> + <option value="<?= Wcms\Model::MEDIA_DIR ?>">/</option> + <?php + foreach ($pathlist as $path) { + echo '<option value="' . Wcms\Model::MEDIA_DIR . $path . '">' . $path . '</option>'; + } + ?> + </select> + <input type="submit" name="action" value="move" > + <h2>Delete</h2> + Delete selected medias + </br> + <input type="submit" name="action" value="delete" > + </form> + + + + <?php } ?> + </div> + </details> + + + <details> + <summary>Filter</summary> + <div class="submenu"> + <h2>Print folder content</h2> + + + + <p>Use this code to print the content of the actual folder in a page</p> + <code><?= $mediaopt->getquery() ?></code> + </div> + </details> + +</aside>
\ No newline at end of file diff --git a/app/view/templates/navback.php b/app/view/templates/navback.php deleted file mode 100644 index 8218897..0000000 --- a/app/view/templates/navback.php +++ /dev/null @@ -1,54 +0,0 @@ -<div class="menu"> - <?= $user->level() ?> - <div id="dropmenu"> - - <ul> - - <li> - <a class="button" href="./">home</a> - </li> - - -<?php if($user->isvisitor()) { ?> - - <li> - <form action="?action=login" method="post"> - <input type="password" name="pass" id="loginpass" placeholder="password"> - <input type="submit" value="login"> - </form> - </li> - -<?php } else { ?> - - <li> - <form action="?action=logout" method="post"> - <input type="submit" value="logout"> - </form> - </li> - -<?php } ?> - - - - -<?php if ($user->iseditor()) { ?> - - <li> - <a class="button" href="?aff=media" >Media</a> - </li> - -<?php } ?> - -<?php if($user->isadmin()) { ?> - - <li> - <a class="button" href="?aff=admin" >Admin</a> - </li> - -<?php } ?> - - - </ul> - - </div> -</div>
\ No newline at end of file diff --git a/app/view/templates/user.php b/app/view/templates/user.php index 21a7639..f281c93 100644 --- a/app/view/templates/user.php +++ b/app/view/templates/user.php @@ -10,157 +10,174 @@ <main class="user"> -<section> + <section> + <div class="block"> -<article> + + <h1>User : <?= $user->id() ?></h1> + + <div class="scroll"> -<h1>User : <?= $user->id() ?></h1> -<h2>Infos</h2> + <h2>Infos</h2> -<p>Connections count : <?= $getuser->connectcount() ?></p> + <p>Connections count : <?= $getuser->connectcount() ?></p> -<p>Account will expire in : <?= $getuser->expiredate('hrdi') ?></p> + <p>Account will expire in : <?= $getuser->expiredate('hrdi') ?></p> -<h2>Preferences</h2> + <h2>Preferences</h2> -<form action="<?= $this->url('userpref') ?>" method="post"> + <form action="<?= $this->url('userpref') ?>" method="post"> -<p> - <input type="number" name="cookie" value="<?= $getuser->cookie() ?>" id="cookie" min="0" max="365"> - <label for="cookie">Cookie conservation time <i>(In days)</i></label> - <input type="submit" value="submit"> -</p> - -</form> - -</article> - - -<?php if($user->isadmin()) { ?> - -<article> - -<h1>Admin panel</h1> - -<table> -<tr> -<th>id</th><th>password</th><th>hash</th><th>level</th><th>set expiration date</th><th>action</th><th>expire</th><th>connect</th> -</tr> - -<tr> - <form action="<?= $this->url('useradd') ?>" method="post"> - <td> - <input type="text" name="id" maxlength="128" required> - </td> - <td> - <input type="password" name="password" minlength="4" maxlength="64" required> - </td> - - <td> - <input type="hidden" name="passwordhashed" value="0"> - <input type="checkbox" name="passwordhashed" value="1"> - </td> - - <td> - <select name="level" id="level"> - <option value="1">reader</option> - <option value="2">invite</option> - <option value="3">editor</option> - <option value="4">super editor</option> - <option value="10">admin</option> - </select> - </td> - <td> - <input type="date" name="expiredate" id="expiredate" min="<?= $now ?>"> - </td> - <td> - <input type="submit" value="add"> - </td> - <td> - - </td> - <td> - - </td> - - </form> -</tr> + <p> + <input type="number" name="cookie" value="<?= $getuser->cookie() ?>" id="cookie" min="0" max="365"> + <label for="cookie">Cookie conservation time <i>(In days)</i></label> + <input type="submit" value="submit"> + </p> + + </form> + + + </div> + + + </div> + </section> -<?php -foreach ($userlist as $user ) { - ?> - <tr> - <form action="<?= $this->url('userupdate') ?>" method="post"> - - <td> - <?= $user->id() ?> - </td> - - <td> - <input type="password" name="password" minlength="4" maxlength="64" > - </td> - - <td> - <?= $user->passwordhashed() ? '🔑' : '<input type="hidden" name="passwordhashed" value="0"><input type="checkbox" name="passwordhashed" value="1">' ?> - </td> - - <td> - <select name="level" id="level"> - <option value="1" <?= $user->level() === 1 ? 'selected' : '' ?>>reader</option> - <option value="2" <?= $user->level() === 2 ? 'selected' : '' ?>>invite</option> - <option value="3" <?= $user->level() === 3 ? 'selected' : '' ?>>editor</option> - <option value="4" <?= $user->level() === 4 ? 'selected' : '' ?>>super editor</option> - <option value="10" <?= $user->level() === 10 ? 'selected' : '' ?>>admin</option> - </select> - </td> - - - <td> - <input type="date" name="expiredate" id="expiredate"<?= $user->expiredate() !== false ? 'value="' . $user->expiredate('string') . '"' : '' ?>> - <span>reset<input type="checkbox" name="expiredate" id="expiredate" value="null"></span> + <?php if($user->isadmin()) { ?> + + <section> - </td> + <div class="block"> + + <h1>Admin panel</h1> + + <div class="scroll"> + + <table> + <tr> + <th>id</th><th>password</th><th>hash</th><th>level</th><th>set expiration date</th><th>action</th><th>expire</th><th>connect</th> + </tr> + + <tr> + <form action="<?= $this->url('useradd') ?>" method="post"> + <td> + <input type="text" name="id" maxlength="128" required> + </td> + <td> + <input type="password" name="password" minlength="4" maxlength="64" required> + </td> + + <td> + <input type="hidden" name="passwordhashed" value="0"> + <input type="checkbox" name="passwordhashed" value="1"> + </td> + + <td> + <select name="level" id="level"> + <option value="1">reader</option> + <option value="2">invite</option> + <option value="3">editor</option> + <option value="4">super editor</option> + <option value="10">admin</option> + </select> + </td> + <td> + <input type="date" name="expiredate" id="expiredate" min="<?= $now ?>"> + </td> + <td> + <input type="submit" value="add"> + </td> + <td> + + </td> + <td> + + </td> + + </form> + </tr> + + + <?php + foreach ($userlist as $user ) { + ?> + + <tr> + <form action="<?= $this->url('userupdate') ?>" method="post"> + + <td> + <?= $user->id() ?> + </td> + + <td> + <input type="password" name="password" minlength="4" maxlength="64" > + </td> + + <td> + <?= $user->passwordhashed() ? '🔑' : '<input type="hidden" name="passwordhashed" value="0"><input type="checkbox" name="passwordhashed" value="1">' ?> + </td> + + <td> + <select name="level" id="level"> + <option value="1" <?= $user->level() === 1 ? 'selected' : '' ?>>reader</option> + <option value="2" <?= $user->level() === 2 ? 'selected' : '' ?>>invite</option> + <option value="3" <?= $user->level() === 3 ? 'selected' : '' ?>>editor</option> + <option value="4" <?= $user->level() === 4 ? 'selected' : '' ?>>super editor</option> + <option value="10" <?= $user->level() === 10 ? 'selected' : '' ?>>admin</option> + </select> + </td> + + + <td> + <input type="date" name="expiredate" id="expiredate"<?= $user->expiredate() !== false ? 'value="' . $user->expiredate('string') . '"' : '' ?>> + <span>reset<input type="checkbox" name="expiredate" id="expiredate" value="null"></span> + + </td> + + <td> + <input type="hidden" name="id" value="<?= $user->id() ?>"> + <input type="submit" name="action" value="update"> + <input type="submit" name="action" value="delete"> + </form> + + </td> + - <td> - <input type="hidden" name="id" value="<?= $user->id() ?>"> - <input type="submit" name="action" value="update"> - <input type="submit" name="action" value="delete"> - </form> - </td> + <td> + <?= $user->expiredate('hrdi') ?> + </td> + <td> + <?= $user->connectcount() ?> + </td> - <td> - <?= $user->expiredate('hrdi') ?> - </td> + </tr> - <td> - <?= $user->connectcount() ?> - </td> + <?php + } + ?> + </table> - </tr> - <?php - } -?> + </div> -</table> + </div> -</article> -<?php } ?> + </section> + <?php } ?> -</section> </main> |