From 0d863868d69d9e2c9ae3f6f0b22b4d3a1be73ee2 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sat, 17 Aug 2019 00:02:21 +0200 Subject: Feature : list is going to work soon --- app/class/art2.php | 6 +++++- app/class/controllerhome.php | 4 +--- app/class/modelart.php | 5 +++++ app/class/modelhome.php | 16 ++++++++++++++++ app/class/modelrender.php | 45 ++++++++++++++++++++++++++++++++++++++++++++ app/class/optlist.php | 15 +++++---------- app/view/templates/home.php | 8 ++++---- assets/css/home.css | 3 ++- composer.json | 2 +- 9 files changed, 84 insertions(+), 20 deletions(-) diff --git a/app/class/art2.php b/app/class/art2.php index a43d35e..4561773 100644 --- a/app/class/art2.php +++ b/app/class/art2.php @@ -431,7 +431,11 @@ class Art2 public function authors($type = 'array') { - return $this->authors; + if($type == 'string') { + return implode(', ', $this->authors); + } elseif ($type == 'array') { + return $this->authors; + } } public function invites($type = 'array') diff --git a/app/class/controllerhome.php b/app/class/controllerhome.php index c053270..166ada9 100644 --- a/app/class/controllerhome.php +++ b/app/class/controllerhome.php @@ -36,9 +36,7 @@ class Controllerhome extends Controller if(isset($_POST['query']) && $this->user->iseditor()) { $datas = array_merge($_POST, $_SESSION['opt']); - $this->optlist = new Optlist(Art2::classvarlist()); - $this->optlist->settaglist($table); - $this->optlist->setauthorlist($table); + $this->optlist = $this->modelhome->Optlistinit($table); $this->optlist->hydrate($datas); $vars['optlist'] = $this->optlist; } diff --git a/app/class/modelart.php b/app/class/modelart.php index f5b4858..8462675 100644 --- a/app/class/modelart.php +++ b/app/class/modelart.php @@ -13,6 +13,11 @@ class Modelart extends Modeldb $this->storeinit(Config::arttable()); } + /** + * Scan library for all pages as objects + * + * @return array of Pages objects + */ public function getlister() { $artlist = []; diff --git a/app/class/modelhome.php b/app/class/modelhome.php index 5b3b5a5..3347edf 100644 --- a/app/class/modelhome.php +++ b/app/class/modelhome.php @@ -19,6 +19,22 @@ class Modelhome extends Modelart return $opt; } + /** + * Initialise Optlist object using + * + * @param array $table the list of all pages objects + * + * @return Optlist Object initialized + */ + public function Optlistinit(array $table) + { + $optlist = new Optlist(Art2::classvarlist()); + $optlist->settaglist($table); + $optlist->setauthorlist($table); + + return $optlist; + } + diff --git a/app/class/modelrender.php b/app/class/modelrender.php index aa444f0..3d8f25f 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -143,6 +143,7 @@ class Modelrender extends Modelart { $content = $this->article($element->content()); $content = $this->automedialist($content); + $content = $this->pagelist($content); $content = $this->autotaglistupdate($content); $content = $this->date($content); $content = $this->thumbnail($content); @@ -583,6 +584,50 @@ class Modelrender extends Modelart return $text; } + /** + * Render pages list + */ + public function pagelist(string $text) : string + { + preg_match_all('~\%LIST\?([a-zA-Z0-9\]\[\&=\-\/\%]*)\%~', $text, $out); + + foreach ($out[0] as $key => $match) { + $matches[$key] = ['fullmatch' => $match, 'options' => $out[1][$key]]; + } + + $modelhome = new Modelhome(); + + if(isset($matches)) { + foreach ($matches as $match) { + $optlist = $modelhome->Optlistinit($this->artlist); + $optlist->parsehydrate($match['options']); + $table2 = $modelhome->table2($this->artlist, $optlist); + + $content = ''; + + $text = str_replace($match['fullmatch'], $content, $text); + } + } + return $text; + } + + + diff --git a/app/class/optlist.php b/app/class/optlist.php index cf68fa7..5190596 100644 --- a/app/class/optlist.php +++ b/app/class/optlist.php @@ -9,18 +9,13 @@ class Optlist extends Opt private $style = 0; - /** - * New constructor dedicated to parse input string - * - * @param string|array $parsedstring parsed query string - */ - public function __construct($datas = []) - { - if(is_string($datas)) { - $datas = parse_str($this->options, $datas); + public function parsehydrate(string $encoded) + { + if(is_string($encoded)) { + parse_str($encoded, $datas); + $this->hydrate($datas); } - $this->hydrate($datas); } diff --git a/app/view/templates/home.php b/app/view/templates/home.php index 922aaf0..c226a9d 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -26,9 +26,10 @@
-

Pages

+

Pages ()

-
+ +
Import W JSON page file Upload page file as json
@@ -53,7 +54,7 @@
-
> +
> Generate list Generate code to display a list of pages
@@ -111,7 +112,6 @@ - diff --git a/assets/css/home.css b/assets/css/home.css index 8d43330..a5905d7 100644 --- a/assets/css/home.css +++ b/assets/css/home.css @@ -389,7 +389,7 @@ main.timeline li.event { @media (max-width: 600px) { - main.home .summary, main.home .linkfrom, main.home .linkto, main.home .delete, main.home .datecreation, main.home .date, main.home .log, main.home .secure, main.home .tag { + main.home .summary, main.home .linkfrom, main.home .linkto, main.home .delete, main.home .datecreation, main.home .date, main.home .log, main.home .secure, main.home .tag, .hidephone { display: none; } @@ -405,3 +405,4 @@ main.timeline li.event { } + diff --git a/composer.json b/composer.json index 69d5a98..f706a73 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "w-cms", "description": "point'n think", - "version": "1.4.2", + "version": "1.4.3", "require": { "michelf/php-markdown": "^1.8", "league/plates": "3.*", -- cgit v1.2.3