com web/master: Allow to search notes within a specfified section: include/functions.inc manage/user-notes.php
| From: | Maciej Sobaczewski | Date: | Sun, 04 Dec 2016 06:25:16 +0000 |
| Subject: | com web/master: Allow to search notes within a specfified section: include/functions.inc manage/user-notes.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-25394@lists.php.net to get a copy of this message | ||
Commit: ed329ef22c59228b5736cf2750283fedf87f733a
Author: Sobak <msobaczewski@gmail.com> Sun, 4 Dec 2016 07:25:16 +0100
Parents: 48fd4fb67a5224060ff0cb6c17e7273598496d93
Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=ed329ef22c59228b5736cf2750283fedf87f733a
Log:
Allow to search notes within a specfified section
Changed paths:
M include/functions.inc
M manage/user-notes.php
Diff:
diff --git a/include/functions.inc b/include/functions.inc
index dfac701..ce915a1 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -40,7 +40,7 @@ function head($title="", $config = array()) {
$SEARCH = array("method" => "get", "action" =>
"/manage/event.php", "placeholder" => "Search Events",
"name" => "search");
}
if (strstr($_SERVER["SCRIPT_FILENAME"], "user-notes.php")) {
- $SEARCH = array("method" => "get", "action" =>
"/manage/user-notes.php", "placeholder" => "Search notes (keyword or
ID)", "name" => "keyword");
+ $SEARCH = array("method" => "get", "action" =>
"/manage/user-notes.php", "placeholder" => "Search notes (keyword, ID or
sect:)", "name" => "keyword");
}
if (isset($_SESSION['credentials'])) {
array_unshift($LINKS, array("href" => "/manage/users.php?username="
. $_SESSION["credentials"][0], "text" => "My Profile"));
diff --git a/manage/user-notes.php b/manage/user-notes.php
index e77e465..12ead05 100644
--- a/manage/user-notes..php
+++ b/manage/user-notes.php
@@ -94,6 +94,10 @@ if (!$action) {
if (is_numeric($_REQUEST['keyword'])) {
$search_heading = 'Search results for #' . (int) $_REQUEST['keyword'];
$sql .= 'note.id = ' . (int) $_REQUEST['keyword'];
+ } elseif (substr($_REQUEST['keyword'], 0, 5) == 'sect:') {
+ $search_heading = 'Search results for <em>' .
hscr($_REQUEST['keyword']) . '</em>';
+ $section = real_clean(str_replace('*', '%',
substr($_REQUEST['keyword'], 5)));
+ $sql .= "note.sect LIKE '$section' GROUP BY note.id ORDER BY note.sect,
note.ts LIMIT $limit, 10";
} else {
$search_heading = 'Search results for <em>' .
hscr($_REQUEST['keyword']) . '</em>';
$sql .= "note.note LIKE '%" . real_clean($_REQUEST['keyword']) .
"%' GROUP BY note.id LIMIT $limit, 10";
@@ -437,6 +441,7 @@ if (!$action) {
<p><a href="<?= PHP_SELF ?>?view=notes&type=4">View bottom 10 rated
notes</a></p>
<p><a href="<?= PHP_SELF ?>?view=notes&type=5">View votes
table</a></p>
<p><a href="<?= PHP_SELF ?>?view=notes&type=6">IPs with the most
votes</a></p>
+<p><a href="<?= PHP_SELF ?>?action=sect">Search notes within a
section</a></p>
<?php
foot();
exit;
@@ -744,6 +749,32 @@ case 'deletevotes':
);
}
exit;
+case 'sect':
+ head('user notes');
+?>
+<h2>Search within a section</h2>
+<p>
+ You can search notes within specified section of the PHP manual using form below or
+ by prepending your query with <em>sect:</em> in regular search form (like
<em>sect:book.mysql</em>).
+</p>
+<p>
+ You can use <em>*</em> as a wildcard, like <em>mysql.*</em>. Query like
<em>function.json-*</em> should
+ show all notes for JSON functions (use <em>sect:function.json-*</em> in case of
generic form).
+</p>
+<form method="get" action="<?= PHP_SELF ?>">
+ <strong>Section:</strong>
+ <input type="hidden" name="action" value="sect" />
+ <input type="text" name="query" /><br />
+ <input type="submit" value="Search" />
+</form>
+<?php
+ if (isset($_GET['query'])) {
+ header('Location: user-notes.php?keyword=sect:' . $_GET['query']);
+ exit;
+ }
+
+ foot();
+ exit;
/* falls through */
default:
head('user notes');