From 9a75abfbaa202d2d29bf00851b4950b7a458d54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de> Date: Fri, 23 Mar 2018 14:47:13 +0100 Subject: [PATCH] feat: show last mod information in search results --- inc/Ui/Search.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/inc/Ui/Search.php b/inc/Ui/Search.php index 4f3b57683..73c347304 100644 --- a/inc/Ui/Search.php +++ b/inc/Ui/Search.php @@ -357,23 +357,34 @@ class Search extends Ui $resultHeader = [$resultLink]; + + $restrictQueryToNSLink = $this->restrictQueryToNSLink(getNS($id)); + if ($restrictQueryToNSLink) { + $resultHeader[] = $restrictQueryToNSLink; + } + $snippet = ''; + $lastMod = ''; + $mtime = filemtime(wikiFN($id)); if ($cnt !== 0) { $resultHeader[] = $cnt . ' ' . $lang['hits']; if ($num < FT_SNIPPET_NUMBER) { // create snippets for the first number of matches only $snippet = '<dd>' . ft_snippet($id, $highlight) . '</dd>'; + $lastMod = '<span class="search_results__lastmod">'. $lang['lastmod'] . ' '; + $lastMod .= '<time datetime="' . date_iso8601($mtime) . '">'. dformat($mtime) . '</time>'; + $lastMod .= '</span>'; } $num++; } - $restrictQueryToNSLink = $this->restrictQueryToNSLink(getNS($id)); - if ($restrictQueryToNSLink) { - $resultHeader[] = $restrictQueryToNSLink; - } + $metaLine = '<div class="search_results__metaLine">'; + $metaLine .= $lastMod; + $metaLine .= '</div>'; + $eventData = [ 'resultHeader' => $resultHeader, - 'resultBody' => [$snippet], + 'resultBody' => [$metaLine, $snippet], 'page' => $id, ]; trigger_event('SEARCH_RESULT_FULLPAGE', $eventData); -- GitLab