diff --git a/content/search-results.php b/content/search-results.php index c7ff9e4..c33b8b5 100644 --- a/content/search-results.php +++ b/content/search-results.php @@ -65,8 +65,8 @@ $resultCount = count($results); - disabled> - Beliebtheit (Likes) + onchange="this.form.submit()"> + Beliebtheit (Likes) onchange="this.form.submit()"> @@ -103,7 +103,14 @@ $resultCount = count($results); - Von: + + Von: + + + ❤️ + + + → diff --git a/css/search-results.css b/css/search-results.css index 4fc5d97..a89817c 100644 --- a/css/search-results.css +++ b/css/search-results.css @@ -247,6 +247,17 @@ CSS für die Suchergebnis-Seite cursor: not-allowed; } +.s-res-meta-row { + display: flex; + gap: 15px; + align-items: center; +} + +.s-res-likes { + font-size: 0.9em; + color: #475569; +} + /* Responsive Anpassungen unter 760px (für z.B. Smartphones) */ @media (max-width: 768px) { .s-res-layout-grid { diff --git a/php/controller/search-results-controller.php b/php/controller/search-results-controller.php index 5ed67d7..bc33cef 100644 --- a/php/controller/search-results-controller.php +++ b/php/controller/search-results-controller.php @@ -25,18 +25,22 @@ if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) { if ($sortStyle === 'alphabet') { // Titel aufsteigend alphabetiisch sortiert + usort($results, function ($a, $b) { + return strcasecmp($a->getTitle(), $b->getTitle()); + }); + } elseif ($sortStyle === 'likes') { usort($results, function($a, $b) { - return strcasecmp($a->title, $b->title); + return $b->getLikeCount() <=> $a->getLikeCount(); }); } elseif ($sortStyle === 'newest') { // Datum neu zu alt sortiert usort($results, function($a, $b) { - return strcmp($b->creationDate, $a->creationDate); + return strcmp($b->getCreationDate(), $a->getCreationDate()); }); } elseif ($sortStyle === 'oldest') { // Datum alt zu neu sortiert usort($results, function($a, $b) { - return strcmp($a->creationDate, $b->creationDate); + return strcmp($a->getCreationDate(), $b->getCreationDate()); }); } @@ -44,14 +48,14 @@ if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) { $safeArrayResults = []; foreach ($results as $obj) { $safeArrayResults[] = [ - "id" => $obj->id, - "title" => $obj->title, - "content" => $obj->content, - "author" => $obj->author, - "category" => $obj->category, - "tags" => $obj->tags, - "creationDate" => $obj->creationDate, - "likes" => $obj->likes, + "id" => $obj->getId(), + "title" => $obj->getTitle(), + "content" => $obj->getContent(), + "author" => $obj->getAuthor(), + "category" => $obj->getCategory(), + "tags" => $obj->getTags(), + "creationDate" => $obj->getCreationDate(), + "likes" => $obj->getLikes(), ]; }
Von: