From d9a0fb2efc8c09ab00b76bb68ec0d1f24ef7d1a5 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 29 Jan 2020 13:32:58 +0100 Subject: new feature : author clickables in home view --- app/class/Opt.php | 39 ++++++++++++++++++++++++++++++++++++--- app/view/templates/home.php | 4 ++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/app/class/Opt.php b/app/class/Opt.php index 6697c63..4e1eb72 100644 --- a/app/class/Opt.php +++ b/app/class/Opt.php @@ -87,7 +87,7 @@ class Opt extends Item public function getadress() { - $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorcompare', 'author', 'invert', 'limit']); + $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorfilter', 'authorcompare', 'invert', 'limit']); $object['submit'] = 'filter'; return '?' . urldecode(http_build_query($object)); @@ -95,7 +95,7 @@ class Opt extends Item public function sortbyorder($sortby = "") { - $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorcompare', 'author', 'invert', 'limit']); + $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorfilter', 'authorcompare', 'invert', 'limit']); if(!empty($sortby)) { $object['sortby'] = $sortby; } @@ -128,7 +128,7 @@ class Opt extends Item */ public function gettagadress(string $tag = "") : string { - $object = $this->drylist(['sortby', 'order', 'secure', 'tagcompare', 'authorcompare', 'author', 'invert', 'limit']); + $object = $this->drylist(['sortby', 'order', 'secure', 'tagcompare', 'authorfilter', 'authorcompare', 'invert', 'limit']); if(!empty($tag)) { $object['tagfilter'][] = $tag; } @@ -138,6 +138,39 @@ class Opt extends Item } + /** + * Get the link list for each authors of an page + * + * @param array $authorlist List of author to be + * @return string html code to be printed + */ + public function author(array $authorlist = []) : string + { + $authorstring = ""; + foreach ($authorlist as $author ) { + $authorstring .= '' . $author . '' . PHP_EOL; + } + return $authorstring; + } + + /** + * Generate http query based on a new authorfilter input + * + * @param string $author The author to be selected + * @return string Query string without `?` + */ + public function getauthoradress(string $author = "") : string + { + $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorcompare', 'invert', 'limit']); + if(!empty($author)) { + $object['authorfilter'][] = $author; + } + $object['submit'] = 'filter'; + + return urldecode(http_build_query($object)); + } + + /** * Get the query as http string * diff --git a/app/view/templates/home.php b/app/view/templates/home.php index ceaa98c..6b3bca3 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -124,8 +124,8 @@ secure('string') ?> - authors('string') ?> - author($item->authors('array')) ?> + visitcount() ?>