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.

254 lines
17 KiB

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