aboutsummaryrefslogtreecommitdiff
path: root/app/class/opt.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-01-30 15:56:04 +0100
committervincent-peugnet <v.peugnet@free.fr>2019-01-30 15:56:04 +0100
commit396a5776cd043e899e4897ec50fc8edc52585512 (patch)
tree51714a3aa981e698f4573f0ce54e22e1dc8338a8 /app/class/opt.php
parent3309bd722454fa8696ce2415075f401e444c9910 (diff)
downloadwcms-396a5776cd043e899e4897ec50fc8edc52585512.tar.gz
wcms-396a5776cd043e899e4897ec50fc8edc52585512.zip
author filter home
Diffstat (limited to 'app/class/opt.php')
-rw-r--r--app/class/opt.php61
1 files changed, 59 insertions, 2 deletions
diff --git a/app/class/opt.php b/app/class/opt.php
index 6ea3e7e..9eddf9f 100644
--- a/app/class/opt.php
+++ b/app/class/opt.php
@@ -5,11 +5,14 @@ class Opt
private $order = 1;
private $tagfilter = [];
private $tagcompare = 'OR';
+ private $authorfilter = [];
+ private $authorcompare = 'OR';
private $secure = 4;
private $linkto = ['min' => '0', 'max' => '0'];
private $linkfrom = ['min' => '0', 'max' => '0'];
private $col = ['id'];
private $taglist = [];
+ private $authorlist = [];
private $invert = 0;
private $artvarlist;
@@ -64,7 +67,7 @@ class Opt
public function getall()
{
- $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'invert'];
+ $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'authorcompare', 'authorfilter', 'invert'];
foreach ($optlist as $method) {
if (method_exists($this, $method)) {
@@ -101,6 +104,10 @@ class Opt
foreach ($this->tagfilter as $tag) {
$adress .= '&tagfilter[]=' . $tag;
}
+ $adress .= '&authorcompare=' . $this->authorcompare;
+ foreach ($this->authorfilter as $author) {
+ $adress .= '&authorfilter[]=' . $author;
+ }
if($this->invert == 1) {
$adress .= '&invert=1';
}
@@ -141,6 +148,16 @@ class Opt
return $this->tagcompare;
}
+ public function authorfilter($type = 'array')
+ {
+ return $this->authorfilter;
+ }
+
+ public function authorcompare()
+ {
+ return $this->authorcompare;
+ }
+
public function linkto($type = 'array')
{
return $this->linkto;
@@ -165,6 +182,11 @@ class Opt
return $this->taglist;
}
+ public function authorlist()
+ {
+ return $this->authorlist;
+ }
+
public function invert()
{
return $this->invert;
@@ -213,6 +235,26 @@ class Opt
}
}
+ public function setauthorfilter($authorfilter)
+ {
+ if (!empty($authorfilter) && is_array($authorfilter)) {
+ $authorfilterverif = [];
+ foreach ($authorfilter as $author) {
+ if(array_key_exists($author, $this->authorlist)) {
+ $authorfilterverif[] = $author;
+ }
+ }
+ $this->authorfilter = $authorfilterverif;
+ }
+ }
+
+ public function setauthorcompare($authorcompare)
+ {
+ if (in_array($authorcompare, ['OR', 'AND'])) {
+ $this->authorcompare = $authorcompare;
+ }
+ }
+
public function setsecure($secure)
{
if ($secure >= 0 && $secure <= 5) {
@@ -257,7 +299,6 @@ class Opt
}
}
-
public function settaglist(array $artlist)
{
$taglist = [];
@@ -274,6 +315,22 @@ class Opt
$this->taglist = $taglist;
}
+ public function setauthorlist(array $artlist)
+ {
+ $authorlist = [];
+ foreach ($artlist as $art) {
+ foreach ($art->authors('array') as $author) {
+ if (!array_key_exists($author, $authorlist)) {
+ $authorlist[$author] = 1;
+ } else {
+ $authorlist[$author]++;
+ }
+ }
+ }
+ $authorlistsorted = arsort($authorlist);
+ $this->authorlist = $authorlist;
+ }
+
public function setinvert(int $invert)
{
if ($invert == 0 || $invert == 1) {