This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/favorites/theme.php

65 lines
2 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
use MicroHTML\HTMLElement;
2021-12-14 18:32:47 +00:00
use function MicroHTML\INPUT;
2009-11-24 14:07:18 +00:00
class FavoritesTheme extends Themelet
{
public function get_voter_html(Image $image, bool $is_favorited): HTMLElement
{
$name = $is_favorited ? "unset" : "set";
$label = $is_favorited ? "Un-Favorite" : "Favorite";
2020-01-26 13:19:35 +00:00
return SHM_SIMPLE_FORM(
2020-01-30 10:31:11 +00:00
"change_favorite",
2023-11-11 21:49:12 +00:00
INPUT(["type" => "hidden", "name" => "image_id", "value" => $image->id]),
INPUT(["type" => "hidden", "name" => "favorite_action", "value" => $name]),
INPUT(["type" => "submit", "value" => $label]),
2020-01-26 13:19:35 +00:00
);
}
2009-11-24 14:07:18 +00:00
public function display_people(array $username_array): void
{
global $page;
2009-11-24 14:07:18 +00:00
$i_favorites = count($username_array);
$html = "$i_favorites people:";
2009-11-24 14:07:18 +00:00
reset($username_array); // rewind to first element in array.
2020-01-26 13:19:35 +00:00
foreach ($username_array as $row) {
$username = html_escape($row);
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
}
2009-11-24 14:07:18 +00:00
$page->add_block(new Block("Favorited By", $html, "left", 25));
}
public function get_help_html(): string
{
2020-10-26 15:15:51 +00:00
return '<p>Search for posts that have been favorited a certain number of times, or favorited by a particular individual.</p>
<div class="command_example">
<pre>favorites=1</pre>
2020-10-26 15:15:51 +00:00
<p>Returns posts that have been favorited once.</p>
</div>
<div class="command_example">
<pre>favorites>0</pre>
2020-10-26 15:15:51 +00:00
<p>Returns posts that have been favorited 1 or more times</p>
</div>
<p>Can use &lt;, &lt;=, &gt;, &gt;=, or =.</p>
<div class="command_example">
<pre>favorited_by:username</pre>
2020-10-26 15:15:51 +00:00
<p>Returns posts that have been favorited by "username". </p>
</div>
<div class="command_example">
<pre>favorited_by_userno:123</pre>
2020-10-26 15:15:51 +00:00
<p>Returns posts that have been favorited by user 123. </p>
</div>
';
}
2009-11-24 14:07:18 +00:00
}