mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-03-13 05:41:02 +00:00
show images total instead of pages in placeholder on image search page
This commit is contained in:
parent
5297e6e918
commit
f0b2eb1613
@ -94,6 +94,15 @@ class MySQL {
|
||||
}
|
||||
|
||||
// Images
|
||||
public function getTotalImages() {
|
||||
|
||||
$query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostImage`');
|
||||
|
||||
$query->execute();
|
||||
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
|
||||
public function getTotalHostImages(int $hostId) {
|
||||
|
||||
$query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostImage` WHERE `hostId` = ?');
|
||||
|
@ -15,20 +15,36 @@ $sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT);
|
||||
// Connect database
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
// Define page basics
|
||||
$totalPages = $db->getTotalPages();
|
||||
|
||||
$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s pages or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s pages or enter the new one...'), $totalPages),
|
||||
]);
|
||||
|
||||
// Filter request data
|
||||
$t = !empty($_GET['t']) ? Filter::url($_GET['t']) : 'page';
|
||||
$m = !empty($_GET['m']) ? Filter::url($_GET['m']) : 'default';
|
||||
$q = !empty($_GET['q']) ? Filter::url($_GET['q']) : '';
|
||||
$p = !empty($_GET['p']) ? (int) $_GET['p'] : 1;
|
||||
|
||||
// Define page basics
|
||||
switch ($t) {
|
||||
|
||||
case 'image':
|
||||
|
||||
$totalPages = $db->getTotalImages();
|
||||
|
||||
$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s image or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s images or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s images or enter the new one...'), $totalPages),
|
||||
]);
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
$totalPages = $db->getTotalPages();
|
||||
|
||||
$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s pages or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s pages or enter the new one...'), $totalPages),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Crawl request
|
||||
if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user