aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/class/application.php8
-rw-r--r--app/class/backrouter.php80
-rw-r--r--app/class/config.php22
-rw-r--r--app/class/controller.php12
-rw-r--r--app/class/controlleradmin.php10
-rw-r--r--app/class/controllerart.php409
-rw-r--r--app/class/controllerconnect.php14
-rw-r--r--app/class/controllerhome.php14
-rw-r--r--app/class/controllerpage.php409
-rw-r--r--app/class/element.php12
-rw-r--r--app/class/event.php4
-rw-r--r--app/class/modelanalyse.php38
-rw-r--r--app/class/modelart.php306
-rw-r--r--app/class/modelhome.php16
-rw-r--r--app/class/modelpage.php306
-rw-r--r--app/class/modelrender.php172
-rw-r--r--app/class/modeltimeline.php2
-rw-r--r--app/class/opt.php28
-rw-r--r--app/class/page.php (renamed from app/class/art2.php)4
-rw-r--r--app/class/route.php2
-rw-r--r--app/class/routes.php30
-rw-r--r--app/view/templates/admin.php20
-rw-r--r--app/view/templates/alert.php12
-rw-r--r--app/view/templates/backtopbar.php2
-rw-r--r--app/view/templates/confirmdelete.php17
-rw-r--r--app/view/templates/connect.php6
-rw-r--r--app/view/templates/edit.php14
-rw-r--r--app/view/templates/editleftbar.php70
-rw-r--r--app/view/templates/editrightbar.php16
-rw-r--r--app/view/templates/edittopbar.php10
-rw-r--r--app/view/templates/home.php8
-rw-r--r--app/view/templates/homemenu.php2
-rw-r--r--app/view/templates/navart.php129
-rw-r--r--app/view/templates/updatemerge.php2
-rw-r--r--assets/js/edit.js6
-rw-r--r--assets/js/worker.js8
-rw-r--r--composer.json2
37 files changed, 1006 insertions, 1216 deletions
diff --git a/app/class/application.php b/app/class/application.php
index b749d9b..784a388 100644
--- a/app/class/application.php
+++ b/app/class/application.php
@@ -40,12 +40,12 @@ class Application
} else {
if(Config::readconfig()) {
- if(!Config::checkbasepath() || empty(Config::arttable()) || !is_dir(Model::RENDER_DIR) || !Config::checkdomain()) {
+ if(!Config::checkbasepath() || empty(Config::pagetable()) || !is_dir(Model::RENDER_DIR) || !Config::checkdomain()) {
echo '<ul>';
if(!Config::checkbasepath()) {
echo '<li>Wrong path</li>';
}
- if(empty(Config::arttable())) {
+ if(empty(Config::pagetable())) {
echo '<li>Unset table name</li>';
}
if(!Config::checkdomain()) {
@@ -91,9 +91,9 @@ class Application
</div>
<div>
<h2>
- <label for="arttable">Name of your database table</label>
+ <label for="pagetable">Name of your database table</label>
</h2>
- <input type="text" name="configinit[arttable]" value="<?= Config::arttable() ?>" id="arttable">
+ <input type="text" name="configinit[pagetable]" value="<?= Config::pagetable() ?>" id="pagetable">
<p><i>Set the name of the first folder that is going to store all your work</i></p>
</div>
<input type="submit" value="set">
diff --git a/app/class/backrouter.php b/app/class/backrouter.php
deleted file mode 100644
index 356a021..0000000
--- a/app/class/backrouter.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-
-class Backrouter
-{
- protected $route;
- protected $altorouter;
-
- const ROUTES = [
- 'art' => ['art', 'read'],
- 'art aff=read' => ['art', 'read'],
- 'art aff=edit' => ['art', 'edit'],
- 'art aff=log' => ['art', 'log'],
- 'art action=update' => ['art', 'update'],
- 'art action=update home' => ['art', 'update', 'home'],
- 'art action=add' => ['art', 'add'],
- 'art action=delete' => ['art', 'delete'],
- 'aff=home action=massedit',
- 'aff=home' => ['home', 'desktop'],
- '' => ['home', 'desktop'],
- 'aff=home action=massedit' => ['home', 'massedit'],
- 'action=massedit' => ['home', 'massedit'],
- 'action=analyseall' => ['home', 'analyseall'],
- 'aff=home action=analyseall' => ['home', 'analyseall'],
- 'art action=login' => ['art', 'login', 'art'],
- 'home action=login' => ['home', 'login', 'home'],
- 'action=login' => ['home', 'login'],
- 'art action=logout' => ['art', 'logout', 'art'],
- 'home action=logout' => ['home', 'logout', 'home'],
- 'action=logout' => ['home', 'logout'],
- 'aff=db' => ['db', 'desktop'],
- 'aff=db action=add' => ['db', 'add'],
- 'aff=media' => ['media', 'desktop'],
- 'aff=media action=addmedia' => ['media', 'addmedia'],
- 'aff=admin' => ['admin', 'desktop'],
- 'aff=co' => ['connect', 'desktop'],
- ];
-
- public function __construct($router)
- {
- $this->altorouter = $router;
- }
-
- public function run() {
- if($this->matchroute()) {
- $this->callmethod();
- } else {
- echo '<h1>404 Error</h1>';
- }
- }
-
- public function matchroute()
- {
- $this->route = new route($_GET);
- $match = array_key_exists($this->route->tostring(), self::ROUTES);
- return $match;
-
- }
-
- public function callmethod()
- {
- $method = self::ROUTES[$this->route->tostring()];
-
- $class = 'controller' . $method[0];
- $function = $method[1];
- $controller = new $class($this->altorouter);
- $params = array_slice($method, 2);
- $controller->$function(...$params);
- }
-
-
-
-}
-
-
-
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/config.php b/app/class/config.php
index 26adf62..3d67908 100644
--- a/app/class/config.php
+++ b/app/class/config.php
@@ -4,7 +4,7 @@
abstract class Config
{
- protected static $arttable = 'mystore';
+ protected static $pagetable = 'mystore';
protected static $domain = '';
protected static $fontsize = 15;
protected static $basepath = '';
@@ -20,7 +20,7 @@ abstract class Config
protected static $notpublishedpass = false;
protected static $alertcss = false;
protected static $defaultbody = '%HEADER%'. PHP_EOL .PHP_EOL . '%NAV%'. PHP_EOL .PHP_EOL . '%ASIDE%'. PHP_EOL .PHP_EOL . '%MAIN%'. PHP_EOL .PHP_EOL . '%FOOTER%';
- protected static $defaultart = '';
+ protected static $defaultpage = '';
protected static $defaultfavicon = '';
protected static $analytics = '';
protected static $externallinkblank = true;
@@ -112,9 +112,9 @@ abstract class Config
// ________________________________________ G E T _______________________________________
- public static function arttable()
+ public static function pagetable()
{
- return self::$arttable;
+ return self::$pagetable;
}
public static function domain()
@@ -192,9 +192,9 @@ abstract class Config
return self::$defaultbody;
}
- public static function defaultart()
+ public static function defaultpage()
{
- return self::$defaultart;
+ return self::$defaultpage;
}
public static function defaultfavicon()
@@ -250,9 +250,9 @@ abstract class Config
// __________________________________________ S E T ______________________________________
- public static function setarttable($arttable)
+ public static function setpagetable($pagetable)
{
- self::$arttable = strip_tags($arttable);
+ self::$pagetable = strip_tags($pagetable);
}
public static function setdomain($domain)
@@ -356,10 +356,10 @@ abstract class Config
}
}
- public static function setdefaultart($defaultart)
+ public static function setdefaultpage($defaultpage)
{
- if(is_string($defaultart)) {
- self::$defaultart = idclean($defaultart);
+ if(is_string($defaultpage)) {
+ self::$defaultpage = idclean($defaultpage);
}
}
diff --git a/app/class/controller.php b/app/class/controller.php
index b925236..a5bd33b 100644
--- a/app/class/controller.php
+++ b/app/class/controller.php
@@ -11,8 +11,8 @@ class Controller
/** @var Modeluser */
protected $usermanager;
- /** @var Modelart */
- protected $artmanager;
+ /** @var Modelpage */
+ protected $pagemanager;
protected $plates;
@@ -22,7 +22,7 @@ class Controller
public function __construct($router) {
$this->setuser();
$this->router = $router;
- $this->artmanager = new Modelart();
+ $this->pagemanager = new Modelpage();
$this->initplates();
$this->now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
}
@@ -40,8 +40,8 @@ class Controller
$this->plates->registerFunction('url', function (string $string, array $vars = []) use ($router) {
return $router->generate($string, $vars);
});
- $this->plates->registerFunction('uart', function (string $string, string $id) use ($router) {
- return $router->generate($string, ['art' => $id]);
+ $this->plates->registerFunction('upage', function (string $string, string $id) use ($router) {
+ return $router->generate($string, ['page' => $id]);
});
}
@@ -56,7 +56,7 @@ class Controller
$commonsparams = [];
$commonsparams['router'] = $this->router;
$commonsparams['user'] = $this->user;
- $commonsparams['pagelist'] = $this->artmanager->list();
+ $commonsparams['pagelist'] = $this->pagemanager->list();
$commonsparams['css'] = Model::csspath();
return $commonsparams;
}
diff --git a/app/class/controlleradmin.php b/app/class/controlleradmin.php
index e3e1b2a..dda0a54 100644
--- a/app/class/controlleradmin.php
+++ b/app/class/controlleradmin.php
@@ -9,14 +9,14 @@ class Controlleradmin extends Controller
public function desktop()
{
if($this->user->isadmin()) {
- $artlist = $this->artmanager->list();
+ $pagelist = $this->pagemanager->list();
$this->mediamanager = new Modelmedia();
$faviconlist = $this->mediamanager->listfavicon();
$interfacecsslist = $this->mediamanager->listinterfacecss();
- if(in_array(Config::defaultart(), $artlist)) {
- $defaultartexist = true;
+ if(in_array(Config::defaultpage(), $pagelist)) {
+ $defaultpageexist = true;
} else {
- $defaultartexist = true;
+ $defaultpageexist = true;
}
$globalcssfile = Model::GLOBAL_DIR . 'global.css';
@@ -27,7 +27,7 @@ class Controlleradmin extends Controller
$globalcss = "";
}
- $admin = ['artlist' => $artlist, 'defaultartexist' => $defaultartexist, 'globalcss' => $globalcss, 'faviconlist' => $faviconlist, 'interfacecsslist' => $interfacecsslist];
+ $admin = ['pagelist' => $pagelist, 'defaultpageexist' => $defaultpageexist, 'globalcss' => $globalcss, 'faviconlist' => $faviconlist, 'interfacecsslist' => $interfacecsslist];
$this->showtemplate('admin', $admin);
} else {
$this->routedirect('home');
diff --git a/app/class/controllerart.php b/app/class/controllerart.php
deleted file mode 100644
index 8d8e3bb..0000000
--- a/app/class/controllerart.php
+++ /dev/null
@@ -1,409 +0,0 @@
-<?php
-
-class Controllerart extends Controller
-{
- /** @var Art2 */
- protected $art;
- protected $fontmanager;
- protected $mediamanager;
-
- const COMBINE = false;
-
- public function __construct($router)
- {
- parent::__construct($router);
-
- $this->fontmanager = new Modelfont();
- $this->mediamanager = new Modelmedia();
-
- }
-
- public function setart(string $id, string $route)
- {
- $cleanid = idclean($id);
- if ($cleanid !== $id) {
- $this->routedirect($route, ['art' => $cleanid]);
- } else {
- $this->art = new Art2(['id' => $cleanid]);
- }
- }
-
- public function importart()
- {
- if (isset($_SESSION['artupdate']) && $_SESSION['artupdate']['id'] == $this->art->id()) {
- $art = new Art2($_SESSION['artupdate']);
- unset($_SESSION['artupdate']);
- } else {
- $art = $this->artmanager->get($this->art);
- }
- if ($art !== false) {
- $this->art = $art;
- return true;
- } 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 artconnect(string $route)
- {
- if($this->user->isvisitor()) {
- $this->showtemplate('connect', ['route' => $route, 'id' => $this->art->id()]);
- exit;
- }
- }
-
-
- public function canedit()
- {
- if ($this->user->issupereditor()) {
- return true;
- } elseif ($this->user->isinvite() || $this->user->iseditor()) {
- if (in_array($this->user->id(), $this->art->authors())) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-
- function render($id)
- {
- $this->setart($id, 'artupdate');
-
- if ($this->importart() && $this->user->iseditor()) {
- $this->art = $this->renderart($this->art);
- $this->artmanager->update($this->art);
- }
- $this->routedirect('artread/', ['art' => $this->art->id()]);
- }
-
- /**
- * Render given page
- *
- * @param Art2 $art input
- *
- * @return Art2 rendered $art
- */
- public function renderart(Art2 $art) : Art2
- {
- $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
-
- $renderengine = new Modelrender($this->router);
-
- $renderengine->render($art);
- $art->setdaterender($now);
- $art->setlinkfrom($renderengine->linkfrom());
- $art->setlinkto($renderengine->linkto());
-
- return $art;
-
- }
-
- public function reccursiverender(Art2 $art)
- {
- $relatedarts = array_diff($art->linkto(), [$art->id()]);
- foreach ($relatedarts as $artid ) {
- $art = $this->artmanager->get($artid);
- if($art !== false) {
- $art = $this->renderart($art);
- $this->artmanager->update($art);
- }
- }
- }
-
-
- public function read($id)
- {
- $this->setart($id, 'artread/');
-
- $artexist = $this->importart();
- $canread = $this->user->level() >= $this->art->secure();
- $page = ['head' => '', 'body' => ''];
-
- if ($artexist) {
-
- if ($this->art->daterender() < $this->art->datemodif()) {
- if(Config::reccursiverender()) {
- $this->reccursiverender($this->art);
- }
- $this->art = $this->renderart($this->art);
- }
- if ($canread) {
- $this->art->addaffcount();
- if ($this->user->level() < 2) {
- $this->art->addvisitcount();
- }
- }
- $this->artmanager->update($this->art);
- }
-
- if($artexist && $canread) {
- $filedir = Model::HTML_RENDER_DIR . $id . '.html';
- if(file_exists($filedir)) {
- $html = file_get_contents($filedir);
- echo $html;
- } else {
- echo 'Please render this page';
- }
- } else {
- $this->showtemplate('alert', ['art' => $this->art, 'artexist' => $artexist, 'canedit' => $this->canedit()]);
- }
-
- }
-
- public function edit($id)
- {
- $this->setart($id, 'artedit');
-
- $this->artconnect('artedit');
-
-
- if ($this->importart() && $this->canedit()) {
- $tablist = ['main' => $this->art->main(), 'css' => $this->art->css(), 'header' => $this->art->header(), 'nav' => $this->art->nav(), 'aside' => $this->art->aside(), 'footer' => $this->art->footer(), 'body' => $this->art->body(), 'javascript' => $this->art->javascript()];
-
- $faviconlist = $this->mediamanager->listfavicon();
- $idlist = $this->artmanager->list();
-
-
- $artlist = $this->artmanager->getlister();
- $tagartlist = $this->artmanager->tagartlist($this->art->tag('array'), $artlist);
- $lasteditedartlist = $this->artmanager->lasteditedartlist(5, $artlist);
-
- $editorlist = $this->usermanager->getlisterbylevel(2, '>=');
-
- if (isset($_SESSION['workspace'])) {
- $showleftpanel = $_SESSION['workspace']['showleftpanel'];
- $showrightpanel = $_SESSION['workspace']['showrightpanel'];
- } else {
- $showleftpanel = false;
- $showrightpanel = false;
- }
- $fonts = [];
-
- $this->showtemplate('edit', ['art' => $this->art, 'artexist' => true, 'tablist' => $tablist, 'artlist' => $idlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts, 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'faviconlist' => $faviconlist, 'editorlist' => $editorlist, 'user' => $this->user]);
- } else {
- $this->routedirect('artread/', ['art' => $this->art->id()]);
- }
-
- }
-
- public function log($id)
- {
- $this->setart($id, 'artlog');
- $this->importart();
- var_dump($this->art);
- }
-
- public function add($id)
- {
- $this->setart($id, 'artadd');
-
- $this->artconnect('artadd');
-
- if ($this->user->iseditor() && !$this->importart()) {
- $this->art->reset();
- if (!empty(Config::defaultart())) {
- $defaultart = $this->artmanager->get(Config::defaultart());
- if ($defaultart !== false) {
- $defaultbody = $defaultart->body();
- }
- }
- if (empty(Config::defaultart()) || $defaultart === false) {
- $defaultbody = Config::defaultbody();
- }
- $this->art->setbody($defaultbody);
- $this->artmanager->add($this->art);
- $this->routedirect('artedit', ['art' => $this->art->id()]);
- } else {
- $this->routedirect('artread/', ['art' => $this->art->id()]);
- }
- }
-
- public function confirmdelete($id)
- {
- $this->setart($id, 'artconfirmdelete');
- if ($this->user->iseditor() && $this->importart()) {
-
- $this->showtemplate('confirmdelete', ['art' => $this->art, 'artexist' => true]);
-
- } else {
- $this->routedirect('artread/', ['art' => $this->art->id()]);
- }
- }
-
- public function download($id)
- {
- if($this->user->isadmin()) {
-
- $file = Model::DATABASE_DIR . Config::arttable() . 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('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- header('Content-Length: ' . filesize($file));
- readfile($file);
- exit;
- }
- } else {
- $this->routedirect('artread/', ['art' => $id]);
- }
- }
-
- /**
- * Import page and save it into the database
- */
- public function upload()
- {
- $art = $this->artmanager->getfromfile();
-
-
- if(!empty($_POST['id'])) {
- $art->setid(idclean($_POST['id']));
- }
-
- if($_POST['datecreation']) {
- $art->setdatecreation($this->now);
- }
-
- if($_POST['author']) {
- $art->setauthors([$this->user->id()]);
- }
-
- $art->setdaterender($art->datecreation('date'));
-
- if($art !== false) {
- if($_POST['erase'] || $this->artmanager->get($art) === false) {
- $this->artmanager->add($art);
- }
- }
- $this->routedirect('home');
- }
-
- public function delete($id)
- {
- $this->setart($id, 'artdelete');
- if ($this->user->iseditor() && $this->importart()) {
-
- $this->artmanager->delete($this->art);
- }
- $this->routedirect('home');
- }
-
- public function update($id)
- {
- $this->setart($id, 'artupdate');
-
- $this->movepanels();
- $this->fontsize();
-
- $date = new DateTimeImmutable($_POST['pdate'] . $_POST['ptime'], new DateTimeZone('Europe/Paris'));
- $date = ['date' => $date];
-
- if ($this->importart()) {
- if ($this->canedit()) {
-
- // Check if someone esle edited the page during the editing.
- $oldart = clone $this->art;
- $this->art->hydrate($_POST);
-
- if (self::COMBINE && $_POST['thisdatemodif'] === $oldart->datemodif('string')) {
-
- }
-
- $this->art->hydrate($date);
- $this->art->updateedited();
- $this->art->addauthor($this->user->id());
- $this->art->removeeditby($this->user->id());
-
- // Add thumbnail image file under 1Mo
- $this->mediamanager->simpleupload('thumbnail', Model::THUMBNAIL_DIR . $this->art->id(), 1024*1024, ['jpg', 'jpeg', 'JPG', 'JPEG'], true);
-
-
- $this->artmanager->update($this->art);
-
- $this->routedirect('artedit', ['art' => $this->art->id()]);
-
- //$this->showtemplate('updatemerge', $compare);
- } else {
- // If the editor session finished during the editing, let's try to reconnect to save the editing
- $_SESSION['artupdate'] = $_POST;
- $_SESSION['artupdate']['id'] = $this->art->id();
- $this->routedirect('connect');
- }
-
- }
- $this->routedirect('art');
- }
-
- /**
- * This function set the actual editor of the page
- *
- * @param string $artid as the page id
- */
- public function editby(string $artid)
- {
- $this->art = new Art2(['id' => $artid]);
- if($this->importart($artid)) {
- $this->art->addeditby($this->user->id());
- $this->artmanager->update($this->art);
- echo json_encode(['success' => true]);
- } else {
- $this->error(400);
- }
- }
-
- /**
- * This function remove the actual editor of the page
- *
- * @param string $artid as the page id
- */
- public function removeeditby(string $artid)
- {
- $this->art = new Art2(['id' => $artid]);
- if($this->importart($artid)) {
- $this->art->removeeditby($this->user->id());
- $this->artmanager->update($this->art);
- echo json_encode(['success' => true]);
- } else {
- $this->error(400);
- }
- }
-
-
- public function movepanels()
- {
- $_SESSION['workspace']['showrightpanel'] = isset($_POST['workspace']['showrightpanel']);
- $_SESSION['workspace']['showleftpanel'] = isset($_POST['workspace']['showleftpanel']);
- }
-
- public function fontsize()
- {
- if (!empty($_POST['fontsize']) && $_POST['fontsize'] !== Config::fontsize()) {
- Config::setfontsize($_POST['fontsize']);
- Config::savejson();
- }
- }
-
- public function artdirect($id)
- {
- $this->routedirect('artread/', ['art' => idclean($id)]);
- }
-}
-
-
-
-
-?> \ No newline at end of file
diff --git a/app/class/controllerconnect.php b/app/class/controllerconnect.php
index bf1b72d..1bd0a5a 100644
--- a/app/class/controllerconnect.php
+++ b/app/class/controllerconnect.php
@@ -19,13 +19,13 @@ class Controllerconnect extends Controller
public function connect()
{
- if(isset($_SESSION['artupdate'])) {
- $artupdate['route'] = 'artedit';
- $artupdate['id'] = $_SESSION['artupdate']['id'];
+ if(isset($_SESSION['pageupdate'])) {
+ $pageupdate['route'] = 'pageedit';
+ $pageupdate['id'] = $_SESSION['pageupdate']['id'];
} else {
- $artupdate = ['route' => 'home'];
+ $pageupdate = ['route' => 'home'];
}
- $this->showtemplate('connect', $artupdate);
+ $this->showtemplate('connect', $pageupdate);
}
@@ -47,7 +47,7 @@ class Controllerconnect extends Controller
}
}
if ($id !== null) {
- $this->routedirect($route, ['art' => $id]);
+ $this->routedirect($route, ['page' => $id]);
} else {
$this->routedirect($route);
}
@@ -58,7 +58,7 @@ class Controllerconnect extends Controller
$this->user = $this->usermanager->logout();
$this->usermanager->writesession($this->user);
if ($id !== null && $route !== 'home') {
- $this->routedirect($route, ['art' => $id]);
+ $this->routedirect($route, ['page' => $id]);
} else {
$this->routedirect($route);
}
diff --git a/app/class/controllerhome.php b/app/class/controllerhome.php
index 7691bab..d263611 100644
--- a/app/class/controllerhome.php
+++ b/app/class/controllerhome.php
@@ -1,6 +1,6 @@
<?php
-class Controllerhome extends Controllerart
+class Controllerhome extends Controllerpage
{
/** @var Modelhome */
protected $modelhome;
@@ -20,7 +20,7 @@ class Controllerhome extends Controllerart
public function desktop()
{
if ($this->user->isvisitor() && Config::homepage() === 'redirect' && Config::homeredirect() !== null) {
- $this->routedirect('artread/', ['art' => Config::homeredirect()]);
+ $this->routedirect('pageread/', ['page' => Config::homeredirect()]);
} else {
@@ -34,7 +34,7 @@ class Controllerhome extends Controllerart
$columns = $this->modelhome->setcolumns($this->user->columns());
$vars = ['user' => $this->user, 'table2' => $table2, 'opt' => $this->opt, 'columns' => $columns];
- $vars['footer'] = ['version' => getversion(), 'total' => count($table), 'database' => Config::arttable()];
+ $vars['footer'] = ['version' => getversion(), 'total' => count($table), 'database' => Config::pagetable()];
if (isset($_POST['query']) && $this->user->iseditor()) {
$datas = array_merge($_POST, $_SESSION['opt']);
@@ -64,11 +64,11 @@ class Controllerhome extends Controllerart
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'read':
- $this->routedirect('artread/', ['art' => $_POST['id']]);
+ $this->routedirect('pageread/', ['page' => $_POST['id']]);
break;
case 'edit':
- $this->routedirect('artedit', ['art' => $_POST['id']]);
+ $this->routedirect('pageedit', ['page' => $_POST['id']]);
break;
}
}
@@ -85,8 +85,8 @@ class Controllerhome extends Controllerart
if ($this->user->iseditor()) {
$pagelist = $this->modelhome->getlister();
foreach ($pagelist as $page) {
- $this->renderart($page);
- $this->artmanager->update($page);
+ $this->renderpage($page);
+ $this->pagemanager->update($page);
}
}
$this->routedirect('home');
diff --git a/app/class/controllerpage.php b/app/class/controllerpage.php
new file mode 100644
index 0000000..9cced39
--- /dev/null
+++ b/app/class/controllerpage.php
@@ -0,0 +1,409 @@
+<?php
+
+class Controllerpage extends Controller
+{
+ /** @var Page */
+ protected $page;
+ protected $fontmanager;
+ protected $mediamanager;
+
+ const COMBINE = false;
+
+ public function __construct($router)
+ {
+ parent::__construct($router);
+
+ $this->fontmanager = new Modelfont();
+ $this->mediamanager = new Modelmedia();
+
+ }
+
+ public function setpage(string $id, string $route)
+ {
+ $cleanid = idclean($id);
+ if ($cleanid !== $id) {
+ $this->routedirect($route, ['page' => $cleanid]);
+ } else {
+ $this->page = new Page(['id' => $cleanid]);
+ }
+ }
+
+ public function importpage()
+ {
+ if (isset($_SESSION['pageupdate']) && $_SESSION['pageupdate']['id'] == $this->page->id()) {
+ $page = new Page($_SESSION['pageupdate']);
+ unset($_SESSION['pageupdate']);
+ } else {
+ $page = $this->pagemanager->get($this->page);
+ }
+ if ($page !== false) {
+ $this->page = $page;
+ return true;
+ } 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()) {
+ $this->showtemplate('connect', ['route' => $route, 'id' => $this->page->id()]);
+ exit;
+ }
+ }
+
+
+ public function canedit()
+ {
+ if ($this->user->issupereditor()) {
+ return true;
+ } elseif ($this->user->isinvite() || $this->user->iseditor()) {
+ if (in_array($this->user->id(), $this->page->authors())) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ function render($id)
+ {
+ $this->setpage($id, 'pageupdate');
+
+ if ($this->importpage() && $this->user->iseditor()) {
+ $this->page = $this->renderpage($this->page);
+ $this->pagemanager->update($this->page);
+ }
+ $this->routedirect('pageread/', ['page' => $this->page->id()]);
+ }
+
+ /**
+ * Render given page
+ *
+ * @param Page $page input
+ *
+ * @return Page rendered $page
+ */
+ public function renderpage(Page $page) : Page
+ {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
+ $renderengine = new Modelrender($this->router);
+
+ $renderengine->render($page);
+ $page->setdaterender($now);
+ $page->setlinkfrom($renderengine->linkfrom());
+ $page->setlinkto($renderengine->linkto());
+
+ return $page;
+
+ }
+
+ public function reccursiverender(Page $page)
+ {
+ $relatedpages = array_diff($page->linkto(), [$page->id()]);
+ foreach ($relatedpages as $pageid ) {
+ $page = $this->pagemanager->get($pageid);
+ if($page !== false) {
+ $page = $this->renderpage($page);
+ $this->pagemanager->update($page);
+ }
+ }
+ }
+
+
+ public function read($id)
+ {
+ $this->setpage($id, 'pageread/');
+
+ $pageexist = $this->importpage();
+ $canread = $this->user->level() >= $this->page->secure();
+ $page = ['head' => '', 'body' => ''];
+
+ if ($pageexist) {
+
+ if ($this->page->daterender() < $this->page->datemodif()) {
+ if(Config::reccursiverender()) {
+ $this->reccursiverender($this->page);
+ }
+ $this->page = $this->renderpage($this->page);
+ }
+ if ($canread) {
+ $this->page->addaffcount();
+ if ($this->user->level() < 2) {
+ $this->page->addvisitcount();
+ }
+ }
+ $this->pagemanager->update($this->page);
+ }
+
+ if($pageexist && $canread) {
+ $filedir = Model::HTML_RENDER_DIR . $id . '.html';
+ if(file_exists($filedir)) {
+ $html = file_get_contents($filedir);
+ echo $html;
+ } else {
+ echo 'Please render this page';
+ }
+ } else {
+ $this->showtemplate('alert', ['page' => $this->page, 'pageexist' => $pageexist, 'canedit' => $this->canedit()]);
+ }
+
+ }
+
+ public function edit($id)
+ {
+ $this->setpage($id, 'pageedit');
+
+ $this->pageconnect('pageedit');
+
+
+ if ($this->importpage() && $this->canedit()) {
+ $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()];
+
+ $faviconlist = $this->mediamanager->listfavicon();
+ $idlist = $this->pagemanager->list();
+
+
+ $pagelist = $this->pagemanager->getlister();
+ $tagpagelist = $this->pagemanager->tagpagelist($this->page->tag('array'), $pagelist);
+ $lasteditedpagelist = $this->pagemanager->lasteditedpagelist(5, $pagelist);
+
+ $editorlist = $this->usermanager->getlisterbylevel(2, '>=');
+
+ if (isset($_SESSION['workspace'])) {
+ $showleftpanel = $_SESSION['workspace']['showleftpanel'];
+ $showrightpanel = $_SESSION['workspace']['showrightpanel'];
+ } else {
+ $showleftpanel = false;
+ $showrightpanel = false;
+ }
+ $fonts = [];
+
+ $this->showtemplate('edit', ['page' => $this->page, 'pageexist' => true, 'tablist' => $tablist, 'pagelist' => $idlist, 'showleftpanel' => $showleftpanel, 'showrightpanel' => $showrightpanel, 'fonts' => $fonts, 'tagpagelist' => $tagpagelist, 'lasteditedpagelist' => $lasteditedpagelist, 'faviconlist' => $faviconlist, 'editorlist' => $editorlist, 'user' => $this->user]);
+ } else {
+ $this->routedirect('pageread/', ['page' => $this->page->id()]);
+ }
+
+ }
+
+ public function log($id)
+ {
+ $this->setpage($id, 'pagelog');
+ $this->importpage();
+ var_dump($this->page);
+ }
+
+ public function add($id)
+ {
+ $this->setpage($id, 'pageadd');
+
+ $this->pageconnect('pageadd');
+
+ if ($this->user->iseditor() && !$this->importpage()) {
+ $this->page->reset();
+ if (!empty(Config::defaultpage())) {
+ $defaultpage = $this->pagemanager->get(Config::defaultpage());
+ if ($defaultpage !== false) {
+ $defaultbody = $defaultpage->body();
+ }
+ }
+ if (empty(Config::defaultpage()) || $defaultpage === false) {
+ $defaultbody = Config::defaultbody();
+ }
+ $this->page->setbody($defaultbody);
+ $this->pagemanager->add($this->page);
+ $this->routedirect('pageedit', ['page' => $this->page->id()]);
+ } else {
+ $this->routedirect('pageread/', ['page' => $this->page->id()]);
+ }
+ }
+
+ public function confirmdelete($id)
+ {
+ $this->setpage($id, 'pageconfirmdelete');
+ if ($this->user->iseditor() && $this->importpage()) {
+
+ $this->showtemplate('confirmdelete', ['page' => $this->page, 'pageexist' => true]);
+
+ } else {
+ $this->routedirect('pageread/', ['page' => $this->page->id()]);
+ }
+ }
+
+ public function download($id)
+ {
+ if($this->user->isadmin()) {
+
+ $file = Model::DATABASE_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('Expires: 0');
+ header('Cache-Control: must-revalidate');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($file));
+ readfile($file);
+ exit;
+ }
+ } else {
+ $this->routedirect('pageread/', ['page' => $id]);
+ }
+ }
+
+ /**
+ * Import page and save it into the database
+ */
+ public function upload()
+ {
+ $page = $this->pagemanager->getfromfile();
+
+
+ if(!empty($_POST['id'])) {
+ $page->setid(idclean($_POST['id']));
+ }
+
+ if($_POST['datecreation']) {
+ $page->setdatecreation($this->now);
+ }
+
+ if($_POST['author']) {
+ $page->setauthors([$this->user->id()]);
+ }
+
+ $page->setdaterender($page->datecreation('date'));
+
+ if($page !== false) {
+ if($_POST['erase'] || $this->pagemanager->get($page) === false) {
+ $this->pagemanager->add($page);
+ }
+ }
+ $this->routedirect('home');
+ }
+
+ public function delete($id)
+ {
+ $this->setpage($id, 'pagedelete');
+ if ($this->user->iseditor() && $this->importpage()) {
+
+ $this->pagemanager->delete($this->page);
+ }
+ $this->routedirect('home');
+ }
+
+ public function update($id)
+ {
+ $this->setpage($id, 'pageupdate');
+
+ $this->movepanels();
+ $this->fontsize();
+
+ $date = new DateTimeImmutable($_POST['pdate'] . $_POST['ptime'], new DateTimeZone('Europe/Paris'));
+ $date = ['date' => $date];
+
+ 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->hydrate($date);
+ $this->page->updateedited();
+ $this->page->addauthor($this->user->id());
+ $this->page->removeeditby($this->user->id());
+
+ // Add thumbnail image file under 1Mo
+ $this->mediamanager->simpleupload('thumbnail', Model::THUMBNAIL_DIR . $this->page->id(), 1024*1024, ['jpg', 'jpeg', 'JPG', 'JPEG'], true);
+
+
+ $this->pagemanager->update($this->page);
+
+ $this->routedirect('pageedit', ['page' => $this->page->id()]);
+
+ //$this->showtemplate('updatemerge', $compare);
+ } else {
+ // If the editor session finished during the editing, let's try to reconnect to save the editing
+ $_SESSION['pageupdate'] = $_POST;
+ $_SESSION['pageupdate']['id'] = $this->page->id();
+ $this->routedirect('connect');
+ }
+
+ }
+ $this->routedirect('page');
+ }
+
+ /**
+ * 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)) {
+ $this->page->addeditby($this->user->id());
+ $this->pagemanager->update($this->page);
+ echo json_encode(['success' => true]);
+ } else {
+ $this->error(400);
+ }
+ }
+
+ /**
+ * 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)) {
+ $this->page->removeeditby($this->user->id());
+ $this->pagemanager->update($this->page);
+ echo json_encode(['success' => true]);
+ } else {
+ $this->error(400);
+ }
+ }
+
+
+ public function movepanels()
+ {
+ $_SESSION['workspace']['showrightpanel'] = isset($_POST['workspace']['showrightpanel']);
+ $_SESSION['workspace']['showleftpanel'] = isset($_POST['workspace']['showleftpanel']);
+ }
+
+ public function fontsize()
+ {
+ if (!empty($_POST['fontsize']) && $_POST['fontsize'] !== Config::fontsize()) {
+ Config::setfontsize($_POST['fontsize']);
+ Config::savejson();
+ }
+ }
+
+ public function pagedirect($id)
+ {
+ $this->routedirect('pageread/', ['page' => idclean($id)]);
+ }
+}
+
+
+
+
+?> \ No newline at end of file
diff --git a/app/class/element.php b/app/class/element.php
index 824a0b6..113daad 100644
--- a/app/class/element.php
+++ b/app/class/element.php
@@ -19,10 +19,10 @@ class Element
- public function __construct($datas = [], $artid)
+ public function __construct($datas = [], $pageid)
{
$this->hydrate($datas);
- $this->analyse($artid);
+ $this->analyse($pageid);
}
public function hydrate($datas)
@@ -36,18 +36,18 @@ class Element
}
}
- private function analyse(string $artid)
+ private function analyse(string $pageid)
{
if(!empty($this->options)) {
// Replace "!" by the real page name
- $this->options = str_replace('!', $artid, $this->options);
+ $this->options = str_replace('!', $pageid, $this->options);
preg_match('~(:([a-z0-9-_+!]+))?(\/([a-z0-9-,_+=]+))?~', $this->options, $matches);
if(isset($matches[2]) && !empty($matches[2])) {
$this->sources = explode('+', $matches[2]);
} else {
- $this->sources[] = $artid;
+ $this->sources[] = $pageid;
}
if(isset($matches[4])) {
$this->params = explode(',', $matches[4]);
@@ -56,7 +56,7 @@ class Element
$this->readoptions();
} else {
- $this->sources[] = $artid;
+ $this->sources[] = $pageid;
}
}
diff --git a/app/class/event.php b/app/class/event.php
index 9fc75d2..ddf177b 100644
--- a/app/class/event.php
+++ b/app/class/event.php
@@ -10,9 +10,9 @@ class Event extends Dbitem
protected $message;
protected $clap = 0;
- const EVENT_TYPES = ['message', 'art_add', 'art_edit', 'art_delete', 'media_add', 'media_delete', 'font_add'];
+ const EVENT_TYPES = ['message', 'page_add', 'page_edit', 'page_delete', 'media_add', 'media_delete', 'font_add'];
const EVENT_BASE = ['message'];
- const EVENT_ART = ['art_add', 'art_edit', 'art_delete'];
+ const EVENT_ART = ['page_add', 'page_edit', 'page_delete'];
const EVENT_MEDIA = ['media_add', 'media_delete'];
const EVENT_FONT = ['font_add', 'font_delete'];
const MESSAGE_MAX_LENGTH = 2 ** 10;
diff --git a/app/class/modelanalyse.php b/app/class/modelanalyse.php
index 379c41a..66a443e 100644
--- a/app/class/modelanalyse.php
+++ b/app/class/modelanalyse.php
@@ -2,7 +2,7 @@
-class Modelanalyse extends Modelart
+class Modelanalyse extends Modelpage
{
@@ -12,38 +12,38 @@ class Modelanalyse extends Modelart
public function analyseall()
{
- $artlist = $this->getlister();
+ $pagelist = $this->getlister();
- $artlist2 = [];
- foreach ($artlist as $art) {
- $art->setlinkfrom($this->analyselinkfrom($art));
- $artlist2[] = $art;
+ $pagelist2 = [];
+ foreach ($pagelist as $page) {
+ $page->setlinkfrom($this->analyselinkfrom($page));
+ $pagelist2[] = $page;
}
- foreach ($artlist2 as $art) {
- $art->setlinkto($this->analyselinkto($art->id(), $artlist));
- $this->update($art);
+ foreach ($pagelist2 as $page) {
+ $page->setlinkto($this->analyselinkto($page->id(), $pagelist));
+ $this->update($page);
}
}
- public function analyse(Art2 $art)
+ public function analyse(Page $page)
{
- $art->setlinkfrom($this->analyselinkfrom($art));
+ $page->setlinkfrom($this->analyselinkfrom($page));
- $artlist = $this->getlister();
- $art->setlinkto($this->analyselinkto($art->id(), $artlist));
+ $pagelist = $this->getlister();
+ $page->setlinkto($this->analyselinkto($page->id(), $pagelist));
- return $art;
+ return $page;
}
- public function analyselinkto($id, $artlist)
+ public function analyselinkto($id, $pagelist)
{
- //analyse les liens vers cet article en fouillant tout les linkfrom de la bdd, génere un tableau à stocker dans l'article
+ //analyse les liens vers cet pageicle en fouillant tout les linkfrom de la bdd, génere un tableau à stocker dans l'pageicle
$linkto = [];
- foreach ($artlist as $link) {
+ foreach ($pagelist as $link) {
if (in_array($id, $link->linkfrom('array')) && $id != $link->id()) {
$linkto[] = $link->id();
}
@@ -51,11 +51,11 @@ class Modelanalyse extends Modelart
return $linkto;
}
- public function analyselinkfrom(Art2 $art)
+ public function analyselinkfrom(Page $page)
{
$linkfrom = [];
foreach (self::TEXT_ELEMENTS as $element) {
- preg_match_all('#\]\((\?id=|=)(\w+)\)#', $art->$element(), $out);
+ preg_match_all('#\]\((\?id=|=)(\w+)\)#', $page->$element(), $out);
$linkfrom = array_merge($linkfrom, $out[2]);
}
return array_unique($linkfrom);
diff --git a/app/class/modelart.php b/app/class/modelart.php
deleted file mode 100644
index 8dee09c..0000000
--- a/app/class/modelart.php
+++ /dev/null
@@ -1,306 +0,0 @@
-<?php
-class Modelart extends Modeldb
-{
-
- const SELECT = ['title', 'id', 'description', 'tag', 'date', 'datecreation', 'datemodif', 'daterender', 'css', 'quickcss', 'javascript', 'body', 'header', 'main', 'nav', 'aside', 'footer', 'render', 'secure', 'invitepassword', 'interface', 'linkfrom', 'linkto', 'template', 'affcount', 'editcount'];
- const BY = ['datecreation', 'title', 'id', 'description', 'datemodif', 'secure'];
- const ORDER = ['DESC', 'ASC'];
-
-
- public function __construct()
- {
- parent::__construct();
- $this->storeinit(Config::arttable());
- if(!$this->dircheck(Model::HTML_RENDER_DIR)) {
- throw new Exception("Media error : Cant create /rendernew folder");
- }
- }
-
- /**
- * Scan library for all pages as objects
- *
- * @return array of Pages objects
- */
- public function getlister()
- {
- $artlist = [];
- $list = $this->repo->findAll();
- foreach ($list as $artdata) {
- $artlist[$artdata->id] = new Art2($artdata);
- }
- return $artlist;
- }
-
-
- public function getlisterid(array $idlist = [])
- {
- $artdatalist = $this->repo->query()
- ->where('__id', 'IN', $idlist)
- ->execute();
-
- $artlist = [];
- foreach ($artdatalist as $id => $artdata) {
- $artlist[$id] = new Art2($artdata);
- }
- return $artlist;
- }
-
- public function add(Art2 $art)
- {
-
- $artdata = new \JamesMoss\Flywheel\Document($art->dry());
- $artdata->setId($art->id());
- $this->repo->store($artdata);
- }
-
- /**
- * Obtain a page object from the database
- *
- * @param Art2|string $id could be an Art2 object or a id string
- *
- * @return Art2|false The Art2 object or false if it does not exist.
- */
- public function get($id)
- {
- if ($id instanceof Art2) {
- $id = $id->id();
- }
- if (is_string($id)) {
- $artdata = $this->repo->findById($id);
- if ($artdata !== false) {
- return new Art2($artdata);
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-
- /**
- * Transform File to Art2 Oject
- *
- * @return false|Art2
- */
- public function getfromfile()
- {
- if(!isset($_FILES['pagefile']) || $_FILES['pagefile']['error'] > 0 ) return false;
-
- $ext = substr(strrchr($_FILES['pagefile']['name'],'.'),1);
- if($ext !== 'json') return false;
-
- $files = $_FILES;
-
- $json = file_get_contents($_FILES['pagefile']['tmp_name']);
- $pagedata = json_decode($json, true);
-
- if($pagedata === false) return false;
-
- $page = new Art2($pagedata);
-
- return $page;
-
- }
-
- public function getartelement($id, $element)
- {
- if (in_array($element, Model::TEXT_ELEMENTS)) {
- $art = $this->get($id);
- if ($art !== false) {
- return $art->$element();
- } else {
- return false;
- }
- }
- }
-
- public function delete(Art2 $art)
- {
- $this->repo->delete($art->id());
- $this->unlink($art->id());
- }
-
-
- public function unlink(string $artid)
- {
- $files = ['.css', '.quick.css', '.js'];
- foreach ($files as $file) {
- if (file_exists(Model::RENDER_DIR . $artid . $file)) {
- unlink(Model::RENDER_DIR . $artid . $file);
- }
- }
- if(file_exists(Model::HTML_RENDER_DIR . $artid . '.html')) {
- unlink(Model::HTML_RENDER_DIR . $artid . '.html');
- }
- }
-
- public function update(Art2 $art)
- {
- $artdata = new \JamesMoss\Flywheel\Document($art->dry());
- $artdata->setId($art->id());
- $this->repo->store($artdata);
- }
-
- public function combine(Art2 $arta, Art2 $artb)
- {
- $mergeart = $arta;
- $merge = [];
- $diff = [];
- foreach ($arta::TABS as $element) {
- if($arta->$element() !== $artb->$element()) {
- $merge[$element] = compare($arta->$element(), $artb->$element());
- $diff[] = $element;
- }
- }
- $mergeart->hydrate($merge);
-
- return ['diff' => $diff, 'mergeart' => $mergeart];
- }
-
- // public function diffartelement(Art2 $arta, Art2 $artb)
- // {
- // $diff = [];
- // foreach ($arta::TABS as $element) {
- // if($arta->$element() !== $artb->$element()) {
- // $diff[] = $element;
- // }
- // }
- // return $diff;
- // }
-
- public function artcompare($art1, $art2, $method = 'id', $order = 1)
- {
- $result = ($art1->$method('sort') <=> $art2->$method('sort'));
- return $result * $order;
- }
-
- public function buildsorter($sortby, $order)
- {
- return function ($art1, $art2) use ($sortby, $order) {
- $result = $this->artcompare($art1, $art2, $sortby, $order);
- return $result;
- };
- }
-
-
-
- public function artlistsort(&$artlist, $sortby, $order = 1)
- {
- return usort($artlist, $this->buildsorter($sortby, $order));
- }
-
-
- /**
- * @param array $artlist List of Art2
- * @param array $tagchecked list of tags
- * @param string $tagcompare string, can be 'OR' or 'AND', set the tag filter method
- * @return array $array
- */
-
- public function filtertagfilter(array $artlist, array $tagchecked, $tagcompare = 'OR')
- {
-
- $filteredlist = [];
- foreach ($artlist as $art) {
- if (empty($tagchecked)) {
- $filteredlist[] = $art->id();
- } else {
- $inter = (array_intersect($art->tag('array'), $tagchecked));
- if ($tagcompare == 'OR') {
- if (!empty($inter)) {
- $filteredlist[] = $art->id();
- }
- } elseif ($tagcompare == 'AND') {
- if (!array_diff($tagchecked, $art->tag('array'))) {
- $filteredlist[] = $art->id();
- }
- }
- }
- }
- return $filteredlist;
- }
-
- public function filterauthorfilter(array $artlist, array $authorchecked, $authorcompare = 'OR')
- {
-
- $filteredlist = [];
- foreach ($artlist as $art) {
- if (empty($authorchecked)) {
- $filteredlist[] = $art->id();
- } else {
- $inter = (array_intersect($art->authors('array'), $authorchecked));
- if ($authorcompare == 'OR') {
- if (!empty($inter)) {
- $filteredlist[] = $art->id();
- }
- } elseif ($authorcompare == 'AND') {
- if (!array_diff($authorchecked, $art->authors('array'))) {
- $filteredlist[] = $art->id();
- }
- }
- }
- }
- return $filteredlist;
- }
-
- public function filtersecure(array $artlist, $secure)
- {
- $filteredlist = [];
- foreach ($artlist as $art) {
- if ($art->secure() == intval($secure)) {
- $filteredlist[] = $art->id();
- } elseif (intval($secure) >= 4) {
- $filteredlist[] = $art->id();
- }
- }
- return $filteredlist;
- }
-
-
- public function tag(array $artlist, $tagchecked)
- {
- $artcheckedlist = [];
- foreach ($artlist as $art) {
- if (in_array($tagchecked, $art->tag('array'))) {
- $artcheckedlist[] = $art;
- }
- }
- return $artcheckedlist;
- }
-
- public function taglist(array $artlist, array $tagcheckedlist)
- {
- $taglist = [];
- foreach ($tagcheckedlist as $tag) {
- $taglist[$tag] = $this->tag($artlist, $tag);
- }
- return $taglist;
- }
-
- /**
- * @param array $taglist list of tags
- * @param array $artlist list of Art2
- * @return array list of tags each containing list of id
- */
-
- public function tagartlist(array $taglist, array $artlist)
- {
- $tagartlist = [];
- foreach ($taglist as $tag) {
- $tagartlist[$tag] = $this->filtertagfilter($artlist, [$tag]);
- }
- return $tagartlist;
- }
-
- public function lasteditedartlist(int $last, array $artlist)
- {
- $this->artlistsort($artlist, 'datemodif', -1);
- $artlist = array_slice($artlist, 0, $last);
- $idlist = [];
- foreach ($artlist as $art) {
- $idlist[] = $art->id();
- }
- return $idlist;
- }
-
-}
diff --git a/app/class/modelhome.php b/app/class/modelhome.php
index 1154e78..d90a3d3 100644
--- a/app/class/modelhome.php
+++ b/app/class/modelhome.php
@@ -1,6 +1,6 @@
<?php
-class Modelhome extends Modelart
+class Modelhome extends Modelpage
{
public function __construct() {
@@ -10,7 +10,7 @@ class Modelhome extends Modelart
public function optinit($table)
{
- $opt = new Opt(Art2::classvarlist());
+ $opt = new Opt(Page::classvarlist());
$opt->setcol(['id', 'tag', 'linkfrom', 'linkto', 'description', 'title', 'datemodif', 'datecreation', 'date', 'secure', 'visitcount', 'editcount', 'affcount']);
$opt->settaglist($table);
$opt->setauthorlist($table);
@@ -28,7 +28,7 @@ class Modelhome extends Modelart
*/
public function Optlistinit(array $table)
{
- $optlist = new Optlist(Art2::classvarlist());
+ $optlist = new Optlist(Page::classvarlist());
$optlist->settaglist($table);
$optlist->setauthorlist($table);
@@ -53,11 +53,11 @@ class Modelhome extends Modelart
$filter = array_intersect($filtertagfilter, $filtersecure, $filterauthorfilter);
$table2 = [];
$table2invert = [];
- foreach ($table as $art) {
- if (in_array($art->id(), $filter)) {
- $table2[] = $art;
+ foreach ($table as $page) {
+ if (in_array($page->id(), $filter)) {
+ $table2[] = $page;
} else {
- $table2invert[] = $art;
+ $table2invert[] = $page;
}
@@ -67,7 +67,7 @@ class Modelhome extends Modelart
$table2 = $table2invert;
}
- $this->artlistsort($table2, $opt->sortby(), $opt->order());
+ $this->pagelistsort($table2, $opt->sortby(), $opt->order());
if($opt->limit() !== 0) {
$table2 = array_slice($table2, 0, $opt->limit());
diff --git a/app/class/modelpage.php b/app/class/modelpage.php
new file mode 100644
index 0000000..a47ebdb
--- /dev/null
+++ b/app/class/modelpage.php
@@ -0,0 +1,306 @@
+<?php
+class Modelpage extends Modeldb
+{
+
+ const SELECT = ['title', 'id', 'description', 'tag', 'date', 'datecreation', 'datemodif', 'daterender', 'css', 'quickcss', 'javascript', 'body', 'header', 'main', 'nav', 'aside', 'footer', 'render', 'secure', 'invitepassword', 'interface', 'linkfrom', 'linkto', 'template', 'affcount', 'editcount'];
+ const BY = ['datecreation', 'title', 'id', 'description', 'datemodif', 'secure'];
+ const ORDER = ['DESC', 'ASC'];
+
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->storeinit(Config::pagetable());
+ if(!$this->dircheck(Model::HTML_RENDER_DIR)) {
+ throw new Exception("Media error : Cant create /rendernew folder");
+ }
+ }
+
+ /**
+ * Scan library for all pages as objects
+ *
+ * @return array of Pages objects
+ */
+ public function getlister()
+ {
+ $pagelist = [];
+ $list = $this->repo->findAll();
+ foreach ($list as $pagedata) {
+ $pagelist[$pagedata->id] = new Page($pagedata);
+ }
+ return $pagelist;
+ }
+
+
+ public function getlisterid(array $idlist = [])
+ {
+ $pagedatalist = $this->repo->query()
+ ->where('__id', 'IN', $idlist)
+ ->execute();
+
+ $pagelist = [];
+ foreach ($pagedatalist as $id => $pagedata) {
+ $pagelist[$id] = new Page($pagedata);
+ }
+ return $pagelist;
+ }
+
+ public function add(Page $page)
+ {
+
+ $pagedata = new \JamesMoss\Flywheel\Document($page->dry());
+ $pagedata->setId($page->id());
+ $this->repo->store($pagedata);
+ }
+
+ /**
+ * Obtain a page object from the database
+ *
+ * @param Page|string $id could be an Page object or a id string
+ *
+ * @return Page|false The Page object or false if it does not exist.
+ */
+ public function get($id)
+ {
+ if ($id instanceof Page) {
+ $id = $id->id();
+ }
+ if (is_string($id)) {
+ $pagedata = $this->repo->findById($id);
+ if ($pagedata !== false) {
+ return new Page($pagedata);
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Transform File to Page Oject
+ *
+ * @return false|Page
+ */
+ public function getfromfile()
+ {
+ if(!isset($_FILES['pagefile']) || $_FILES['pagefile']['error'] > 0 ) return false;
+
+ $ext = substr(strrchr($_FILES['pagefile']['name'],'.'),1);
+ if($ext !== 'json') return false;
+
+ $files = $_FILES;
+
+ $json = file_get_contents($_FILES['pagefile']['tmp_name']);
+ $pagedata = json_decode($json, true);
+
+ if($pagedata === false) return false;
+
+ $page = new Page($pagedata);
+
+ return $page;
+
+ }
+
+ public function getpageelement($id, $element)
+ {
+ if (in_array($element, Model::TEXT_ELEMENTS)) {
+ $page = $this->get($id);
+ if ($page !== false) {
+ return $page->$element();
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public function delete(Page $page)
+ {
+ $this->repo->delete($page->id());
+ $this->unlink($page->id());
+ }
+
+
+ public function unlink(string $pageid)
+ {
+ $files = ['.css', '.quick.css', '.js'];
+ foreach ($files as $file) {
+ if (file_exists(Model::RENDER_DIR . $pageid . $file)) {
+ unlink(Model::RENDER_DIR . $pageid . $file);
+ }
+ }
+ if(file_exists(Model::HTML_RENDER_DIR . $pageid . '.html')) {
+ unlink(Model::HTML_RENDER_DIR . $pageid . '.html');
+ }
+ }
+
+ public function update(Page $page)
+ {
+ $pagedata = new \JamesMoss\Flywheel\Document($page->dry());
+ $pagedata->setId($page->id());
+ $this->repo->store($pagedata);
+ }
+
+ public function combine(Page $pagea, Page $pageb)
+ {
+ $mergepage = $pagea;
+ $merge = [];
+ $diff = [];
+ foreach ($pagea::TABS as $element) {
+ if($pagea->$element() !== $pageb->$element()) {
+ $merge[$element] = compare($pagea->$element(), $pageb->$element());
+ $diff[] = $element;
+ }
+ }
+ $mergepage->hydrate($merge);
+
+ return ['diff' => $diff, 'mergepage' => $mergepage];
+ }
+
+ // public function diffpageelement(Page $pagea, Page $pageb)
+ // {
+ // $diff = [];
+ // foreach ($pagea::TABS as $element) {
+ // if($pagea->$element() !== $pageb->$element()) {
+ // $diff[] = $element;
+ // }
+ // }
+ // return $diff;
+ // }
+
+ public function pagecompare($page1, $page2, $method = 'id', $order = 1)
+ {
+ $result = ($page1->$method('sort') <=> $page2->$method('sort'));
+ return $result * $order;
+ }
+
+ public function buildsorter($sortby, $order)
+ {
+ return function ($page1, $page2) use ($sortby, $order) {
+ $result = $this->pagecompare($page1, $page2, $sortby, $order);
+ return $result;
+ };
+ }
+
+
+
+ public function pagelistsort(&$pagelist, $sortby, $order = 1)
+ {
+ return usort($pagelist, $this->buildsorter($sortby, $order));
+ }
+
+
+ /**
+ * @param array $pagelist List of Page
+ * @param array $tagchecked list of tags
+ * @param string $tagcompare string, can be 'OR' or 'AND', set the tag filter method
+ * @return array $array
+ */
+
+ public function filtertagfilter(array $pagelist, array $tagchecked, $tagcompare = 'OR')
+ {
+
+ $filteredlist = [];
+ foreach ($pagelist as $page) {
+ if (empty($tagchecked)) {
+ $filteredlist[] = $page->id();
+ } else {
+ $inter = (array_intersect($page->tag('array'), $tagchecked));
+ if ($tagcompare == 'OR') {
+ if (!empty($inter)) {
+ $filteredlist[] = $page->id();
+ }
+ } elseif ($tagcompare == 'AND') {
+ if (!array_diff($tagchecked, $page->tag('array'))) {
+ $filteredlist[] = $page->id();
+ }
+ }
+ }
+ }
+ return $filteredlist;
+ }
+
+ public function filterauthorfilter(array $pagelist, array $authorchecked, $authorcompare = 'OR')
+ {
+
+ $filteredlist = [];
+ foreach ($pagelist as $page) {
+ if (empty($authorchecked)) {
+ $filteredlist[] = $page->id();
+ } else {
+ $inter = (array_intersect($page->authors('array'), $authorchecked));
+ if ($authorcompare == 'OR') {
+ if (!empty($inter)) {
+ $filteredlist[] = $page->id();
+ }
+ } elseif ($authorcompare == 'AND') {
+ if (!array_diff($authorchecked, $page->authors('array'))) {
+ $filteredlist[] = $page->id();
+ }
+ }
+ }
+ }
+ return $filteredlist;
+ }
+
+ public function filtersecure(array $pagelist, $secure)
+ {
+ $filteredlist = [];
+ foreach ($pagelist as $page) {
+ if ($page->secure() == intval($secure)) {
+ $filteredlist[] = $page->id();
+ } elseif (intval($secure) >= 4) {
+ $filteredlist[] = $page->id();
+ }
+ }
+ return $filteredlist;
+ }
+
+
+ public function tag(array $pagelist, $tagchecked)
+ {
+ $pagecheckedlist = [];
+ foreach ($pagelist as $page) {
+ if (in_array($tagchecked, $page->tag('array'))) {
+ $pagecheckedlist[] = $page;
+ }
+ }
+ return $pagecheckedlist;
+ }
+
+ public function taglist(array $pagelist, array $tagcheckedlist)
+ {
+ $taglist = [];
+ foreach ($tagcheckedlist as $tag) {
+ $taglist[$tag] = $this->tag($pagelist, $tag);
+ }
+ return $taglist;
+ }
+
+ /**
+ * @param array $taglist list of tags
+ * @param array $pagelist list of Page
+ * @return array list of tags each containing list of id
+ */
+
+ public function tagpagelist(array $taglist, array $pagelist)
+ {
+ $tagpagelist = [];
+ foreach ($taglist as $tag) {
+ $tagpagelist[$tag] = $this->filtertagfilter($pagelist, [$tag]);
+ }
+ return $tagpagelist;
+ }
+
+ public function lasteditedpagelist(int $last, array $pagelist)
+ {
+ $this->pagelistsort($pagelist, 'datemodif', -1);
+ $pagelist = array_slice($pagelist, 0, $last);
+ $idlist = [];
+ foreach ($pagelist as $page) {
+ $idlist[] = $page->id();
+ }
+ return $idlist;
+ }
+
+}
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index d74ddec..237d9b5 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -1,11 +1,11 @@
<?php
-class Modelrender extends Modelart
+class Modelrender extends Modelpage
{
protected $router;
- /** @var art2 */
- protected $art;
- protected $artlist;
+ /** @var page2 */
+ protected $page;
+ protected $pagelist;
protected $linkfrom = [];
protected $sum = [];
protected $internallinkblank = '';
@@ -20,7 +20,7 @@ class Modelrender extends Modelart
parent::__construct();
$this->router = $router;
- $this->artlist = $this->getlister();
+ $this->pagelist = $this->getlister();
if(Config::internallinkblank()) {
$this->internallinkblank = ' target="_blank" ';
@@ -31,20 +31,20 @@ class Modelrender extends Modelart
}
}
- public function uart($id)
+ public function upage($id)
{
- return $this->router->generate('artread/', ['art' => $id]);
+ return $this->router->generate('pageread/', ['page' => $id]);
}
/**
* Main function
*
- * @param Art2 $art page to render
+ * @param Page $page page to render
*/
- public function render(Art2 $art)
+ public function render(Page $page)
{
- $this->art = $art;
+ $this->page = $page;
$this->write($this->gethmtl());
}
@@ -69,17 +69,17 @@ class Modelrender extends Modelart
public function readbody()
{
- if (!empty($this->art->templatebody())) {
- $templateid = $this->art->templatebody();
- $templateart = $this->get($templateid);
- if($templateart !== false) {
- $body = $templateart->body();
+ if (!empty($this->page->templatebody())) {
+ $templateid = $this->page->templatebody();
+ $templatepage = $this->get($templateid);
+ if($templatepage !== false) {
+ $body = $templatepage->body();
} else {
- $body = $this->art->body();
- $this->art->settemplatebody('');
+ $body = $this->page->body();
+ $this->page->settemplatebody('');
}
} else {
- $body = $this->art->body();
+ $body = $this->page->body();
}
$body = $this->article($body);
$body = $this->automedialist($body);
@@ -115,7 +115,7 @@ class Modelrender extends Modelart
// First, analyse the synthax and call the corresponding methods
if(isset($matches)) {
foreach ($matches as $key => $match) {
- $element = new Element($match, $this->art->id());
+ $element = new Element($match, $this->page->id());
$element->setcontent($this->getelementcontent($element));
$element->setcontent($this->elementparser($element));
$element->addtags();
@@ -136,8 +136,8 @@ class Modelrender extends Modelart
$subseparator = PHP_EOL . PHP_EOL;
foreach($element->sources() as $source)
{
- if($source !== $this->art->id()) {
- $subcontent = $this->getartelement($source, $element->type());
+ if($source !== $this->page->id()) {
+ $subcontent = $this->getpageelement($source, $element->type());
if($subcontent !== false) {
if(empty($subcontent && self::RENDER_VERBOSE > 0)) {
$subcontent = PHP_EOL . '<!-- The ' . strtoupper($element->type()) . ' from page "' . $source . '" is currently empty ! -->' . PHP_EOL;
@@ -149,7 +149,7 @@ class Modelrender extends Modelart
} else {
$type = $element->type();
- $subcontent = $this->art->$type();
+ $subcontent = $this->page->$type();
}
$content .= $subseparator . $subcontent;
}
@@ -183,27 +183,27 @@ class Modelrender extends Modelart
*/
public function write(string $html)
{
- file_put_contents(Model::HTML_RENDER_DIR . $this->art->id() . '.html', $html);
- file_put_contents(Model::RENDER_DIR . $this->art->id() . '.css', $this->art->css());
- //file_put_contents(Model::RENDER_DIR . $this->art->id() . '.quick.css', $this->art->quickcss());
- file_put_contents(Model::RENDER_DIR . $this->art->id() . '.js', $this->art->javascript());
+ file_put_contents(Model::HTML_RENDER_DIR . $this->page->id() . '.html', $html);
+ file_put_contents(Model::RENDER_DIR . $this->page->id() . '.css', $this->page->css());
+ //file_put_contents(Model::RENDER_DIR . $this->page->id() . '.quick.css', $this->page->quickcss());
+ file_put_contents(Model::RENDER_DIR . $this->page->id() . '.js', $this->page->javascript());
}
public function writetemplates()
{
- if (array_key_exists('css', $this->art->template('array'))) {
- $tempaltecssart = $this->get($this->art->template('array')['css']);
- file_put_contents(Model::RENDER_DIR . $tempaltecssart->id() . '.css', $tempaltecssart->css());
+ if (array_key_exists('css', $this->page->template('array'))) {
+ $tempaltecsspage = $this->get($this->page->template('array')['css']);
+ file_put_contents(Model::RENDER_DIR . $tempaltecsspage->id() . '.css', $tempaltecsspage->css());
}
- if (array_key_exists('quickcss', $this->art->template('array'))) {
- $tempaltequickcssart = $this->get($this->art->template('array')['quickcss']);
- file_put_contents(Model::RENDER_DIR . $tempaltequickcssart->id() . '.quick.css', $tempaltequickcssart->quickcss());
+ if (array_key_exists('quickcss', $this->page->template('array'))) {
+ $tempaltequickcsspage = $this->get($this->page->template('array')['quickcss']);
+ file_put_contents(Model::RENDER_DIR . $tempaltequickcsspage->id() . '.quick.css', $tempaltequickcsspage->quickcss());
}
- if (array_key_exists('javascript', $this->art->template('array'))) {
- $templatejsart = $this->get($this->art->template('array')['javascript']);
- file_put_contents(Model::RENDER_DIR . $templatejsart->id() . '.js', $templatejsart->javascript());
+ if (array_key_exists('javascript', $this->page->template('array'))) {
+ $templatejspage = $this->get($this->page->template('array')['javascript']);
+ file_put_contents(Model::RENDER_DIR . $templatejspage->id() . '.js', $templatejspage->javascript());
}
}
@@ -216,32 +216,32 @@ class Modelrender extends Modelart
$head = '';
$head .= '<meta charset="utf8" />' . PHP_EOL;
- $head .= '<title>' . $this->art->title() . '</title>' . PHP_EOL;
- if (!empty($this->art->favicon())) {
- $head .= '<link rel="shortcut icon" href="' . Model::faviconpath() . $this->art->favicon() . '" type="image/x-icon">';
+ $head .= '<title>' . $this->page->title() . '</title>' . PHP_EOL;
+ if (!empty($this->page->favicon())) {
+ $head .= '<link rel="shortcut icon" href="' . Model::faviconpath() . $this->page->favicon() . '" type="image/x-icon">';
} elseif (!empty(Config::defaultfavicon())) {
$head .= '<link rel="shortcut icon" href="' . Model::faviconpath() . Config::defaultfavicon() . '" type="image/x-icon">';
}
- $head .= '<meta name="description" content="' . $this->art->description() . '" />' . PHP_EOL;
+ $head .= '<meta name="description" content="' . $this->page->description() . '" />' . PHP_EOL;
$head .= '<meta name="viewport" content="width=device-width" />' . PHP_EOL;
- $head .= '<meta property="og:title" content="' . $this->art->title() . '">' . PHP_EOL;
- $head .= '<meta property="og:description" content="' . $this->art->description() . '">' . PHP_EOL;
+ $head .= '<meta property="og:title" content="' . $this->page->title() . '">' . PHP_EOL;
+ $head .= '<meta property="og:description" content="' . $this->page->description() . '">' . PHP_EOL;
- if($this->art->thumbnailexist()) {
- $head .= '<meta property="og:image" content="' . Config::domain() . self::thumbnailpath() . $this->art->id() . '.jpg">' . PHP_EOL;
+ if($this->page->thumbnailexist()) {
+ $head .= '<meta property="og:image" content="' . Config::domain() . self::thumbnailpath() . $this->page->id() . '.jpg">' . PHP_EOL;
}
- $head .= '<meta property="og:url" content="' . Config::url() . $this->art->id() . '/">' . PHP_EOL;
+ $head .= '<meta property="og:url" content="' . Config::url() . $this->page->id() . '/">' . PHP_EOL;
- foreach ($this->art->externalcss() as $externalcss) {
+ foreach ($this->page->externalcss() as $externalcss) {
$head .= '<link href="' . $externalcss . '" rel="stylesheet" />' . PHP_EOL;
}
- if (!empty($this->art->templatecss() && in_array('externalcss', $this->art->templateoptions()))) {
- $templatecss = $this->get($this->art->templatecss());
+ if (!empty($this->page->templatecss() && in_array('externalcss', $this->page->templateoptions()))) {
+ $templatecss = $this->get($this->page->templatecss());
if($templatecss !== false) {
foreach ($templatecss->externalcss() as $externalcss) {
@@ -250,24 +250,24 @@ class Modelrender extends Modelart
}
}
- $head .= PHP_EOL . $this->art->customhead() . PHP_EOL;
+ $head .= PHP_EOL . $this->page->customhead() . PHP_EOL;
$head .= '<link href="' . Model::globalpath() . 'fonts.css" rel="stylesheet" />' . PHP_EOL;
$head .= '<link href="' . Model::globalpath() . 'global.css" rel="stylesheet" />' . PHP_EOL;
- if (!empty($this->art->templatecss())) {
- $tempaltecssart = $this->art->templatecss();
- $head .= '<link href="' . Model::renderpath() . $tempaltecssart . '.css" rel="stylesheet" />' . PHP_EOL;
+ if (!empty($this->page->templatecss())) {
+ $tempaltecsspage = $this->page->templatecss();
+ $head .= '<link href="' . Model::renderpath() . $tempaltecsspage . '.css" rel="stylesheet" />' . PHP_EOL;
}
- $head .= '<link href="' . Model::renderpath() . $this->art->id() . '.css" rel="stylesheet" />' . PHP_EOL;
+ $head .= '<link href="' . Model::renderpath() . $this->page->id() . '.css" rel="stylesheet" />' . PHP_EOL;
- if (!empty($this->art->templatejavascript())) {
- $templatejsart = $this->art->templatejavascript();
- $head .= '<script src="' . Model::renderpath() . $templatejsart . '.js" async/></script>' . PHP_EOL;
+ if (!empty($this->page->templatejavascript())) {
+ $templatejspage = $this->page->templatejavascript();
+ $head .= '<script src="' . Model::renderpath() . $templatejspage . '.js" async/></script>' . PHP_EOL;
}
- if (!empty($this->art->javascript())) {
- $head .= '<script src="' . Model::renderpath() . $this->art->id() . '.js" async/></script>' . PHP_EOL;
+ if (!empty($this->page->javascript())) {
+ $head .= '<script src="' . Model::renderpath() . $this->page->id() . '.js" async/></script>' . PHP_EOL;
}
if (!empty(Config::analytics())) {
@@ -308,7 +308,7 @@ class Modelrender extends Modelart
$text = $this->wurl($text);
$text = $this->wikiurl($text);
- $text = $this->desctitle($text, $this->art->description(), $this->art->title());
+ $text = $this->desctitle($text, $this->page->description(), $this->page->title());
$text = str_replace('href="http', ' class="external" target="_blank" href="http', $text);
@@ -343,12 +343,12 @@ class Modelrender extends Modelart
$text = preg_replace_callback(
'%href="([\w-]+)\/?(#?[a-z-_]*)"%',
function ($matches) use ($rend, &$linkfrom) {
- $matchart = $rend->get($matches[1]);
- if (!$matchart) {
- $link = 'href="' . $rend->uart($matches[1]) . '"" title="' . Config::existnot() . '" class="internal existnot"' . $this->internallinkblank;
+ $matchpage = $rend->get($matches[1]);
+ if (!$matchpage) {
+ $link = 'href="' . $rend->upage($matches[1]) . '"" title="' . Config::existnot() . '" class="internal existnot"' . $this->internallinkblank;
} else {
- $linkfrom[] = $matchart->id();
- $link = 'href="' . $rend->uart($matches[1]) . $matches[2] . '" title="' . $matchart->description() . '" class="internal exist '. $matchart->secure('string') .'"' . $this->internallinkblank;
+ $linkfrom[] = $matchpage->id();
+ $link = 'href="' . $rend->upage($matches[1]) . $matches[2] . '" title="' . $matchpage->description() . '" class="internal exist '. $matchpage->secure('string') .'"' . $this->internallinkblank;
}
return $link;
},
@@ -365,12 +365,12 @@ class Modelrender extends Modelart
$text = preg_replace_callback(
'%\[([\w-]+)\/?#?([a-z-_]*)\]%',
function ($matches) use ($rend, &$linkfrom) {
- $matchart = $rend->get($matches[1]);
- if (!$matchart) {
- return '<a href="' . $rend->uart($matches[1]) . '"" title="' . Config::existnot() . '" class="internal existnot" '. $this->internallinkblank .' >' . $matches[1] . '</a>';
+ $matchpage = $rend->get($matches[1]);
+ if (!$matchpage) {
+ return '<a href="' . $rend->upage($matches[1]) . '"" title="' . Config::existnot() . '" class="internal existnot" '. $this->internallinkblank .' >' . $matches[1] . '</a>';
} else {
- $linkfrom[] = $matchart->id();
- return '<a href="' . $rend->uart($matches[1]) . $matches[2] . '" title="' . $matchart->description() . '" class="internal exist '. $matchart->secure('string') .'" '. $this->internallinkblank .' >' . $matchart->title() . '</a>';
+ $linkfrom[] = $matchpage->id();
+ return '<a href="' . $rend->upage($matches[1]) . $matches[2] . '" title="' . $matchpage->description() . '" class="internal exist '. $matchpage->secure('string') .'" '. $this->internallinkblank .' >' . $matchpage->title() . '</a>';
}
},
$text
@@ -499,21 +499,21 @@ class Modelrender extends Modelart
$taglist = $this->autotaglist($text);
foreach ($taglist as $tag) {
$li = [];
- foreach ($this->artlist as $item) {
+ foreach ($this->pagelist as $item) {
if (in_array($tag, $item->tag('array'))) {
$li[] = $item;
}
}
$ul = '<ul class="taglist" id="' . $tag . '">' . PHP_EOL;
- $this->artlistsort($li, 'date', -1);
+ $this->pagelistsort($li, 'date', -1);
foreach ($li as $item) {
- if ($item->id() === $this->art->id()) {
+ if ($item->id() === $this->page->id()) {
$actual = ' actualpage';
} else {
$actual = '';
}
- $ul .= '<li><a href="' . $this->router->generate('artread/', ['art' => $item->id()]) . '" title="' . $item->description() . '" class="internal' . $actual . '" '. $this->internallinkblank .' >' . $item->title() . '</a></li>' . PHP_EOL;
+ $ul .= '<li><a href="' . $this->router->generate('pageread/', ['page' => $item->id()]) . '" title="' . $item->description() . '" class="internal' . $actual . '" '. $this->internallinkblank .' >' . $item->title() . '</a></li>' . PHP_EOL;
}
$ul .= '</ul>' . PHP_EOL;
@@ -531,12 +531,12 @@ class Modelrender extends Modelart
public function date(string $text)
{
- $art = $this->art;
- $text = preg_replace_callback('~\%DATE\%~', function ($matches) use ($art) {
- return '<time datetime=' . $art->date('string') . '>' . $art->date('dmy') . '</time>';
+ $page = $this->page;
+ $text = preg_replace_callback('~\%DATE\%~', function ($matches) use ($page) {
+ return '<time datetime=' . $page->date('string') . '>' . $page->date('dmy') . '</time>';
}, $text);
- $text = preg_replace_callback('~\%TIME\%~', function ($matches) use ($art) {
- return '<time datetime=' . $art->date('string') . '>' . $art->date('ptime') . '</time>';
+ $text = preg_replace_callback('~\%TIME\%~', function ($matches) use ($page) {
+ return '<time datetime=' . $page->date('string') . '>' . $page->date('ptime') . '</time>';
}, $text);
return $text;
@@ -551,7 +551,7 @@ class Modelrender extends Modelart
*/
public function thumbnail(string $text) : string
{
- $img = '<img class="thumbnail" src="' . Model::thumbnailpath() . $this->art->id() . '.jpg" alt="' . $this->art->title() . '">';
+ $img = '<img class="thumbnail" src="' . Model::thumbnailpath() . $this->page->id() . '.jpg" alt="' . $this->page->title() . '">';
$img = PHP_EOL . $img . PHP_EOL;
$text = str_replace('%THUMBNAIL%', $img, $text);
@@ -592,7 +592,7 @@ class Modelrender extends Modelart
*/
public function authenticate(string $text)
{
- $id = $this->art->id();
+ $id = $this->page->id();
$regex = '~\%CONNECT(\?dir=([a-zA-Z0-9-_]+))?\%~';
$text = preg_replace_callback($regex, function ($matches) use ($id) {
if(isset($matches[2])) {
@@ -600,7 +600,7 @@ class Modelrender extends Modelart
}
$form = '<form action="/!co" method="post">
<input type="password" name="pass" id="loginpass" placeholder="password">
- <input type="hidden" name="route" value="artread/">
+ <input type="hidden" name="route" value="pageread/">
<input type="hidden" name="id" value="' . $id . '">
<input type="submit" name="log" value="login" id="button">
</form>';
@@ -625,14 +625,14 @@ class Modelrender extends Modelart
if(isset($matches)) {
foreach ($matches as $match) {
- $optlist = $modelhome->Optlistinit($this->artlist);
+ $optlist = $modelhome->Optlistinit($this->pagelist);
$optlist->parsehydrate($match['options']);
- $table2 = $modelhome->table2($this->artlist, $optlist);
+ $table2 = $modelhome->table2($this->pagelist, $optlist);
$content = '<ul>' . PHP_EOL ;
foreach ($table2 as $page ) {
$content .= '<li>' . PHP_EOL;
- $content .= '<a href="' . $this->uart($page->id()) . '">' . $page->title() . '</a>' . PHP_EOL;
+ $content .= '<a href="' . $this->upage($page->id()) . '">' . $page->title() . '</a>' . PHP_EOL;
if($optlist->description()) {
$content .= '<em>' . $page->description() . '</em>' . PHP_EOL;
}
@@ -673,9 +673,9 @@ class Modelrender extends Modelart
public function linkto()
{
$linkto = [];
- foreach ($this->artlist as $art) {
- if (in_array($this->art->id(), $art->linkfrom())) {
- $linkto[] = $art->id();
+ foreach ($this->pagelist as $page) {
+ if (in_array($this->page->id(), $page->linkfrom())) {
+ $linkto[] = $page->id();
}
}
return $linkto;
diff --git a/app/class/modeltimeline.php b/app/class/modeltimeline.php
index b575dda..fa4f709 100644
--- a/app/class/modeltimeline.php
+++ b/app/class/modeltimeline.php
@@ -3,7 +3,7 @@
class Modeltimeline extends Modeldb
{
const EVENT_BASE = ['message'];
- const EVENT_ART = ['art_add', 'art_edit', 'art_delete'];
+ const EVENT_ART = ['page_add', 'page_edit', 'page_delete'];
const EVENT_MEDIA = ['media_add', 'media_delete'];
const EVENT_FONT = ['font_add', 'font_delete'];
diff --git a/app/class/opt.php b/app/class/opt.php
index 1cfa299..bf732c5 100644
--- a/app/class/opt.php
+++ b/app/class/opt.php
@@ -16,7 +16,7 @@ class Opt
protected $invert = 0;
protected $limit= 0;
- protected $artvarlist;
+ protected $pagevarlist;
public function __construct(array $donnees = [])
{
@@ -131,7 +131,7 @@ class Opt
{
$class = get_class_vars(get_class($this));
$object = get_object_vars($this);
- $class['artvarlist'] = $object['artvarlist'];
+ $class['pagevarlist'] = $object['pagevarlist'];
$class['taglist'] = $object['taglist'];
$class['authorlist'] = $object['authorlist'];
$query = array_diff_assoc_recursive($object, $class);
@@ -213,9 +213,9 @@ class Opt
return $this->invert;
}
- public function artvarlist()
+ public function pagevarlist()
{
- return $this->artvarlist;
+ return $this->pagevarlist;
}
public function limit()
@@ -228,7 +228,7 @@ class Opt
public function setsortby($sortby)
{
- if (is_string($sortby) && in_array($sortby, $this->artvarlist)) {
+ if (is_string($sortby) && in_array($sortby, $this->pagevarlist)) {
$this->sortby = strtolower(strip_tags($sortby));
}
}
@@ -321,15 +321,15 @@ class Opt
public function setcol($col)
{
if (is_array($col)) {
- $this->col = array_intersect($this->artvarlist(), $col);
+ $this->col = array_intersect($this->pagevarlist(), $col);
}
}
- public function settaglist(array $artlist)
+ public function settaglist(array $pagelist)
{
$taglist = [];
- foreach ($artlist as $art) {
- foreach ($art->tag('array') as $tag) {
+ foreach ($pagelist as $page) {
+ foreach ($page->tag('array') as $tag) {
if (!array_key_exists($tag, $taglist)) {
$taglist[$tag] = 1;
} else {
@@ -341,11 +341,11 @@ class Opt
$this->taglist = $taglist;
}
- public function setauthorlist(array $artlist)
+ public function setauthorlist(array $pagelist)
{
$authorlist = [];
- foreach ($artlist as $art) {
- foreach ($art->authors('array') as $author) {
+ foreach ($pagelist as $page) {
+ foreach ($page->authors('array') as $author) {
if (!array_key_exists($author, $authorlist)) {
$authorlist[$author] = 1;
} else {
@@ -378,8 +378,8 @@ class Opt
}
- public function setartvarlist(array $artvarlist)
+ public function setpagevarlist(array $pagevarlist)
{
- $this->artvarlist = $artvarlist;
+ $this->pagevarlist = $pagevarlist;
}
}
diff --git a/app/class/art2.php b/app/class/page.php
index 754ba14..299e448 100644
--- a/app/class/art2.php
+++ b/app/class/page.php
@@ -1,6 +1,6 @@
<?php
-class Art2
+class Page
{
protected $id;
protected $title;
@@ -116,7 +116,7 @@ class Art2
foreach (get_class_vars(__class__) as $var => $default) {
$classvarlist[] = $var;
}
- return ['artvarlist' => $classvarlist];
+ return ['pagevarlist' => $classvarlist];
}
public function dry()
diff --git a/app/class/route.php b/app/class/route.php
index cc2fe59..8e58945 100644
--- a/app/class/route.php
+++ b/app/class/route.php
@@ -28,7 +28,7 @@ class Route
{
$array = [];
if (!empty($this->id)) {
- $array[] = 'art';
+ $array[] = 'page';
}
if (!empty($this->aff)) {
$array[] = 'aff='.$this->aff;
diff --git a/app/class/routes.php b/app/class/routes.php
index 4119e58..44f30bd 100644
--- a/app/class/routes.php
+++ b/app/class/routes.php
@@ -19,7 +19,7 @@ class Routes
['POST', '/columns', 'Controllerhome#columns', 'homecolumns'],
['GET', '//renderall', 'Controllerhome#renderall', 'homerenderall'],
['POST', '/bookmark', 'Controllerhome#bookmark', 'homebookmark'],
- ['POST', '/upload', 'Controllerart#upload', 'artupload'],
+ ['POST', '/upload', 'Controllerpage#upload', 'pageupload'],
['POST', '/!co', 'Controllerconnect#log', 'log'],
['GET', '/!co', 'Controllerconnect#connect', 'connect'],
['POST', '/!search', 'Controllerhome#search', 'search'],
@@ -41,19 +41,19 @@ class Routes
['GET', '/!timeline', 'Controllertimeline#desktop', 'timeline'],
['POST', '/!timeline/add', 'Controllertimeline#add', 'timelineadd'],
['POST', '/!timeline/clap', 'Controllertimeline#clap', 'timelineclap'],
- ['GET', '/[cid:art]/', 'Controllerart#read', 'artread/'],
- ['GET', '/[cid:art]', 'Controllerart#read', 'artread'],
- ['GET', '/[cid:art]/add', 'Controllerart#add', 'artadd'],
- ['GET', '/[cid:art]/edit', 'Controllerart#edit', 'artedit'],
- ['GET', '/[cid:art]/render', 'Controllerart#render', 'artrender'],
- ['GET', '/[cid:art]/log', 'Controllerart#log', 'artlog'],
- ['GET', '/[cid:art]/download', 'Controllerart#download', 'artdownload'],
- ['POST', '/[cid:art]/edit', 'Controllerart#update', 'artupdate'],
- ['POST', '/[cid:art]/editby', 'Controllerart#editby', 'arteditby'],
- ['POST', '/[cid:art]/removeeditby', 'Controllerart#removeeditby', 'artremoveeditby'],
- ['GET', '/[cid:art]/delete', 'Controllerart#confirmdelete', 'artconfirmdelete'],
- ['POST', '/[cid:art]/delete', 'Controllerart#delete', 'artdelete'],
- ['GET', '/[cid:art]/[*]', 'Controllerart#artdirect', 'artread/etoile'],
+ ['GET', '/[cid:page]/', 'Controllerpage#read', 'pageread/'],
+ ['GET', '/[cid:page]', 'Controllerpage#read', 'pageread'],
+ ['GET', '/[cid:page]/add', 'Controllerpage#add', 'pageadd'],
+ ['GET', '/[cid:page]/edit', 'Controllerpage#edit', 'pageedit'],
+ ['GET', '/[cid:page]/render', 'Controllerpage#render', 'pagerender'],
+ ['GET', '/[cid:page]/log', 'Controllerpage#log', 'pagelog'],
+ ['GET', '/[cid:page]/download', 'Controllerpage#download', 'pagedownload'],
+ ['POST', '/[cid:page]/edit', 'Controllerpage#update', 'pageupdate'],
+ ['POST', '/[cid:page]/editby', 'Controllerpage#editby', 'pageeditby'],
+ ['POST', '/[cid:page]/removeeditby', 'Controllerpage#removeeditby', 'pageremoveeditby'],
+ ['GET', '/[cid:page]/delete', 'Controllerpage#confirmdelete', 'pageconfirmdelete'],
+ ['POST', '/[cid:page]/delete', 'Controllerpage#delete', 'pagedelete'],
+ ['GET', '/[cid:page]/[*]', 'Controllerpage#pagedirect', 'pageread/etoile'],
]);
$match = $router->match();
@@ -70,7 +70,7 @@ class Routes
else {
if(!empty(Config::route404())) {
$controller = new Controller($router);
- $controller->routedirect('artread/', ['art' => Config::route404()]);
+ $controller->routedirect('pageread/', ['page' => Config::route404()]);
} else {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}
diff --git a/app/view/templates/admin.php b/app/view/templates/admin.php
index c1f3b73..46e5045 100644
--- a/app/view/templates/admin.php
+++ b/app/view/templates/admin.php
@@ -47,9 +47,9 @@
<option value="" <?= Config::homeredirect() === null ? 'selected' : '' ?>>--select page to redirect--</option>
<?php
- foreach ($artlist as $art) {
+ foreach ($pagelist as $page) {
?>
- <option value="<?= $art ?>" <?= Config::homeredirect() === $art ? 'selected' : '' ?>><?= $art ?></option>
+ <option value="<?= $page ?>" <?= Config::homeredirect() === $page ? 'selected' : '' ?>><?= $page ?></option>
<?php
}
@@ -76,19 +76,19 @@
- <label for="defaultart">Or, create new page BODY based on an already existing one</label>
- <select name="defaultart" id="defaultart">
- <option value="" <?= Config::defaultart() === '' || !$defaultartexist ? 'selected' : '' ?>>--use default BODY element--</option>
+ <label for="defaultpage">Or, create new page BODY based on an already existing one</label>
+ <select name="defaultpage" id="defaultpage">
+ <option value="" <?= Config::defaultpage() === '' || !$defaultpageexist ? 'selected' : '' ?>>--use default BODY element--</option>
<?php
- foreach ($artlist as $art) {
+ foreach ($pagelist as $page) {
?>
- <option value="<?= $art ?>" <?= Config::defaultart() === $art ? 'selected' : '' ?>><?= $art ?></option>
+ <option value="<?= $page ?>" <?= Config::defaultpage() === $page ? 'selected' : '' ?>><?= $page ?></option>
<?php }
?>
</select>
<?php
- if (empty(!$defaultartexist || Config::defaultart())) {
+ if (empty(!$defaultpageexist || Config::defaultpage())) {
?>
<label for="defaultbody">Edit default BODY element</label>
<textarea name="defaultbody" id="defaultbody" cols="30" rows="10"><?= Config::defaultbody() ?></textarea>
@@ -114,9 +114,9 @@
<select name="alertlink" id="alertlink">
<option value="" <?= empty(Config::alertlink()) ? 'selected' : '' ?>>--No link--</option>
<?php
- foreach ($artlist as $art) {
+ foreach ($pagelist as $page) {
?>
- <option value="<?= $art ?>" <?= Config::alertlink() === $art ? 'selected' : '' ?>><?= $art ?></option>
+ <option value="<?= $page ?>" <?= Config::alertlink() === $page ? 'selected' : '' ?>><?= $page ?></option>
<?php }
?>
</select>
diff --git a/app/view/templates/alert.php b/app/view/templates/alert.php
index 24f77ed..c4a54b1 100644
--- a/app/view/templates/alert.php
+++ b/app/view/templates/alert.php
@@ -35,14 +35,14 @@ $this->stop();
$form = '<p>
<form action="' . $this->url('log') .'" method="post">
<input type="password" name="pass" id="loginpass" placeholder="password">
- <input type="hidden" name="route" value="artread/">
- <input type="hidden" name="id" value="' . $art->id() . '">
+ <input type="hidden" name="route" value="pageread/">
+ <input type="hidden" name="id" value="' . $page->id() . '">
<input type="submit" name="log" value="login" id="button">
</form>
</p>';
- if(!$artexist) {
+ if(!$pageexist) {
if(!empty(Config::existnot())) {
echo '<h2>' . Config::existnot() . '</h2>';
}
@@ -53,7 +53,7 @@ $this->stop();
- switch ($art->secure()) {
+ switch ($page->secure()) {
case 1:
if(!empty(Config::private())) {
echo '<h2>' . Config::private() . '</h2>';
@@ -78,11 +78,11 @@ $this->stop();
if ($canedit) {
?>
- <p><a href="<?= $this->uart('artadd', $art->id()) ?>">⭐ Create</a></p>
+ <p><a href="<?= $this->upage('pageadd', $page->id()) ?>">⭐ Create</a></p>
<?php
} elseif(!empty(Config::alertlink())) {
?>
- <p><a href="<?= $this->uart('artread/', Config::alertlink()) ?>"><?= empty(Config::alertlinktext()) ? Config::alertlink() : Config::alertlinktext() ?></a></p>
+ <p><a href="<?= $this->upage('pageread/', Config::alertlink()) ?>"><?= empty(Config::alertlinktext()) ? Config::alertlink() : Config::alertlinktext() ?></a></p>
<?php
}
diff --git a/app/view/templates/backtopbar.php b/app/view/templates/backtopbar.php
index 76ec90f..d10d5da 100644
--- a/app/view/templates/backtopbar.php
+++ b/app/view/templates/backtopbar.php
@@ -66,7 +66,7 @@ if($user->isadmin()) {
<form action="<?= $this->url('log') ?>" method="post" id="connect">
<input type="submit" name="log" value="logout" >
<?php if($tab === 'edit') { ?>
- <input type="hidden" name="route" value="artread/">
+ <input type="hidden" name="route" value="pageread/">
<input type="hidden" name="id" value="<?= $pageid ?>">
<?php } ?>
diff --git a/app/view/templates/confirmdelete.php b/app/view/templates/confirmdelete.php
index 7d8f62a..133f32b 100644
--- a/app/view/templates/confirmdelete.php
+++ b/app/view/templates/confirmdelete.php
@@ -4,26 +4,25 @@
<?php $this->start('page') ?>
-<?php $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist]) ?>
<div>
<h1>Delete</h1>
<ul>
-<li>Id : <?= $art->id() ?></li>
-<li>Title : <?= $art->title() ?></li>
-<li>Article(s) linked to this one : <?= $art->linkto('sort') ?></li>
-<li>Article(s) linked from this one : <?= $art->linkfrom('sort') ?></li>
-<li>Number of edits : <?= $art->editcount() ?></li>
+<li>Id : <?= $page->id() ?></li>
+<li>Title : <?= $page->title() ?></li>
+<li>Article(s) linked to this one : <?= $page->linkto('sort') ?></li>
+<li>Article(s) linked from this one : <?= $page->linkfrom('sort') ?></li>
+<li>Number of edits : <?= $page->editcount() ?></li>
</ul>
-<?php if (!empty($art->linkto())) { ?>
+<?php if (!empty($page->linkto())) { ?>
<h2>Article linked to :</h2>
<ul>
-<?php foreach ($art->linkto('array') as $linkto) {
+<?php foreach ($page->linkto('array') as $linkto) {
echo '<li><a href="./?id=' . $linkto . '">' . $linkto . '</a></li>';
} ?>
</ul>
@@ -34,7 +33,7 @@
</div>
-<form action="<?= $this->uart('artdelete', $art->id()) ?>" method="post">
+<form action="<?= $this->upage('pagedelete', $page->id()) ?>" method="post">
<input type="hidden" name="deleteconfirm" value="true">
<input type="submit" value="confirm delete">
</form>
diff --git a/app/view/templates/connect.php b/app/view/templates/connect.php
index 82c01ec..dca4303 100644
--- a/app/view/templates/connect.php
+++ b/app/view/templates/connect.php
@@ -14,7 +14,7 @@
<form action="<?= $this->url('log') ?>" method="post">
<input type="hidden" name="route" value="<?= $route ?>">
<?php
-if(in_array($route, ['artedit', 'artread', 'artread/', 'artadd'])) {
+if(in_array($route, ['pageedit', 'pageread', 'pageread/', 'pageadd'])) {
echo '<input type="hidden" name="id" value="'. $id .'">';
}
?>
@@ -34,8 +34,8 @@ if(in_array($route, ['artedit', 'artread', 'artread/', 'artadd'])) {
<?php } ?>
<?php
-if(in_array($route, ['artedit', 'artread', 'artread/', 'artadd'])) {
- echo '<p><a href="' . $this->uart('artread/', $id) . '">back to page read view</a></p>';
+if(in_array($route, ['pageedit', 'pageread', 'pageread/', 'pageadd'])) {
+ echo '<p><a href="' . $this->upage('pageread/', $id) . '">back to page read view</a></p>';
}
?>
diff --git a/app/view/templates/edit.php b/app/view/templates/edit.php
index 7cebcc7..4c7fc61 100644
--- a/app/view/templates/edit.php
+++ b/app/view/templates/edit.php
@@ -1,4 +1,4 @@
-<?php $this->layout('layout', ['title' => '✏ '.$art->title(), 'css' => $css . 'edit.css', 'favicon' => $art->favicon()]) ?>
+<?php $this->layout('layout', ['title' => '✏ '.$page->title(), 'css' => $css . 'edit.css', 'favicon' => $page->favicon()]) ?>
@@ -10,16 +10,16 @@
<body>
<main class="editor">
- <?php $this->insert('backtopbar', ['user' => $user, 'tab' => 'edit', 'pagelist' => $pagelist, 'pageid' => $art->id()]) ?>
+ <?php $this->insert('backtopbar', ['user' => $user, 'tab' => 'edit', 'pagelist' => $pagelist, 'pageid' => $page->id()]) ?>
- <?php $this->insert('edittopbar', ['art' => $art, 'user' => $user]) ?>
+ <?php $this->insert('edittopbar', ['page' => $page, 'user' => $user]) ?>
<div id="workspace">
- <?php $this->insert('editleftbar', ['art' => $art, 'tablist' => $tablist, 'artlist' => $artlist, 'showleftpanel' => $showleftpanel, 'faviconlist' => $faviconlist]) ?>
- <?php $this->insert('edittabs', ['tablist' => $tablist, 'opentab' => $art->interface(), 'templates' => $art->template()]) ?>
- <?php $this->insert('editrightbar', ['art' => $art, 'artlist' => $artlist, 'showrightpanel' => $showrightpanel, 'templates' => $art->template(), 'tagartlist' => $tagartlist, 'lasteditedartlist' => $lasteditedartlist, 'editorlist' => $editorlist, 'user' => $user]) ?>
+ <?php $this->insert('editleftbar', ['page' => $page, 'tablist' => $tablist, 'pagelist' => $pagelist, 'showleftpanel' => $showleftpanel, 'faviconlist' => $faviconlist]) ?>
+ <?php $this->insert('edittabs', ['tablist' => $tablist, 'opentab' => $page->interface(), 'templates' => $page->template()]) ?>
+ <?php $this->insert('editrightbar', ['page' => $page, 'pagelist' => $pagelist, 'showrightpanel' => $showrightpanel, 'templates' => $page->template(), 'tagpagelist' => $tagpagelist, 'lasteditedpagelist' => $lasteditedpagelist, 'editorlist' => $editorlist, 'user' => $user]) ?>
</div>
@@ -28,7 +28,7 @@
</main>
<script>
- const artid = '<?= $art->id() ?>';
+ const pageid = '<?= $page->id() ?>';
</script>
<script src="<?= Model::jspath() ?>edit.js"></script>
</body>
diff --git a/app/view/templates/editleftbar.php b/app/view/templates/editleftbar.php
index bd3fd15..d169473 100644
--- a/app/view/templates/editleftbar.php
+++ b/app/view/templates/editleftbar.php
@@ -3,40 +3,40 @@
<label for="showleftpanel" class="toogle">◧</label>
<div id="leftbarpanel" class="panel">
- <input type="hidden" name="thisdatemodif" value="<?= $art->datemodif('string') ?>">
+ <input type="hidden" name="thisdatemodif" value="<?= $page->datemodif('string') ?>">
<details id="editinfo" open>
<summary>Infos</summary>
<fieldset>
<label for="title">title :</label>
- <input type="text" name="title" id="title" value="<?= $art->title(); ?>">
+ <input type="text" name="title" id="title" value="<?= $page->title(); ?>">
<label for="description">Description :</label>
- <input type="text" name="description" id="description" value="<?= $art->description(); ?>">
+ <input type="text" name="description" id="description" value="<?= $page->description(); ?>">
<label for="tag">Tag(s) :</label>
- <input type="text" name="tag" id="tag" value="<?= $art->tag('string'); ?>">
+ <input type="text" name="tag" id="tag" value="<?= $page->tag('string'); ?>">
<label for="secure">Privacy level :</label>
<select name="secure" id="secure">
- <option value="0" <?= $art->secure() == 0 ? 'selected' : '' ?>>public</option>
- <option value="1" <?= $art->secure() == 1 ? 'selected' : '' ?>>private</option>
- <option value="2" <?= $art->secure() == 2 ? 'selected' : '' ?>>not published</option>
+ <option value="0" <?= $page->secure() == 0 ? 'selected' : '' ?>>public</option>
+ <option value="1" <?= $page->secure() == 1 ? 'selected' : '' ?>>private</option>
+ <option value="2" <?= $page->secure() == 2 ? 'selected' : '' ?>>not published</option>
</select>
<label for="date">Date</label>
- <input type="date" name="pdate" value="<?= $art->date('pdate') ?>" id="date">
+ <input type="date" name="pdate" value="<?= $page->date('pdate') ?>" id="date">
<label for="time">Time</label>
- <input type="time" name="ptime" value="<?= $art->date('ptime') ?>" id="time">
+ <input type="time" name="ptime" value="<?= $page->date('ptime') ?>" id="time">
<label for="favicon">Favicon</label>
<select name="favicon" id="favicon">
<?php
- if(!empty($art->templatecss()) && $art->template()['cssfavicon']) {
+ if(!empty($page->templatecss()) && $page->template()['cssfavicon']) {
?>
- <option value="<?= $art->favicon() ?>">--using template favicon--</option>
+ <option value="<?= $page->favicon() ?>">--using template favicon--</option>
<?php
} else {
echo '<option value="">--no favicon--</option>';
foreach ($faviconlist as $favicon) {
?>
- <option value="<?= $favicon ?>" <?= $art->favicon() === $favicon ? 'selected' : '' ?>><?= $favicon ?></option>
+ <option value="<?= $favicon ?>" <?= $page->favicon() === $favicon ? 'selected' : '' ?>><?= $favicon ?></option>
<?php
}
}
@@ -46,7 +46,7 @@
<div id="thumbnail">
<label for="thumbnail">Thumbnail</label>
<input type="file" id="thumbnail" name="thumbnail" accept=".jpg, .JPG, .jpeg, .JPEG">
- <img src="<?= Model::thumbnailpath() ?><?= $art->id() ?>.jpg" alt="no-thumbnail">
+ <img src="<?= Model::thumbnailpath() ?><?= $page->id() ?>.jpg" alt="no-thumbnail">
</div>
@@ -61,16 +61,16 @@
- <details <?= !empty($art->templatebody()) || !empty($art->templatecss()) || !empty($art->templatejavascript()) ? 'open' : '' ?>>
+ <details <?= !empty($page->templatebody()) || !empty($page->templatecss()) || !empty($page->templatejavascript()) ? 'open' : '' ?>>
<summary>Template</summary>
<fieldset>
<label for="templatebody">BODY template</label>
<select name="templatebody" id="templatebody">
- <option value="" <?= empty($art->templatebody()) ? 'selected' : '' ?>>--no template--</option>
+ <option value="" <?= empty($page->templatebody()) ? 'selected' : '' ?>>--no template--</option>
<?php
- foreach ($artlist as $template) {
+ foreach ($pagelist as $template) {
?>
- <option value="<?= $template ?>" <?= $art->templatebody() === $template ? 'selected' : '' ?>><?= $template ?></option>
+ <option value="<?= $template ?>" <?= $page->templatebody() === $template ? 'selected' : '' ?>><?= $template ?></option>
<?php
}
?>
@@ -79,39 +79,39 @@
<label for="templatecss">CSS template</label>
<select name="templatecss" id="templatecss">
- <option value="" <?= empty($art->templatecss()) ? 'selected' : '' ?>>--no template--</option>
+ <option value="" <?= empty($page->templatecss()) ? 'selected' : '' ?>>--no template--</option>
<?php
- foreach ($artlist as $template) {
+ foreach ($pagelist as $template) {
?>
- <option value="<?= $template ?>" <?= $art->templatecss() === $template ? 'selected' : '' ?>><?= $template ?></option>
+ <option value="<?= $template ?>" <?= $page->templatecss() === $template ? 'selected' : '' ?>><?= $template ?></option>
<?php
}
?>
</select>
<?php
- if(!empty($art->templatecss())) {
+ if(!empty($page->templatecss())) {
?>
<div class="subtemplate">
- <input type="checkbox" name="templateoptions[]" id="oreccursivecss" value="reccursivecss" <?= in_array('reccursivecss', $art->templateoptions()) ? 'checked' : '' ?>>
+ <input type="checkbox" name="templateoptions[]" id="oreccursivecss" value="reccursivecss" <?= in_array('reccursivecss', $page->templateoptions()) ? 'checked' : '' ?>>
<label for="oreccursivecss">Reccursive template</label>
</div>
<div class="subtemplate">
- <input type="checkbox" name="templateoptions[]" id="oquickcss" value="quickcss" <?= in_array('quickcss', $art->templateoptions()) ? 'checked' : '' ?>>
+ <input type="checkbox" name="templateoptions[]" id="oquickcss" value="quickcss" <?= in_array('quickcss', $page->templateoptions()) ? 'checked' : '' ?>>
<label for="oquickcss">Quickcss</label>
</div>
<div class="subtemplate">
- <input type="checkbox" name="templateoptions[]" id="oexternalcss" value="externalcss" <?= in_array('externalcss', $art->templateoptions()) ? 'checked' : '' ?>>
+ <input type="checkbox" name="templateoptions[]" id="oexternalcss" value="externalcss" <?= in_array('externalcss', $page->templateoptions()) ? 'checked' : '' ?>>
<label for="oexternalcss">External CSS</label>
</div>
<div class="subtemplate">
- <input type="checkbox" name="templateoptions[]" id="ofavicon" value="favicon" <?= in_array('favicon', $art->templateoptions()) ? 'checked' : '' ?>>
+ <input type="checkbox" name="templateoptions[]" id="ofavicon" value="favicon" <?= in_array('favicon', $page->templateoptions()) ? 'checked' : '' ?>>
<label for="ofavicon">Favicon</label>
</div>
<?php
} else {
- foreach($art->templateoptions() as $option) {
+ foreach($page->templateoptions() as $option) {
if($option != 'externaljavascript') {
echo '<input type="hidden" name="templateoptions[]" value="'.$option.'">';
}
@@ -123,11 +123,11 @@
<label for="templatejavascript">Javascript template</label>
<select name="templatejavascript" id="templatejavascript">
- <option value="" <?= empty($art->templatejavascript()) ? 'selected' : '' ?>>--no template--</option>
+ <option value="" <?= empty($page->templatejavascript()) ? 'selected' : '' ?>>--no template--</option>
<?php
- foreach ($artlist as $template) {
+ foreach ($pagelist as $template) {
?>
- <option value="<?= $template ?>" <?= $art->templatejavascript() === $template ? 'selected' : '' ?>><?= $template ?></option>
+ <option value="<?= $template ?>" <?= $page->templatejavascript() === $template ? 'selected' : '' ?>><?= $template ?></option>
<?php
}
?>
@@ -135,15 +135,15 @@
<?php
- if(!empty($art->templatejavascript())) {
+ if(!empty($page->templatejavascript())) {
?>
<div class="subtemplate">
- <input type="checkbox" name="templateoptions[]" value="externaljavascript" id="oexternaljs" <?= in_array('externaljavascript', $art->templateoptions()) ? 'checked' : '' ?>>
+ <input type="checkbox" name="templateoptions[]" value="externaljavascript" id="oexternaljs" <?= in_array('externaljavascript', $page->templateoptions()) ? 'checked' : '' ?>>
<label for="oexternaljs">external js</label>
</div>
<?php } else {
- if(in_array('externaljavascript', $art->templateoptions())) {
+ if(in_array('externaljavascript', $page->templateoptions())) {
echo '<input type="hidden" name="templateoptions[]" value="externaljavascript">';
}
@@ -152,7 +152,7 @@
</fieldset>
</details>
- <details id="advanced" <?= !empty($art->externalcss()) || !empty($art->customhead()) ? 'open' : '' ?>>
+ <details id="advanced" <?= !empty($page->externalcss()) || !empty($page->customhead()) ? 'open' : '' ?>>
<summary>Advanced</summary>
@@ -163,7 +163,7 @@
<label for="externalcss">External CSS</label>
<input type="text" name="externalcss[]" id="externalcss" placeholder="add external adress">
<?php
- foreach ($art->externalcss() as $css) {
+ foreach ($page->externalcss() as $css) {
?>
<div class="checkexternal">
<input type="checkbox" name="externalcss[]" id="<?= $css ?>" value="<?= $css ?>" checked>
@@ -174,7 +174,7 @@
?>
<label for="customhead">Custom head</label>
- <textarea name="customhead" wrap="off" spellcheck="false" rows="<?= $art->customhead('int') ?>"><?= $art->customhead() ?></textarea>
+ <textarea name="customhead" wrap="off" spellcheck="false" rows="<?= $page->customhead('int') ?>"><?= $page->customhead() ?></textarea>
</fieldset>
diff --git a/app/view/templates/editrightbar.php b/app/view/templates/editrightbar.php
index 15cef7f..b0518ad 100644
--- a/app/view/templates/editrightbar.php
+++ b/app/view/templates/editrightbar.php
@@ -8,9 +8,9 @@
<summary>Last edited</summary>
<ul>
<?php
- foreach ($lasteditedartlist as $id) {
+ foreach ($lasteditedpagelist as $id) {
?>
- <li><a href="<?= $this->uart('artedit', $id) ?>"><?= $id === $art->id() ? '➤' : '✎' ?> <?= $id ?></a></li>
+ <li><a href="<?= $this->upage('pageedit', $id) ?>"><?= $id === $page->id() ? '➤' : '✎' ?> <?= $id ?></a></li>
<?php
}
@@ -23,7 +23,7 @@
<details id="tags" open>
<summary>Tags</summary>
<?php
- foreach ($tagartlist as $tag => $idlist) {
+ foreach ($tagpagelist as $tag => $idlist) {
if(count($idlist) > 1) {
?>
<strong><?= $tag ?></strong>
@@ -31,11 +31,11 @@
echo '<ul>';
foreach ($idlist as $id) {
- if($id === $art->id()) {
+ if($id === $page->id()) {
echo '<li>➤ '.$id.'</li>';
} else {
?>
- <li><a href="<?= $this->uart('artedit', $id) ?>">✎ <?= $id ?></a></li>
+ <li><a href="<?= $this->upage('pageedit', $id) ?>">✎ <?= $id ?></a></li>
<?php
}
}
@@ -54,7 +54,7 @@
foreach ($templates as $template => $id) {
if(!empty($id) && !is_bool($id)) {
?>
- <li><?= $template ?> : <?= $id ?> <a href="<?= $this->uart('artedit', $id) ?>">✎</a></li>
+ <li><?= $template ?> : <?= $id ?> <a href="<?= $this->upage('pageedit', $id) ?>">✎</a></li>
<?php
}
}
@@ -74,7 +74,7 @@
<select name="authors[]" id="authors">
<option value="" selected>--add author--</option>
<?php
- $notyetauthorlist = array_diff($editorlist, $art->authors());
+ $notyetauthorlist = array_diff($editorlist, $page->authors());
foreach ($notyetauthorlist as $author) {
echo '<option value="'.$author.'" >'.$author.'</option>';
}
@@ -83,7 +83,7 @@
</select>
<?php
- $alreadyauthorlist = array_intersect($editorlist, $art->authors());
+ $alreadyauthorlist = array_intersect($editorlist, $page->authors());
foreach ($alreadyauthorlist as $author) {
?>
<div class="checkexternal">
diff --git a/app/view/templates/edittopbar.php b/app/view/templates/edittopbar.php
index 04331b4..8d158d6 100644
--- a/app/view/templates/edittopbar.php
+++ b/app/view/templates/edittopbar.php
@@ -2,7 +2,7 @@
- <form action="<?= $this->uart('artupdate', $art->id()) ?>" method="post" id="update" enctype="multipart/form-data">
+ <form action="<?= $this->upage('pageupdate', $page->id()) ?>" method="post" id="update" enctype="multippage/form-data">
<div id="editmenu">
@@ -17,8 +17,8 @@
- <a href="<?= $this->uart('artread/', $art->id()) ?>" target="_blank" ><img src="<?= Model::iconpath() ?>read.png" class="icon">display</a>
- <span id="headid"><?= $art->id() ?></span>
+ <a href="<?= $this->upage('pageread/', $page->id()) ?>" target="_blank" ><img src="<?= Model::iconpath() ?>read.png" class="icon">display</a>
+ <span id="headid"><?= $page->id() ?></span>
</span>
<span id="fontsize">
@@ -28,12 +28,12 @@
</span>
<span id="download">
- <a href="<?= $this->uart('artdownload', $art->id()) ?>"><img src="<?= Model::iconpath() ?>download.png" class="icon"><span class="text">download</span></a>
+ <a href="<?= $this->upage('pagedownload', $page->id()) ?>"><img src="<?= Model::iconpath() ?>download.png" class="icon"><span class="text">download</span></a>
</span>
<span id="delete">
- <a href="<?= $this->uart('artconfirmdelete', $art->id()) ?>"><span class="symbol">✖</span><span class="text">delete</span></a>
+ <a href="<?= $this->upage('pageconfirmdelete', $page->id()) ?>"><span class="symbol">✖</span><span class="text">delete</span></a>
</span>
</div>
diff --git a/app/view/templates/home.php b/app/view/templates/home.php
index 17d0a22..f767b13 100644
--- a/app/view/templates/home.php
+++ b/app/view/templates/home.php
@@ -87,11 +87,11 @@
<tr>
<td><input type="checkbox" name="id[]" value="<?= $item->id() ?>" id="id_<?= $item->id() ?>"></td>
<td><label title="<?= $item->title() ?>" for="id_<?= $item->id() ?>"><?= $item->id() ?></label></td>
- <td><a href="<?= $this->uart('artedit', $item->id()) ?>"><img src="<?= Model::iconpath() ?>edit.png" class="icon"></a></td>
- <td><a href="<?= $this->uart('artread/', $item->id()) ?>" target="_blank"><img src="<?= Model::iconpath() ?>read.png" class="icon"></a></td>
- <td class="delete"><a href="<?= $this->uart('artdelete', $item->id()) ?>">✖</a></td>
+ <td><a href="<?= $this->upage('pageedit', $item->id()) ?>"><img src="<?= Model::iconpath() ?>edit.png" class="icon"></a></td>
+ <td><a href="<?= $this->upage('pageread/', $item->id()) ?>" target="_blank"><img src="<?= Model::iconpath() ?>read.png" class="icon"></a></td>
+ <td class="delete"><a href="<?= $this->upage('pagedelete', $item->id()) ?>">✖</a></td>
<?php if ($user->issupereditor()) { ?>
- <td><a href="<?= $this->uart('artdownload', $item->id()) ?>" download><img src="<?= Model::iconpath() ?>download.png" class="icon"></a></td>
+ <td><a href="<?= $this->upage('pagedownload', $item->id()) ?>" download><img src="<?= Model::iconpath() ?>download.png" class="icon"></a></td>
<?php }
if ($columns['tag']) { ?>
<td class="tag"><a title="<?= $item->tag('string') ?>"><?= $item->tag('sort') ?></a></td>
diff --git a/app/view/templates/homemenu.php b/app/view/templates/homemenu.php
index 8716c17..f807f7c 100644
--- a/app/view/templates/homemenu.php
+++ b/app/view/templates/homemenu.php
@@ -6,7 +6,7 @@
<summary>File</summary>
<div class="submenu">
<h2>Import page as file</h2>
- <form action="<?= $this->url('artupload') ?>" method="post" enctype="multipart/form-data">
+ <form action="<?= $this->url('pageupload') ?>" method="post" enctype="multipart/form-data">
<input type="file" name="pagefile" id="pagefile" accept=".json">
<label for="pagefile">JSON Page file</label>
<input type="hidden" name="erase" value="0">
diff --git a/app/view/templates/navart.php b/app/view/templates/navart.php
deleted file mode 100644
index 0e690c2..0000000
--- a/app/view/templates/navart.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<style>
-.wqn, .wqn *, .wqn:hover *, .wqn *:hover{
- all:initial;
-
-}
-.wqn {
- position: fixed;
- top: 0;
- right: 0;
- z-index: 10;
- background-color: var(--color1);
-}
-
-.wqn div#dropwqn {
- background-color: lightgrey;
- text-align: right;
- font-family: monospace;
-}
-
-.wqn li.drop{
- display: block;
- text-align: right;
-}
-
-.wqn li.drop a.button:hover, .wqn li.drop input[type="submit"]:hover {
- color: white;
-}
-
-.wqn li.drop a.button, .wqn li.drop input[type="submit"] {
- cursor: pointer;
- font-family: monospace;
- font-size: 15px;
-}
-
-.wqn li.drop a.button, .wqn li.drop input[type="submit"] {
- cursor: pointer;
- font-family: monospace;
- font-size: 15px;
-}
-
-.wqn div#dropwqn {
- display: none;
-}
-
-.wqn input#loginpass {
- width: 70px;
- background-color: white;
-}
-
-.wqn:hover div#dropwqn {
- display: block;
-}
-
-</style>
-
-
-<div class="wqn" >
-<div style="opacity: 0.5; text-align: right; display: block;">✎</div>
- <div id="dropwqn">
-
- <ul>
- <li class="drop">
- <span class="button" style="font-family: monospace; background-color: #7b97b9;" ><?= $user->id() ?> (<?= $user->level() ?>)</span>
- </li>
- <li class="drop">
- <a class="button" href="<?= $this->url('home') ?>">home</a>
- </li>
-
-
-<?php if($user->isvisitor()) { ?>
-
- <li class="drop">
- <form action="<?= $this->url('log') ?>" method="post">
- <input type="password" name="pass" id="loginpass" placeholder="password">
- <input type="hidden" name="route" value="artread/">
- <input type="hidden" name="id" value="<?= $art->id() ?>">
- <input type="submit" name="log" value="login" id="button">
- </form>
- </li>
-
-<?php } else { ?>
-
- <li class="drop">
- <form action="<?= $this->url('log') ?>" method="post">
- <input type="hidden" name="id" value="<?= $art->id() ?>">
- <input type="hidden" name="route" value="artread/">
- <input type="submit" name="log" value="logout" id="button">
- </form>
- </li>
-
-<?php } ?>
-
-
-<?php if($canedit && $artexist) { ?>
-
- <li class="drop">
- <a class="button" href="<?= $this->uart('artread/', $art->id()) ?>" target="_blank">display</a>
- </li>
- <li class="drop">
- <a class="button" href="<?= $this->uart('artedit', $art->id()) ?>" >edit</a>
- </li>
- <li class="drop">
- <a class="button" href="<?= $this->uart('artrender', $art->id()) ?>" >render</a>
- </li>
-
-<?php } ?>
-
-
-<?php if ($user->iseditor()) { ?>
-
- <li class="drop">
- <a class="button" href="<?= $this->url('media') ?>" >Media</a>
- </li>
-
-<?php } ?>
-
-<?php if($user->isadmin()) { ?>
-
- <li class="drop">
- <a class="button" href="<?= $this->url('admin') ?>" >Admin</a>
- </li>
-
-<?php } ?>
-
-
-
-
- </div>
-</div> \ No newline at end of file
diff --git a/app/view/templates/updatemerge.php b/app/view/templates/updatemerge.php
index f9d29bf..09476fa 100644
--- a/app/view/templates/updatemerge.php
+++ b/app/view/templates/updatemerge.php
@@ -3,7 +3,7 @@
foreach ($diff as $element) {
echo '<h2>' . $element . '</h2>';
- echo '<textarea style="width: 100%; max-width: 600px; height: 300px;">' . $mergeart->$element() . '</textarea>';
+ echo '<textarea style="width: 100%; max-width: 600px; height: 300px;">' . $mergepage->$element() . '</textarea>';
}
?> \ No newline at end of file
diff --git a/assets/js/edit.js b/assets/js/edit.js
index b4c173f..b0f8915 100644
--- a/assets/js/edit.js
+++ b/assets/js/edit.js
@@ -1,6 +1,6 @@
let form;
let unsavedChanges = false;
-const arturl = basepath + artid;
+const pageurl = basepath + pageid;
const myWorker = new Worker(jspath + 'worker.js');
window.onload = () => {
@@ -17,7 +17,7 @@ window.onload = () => {
myWorker.postMessage({
type: 'init',
- arturl: arturl,
+ pageurl: pageurl,
});
myWorker.postMessage({ type: 'stillEditing' });
};
@@ -63,7 +63,7 @@ function submitHandler(e) {
*/
function confirmExit(e) {
if (unsavedChanges) {
- const url = arturl + '/removeeditby';
+ const url = pageurl + '/removeeditby';
console.log('send quit editing')
fetch(url, { method: 'POST' })
.then(handleErrors)
diff --git a/assets/js/worker.js b/assets/js/worker.js
index 846acba..d60fdf1 100644
--- a/assets/js/worker.js
+++ b/assets/js/worker.js
@@ -1,9 +1,9 @@
-let arturl;
+let pageurl;
onmessage = function (e) {
switch (e.data.type) {
case 'init':
- arturl = e.data.arturl;
+ pageurl = e.data.pageurl;
break;
case 'stillEditing':
stillEditing();
@@ -16,7 +16,7 @@ onmessage = function (e) {
function stillEditing() {
console.log('send still editing');
- const url = arturl + '/editby';
+ const url = pageurl + '/editby';
const req = new XMLHttpRequest();
req.open('POST', url, false);
req.send(null);
@@ -27,7 +27,7 @@ function stillEditing() {
function quitEditing() {
console.log('send quit editing');
- const url = arturl + '/removeeditby';
+ const url = pageurl + '/removeeditby';
const req = new XMLHttpRequest();
req.open('POST', url, false);
req.send(null);
diff --git a/composer.json b/composer.json
index 6450f32..51f9974 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "w-cms",
"description": "point'n think",
- "version": "1.6.2",
+ "version": "1.7.0",
"require": {
"michelf/php-markdown": "^1.8",
"league/plates": "3.*",