level 7 typing
This commit is contained in:
@ -205,25 +205,25 @@ class NumericScore extends Extension
|
||||
|
||||
$totaldate = $year."/".$month."/".$day;
|
||||
|
||||
$sql = "SELECT id FROM images
|
||||
WHERE EXTRACT(YEAR FROM posted) = :year
|
||||
";
|
||||
$sql = "SELECT id FROM images WHERE EXTRACT(YEAR FROM posted) = :year";
|
||||
$args = ["limit" => $config->get_int(IndexConfig::IMAGES), "year" => $year];
|
||||
|
||||
if ($event->page_matches("popular_by_day")) {
|
||||
$sql .=
|
||||
"AND EXTRACT(MONTH FROM posted) = :month
|
||||
AND EXTRACT(DAY FROM posted) = :day";
|
||||
|
||||
$sql .= " AND EXTRACT(MONTH FROM posted) = :month AND EXTRACT(DAY FROM posted) = :day";
|
||||
$args = array_merge($args, ["month" => $month, "day" => $day]);
|
||||
$dte = [$totaldate, date("F jS, Y", (strtotime($totaldate))), "\\y\\e\\a\\r\\=Y\\&\\m\\o\\n\\t\\h\\=m\\&\\d\\a\\y\\=d", "day"];
|
||||
$current = date("F jS, Y", strtotime_ex($totaldate)).
|
||||
$name = "day";
|
||||
$fmt = "\\y\\e\\a\\r\\=Y\\&\\m\\o\\n\\t\\h\\=m\\&\\d\\a\\y\\=d";
|
||||
} elseif ($event->page_matches("popular_by_month")) {
|
||||
$sql .= "AND EXTRACT(MONTH FROM posted) = :month";
|
||||
|
||||
$sql .= " AND EXTRACT(MONTH FROM posted) = :month";
|
||||
$args = array_merge($args, ["month" => $month]);
|
||||
$dte = [$totaldate, date("F Y", (strtotime($totaldate))), "\\y\\e\\a\\r\\=Y\\&\\m\\o\\n\\t\\h\\=m", "month"];
|
||||
$current = date("F Y", strtotime_ex($totaldate));
|
||||
$name = "month";
|
||||
$fmt = "\\y\\e\\a\\r\\=Y\\&\\m\\o\\n\\t\\h\\=m";
|
||||
} elseif ($event->page_matches("popular_by_year")) {
|
||||
$dte = [$totaldate, $year, "\\y\\e\\a\\r\=Y", "year"];
|
||||
$current = "$year";
|
||||
$name = "year";
|
||||
$fmt = "\\y\\e\\a\\r\=Y";
|
||||
} else {
|
||||
// this should never happen due to the fact that the page event is already matched against earlier.
|
||||
throw new \UnexpectedValueException("Error: Invalid page event.");
|
||||
@ -234,7 +234,7 @@ class NumericScore extends Extension
|
||||
|
||||
$ids = $database->get_col($sql, $args);
|
||||
$images = Search::get_images($ids);
|
||||
$this->theme->view_popular($images, $dte);
|
||||
$this->theme->view_popular($images, $totaldate, $current, $name, $fmt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,9 +70,8 @@ class NumericScoreTheme extends Themelet
|
||||
|
||||
/**
|
||||
* @param Image[] $images
|
||||
* @param string[] $dte
|
||||
*/
|
||||
public function view_popular(array $images, array $dte): void
|
||||
public function view_popular(array $images, string $totaldate, string $current, string $name, string $fmt): void
|
||||
{
|
||||
global $page, $config;
|
||||
|
||||
@ -81,12 +80,12 @@ class NumericScoreTheme extends Themelet
|
||||
$pop_images .= $this->build_thumb_html($image)."\n";
|
||||
}
|
||||
|
||||
$b_dte = make_link("popular_by_".$dte[3], date($dte[2], (strtotime('-1 '.$dte[3], strtotime($dte[0])))));
|
||||
$f_dte = make_link("popular_by_".$dte[3], date($dte[2], (strtotime('+1 '.$dte[3], strtotime($dte[0])))));
|
||||
$b_dte = make_link("popular_by_$name", date($fmt, strtotime_ex("-1 $name", strtotime_ex($totaldate))));
|
||||
$f_dte = make_link("popular_by_$name", date($fmt, strtotime_ex("+1 $name", strtotime_ex($totaldate))));
|
||||
|
||||
$html = "\n".
|
||||
"<h3 style='text-align: center;'>\n".
|
||||
" <a href='{$b_dte}'>«</a> {$dte[1]} <a href='{$f_dte}'>»</a>\n".
|
||||
" <a href='{$b_dte}'>«</a> {$current} <a href='{$f_dte}'>»</a>\n".
|
||||
"</h3>\n".
|
||||
"<br/>\n".$pop_images;
|
||||
|
||||
|
Reference in New Issue
Block a user