/[libdata]/trunk/admin/res_results_brief.phtml
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/admin/res_results_brief.phtml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 73 - (hide annotations)
Thu Mar 18 21:27:37 2004 UTC (20 years, 1 month ago) by dpavlin
File size: 9759 byte(s)
sync trunk to HEAD of pear-db (without changes specific to PEAR which will be dropped)

1 dpavlin 16 <?php
2     // Load globals
3     require_once ("global_vars.php");
4    
5     // Includes
6     require_once ($GLOBAL_ADMIN_INC."sessionClass.php");
7     require_once ($GLOBAL_ADMIN_INC."accessClass.php");
8 dpavlin 73 require_once ("db_connect.php");
9 dpavlin 16 require_once ($GLOBAL_ADMIN_INC."app_controls.php");
10    
11     // HTML header
12     printf("<HTML>\n");
13     printf("<HEAD>\n");
14     printf("<title>Resource Search Results</title>\n");
15     printf("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n", $GLOBAL_ADMIN_CSS);
16     printf("</HEAD>\n");
17    
18    
19 dpavlin 72 // Default access settings
20     $sess_time_human = "";
21     $sess_staff_account = "";
22     $sess_staff_id = 0;
23     $sess_access_level = 0;
24     $sess_access = "";
25     $sess_last_name = "";
26     $sess_first_name = "";
27    
28    
29 dpavlin 16 // Page header
30     require_once ($GLOBAL_ADMIN_HEADER);
31    
32    
33     // Collect access information
34     if(isset($libsession)) {
35    
36     // Fetch session information
37     $sessionClass = new sessionClass("", $libsession, "", "");
38     $accessClass = new accessClass($sessionClass);
39    
40     // Load user session variables
41     $sess_time_human = $sessionClass->time_human;
42     $sess_staff_account = $sessionClass->staff_account;
43     $sess_access_level = $accessClass->access_level;
44     $sess_access = $accessClass->access;
45     $sess_last_name = $accessClass->last_name;
46     $sess_first_name = $accessClass->first_name;
47    
48     }
49    
50     // If the cookie is set and access level is appropriate
51     if(isset($libsession) && $sess_access_level >= 20) {
52    
53     // Display page heading
54     printf("<center><h3>Resource Search Results</h3>\n");
55    
56     // Set up a flagging variable to track possible problems with the search parameters
57     $problem = 0;
58    
59     // Make sure some criteria was chosen (i.e. we don't want to return ALL records)
60     // However, a "*" for record_id means a wildcard.
61    
62 dpavlin 72 if ($account_created == "" && $account_modified == "" && $subject == "" &&
63     $author == "" && $annotation == "" && $subject_id < 1 && $title == "" &&
64     $date_created == "" && $date_modified == "" && $location =="" &&
65     $location_id < 1 && $infotype_id =="" && $resource_id < 1 &&
66     $resource_id != "*" && $cat_num < 1 && $url =="" && $call_no =="" &&
67     $feature_id < 1 && $feature_id < 1 && $vendor_id < 1 &&
68     $guide_url == "") $problem = 2;
69 dpavlin 16 if ($resource_id == "*") $resource_id = "";
70    
71     // Algorithm is cleared to search
72     if ($problem < 1) {
73    
74     // Clean up strings
75     //if (strlen($annotation) > 0) $annotation = textInmySQL($annotation);
76     //if (strlen($author) > 0) $author = textInmySQL($author);
77     //if (strlen($call_no) > 0) $call_no = textInmySQL($call_no);
78     //if (strlen($cat_num) > 0) $cat_num = textInmySQL($cat_num);
79     //if (strlen($coverage_detail) > 0) $coverage_detail = textInmySQL($coverage_detail);
80     //if (strlen($edition) > 0) $edition = textInmySQL($edition);
81     //if (strlen($other_title) > 0) $other_title = textInmySQL($other_title);
82     //if (strlen($pub_date) > 0) $pub_date = textInmySQL($pub_date);
83     //if (strlen($publisher) > 0) $publisher = textInmySQL($publisher);
84     //if (strlen($sources_indexed) > 0) $sources_indexed = textInmySQL($sources_indexed);
85     //if (strlen($title)> 0) $title = textInHTML($title);
86     //if (strlen($url) > 0) $url = textInmySQL($url);
87    
88    
89     /* Select a distinct row of reference information, but build the extra
90     joins in case the user wants to limit by additional criteria. */
91    
92     $sql = "SELECT DISTINCT
93     r.resource_id,
94     r.date_created,
95     r.date_modified,
96     r.title,
97     r.annotation,
98     r.cat_num,
99     r.call_no,
100     r.publisher,
101     r.pub_date,
102     r.author,
103     r.url
104    
105     FROM
106     resource r
107     LEFT JOIN res_loc rl using (resource_id) ";
108    
109     if ($feature_id > 0) $sql .=
110     "LEFT JOIN res_feature rf on r.resource_id = rf.resource_id ";
111    
112     $sql .="WHERE (
113     ( r.resource_id > 0 ) ";
114    
115     // If user limited by author
116     if ($author != ""){
117    
118     $author = textSearchmySQL($author);
119     $sql .= " AND (r.author LIKE '%" . $author . "%')";
120     }
121    
122     // If user limited by annotation keyword or phrase
123     if ($annotation != ""){
124    
125     $annotation = textSearchmySQL($annotation);
126     $sql .= " AND (r.annotation LIKE '%" . $annotation . "%')";
127     }
128    
129     // If user limited by feature id
130     if ($feature_id > 0){
131     $sql .= " AND (rf.feature_id ="
132     . $feature_id
133     . ")";
134     }
135    
136     // If user limited by url
137     if ($url != ""){
138    
139     $url = textSearchmySQL($url);
140     $sql .= " AND (r.url LIKE '%" . $url . "%')";
141     }
142    
143 dpavlin 72 // If user limited by help/guide url
144     if ($guide_url != ""){
145    
146     $guide_url = textSearchmySQL($guide_url);
147     $sql .= " AND (r.guide_url LIKE '%" . $guide_url . "%')";
148     }
149    
150 dpavlin 16 // If user limited by title
151     if ($title !=""){
152    
153     $title = textSearchmySQL($title);
154     $sql .= " AND (r.title LIKE '%"
155     . $title
156     . "%')";
157     }
158    
159     // If user limited by date created
160     if ($date_created !=""){
161    
162     $date_created = textSearchmySQL($date_created);
163     $sql .= " AND (r.date_created LIKE '%"
164     . $date_created
165     . "%')";
166     }
167    
168     // If user limited by date modified
169     if ($date_modified !=""){
170    
171     $date_modified = textSearchmySQL($date_modified);
172     $sql .= " AND (r.date_modified LIKE '%"
173     . $date_modified
174     . "%')";
175     }
176    
177     // If user limited by pub date
178     if ($pub_date !=""){
179    
180     $pub_date = textSearchmySQL($pub_date);
181     $sql .= " AND (r.pub_date ='"
182     . $pub_date
183     . "')";
184     }
185    
186     // If user limited by information type id
187     if ($infotype_id > 0){
188     $sql .= " AND (r.infotype_id ="
189     . $infotype_id
190     . ")";
191     }
192    
193     // If user limited by location id
194     if ($location_id > 0){
195     $sql .= " AND (rl.location_id ="
196     . $location_id
197     . ")";
198     }
199 dpavlin 72
200     // If user limited by vendor id
201     if ($vendor_id > 0){
202     $sql .= " AND (r.vendor_id ="
203     . $vendor_id
204     . ")";
205     }
206 dpavlin 16
207     // If user limited by call number
208     if ($call_no !=""){
209    
210     $call_no = textSearchmySQL($call_no);
211     $sql .= " AND (r.call_no LIKE '%"
212     . $call_no
213     . "%')";
214     }
215    
216     // If user limited by resource id
217     if ($resource_id !=""){
218     // Cast as integer to avoid possible problems
219     $resource_id = (int) $resource_id;
220     $sql .= " AND (r.resource_id = "
221     . $resource_id
222     . ")";
223     }
224    
225     // If user limited by catalog number
226     if ($cat_num !=""){
227    
228     $cat_num = textSearchmySQL($cat_num);
229     $sql .= " AND (r.cat_num ='"
230     . $cat_num
231     . "')";
232     }
233    
234     // If user limited by account_created
235     if ($account_created !=""){
236    
237     $account_created = textSearchmySQL($account_created);
238     $sql .= " AND (r.account_created ='"
239     . $account_created
240     . "')";
241     }
242    
243     // If user limited by account_modified
244     if ($account_modified !=""){
245    
246     $account_modified = textSearchmySQL($account_modified);
247     $sql .= " AND (r.account_modified ='"
248     . $account_modified
249     . "')";
250     }
251    
252     // cap it off
253     $sql .= ")";
254    
255     // Order by
256     if ($orderby !="" && $orderdir != ""){
257     $sql .= " ORDER BY " . $orderby . " " . $orderdir;
258     }
259    
260 dpavlin 72 $rs = xx_tryquery($sql);
261    
262 dpavlin 16 // Table
263     printf("<center><table width=\"90%%\" border =\"1\" bgcolor =\"#ffffff\" cellpadding=\"4\">");
264    
265     // Row header
266     printf("<tr><td width = \"10%%\" class=\"cellPlain\">\n");
267     printf("ID#");
268     printf("</td>\n");
269    
270     printf("<td class=\"cellPlain\">Cmd</td>\n");
271    
272     printf("<td width = \"20%%\" class=\"cellPlain\">\n");
273     printf("Usage Drilldown");
274     printf("</td>\n");
275    
276     printf("<td width = \"70%%\" class=\"cellPlain\">\n");
277     printf("Resource");
278     printf("</td></tr>\n");
279    
280     // Initialize counter
281     $rowcount = 0;
282    
283     // Cycle through the result set of unique reference id's.
284 dpavlin 72 while ( $row = xx_fetch_array ($rs, xx_ASSOC)) {
285 dpavlin 16 $resource_id = $row["resource_id"];
286     $title = Trim($row["title"]);
287     $publisher = Trim($row["publisher"]);
288     $pub_date = Trim($row["pub_date"]);
289     $record_id = Trim($row["record_id"]);
290     $cat_num = Trim($row["cat_num"]);
291     $annotation = Trim($row["annotation"]);
292     $author = Trim($row["author"]);
293     $call_no = Trim($row["call_no"]);
294     $url = Trim($row["url"]);
295    
296     // Make every other row colored
297     if ($rowcount % 2 == 0) $color = " class=\"backLight\" ";
298     else $color = "";
299    
300     // For display purposes
301     if (strlen($url) > 1 && strlen($call_no) < 1) {
302     $call_no = "<a href = \" " . $url . " \" >" . $url . "</a>";
303     $call_no_label = "URL";
304     }
305     else $call_no_label = "Call No.";
306     if (strlen($title) < 1) $title = "&nbsp;";
307     if (strlen($pub_date) < 1) $pub_date = "&nbsp;";
308    
309     // Resource ID #
310     printf("<tr>");
311     printf("<td width = \"10%%\" %s>\n", $color);
312     printf("%d ", $resource_id);
313     printf("</td>\n");
314    
315     printf("<td align=\"center\" %s>\n", $color);
316     printf("<a href=\"operation.phtml?operation=Edit&table=resource&key_id="
317     . $resource_id
318     . "\">Edit</a>");
319     printf("</td>\n");
320    
321     // Detail page
322     printf("<td width = \"20%%\" %s>\n", $color);
323     printf("<a href=\"res_drill.phtml?resource_id=%d\">[Drilldown]</a>\n", $resource_id);
324     printf("</td>\n");
325    
326     // Resource
327     printf("<td width = \"70%%\" %s>\n", $color);
328     printf("Title: %s<BR>", $title);
329     if (strlen($author) > 0) printf("Author: %s<br>", $author);
330     if (strlen($call_no) > 0) printf("%s: %s<br>", $call_no_label, $call_no);
331     printf("</td></tr>\n");
332    
333     // Increment counter
334     $rowcount++;
335     }
336    
337     // Search statistics
338     printf("<tr><td align = \"right\" colspan =\"4\" class=\"backLight\">\n");
339     $records = "record";
340 dpavlin 42 printf("<BR>Returned %d ", xx_num_rows($rs));
341     if (xx_num_rows($rs) != 1) $records .= "s";
342 dpavlin 16 printf($records);
343     printf(".");
344    
345     // Close off the table
346     printf ("</td></tr></table></center><BR>\n");
347    
348     }
349    
350     printf("<center>\n");
351    
352     // Error trapping
353     // No search criteria supplied
354     if ($problem == 2) printf ("No search criteria supplied. Please go back and select some criteria.<br><br>\n");
355    
356     printf("</center>\n");
357    
358     // Link to return to admin console
359     adminReturn($sess_access_level);
360    
361     } // logged in
362    
363    
364     // No access
365     else require_once ($GLOBAL_NO_ACCESS);
366    
367    
368     // Page footer
369     require_once ($GLOBAL_ADMIN_FOOTER);
370     ?>
371    
372     </body>
373     </html>

  ViewVC Help
Powered by ViewVC 1.1.26