2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2007-10-18 01:21:55 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class NumericScoreTheme extends Themelet
|
|
|
|
{
|
2024-01-20 14:10:59 +00:00
|
|
|
public function get_voter(Image $image): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $user, $page;
|
2020-01-26 13:19:35 +00:00
|
|
|
$i_image_id = $image->id;
|
2024-01-15 17:12:36 +00:00
|
|
|
$i_score = (int)$image['numeric_score'];
|
2019-05-28 16:59:38 +00:00
|
|
|
|
|
|
|
$html = "
|
2008-07-21 15:16:48 +00:00
|
|
|
Current Score: $i_score
|
|
|
|
|
2024-02-11 11:34:09 +00:00
|
|
|
<p>".make_form(make_link("numeric_score_vote"))."
|
2008-07-21 15:16:48 +00:00
|
|
|
<input type='hidden' name='image_id' value='$i_image_id'>
|
2023-02-04 18:00:23 +00:00
|
|
|
<input type='hidden' name='vote' value='1'>
|
2008-07-21 15:16:48 +00:00
|
|
|
<input type='submit' value='Vote Up'>
|
|
|
|
</form>
|
|
|
|
|
2024-02-11 11:34:09 +00:00
|
|
|
".make_form(make_link("numeric_score_vote"))."
|
2010-05-28 10:58:26 +00:00
|
|
|
<input type='hidden' name='image_id' value='$i_image_id'>
|
2023-02-04 18:00:23 +00:00
|
|
|
<input type='hidden' name='vote' value='0'>
|
2010-05-28 10:58:26 +00:00
|
|
|
<input type='submit' value='Remove Vote'>
|
|
|
|
</form>
|
|
|
|
|
2024-02-11 11:34:09 +00:00
|
|
|
".make_form(make_link("numeric_score_vote"))."
|
2008-07-21 15:16:48 +00:00
|
|
|
<input type='hidden' name='image_id' value='$i_image_id'>
|
2023-02-04 18:00:23 +00:00
|
|
|
<input type='hidden' name='vote' value='-1'>
|
2008-07-21 15:16:48 +00:00
|
|
|
<input type='submit' value='Vote Down'>
|
|
|
|
</form>
|
2007-10-18 02:29:39 +00:00
|
|
|
";
|
2019-07-09 14:10:21 +00:00
|
|
|
if ($user->can(Permissions::EDIT_OTHER_VOTE)) {
|
2024-02-11 11:34:09 +00:00
|
|
|
$html .= make_form(make_link("numeric_score/remove_votes_on"))."
|
2011-03-23 11:04:22 +00:00
|
|
|
<input type='hidden' name='image_id' value='$i_image_id'>
|
|
|
|
<input type='submit' value='Remove All Votes'>
|
|
|
|
</form>
|
2011-11-08 11:23:38 +00:00
|
|
|
|
2013-07-06 09:42:06 +00:00
|
|
|
<br><div id='votes-content'>
|
|
|
|
<a
|
|
|
|
href='".make_link("numeric_score_votes/$i_image_id")."'
|
|
|
|
onclick='$(\"#votes-content\").load(\"".make_link("numeric_score_votes/$i_image_id")."\"); return false;'
|
|
|
|
>See All Votes</a>
|
|
|
|
</div>
|
2011-03-23 11:04:22 +00:00
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2020-10-26 15:16:58 +00:00
|
|
|
$page->add_block(new Block("Post Score", $html, "left", 20));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
public function get_nuller(User $duser): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $user, $page;
|
2024-02-11 11:34:09 +00:00
|
|
|
$html = make_form(make_link("numeric_score/remove_votes_by"))."
|
2011-03-28 21:31:45 +00:00
|
|
|
<input type='hidden' name='user_id' value='{$duser->id}'>
|
|
|
|
<input type='submit' value='Delete all votes by this user'>
|
|
|
|
</form>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->add_block(new Block("Votes", $html, "main", 80));
|
|
|
|
}
|
2012-01-24 20:11:16 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param Image[] $images
|
|
|
|
*/
|
2024-01-20 20:48:47 +00:00
|
|
|
public function view_popular(array $images, string $totaldate, string $current, string $name, string $fmt): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $page, $config;
|
2012-01-24 20:11:16 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$pop_images = "";
|
|
|
|
foreach ($images as $image) {
|
|
|
|
$pop_images .= $this->build_thumb_html($image)."\n";
|
|
|
|
}
|
2012-01-24 20:11:16 +00:00
|
|
|
|
2024-02-20 00:22:25 +00:00
|
|
|
$b_dte = make_link("popular_by_$name", date($fmt, \Safe\strtotime("-1 $name", \Safe\strtotime($totaldate))));
|
|
|
|
$f_dte = make_link("popular_by_$name", date($fmt, \Safe\strtotime("+1 $name", \Safe\strtotime($totaldate))));
|
2012-01-26 05:39:04 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = "\n".
|
2020-03-13 09:23:54 +00:00
|
|
|
"<h3 style='text-align: center;'>\n".
|
2024-01-20 20:48:47 +00:00
|
|
|
" <a href='{$b_dte}'>«</a> {$current} <a href='{$f_dte}'>»</a>\n".
|
2020-03-13 09:23:54 +00:00
|
|
|
"</h3>\n".
|
2019-05-28 16:59:38 +00:00
|
|
|
"<br/>\n".$pop_images;
|
2012-01-26 05:39:04 +00:00
|
|
|
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$nav_html = "<a href=".make_link().">Index</a>";
|
2012-01-24 20:11:16 +00:00
|
|
|
|
2019-08-02 19:40:03 +00:00
|
|
|
$page->set_heading($config->get_string(SetupConfig::TITLE));
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->add_block(new Block("Navigation", $nav_html, "left", 10));
|
|
|
|
$page->add_block(new Block(null, $html, "main", 30));
|
|
|
|
}
|
2019-08-02 20:05:49 +00:00
|
|
|
|
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function get_help_html(): string
|
2019-08-02 20:05:49 +00:00
|
|
|
{
|
2020-10-26 15:16:58 +00:00
|
|
|
return '<p>Search for posts that have received numeric scores by the score or by the scorer.</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>score=1</code>
|
2020-10-26 15:16:58 +00:00
|
|
|
<p>Returns posts with a score of 1.</p>
|
2020-01-26 13:19:35 +00:00
|
|
|
</div>
|
2019-08-02 20:05:49 +00:00
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>score>0</code>
|
2020-10-26 15:16:58 +00:00
|
|
|
<p>Returns posts with a score of 1 or more.</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
<p>Can use <, <=, >, >=, or =.</p>
|
|
|
|
|
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>upvoted_by=username</code>
|
2020-10-26 15:16:58 +00:00
|
|
|
<p>Returns posts upvoted by "username".</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>upvoted_by_id=123</code>
|
2020-10-26 15:16:58 +00:00
|
|
|
<p>Returns posts upvoted by user 123.</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>downvoted_by=username</code>
|
2020-10-26 15:16:58 +00:00
|
|
|
<p>Returns posts downvoted by "username".</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>downvoted_by_id=123</code>
|
2020-10-26 15:16:58 +00:00
|
|
|
<p>Returns posts downvoted by user 123.</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>order:score_desc</code>
|
2019-08-02 20:05:49 +00:00
|
|
|
<p>Sorts the search results by score, descending.</p>
|
|
|
|
</div>
|
|
|
|
<div class="command_example">
|
2024-06-11 15:02:52 +00:00
|
|
|
<code>order:score_asc</code>
|
2019-08-02 20:05:49 +00:00
|
|
|
<p>Sorts the search results by score, ascending.</p>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
2007-10-18 01:21:55 +00:00
|
|
|
}
|