diff options
Diffstat (limited to 'app/class/Opt.php')
-rw-r--r-- | app/class/Opt.php | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/app/class/Opt.php b/app/class/Opt.php index e920cb7..e0a8492 100644 --- a/app/class/Opt.php +++ b/app/class/Opt.php @@ -11,14 +11,15 @@ class Opt extends Item protected $authorfilter = []; protected $authorcompare = 'AND'; protected $secure = 4; - protected $linkto = ['min' => '0', 'max' => '0']; - protected $linkfrom = ['min' => '0', 'max' => '0']; + protected $linkto = ''; protected $col = ['id']; protected $taglist = []; protected $authorlist = []; protected $invert = 0; protected $limit = 0; + protected $pageidlist = []; + protected $pagevarlist; public function __construct(array $donnees = []) @@ -63,7 +64,7 @@ class Opt extends Item public function getall() { - $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'authorcompare', 'authorfilter', 'limit', 'invert']; + $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'authorcompare', 'authorfilter', 'limit', 'invert', 'linkto']; foreach ($optlist as $method) { if (method_exists($this, $method)) { @@ -140,6 +141,15 @@ class Opt extends Item return '<a class="secure ' . $secure . '" href="?' . $this->getfilteradress(['secure' => $level]) . '">' . $secure . '</a>' . PHP_EOL; } + public function linktolink(array $linkfromlist) + { + $linkfromstring = ""; + foreach ($linkfromlist as $linkfrom ) { + $linkfromstring .= '<a class="linkfrom" href="?' . $this->getfilteradress(['linkto' => $linkfrom]) . '" >' . $linkfrom . '</a>' . PHP_EOL; + } + return $linkfromstring; + } + public function getfilteradress(array $vars = []) { @@ -230,16 +240,11 @@ class Opt extends Item return $this->authorcompare; } - public function linkto($type = 'array') + public function linkto($type = 'string') { return $this->linkto; } - public function linkfrom($type = 'array') - { - return $this->linkfrom; - } - public function col($type = 'array') { if ($type == 'string') { @@ -274,6 +279,11 @@ class Opt extends Item return $this->limit; } + public function pageidlist() + { + return $this->pageidlist; + } + // __________________________________________________ S E T _____________________________________________ @@ -339,14 +349,19 @@ class Opt extends Item } } - public function setlinkto($range) + public function setlinkto($linkto) : bool { - $this->linkto = $range; - } - - public function setlinkfrom($range) - { - $this->linkfrom = $range; + if (is_string($linkto)) { + if (in_array($linkto, $this->pageidlist)) { + + $this->linkto = idclean($linkto); + return true; + } else { + return false; + } + } else { + return false; + } } public function setlinktomin($min) @@ -428,6 +443,29 @@ class Opt extends Item $this->limit = $limit; } + /** + * Import list of pages IDs + * + * @param array $pageidlist could be array of IDs or array of Page Object + * + * @return bool false if array content isn't string or Pages, otherwise : true + */ + public function setpageidlist(array $pageidlist) : bool + { + $idlist = []; + foreach ($pageidlist as $item) { + if (is_string($item)) { + $idlist[] = $item; + } elseif ($item instanceof Page) { + $idlist[] = $item->id(); + } else { + return false; + } + } + $this->pageidlist = $idlist; + return true; + } + public function setpagevarlist(array $pagevarlist) { |