diff options
-rw-r--r-- | MANUAL.md | 368 | ||||
-rw-r--r-- | README.md | 72 | ||||
-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/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 | ||||
-rw-r--r-- | assets/css/home.css | 138 | ||||
-rw-r--r-- | old_manual.html (renamed from app/view/templates/man.php) | 21 |
23 files changed, 1273 insertions, 679 deletions
diff --git a/MANUAL.md b/MANUAL.md new file mode 100644 index 0000000..b44b8e0 --- /dev/null +++ b/MANUAL.md @@ -0,0 +1,368 @@ +USER MANUAL +=========== + +Introduction +------------ + +Welcome to __W__, this manual is here to help you get the best of this tool. + +If it's you're first time using it, you should learn how to [create your first page](#create-your-first-page). + +If you already know the basics, you may want to check the references : + +- Discover how to [navigate](#navigation). +- Get to know the [structure of a page](#page-structure) to edit meta content. +- Learn more about the [URL based commands](#url-based-command-interface) you can type in the adress bar. +- Master the [render engine](#page-editing) to release the full potential of __W__. + + + +### Create your first page + +This 3 steps tutorial will introduce you to the basic __W__ moves. + +#### Add a new page + + +The first thing you have to do before creating a page is to **choose an adress** for this page. Each page have a unique adress that identify it, it's the [**page id**](#page-id). You can use the adress bar of your web browser to directly access, [edit](#edit) or [delete](#delete) a page. + +You can type anything in your adress bar, if it's an already exisiting page_id, you will access a page, otherwise, you will arrive to an empty space waiting to be filled. + +Once you've typed an adress and found nothing, if you are connected, you now have the opportunity to create a page at this adress. + +There is two ways to do this : + +1. Graphicaly, by clicking the "create" button +2. Using the adress bar, by typing `/add` just after the adress + +There it is ! Congratulation, you've created your first page using W. + + +#### Edit your page content + +Now you should be in front of the [edit interface](#editor) of your page. If you check the adress bar, you will now see `/edit` written after your page adress. + +You can type a few words in the main text area. Once you're happy with what you wrote, it's time to save your work : click on the <kbd>update</kbd> button in the top left corner. You can use the shortcut <kbd>CTRL</kbd> + <kbd>S</kbd> too if you prefer. After you've done this, you sould have notice that the asterix `*` next to your page_id have left, it's the sign that saving was sucesfull. + +Let's come back to the page reading view to see the result of our editing. There are different approaches for doing so : + +1. By removing the `/edit` command after your page adress +2. Pressing the "display" button (next to "update"), or using <kbd>CTRL</kbd> + <kbd>D</kbd> shortcut. + +The first method will use the same tab while the second will create a new one, wich is usefull if you want to keep your [edit interface](#editor) open to come back quickly. + +You should now see something that look like what you've typed. + + +#### Create a hyperlink + + +The [markdown synthax](), this is a formating standard well known accross the web. It's main goal is to be a intermediate between an easy to read prose text, and the internet standard tag language, the HTML. One of the main interest of Markdown, is it's ability to be mixed with HTML. That way, people can type more easily basic text, and switch to HTML at any time, to achieve a more complex layout. You can use the official Markdonw synthax with __W__ alongside with HTML to build your pages. + +[Official website describing Markdown synthax](https://daringfireball.net/projects/markdown/syntax) + +One of the most interesting things to do when you use internet publishing, is to create HYPERLINKS. __W__ encourage you creating those links between pages using a very light synthax. There are multiple ways to do it. + +1. Using classic HTML : `<a href="<page_id>">click here</a>` +2. Using Markdown : `[click here](<page_id>)` +3. Using W quick synthax : `[<page_id>]` + +All those methods will create a link pointing to the `<page_id>` you've given. + +Those kind of links are called internal links beccause they stay inside of your domain. To set a link outside of your website, simply remplace `<page_id>` by + + +### Navigation + +Discover the differents interfaces of __W__. + +#### Home + +The Home interface is the main view of your project. You can access it only when you're connected. All the pages of your database are listed here. + +The [readers](#reader) and [invite editors](#invite-editor) can't access this interface. + +##### Home menu + +In the home menu [super editors and above](#super-editor) can : + +- File : import pages as JSON file. (usefull for transfering pages from a W instance to another) +- Edit : + +The Home view is divided in two main parts : + +##### Options + + where you can apply filters and sorting + +##### Pages + +the list of pages after filtering + +#### Edition + +The edition interface is accessible when typing `/edit` after an existing [page_id](#page-id) in the adress bar. Or from the [home](#home), by clicking on the pencil button. + +[Invite editors](#invite-editor) and [editors](#editor) users can only access edition of pages where they are listed as [author](#authors). + +The Edition view is composed of a main content edition area, surounded by two lateral panels that you can deploy or hide. + +##### left panel + +This is the + +- Meta infos : edit [title](#title), [description](#description) and more infos about your page. +- Templating +- Advanced +- Help : a quick synthax reference for markdown and W synthax + +##### contents area + +Each tab allow you to edit a different type of content : + +[main](#main), [nav](#nav), [aside](#aside) + +Note that the MAIN tab is the default opened tab, this is meant to be the most spontaneous place to store information when you are using __W__ in *note taking style*. + +##### right panel + +#### Media manager + +When you need to use images, sound or videos in your pages, or any other type of files, you can use the media manager to host them before including them in your pages. + +[Invite editors](#invite-editor) don't have access to this place. + +##### Media menu + +The media menu allow you to do more powerfull function like moving medias or delete folders. + +#### Admin + +#### User manager + + + + + + + + + +Page Editing +------------ + +### Synthax + +#### Markdown + +- [Daring Fireballs](https://daringfireball.net/projects/markdown/syntax) Official reference of Markdown Synthax +- [Michel Fortin's Markdown extra](https://michelf.ca/projects/php-markdown/extra/) The library used in W. + + +#### W specific synthax + +##### Auto url + +When you use an adress starting with `http://` or `https://`, W will automaitcaly create a link pointing to a new tab. + + <a href="<url>" target="_blank" class="external"><url></a> + +Note that the `.external` class have been added. + +##### Quick links + + [<page_id>] + +Will generate : + + <a href="<page_id>" title="PAGE_DESCRIPTION" class="internal">PAGE_TITLE</a> + +Where [PAGE_DESCRIPTION](#description) and [PAGE_TITLE](page-title) are the [page_id](#page-id)'s meta infos. + +Note that the `.internal` class have been added to the `a` html link, allowing you to differenciate internal link styling from `.external`. + +### Inclusions + +#### Basic inclusions + +##### Title inclusion + + %TITLE% + +This will include the page [title](#page-title). + +##### Description inclusion + + %DESCRIPTION% + +This will include the page [description](#description). + +##### Date inclusion + + %DATE% + + +#### Page list + +Sometimes, when you want to add links to a lot of pages, it can be way to long. This tool is here to help you generate list of links automatically. + +It use the same logic as the page filter. + +When you are in the [home view](#home), ajust the filters using the [options panel](#options) to achieve the page selection you desire. Then select "filters" in the [menu](#home-menu), choose options you prefer and hit "generate". You can now copy and paste the code obtainded that way in one of the [elements](#markdown-elements) of a page. + +Display options are : + +- title : display the [title](#page-title) of the page +- description : display the [description](#description) of the page. +- thumbnail : display the [thumnail](#thumbnail) of the page. +- date : display the [date](#date) of the page. +- time : display the [time](#time) of the page. + +Generate : + + + <ul class="pagelist"> + <li><a href="ID">TITLE</a> DESCRIPTION DATE TIME ... </li> + .... + </ul> + + + +#### Media list + +### Templating + +### Content insertion + +#### Advanced BODY synthax + + + + + + +References +--------- + + +### Page structure + + +Technicaly, each page is stored as a JSON object in yout fatabase folder. + +A page consist of meta informations and contents. + +#### Meta infos + +##### Page ID + +The unique identifier of a page. + +##### Page title + +The page title is also very important. It's like the official name of a page. + +##### Description + +##### Tag + +Tags are very powerfull to help you organize your pages. As in __W__, there is no hierarchy between pages, this is the only tool to create groups of pages. + +Tags can be set in the [left panel of the editor interface](#left-panel) using comma to separate tags. + +##### Date & time + +##### Thumbnail + +The thumbnail have two use cases : + +- When you share a link to a page on a social network +- When you generate a [list of page](#page-list) and activated the `thumbail` option. + +##### Authors + +List of [users](#user-levels) that have edited the page, or that can do it. You have to be at least [super-editor](#super-editor) to add or remove authors. + +#### Content + +##### markdown elements + +Main, Nav, Aside, Header, Footer + +##### CSS + +##### BODY + +##### Javascript + + + + + +### User levels + +#### Visitor + +> level : 0 + +#### Reader + +> level : 1 + +#### Invite Editor + +> level : 2 + +Invite Editors are the lowest editor status possible. They can only access the [Edition interface](#edition). They can't create page but only edit page when listed as [author](#authors). + +#### Editor + +> level : 3 + +- Can create pages and edit them. +- Can only edit pages when listed as [author](#authors) + +#### Super Editor + +> level : 4 + +- Can edit any pages they like (they will be added as [author](#authors) of the page). +- Can use the home menu and media menu to access powerfull features. + +#### Administrator + +> level : 10 + +- Can access the [admin interface](#admin). +- Can create new users. + +### URL based command interface + +#### Pages commands + +Type thoses commands after a __page_id__ + +`<page_id>/COMMAND` + +##### /add + +Command used to add a page in the database. + +##### /edit + +Command used to edit a page. If you're not logged in, it will ask for your credentials. + +##### /delete + +Command used to delete a page from the database. This will ask you for a confirmation. + +##### /render + +Force the rendering of a page. + +##### /log + +Show a `var_dump` of the page object. This could be usefull for debbuging. + + + @@ -1,17 +1,40 @@ # W-CMS +W is a lightweight CMS tool, meant to help you design a website using a unique approach. It's targeting artists, or experimental projects. + +To have a better idea of what W can do, you can check out the [User manual](MANUAL.md), or dicover the [ideas](#ideas) behind this specific tool. + +If tou want to try it out, you can : + +- follow the [install instructions](#how-to-install) to host your own instance of W. +- be hosted for free by [club1.fr](https://club1.fr) as an official tester (please contact [v.peugnet@free.fr](mailto:v.peugnet@free.fr) for more info). +- [install from sources](#install-from-sources), if you want to contribute to the code. + +W is a free and open source tool under the MIT License. The project was initiated in 2018 by Vincent Peugnet. + +Ideas +----- + **W** was first a tool, based on my way of thinking, as a protesis, to write on ideas and create a self explorating text point n' click game. -It's a mix between a drive, wikipedia and a personnal blog. You can create articles very quickly and share them with other people or keep them for you and restricted people. -There is no boundaries beetween taking notes and creating a website. When you create a article, you create a space in internet, a place, that can be public or private. Then, you decide to link it or not with the others places you've created before. +It's a mix between a drive, wikipedia and a personnal blog. You can create page very quickly and share them with other people or keep them for you and restricted people. +There is no boundaries beetween taking notes and creating a website. When you create a page, you create a space in internet, a place, that can be public or private. Then, you decide to link it or not with the others places you've created before. There is a lots of possibilites of creations, for people who need to create multi-aspect labyrinth websites, to use a half public/private mindmap, or even interactives fictions. -## Highlights +Highlights +---------- -- The user can never see the whole map of the website : yo can create specific auto-menu for each page if you want. -- Each page, of group of pages can be like a single website, with it's own style. (You can create your mini internet on internet) -- The pages load very quickly as they can be rendered -- Editor interface, the only place where where you can see the master-plan. +W try to help you create pages more spontaneously. + +- low latency page loading +- Use markdown synthax, HTML, CSS and Javascript +- [url based command interface](MANUAL.md#url-based-command-interface) +- [Media manager](MANUAL.md#media-manager) +- Font manager +- Multi-users +- No hierarchy between pages +- Configured without landing-page (by default) +- optional javascript ergonomic enhancement (no-script proof) Overview @@ -38,13 +61,31 @@ There is lot more you can by altering the `BODY`. [Old webpage of the project (in french)](http://vincent.club1.fr/w/?id=w) -# Technology +How to install +-------------- + +### Server requirements + +- apache server +- PHP >=7.2.0 + +__W__ don't need any database manager as it use a "flat file" system. -- almost pure PHP. -- Use MarkDown to edit pages quickly. -- Easy to manage Json 'flat file' database. -using [James Moss's Flywheel Database](https://github.com/jamesmoss/flywheel), [Michel Fortin's Markdown Extra](https://github.com/michelf/php-markdown) and [Plates](https://github.com/thephpleague/plates) as lightweight template engine. +### Installation guide + +Simply download the [latest realease](https://github.com/vincent-peugnet/wcms/releases/latest) from github, and unzip it in your hosted folder. You can put W at the root of your domain, or in subfolders. Then access the adress in your browser and follow the differents steps. + +W will ask you for the path you've installed it, if you installed it at the root, leave this field blank, otherwise, indiquate the subfolders like `path/to/wcms`. + + + +### Thanks to + +- [James Moss's Flywheel Database](https://github.com/jamesmoss/flywheel) +- [Michel Fortin's Markdown Extra](https://github.com/michelf/php-markdown) +- [Plates](https://github.com/thephpleague/plates) as template engine. +- [Nicolas Peugnet](https://nicolas.club1.fr/) for the technical support # Development informations @@ -112,10 +153,3 @@ Then, to make the release, run the following command: make release To only build the release zip, simply run `make dist`. This will create a zip file in `dist/` of the current version. - - -To Do -===== - - -- Locking page system by super editor to prevent editing by the wrong person 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/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> diff --git a/assets/css/home.css b/assets/css/home.css index 0e5e4a1..4477de9 100644 --- a/assets/css/home.css +++ b/assets/css/home.css @@ -18,14 +18,14 @@ div#options, article#main { -main.home { +main { display: flex; height: 100%; /* width: 100%; */ } -aside.home { +aside { display: flex; background-color: darkgrey; border-top: 1px solid grey; @@ -34,20 +34,20 @@ aside.home { -aside.home details, aside.home span { +aside details, aside span { width: 100%; max-width: 280px; } -aside.home details .submenu, aside.home summary { +aside details .submenu, aside summary { background-color: darkgrey; border-left: 1px solid grey; } -aside.home .submenu { +aside .submenu { position: absolute; border: solid 1px dimgrey; width: 20%; @@ -55,6 +55,21 @@ aside.home .submenu { } +aside summary { + color: grey; +} + +aside details > summary::-webkit-details-marker { + display: none; +} + + +aside summary:hover { + color: black; + cursor: pointer; +} + + aside.home details#bookmarks input[type="checkbox"] { opacity: 0.2; float: right; @@ -71,27 +86,13 @@ aside.home details#bookmarks ul { -aside.home summary { - color: grey; -} - -aside.home details > summary::-webkit-details-marker { - display: none; -} - - -aside.home summary:hover { - color: black; - cursor: pointer; -} - -details#selection code { +aside .submenu code { overflow: auto; display: block; white-space: nowrap; color: #7b97b9; - background-color: #252525; + background-color: #233143; padding: 1%; font-size: 12px; } @@ -142,13 +143,6 @@ h1, h2 { -main.media div, main.home div#options, main.info nav, main article { - border: solid 1px dimgrey; - margin: 1%; - background-color: lightgrey; -} - - p { padding: 0 1%; } @@ -237,10 +231,6 @@ main.font table#fontlist { max-width: 500px; } -main.media table#medialist { - width: 100%; - max-width: 960px; -} #topbar a.actualpage { text-decoration: underline; @@ -256,14 +246,12 @@ a:hover img.icon { filter: invert(1); } - - - -main.media table#faviconlist { - width: 100%; - max-width: 640px; +section.info { + max-width: 600px; + list-style: inside disc; } + main.info ul i { color: grey; } @@ -272,14 +260,13 @@ main.info a { text-decoration: underline white; } -main.info ul { - list-style: none; +nav.info ul { padding-inline-start: 10px; } -main.info code, main.info blockquote { +main.info code { color: white; - background-color: #191919; + background-color: #233143; width: fit-content; font-family: monospace; font-size: initial; @@ -290,49 +277,65 @@ main.info blockquote i { color: #7b97b9; } +main.info article#manual h1 { + text-align: center; + font-size: 50px; + color: black; + background-color: transparent; + font-weight: lighter; + margin: 6%; + border-top: solid; + border-bottom: solid; +} + -main.info article h2#manual { +main.info article#manual h2 { text-align: center; font-size: 40px; + margin-top: 60px; } main.info article#manual h3 { border-bottom: solid 1px grey; - margin-top: 100px; + margin-top: 30px; padding-top: 15px; font-size: 35px; } main.info article h4 { background-color: darkgrey; - padding: 10px; font-size: x-large; - margin-top: 70px; + margin-top: 35px; + margin-bottom: 25px; } -main.info article h5 { +main.info article#manual h5 { text-transform: uppercase; - margin-top: 45px; - font-size: large; + margin-top: 20px; + margin-bottom: 0; + font-size: medium; +} + + +section.info ul { + list-style: inside disc; + padding-inline-start: 10px; } main.info code { padding: 0 4px; } + + +main.info pre {width: fit-content;padding: 1%;background-color: hsla(213, 31%, 20%, 1);white-space: pre-wrap;margin: 1%;} + main.info blockquote { padding: 6px 12px; text-align: left; word-break: break-all; } -main.info nav { - position: fixed; - left: 850px; - top: 0px; - margin-top: 50px; -} - main.info article code i { font-style: normal; color: #7b97b9; @@ -354,13 +357,7 @@ main.media table#medialist .thumbnail:hover img { } -main.media form { - margin: 0.5%; -} -main.media div#tree, main.media div#explorer { - display: inline-grid; -} main.media code { color: #9cbfe8; @@ -369,10 +366,17 @@ main.media code { padding: 1px; } +nav.media span#currentdir { + color: hsla(213, 70%, 40%, 1); +} + td.code { background-color: darkslategrey; + max-width: 250px; + white-space: nowrap; + overflow: hidden; } @@ -464,13 +468,13 @@ main.timeline li.event { -section.pages { +main section { display: flex; flex-direction: column; max-width: calc(100% - 160px); } -.home nav { +main nav { display: flex; flex-direction: column; height: 100%; @@ -509,7 +513,6 @@ footer { main.info nav { position: relative; left: 0; - margin-top: 1%; } main.home nav { @@ -525,8 +528,3 @@ footer { } } - - - - - diff --git a/app/view/templates/man.php b/old_manual.html index deb81ee..215326c 100644 --- a/app/view/templates/man.php +++ b/old_manual.html @@ -1,26 +1,5 @@ -<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"> |