From: Chris S. <san...@us...> - 2005-07-03 13:53:08
|
Update of /cvsroot/stack/stack-1-0/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28200/scripts Modified Files: stackDatabase.php Log Message: Index: stackDatabase.php =================================================================== RCS file: /cvsroot/stack/stack-1-0/scripts/stackDatabase.php,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** stackDatabase.php 21 Jun 2005 16:36:43 -0000 1.21 --- stackDatabase.php 3 Jul 2005 13:52:56 -0000 1.22 *************** *** 126,130 **** if(0 != mysql_num_rows($result)) { ! echo "<h2>Question bank</h2><form name='stackquestionsform' action='{$_PHP_SELF}' method='POST'>\n"; echo "<input type='hidden' name='action' value='edit' />"; echo '<table>'; --- 126,132 ---- if(0 != mysql_num_rows($result)) { ! 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' />"; echo '<table>'; *************** *** 169,174 **** // Descriptions on a new line. ! echo "<tr><td></td>\n"; ! echo "<td colspan='4'><font size='1'>".stripslashes($row[2])."</font></td></tr>\n"; } else { // Display the edit form to edit metadata. --- 171,179 ---- // Descriptions on a new line. ! if ($filter['show_descript']) { ! echo "<tr><td></td>\n"; ! echo "<td colspan='4'><font size='1'>".stripslashes($row[2])."</font></td></tr>\n"; ! } ! } else { // Display the edit form to edit metadata. *************** *** 243,246 **** --- 248,258 ---- echo "<tr><td><input type=\"checkbox\" name=\"questionsToAdd[$qID][add]\" value=\"ticked\" /></td>\n"; echo "<td>$qID</td><td>$name</td><td>$qkw</td> </tr>\n"; + + // Descriptions on a new line. + if ($filter['show_descript']) { + echo "<tr><td></td>\n"; + echo "<td colspan='4'><font size='1'>".stripslashes($row[2])."</font></td></tr>\n"; + } + } // End preg_match to display each line. *************** *** 298,302 **** */ function stack_db_question_filter_tablehead($action,$filter,$quizid=0) { ! echo "<thead>\n"; --- 310,314 ---- */ function stack_db_question_filter_tablehead($action,$filter,$quizid=0) { ! echo "<thead>\n"; *************** *** 311,314 **** --- 323,341 ---- $fields3 = array('1st','2nd','3rd'); + // Other fields in the table, to make use of the space. + $fields4 = array('','',''); + + if ($filter['case_sense']) { + $fields4[0] = "<th colspan='2'>Case sensitive <input type='checkbox' name='bank_filter[case_sense]' value='TRUE' checked='TRUE' /></th>"; + } else { + $fields4[0] = "<th colspan='2'>Case sensitive <input type='checkbox' name='bank_filter[case_sense]' value='TRUE' /></th>"; + } + + if ($filter['show_descript']) { + $fields4[1] = "<th colspan='2'>Show description <input type='checkbox' name='bank_filter[show_descript]' value='TRUE' checked='TRUE' /></th>"; + } else { + $fields4[1] = "<th colspan='2'>Show description <input type='checkbox' name='bank_filter[show_descript]' value='TRUE' /></th>"; + } + foreach ($fields2 as $no => $fn){ echo "<tr><th>{$fields3[$no]} </th>\n"; *************** *** 321,325 **** } } ! echo "\n</select></th>\n</tr>\n"; } --- 348,353 ---- } } ! echo "\n</select></th>\n"; ! echo "<th>{$fields4[$no]} </th>\n</tr>\n"; } *************** *** 343,351 **** echo '<th><input type="text" name="bank_filter[name]" value="'.$filter['name'].'" /></th>'; echo '<th><input type="text" name="bank_filter[kw]" value="'.$filter['kw'].'" /></th>'; - if ($filter['case_sense']) { - echo "<th colspan='2'>Case sensitive <input type='checkbox' name='bank_filter[case_sense]' value='TRUE' checked='TRUE' /></th>"; - } else { - echo "<th colspan='2'>Case sensitive <input type='checkbox' name='bank_filter[case_sense]' value='TRUE' /></th>"; - } echo "</tr>\n"; } --- 371,374 ---- *************** *** 364,391 **** function stack_db_question_filter($name,$kw,$filter_name,$filter_kw,$filter_case=FALSE) { ! $dispQ = TRUE; ! ! // This will need to wait for PHP 5 :-( ! // if ($filter_case) { ! // $foo = 'strpos'; ! // } else { ! // $foo = 'stripos'; ! // } ! if (!$filter_case) { ! $name = strtolower($name); ! $kw = strtolower($kw); $filter_name = strtolower($filter_name); ! $filter_kw = strtolower($filter_kw); } if ('' != $filter_kw) { ! if ('' != $filter_name) { ! $dispQ = max(strpos($kw,$filter_kw),strpos($name,$filter_name)); ! } else { ! $dispQ = strpos($kw,$filter_kw); } ! } else if ('' != $filter_name) { ! $dispQ = strpos($name,$filter_name); } --- 387,428 ---- 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. if (!$filter_case) { ! $name = strtolower($name); ! $kw = strtolower($kw); $filter_name = strtolower($filter_name); ! $filter_kw = strtolower($filter_kw); } + // Now perform the checks/ + $dispQ = FALSE; + $filter_needed = FALSE; + + // SEARCH over the keywords if ('' != $filter_kw) { ! $filter_needed = TRUE; ! $filter = explode(',',$filter_kw); ! foreach ($filter as $key => $val) { ! $val = trim($val); ! if ('' != $val) { ! $dispQ = max(strpos($kw,$val),$dispQ); ! } } ! } ! ! if ('' != $filter_name) { ! $filter_needed = TRUE; ! $filter = explode(',',$filter_name); ! foreach ($filter as $key => $val) { ! $val = trim($val); ! if ('' != $val) { ! $dispQ = max(strpos($name,$val),$dispQ); ! } ! } ! } ! ! // If no filters have been set, then just display the question anyway. ! if (!$filter_needed) { ! $dispQ = TRUE; } |