diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2020-01-29 14:18:52 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2020-01-29 14:18:52 +0100 |
commit | dbdff59c140fe45d858f4dc2c611daf56005aef6 (patch) | |
tree | 8ea90353999d740bb47e7d03d7a64f7e8f9f37d0 /app | |
parent | d9a0fb2efc8c09ab00b76bb68ec0d1f24ef7d1a5 (diff) | |
download | wcms-dbdff59c140fe45d858f4dc2c611daf56005aef6.tar.gz wcms-dbdff59c140fe45d858f4dc2c611daf56005aef6.zip |
new feature : secure level coloration in home
Diffstat (limited to 'app')
-rw-r--r-- | app/class/Opt.php | 50 | ||||
-rw-r--r-- | app/view/templates/home.php | 6 |
2 files changed, 19 insertions, 37 deletions
diff --git a/app/class/Opt.php b/app/class/Opt.php index 4e1eb72..253e4f6 100644 --- a/app/class/Opt.php +++ b/app/class/Opt.php @@ -111,66 +111,48 @@ class Opt extends Item * @param array $taglist List of tag to be * @return string html code to be printed */ - public function tag(array $taglist = []) : string + public function taglinks(array $taglist = []) : string { $tagstring = ""; foreach ($taglist as $tag ) { - $tagstring .= '<a class="tag" href="?' . $this->gettagadress($tag) . '" >' . $tag . '</a>' . PHP_EOL; + $tagstring .= '<a class="tag tag_' . $tag . '" href="?' . $this->getfilteradress(['tagfilter' => [$tag]]) . '" >' . $tag . '</a>' . PHP_EOL; } return $tagstring; } /** - * Generate http query based on a new tagfilter input - * - * @param string $tag The tag to be selected - * @return string Query string without `?` - */ - public function gettagadress(string $tag = "") : string - { - $object = $this->drylist(['sortby', 'order', 'secure', 'tagcompare', 'authorfilter', 'authorcompare', 'invert', 'limit']); - if(!empty($tag)) { - $object['tagfilter'][] = $tag; - } - $object['submit'] = 'filter'; - - return urldecode(http_build_query($object)); - } - - - /** * 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 + public function authorlinks(array $authorlist = []) : string { $authorstring = ""; foreach ($authorlist as $author ) { - $authorstring .= '<a class="tag" href="?' . $this->getauthoradress($author) . '" >' . $author . '</a>' . PHP_EOL; + $authorstring .= '<a class="tag author_' . $author . '" href="?' . $this->getfilteradress(['authorfilter' => [$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 + public function securelink(int $level, string $secure) { - $object = $this->drylist(['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorcompare', 'invert', 'limit']); - if(!empty($author)) { - $object['authorfilter'][] = $author; - } - $object['submit'] = 'filter'; + return '<a class="secure ' . $secure . '" href="?' . $this->getfilteradress(['secure' => $level]) . '">' . $secure . '</a>' . PHP_EOL; + } + + public function getfilteradress(array $vars = []) + { + $varlist = ['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorfilter', 'authorcompare', 'invert', 'limit']; + // array_filter($vars, function ()) + $object = $this->drylist($varlist); + $object = array_merge($object, $vars); + $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 6b3bca3..60dd836 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -97,7 +97,7 @@ <td class="hidephone"><a href="<?= $this->upage('pagedownload', $item->id()) ?>" download><img src="<?= Wcms\Model::iconpath() ?>download.png" class="icon"></a></td> <?php } if ($columns['tag']) { ?> - <td class="tag"><?= $opt->tag($item->tag('array')) ?></td> + <td class="tag"><?= $opt->taglinks($item->tag('array')) ?></td> <?php } if ($columns['title']) { ?> <td class="title" title="<?= $item->title() ?>"><?= $item->title() ?></td> @@ -121,10 +121,10 @@ <td class="date"><?= $item->date('dmy') ?></td> <?php } if ($columns['secure']) { ?> - <td class="secure"><?= $item->secure('string') ?></td> + <td class="secure"><?= $opt->securelink($item->secure('int') , $item->secure('string')) ?></td> <?php } if ($columns['authors']) { ?> - <td class="authors"><?= $opt->author($item->authors('array')) ?></td> + <td class="authors"><?= $opt->authorlinks($item->authors('array')) ?></td> <?php } if ($columns['visitcount']) { ?> <td class="visitcount"><?= $item->visitcount() ?></td> |