mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-08 22:07:56 +00:00
create separated pagination settings for page/image search types
This commit is contained in:
parent
d8449d4f7d
commit
834ac68cce
@ -50,10 +50,16 @@ error_reporting(E_ALL);
|
|||||||
define('WEBSITE_DOMAIN', (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . (!empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
|
define('WEBSITE_DOMAIN', (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . (!empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search results per page before show the read more link.
|
* Page search results before show the read more link.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT', 100);
|
define('WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT', 100);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Image search results before show the read more link.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
define('WEBSITE_PAGINATION_SEARCH_IMAGE_RESULTS_LIMIT', 10);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save ident icons to the static webp cache (placed in storage/cache) to prevent CPU overload
|
* Save ident icons to the static webp cache (placed in storage/cache) to prevent CPU overload
|
||||||
|
@ -108,15 +108,15 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
|
|||||||
// Search request
|
// Search request
|
||||||
if (!empty($q)) {
|
if (!empty($q)) {
|
||||||
|
|
||||||
if (!empty($t) && $t == 'image') {
|
if ($t == 'image') {
|
||||||
|
|
||||||
$resultsTotal = $sphinx->searchHostImagesTotal(Filter::searchQuery($q, $m));
|
$resultsTotal = $sphinx->searchHostImagesTotal(Filter::searchQuery($q, $m));
|
||||||
$results = $sphinx->searchHostImages(Filter::searchQuery($q, $m), $p * WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT - WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT, WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT, $resultsTotal);
|
$results = $sphinx->searchHostImages(Filter::searchQuery($q, $m), $p * WEBSITE_PAGINATION_SEARCH_IMAGE_RESULTS_LIMIT - WEBSITE_PAGINATION_SEARCH_IMAGE_RESULTS_LIMIT, WEBSITE_PAGINATION_SEARCH_IMAGE_RESULTS_LIMIT, $resultsTotal);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$resultsTotal = $sphinx->searchHostPagesTotal(Filter::searchQuery($q, $m));
|
$resultsTotal = $sphinx->searchHostPagesTotal(Filter::searchQuery($q, $m));
|
||||||
$results = $sphinx->searchHostPages(Filter::searchQuery($q, $m), $p * WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT - WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT, WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT, $resultsTotal);
|
$results = $sphinx->searchHostPages(Filter::searchQuery($q, $m), $p * WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT - WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT, WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT, $resultsTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -297,7 +297,7 @@ if (!empty($q)) {
|
|||||||
<form name="search" method="GET" action="<?php echo WEBSITE_DOMAIN; ?>/search.php">
|
<form name="search" method="GET" action="<?php echo WEBSITE_DOMAIN; ?>/search.php">
|
||||||
<h1><a href="<?php echo WEBSITE_DOMAIN; ?>"><?php echo _('YGGo!') ?></a></h1>
|
<h1><a href="<?php echo WEBSITE_DOMAIN; ?>"><?php echo _('YGGo!') ?></a></h1>
|
||||||
<input type="text" name="q" placeholder="<?php echo $placeholder ?>" value="<?php echo htmlentities($q) ?>" />
|
<input type="text" name="q" placeholder="<?php echo $placeholder ?>" value="<?php echo htmlentities($q) ?>" />
|
||||||
<label><input type="checkbox" name="t" value="image" <?php echo (!empty($t) && $t == 'image' ? 'checked="checked"' : false) ?>/> <?php echo _('Images') ?></label>
|
<label><input type="checkbox" name="t" value="image" <?php echo ($t == 'image' ? 'checked="checked"' : false) ?>/> <?php echo _('Images') ?></label>
|
||||||
<button type="submit"><?php echo _('Search'); ?></button>
|
<button type="submit"><?php echo _('Search'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
</header>
|
</header>
|
||||||
@ -310,8 +310,7 @@ if (!empty($q)) {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php foreach ($results as $result) { ?>
|
<?php foreach ($results as $result) { ?>
|
||||||
<?php if (!empty($t) && $t == 'image' &&
|
<?php if ($t == 'image' && $hostImage = $db->getFoundHostImage($result->id)) { ?>
|
||||||
$hostImage = $db->getFoundHostImage($result->id)) { ?>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Built image url
|
// Built image url
|
||||||
@ -389,9 +388,9 @@ if (!empty($q)) {
|
|||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($p * WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT <= $resultsTotal) { ?>
|
<?php if ($p * ($t == 'image' ? WEBSITE_PAGINATION_SEARCH_IMAGE_RESULTS_LIMIT : WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT) <= $resultsTotal) { ?>
|
||||||
<div>
|
<div>
|
||||||
<a href="<?php echo WEBSITE_DOMAIN; ?>/search.php?q=<?php echo urlencode(htmlentities($q)) ?>&p=<?php echo $p + 1 ?>"><?php echo _('Next page') ?></a>
|
<a href="<?php echo WEBSITE_DOMAIN; ?>/search.php?q=<?php echo urlencode(htmlentities($q)) ?>&t=<?php echo $t ?>&p=<?php echo $p + 1 ?>"><?php echo _('Next page') ?></a>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user