/
extract.php
179 lines (150 loc) · 9.18 KB
/
extract.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./extract.php
// Repository: $HeadURL: http://svn.code.sf.net/p/refbase/code/trunk/extract.php $
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 29-Jul-02, 16:39
// Modified: $Date: 2012-02-27 12:25:30 -0800 (Mon, 27 Feb 2012) $
// $Author: msteffens $
// $Revision: 1337 $
// Search form that offers to extract
// literature cited within a text and build
// an appropriate reference list from that.
// TODO: I18n
// Incorporate some include files:
include 'includes/header.inc.php'; // include header
include 'includes/footer.inc.php'; // include footer
include 'includes/include.inc.php'; // include common functions
include 'initialize/ini.inc.php'; // include common variables
// --------------------------------------------------------------------
// START A SESSION:
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
start_session(true);
// --------------------------------------------------------------------
// Initialize preferred display language:
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
include 'includes/locales.inc.php'; // include the locales
// --------------------------------------------------------------------
// If there's no stored message available:
if (!isset($_SESSION['HeaderString']))
$HeaderString = "Extract citations from a text and build an appropriate reference list:"; // Provide the default message
else
{
$HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
// Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
}
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
// ('' will produce the default 'Web' output style)
if (isset($_REQUEST['viewType']))
$viewType = $_REQUEST['viewType'];
else
$viewType = "";
// Show the login status:
showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
// (2a) Display header:
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Extract Citations", "index,follow", "Search the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
showPageHeader($HeaderString);
// (2b) Start <form> and <table> holding the form elements:
echo "\n<form action=\"search.php\" method=\"POST\">";
echo "\n<input type=\"hidden\" name=\"formType\" value=\"extractSearch\">"
. "\n<input type=\"hidden\" name=\"submit\" value=\"Cite\">"; // provide a default value for the 'submit' form tag. Otherwise, some browsers may not recognize the correct output format when a user hits <enter> within a form field (instead of clicking the "Cite" button)
if (!isset($_SESSION['user_styles']))
$citeStyleDisabled = " disabled"; // disable the style popup if the session variable holding the user's styles isn't available
else
$citeStyleDisabled = "";
if (!isset($_SESSION['user_cite_formats']))
$citeFormatDisabled = " disabled"; // disable the cite format popup if the session variable holding the user's cite formats isn't available
else
$citeFormatDisabled = "";
echo "\n<table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\" summary=\"This table holds the search form\">"
. "\n<tr>\n\t<td width=\"58\" valign=\"top\"><b>Extract Citations From:</b></td>\n\t<td width=\"10\"> </td>"
. "\n\t<td><textarea name=\"sourceText\" rows=\"6\" cols=\"60\">Paste your text here...</textarea></td>"
. "\n</tr>"
. "\n<tr>\n\t<td valign=\"top\" rowspan=\"2\"><b>Serial Delimiters:</b></td>\n\t<td> </td>"
. "\n\t<td valign=\"top\">Specify the character(s) that enclose record serial numbers or cite keys:</td>"
. "\n</tr>"
. "\n<tr>\n\t<td> </td>"
. "\n\t<td valign=\"top\">Start Delimiter: <input type=\"text\" name=\"startDelim\" value=\"{\" size=\"4\"> End Delimiter: <input type=\"text\" name=\"endDelim\" value=\"}\" size=\"4\"></td>"
. "\n</tr>"
. "\n<tr>\n\t<td valign=\"top\" rowspan=\"2\"><b>Display Options:</b></td>\n\t<td> </td>"
. "\n\t<td valign=\"top\"><input type=\"checkbox\" name=\"showLinks\" value=\"1\" checked> Display Links"
. " Show <input type=\"text\" name=\"showRows\" value=\"100\" size=\"4\" title=\"" . $loc["DescriptionShowRecordsPerPage"] . "\"> records per page</td>"
. "\n</tr>"
. "\n<tr>\n\t<td> </td>"
. "\n\t<td valign=\"top\">View type: "
. "\n\t\t<select name=\"viewType\">"
. "\n\t\t\t<option>Web</option>"
. "\n\t\t\t<option>Print</option>"
. "\n\t\t\t<option>Mobile</option>"
. "\n\t\t</select>"
. "\n\t</td>"
. "\n</tr>"
. "\n<tr>\n\t<td> </td>\n\t<td> </td>";
if (isset($_SESSION['user_permissions']) AND preg_match("/allow_cite/", $_SESSION['user_permissions'])) // if the 'user_permissions' session variable contains 'allow_cite'...
// adjust the title string for the show cite button
{
$citeButtonLock = "";
$citeTitle = "build a reference list for all citations contained within the entered text";
}
else // Note, that disabling the submit button is just a cosmetic thing -- the user can still submit the form by pressing enter or by building the correct URL from scratch! (however, there's some code in 'search.php' that will prevent query execution)
{
$citeButtonLock = " disabled";
$citeTitle = "not available since you have no permission to use the cite feature";
}
echo "\n\t<td>\n\t\t<br><input type=\"submit\" name=\"submit\" value=\"Cite\"$citeButtonLock title=\"$citeTitle\"> "
. "\n\t\tusing style: "
. "\n\t\t<select name=\"citeStyle\" title=\"choose the output style for your reference list\"$citeStyleDisabled>";
if (isset($_SESSION['user_styles']))
{
$optionTags = buildSelectMenuOptions($_SESSION['user_styles'], "/ *; */", "\t\t\t", false); // build properly formatted <option> tag elements from the items listed in the 'user_styles' session variable
echo $optionTags;
}
else
echo "\n\t\t\t<option>" . $defaultCiteStyle . "</option>"; // defined in 'ini.inc.php'
echo "\n\t\t</select> "
. "\n\t\tsort by: "
. "\n\t\t<select name=\"citeOrder\" title=\"choose the primary sort order for your reference list\">"
. "\n\t\t\t<option value=\"author\">author</option>"
. "\n\t\t\t<option value=\"year\">year</option>"
. "\n\t\t\t<option value=\"type\">type</option>"
. "\n\t\t\t<option value=\"type-year\">type, year</option>"
. "\n\t\t\t<option value=\"creation-date\">date created</option>"
. "\n\t\t</select> "
. "\n\t\treturn as: "
. "\n\t\t<select name=\"citeType\" title=\"choose how your reference list shall be returned\"$citeFormatDisabled>";
if (isset($_SESSION['user_cite_formats']))
{
$optionTags = buildSelectMenuOptions($_SESSION['user_cite_formats'], "/ *; */", "\t\t\t", false); // build properly formatted <option> tag elements from the items listed in the 'user_cite_formats' session variable
echo $optionTags;
}
else
echo "\n\t\t\t<option>(no formats available)</option>";
echo "\n\t\t</select>\n\t</td>"
. "\n</tr>"
. "\n<tr>\n\t<td align=\"center\" colspan=\"3\"> </td>"
. "\n</tr>"
. "\n<tr>\n\t<td valign=\"top\"><b>Help:</b></td>\n\t<td> </td>"
. "\n\t<td valign=\"top\">This form enables you to extract all citations from your text and build an appropriate reference list. To have this work simply include the serial numbers or cite keys of your cited records within your text (as shown below) and enclose the identifiers by some preferrably unique characters. These delimiters must be specified in the text fields above.</td>"
. "\n</tr>"
. "\n<tr>\n\t<td valign=\"top\"><b>Example:</b></td>\n\t<td> </td>"
. "\n\t<td valign=\"top\"><code>Results of the german south polar expedition were published by Hennings (1906) {1141} as well as several other authors (e.g.: Wille 1924 {1785}; Heiden & Kolbe 1928 {1127}).</code></td>"
. "\n</tr>"
. "\n</table>"
. "\n</form>";
// --------------------------------------------------------------------
// DISPLAY THE HTML FOOTER:
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
showPageFooter($HeaderString);
displayHTMLfoot();
// --------------------------------------------------------------------
?>