search-results -> Likes-Sortierung
This commit is contained in:
@@ -65,8 +65,8 @@ $resultCount = count($results);
|
|||||||
</label>
|
</label>
|
||||||
<!-- Noch disabled, da likes noch nicht implementiert-->
|
<!-- Noch disabled, da likes noch nicht implementiert-->
|
||||||
<label class="s-res-filter-option">
|
<label class="s-res-filter-option">
|
||||||
<input type="radio" name="sort" value="likes" <?php echo $currentSort === 'likes' ? 'checked' : ''; ?> disabled>
|
<input type="radio" name="sort" value="likes" <?php echo $currentSort === 'likes' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
||||||
<span style="color: #94a3b8;">Beliebtheit (Likes)</span>
|
<span>Beliebtheit (Likes)</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="s-res-filter-option">
|
<label class="s-res-filter-option">
|
||||||
<input type="radio" name="sort" value="newest" <?php echo $currentSort === 'newest' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
<input type="radio" name="sort" value="newest" <?php echo $currentSort === 'newest' ? 'checked' : ''; ?> onchange="this.form.submit()">
|
||||||
@@ -103,7 +103,14 @@ $resultCount = count($results);
|
|||||||
<?php echo htmlspecialchars($item['title']); ?>
|
<?php echo htmlspecialchars($item['title']); ?>
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
|
<div class="s-res-meta-row">
|
||||||
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($item['author']); ?></span></p>
|
<p class="s-res-author">Von: <span class="s-res-author-name"><?php echo htmlspecialchars($item['author']); ?></span></p>
|
||||||
|
|
||||||
|
<span class="s-res-likes">
|
||||||
|
❤️ <?php echo isset($item['likes']) && is_array($item['likes']) ? count($item['likes']) : 0; ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="s-res-arrow">→</div>
|
<div class="s-res-arrow">→</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -247,6 +247,17 @@ CSS für die Suchergebnis-Seite
|
|||||||
cursor: not-allowed;
|
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) */
|
/* Responsive Anpassungen unter 760px (für z.B. Smartphones) */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.s-res-layout-grid {
|
.s-res-layout-grid {
|
||||||
|
|||||||
@@ -26,17 +26,21 @@ if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["q"])) {
|
|||||||
if ($sortStyle === 'alphabet') {
|
if ($sortStyle === 'alphabet') {
|
||||||
// Titel aufsteigend alphabetiisch sortiert
|
// Titel aufsteigend alphabetiisch sortiert
|
||||||
usort($results, function ($a, $b) {
|
usort($results, function ($a, $b) {
|
||||||
return strcasecmp($a->title, $b->title);
|
return strcasecmp($a->getTitle(), $b->getTitle());
|
||||||
|
});
|
||||||
|
} elseif ($sortStyle === 'likes') {
|
||||||
|
usort($results, function($a, $b) {
|
||||||
|
return $b->getLikeCount() <=> $a->getLikeCount();
|
||||||
});
|
});
|
||||||
} elseif ($sortStyle === 'newest') {
|
} elseif ($sortStyle === 'newest') {
|
||||||
// Datum neu zu alt sortiert
|
// Datum neu zu alt sortiert
|
||||||
usort($results, function($a, $b) {
|
usort($results, function($a, $b) {
|
||||||
return strcmp($b->creationDate, $a->creationDate);
|
return strcmp($b->getCreationDate(), $a->getCreationDate());
|
||||||
});
|
});
|
||||||
} elseif ($sortStyle === 'oldest') {
|
} elseif ($sortStyle === 'oldest') {
|
||||||
// Datum alt zu neu sortiert
|
// Datum alt zu neu sortiert
|
||||||
usort($results, function($a, $b) {
|
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 = [];
|
$safeArrayResults = [];
|
||||||
foreach ($results as $obj) {
|
foreach ($results as $obj) {
|
||||||
$safeArrayResults[] = [
|
$safeArrayResults[] = [
|
||||||
"id" => $obj->id,
|
"id" => $obj->getId(),
|
||||||
"title" => $obj->title,
|
"title" => $obj->getTitle(),
|
||||||
"content" => $obj->content,
|
"content" => $obj->getContent(),
|
||||||
"author" => $obj->author,
|
"author" => $obj->getAuthor(),
|
||||||
"category" => $obj->category,
|
"category" => $obj->getCategory(),
|
||||||
"tags" => $obj->tags,
|
"tags" => $obj->getTags(),
|
||||||
"creationDate" => $obj->creationDate,
|
"creationDate" => $obj->getCreationDate(),
|
||||||
"likes" => $obj->likes,
|
"likes" => $obj->getLikes(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user