2007-10-02 21:59:20 +00:00
|
|
|
<?php
|
|
|
|
|
2019-05-28 17:59:38 +01:00
|
|
|
class RatingsTheme extends Themelet
|
|
|
|
{
|
|
|
|
public function get_rater_html(int $image_id, string $rating, bool $can_rate): string
|
|
|
|
{
|
|
|
|
$human_rating = Ratings::rating_to_human($rating);
|
|
|
|
$html = "
|
2008-04-08 16:54:13 +00:00
|
|
|
<tr>
|
2012-03-11 15:49:37 +00:00
|
|
|
<th>Rating</th>
|
2008-04-08 16:54:13 +00:00
|
|
|
<td>
|
2016-09-13 02:10:48 -04:00
|
|
|
".($can_rate ? "
|
2016-09-11 23:26:20 -04:00
|
|
|
<span class='view'>$human_rating</span>
|
|
|
|
<span class='edit'>
|
2019-06-13 14:41:03 -05:00
|
|
|
".$this->get_selection_rater_html($rating)."
|
2016-09-11 23:26:20 -04:00
|
|
|
</span>
|
2016-09-13 02:10:48 -04:00
|
|
|
" : "
|
|
|
|
$human_rating
|
|
|
|
")."
|
2008-04-08 16:54:13 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
2007-10-02 21:59:20 +00:00
|
|
|
";
|
2019-05-28 17:59:38 +01:00
|
|
|
return $html;
|
|
|
|
}
|
2007-11-04 08:16:41 +00:00
|
|
|
|
2019-06-13 14:41:03 -05:00
|
|
|
// public function display_bulk_rater(string $terms)
|
|
|
|
// {
|
|
|
|
// global $page;
|
|
|
|
// $html = "
|
|
|
|
// ".make_form(make_link("admin/bulk_rate"))."
|
|
|
|
// <input type='hidden' name='query' value='".html_escape($terms)."'>
|
|
|
|
// <select name='rating'>
|
|
|
|
// <option value='s'>Safe</option>
|
|
|
|
// <option value='q'>Questionable</option>
|
|
|
|
// <option value='e'>Explicit</option>
|
|
|
|
// <option value='u'>Unrated</option>
|
|
|
|
// </select>
|
|
|
|
// <input type='submit' value='Go'>
|
|
|
|
// </form>
|
|
|
|
// ";
|
|
|
|
// $page->add_block(new Block("List Controls", $html, "left"));
|
|
|
|
// }
|
2019-06-05 18:03:22 -05:00
|
|
|
|
2019-06-13 14:41:03 -05:00
|
|
|
public function get_selection_rater_html(String $selected_option, String $id = "rating") {
|
|
|
|
global $_shm_ratings;
|
|
|
|
|
|
|
|
$output = "<select name='".$id."'>";
|
|
|
|
$options = array_values($_shm_ratings);
|
|
|
|
usort($options, function($a, $b) {
|
|
|
|
return $a->order <=> $b->order;
|
|
|
|
});
|
|
|
|
|
|
|
|
foreach($options as $option) {
|
|
|
|
$output .= "<option value='".$option->code."' ".($selected_option==$option->code ? "selected='selected'": "").">".$option->name."</option>";
|
|
|
|
}
|
|
|
|
return $output."</select>";
|
2019-06-05 18:03:22 -05:00
|
|
|
}
|
2007-10-02 21:59:20 +00:00
|
|
|
}
|