diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2020-01-29 13:32:58 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2020-01-29 13:32:58 +0100 |
commit | d9a0fb2efc8c09ab00b76bb68ec0d1f24ef7d1a5 (patch) | |
tree | 8840c03f8af7559a9ee8aad539e3945a7cda873a | |
parent | 5aa781242e42c95c6f2e04a30510d853a89fa944 (diff) | |
download | wcms-d9a0fb2efc8c09ab00b76bb68ec0d1f24ef7d1a5.tar.gz wcms-d9a0fb2efc8c09ab00b76bb68ec0d1f24ef7d1a5.zip |
new feature : author clickables in home view
-rw-r--r-- | app/class/Opt.php | 39 | ||||
-rw-r--r-- | 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; } @@ -139,6 +139,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 .= '<a class="tag" href="?' . $this->getauthoradress($author) . '" >' . $author . '</a>' . 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 * * @return string The resulted query 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 @@ <td class="secure"><?= $item->secure('string') ?></td> <?php } if ($columns['authors']) { ?> - <td class="authors"><?= $item->authors('string') ?></td> - <?php } + <td class="authors"><?= $opt->author($item->authors('array')) ?></td> + <?php } if ($columns['visitcount']) { ?> <td class="visitcount"><?= $item->visitcount() ?></td> <?php } |