mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-08 22:07:56 +00:00
show mime type options that match search results only
This commit is contained in:
parent
307ebcf0b1
commit
4486bdc215
@ -39,11 +39,20 @@ class SphinxQL {
|
|||||||
return $query->fetch()->total;
|
return $query->fetch()->total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHostPagesMime() {
|
public function searchHostPagesTotalByMime(string $keyword, string $mime) {
|
||||||
|
|
||||||
$query = $this->_sphinx->prepare('SELECT `mime` FROM `hostPage` GROUP BY `mime` ORDER BY `mime` ASC');
|
$query = $this->_sphinx->prepare('SELECT COUNT(*) AS `total` FROM `hostPage` WHERE MATCH(?) AND `mime` = ?');
|
||||||
|
|
||||||
$query->execute();
|
$query->execute([$keyword, $mime]);
|
||||||
|
|
||||||
|
return $query->fetch()->total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchHostPagesMime(string $keyword) {
|
||||||
|
|
||||||
|
$query = $this->_sphinx->prepare('SELECT `mime` FROM `hostPage` WHERE MATCH(?) GROUP BY `mime` ORDER BY `mime` ASC');
|
||||||
|
|
||||||
|
$query->execute([$keyword]);
|
||||||
|
|
||||||
return $query->fetchAll();
|
return $query->fetchAll();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ if (!empty($q)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mime list
|
// Mime list
|
||||||
$hostPagesMime = $sphinx->getHostPagesMime();
|
$hostPagesMime = $sphinx->searchHostPagesMime($q);
|
||||||
|
|
||||||
// Define page basics
|
// Define page basics
|
||||||
$totalPages = $sphinx->getHostPagesTotal();
|
$totalPages = $sphinx->getHostPagesTotal();
|
||||||
@ -310,7 +310,7 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
|
|||||||
<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) ?>" />
|
||||||
<?php foreach ($hostPagesMime as $hostPageMime) { ?>
|
<?php foreach ($hostPagesMime as $hostPageMime) { ?>
|
||||||
<label><input type="radio" name="t" value="<?php echo $hostPageMime->mime ?>" <?php echo ($t == $hostPageMime->mime ? 'checked="checked"' : false) ?>/> <?php echo $hostPageMime->mime ?></label>
|
<label><input type="radio" name="t" value="<?php echo $hostPageMime->mime ?>" <?php echo ($t == $hostPageMime->mime ? 'checked="checked"' : false) ?>/> <?php echo $hostPageMime->mime ?> <!--(<?php // echo $sphinx->searchHostPagesTotalByMime($q, $hostPageMime->mime) ?>)--></label>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<button type="submit"><?php echo _('Search'); ?></button>
|
<button type="submit"><?php echo _('Search'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user