Commit 56da7ebf authored by Dries's avatar Dries

- Fixed bug that prevented results containing multiple occurences of the
  search word(s).  Patch by Ax.
parent de95001c
Drupal x.x.x, xxxx-xx-xx (to be released) Drupal x.x.x, xxxx-xx-xx (to be released)
------------------------ ------------------------
- restructured all admininstration pages - reorganized the administration pages
- search module:
* changed the search module to use implicit AND'ing instead of implicit OR'ing.
- node system improvements: - node system improvements:
* replaced the "post content" permission by more fine-grained permissions. * replaced the "post content" permission by more fine-grained permissions.
* improved content submission: * improved content submission:
...@@ -74,7 +76,7 @@ Drupal 4.0.0, 2002-06-15 ...@@ -74,7 +76,7 @@ Drupal 4.0.0, 2002-06-15
- improved comment module to mark new comments. - improved comment module to mark new comments.
- added a general outliner which will let any node type be linked to a book. - added a general outliner which will let any node type be linked to a book.
- added an update script that lets you upgrade from previous releases or on a day to day basis when using the development tree. - added an update script that lets you upgrade from previous releases or on a day to day basis when using the development tree.
- search: - search module:
* improved the search system by making it context sensitive. * improved the search system by making it context sensitive.
* added indexing. * added indexing.
- various updates: - various updates:
......
...@@ -106,16 +106,10 @@ function do_search($search_array) { ...@@ -106,16 +106,10 @@ function do_search($search_array) {
foreach ($words as $word) { foreach ($words as $word) {
/* // If the word is too short, and we've got it set to skip them, loop
** If the word is too short, and we've got it set to skip them,
** loop
*/
if (strlen($word) < variable_get("remove_short", 0)) { if (strlen($word) < variable_get("remove_short", 0)) {
continue; continue;
} }
// All words are required
$reqcount++;
// Put the next search word into the query and do the query // Put the next search word into the query and do the query
$query = preg_replace("'\%'", $word, $select); $query = preg_replace("'\%'", $word, $select);
...@@ -145,20 +139,14 @@ function do_search($search_array) { ...@@ -145,20 +139,14 @@ function do_search($search_array) {
$results[$lno]["created"] = $created; $results[$lno]["created"] = $created;
$results[$lno]["uid"] = $uid; $results[$lno]["uid"] = $uid;
$results[$lno]["name"] = $name; $results[$lno]["name"] = $name;
// Set it to "valid"
$results[$lno]["valid"] = 1;
} }
else { else {
/* /*
** Different word, but existing "lno", increase the count of ** Different word, but existing "lno", increase the count of
** matches against this "lno" by the number of times this ** matches against this "lno" by the number of times this
** word appears in the text ** word appears in the text
*/ */
$results[$lno]["count"] = $results[$lno]["count"] + $count; $results[$lno]["count"] = $results[$lno]["count"] + $count;
// Another match, increase valid
$results[$lno]["valid"]++;
} }
} }
} }
...@@ -177,9 +165,6 @@ function do_search($search_array) { ...@@ -177,9 +165,6 @@ function do_search($search_array) {
$uid = $value["uid"]; $uid = $value["uid"];
$name = $value["name"]; $name = $value["name"];
$count = $value["count"]; $count = $value["count"];
if ($value["valid"] != $reqcount) {
continue;
}
switch ($type) { switch ($type) {
case "node": case "node":
$find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr($PHP_SELF, "admin.php") ? drupal_url(array("mod" => "node", "type" => "node", "op" => "edit", "id" => $lno), "admin") : drupal_url(array("id" => $lno))), "user" => $name, "date" => $created, "keywords" => implode("|", $words)); $find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr($PHP_SELF, "admin.php") ? drupal_url(array("mod" => "node", "type" => "node", "op" => "edit", "id" => $lno), "admin") : drupal_url(array("id" => $lno))), "user" => $name, "date" => $created, "keywords" => implode("|", $words));
...@@ -325,30 +310,18 @@ function search_view() { ...@@ -325,30 +310,18 @@ function search_view() {
if (user_access("search content")) { if (user_access("search content")) {
/* // Verify the user input:
** Verify the user input:
*/
// TODO: is this necessary or is it / should it be done in search_{form|data}? // TODO: is this necessary or is it / should it be done in search_{form|data}?
$type = check_input($type); $type = check_input($type);
$keys = check_input($keys); $keys = check_input($keys);
/* // Construct the search form:
** Construct the search form:
*/
$form = search_form(NULL, NULL, TRUE); $form = search_form(NULL, NULL, TRUE);
/* // Collect the search results:
** Collect the search results:
*/
$output = search_data(); $output = search_data();
/* // Display form and search results:
** Display form and search results:
*/
$help_link = lm(t("search help"), array("mod" => "search", "op" => "help")); $help_link = lm(t("search help"), array("mod" => "search", "op" => "help"));
switch (variable_get("help_pos", 1)) { switch (variable_get("help_pos", 1)) {
case "1": case "1":
......
...@@ -106,16 +106,10 @@ function do_search($search_array) { ...@@ -106,16 +106,10 @@ function do_search($search_array) {
foreach ($words as $word) { foreach ($words as $word) {
/* // If the word is too short, and we've got it set to skip them, loop
** If the word is too short, and we've got it set to skip them,
** loop
*/
if (strlen($word) < variable_get("remove_short", 0)) { if (strlen($word) < variable_get("remove_short", 0)) {
continue; continue;
} }
// All words are required
$reqcount++;
// Put the next search word into the query and do the query // Put the next search word into the query and do the query
$query = preg_replace("'\%'", $word, $select); $query = preg_replace("'\%'", $word, $select);
...@@ -145,20 +139,14 @@ function do_search($search_array) { ...@@ -145,20 +139,14 @@ function do_search($search_array) {
$results[$lno]["created"] = $created; $results[$lno]["created"] = $created;
$results[$lno]["uid"] = $uid; $results[$lno]["uid"] = $uid;
$results[$lno]["name"] = $name; $results[$lno]["name"] = $name;
// Set it to "valid"
$results[$lno]["valid"] = 1;
} }
else { else {
/* /*
** Different word, but existing "lno", increase the count of ** Different word, but existing "lno", increase the count of
** matches against this "lno" by the number of times this ** matches against this "lno" by the number of times this
** word appears in the text ** word appears in the text
*/ */
$results[$lno]["count"] = $results[$lno]["count"] + $count; $results[$lno]["count"] = $results[$lno]["count"] + $count;
// Another match, increase valid
$results[$lno]["valid"]++;
} }
} }
} }
...@@ -177,9 +165,6 @@ function do_search($search_array) { ...@@ -177,9 +165,6 @@ function do_search($search_array) {
$uid = $value["uid"]; $uid = $value["uid"];
$name = $value["name"]; $name = $value["name"];
$count = $value["count"]; $count = $value["count"];
if ($value["valid"] != $reqcount) {
continue;
}
switch ($type) { switch ($type) {
case "node": case "node":
$find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr($PHP_SELF, "admin.php") ? drupal_url(array("mod" => "node", "type" => "node", "op" => "edit", "id" => $lno), "admin") : drupal_url(array("id" => $lno))), "user" => $name, "date" => $created, "keywords" => implode("|", $words)); $find[$i++] = array("count" => $count, "title" => $title, "link" => (strstr($PHP_SELF, "admin.php") ? drupal_url(array("mod" => "node", "type" => "node", "op" => "edit", "id" => $lno), "admin") : drupal_url(array("id" => $lno))), "user" => $name, "date" => $created, "keywords" => implode("|", $words));
...@@ -325,30 +310,18 @@ function search_view() { ...@@ -325,30 +310,18 @@ function search_view() {
if (user_access("search content")) { if (user_access("search content")) {
/* // Verify the user input:
** Verify the user input:
*/
// TODO: is this necessary or is it / should it be done in search_{form|data}? // TODO: is this necessary or is it / should it be done in search_{form|data}?
$type = check_input($type); $type = check_input($type);
$keys = check_input($keys); $keys = check_input($keys);
/* // Construct the search form:
** Construct the search form:
*/
$form = search_form(NULL, NULL, TRUE); $form = search_form(NULL, NULL, TRUE);
/* // Collect the search results:
** Collect the search results:
*/
$output = search_data(); $output = search_data();
/* // Display form and search results:
** Display form and search results:
*/
$help_link = lm(t("search help"), array("mod" => "search", "op" => "help")); $help_link = lm(t("search help"), array("mod" => "search", "op" => "help"));
switch (variable_get("help_pos", 1)) { switch (variable_get("help_pos", 1)) {
case "1": case "1":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment