mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-31 08:54:17 +00:00
display related pages in priority to the unique host by rank, rand() order
This commit is contained in:
parent
34b7291228
commit
297563d4a5
@ -50,17 +50,23 @@ 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'] : ''));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Page search results before show the read more link.
|
* Page search results before show the read more link
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT', 100);
|
define('WEBSITE_PAGINATION_SEARCH_PAGE_RESULTS_LIMIT', 100);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Image search results before show the read more link.
|
* Image search results before show the read more link
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('WEBSITE_PAGINATION_SEARCH_IMAGE_RESULTS_LIMIT', 10);
|
define('WEBSITE_PAGINATION_SEARCH_IMAGE_RESULTS_LIMIT', 10);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Quantity of related pages for each image in the search results
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
define('WEBSITE_SEARCH_IMAGE_RELATED_PAGE_RESULTS_LIMIT', 5);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
*
|
*
|
||||||
|
@ -236,13 +236,29 @@ class MySQL {
|
|||||||
|
|
||||||
public function getHostImageHostPages(int $hostImageId, int $limit = 5) {
|
public function getHostImageHostPages(int $hostImageId, int $limit = 5) {
|
||||||
|
|
||||||
$query = $this->_db->prepare('SELECT * FROM `hostImageToHostPage` WHERE `hostImageId` = ? LIMIT ' . (int) $limit);
|
$query = $this->_db->prepare('SELECT * FROM `hostImageToHostPage`
|
||||||
|
JOIN `hostPage` ON (`hostPage`.`hostPageId` = `hostImageToHostPage`.`hostPageId`)
|
||||||
|
|
||||||
|
WHERE `hostImageId` = ?
|
||||||
|
|
||||||
|
ORDER BY `hostPage`.`rank` DESC, RAND(`hostPage`.`hostId`)
|
||||||
|
|
||||||
|
LIMIT ' . (int) $limit);
|
||||||
|
|
||||||
$query->execute([$hostImageId]);
|
$query->execute([$hostImageId]);
|
||||||
|
|
||||||
return $query->fetchAll();
|
return $query->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHostImageHostPagesTotal(int $hostImageId) {
|
||||||
|
|
||||||
|
$query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostImageToHostPage` WHERE `hostImageId` = ?');
|
||||||
|
|
||||||
|
$query->execute([$hostImageId]);
|
||||||
|
|
||||||
|
return $query->fetch()->total;
|
||||||
|
}
|
||||||
|
|
||||||
public function setHostImageToHostPage(int $hostImageId, int $hostPageId, int $timeAdded, mixed $timeUpdated, int $quantity) {
|
public function setHostImageToHostPage(int $hostImageId, int $hostPageId, int $timeAdded, mixed $timeUpdated, int $quantity) {
|
||||||
|
|
||||||
$query = $this->_db->prepare('INSERT INTO `hostImageToHostPage` (`hostImageId`,
|
$query = $this->_db->prepare('INSERT INTO `hostImageToHostPage` (`hostImageId`,
|
||||||
|
@ -291,6 +291,11 @@ if (!empty($q)) {
|
|||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 16px 0;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -355,7 +360,8 @@ if (!empty($q)) {
|
|||||||
<a href="<?php echo $hostImageURL ?>">
|
<a href="<?php echo $hostImageURL ?>">
|
||||||
<img src="<?php echo $hostImageURLencoded ?>" alt="<?php echo htmlentities($hostImage->description) ?>" title="<?php echo htmlentities($hostImageURL) ?>" class="image" />
|
<img src="<?php echo $hostImageURLencoded ?>" alt="<?php echo htmlentities($hostImage->description) ?>" title="<?php echo htmlentities($hostImageURL) ?>" class="image" />
|
||||||
</a>
|
</a>
|
||||||
<?php foreach ((array) $db->getHostImageHostPages($result->id) as $hostPage) { ?>
|
<?php $hostImageHostPagesTotal = $db->getHostImageHostPagesTotal($result->id) ?>
|
||||||
|
<?php foreach ((array) $db->getHostImageHostPages($result->id, WEBSITE_SEARCH_IMAGE_RELATED_PAGE_RESULTS_LIMIT) as $hostPage) { ?>
|
||||||
<?php if ($hostPage = $db->getFoundHostPage($hostPage->hostPageId)) { ?>
|
<?php if ($hostPage = $db->getFoundHostPage($hostPage->hostPageId)) { ?>
|
||||||
<?php $hostPageURL = $hostPage->scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false) . $hostPage->uri ?>
|
<?php $hostPageURL = $hostPage->scheme . '://' . $hostPage->name . ($hostPage->port ? ':' . $hostPage->port : false) . $hostPage->uri ?>
|
||||||
<h3><?php echo $hostPage->metaTitle ?></h3>
|
<h3><?php echo $hostPage->metaTitle ?></h3>
|
||||||
@ -368,6 +374,18 @@ if (!empty($q)) {
|
|||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<?php if ($hostImageHostPagesTotal - WEBSITE_SEARCH_IMAGE_RELATED_PAGE_RESULTS_LIMIT > 0) { ?>
|
||||||
|
<p>
|
||||||
|
<small>
|
||||||
|
<?php echo Filter::plural($hostImageHostPagesTotal - WEBSITE_SEARCH_IMAGE_RELATED_PAGE_RESULTS_LIMIT,
|
||||||
|
[
|
||||||
|
sprintf(_('+%s other page'), $hostImageHostPagesTotal - WEBSITE_SEARCH_IMAGE_RELATED_PAGE_RESULTS_LIMIT),
|
||||||
|
sprintf(_('+%s other pages'), $hostImageHostPagesTotal - WEBSITE_SEARCH_IMAGE_RELATED_PAGE_RESULTS_LIMIT),
|
||||||
|
sprintf(_('+%s other pages'), $hostImageHostPagesTotal - WEBSITE_SEARCH_IMAGE_RELATED_PAGE_RESULTS_LIMIT),
|
||||||
|
]); ?>
|
||||||
|
</small>
|
||||||
|
</p>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } else if ($hostPage = $db->getFoundHostPage($result->id)) { ?>
|
<?php } else if ($hostPage = $db->getFoundHostPage($result->id)) { ?>
|
||||||
<?php
|
<?php
|
||||||
|
Loading…
x
Reference in New Issue
Block a user