aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-04-17 20:58:27 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-04-17 20:58:27 +0200
commit1c4182d9d88bb4471f86b08329f1b68a5290872b (patch)
treee7ccae68902113ece94ab4c8e86fd712dc028d2a /app
parentdc5613c15b1b414fefadd66912ebf8ff3a5eef9d (diff)
downloadwcms-1c4182d9d88bb4471f86b08329f1b68a5290872b.tar.gz
wcms-1c4182d9d88bb4471f86b08329f1b68a5290872b.zip
apply psr 12 part 2
Diffstat (limited to 'app')
-rw-r--r--app/class/Controllerconnect.php16
-rw-r--r--app/class/Controllerhome.php76
-rw-r--r--app/class/Controllerinfo.php15
-rw-r--r--app/class/Controllermedia.php33
-rw-r--r--app/class/Controllerpage.php88
-rw-r--r--app/class/Controllertimeline.php21
-rw-r--r--app/class/Controlleruser.php46
-rw-r--r--app/class/Dbitem.php5
-rw-r--r--app/class/Element.php8
-rw-r--r--app/class/Event.php11
-rw-r--r--app/class/Flywheel/Formatter/JSON.php3
-rw-r--r--app/class/Flywheel/Predicate.php4
-rw-r--r--app/class/Flywheel/Query.php1
-rw-r--r--app/class/Flywheel/Repository.php3
-rw-r--r--app/class/Header.php23
-rw-r--r--app/class/Item.php111
-rw-r--r--app/class/Media.php552
-rw-r--r--app/class/Medialist.php42
-rw-r--r--app/class/Modelrender.php2
19 files changed, 520 insertions, 540 deletions
diff --git a/app/class/Controllerconnect.php b/app/class/Controllerconnect.php
index 8555e92..24b0c3c 100644
--- a/app/class/Controllerconnect.php
+++ b/app/class/Controllerconnect.php
@@ -39,7 +39,11 @@ class Controllerconnect extends Controller
if (!empty($_POST['pass']) && !empty($_POST['user'])) {
$this->user = $this->usermanager->passwordcheck($_POST['user'], $_POST['pass']);
if ($this->user != false) {
- if ($this->user->expiredate() === false || $this->user->level() === 10 || $this->user->expiredate('date') > $this->now) {
+ if (
+ $this->user->expiredate() === false
+ || $this->user->level() === 10
+ || $this->user->expiredate('date') > $this->now
+ ) {
$this->user->connectcounter();
$this->usermanager->add($this->user);
$this->usermanager->writesession($this->user);
@@ -52,7 +56,6 @@ class Controllerconnect extends Controller
$_SESSION['user' . Config::basepath()]['authtoken'] = $token;
}
}
-
}
}
}
@@ -67,7 +70,7 @@ class Controllerconnect extends Controller
{
$this->user = $this->usermanager->logout();
$this->usermanager->writesession($this->user);
- if(!empty($_SESSION['user' . Config::basepath()]['authtoken'])) {
+ if (!empty($_SESSION['user' . Config::basepath()]['authtoken'])) {
$this->destroyauthtoken($_SESSION['user' . Config::basepath()]['authtoken']);
}
if ($id !== null && $route !== 'home') {
@@ -79,7 +82,7 @@ class Controllerconnect extends Controller
/**
* Create a token stored in the database and then a cookie
- *
+ *
* @return string|bool Token in cas of success, otherwise, false.
*/
public function createauthtoken()
@@ -99,10 +102,10 @@ class Controllerconnect extends Controller
/**
* Create a cookie called `authtoken`
- *
+ *
* @param string $token Token string
* @param int $conservation Time in day to keep the token
- *
+ *
* @return bool True in cas of success, otherwise, false.
*/
public function creatauthcookie(string $token, int $conservation): bool
@@ -122,5 +125,4 @@ class Controllerconnect extends Controller
//deleteauthcookie
}
-
}
diff --git a/app/class/Controllerhome.php b/app/class/Controllerhome.php
index d024a19..d1c7a11 100644
--- a/app/class/Controllerhome.php
+++ b/app/class/Controllerhome.php
@@ -14,7 +14,7 @@ class Controllerhome extends Controllerpage
public function __construct($render)
{
parent::__construct($render);
- $this->modelhome = new Modelhome;
+ $this->modelhome = new Modelhome();
}
@@ -25,8 +25,6 @@ class Controllerhome extends Controllerpage
if ($this->user->isvisitor() && Config::homepage() === 'redirect' && !empty(Config::homeredirect())) {
$this->routedirect('pageread/', ['page' => Config::homeredirect()]);
} else {
-
-
$pagelist = $this->modelhome->pagelist();
$this->opt = $this->modelhome->optinit($pagelist);
@@ -34,7 +32,12 @@ class Controllerhome extends Controllerpage
$deepsearch = $this->deepsearch();
- $vars['pagelistopt'] = $this->modelhome->pagetable($pagelist, $this->opt, $deepsearch['regex'], $deepsearch['searchopt']);
+ $vars['pagelistopt'] = $this->modelhome->pagetable(
+ $pagelist,
+ $this->opt,
+ $deepsearch['regex'],
+ $deepsearch['searchopt']
+ );
$vars['columns'] = $this->modelhome->setcolumns($this->user->columns());
@@ -48,15 +51,24 @@ class Controllerhome extends Controllerpage
$vars['searchopt'] = $deepsearch['searchopt'];
$vars['display'] = $_GET['display'] ?? 'list';
- if($vars['display'] === 'map') {
+ if ($vars['display'] === 'map') {
$vars['layout'] = $_GET['layout'] ?? 'cose-bilkent';
- $vars['showorphans'] = boolval($_GET['showorphans'] ?? false);
+ $vars['showorphans'] = boolval($_GET['showorphans'] ?? false);
$vars['showredirection'] = boolval($_GET['showredirection'] ?? false);
- $datas = $this->modelhome->cytodata($vars['pagelistopt'], $vars['layout'], $vars['showorphans'], $vars['showredirection']);
+ $datas = $this->modelhome->cytodata(
+ $vars['pagelistopt'],
+ $vars['layout'],
+ $vars['showorphans'],
+ $vars['showredirection']
+ );
$vars['json'] = json_encode($datas, JSON_PRETTY_PRINT);
}
- $vars['footer'] = ['version' => getversion(), 'total' => count($pagelist), 'database' => Config::pagetable()];
+ $vars['footer'] = [
+ 'version' => getversion(),
+ 'total' => count($pagelist),
+ 'database' => Config::pagetable()
+ ];
$this->listquery($pagelist);
@@ -68,13 +80,20 @@ class Controllerhome extends Controllerpage
/**
* Look for GET deepsearch datas and transform it an array
- *
+ *
* @return array containing `string $regex` and `array $searchopt`
*/
- public function deepsearch() : array
+ public function deepsearch(): array
{
if (!isset($_GET['search'])) {
- $searchopt = ['id' => 1, 'title' => 1, 'description' => 1, 'content' => 1, 'other' => 0, 'casesensitive' => 0];
+ $searchopt = [
+ 'id' => 1,
+ 'title' => 1,
+ 'description' => 1,
+ 'content' => 1,
+ 'other' => 0,
+ 'casesensitive' => 0
+ ];
} else {
$searchopt['id'] = $_GET['id'] ?? 0;
$searchopt['title'] = $_GET['title'] ?? 0;
@@ -117,7 +136,6 @@ class Controllerhome extends Controllerpage
$colors->writecssfile();
}
$this->routedirect('home');
-
}
public function search()
@@ -140,7 +158,7 @@ class Controllerhome extends Controllerpage
}
/**
- * Render every pages in the database
+ * Render every pages in the database
*/
public function renderall()
{
@@ -150,7 +168,7 @@ class Controllerhome extends Controllerpage
foreach ($pagelist as $page) {
$page = $this->renderpage($page);
if ($this->pagemanager->update($page)) {
- $count ++;
+ $count++;
}
}
$total = count($pagelist);
@@ -173,7 +191,7 @@ class Controllerhome extends Controllerpage
Config::savejson();
}
} elseif ($_POST['action'] == 'del') {
- if(isset($_POST['user']) && $_POST['user'] == $this->user->id()) {
+ if (isset($_POST['user']) && $_POST['user'] == $this->user->id()) {
$usermanager = new Modeluser();
$user = $usermanager->get($_POST['user']);
foreach ($_POST['id'] as $id) {
@@ -193,19 +211,19 @@ class Controllerhome extends Controllerpage
public function multi()
{
- if(isset($_POST['action']) && $this->user->issupereditor() && !empty($_POST['pagesid'])) {
+ if (isset($_POST['action']) && $this->user->issupereditor() && !empty($_POST['pagesid'])) {
switch ($_POST['action']) {
case 'edit':
$this->multiedit();
- break;
+ break;
case 'render':
$this->multirender();
- break;
+ break;
case 'delete':
$this->multidelete();
- break;
+ break;
}
} else {
$action = $_POST['action'] ?? 'edit';
@@ -217,12 +235,12 @@ class Controllerhome extends Controllerpage
public function multiedit()
{
$pagelist = $_POST['pagesid'] ?? [];
- $datas = $_POST['datas']?? [];
+ $datas = $_POST['datas'] ?? [];
$datas = array_filter($datas, function ($var) {
return $var !== "";
});
$datas = array_map(function ($value) {
- if($value === "!") {
+ if ($value === "!") {
return "";
} else {
return $value;
@@ -234,9 +252,9 @@ class Controllerhome extends Controllerpage
$count = 0;
$total = 0;
foreach ($pagelist as $id) {
- $total ++;
- if($this->pagemanager->pageedit($id, $datas, $reset, $addtag, $addauthor)) {
- $count ++;
+ $total++;
+ if ($this->pagemanager->pageedit($id, $datas, $reset, $addtag, $addauthor)) {
+ $count++;
}
}
$this->sendstatflashmessage($count, $total, 'pages have been edited');
@@ -250,8 +268,8 @@ class Controllerhome extends Controllerpage
$count = 0;
foreach ($pagelist as $page) {
$page = $this->renderpage($page);
- if($this->pagemanager->update($page)) {
- $count ++;
+ if ($this->pagemanager->update($page)) {
+ $count++;
}
}
$this->sendstatflashmessage($count, $total, 'pages have been rendered');
@@ -259,13 +277,13 @@ class Controllerhome extends Controllerpage
public function multidelete()
{
- if(isset($_POST['confirmdelete']) && $_POST['confirmdelete']) {
+ if (isset($_POST['confirmdelete']) && $_POST['confirmdelete']) {
$pagelist = $_POST['pagesid'] ?? [];
$total = count($pagelist);
$count = 0;
foreach ($pagelist as $id) {
if ($this->pagemanager->delete($id)) {
- $count ++;
+ $count++;
}
}
$this->sendstatflashmessage($count, $total, 'pages have been deleted');
@@ -274,5 +292,3 @@ class Controllerhome extends Controllerpage
}
}
}
-
-?>
diff --git a/app/class/Controllerinfo.php b/app/class/Controllerinfo.php
index ab2a526..0e639e8 100644
--- a/app/class/Controllerinfo.php
+++ b/app/class/Controllerinfo.php
@@ -1,20 +1,20 @@
<?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()) {
-
- if(file_exists(Model::MAN_FILE)) {
-
+ if ($this->user->iseditor()) {
+ if (file_exists(Model::MAN_FILE)) {
$render = new Modelrender($this->router);
$htmlman = file_get_contents(Model::MAN_FILE);
$htmlman = $render->rendermanual($htmlman);
@@ -23,12 +23,7 @@ class Controllerinfo extends Controller
$summary = $sum->sumparser();
$this->showtemplate('info', ['version' => getversion(), 'manual' => $htmlman, 'summary' => $summary]);
-
}
}
}
-
}
-
-
-?> \ No newline at end of file
diff --git a/app/class/Controllermedia.php b/app/class/Controllermedia.php
index 1b7bdaa..609ea2f 100644
--- a/app/class/Controllermedia.php
+++ b/app/class/Controllermedia.php
@@ -15,14 +15,12 @@ class Controllermedia extends Controller
{
parent::__construct($render);
- $this->mediamanager = new Modelmedia;
-
+ $this->mediamanager = new Modelmedia();
}
public function desktop()
{
if ($this->user->iseditor()) {
-
if (!$this->mediamanager->dircheck(Model::MEDIA_DIR)) {
throw new Exception("Media error : Cant create /media folder");
}
@@ -34,11 +32,11 @@ class Controllermedia extends Controller
}
$mediaopt = new Medialist($_GET);
- if(empty($mediaopt->path())) {
+ if (empty($mediaopt->path())) {
$mediaopt->setpath(DIRECTORY_SEPARATOR . Model::MEDIA_DIR);
}
- if(is_dir($mediaopt->dir())) {
+ if (is_dir($mediaopt->dir())) {
$medialist = $this->mediamanager->medialistopt($mediaopt);
$dirlist = $this->mediamanager->listdir(Model::MEDIA_DIR);
@@ -47,11 +45,18 @@ class Controllermedia extends Controller
$this->mediamanager->listpath($dirlist, '', $pathlist);
- $this->showtemplate('media', ['medialist' => $medialist, 'dirlist' => $dirlist, 'pathlist' =>$pathlist, 'mediaopt' => $mediaopt]);
+ $this->showtemplate(
+ 'media',
+ [
+ 'medialist' => $medialist,
+ 'dirlist' => $dirlist,
+ 'pathlist' => $pathlist,
+ 'mediaopt' => $mediaopt
+ ]
+ );
} else {
$this->routedirect('media');
}
-
} else {
$this->routedirect('home');
}
@@ -78,13 +83,12 @@ class Controllermedia extends Controller
$this->mediamanager->adddir($dir, $name);
}
$this->redirect($this->router->generate('media') . '?path=/' . $dir . DIRECTORY_SEPARATOR . $name);
-
}
public function folderdelete()
{
- if(isset($_POST['dir'])) {
- if(isset($_POST['deletefolder']) && intval($_POST['deletefolder']) && $this->user->issupereditor()) {
+ if (isset($_POST['dir'])) {
+ 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']);
@@ -96,8 +100,8 @@ class Controllermedia extends Controller
public function edit()
{
- if($this->user->issupereditor() && isset($_POST['action']) && isset($_POST['id'])) {
- if($_POST['action'] == 'delete') {
+ if ($this->user->issupereditor() && isset($_POST['action']) && isset($_POST['id'])) {
+ if ($_POST['action'] == 'delete') {
$this->mediamanager->multifiledelete($_POST['id']);
} elseif ($_POST['action'] == 'move' && isset($_POST['dir'])) {
$this->mediamanager->multimovefile($_POST['id'], $_POST['dir']);
@@ -105,9 +109,4 @@ class Controllermedia extends Controller
}
$this->redirect($this->router->generate('media') . '?path=/' . $_POST['path']);
}
-
-
}
-
-
-?> \ No newline at end of file
diff --git a/app/class/Controllerpage.php b/app/class/Controllerpage.php
index 447f2c5..9d20ded 100644
--- a/app/class/Controllerpage.php
+++ b/app/class/Controllerpage.php
@@ -21,7 +21,6 @@ class Controllerpage extends Controller
$this->fontmanager = new Modelfont();
$this->mediamanager = new Modelmedia();
-
}
public function setpage(string $id, string $route)
@@ -48,18 +47,17 @@ class Controllerpage extends Controller
} else {
return false;
}
-
}
/**
* show credentials for unconnected editors for a specific page
- *
+ *
* @param string $route direction to redirect after the connection form
* @return void
*/
public function pageconnect(string $route)
{
- if($this->user->isvisitor()) {
+ if ($this->user->isvisitor()) {
$this->showtemplate('connect', ['route' => $route, 'id' => $this->page->id()]);
exit;
}
@@ -81,7 +79,7 @@ class Controllerpage extends Controller
}
}
- function render($id)
+ public function render($id)
{
$this->setpage($id, 'pageupdate');
@@ -94,12 +92,12 @@ class Controllerpage extends Controller
/**
* Render given page
- *
+ *
* @param Page $page input
- *
+ *
* @return Page rendered $page
*/
- public function renderpage(Page $page) : Page
+ public function renderpage(Page $page): Page
{
$now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
@@ -110,15 +108,14 @@ class Controllerpage extends Controller
$page->setlinkto($renderengine->linkto());
return $page;
-
}
public function reccursiverender(Page $page)
{
$relatedpages = array_diff($page->linkto(), [$page->id()]);
- foreach ($relatedpages as $pageid ) {
+ foreach ($relatedpages as $pageid) {
$page = $this->pagemanager->get($pageid);
- if($page !== false) {
+ if ($page !== false) {
$page = $this->renderpage($page);
$this->pagemanager->update($page);
}
@@ -136,7 +133,7 @@ class Controllerpage extends Controller
$canread = $this->user->level() >= $this->page->secure();
if ($this->page->daterender() < $this->page->datemodif()) {
- if(Config::reccursiverender()) {
+ if (Config::reccursiverender()) {
$this->reccursiverender($this->page);
}
$this->page = $this->renderpage($this->page);
@@ -150,9 +147,9 @@ class Controllerpage extends Controller
$this->pagemanager->update($this->page);
}
- if($pageexist && $canread) {
+ if ($pageexist && $canread) {
$filedir = Model::HTML_RENDER_DIR . $id . '.html';
- if(file_exists($filedir)) {
+ if (file_exists($filedir)) {
$html = file_get_contents($filedir);
sleep($this->page->sleep());
echo $html;
@@ -160,7 +157,10 @@ class Controllerpage extends Controller
echo 'Please render this page';
}
} else {
- $this->showtemplate('alert', ['page' => $this->page, 'pageexist' => $pageexist, 'canedit' => $this->canedit()]);
+ $this->showtemplate(
+ 'alert',
+ ['page' => $this->page, 'pageexist' => $pageexist, 'canedit' => $this->canedit()]
+ );
}
}
@@ -172,7 +172,16 @@ class Controllerpage extends Controller
if ($this->importpage() && $this->canedit()) {
- $datas['tablist'] = ['main' => $this->page->main(), 'css' => $this->page->css(), 'header' => $this->page->header(), 'nav' => $this->page->nav(), 'aside' => $this->page->aside(), 'footer' => $this->page->footer(), 'body' => $this->page->body(), 'javascript' => $this->page->javascript()];
+ $datas['tablist'] = [
+ 'main' => $this->page->main(),
+ 'css' => $this->page->css(),
+ 'header' => $this->page->header(),
+ 'nav' => $this->page->nav(),
+ 'aside' => $this->page->aside(),
+ 'footer' => $this->page->footer(),
+ 'body' => $this->page->body(),
+ 'javascript' => $this->page->javascript()
+ ];
$datas['faviconlist'] = $this->mediamanager->listfavicon();
$datas['thumbnaillist'] = $this->mediamanager->listthumbnail();
@@ -197,12 +206,11 @@ class Controllerpage extends Controller
} else {
$this->routedirect('pageread/', ['page' => $this->page->id()]);
}
-
}
public function log($id)
{
- if($this->user->issupereditor()) {
+ if ($this->user->issupereditor()) {
$this->setpage($id, 'pagelog');
$this->importpage();
var_dump($this->page);
@@ -230,7 +238,7 @@ class Controllerpage extends Controller
public function addascopy(string $id, string $copy)
{
$id = idclean($id);
- if($this->copy($copy, $id)) {
+ if ($this->copy($copy, $id)) {
$this->routedirect('pageedit', ['page' => $this->page->id()]);
} else {
$this->routedirect('pageread/', ['page' => $id]);
@@ -241,9 +249,7 @@ class Controllerpage extends Controller
{
$this->setpage($id, 'pageconfirmdelete');
if ($this->importpage() && ($this->user->issupereditor() || $this->page->authors() === [$this->user->id()] )) {
-
$this->showtemplate('confirmdelete', ['page' => $this->page, 'pageexist' => true]);
-
} else {
$this->routedirect('pageread/', ['page' => $this->page->id()]);
}
@@ -251,14 +257,13 @@ class Controllerpage extends Controller
public function download($id)
{
- if($this->user->isadmin()) {
-
+ if ($this->user->isadmin()) {
$file = Model::PAGES_DIR . Config::pagetable() . DIRECTORY_SEPARATOR . $id . '.json';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/json; charset=utf-8');
- header('Content-Disposition: attachment; filename="'.basename($file).'"');
+ header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
@@ -278,24 +283,23 @@ class Controllerpage extends Controller
{
$page = $this->pagemanager->getfromfile();
- if($page !== false) {
-
- if(!empty($_POST['id'])) {
+ if ($page !== false) {
+ if (!empty($_POST['id'])) {
$page->setid(idclean($_POST['id']));
}
- if($_POST['datecreation']) {
+ if ($_POST['datecreation']) {
$page->setdatecreation($this->now);
}
- if($_POST['author']) {
+ if ($_POST['author']) {
$page->setauthors([$this->user->id()]);
}
$page->setdaterender($page->datecreation('date'));
- if($_POST['erase'] || $this->pagemanager->get($page) === false) {
- if($this->pagemanager->add($page)) {
+ if ($_POST['erase'] || $this->pagemanager->get($page) === false) {
+ if ($this->pagemanager->add($page)) {
Model::sendflashmessage('Page successfully uploaded', 'success');
}
} else {
@@ -311,7 +315,6 @@ class Controllerpage extends Controller
{
$this->setpage($id, 'pagedelete');
if ($this->user->iseditor() && $this->importpage()) {
-
$this->pagemanager->delete($this->page);
}
$this->routedirect('home');
@@ -324,13 +327,12 @@ class Controllerpage extends Controller
$this->routedirect('pageread/', ['page' => $targetid]);
} else {
$this->routedirect('pageread/', ['page' => idclean($srcid)]);
-
}
}
/**
* Copy a page to a new ID
- *
+ *
* @param string $srcid Source page ID
* @param string $targetid Target page ID
*/
@@ -338,7 +340,7 @@ class Controllerpage extends Controller
{
if ($this->user->iseditor()) {
$this->page = $this->pagemanager->get($srcid);
- if($this->page !== false && $this->canedit() && $this->pagemanager->get($targetid) === false) {
+ if ($this->page !== false && $this->canedit() && $this->pagemanager->get($targetid) === false) {
$this->page->setid($targetid);
$this->page->setdatecreation(true); // Reset date of creation
$this->page->addauthor($this->user->id());
@@ -360,13 +362,11 @@ class Controllerpage extends Controller
if ($this->importpage()) {
if ($this->canedit()) {
-
// Check if someone esle edited the page during the editing.
$oldpage = clone $this->page;
$this->page->hydrate($_POST);
if (self::COMBINE && $_POST['thisdatemodif'] === $oldpage->datemodif('string')) {
-
}
$this->page->updateedited();
@@ -383,20 +383,19 @@ class Controllerpage extends Controller
$_SESSION['pageupdate']['id'] = $this->page->id();
$this->routedirect('connect');
}
-
}
$this->routedirect('pageedit', ['page' => $this->page->id()]);
}
/**
* This function set the actual editor of the page
- *
+ *
* @param string $pageid as the page id
*/
public function editby(string $pageid)
{
$this->page = new Page(['id' => $pageid]);
- if($this->importpage($pageid)) {
+ if ($this->importpage($pageid)) {
$this->page->addeditby($this->user->id());
$this->pagemanager->update($this->page);
echo json_encode(['success' => true]);
@@ -407,13 +406,13 @@ class Controllerpage extends Controller
/**
* This function remove the actual editor of the page
- *
+ *
* @param string $pageid as the page id
*/
public function removeeditby(string $pageid)
{
$this->page = new Page(['id' => $pageid]);
- if($this->importpage($pageid)) {
+ if ($this->importpage($pageid)) {
$this->page->removeeditby($this->user->id());
$this->pagemanager->update($this->page);
echo json_encode(['success' => true]);
@@ -442,8 +441,3 @@ class Controllerpage extends Controller
$this->routedirect('pageread/', ['page' => idclean($id)]);
}
}
-
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/Controllertimeline.php b/app/class/Controllertimeline.php
index 8fc40d2..e856f40 100644
--- a/app/class/Controllertimeline.php
+++ b/app/class/Controllertimeline.php
@@ -9,9 +9,10 @@ class Controllertimeline extends Controller
*/
protected $eventmanager;
- public function __construct($render) {
+ public function __construct($render)
+ {
parent::__construct($render);
- $this->eventmanager = new Modeltimeline;
+ $this->eventmanager = new Modeltimeline();
}
public function desktop()
@@ -21,13 +22,11 @@ class Controllertimeline extends Controller
$groupedeventlist = $this->eventmanager->group($eventlist);
$this->showtemplate('timeline', ['eventlist' => $eventlist, 'groupedeventlist' => $groupedeventlist]);
-
}
public function add()
{
- if($this->user->level() >= Modeluser::EDITOR && !empty($_POST['message'])) {
-
+ if ($this->user->level() >= Modeluser::EDITOR && !empty($_POST['message'])) {
$event = new Event($_POST);
$event->stamp();
$event->setid($this->eventmanager->getlastfreeid());
@@ -38,21 +37,11 @@ class Controllertimeline extends Controller
public function clap()
{
- if(isset($_POST['id']) && isset($_POST['clap'])) {
+ if (isset($_POST['id']) && isset($_POST['clap'])) {
$event = $this->eventmanager->get(intval($_POST['id']));
$event->addclap();
$this->eventmanager->add($event);
}
$this->routedirect('timeline');
-
}
}
-
-
-
-
-
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/Controlleruser.php b/app/class/Controlleruser.php
index 1f53f76..d5bf934 100644
--- a/app/class/Controlleruser.php
+++ b/app/class/Controlleruser.php
@@ -5,18 +5,19 @@ namespace Wcms;
class Controlleruser extends Controller
{
- public function __construct($router) {
+ public function __construct($router)
+ {
parent::__construct($router);
}
public function desktop()
{
- if($this->user->iseditor()) {
+ if ($this->user->iseditor()) {
$authtokenmanager = new Modelauthtoken();
$datas['tokenlist'] = $authtokenmanager->listbyuser($this->user->id());
$datas['getuser'] = $this->usermanager->get($this->user);
- if($this->user->isadmin()) {
+ if ($this->user->isadmin()) {
$datas['userlist'] = $this->usermanager->getlister();
$this->showtemplate('user', $datas);
} else {
@@ -30,7 +31,7 @@ class Controlleruser extends Controller
public function pref()
{
- if($this->user->iseditor()) {
+ if ($this->user->iseditor()) {
$user = $this->usermanager->get($this->user);
if ($user->hydrate($_POST)) {
Model::sendflashmessage('User preferences have been successfully updated', 'success');
@@ -53,14 +54,14 @@ class Controlleruser extends Controller
public function add()
{
- if(isset($_POST['id'])) {
+ if (isset($_POST['id'])) {
$user = new User($_POST);
- if(empty($user->id()) || $this->usermanager->get($user)) {
+ if (empty($user->id()) || $this->usermanager->get($user)) {
$this->routedirectget('user', ['error' => 'wrong_id']);
- } elseif(empty($user->password()) || !$user->validpassword()) {
+ } elseif (empty($user->password()) || !$user->validpassword()) {
$this->routedirectget('user', ['error' => 'change_password']);
} else {
- if($user->passwordhashed()) {
+ if ($user->passwordhashed()) {
$user->hashpassword();
}
$this->usermanager->add($user);
@@ -72,7 +73,6 @@ class Controlleruser extends Controller
public function token()
{
if (isset($_POST['tokendelete'])) {
-
$authtokenmanager = new Modelauthtoken();
$authtokenmanager->delete($_POST['tokendelete']);
}
@@ -81,13 +81,13 @@ class Controlleruser extends Controller
public function update()
{
- if($this->user->isadmin() && isset($_POST['action'])) {
+ if ($this->user->isadmin() && isset($_POST['action'])) {
switch ($_POST['action']) {
case 'delete':
$user = new User($_POST);
$user = $this->usermanager->get($user);
- if($user !== false) {
- if($user->id() === $this->user->id()) {
+ if ($user !== false) {
+ if ($user->id() === $this->user->id()) {
$this->showtemplate('userconfirmdelete', ['userdelete' => $user, 'candelete' => false]);
} else {
$this->showtemplate('userconfirmdelete', ['userdelete' => $user, 'candelete' => true]);
@@ -107,19 +107,27 @@ class Controlleruser extends Controller
$user = $this->usermanager->get($_POST['id']);
$userupdate = clone $user;
$userupdate->hydrate($_POST);
- if(empty($userupdate->id())) {
+ if (empty($userupdate->id())) {
$this->routedirectget('user', ['error' => 'wrong_id']);
- } elseif (!empty($_POST['password']) && (empty($userupdate->password()) || !$userupdate->validpassword())) {
+ } elseif (
+ !empty($_POST['password'])
+ && (empty($userupdate->password())
+ || !$userupdate->validpassword())
+ ) {
$this->routedirectget('user', ['error' => 'password_unvalid']);
} elseif (empty($userupdate->level())) {
$this->routedirectget('user', ['error' => 'wrong_level']);
- } elseif ($user->level() === 10 && $userupdate->level() !== 10 && $this->user->id() === $user->id()) {
+ } elseif (
+ $user->level() === 10
+ && $userupdate->level() !== 10
+ && $this->user->id() === $user->id()
+ ) {
$this->routedirectget('user', ['error' => 'cant_edit_yourself']);
} else {
- if($userupdate->password() !== $user->password() && $user->passwordhashed()) {
+ if ($userupdate->password() !== $user->password() && $user->passwordhashed()) {
$userupdate->setpasswordhashed(false);
}
- if($userupdate->passwordhashed() && !$user->passwordhashed()) {
+ if ($userupdate->passwordhashed() && !$user->passwordhashed()) {
$userupdate->hashpassword();
}
$this->usermanager->add($userupdate);
@@ -131,7 +139,3 @@ class Controlleruser extends Controller
}
}
}
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/Dbitem.php b/app/class/Dbitem.php
index 34814d2..44dec2c 100644
--- a/app/class/Dbitem.php
+++ b/app/class/Dbitem.php
@@ -12,7 +12,7 @@ abstract class Dbitem extends Item
{
$array = [];
foreach ($this as $var => $value) {
- if($value instanceof DateTime || $value instanceof DateTimeImmutable) {
+ if ($value instanceof DateTime || $value instanceof DateTimeImmutable) {
$array[$var] = $this->$var('string');
} else {
$array[$var] = $this->$var();
@@ -20,7 +20,4 @@ abstract class Dbitem extends Item
}
return $array;
}
-
}
-
-?> \ No newline at end of file
diff --git a/app/class/Element.php b/app/class/Element.php
index 1193c66..3160986 100644
--- a/app/class/Element.php
+++ b/app/class/Element.php
@@ -18,11 +18,11 @@ class Element extends Item
protected $headerid = 1;
- // __________________________________________________ F U N ____________________________________________________________
+ // ______________________________________________ F U N ________________________________________________________
- public function __construct($datas = [], $pageid)
+ public function __construct($pageid, $datas = [])
{
$this->hydrate($datas);
$this->analyse($pageid);
@@ -53,7 +53,7 @@ class Element extends Item
- // __________________________________________________ G E T ____________________________________________________________
+ // ______________________________________________ G E T ________________________________________________________
public function fullmatch()
@@ -111,7 +111,7 @@ class Element extends Item
- // __________________________________________________ S E T ____________________________________________________________
+ // ______________________________________________ S E T ________________________________________________________
public function setfullmatch(string $fullmatch)
diff --git a/app/class/Event.php b/app/class/Event.php
index ca470f6..c14b0e8 100644
--- a/app/class/Event.php
+++ b/app/class/Event.php
@@ -68,7 +68,6 @@ class Event extends Dbitem
$now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
return hrdi($this->date->diff($now));
break;
-
}
}
@@ -147,16 +146,8 @@ class Event extends Dbitem
public function setclap($clap)
{
- if(is_int($clap)) {
+ if (is_int($clap)) {
$this->clap = $clap;
}
}
-
-
-
-
-
}
-
-
-?> \ No newline at end of file
diff --git a/app/class/Flywheel/Formatter/JSON.php b/app/class/Flywheel/Formatter/JSON.php
index 9659fcb..d55c3b6 100644
--- a/app/class/Flywheel/Formatter/JSON.php
+++ b/app/class/Flywheel/Formatter/JSON.php
@@ -1,4 +1,5 @@
<?php
+
namespace Wcms\Flywheel\Formatter;
class JSON implements \JamesMoss\Flywheel\Formatter\FormatInterface
@@ -18,4 +19,4 @@ class JSON implements \JamesMoss\Flywheel\Formatter\FormatInterface
$options = defined('JSON_OBJECT_AS_ARRAY') ? JSON_OBJECT_AS_ARRAY : null;
return json_decode($data, $options);
}
-} \ No newline at end of file
+}
diff --git a/app/class/Flywheel/Predicate.php b/app/class/Flywheel/Predicate.php
index 2922c8d..0fa1a23 100644
--- a/app/class/Flywheel/Predicate.php
+++ b/app/class/Flywheel/Predicate.php
@@ -1,9 +1,11 @@
<?php
+
namespace Wcms\Flywheel;
class Predicate extends \JamesMoss\Flywheel\Predicate
{
- public function __construct() {
+ public function __construct()
+ {
$this->operators = array(
'>', '>=', '<', '<=', '==', '===', '!=', '!==', 'IN'
);
diff --git a/app/class/Flywheel/Query.php b/app/class/Flywheel/Query.php
index f002080..a3ccf36 100644
--- a/app/class/Flywheel/Query.php
+++ b/app/class/Flywheel/Query.php
@@ -1,4 +1,5 @@
<?php
+
namespace Wcms\Flywheel;
class Query extends \JamesMoss\Flywheel\Query
diff --git a/app/class/Flywheel/Repository.php b/app/class/Flywheel/Repository.php
index d0b68eb..d34099f 100644
--- a/app/class/Flywheel/Repository.php
+++ b/app/class/Flywheel/Repository.php
@@ -1,4 +1,5 @@
<?php
+
namespace Wcms\Flywheel;
class Repository extends \JamesMoss\Flywheel\Repository
@@ -23,7 +24,7 @@ class Repository extends \JamesMoss\Flywheel\Repository
public function getAllIds()
{
$ext = $this->formatter->getFileExtension();
- return array_map(function($path) use ($ext) {
+ return array_map(function ($path) use ($ext) {
return $this->getIdFromPath($path, $ext);
}, $this->getAllFiles());
}
diff --git a/app/class/Header.php b/app/class/Header.php
index 0165e59..38ae8c4 100644
--- a/app/class/Header.php
+++ b/app/class/Header.php
@@ -9,16 +9,17 @@ namespace Wcms;
*/
class Header
{
- /** @var string $id the id of this header. */
- public $id;
- /** @var int $level the level of deepness of this header. */
- public $level;
- /** @var string $title the title displayed by this header. */
- public $title;
+ /** @var string $id the id of this header. */
+ public $id;
+ /** @var int $level the level of deepness of this header. */
+ public $level;
+ /** @var string $title the title displayed by this header. */
+ public $title;
- public function __construct(string $id, int $level, string $title) {
- $this->id = $id;
- $this->level = $level;
- $this->title = $title;
- }
+ public function __construct(string $id, int $level, string $title)
+ {
+ $this->id = $id;
+ $this->level = $level;
+ $this->title = $title;
+ }
}
diff --git a/app/class/Item.php b/app/class/Item.php
index 10d35d7..8a8f2d6 100644
--- a/app/class/Item.php
+++ b/app/class/Item.php
@@ -12,21 +12,21 @@ abstract class Item
public function hydrate($datas = [])
{
- $error = 0;
+ $error = 0;
foreach ($datas as $key => $value) {
$method = 'set' . $key;
if (method_exists($this, $method)) {
- if($this->$method($value) === false) {
- $error ++;
- }
+ if ($this->$method($value) === false) {
+ $error++;
+ }
}
- }
- if ($error > 0) {
- return false;
- } else {
- return true;
- }
+ }
+ if ($error > 0) {
+ return false;
+ } else {
+ return true;
+ }
}
@@ -40,54 +40,51 @@ abstract class Item
}
- /**
- * Return any asked vars and their values of an object as associative array
- *
- * @param array $vars list of vars
- * @return array Associative array `$var => $value`
- */
- public function drylist(array $vars) : array
- {
- $array = [];
- foreach ($vars as $var) {
- if (property_exists($this, $var))
- $array[$var] = $this->$var;
- }
- return $array;
+ /**
+ * Return any asked vars and their values of an object as associative array
+ *
+ * @param array $vars list of vars
+ * @return array Associative array `$var => $value`
+ */
+ public function drylist(array $vars): array
+ {
+ $array = [];
+ foreach ($vars as $var) {
+ if (property_exists($this, $var)) {
+ $array[$var] = $this->$var;
+ }
+ }
+ return $array;
}
- /**
- * Tool for accessing different view of the same DateTimeImmutable var
- *
- * @param string $property DateTimeImmutable var to access
- * @param string $option
- *
- * @return mixed string or false if propriety does not exist
- */
- protected function datetransform(string $property, string $option = 'date')
- {
- if(property_exists($this, $property)) {
- if ($option == 'string') {
- return $this->$property->format(DateTime::ISO8601);
- } elseif ($option == 'date' || $option == 'sort') {
- return $this->$property;
- } elseif ($option == 'hrdi') {
- $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
- return hrdi($this->$property->diff($now));
- } elseif ($option == 'pdate') {
- return $this->$property->format('Y-m-d');
- } elseif ($option == 'ptime') {
- return $this->$property->format('H:i');
- } elseif ($option = 'dmy') {
- return $this->$property->format('d/m/Y');
- }
- } else {
- return false;
- }
- }
-
+ /**
+ * Tool for accessing different view of the same DateTimeImmutable var
+ *
+ * @param string $property DateTimeImmutable var to access
+ * @param string $option
+ *
+ * @return mixed string or false if propriety does not exist
+ */
+ protected function datetransform(string $property, string $option = 'date')
+ {
+ if (property_exists($this, $property)) {
+ if ($option == 'string') {
+ return $this->$property->format(DateTime::ISO8601);
+ } elseif ($option == 'date' || $option == 'sort') {
+ return $this->$property;
+ } elseif ($option == 'hrdi') {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->$property->diff($now));
+ } elseif ($option == 'pdate') {
+ return $this->$property->format('Y-m-d');
+ } elseif ($option == 'ptime') {
+ return $this->$property->format('H:i');
+ } elseif ($option = 'dmy') {
+ return $this->$property->format('d/m/Y');
+ }
+ } else {
+ return false;
+ }
+ }
}
-
-
-?> \ No newline at end of file
diff --git a/app/class/Media.php b/app/class/Media.php
index 9213c31..def4645 100644
--- a/app/class/Media.php
+++ b/app/class/Media.php
@@ -8,298 +8,290 @@ use DateTimeZone;
class Media extends Item
{
- Protected $id;
- Protected $path;
- Protected $extension;
- Protected $type;
- Protected $size;
- Protected $date;
- Protected $width;
- Protected $height;
- Protected $length;
- Protected $uid;
- Protected $permissions;
+ protected $id;
+ protected $path;
+ protected $extension;
+ protected $type;
+ protected $size;
+ protected $date;
+ protected $width;
+ protected $height;
+ protected $length;
+ protected $uid;
+ protected $permissions;
- const IMAGE = array('jpg', 'jpeg', 'gif', 'png');
- const SOUND = array('mp3', 'flac', 'wav', 'ogg');
- const VIDEO = array('mp4', 'mov', 'avi', 'mkv');
- const ARCHIVE = array('zip', 'rar');
+ public const IMAGE = array('jpg', 'jpeg', 'gif', 'png');
+ public const SOUND = array('mp3', 'flac', 'wav', 'ogg');
+ public const VIDEO = array('mp4', 'mov', 'avi', 'mkv');
+ public const ARCHIVE = array('zip', 'rar');
// _____________________________________________________ F U N ____________________________________________________
- public function __construct(array $donnees)
- {
- $this->hydrate($donnees);
- }
-
- public function analyse()
- {
- $this->settype();
-
- $this->setdate();
-
- $filepath = $this->path . $this->id . '.' . $this->extension;
-
- if ($this->type == 'image') {
- list($width, $height, $type, $attr) = getimagesize($filepath);
- $this->width = $width;
- $this->height = $height;
- }
-
- $stat = stat($filepath);
-
- $permissions = decoct(fileperms($filepath) & 0777);
-
- $this->setpermissions($permissions);
-
- $this->hydrate($stat);
-
-
- }
-
-
- public function getfullpath()
- {
- if(!empty(Config::basepath())) {
- $base = '/' . Config::basepath();
- } else {
- $base = '';
- }
- $fullpath = $base . '/'. $this->path() . $this->id() . '.' . $this->extension();
- $fullpath = str_replace('\\', '/', $fullpath);
- return $fullpath;
- }
-
- public function getincludepath()
- {
- $includepath = $this->path() . $this->id() . '.' . $this->extension();
- $includepath = str_replace('\\', '/', $includepath);
- $includepath = substr($includepath, 6);
- return $includepath;
- }
-
- public function getfulldir()
- {
- return $this->path . $this->id . '.' . $this->extension;
- }
-
- /**
- * Generate html code depending on media type
- *
- * @return string html code
- */
- public function getcode() : string
- {
- switch ($this->type) {
- case 'image':
- $code = '![' . $this->id . '](' . $this->getincludepath() . ')';
- break;
-
- case 'sound':
- $code = '&lt;audio controls src="' . $this->getincludepath() . '"&gt;&lt;/audio&gt;';
- break;
-
- case 'video':
- $code = '&lt;video controls=""&gt;&lt;source src="' . $this->getincludepath() . '" type="video/' . $this->extension . '"&gt;&lt;/video&gt;';
- break;
-
- default :
- $code = '[' . $this->id . '](' . $this->getincludepath() . ')';
- break;
-
- }
-
- return $code;
-
- }
-
- public function getsymbol()
- {
- switch ($this->type) {
- case 'image':
- $symbol = "🖼";
- break;
-
- case 'sound':
- $symbol = "🎵";
- break;
-
- case 'video':
- $symbol = "🎞";
- break;
-
- case 'document':
- $symbol = "📓";
- break;
-
- case 'archive':
- $symbol = "🗜";
- break;
-
- case 'code':
- $symbol = "📄";
- break;
-
- default :
- $symbol = "🎲";
- break;
- }
- return $symbol;
- }
+ public function __construct(array $donnees)
+ {
+ $this->hydrate($donnees);
+ }
+
+ public function analyse()
+ {
+ $this->settype();
+
+ $this->setdate();
+
+ $filepath = $this->path . $this->id . '.' . $this->extension;
+
+ if ($this->type == 'image') {
+ list($width, $height, $type, $attr) = getimagesize($filepath);
+ $this->width = $width;
+ $this->height = $height;
+ }
+
+ $stat = stat($filepath);
+
+ $permissions = decoct(fileperms($filepath) & 0777);
+
+ $this->setpermissions($permissions);
+
+ $this->hydrate($stat);
+ }
+
+
+ public function getfullpath()
+ {
+ if (!empty(Config::basepath())) {
+ $base = '/' . Config::basepath();
+ } else {
+ $base = '';
+ }
+ $fullpath = $base . '/' . $this->path() . $this->id() . '.' . $this->extension();
+ $fullpath = str_replace('\\', '/', $fullpath);
+ return $fullpath;
+ }
+
+ public function getincludepath()
+ {
+ $includepath = $this->path() . $this->id() . '.' . $this->extension();
+ $includepath = str_replace('\\', '/', $includepath);
+ $includepath = substr($includepath, 6);
+ return $includepath;
+ }
+
+ public function getfulldir()
+ {
+ return $this->path . $this->id . '.' . $this->extension;
+ }
+
+ /**
+ * Generate html code depending on media type
+ *
+ * @return string html code
+ */
+ public function getcode(): string
+ {
+ switch ($this->type) {
+ case 'image':
+ $code = '![' . $this->id . '](' . $this->getincludepath() . ')';
+ break;
+
+ case 'sound':
+ $code = '&lt;audio controls src="' . $this->getincludepath() . '"&gt;&lt;/audio&gt;';
+ break;
+
+ case 'video':
+ $code = '&lt;video controls=""&gt;&lt;source src="' . $this->getincludepath() . '" type="video/' . $this->extension . '"&gt;&lt;/video&gt;';
+ break;
+
+ default:
+ $code = '[' . $this->id . '](' . $this->getincludepath() . ')';
+ break;
+ }
+
+ return $code;
+ }
+
+ public function getsymbol()
+ {
+ switch ($this->type) {
+ case 'image':
+ $symbol = "🖼";
+ break;
+
+ case 'sound':
+ $symbol = "🎵";
+ break;
+
+ case 'video':
+ $symbol = "🎞";
+ break;
+
+ case 'document':
+ $symbol = "📓";
+ break;
+
+ case 'archive':
+ $symbol = "🗜";
+ break;
+
+ case 'code':
+ $symbol = "📄";
+ break;
+
+ default:
+ $symbol = "🎲";
+ break;
+ }
+ return $symbol;
+ }
// _________________________________________________ G E T ____________________________________________________
- public function id()
- {
- return $this->id;
- }
-
- public function path()
- {
- return $this->path;
- }
-
- public function extension()
- {
- return $this->extension;
- }
-
- public function type()
- {
- return $this->type;
- }
-
- public function size($display = 'binary')
- {
- if($display == 'hr') {
- return readablesize($this->size) . 'o';
- } else {
- return $this->size;
- }
- }
-
- public function date($option = 'date')
- {
- return $this->datetransform('date', $option);
- }
-
- public function width()
- {
- return $this->width;
- }
-
- public function height()
- {
- return $this->height;
- }
-
- public function length()
- {
- return $this->length;
- }
-
- public function surface()
- {
- $surface = $this->width * $this->height;
- return readablesize($surface, 1000) . 'px';
- }
-
- public function uid($option = 'id')
- {
- if($option === 'name') {
- $userinfo = posix_getpwuid($this->uid);
- return $userinfo['name'];
- } else {
- return $this->uid;
- }
- }
-
- public function permissions()
- {
- return $this->permissions;
- }
+ public function id()
+ {
+ return $this->id;
+ }
+
+ public function path()
+ {
+ return $this->path;
+ }
+
+ public function extension()
+ {
+ return $this->extension;
+ }
+
+ public function type()
+ {
+ return $this->type;
+ }
+
+ public function size($display = 'binary')
+ {
+ if ($display == 'hr') {
+ return readablesize($this->size) . 'o';
+ } else {
+ return $this->size;
+ }
+ }
+
+ public function date($option = 'date')
+ {
+ return $this->datetransform('date', $option);
+ }
+
+ public function width()
+ {
+ return $this->width;
+ }
+
+ public function height()
+ {
+ return $this->height;
+ }
+
+ public function length()
+ {
+ return $this->length;
+ }
+
+ public function surface()
+ {
+ $surface = $this->width * $this->height;
+ return readablesize($surface, 1000) . 'px';
+ }
+
+ public function uid($option = 'id')
+ {
+ if ($option === 'name') {
+ $userinfo = posix_getpwuid($this->uid);
+ return $userinfo['name'];
+ } else {
+ return $this->uid;
+ }
+ }
+
+ public function permissions()
+ {
+ return $this->permissions;
+ }
// ___________________________________________________ S E T __________________________________________________
- public function setid($id)
- {
- if (is_string($id)) {
- $this->id = $id;
- }
- }
-
- public function setpath($path)
- {
- if (strlen($path) < 40 and is_string($path)) {
- $this->path = strip_tags(strtolower($path));
- }
- }
-
- public function setextension($extension)
- {
- if (strlen($extension) < 7 and is_string($extension)) {
- $this->extension = strip_tags(strtolower($extension));
- }
- }
-
- public function settype()
- {
- if (!empty($this->extension) && isset(Model::MEDIA_EXT[$this->extension])) {
- $this->type = Model::MEDIA_EXT[$this->extension];
- } else {
- $this->type = 'other';
- }
- }
-
- public function setsize($size)
- {
- if (is_int($size)) {
- $this->size = $size;
- }
- }
-
- public function setdate()
- {
- $timestamp = filemtime($this->getfulldir());
- $this->date = new DateTimeImmutable("@$timestamp");
- }
-
- public function setwidth($width)
- {
- if (is_int($width)) {
- $this->width = strip_tags(strtolower($width));
- }
- }
-
- public function setheight($height)
- {
- if (is_int($height)) {
- $this->height = strip_tags(strtolower($height));
- }
- }
-
- public function setlength($length)
- {
- if ($this->type == 'sound') {
- $this->length = $length;
- }
- }
-
- public function setuid($uid)
- {
- $this->uid = $uid;
- }
-
- public function setpermissions($permissions)
- {
- $this->permissions = $permissions;
- }
-
-
-
-
+ public function setid($id)
+ {
+ if (is_string($id)) {
+ $this->id = $id;
+ }
+ }
+
+ public function setpath($path)
+ {
+ if (strlen($path) < 40 and is_string($path)) {
+ $this->path = strip_tags(strtolower($path));
+ }
+ }
+
+ public function setextension($extension)
+ {
+ if (strlen($extension) < 7 and is_string($extension)) {
+ $this->extension = strip_tags(strtolower($extension));
+ }
+ }
+
+ public function settype()
+ {
+ if (!empty($this->extension) && isset(Model::MEDIA_EXT[$this->extension])) {
+ $this->type = Model::MEDIA_EXT[$this->extension];
+ } else {
+ $this->type = 'other';
+ }
+ }
+
+ public function setsize($size)
+ {
+ if (is_int($size)) {
+ $this->size = $size;
+ }
+ }
+
+ public function setdate()
+ {
+ $timestamp = filemtime($this->getfulldir());
+ $this->date = new DateTimeImmutable("@$timestamp");
+ }
+
+ public function setwidth($width)
+ {
+ if (is_int($width)) {
+ $this->width = strip_tags(strtolower($width));
+ }
+ }
+
+ public function setheight($height)
+ {
+ if (is_int($height)) {
+ $this->height = strip_tags(strtolower($height));
+ }
+ }
+
+ public function setlength($length)
+ {
+ if ($this->type == 'sound') {
+ $this->length = $length;
+ }
+ }
+
+ public function setuid($uid)
+ {
+ $this->uid = $uid;
+ }
+
+ public function setpermissions($permissions)
+ {
+ $this->permissions = $permissions;
+ }
}
diff --git a/app/class/Medialist.php b/app/class/Medialist.php
index ddb5eaa..35ea991 100644
--- a/app/class/Medialist.php
+++ b/app/class/Medialist.php
@@ -35,7 +35,7 @@ class Medialist extends Item
- // __________________________________________________ F U N ____________________________________________________________
+ // ______________________________________________ F U N ________________________________________________________
@@ -59,7 +59,6 @@ class Medialist extends Item
$this->content = '<strong>RENDERING ERROR :</strong> path : <code>' . Model::MEDIA_DIR . $this->path . '/</code> does not exist';
return false;
} else {
-
$mediamanager->medialistsort($medialist, $this->sortby, $this->order);
$dirid = str_replace('/', '-', $this->path);
@@ -88,32 +87,31 @@ class Medialist extends Item
/**
* Generate link adress for table header
- *
- * @param string $sortby
+ *
+ * @param string $sortby
* @return string link adress
*/
- public function getsortbyadress(string $sortby) : string
+ public function getsortbyadress(string $sortby): string
{
- if(!in_array($sortby, Model::MEDIA_SORTBY)) {
+ if (!in_array($sortby, Model::MEDIA_SORTBY)) {
$sortby = 'id';
}
- if ($this->sortby === $sortby) {
- $order = $this->order * -1;
- } else {
- $order = $this->order;
- }
+ 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) != []) {
+ if (array_diff(self::TYPES, $this->type) != []) {
$query['type'] = $this->type;
}
return '?' . urldecode(http_build_query($query));
-
}
- public function getpathadress(string $path) : string
+ public function getpathadress(string $path): string
{
$query = ['path' => '/' . $path, 'sortby' => $this->sortby, 'order' => $this->order];
- if(array_diff( self::TYPES, $this->type) != []) {
+ if (array_diff(self::TYPES, $this->type) != []) {
$query['type'] = $this->type;
}
return '?' . urldecode(http_build_query($query));
@@ -122,14 +120,14 @@ class Medialist extends Item
public function getquery()
{
$query = ['path' => $this->path, 'sortby' => $this->sortby, 'order' => $this->order];
- if(array_diff( self::TYPES, $this->type) != []) {
+ if (array_diff(self::TYPES, $this->type) != []) {
$query['type'] = $this->type;
}
- return '%MEDIA?' . urldecode(http_build_query($query)). '%';
+ return '%MEDIA?' . urldecode(http_build_query($query)) . '%';
}
- // __________________________________________________ G E T ____________________________________________________________
+ // ______________________________________________ G E T ________________________________________________________
public function fullmatch()
@@ -173,7 +171,7 @@ class Medialist extends Item
return $this->type;
}
- // __________________________________________________ S E T ____________________________________________________________
+ // ______________________________________________ S E T ________________________________________________________
public function setfullmatch(string $fullmatch)
@@ -191,10 +189,10 @@ class Medialist extends Item
public function setpath(string $path)
{
- if(preg_match('%^\/' . rtrim(Model::MEDIA_DIR, DIRECTORY_SEPARATOR) . '%', $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);
+ $this->path = '/' . Model::MEDIA_DIR . rtrim($path, DIRECTORY_SEPARATOR);
}
}
@@ -214,7 +212,7 @@ class Medialist extends Item
public function settype($type)
{
- if(is_array($type)) {
+ if (is_array($type)) {
$this->type = array_intersect(Model::mediatypes(), array_unique($type));
}
}
diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php
index 8df813b..2fabc3a 100644
--- a/app/class/Modelrender.php
+++ b/app/class/Modelrender.php
@@ -130,7 +130,7 @@ class Modelrender extends Modelpage
// First, analyse the synthax and call the corresponding methods
if (isset($matches)) {
foreach ($matches as $key => $match) {
- $element = new Element($match, $this->page->id());
+ $element = new Element($this->page->id(), $match);
$element->setcontent($this->getelementcontent($element->sources(), $element->type()));
$element->setcontent($this->elementparser($element));
$element->addtags();