You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

257 lines
17 KiB

  1. <?php
  2. // turn on warnings and notice during developement
  3. include('initialize/PhpErrorSettings.inc.php');
  4. // Project: Web Reference Database (refbase) <http://www.refbase.net>
  5. // Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
  6. // original author(s).
  7. //
  8. // This code is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY. Please see the GNU General Public
  10. // License for more details.
  11. //
  12. // File: ./library_search.php
  13. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/library_search.php $
  14. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  15. //
  16. // Created: 29-Jul-02, 16:39
  17. // Modified: $Date: 2008-11-05 21:54:22 +0000 (Wed, 05 Nov 2008) $
  18. // $Author: msteffens $
  19. // $Revision: 1297 $
  20. // Search form providing the main fields.
  21. // Searches will be restricted to records belonging
  22. // to the IPOE <http://www.uni-kiel.de/ipoe/> library.
  23. // TODO: I18n
  24. // Incorporate some include files:
  25. include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
  26. include 'includes/header.inc.php'; // include header
  27. include 'includes/footer.inc.php'; // include footer
  28. include 'includes/include.inc.php'; // include common functions
  29. include 'initialize/ini.inc.php'; // include common variables
  30. // --------------------------------------------------------------------
  31. // START A SESSION:
  32. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  33. start_session(true);
  34. // --------------------------------------------------------------------
  35. // Initialize preferred display language:
  36. // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
  37. include 'includes/locales.inc.php'; // include the locales
  38. // --------------------------------------------------------------------
  39. // (1) Open the database connection and use the literature database:
  40. connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php'
  41. // If there's no stored message available:
  42. if (!isset($_SESSION['HeaderString']))
  43. $HeaderString = "Search the $hostInstitutionAbbrevName library:"; // Provide the default message
  44. else
  45. {
  46. $HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
  47. // Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
  48. deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
  49. }
  50. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  51. // ('' will produce the default 'Web' output style)
  52. if (isset($_REQUEST['viewType']))
  53. $viewType = $_REQUEST['viewType'];
  54. else
  55. $viewType = "";
  56. // Get the default number of records per page preferred by the current user:
  57. $showRows = $_SESSION['userRecordsPerPage'];
  58. // Get the user's preference for displaying auto-completions:
  59. $showAutoCompletions = $_SESSION['userAutoCompletions'];
  60. // Show the login status:
  61. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  62. // (2a) Display header:
  63. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  64. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Library Search", "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  65. showPageHeader($HeaderString);
  66. // (2b) Start <form> and <table> holding the form elements:
  67. echo "\n<form action=\"search.php\" method=\"GET\">";
  68. echo "\n<input type=\"hidden\" name=\"formType\" value=\"librarySearch\">"
  69. . "\n<input type=\"hidden\" name=\"showQuery\" value=\"0\">";
  70. echo "\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table holds the search form\">"
  71. . "\n<tr>"
  72. . "\n\t<th align=\"left\">Show</th>\n\t<th align=\"left\">Field</th>\n\t<th align=\"left\">&nbsp;</th>\n\t<th align=\"left\">That...</th>\n\t<th align=\"left\">Search String</th>"
  73. . "\n</tr>"
  74. . "\n<tr>"
  75. . "\n\t<td width=\"20\" valign=\"middle\"><input type=\"checkbox\" name=\"showAuthor\" value=\"1\" checked></td>"
  76. . "\n\t<td width=\"40\"><b>Author:</b></td>\n\t<td width=\"10\">&nbsp;</td>"
  77. . "\n\t<td width=\"130\">\n\t\t<select name=\"authorSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  78. . "\n\t<td><input type=\"text\" name=\"authorName\" size=\"42\"></td>"
  79. . "\n</tr>"
  80. . "\n<tr>"
  81. . "\n\t<td valign=\"middle\"><input type=\"checkbox\" name=\"showTitle\" value=\"1\" checked></td>"
  82. . "\n\t<td><b>Title:</b></td>\n\t<td>&nbsp;</td>"
  83. . "\n\t<td>\n\t\t<select name=\"titleSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  84. . "\n\t<td><input type=\"text\" name=\"titleName\" size=\"42\"></td>"
  85. . "\n</tr>"
  86. . "\n<tr>"
  87. . "\n\t<td valign=\"middle\"><input type=\"checkbox\" name=\"showYear\" value=\"1\" checked></td>"
  88. . "\n\t<td><b>Year:</b></td>\n\t<td>&nbsp;</td>"
  89. . "\n\t<td>\n\t\t<select name=\"yearSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t\t<option>is greater than</option>\n\t\t\t<option>is less than</option>\n\t\t\t<option>is within range</option>\n\t\t\t<option>is within list</option>\n\t\t</select>\n\t</td>"
  90. . "\n\t<td><input type=\"text\" name=\"yearNo\" size=\"42\"></td>"
  91. . "\n</tr>"
  92. . "\n<tr>"
  93. . "\n\t<td width=\"20\" valign=\"middle\"><input type=\"checkbox\" name=\"showEditor\" value=\"1\"></td>"
  94. . "\n\t<td width=\"40\"><b>Editor:</b></td>\n\t<td width=\"10\">&nbsp;</td>"
  95. . "\n\t<td width=\"130\">\n\t\t<select name=\"editorSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  96. . "\n\t<td><input type=\"text\" name=\"editorName\" size=\"42\"></td>"
  97. . "\n</tr>"
  98. . "\n<tr>"
  99. . "\n\t<td valign=\"middle\"><input type=\"checkbox\" name=\"showSeriesTitle\" value=\"1\" checked></td>"
  100. . "\n\t<td><b>Series:</b></td>\n\t<td align=\"center\"><input type=\"radio\" name=\"seriesTitleRadio\" value=\"1\" checked></td>"
  101. . "\n\t<td>\n\t\t<select name=\"seriesTitleSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  102. . "\n\t<td>";
  103. // (3) Run the query on the literature database through the connection:
  104. // (here by use of the 'selectDistinct' function)
  105. // Produce the select list
  106. // Parameters:
  107. // 1: Database connection
  108. // 2. Table that contains values
  109. // 3. The field name of the table's primary key
  110. // 4. Table name of the user data table
  111. // 5. The field name within the user data table that corresponds to the field in 3.
  112. // 6. The field name of the user ID field within the user data table
  113. // 7. The user ID of the currently logged in user (which must be provided as a session variable)
  114. // 8. Attribute that contains values
  115. // 9. <SELECT> element name
  116. // 10. An additional non-database value (display string)
  117. // 11. String that gets submitted instead of the display string given in 10.
  118. // 12. Optional <OPTION SELECTED>
  119. // 13. Restrict query to field... (keep empty if no restriction wanted)
  120. // 14. ...where field contents are...
  121. // 15. Split field contents into substrings? (yes = true, no = false)
  122. // 16. POSIX-PATTERN to split field contents into substrings (in order to obtain actual values)
  123. echo selectDistinct($connection,
  124. $tableRefs,
  125. "serial",
  126. $tableUserData,
  127. "record_id",
  128. "user_id",
  129. $loginUserID,
  130. "series_title",
  131. "seriesTitleName",
  132. $loc["All"],
  133. "All",
  134. $loc["All"],
  135. "",
  136. "",
  137. false,
  138. "");
  139. echo "\n\t</td>"
  140. . "\n</tr>";
  141. echo "\n<tr>"
  142. . "\n\t<td>&nbsp;</td>"
  143. . "\n\t<td align=\"right\">or:</td>\n\t<td align=\"center\"><input type=\"radio\" name=\"seriesTitleRadio\" value=\"0\"></td>"
  144. . "\n\t<td>\n\t\t<select name=\"seriesTitleSelector2\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  145. . "\n\t<td><input type=\"text\" name=\"seriesTitleName2\" size=\"42\"></td>"
  146. . "\n</tr>";
  147. // (4) Complete the form:
  148. echo "\n<tr>"
  149. . "\n\t<td valign=\"middle\"><input type=\"checkbox\" name=\"showVolume\" value=\"1\"></td>"
  150. . "\n\t<td><b>Volume:</b></td>\n\t<td>&nbsp;</td>"
  151. . "\n\t<td>\n\t\t<select name=\"volumeSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t\t<option>is greater than</option>\n\t\t\t<option>is less than</option>\n\t\t\t<option>is within range</option>\n\t\t\t<option>is within list</option>\n\t\t</select>\n\t</td>"
  152. . "\n\t<td><input type=\"text\" name=\"volumeNo\" size=\"42\"></td>"
  153. . "\n</tr>"
  154. . "\n<tr>"
  155. . "\n\t<td valign=\"middle\"><input type=\"checkbox\" name=\"showPages\" value=\"1\" checked></td>"
  156. . "\n\t<td><b>Pages:</b></td>\n\t<td>&nbsp;</td>"
  157. . "\n\t<td>\n\t\t<select name=\"pagesSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  158. . "\n\t<td><input type=\"text\" name=\"pagesNo\" size=\"42\"></td>"
  159. . "\n</tr>"
  160. . "\n<tr>"
  161. . "\n\t<td width=\"20\" valign=\"middle\"><input type=\"checkbox\" name=\"showPublisher\" value=\"1\"></td>"
  162. . "\n\t<td width=\"40\"><b>Publisher:</b></td>\n\t<td width=\"10\">&nbsp;</td>"
  163. . "\n\t<td width=\"130\">\n\t\t<select name=\"publisherSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  164. . "\n\t<td><input type=\"text\" name=\"publisherName\" size=\"42\"></td>"
  165. . "\n</tr>"
  166. . "\n<tr>"
  167. . "\n\t<td width=\"20\" valign=\"middle\"><input type=\"checkbox\" name=\"showPlace\" value=\"1\"></td>"
  168. . "\n\t<td width=\"40\"><b>Place:</b></td>\n\t<td width=\"10\">&nbsp;</td>"
  169. . "\n\t<td width=\"130\">\n\t\t<select name=\"placeSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  170. . "\n\t<td><input type=\"text\" name=\"placeName\" size=\"42\"></td>"
  171. . "\n</tr>"
  172. . "\n<tr>"
  173. . "\n\t<td width=\"20\" valign=\"middle\"><input type=\"checkbox\" name=\"showCallNumber\" value=\"1\" checked></td>"
  174. . "\n\t<td width=\"40\"><b>Signature:</b></td>\n\t<td width=\"10\">&nbsp;</td>"
  175. . "\n\t<td width=\"130\">\n\t\t<select name=\"callNumberSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  176. . "\n\t<td><input type=\"text\" name=\"callNumberName\" size=\"42\"></td>"
  177. . "\n</tr>"
  178. . "\n<tr>"
  179. . "\n\t<td width=\"20\" valign=\"middle\"><input type=\"checkbox\" name=\"showKeywords\" value=\"1\"></td>"
  180. . "\n\t<td width=\"40\"><b>Keywords:</b></td>\n\t<td width=\"10\">&nbsp;</td>"
  181. . "\n\t<td width=\"130\">\n\t\t<select name=\"keywordsSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  182. . "\n\t<td><input type=\"text\" name=\"keywordsName\" size=\"42\"></td>"
  183. . "\n</tr>"
  184. . "\n<tr>"
  185. . "\n\t<td width=\"20\" valign=\"middle\"><input type=\"checkbox\" name=\"showNotes\" value=\"1\"></td>"
  186. . "\n\t<td width=\"40\"><b>Notes:</b></td>\n\t<td width=\"10\">&nbsp;</td>"
  187. . "\n\t<td width=\"130\">\n\t\t<select name=\"notesSelector\">\n\t\t\t<option>contains</option>\n\t\t\t<option>does not contain</option>\n\t\t\t<option>is equal to</option>\n\t\t\t<option>is not equal to</option>\n\t\t\t<option>starts with</option>\n\t\t\t<option>ends with</option>\n\t\t</select>\n\t</td>"
  188. . "\n\t<td><input type=\"text\" name=\"notesName\" size=\"42\"></td>"
  189. . "\n</tr>"
  190. . "\n<tr>\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>"
  191. . "\n</tr>"
  192. . "\n<tr>"
  193. . "\n\t<td>&nbsp;</td>"
  194. . "\n\t<td valign=\"top\"><b>Display Options:</b></td>\n\t<td>&nbsp;</td>"
  195. . "\n\t<td valign=\"middle\"><input type=\"checkbox\" name=\"showLinks\" value=\"1\" checked>&nbsp;&nbsp;&nbsp;Display Links</td>"
  196. . "\n\t<td valign=\"middle\">Show&nbsp;&nbsp;&nbsp;<input type=\"text\" name=\"showRows\" value=\"" . $showRows . "\" size=\"4\" title=\"" . $loc["DescriptionShowRecordsPerPage"] . "\">&nbsp;&nbsp;&nbsp;records per page"
  197. . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"submit\" value=\"Search\"></td>"
  198. . "\n</tr>"
  199. . "\n<tr>"
  200. . "\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>\n\t<td>&nbsp;</td>"
  201. . "\n</tr>"
  202. . "\n<tr>"
  203. . "\n\t<td>&nbsp;</td>\n\t<td>1st&nbsp;sort&nbsp;by:</td>\n\t<td>&nbsp;</td>"
  204. . "\n\t<td>\n\t\t<select name=\"sortSelector1\">\n\t\t\t<option selected>author</option>\n\t\t\t<option>title</option>\n\t\t\t<option>year</option>\n\t\t\t<option>editor</option>\n\t\t\t<option>series_title</option>\n\t\t\t<option>series_volume</option>\n\t\t\t<option>pages</option>\n\t\t\t<option>publisher</option>\n\t\t\t<option>place</option>\n\t\t\t<option>call_number</option>\n\t\t\t<option>keywords</option>\n\t\t\t<option>notes</option>\n\t\t</select>\n\t</td>"
  205. . "\n\t<td>\n\t\t<input type=\"radio\" name=\"sortRadio1\" value=\"0\" checked>&nbsp;&nbsp;&nbsp;ascending&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  206. . "\n\t\t<input type=\"radio\" name=\"sortRadio1\" value=\"1\">&nbsp;&nbsp;&nbsp;descending\n\t</td>"
  207. . "\n</tr>"
  208. . "\n<tr>"
  209. . "\n\t<td>&nbsp;</td>\n\t<td>2nd&nbsp;sort&nbsp;by:</td>\n\t<td>&nbsp;</td>"
  210. . "\n\t<td>\n\t\t<select name=\"sortSelector2\">\n\t\t\t<option>author</option>\n\t\t\t<option>title</option>\n\t\t\t<option selected>year</option>\n\t\t\t<option>editor</option>\n\t\t\t<option>series_title</option>\n\t\t\t<option>series_volume</option>\n\t\t\t<option>pages</option>\n\t\t\t<option>publisher</option>\n\t\t\t<option>place</option>\n\t\t\t<option>call_number</option>\n\t\t\t<option>keywords</option>\n\t\t\t<option>notes</option>\n\t\t</select>\n\t</td>"
  211. . "\n\t<td>\n\t\t<input type=\"radio\" name=\"sortRadio2\" value=\"0\">&nbsp;&nbsp;&nbsp;ascending&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  212. . "\n\t\t<input type=\"radio\" name=\"sortRadio2\" value=\"1\" checked>&nbsp;&nbsp;&nbsp;descending\n\t</td>"
  213. . "\n</tr>"
  214. . "\n<tr>"
  215. . "\n\t<td>&nbsp;</td>\n\t<td>3rd&nbsp;sort&nbsp;by:</td>\n\t<td>&nbsp;</td>"
  216. . "\n\t<td>\n\t\t<select name=\"sortSelector3\">\n\t\t\t<option>author</option>\n\t\t\t<option selected>title</option>\n\t\t\t<option>year</option>\n\t\t\t<option>editor</option>\n\t\t\t<option>series_title</option>\n\t\t\t<option>series_volume</option>\n\t\t\t<option>pages</option>\n\t\t\t<option>publisher</option>\n\t\t\t<option>place</option>\n\t\t\t<option>call_number</option>\n\t\t\t<option>keywords</option>\n\t\t\t<option>notes</option>\n\t\t</select>\n\t</td>"
  217. . "\n\t<td>\n\t\t<input type=\"radio\" name=\"sortRadio3\" value=\"0\" checked>&nbsp;&nbsp;&nbsp;ascending&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  218. . "\n\t\t<input type=\"radio\" name=\"sortRadio3\" value=\"1\">&nbsp;&nbsp;&nbsp;descending\n\t</td>"
  219. . "\n</tr>"
  220. . "\n</table>"
  221. . "\n</form>";
  222. // (5) Close the database connection:
  223. disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php'
  224. // --------------------------------------------------------------------
  225. // DISPLAY THE HTML FOOTER:
  226. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  227. showPageFooter($HeaderString);
  228. displayHTMLfoot();
  229. // --------------------------------------------------------------------
  230. ?>