aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-01-12 15:52:55 +0100
committervincent-peugnet <v.peugnet@free.fr>2019-01-12 19:51:41 +0100
commit36d878ac00f4df0a4ff54e2ea8355b323f0a87f3 (patch)
tree7f0cc2f2337764618ab43f6cd59e49f4c1ac9c89 /app/class
parent393709dcf84776c760146722560816172167fe98 (diff)
downloadwcms-36d878ac00f4df0a4ff54e2ea8355b323f0a87f3.tar.gz
wcms-36d878ac00f4df0a4ff54e2ea8355b323f0a87f3.zip
add timeline class and event class
Diffstat (limited to 'app/class')
-rw-r--r--app/class/art2.php3
-rw-r--r--app/class/controllerhome.php5
-rw-r--r--app/class/controllertimeline.php26
-rw-r--r--app/class/dbitem.php19
-rw-r--r--app/class/event.php133
-rw-r--r--app/class/modeltimeline.php14
-rw-r--r--app/class/routes.php5
7 files changed, 195 insertions, 10 deletions
diff --git a/app/class/art2.php b/app/class/art2.php
index 2341ff9..a7e94f3 100644
--- a/app/class/art2.php
+++ b/app/class/art2.php
@@ -44,9 +44,6 @@ class Art2
const LEN = 255;
const LENTEXT = 2**20;
const SECUREMAX = 2;
- const LENCOULEUR = 7;
- const DEBUT = '(?id=';
- const FIN = ')';
const TABS = ['main', 'css', 'header', 'body', 'nav', 'aside', 'footer', 'javascript'];
const VAR_DATE = ['date', 'datecreation', 'datemodif', 'daterender'];
diff --git a/app/class/controllerhome.php b/app/class/controllerhome.php
index caeb652..f5b3068 100644
--- a/app/class/controllerhome.php
+++ b/app/class/controllerhome.php
@@ -17,11 +17,6 @@ class Controllerhome extends Controller
public function desktop()
{
- $this->table2();
- }
-
- public function table2()
- {
$table = $this->modelhome->getlister();
$this->opt = $this->modelhome->optinit($table);
diff --git a/app/class/controllertimeline.php b/app/class/controllertimeline.php
new file mode 100644
index 0000000..5f80fc2
--- /dev/null
+++ b/app/class/controllertimeline.php
@@ -0,0 +1,26 @@
+<?php
+
+class Controllertimeline extends Controller
+{
+ /**@var Modeltimeline */
+ protected $eventmanager;
+
+ public function __construct($render) {
+ parent::__construct($render);
+ $this->eventmanager = new Modeltimeline;
+ }
+
+ public function desktop()
+ {
+ var_dump($this->eventmanager->list());
+ }
+}
+
+
+
+
+
+
+
+
+?> \ No newline at end of file
diff --git a/app/class/dbitem.php b/app/class/dbitem.php
new file mode 100644
index 0000000..ff41d6f
--- /dev/null
+++ b/app/class/dbitem.php
@@ -0,0 +1,19 @@
+<?php
+
+class Dbitem
+{
+ public function hydrate(array $datas)
+ {
+ foreach ($datas as $key => $value) {
+ $method = 'set' . $key;
+
+ if (method_exists($this, $method)) {
+ $this->$method($value);
+ }
+ }
+
+ }
+}
+
+
+?> \ No newline at end of file
diff --git a/app/class/event.php b/app/class/event.php
new file mode 100644
index 0000000..7661aa3
--- /dev/null
+++ b/app/class/event.php
@@ -0,0 +1,133 @@
+<?php
+
+class Event extends Dbitem
+{
+ protected $id;
+ protected $date;
+ protected $type;
+ protected $user;
+ protected $target;
+ protected $message;
+
+ const EVENT_TYPES = ['message', 'art_add', 'art_edit', 'art_delete', 'media_add', 'media_delete', 'font_add'];
+ const EVENT_BASE = ['message'];
+ const EVENT_ART = ['art_add', 'art_edit', 'art_delete'];
+ const EVENT_MEDIA = ['media_add', 'media_delete'];
+ const EVENT_FONT = ['font_add', 'font_delete'];
+ const MESSAGE_MAX_LENGTH = 2**10;
+
+ public function __contruct($datas)
+ {
+ $this->hydrate($datas);
+ }
+
+ public function conform()
+ {
+ $this->user = idclean($this->user);
+ if(in_array($this->type, self::EVENT_ART)) {
+ $this->target = idclean($this->target);
+ }
+ }
+
+ // _____________________ G E T __________________________
+
+ public function id()
+ {
+ return $this->id;
+ }
+
+ public function date($type = 'datetime')
+ {
+ switch ($type) {
+ case 'datetime':
+ return $this->date;
+ break;
+
+ case 'string':
+ return $this->date->format(DateTime::ISO8601);
+ break;
+
+ case 'hrdi':
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->date->diff($now));
+ break;
+
+ }
+ }
+
+ public function type()
+ {
+ return $this->type;
+ }
+
+ public function user()
+ {
+ return $this->user;
+ }
+
+ public function target()
+ {
+ return $this->target;
+ }
+
+ public function message()
+ {
+ return $this->message;
+ }
+
+
+
+ // ________________________ S E T ____________________
+
+ public function setid($id)
+ {
+ if(is_int($id)) {
+ $this->id = $id;
+ }
+ }
+
+ public function setdate($date)
+ {
+ if ($date instanceof DateTimeImmutable) {
+ $this->date = $date;
+ } else {
+ $this->date = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $date, new DateTimeZone('Europe/Paris'));
+ }
+ }
+
+ public function settype($type)
+ {
+ if(in_array($type, self::EVENT_TYPES)) {
+ $this->type = $type;
+ }
+ }
+
+ public function setuser($user)
+ {
+ if(is_string($user) && strlen($user) < Model::MAX_ID_LENGTH) {
+ $this->user = $user;
+ }
+ }
+
+ public function settarget($target)
+ {
+ if(is_string($target) && strlen($target) < Model::MAX_ID_LENGTH) {
+ $this->target = $target;
+ }
+ }
+
+ public function setmessage($message)
+ {
+ if(is_string($message) && strlen($message) < self::MESSAGE_MAX_LENGTH) {
+ $this->message = $message;
+ }
+ }
+
+
+
+
+
+}
+
+
+?> \ No newline at end of file
diff --git a/app/class/modeltimeline.php b/app/class/modeltimeline.php
new file mode 100644
index 0000000..fd9126e
--- /dev/null
+++ b/app/class/modeltimeline.php
@@ -0,0 +1,14 @@
+<?php
+
+class Modeltimeline extends Modeldb
+{
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->storeinit('timeline');
+ }
+}
+
+
+?> \ No newline at end of file
diff --git a/app/class/routes.php b/app/class/routes.php
index a72d2e9..a90a8a1 100644
--- a/app/class/routes.php
+++ b/app/class/routes.php
@@ -22,14 +22,15 @@ class Routes
['POST', '/!media/upload', 'Controllermedia#upload', 'mediaupload'],
['POST', '/!media/folder', 'Controllermedia#folder', 'mediafolder'],
['GET', '/!font', 'Controllerfont#desktop', 'font'],
+ ['GET', '/!font/render', 'Controllerfont#render', 'fontrender'],
+ ['POST', '/!font/add', 'Controllerfont#add', 'fontadd'],
['POST', '/!admin', 'Controlleradmin#update', 'adminupdate'],
['GET', '/!admin', 'Controlleradmin#desktop', 'admin'],
['GET', '/!user', 'Controlleruser#desktop', 'user'],
['POST', '/!user/add', 'Controlleruser#add', 'useradd'],
['POST', '/!user/update', 'Controlleruser#update', 'userupdate'],
['GET', '/!info', 'Controllerinfo#desktop', 'info'],
- ['GET', '/!font/render', 'Controllerfont#render', 'fontrender'],
- ['POST', '/!font/add', 'Controllerfont#add', 'fontadd'],
+ ['GET', '/!timeline', 'Controllertimeline#desktop', 'timeline'],
['GET', '/[cid:art]/', 'Controllerart#read', 'artread/'],
['GET', '/[cid:art]', 'Controllerart#read', 'artread'],
['GET', '/[cid:art]/add', 'Controllerart#add', 'artadd'],