aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md36
-rw-r--r--w/class/art.php506
-rw-r--r--w/class/art2.php129
-rw-r--r--w/class/controllerart.php50
-rw-r--r--w/class/controllerconnect.php18
-rw-r--r--w/class/controllerdb.php23
-rw-r--r--w/class/controllerhome.php6
-rw-r--r--w/class/model.php2
-rw-r--r--w/class/modelanalyse.php4
-rw-r--r--w/class/modelart.php23
-rw-r--r--w/class/modeldb.php25
-rw-r--r--w/class/modelrender.php173
-rw-r--r--w/class/router.php1
-rw-r--r--w/view/templates/connect.php30
-rw-r--r--w/view/templates/delete.php44
-rw-r--r--w/view/templates/edit.php2
-rw-r--r--w/view/templates/edittopbar.php15
-rw-r--r--w/view/templates/home.php26
18 files changed, 318 insertions, 795 deletions
diff --git a/README.md b/README.md
index 1a58eca..13747fe 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,17 @@
# W-CMS
-**W** is a CMS based on my way of thinking.
+**W** was first a tool, based on my way of thinking, as a protesis, to write on ideas and create a self explorating text point n' click game.
-It's a mix between a drive, wikipedia and a personnal blog. You can create articles very quickly and share them with other people or keep them for you and restricted people.
+It's a mix between a drive, wikipedia and a personnal blog. You can create articles very quickly and share them with other people or keep them for you and restricted people.
+There is no boundaries beetween taking notes and creating a website. When you create a article, you create a space in internet, a place, that can be public or private. Then, you decide to link it or not with the others places you've created before.
+There is a lots of possibilites of creations, for people who need to create multi-aspect labyrinth websites, to use a half public/private mindmap, or even interactives fictions.
+## Highlights
-- The user can never see the whole map of the website : no menu (never ever)
-- you can discover the website only by clicking on internal link, wiki style.
-- Each page can have is own style, so you don't realise it's exactly the same website when you navigate (no graphical identity) Each page is a kind of single website on his own. (Just like a mini internet)
-
-The code is very very light, it's a very quick and limited CMS.
-
-The project is ispired by the *web publishing function* in *google docs* that create quick temporary web page instead of sharing a A4 page. I think very few people are using it.
+- The user can never see the whole map of the website : yo can create specific auto-menu for each page if you want.
+- Each page, of group of pages can be like a single website, with it's own style. (You can create your mini internet on internet)
+- The pages load very quickly as they can be rendered
+- Editor interface, the only place where where you can see the master-plan.
There is 3 levels of privacy :
@@ -29,23 +29,13 @@ And 4 levels of users :
[Webpage of the project (in french)](http://vincent.club1.fr/w/?id=w)
-# M
-
-**M** is the media manager to be used with **W**. The purpose is to import images or sound, rename them, resize them or compress them very quickly online.
# Technology
-- Pure PHP an MySQL only.
+- Pure PHP.
- Use MarkDown to edit articles.
-- All the article use only basic GET information.
-
-# Versions
-
-## W
-
-- 2.2 : all tools are now under the same folder **/W**, class are named **class.w.** to prevent name problems, edit symbol, new menu, better media display.
-- 2.1 : dynamic template : you can link a article to another to use the CSS parameters of the this one.
+- Intelligent link analysis.
+- Easy to manage Json files database.
-## M
+using [James Moss's Flywheel Database](https://github.com/jamesmoss/flywheel), [Michel Fortin's Markdown Extra](https://github.com/michelf/php-markdown) and [Plates](https://github.com/thephpleague/plates) as lightweight template engine.
-- 0.1 : test version. \ No newline at end of file
diff --git a/w/class/art.php b/w/class/art.php
deleted file mode 100644
index a4c93eb..0000000
--- a/w/class/art.php
+++ /dev/null
@@ -1,506 +0,0 @@
-<?php
-
-use Michelf\MarkdownExtra;
-
-
-class Art
-{
- private $id;
- private $titre;
- private $soustitre;
- private $intro;
- private $tag;
- private $datecreation;
- private $datemodif;
- private $css;
- private $html;
- private $secure;
- private $couleurtext;
- private $couleurbkg;
- private $couleurlien;
- private $couleurlienblank;
- private $lien;
- private $liento;
- private $template;
-
- const LEN = 255;
- const LENHTML = 20000;
- const SECUREMAX = 2;
- const LENCOULEUR = 7;
- const DEBUT = '(?id=';
- const FIN = ')';
-
-
-
-
-// _____________________________________________________ F U N ____________________________________________________
-
- public function __construct(array $donnees)
- {
- $this->hydrate($donnees);
- }
-
- public function hydrate(array $donnees)
- {
- foreach ($donnees as $key => $value) {
- $method = 'set' . $key;
-
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
- }
-
- public function reset()
- {
- $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
-
- $this->settitre($this->id());
- $this->setsoustitre('');
- $this->setintro('');
- $this->settag('');
- $this->setdatecreation($now);
- $this->setcss('');
- $this->sethtml('');
- $this->setsecure(2);
- $this->setcouleurtext('#000000');
- $this->setcouleurbkg('#FFFFFF');
- $this->setcouleurlien('#000000');
- $this->setcouleurlienblank('#000000');
- $this->setlien('');
- $this->settemplate('');
- }
-
- public function updatelien()
- {
- $this->lien = [];
- $this->lien = array_unique(search($this->md(true), self::DEBUT, self::FIN));
-
- }
-
- public static function classvarlist()
- {
- $classvarlist = [];
- foreach (get_class_vars(__class__) as $var => $default) {
- $classvarlist[] = $var;
- }
- return ['artvarlist' => $classvarlist];
- }
-
-
-
-
- public function calcliento($getlist)
- {
- $liento = [];
- foreach ($getlist as $lien) {
- if (in_array($this->id(), $lien->lien('array'))) {
- $liento[] = $lien->id();
- }
- }
- $this->setliento($liento);
- }
-
-
- public function autotaglist()
- {
- $pattern = "/%%(\w*)%%/";
- preg_match_all($pattern, $this->md(), $out);
- return $out[1];
-
- }
-
- public function autotaglistupdate($taglist)
- {
- foreach ($taglist as $tag => $artlist) {
- $replace = '<ul>';
- foreach ($artlist as $art) {
- $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->intro() . '">' . $art->titre() . '</a></li>';
- }
- $replace .= '</ul>';
- $this->html = str_replace('%%' . $tag . '%%', $replace, $this->html);
- }
- }
-
- public function autotaglistcalc($taglist)
- {
- foreach ($taglist as $tag => $artlist) {
- foreach ($artlist as $art) {
- if(!in_array($art->id(), $this->lien('array')) && $art->id() != $this->id()) {
- $this->lien[] = $art->id();
- }
- }
- }
- }
-
- public function templaterender()
- {
-
- }
-
-
- // _____________________________________________________ G E T ____________________________________________________
-
- public function id($type = 'string')
- {
- return $this->id;
- }
-
- public function titre($type = 'string')
- {
- return $this->titre;
- }
-
- public function soustitre($type = 'string')
- {
- return $this->soustitre;
- }
-
- public function intro($type = 'string')
- {
- return $this->intro;
- }
-
- public function tag($option)
- {
- if ($option == 'string') {
- return implode(", ", $this->tag);
- } elseif ($option == 'array') {
- return $this->tag;
- } elseif ($option == 'sort') {
- return count($this->tag);
- }
- }
-
- public function datecreation($option)
- {
- if ($option == 'string') {
- return $this->datecreation->format('Y-m-d H:i:s');
- } elseif ($option == 'date' || $option == 'sort') {
- return $this->datecreation;
- } elseif ($option == 'hrdi') {
- $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
- return hrdi($this->datecreation->diff($now));
- }
- }
-
-
- public function datemodif($option)
- {
- if ($option == 'string') {
- return $this->datemodif->format('Y-m-d H:i:s');
- } elseif ($option == 'date' || $option == 'sort') {
- return $this->datemodif;
- } elseif ($option == 'hrdi') {
- $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
- return hrdi($this->datemodif->diff($now));
- }
- }
-
- public function css($type = 'string')
- {
- return $this->css;
- }
-
- public function cssprint()
- {
- return $cssprint;
- }
-
- public function csstemplate(App $app)
- {
- $data = [];
- $temp = '';
- if (!empty($this->template())) {
- if ($app->exist($this->template()) and !in_array($this->template(), $data)) {
- $template = $app->get($this->template());
- $temp = $temp . $template->css($app);
- $data[] = $template->id();
-
- }
-
- }
- $cssprint = str_replace('url(/', 'url('.$app::MEDIA_DIR , $temp . $this->css);
- return $cssprint;
- }
-
- public function md($expand = false)
- {
- if ($expand == true) {
- $md = str_replace('](=', '](?id=', $this->html);
- } else {
- $md = $this->html;
- }
- return $md;
- }
-
- public function html(App $app)
- {
-
- // %%%% TITLE & DESCIPTION
- $html = str_replace('%TITLE%', $this->titre(), $this->html);
- $html = str_replace('%DESCRIPTION%', $this->intro(), $html);
-
- $parser = new MarkdownExtra;
-
- // id in headers
- $parser->header_id_func = function ($header) {
- return preg_replace('/[^\w]/', '', strtolower($header));
- };
- $html = $parser->transform($html);
-
- // replace = > ?id=
- $html = str_replace('href="=', 'href="?id=', $html);
-
-
- // infobulles tooltip
- foreach ($this->lien('array') as $id) {
- $title = "Cet article n'existe pas encore";
- foreach ($app->getlister(['id', 'intro']) as $item) {
- if ($item->id() == $id) {
- $title = $item->intro();
- }
- }
- $lien = 'href="?id=' . $id . '"';
- $titlelien = ' title="' . $title . '" ' . $lien;
- $html = str_replace($lien, $titlelien, $html);
- }
-
- if(!empty(strstr($html, '%SUMMARY%'))) {
-
-
-
- $html = str_replace('%SUMMARY%', sumparser($html), $html);
- }
-
-
- $html = str_replace('href="./media/', ' class="file" target="_blank" href="./media/', $html);
- $html = str_replace('href="http', ' class="external" target="_blank" href="http', $html);
- $html = str_replace('<img src="/', '<img src="./media/', $html);
- $html = str_replace('<iframe', '<div class="iframe"><div class="container"><iframe class="video" ', $html);
- $html = str_replace('</iframe>', '</iframe></div></div>', $html);
- return $html;
-
-
- }
-
- public function secure($type = 'int')
- {
- if ($type == 'string') {
- if ($this->secure == 0) $secure = 'public';
- if ($this->secure == 1) $secure = 'private';
- if ($this->secure == 2) $secure = 'not published';
- return $secure;
- } else {
- return $this->secure;
- }
- }
-
- public function couleurtext()
- {
- return $this->couleurtext;
- }
-
- public function couleurbkg()
- {
- return $this->couleurbkg;
- }
-
- public function couleurlien()
- {
- return $this->couleurlien;
- }
-
- public function couleurlienblank()
- {
- return $this->couleurlienblank;
- }
-
- public function lien($option)
- {
- if ($option == 'string') {
- $lien = implode(", ", $this->lien);
- } elseif ($option == 'array') {
- $lien = $this->lien;
- } elseif ($option == 'sort') {
- return count($this->lien);
- }
- return $lien;
-
- }
-
- public function liento($option)
- {
- if ($option == 'string') {
- $liento = implode(", ", $this->liento);
- } elseif ($option == 'array') {
- $liento = $this->liento;
- } elseif ($option == 'sort') {
- return count($this->liento);
- }
- return $liento;
-
- }
-
- public function template($type = 'string')
- {
- return $this->template;
- }
-
-
-
-
-
- // _____________________________________________________ S E T ____________________________________________________
-
- public function setid($id)
- {
- if (strlen($id) < self::LEN and is_string($id)) {
- $this->id = strip_tags(strtolower(str_replace(" ", "", $id)));
- }
- }
-
- public function settitre($titre)
- {
- if (strlen($titre) < self::LEN and is_string($titre)) {
- $this->titre = strip_tags(trim($titre));
- }
- }
-
- public function setsoustitre($soustitre)
- {
- if (strlen($soustitre) < self::LEN and is_string($soustitre)) {
- $this->soustitre = strip_tags(trim($soustitre));
- }
- }
-
- public function setintro($intro)
- {
- if (strlen($intro) < self::LEN and is_string($intro)) {
- $this->intro = strip_tags(trim($intro));
- }
- }
-
- public function settag($tag)
- {
- if (is_string($tag)) {
-
- if (strlen($tag) < self::LEN and is_string($tag)) {
- $tag = strip_tags(trim(strtolower($tag)));
- $tag = str_replace('*', '', $tag);
- $tag = str_replace(' ', '', $tag);
-
- $taglist = explode(",", $tag);
- $taglist = array_filter($taglist);
- $this->tag = $taglist;
- }
- } elseif (is_array($tag)) {
- $this->tag = $tag;
- }
- }
-
- public function setdatecreation($datecreation)
- {
- if ($datecreation instanceof DateTimeImmutable) {
- $this->datecreation = $datecreation;
- } else {
- $this->datecreation = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datecreation, new DateTimeZone('Europe/Paris'));
- }
- }
-
- public function setdatemodif($datemodif)
- {
- if ($datemodif instanceof DateTimeImmutable) {
- $this->datemodif = $datemodif;
- } else {
- $this->datemodif = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datemodif, new DateTimeZone('Europe/Paris'));
- }
- }
-
- public function setcss($css)
- {
- if (strlen($css) < self::LENHTML and is_string($css)) {
- $this->css = strip_tags(trim(strtolower($css)));
- }
- }
-
- public function sethtml($html)
- {
- if (strlen($html) < self::LENHTML and is_string($html)) {
- $this->html = $html;
- }
- }
-
- public function setsecure($secure)
- {
- if ($secure >= 0 and $secure <= self::SECUREMAX) {
- $this->secure = intval($secure);
- }
- }
-
- public function setcouleurtext($couleurtext)
- {
- $couleurtext = strval($couleurtext);
- if (strlen($couleurtext) <= self::LENCOULEUR) {
- $this->couleurtext = strip_tags(trim($couleurtext));
- }
- }
-
- public function setcouleurbkg($couleurbkg)
- {
- $couleurbkg = strval($couleurbkg);
- if (strlen($couleurbkg) <= self::LENCOULEUR) {
- $this->couleurbkg = strip_tags(trim($couleurbkg));
- }
- }
-
- public function setcouleurlien($couleurlien)
- {
- $couleurlien = strval($couleurlien);
- if (strlen($couleurlien) <= self::LENCOULEUR) {
- $this->couleurlien = strip_tags(trim($couleurlien));
- }
- }
-
- public function setcouleurlienblank($couleurlienblank)
- {
- $couleurlienblank = strval($couleurlienblank);
- if (strlen($couleurlienblank) <= self::LENCOULEUR) {
- $this->couleurlienblank = strip_tags(trim($couleurlienblank));
- }
- }
-
- public function setlien($lien)
- {
- if (!empty($lien) && strlen($lien) < self::LEN && is_string($lien)) {
- $lien = strip_tags(trim(strtolower($lien)));
- $lienlist = explode(", ", $lien);
- $this->lien = $lienlist;
- } else {
- $this->lien = [];
- }
- }
-
- public function setliento($liento)
- {
- if (is_array($liento)) {
- $this->liento = $liento;
- }
-
-
- }
-
- public function settemplate($template)
- {
- $template = strip_tags($template);
- if (strlen($template) == 0) {
- $template = 'NULL';
- }
- $this->template = $template;
- }
-
-
-}
-
-
-?> \ No newline at end of file
diff --git a/w/class/art2.php b/w/class/art2.php
index 2298147..5bad524 100644
--- a/w/class/art2.php
+++ b/w/class/art2.php
@@ -92,12 +92,7 @@ class Art2
$this->seteditcount(0);
}
- public function updatelinkfrom()
- {
- $this->linkfrom = [];
- $this->linkfrom = array_unique(search($this->md(true), self::DEBUT, self::FIN));
- }
public static function classvarlist()
{
@@ -108,64 +103,6 @@ class Art2
return ['artvarlist' => $classvarlist];
}
-
-
-
- public function calclinkto($getlist)
- {
- $linkto = [];
- if (!empty($getlist)) {
- foreach ($getlist as $link) {
- if (in_array($this->id(), $link->linkfrom('array'))) {
- $linkto[] = $link->id();
- }
- }
- $this->setlinkto($linkto);
- }
- }
-
-
- public function autotaglist()
- {
- $pattern = "/%%(\w*)%%/";
- preg_match_all($pattern, $this->md(), $out);
- return $out[1];
-
- }
-
- public function autotaglistupdate($taglist)
- {
- foreach ($taglist as $tag => $artlist) {
- $replace = '<ul>';
- foreach ($artlist as $art) {
- $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->description() . '">' . $art->title() . '</a></li>';
- }
- $replace .= '</ul>';
- $this->section = str_replace('%%' . $tag . '%%', $replace, $this->section);
- }
- }
-
- public function autotaglistcalc($taglist)
- {
- foreach ($taglist as $tag => $artlist) {
- foreach ($artlist as $art) {
- if (!in_array($art->id(), $this->linkfrom('array')) && $art->id() != $this->id()) {
- $this->linkfrom[] = $art->id();
- }
- }
- }
- }
-
- public function templaterender(array $vars)
- {
- $datas = [];
- foreach ($vars as $var) {
- if (method_exists($this, $var))
- $datas[$var] = $this->$var();
- }
- return $datas;
- }
-
public function dry()
{
$array = [];
@@ -211,7 +148,7 @@ class Art2
public function date($option = 'date')
{
if ($option == 'string') {
- return $this->date->format('Y-m-d H:i:s');
+ return $this->date->format(DateTime::ISO8601);
} elseif ($option == 'date' || $option == 'sort') {
return $this->date;
} elseif ($option == 'hrdi') {
@@ -225,7 +162,7 @@ class Art2
public function datecreation($option = 'date')
{
if ($option == 'string') {
- return $this->datecreation->format('Y-m-d H:i:s');
+ return $this->datecreation->format(DateTime::ISO8601);
} elseif ($option == 'date' || $option == 'sort') {
return $this->datecreation;
} elseif ($option == 'hrdi') {
@@ -238,7 +175,7 @@ class Art2
public function datemodif($option = 'date')
{
if ($option == 'string') {
- return $this->datemodif->format('Y-m-d H:i:s');
+ return $this->datemodif->format(DateTime::ISO8601);
} elseif ($option == 'date' || $option == 'sort') {
return $this->datemodif;
} elseif ($option == 'hrdi') {
@@ -250,7 +187,7 @@ class Art2
public function daterender($option = 'date')
{
if ($option == 'string') {
- return $this->daterender->format('Y-m-d H:i:s');
+ return $this->daterender->format(DateTime::ISO8601);
} elseif ($option == 'date' || $option == 'sort') {
return $this->daterender;
} elseif ($option == 'hrdi') {
@@ -322,56 +259,6 @@ class Art2
return $this->section;
}
- public function section888(App $app)
- {
-
- // %%%% TITLE & DESCIPTION
- $section = str_replace('%TITLE%', $this->title(), $this->section);
- $section = str_replace('%DESCRIPTION%', $this->description(), $section);
-
- $parser = new MarkdownExtra;
-
- // id in headers
- $parser->headerid_func = function ($header) {
- return preg_replace('/[^\w]/', '', strtolower($header));
- };
- $section = $parser->transform($section);
-
- // replace = > ?id=
- $section = str_replace('href="=', 'href="?id=', $section);
-
-
- // infobulles tooltip
- foreach ($this->linkfrom('array') as $id) {
- $title = "Cet article n'existe pas encore";
- foreach ($app->getlister(['id', 'description']) as $item) {
- if ($item->id() == $id) {
- $title = $item->description();
- }
- }
- $linkfrom = 'href="?id=' . $id . '"';
- $titlelinkfrom = ' title="' . $title . '" ' . $linkfrom;
- $section = str_replace($linkfrom, $titlelinkfrom, $section);
- }
-
- if (!empty(strstr($section, '%SUMMARY%'))) {
-
-
-
- $section = str_replace('%SUMMARY%', sumparser($section), $section);
- }
-
-
- $section = str_replace('href="./media/', ' class="file" target="_blank" href="./media/', $section);
- $section = str_replace('href="http', ' class="external" target="_blank" href="http', $section);
- $section = str_replace('<img src="/', '<img src="./media/', $section);
- $section = str_replace('<iframe', '<div class="iframe"><div class="container"><iframe class="video" ', $section);
- $section = str_replace('</iframe>', '</iframe></div></div>', $section);
- return $section;
-
-
- }
-
public function nav($type = "string")
{
return $this->nav;
@@ -509,7 +396,7 @@ class Art2
if ($date instanceof DateTimeImmutable) {
$this->date = $date;
} else {
- $this->date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date, new DateTimeZone('Europe/Paris'));
+ $this->date = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $date, new DateTimeZone('Europe/Paris'));
}
}
@@ -518,7 +405,7 @@ class Art2
if ($datecreation instanceof DateTimeImmutable) {
$this->datecreation = $datecreation;
} else {
- $this->datecreation = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datecreation, new DateTimeZone('Europe/Paris'));
+ $this->datecreation = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $datecreation, new DateTimeZone('Europe/Paris'));
}
}
@@ -527,7 +414,7 @@ class Art2
if ($datemodif instanceof DateTimeImmutable) {
$this->datemodif = $datemodif;
} else {
- $this->datemodif = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datemodif, new DateTimeZone('Europe/Paris'));
+ $this->datemodif = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $datemodif, new DateTimeZone('Europe/Paris'));
}
}
@@ -536,7 +423,7 @@ class Art2
if ($daterender instanceof DateTimeImmutable) {
$this->daterender = $daterender;
} else {
- $this->daterender = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $daterender, new DateTimeZone('Europe/Paris'));
+ $this->daterender = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $daterender, new DateTimeZone('Europe/Paris'));
}
}
diff --git a/w/class/controllerart.php b/w/class/controllerart.php
index 064474a..340e8e5 100644
--- a/w/class/controllerart.php
+++ b/w/class/controllerart.php
@@ -4,19 +4,23 @@ class Controllerart extends Controllerdb
{
/** @var Art2 */
protected $art;
-
-
- public function __construct($id) {
- parent::__construct();
+ protected $artmanager;
+ protected $renderengine;
-
+ public function __construct($id)
+ {
+ parent::__construct();
+
+
$this->art = new Art2(['id' => $id]);
+ $this->artmanager = new Modelart();
+ $this->renderengine = new Modelrender();
}
public function importart()
{
$art = $this->artmanager->get($this->art);
- if($art !== false) {
+ if ($art !== false) {
$this->art = $art;
//$this->art->autotaglistupdate($this->artmanager->taglist($this->artmanager->getlister(['id', 'title', 'description', 'tag']), $this->art->autotaglist()));
return true;
@@ -32,20 +36,22 @@ class Controllerart extends Controllerdb
$display = $this->user->level() >= $this->art->secure();
$cancreate = $this->user->cancreate();
- $this->showtemplate('read', ['art' => $this->art, 'artexist' => $artexist, 'display' => $display, 'cancreate' => $cancreate]);
-
+ $renderbody = $this->renderengine->render($this->art);
+
+ //$this->showtemplate('read', ['art' => $this->art, 'artexist' => $artexist, 'display' => $display, 'cancreate' => $cancreate]);
+
}
public function edit()
{
- if($this->importart() && $this->user->canedit()) {
+ if ($this->importart() && $this->user->canedit()) {
$this->showtemplate('edit', ['art' => $this->art, 'artexist' => true]);
} else {
$this->redirect('?id=' . $this->art->id());
}
-
+
}
public function log()
@@ -63,25 +69,33 @@ class Controllerart extends Controllerdb
public function delete()
{
- echo '<h2>Delete</h2>';
- $this->artmanager->delete($this->art);
+ if ($this->user->canedit() && $this->importart()) {
+
+ if (isset($_POST['deleteconfirm']) && $_POST['deleteconfirm'] == true) {
+ $this->artmanager->delete($this->art);
+ $this->redirect('?id=' . $this->art->id());
+ } else {
+ $this->showtemplate('delete', ['art' => $this->art, 'artexist' => true]);
+ }
+ } else {
+ $this->redirect('?id=' . $this->art->id());
+ }
}
public function update()
{
- if($this->importart()) {
+ if ($this->importart() && $this->user->canedit()) {
$this->art->hydrate($_POST);
- }
+ $this->art->updateedited();
+ $this->artmanager->update($this->art);
- // $this->art->updatelinkfrom();
- // $this->art->autotaglistcalc($this->artmanager->taglist($this->artmanager->getlister(['id', 'title', 'tag']), $this->art->autotaglist()));
- $this->artmanager->update($this->art);
+ }
$this->redirect('?id=' . $this->art->id() . '&aff=edit');
-
+
}
}
diff --git a/w/class/controllerconnect.php b/w/class/controllerconnect.php
new file mode 100644
index 0000000..2bda1b0
--- /dev/null
+++ b/w/class/controllerconnect.php
@@ -0,0 +1,18 @@
+<?php
+
+class Controllerconnect extends Controller
+{
+
+ public function desktop()
+ {
+ $this->showtemplate('connect', ['user' => $this->user]);
+ }
+
+}
+
+
+
+
+
+
+?> \ No newline at end of file
diff --git a/w/class/controllerdb.php b/w/class/controllerdb.php
index f21d265..54a9de1 100644
--- a/w/class/controllerdb.php
+++ b/w/class/controllerdb.php
@@ -11,31 +11,8 @@ class Controllerdb extends Controller
public function __construct()
{
parent::__construct();
- $this->artmanager = new Modelart();
-
- }
-
- public function fetch()
- {
- $datas = $this->artstore->fetch();
- return $datas;
- }
-
- public function desktop()
- {
-
-
- $this->dbinit();
- var_dump( $this->fetch());
-
-
- }
-
- public function add()
- {
- $user = $usersDB->where( 'name', '=', 'Joshua Edwards' )->fetch();
}
diff --git a/w/class/controllerhome.php b/w/class/controllerhome.php
index 6e62426..31d27c3 100644
--- a/w/class/controllerhome.php
+++ b/w/class/controllerhome.php
@@ -22,7 +22,7 @@ class Controllerhome extends Controllerdb
public function table2()
{
- $table = $this->artmanager->getlister();
+ $table = $this->modelhome->getlister();
$this->opt = $this->modelhome->optinit($table);
$table2 = $this->modelhome->table2($table, $this->opt);
@@ -37,8 +37,8 @@ class Controllerhome extends Controllerdb
if($this->user->level() >= Modeluser::EDITOR) {
$scan = new Modelanalyse;
$scan->analyseall();
-
- $this->table2();
+ $this->redirect('./');
+
}
}
diff --git a/w/class/model.php b/w/class/model.php
index 0eb3a2f..24c2404 100644
--- a/w/class/model.php
+++ b/w/class/model.php
@@ -9,7 +9,7 @@ class Model
const MEDIA_EXTENSIONS = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac', 'pdf');
const MEDIA_TYPES = ['image', 'video', 'sound', 'other'];
- const TEXT_ELEMENTS = ['section', 'header', 'nav', 'aside', 'footer'];
+ const TEXT_ELEMENTS = ['header', 'nav', 'section', 'aside', 'footer'];
diff --git a/w/class/modelanalyse.php b/w/class/modelanalyse.php
index b7819aa..379c41a 100644
--- a/w/class/modelanalyse.php
+++ b/w/class/modelanalyse.php
@@ -12,7 +12,7 @@ class Modelanalyse extends Modelart
public function analyseall()
{
- $artlist = $this->getlister(['*']);
+ $artlist = $this->getlister();
$artlist2 = [];
foreach ($artlist as $art) {
@@ -30,7 +30,7 @@ class Modelanalyse extends Modelart
{
$art->setlinkfrom($this->analyselinkfrom($art));
- $artlist = $this->getlister(['id', 'linkfrom']);
+ $artlist = $this->getlister();
$art->setlinkto($this->analyselinkto($art->id(), $artlist));
return $art;
diff --git a/w/class/modelart.php b/w/class/modelart.php
index be72611..37262ad 100644
--- a/w/class/modelart.php
+++ b/w/class/modelart.php
@@ -34,9 +34,12 @@ class Modelart extends Modeldb
$this->artstore->store($artdata);
}
- public function get(Art2 $art)
+ public function get($art)
{
- $artdata = $this->artstore->findById($art->id());
+ if($art instanceof Art2) {
+ $id = $art->id();
+ }
+ $artdata = $this->artstore->findById($id);
if($artdata !== false) {
return new Art2($artdata);
} else {
@@ -44,24 +47,18 @@ class Modelart extends Modeldb
}
}
+ public function delete(Art2 $art)
+ {
+ $this->artstore->delete($art->id());
+ }
+
public function update(Art2 $art)
{
- $art->updateedited();
$artdata = new \JamesMoss\Flywheel\Document($art->dry());
$artdata->setId($art->id());
$this->artstore->store($artdata);
}
- public function getlister()
- {
- $artlist = [];
- $list = $this->artstore->findAll();
- foreach ($list as $artdata) {
- $artlist[] = new Art2($artdata);
- }
- return $artlist;
- }
-
public function exist3($id)
{
diff --git a/w/class/modeldb.php b/w/class/modeldb.php
index d6a4c18..0d4e630 100644
--- a/w/class/modeldb.php
+++ b/w/class/modeldb.php
@@ -20,5 +20,30 @@ class Modeldb extends Model
$this->artstore = new \JamesMoss\Flywheel\Repository(Config::arttable(), $this->database);
}
+
+ public function getlister()
+ {
+ $artlist = [];
+ $list = $this->artstore->findAll();
+ foreach ($list as $artdata) {
+ $artlist[$artdata->id] = new Art2($artdata);
+ }
+ return $artlist;
+ }
+
+ public function getlisterid(array $idlist = [])
+ {
+ $artdatalist = $this->artstore->query()
+ ->where('__id', 'IN', $idlist)
+ ->execute();
+
+ $artlist = [];
+ foreach ($artdatalist as $id => $artdata) {
+ $artlist[$id] = new Art2($artdata);
+ }
+ return $artlist;
+ }
+
+
}
diff --git a/w/class/modelrender.php b/w/class/modelrender.php
index 219e88e..838765f 100644
--- a/w/class/modelrender.php
+++ b/w/class/modelrender.php
@@ -4,64 +4,80 @@ class Modelrender extends Modelart
{
const SUMMARY = '%SUMMARY%';
-
- public function __construct() {
+
+ public function __construct()
+ {
parent::__construct();
}
-
- public function getelements(Art2 $art)
+ public function render(Art2 $art)
{
- $templates = [];
- foreach ($art->template('array') as $element => $tempalteid) {
- if(isset($tempalteid) && $tempalteid != $art->id()) {
- $templateart = new Art2(['id' => $templateid]);
- $templateart = $this->get($templateart);
- $templates[$element] = $templateart->$element();
- }
- }
+ $body = $this->getbody($art);
+
+ var_dump($body);
+
+ $parsebody = $this->parser($art, $body);
+
+ echo $parsebody;
- $elements = [];
- foreach ($art->template('array') as $element) {
- if(array_key_exists($element, $templates)) {
- $elements[$element] = $templates[$element] . PHP_EOL . $art->$element();
+ return $parsebody;
+ }
+
+
+
+ public function getbody(Art2 $art)
+ {
+ $body = '';
+ foreach (self::TEXT_ELEMENTS as $element) {
+ if (array_key_exists($element, $art->template('array'))) {
+ $tempalteart = $this->get($art->template('array')[$element]);
+ $text = $tempalteart->$element() . PHP_EOL . $art->$element();
} else {
- $elements[$element] = $art->$element();
+ $text = $art->$element();
}
+ $body .= PHP_EOL . '<' . $element . '>' . PHP_EOL . $this->markdown($text) . PHP_EOL . '</' . $element . '>' . PHP_EOL;
}
- return $elements;
+
+ return $body;
}
- public function elementsrender(array $elements)
+ public function elementsrender(Art2 $art)
{
- foreach ($elements as $element => $text) {
- if(in_array($element, self::TEXT_ELEMENTS)) {
- $elements[$element] = $this->textrender($text);
+ foreach ($this->getelements($art) as $element => $text) {
+ if (in_array($element, self::TEXT_ELEMENTS)) {
+ $elements[$element] = $this->markdown($text);
}
}
return $elements;
}
-
- public function textrender($text)
+
+ public function parser(Art2 $art, string $text)
{
+ $text = str_replace('%TITLE%', $art->title(), $text);
+ $text = str_replace('%DESCRIPTION%', $art->description(), $text);
+
+
+ $text = str_replace(self::SUMMARY, $this->sumparser($text), $text);
+
+ $text = str_replace('href="=', 'href="?id=', $text);
+ $text = $this->tooltip($art->linkfrom('array'), $text);
+
+ $text = str_replace('href="http', ' class="external" target="_blank" href="http', $text);
+ $text = str_replace('<img src="/', '<img src="./media/', $text);
+
+ $text = $this->autourl($text);
+
+ return $text;
}
- public function parser($text)
+ public function autourl($text)
{
- $text = str_replace('%TITLE%', $this->title(), $this->text);
- $text = str_replace('%DESCRIPTION%', $this->description(), $text);
-
- $text = $this->markdown($text);
-
- $text = str_replace('%SUMMARY%', sumparser($text), $text);
-
- $text = str_replace('href="=', 'href="?id=', $text);
-
+ $text = preg_replace('#( |\R|>)(https?:\/\/((\S+)\.([^< ]+)))#', '$1<a href="$2" class="external" target="_blank">$3</a>', $text);
return $text;
}
@@ -81,64 +97,27 @@ class Modelrender extends Modelart
- public function tooltip($linkfrom, $text)
+ public function tooltip(array $linkfrom, string $text)
{
$descriptions = [];
- $artlist = $app->getlisterwhere(['id', 'description'], $linkfrom);
+ $artlist = $this->getlisterid($linkfrom);
foreach ($artlist as $art) {
$descriptions[$art->id()] = $art->description();
}
-
-
foreach ($linkfrom as $id) {
- if(isset($descriptions[$id])) {
+ if (isset($descriptions[$id])) {
$title = $descriptions[$id];
- } else {
- $title = "This page does not exist yet";
}
$linkfrom = 'href="?id=' . $id . '"';
$titlelinkfrom = ' title="' . $title . '" ' . $linkfrom;
$text = str_replace($linkfrom, $titlelinkfrom, $text);
}
+ return $text;
}
- public function parserff($text)
- {
- $section = str_replace('%TITLE%', $this->title(), $this->section);
- $section = str_replace('%DESCRIPTION%', $this->description(), $section);
-
- // replace = > ?id=
- $section = str_replace('href="=', 'href="?id=', $section);
-
-
- // infobulles tooltip
-
-
-
-
- if (!empty(strstr($section, '%SUMMARY%'))) {
-
-
-
-
- }
-
-
- $section = str_replace('href="./media/', ' class="file" target="_blank" href="./media/', $section);
- $section = str_replace('href="http', ' class="external" target="_blank" href="http', $section);
- $section = str_replace('<img src="/', '<img src="./media/', $section);
- $section = str_replace('<iframe', '<div class="iframe"><div class="container"><iframe class="video" ', $section);
- $section = str_replace('</iframe>', '</iframe></div></div>', $section);
- return $section;
-
- }
-
-
-
-
function sumparser($text)
{
preg_match_all('#<h([1-6]) id="(\w+)">(.+)</h[1-6]>#iU', $text, $out);
@@ -154,18 +133,18 @@ class Modelrender extends Modelart
$last = 0;
foreach ($sum as $title => $list) {
foreach ($list as $h => $link) {
- if($h > $last) {
+ if ($h > $last) {
for ($i = 1; $i <= ($h - $last); $i++) {
$sumstring .= '<ul>';
- }
- $sumstring .= '<li><a href="#'.$title.'">'.$link.'</a></li>' ;
+ }
+ $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
} elseif ($h < $last) {
for ($i = 1; $i <= ($last - $h); $i++) {
$sumstring .= '</ul>';
}
- $sumstring .= '<li><a href="#'.$title.'">'.$link.'</a></li>' ;
+ $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
} elseif ($h = $last) {
- $sumstring .= '<li><a href="#'.$title.'">'.$link.'</a></li>' ;
+ $sumstring .= '<li><a href="#' . $title . '">' . $link . '</a></li>';
}
$last = $h;
}
@@ -178,6 +157,40 @@ class Modelrender extends Modelart
+ //tag auto menu
+
+
+ public function autotaglist()
+ {
+ $pattern = "/%%(\w*)%%/";
+ preg_match_all($pattern, $this->md(), $out);
+ return $out[1];
+
+ }
+
+ public function autotaglistupdate($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ $replace = '<ul>';
+ foreach ($artlist as $art) {
+ $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->description() . '">' . $art->title() . '</a></li>';
+ }
+ $replace .= '</ul>';
+ $text = str_replace('%%' . $tag . '%%', $replace, $text);
+ }
+ }
+
+ public function autotaglistcalc($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ foreach ($artlist as $art) {
+ if (!in_array($art->id(), $this->linkfrom('array')) && $art->id() != $this->id()) {
+ $this->linkfrom[] = $art->id();
+ }
+ }
+ }
+ }
+
}
diff --git a/w/class/router.php b/w/class/router.php
index 27ac4e4..604fb84 100644
--- a/w/class/router.php
+++ b/w/class/router.php
@@ -32,6 +32,7 @@ class Router
'aff=media' => ['media', 'desktop'],
'aff=media action=addmedia' => ['media', 'addmedia'],
'aff=admin' => ['admin', 'desktop'],
+ 'aff=co' => ['connect', 'desktop'],
];
public function __construct() {
diff --git a/w/view/templates/connect.php b/w/view/templates/connect.php
new file mode 100644
index 0000000..3e2aeba
--- /dev/null
+++ b/w/view/templates/connect.php
@@ -0,0 +1,30 @@
+<?php $this->layout('layout', ['title' => 'Connect', 'description' => 'connect']) ?>
+
+
+
+
+<?php $this->start('page') ?>
+
+<span>
+<?= $user->level() ?>
+</span>
+
+<?php if($user->isvisitor()) { ?>
+
+<form action="./?action=login" method="post">
+<input type="password" name="pass" id="loginpass" placeholder="password">
+<input type="submit" value="login">
+</form>
+
+
+<?php } else { ?>
+
+<form action="./?action=logout" method="post">
+<input type="submit" value="logout">
+</form>
+
+
+
+<?php } ?>
+
+<?php $this->stop() ?> \ No newline at end of file
diff --git a/w/view/templates/delete.php b/w/view/templates/delete.php
new file mode 100644
index 0000000..be54451
--- /dev/null
+++ b/w/view/templates/delete.php
@@ -0,0 +1,44 @@
+<?php $this->layout('layout', ['title' => 'delete', 'description' => 'delete']) ?>
+
+
+<?php $this->start('page') ?>
+
+
+<?php $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist]) ?>
+
+<div>
+
+<h1>Delete</h1>
+
+<ul>
+<li>Id : <?= $art->title() ?></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>
+</ul>
+
+<?php if (!empty($art->linkto())) { ?>
+
+<h2>Article linked to :</h2>
+
+<ul>
+<?php foreach ($art->linkto('array') as $linkto) {
+ echo '<li><a href="./?id=' . $linkto . '">' . $linkto . '</a></li>';
+} ?>
+</ul>
+
+<?php
+} ?>
+
+</div>
+
+
+<form action="./?id=<?= $art->id() ?>&action=delete" method="post">
+<input type="hidden" name="deleteconfirm" value="true">
+<input type="submit" value="confirm delete">
+</form>
+
+
+
+<?php $this->stop() ?> \ No newline at end of file
diff --git a/w/view/templates/edit.php b/w/view/templates/edit.php
index 4db6706..ee231cd 100644
--- a/w/view/templates/edit.php
+++ b/w/view/templates/edit.php
@@ -20,8 +20,6 @@
<?php $this->insert('navart', ['user' => $user, 'art' => $art, 'artexist' => $artexist]) ?>
-<form action="?id=<?= $art->id() ?>&action=update" method="post" id="artedit">
-
<?php $this->insert('edittopbar', ['art' => $art]) ?>
<?php $this->insert('editsidebar', ['art' => $art]) ?>
diff --git a/w/view/templates/edittopbar.php b/w/view/templates/edittopbar.php
index ffd1c0f..9973335 100644
--- a/w/view/templates/edittopbar.php
+++ b/w/view/templates/edittopbar.php
@@ -1,12 +1,23 @@
<div id="submit">
<!-- <input type="submit" name="action" value="home" accesskey="w" onclick="document.getElementById('artedit').submit();" form="artedit"> -->
- <input type="submit" name="action" value="update" accesskey="x" onclick="document.getElementById('artedit').submit();" form="artedit">
+ <input type="submit" name="action" value="update" accesskey="x" form="update">
<!-- <input type="submit" name="action" value="display" accesskey="c" onclick="document.getElementById('artedit').submit();" form="artedit"> -->
- <!-- <input type="submit" name="action" value="delete" onclick="confirmSubmit(event, 'Delete this article', 'artedit')" form="artedit"> -->
+
+
+
+ <form id="delete" action="./" method="get">
+ <input type="hidden" name="id" value="<?= $art->id() ?>">
+ <input type="submit" name="action" value="delete" form="delete">
+ </form>
+
+
<a href="?id=<?= $art->id() ?>" target="_blank">πŸ‘</a>
<a href="?id=<?= $art->id() ?>&aff=log" target="_blank">ΒΆ</a>
<span id="headid"><?= $art->id() ?></span>
+
+ <form action="?id=<?= $art->id() ?>&action=update" method="post" id="update">
+
<label for="fontsize">Font-size</label>
<input type="number" name="fontsize" value="<?= Config::fontsize() ?>" id="fontsize">
</div> \ No newline at end of file
diff --git a/w/view/templates/home.php b/w/view/templates/home.php
index 34bac1a..2303f0f 100644
--- a/w/view/templates/home.php
+++ b/w/view/templates/home.php
@@ -10,8 +10,28 @@
<?php $this->insert('navback', ['user' => $user]) ?>
+<?php if($user->canedit()) { ?>
<section>
+
+<div>
+
+<form id="goto" action="./" method="get">
+<input type="text" name="id" placeholder="id" required>
+<input type="submit" name="aff" value="read">
+<input type="submit" name="aff" value="edit">
+<input type="submit" name="action" value="add">
+</form>
+
+
+<form action="./" method="get">
+<input type="submit" name="action" value="analyseall">
+</form>
+
+
+</div>
+
+
<div id="flex">
@@ -55,13 +75,14 @@
<table id="home2table">
- <tr><th>x</th><th>id</th><th>edit</th><th>see</th><th>log</th><th>tag</th><th>summary</th><th>β†˜ to</th><th>β†— from</th><th>last modification</th><th>date of creation</th><th>privacy</th></tr>
+ <tr><th>x</th><th>id</th><th>edit</th><th>see</th><th>del</th><th>log</th><th>tag</th><th>summary</th><th>β†˜ to</th><th>β†— from</th><th>last modification</th><th>date of creation</th><th>privacy</th></tr>
<?php foreach ($table2 as $item) { ?>
<tr>
<td><input type="checkbox" name="id[]" value="<?= $item->id() ?>" id="<?= $item->id() ?>"></td>
<td><label title="<?= $item->title() ?>" for="<?= $item->id() ?>"><?= $item->id() ?></label></td>
<td><a href="?id=<?= $item->id() ?>&aff=edit">✏</a></td>
<td><a href="?id=<?= $item->id() ?>" target="_blank">πŸ‘</a></td>
+ <td><a href="?id=<?= $item->id() ?>&action=delete" >πŸ—‘</a></td>
<td><a href="?id=<?= $item->id() ?>&aff=log" target="_blank">ΒΆ</a></td>
<td><?= $item->tag('sort') ?></td>
<td><?= $item->description() ?></td>
@@ -78,6 +99,9 @@
</div>
</div>
</section>
+
+<?php } ?>
+
</body>