Browse Source

add extended search mode option

main
ghost 12 months ago
parent
commit
f0da3caaf5
  1. 11
      src/webui/explore.php
  2. 72
      src/webui/search.php

11
src/webui/explore.php

@ -244,10 +244,9 @@ foreach ($config->snap->storage->remote->ftp as $i => $ftp)
label { label {
font-size: 14px; font-size: 14px;
color: #fff; position: absolute;
float: left; right: 80px;
margin-left: 16px; top: 18px;
margin-bottom: 14px;
} }
label > input { label > input {
@ -303,6 +302,10 @@ foreach ($config->snap->storage->remote->ftp as $i => $ftp)
<form name="search" method="GET" action="search.php"> <form name="search" method="GET" action="search.php">
<h1><a href="./"><?php echo _('Yo!') ?></a></h1> <h1><a href="./"><?php echo _('Yo!') ?></a></h1>
<input type="text" name="q" placeholder="<?php echo $placeholder ?>" value="" /> <input type="text" name="q" placeholder="<?php echo $placeholder ?>" value="" />
<label for="e">
<input type="checkbox" name="e" id="e" value="true" />
<?php echo _('Extended') ?>
</label>
<button type="submit"> <button type="submit">
<sub> <sub>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" class="bi bi-search" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" class="bi bi-search" viewBox="0 0 16 16">

72
src/webui/search.php

@ -102,7 +102,7 @@ if ($config->webui->search->index->request->url->enabled && filter_var($q, FILTE
} }
} }
// Extended syntax corrections // Extended corrections
switch (true) switch (true)
{ {
case empty($q): case empty($q):
@ -119,10 +119,23 @@ switch (true)
default: default:
// @TODO add extended syntax mode, add Utils::escape // Allow raw requests on extended syntax mode requested
// http://sphinxsearch.com/docs/current/extended-syntax.html
if (isset($_GET['e']))
{
$query = $index->search($q); $query = $index->search($q);
} }
// Escape reserved chars
// http://sphinxsearch.com/docs/current/extended-syntax.html
else
{
$query = $index->search(
@\Manticoresearch\Utils::escape($q)
);
}
}
// Get found // Get found
$found = empty($q) ? $total : $query->get()->getTotal(); $found = empty($q) ? $total : $query->get()->getTotal();
@ -225,7 +238,11 @@ $results = $query->offset($p * $config->webui->pagination->limit - $config->webu
text-align: center; text-align: center;
} }
input { input[type="checkbox"] {
accent-color: #3394fb;
}
input[type="text"] {
width: 100%; width: 100%;
margin: 12px 0; margin: 12px 0;
padding: 6px 0; padding: 6px 0;
@ -236,25 +253,24 @@ $results = $query->offset($p * $config->webui->pagination->limit - $config->webu
text-align: center; text-align: center;
} }
input:hover { input[type="text"]:hover {
background-color: #111 background-color: #111
} }
input:focus { input[type="text"]:focus {
outline: none; outline: none;
background-color: #111 background-color: #111
} }
input:focus::placeholder { input[type="text"]:focus::placeholder {
color: #090808 color: #090808
} }
label { label {
font-size: 14px; font-size: 14px;
color: #fff; position: absolute;
float: left; right: 80px;
margin-left: 16px; top: 18px;
margin-bottom: 14px;
} }
label > input { label > input {
@ -292,8 +308,6 @@ $results = $query->offset($p * $config->webui->pagination->limit - $config->webu
} }
p { p {
margin: 16px 0;
text-align: right;
font-size: 11px; font-size: 11px;
} }
@ -308,6 +322,10 @@ $results = $query->offset($p * $config->webui->pagination->limit - $config->webu
<form name="search" method="GET" action="search.php"> <form name="search" method="GET" action="search.php">
<h1><a href="./"><?php echo _('Yo!') ?></a></h1> <h1><a href="./"><?php echo _('Yo!') ?></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 for="e">
<input type="checkbox" name="e" id="e" value="true" <?php echo isset($_GET['e']) ? 'checked="checked"': false ?>/>
<?php echo _('Extended') ?>
</label>
<button type="submit"> <button type="submit">
<sub> <sub>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" class="bi bi-search" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" class="bi bi-search" viewBox="0 0 16 16">
@ -318,10 +336,36 @@ $results = $query->offset($p * $config->webui->pagination->limit - $config->webu
</form> </form>
</header> </header>
<main> <main>
<?php if (isset($_GET['e'])) { ?>
<div>
<p>
<?php echo _('Extended syntax enabled, follow') ?>
<a href="http://sphinxsearch.com/docs/current/extended-syntax.html" rel="nofollow" target="_blank"><?php echo _('Documentation') ?></a>
<sub>
<svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" fill="currentColor" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5"/>
<path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0z"/>
</svg>
</sub>
</p>
<p>
<?php echo _('Available fields:') ?>
<i>@title</i>
<i>@description</i>
<i>@keywords</i>
<i>@mime</i>
<i>@url</i>
</p>
</div>
<?php } ?>
<?php if ($response) { ?> <?php if ($response) { ?>
<div><?php echo $response ?></div> <div>
<?php echo $response ?>
</div>
<?php } ?> <?php } ?>
<div><?php echo sprintf(_('Found: %s'), number_format($found)) ?></div> <div>
<?php echo sprintf(_('Found: %s'), number_format($found)) ?>
</div>
<?php foreach ($results as $result) { ?> <?php foreach ($results as $result) { ?>
<div> <div>
<?php <?php

Loading…
Cancel
Save