From b49830232096951202688bd775193424880bbd11 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Tue, 7 Apr 2020 19:43:58 +0200 Subject: refactor LIST fix #74 --- app/class/Optlist.php | 120 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 83 insertions(+), 37 deletions(-) (limited to 'app/class/Optlist.php') diff --git a/app/class/Optlist.php b/app/class/Optlist.php index 122072b..37f9343 100644 --- a/app/class/Optlist.php +++ b/app/class/Optlist.php @@ -10,16 +10,13 @@ class Optlist extends Opt protected $date = 0; protected $time = 0; protected $author = 0; - protected $style = 0; - - /** @var Modelrender Render engine used to generate pages urls */ - protected $render = null; - + protected $style = 'list'; + protected $render; public function parsehydrate(string $encoded) { - if(is_string($encoded)) { + if (is_string($encoded)) { parse_str($encoded, $datas); $this->hydrate($datas); } @@ -28,40 +25,94 @@ class Optlist extends Opt /** * Get the code to insert directly */ - public function getcode() : string + public function getcode(): string { return '%LIST?' . $this->getquery() . '%'; } - public function listhtml(array $pagelist) - { - if(!empty($this->render)) { - $content = ''; + if ($this->thumbnail) { + $content .= '' . $page->title() . ''; + } + + - return $content; - + switch ($this->style) { + case 'card': + $li .= $this->li($this->a($title . $content, $class, $page->id()), $page->id()); + break; + + case 'list': + $li .= $this->li($this->a($title, $class, $page->id()) . $content, $page->id()); + break; + } } + + $html = $this->ul($li); + + return $html; + } + + public function ul(string $content) + { + return ''; } + public function li(string $content, string $id) + { + return '
  • ' . PHP_EOL . $content . PHP_EOL . '
  • ' . PHP_EOL; + } + + public function a(string $content, string $class, string $id) + { + return '' . $content . '' . PHP_EOL; + } + + public function spandescription(Page $page) + { + if ($this->description) { + return '' . $page->description() . ''; + } else { + return ''; + } + } + + // _______________________________________ G E T _____________________________________ @@ -137,13 +188,8 @@ class Optlist extends Opt public function setstyle($style) { - $this->style = intval($style); - } - - public function setrender($render) - { - if(is_a($render, 'Wcms\Modelrender')) { - $this->render = $render; + if (is_string($style) && key_exists($style, Model::LIST_STYLES)) { + $this->style = $style; } } } -- cgit v1.2.3