diff options
Diffstat (limited to 'app/class')
-rw-r--r-- | app/class/art2.php | 6 | ||||
-rw-r--r-- | app/class/controllerhome.php | 4 | ||||
-rw-r--r-- | app/class/modelart.php | 5 | ||||
-rw-r--r-- | app/class/modelhome.php | 16 | ||||
-rw-r--r-- | app/class/modelrender.php | 45 | ||||
-rw-r--r-- | app/class/optlist.php | 15 |
6 files changed, 77 insertions, 14 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 = '<ul>' . PHP_EOL ; + foreach ($table2 as $page ) { + $content .= '<li>' . PHP_EOL; + $content .= '<a href="' . $this->uart($page->id()) . '">' . $page->title() . '</a>' . PHP_EOL; + if($optlist->description()) { + $content .= '<em>' . $page->description() . '</em>' . PHP_EOL; + } + if($optlist->date()) { + $content .= '<code>' . $page->date('pdate') . '</code>' . PHP_EOL; + } + if($optlist->author()) { + $content .= $page->authors('string') . PHP_EOL; + } + $content .= '</li>'; + } + $content .= '</ul>'; + + $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); } |