From: Chris S. <san...@us...> - 2005-07-03 14:50:23
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25853/scripts Modified Files: stackDatabase.php Log Message: Index: stackDatabase.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackDatabase.php,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** stackDatabase.php 3 Jul 2005 13:52:56 -0000 1.22 --- stackDatabase.php 3 Jul 2005 14:50:15 -0000 1.23 *************** *** 127,131 **** echo "<h2>Question bank</h2>\n"; ! echo "<font size='-2'>Search the question bank using comma separated lists of search terms in the Name and Keywords fields. Any match will display the question. Leave both blank to display all questions in the question bank. White space is ignored.</font>"; echo "<form name='stackquestionsform' action='{$_PHP_SELF}' method='POST'>\n"; echo "<input type='hidden' name='action' value='edit' />"; --- 127,131 ---- echo "<h2>Question bank</h2>\n"; ! echo "<font size='-2'>Search the question bank using comma separated lists of search terms in the Name and Keywords fields. Choose to match either 'Any' or 'All' of these to display the questions. Leave both blank to display all questions in the question bank. White space is ignored.</font>"; echo "<form name='stackquestionsform' action='{$_PHP_SELF}' method='POST'>\n"; echo "<input type='hidden' name='action' value='edit' />"; *************** *** 148,152 **** // Decide how to filter questions ! $dispQ = stack_db_question_filter($qname,$qkeywords,$filter['name'],$filter['kw'],$filter['case_sense']); if (FALSE !== $dispQ) { --- 148,152 ---- // Decide how to filter questions ! $dispQ = stack_db_question_filter($qname,$qkeywords,$filter['name'],$filter['kw'],$filter['any'],$filter['case_sense']); if (FALSE !== $dispQ) { *************** *** 235,239 **** $name = stripslashes($row[1]); $qkw = stripslashes($row[2]); ! $dispQ = stack_db_question_filter($name,$qkw,$filter['name'],$filter['kw'],$filter['case_sense']); if (FALSE !== $dispQ) { --- 235,239 ---- $name = stripslashes($row[1]); $qkw = stripslashes($row[2]); ! $dispQ = stack_db_question_filter($name,$qkw,$filter['name'],$filter['kw'],$filter['any'],$filter['case_sense']); if (FALSE !== $dispQ) { *************** *** 338,341 **** --- 338,354 ---- } + // Add different search methods. + $fields5 = array('Any','All'); + $fields4[2] = "<th colspan='2'>Match terms\n<select name='bank_filter[any]'>"; + foreach ($fields5 as $no => $key) { + if ($key == $filter['any']) { + $fields4[2] .= "\n <option value='$key' selected>".$fields5[$no]."</option>"; + } else { + $fields4[2] .= "\n <option value='$key'>".$fields5[$no]."</option>"; + } + } + $fields4[2] .= "\n</select></th>\n"; + + foreach ($fields2 as $no => $fn){ echo "<tr><th>{$fields3[$no]} </th>\n"; *************** *** 385,389 **** * @return $dispQ boolean */ ! function stack_db_question_filter($name,$kw,$filter_name,$filter_kw,$filter_case=FALSE) { // If we are case insensitive then we should make everything lower case. --- 398,402 ---- * @return $dispQ boolean */ ! function stack_db_question_filter($name,$kw,$filter_name,$filter_kw,$filter_any,$filter_case=FALSE) { // If we are case insensitive then we should make everything lower case. *************** *** 398,401 **** --- 411,418 ---- $dispQ = FALSE; $filter_needed = FALSE; + if ('All' == $filter_any) { + $dispQ = TRUE; + } + // SEARCH over the keywords *************** *** 406,410 **** $val = trim($val); if ('' != $val) { ! $dispQ = max(strpos($kw,$val),$dispQ); } } --- 423,431 ---- $val = trim($val); if ('' != $val) { ! if ('Any' == $filter_any) { ! $dispQ = max(strpos($kw,$val),$dispQ); ! } else { ! $dispQ = min(strpos($kw,$val),$dispQ); ! } } } *************** *** 417,421 **** $val = trim($val); if ('' != $val) { ! $dispQ = max(strpos($name,$val),$dispQ); } } --- 438,446 ---- $val = trim($val); if ('' != $val) { ! if ('Any' == $filter_any) { ! $dispQ = max(strpos($name,$val),$dispQ); ! } else { ! $dispQ = min(strpos($name,$val),$dispQ); ! } } } |