Annotation of loncom/interface/lonsearchcat.pm, revision 1.7
1.1 www 1: # The LearningOnline Network
2: # Search Catalog
3: #
1.2 harris41 4: # 03/08/2001 Scott Harrison
1.1 www 5: #
6: package Apache::lonsearchcat;
7:
8: use strict;
9: use Apache::Constants qw(:common);
1.6 harris41 10: use Apache::lonnet();
11: use Apache::File();
1.7 ! harris41 12: use CGI qw(:standard);
1.1 www 13:
1.3 harris41 14: my %language;
15: my $scrout;
16: my %metadatafields;
17: my %cprtag;
18: my %mimetag;
19:
1.1 www 20: sub handler {
21: my $r = shift;
1.7 ! harris41 22:
! 23: # -------------------------------------- see if called from an interactive mode
! 24: map {
! 25: my ($name, $value) = split(/=/,$_);
! 26: $value =~ tr/+/ /;
! 27: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
! 28: if ($name eq 'catalogmode') {
! 29: $ENV{'form.'.$name}=$value;
! 30: }
! 31: } (split(/&/,$ENV{'QUERY_STRING'}));
! 32:
1.1 www 33: $r->content_type('text/html');
34: $r->send_http_header;
35: return OK if $r->header_only;
36:
1.3 harris41 37: %metadatafields=();
38:
39: # ------------------------------------------------ First, check out environment
40: $metadatafields{'owner'}=$ENV{'user.name'}.'@'.$ENV{'user.domain'};
41:
42:
43: %language=();
44: $language{'any'}='Any language';
45: {
46: my $fh=Apache::File->new($r->dir_config('lonTabDir').'/language.tab');
47: map {
48: $_=~/(\w+)\s+([\w\s\-]+)/;
49: $language{$1}=$2;
50: } <$fh>;
51: }
52:
53: %cprtag=();
54: $cprtag{'any'}='Any copyright/distribution';
55: {
56: my $fh=Apache::File->new($r->dir_config('lonIncludes').'/copyright.tab');
57: map {
58: $_=~/(\w+)\s+([\w\s\-]+)/;
59: $cprtag{$1}=$2;
60: } <$fh>;
61: }
62:
63: %mimetag=();
64: $mimetag{'any'}='Any type';
65: {
66: my $fh=Apache::File->new($r->dir_config('lonTabDir').'/filetypes.tab');
67: map {
68: $_=~/(\w+)\s+(\w+)\s+([\w\s\-]+)/;
69: $mimetag{$1}=".$1 $3";
70: } <$fh>;
71: }
72:
1.6 harris41 73: if ($ENV{'form.basicsubmit'} eq 'SEARCH') {
74: return &basicsearch($r,$ENV{'form.basicexp'});
75: }
76:
1.3 harris41 77: $scrout="";
78: $scrout.=&searchphrasefield('Limit by title','title',
79: '');
80:
81: $scrout.=&searchphrasefield('Limit by author','author',
82: '');
83:
84: $scrout.=&searchphrasefield('Limit by subject','subject',
85: '');
86:
87: $scrout.=&searchphrasefield('Limit by notes','notes',
88: '');
89:
90: $scrout.=&searchphrasefield('Limit by abstract','abstract',
91: '');
92:
93: $scrout.=&selectbox('Limit by MIME type','mime',
94: 'notxxx',%mimetag);
95:
96: $scrout.=&selectbox('Limit by language','language',
97: 'any',%language);
98:
99: $scrout.=<<CREATIONDATEEND;
100: <p>
101: <font color="#800000" face="helvetica"><b>LIMIT BY CREATION DATE RANGE:</b>
102: </font>
103: <br>
104: between:<select name="creationdatemonthstart">
105: <option value="01"> </option>
106: <option value="01">January</option>
107: <option value="02">February</option>
108: <option value="03">March</option>
109: <option value="04">April</option>
110: <option value="05">May</option>
111: <option value="06">June</option>
112: <option value="07">July</option>
113: <option value="08">August</option>
114: <option value="09">September</option>
115: <option value="10">October</option>
116: <option value="11">November</option>
117: <option value="12">December</option>
118: </select>
119: <select name="creationdatedaystart">
120: <option value="1"> </option>
121: <option value=1>1</option>
122: <option value=2>2</option>
123: <option value=3>3</option>
124: <option value=4>4</option>
125: <option value=5>5</option>
126: <option value=6>6</option>
127: <option value=7>7</option>
128: <option value=8>8</option>
129: <option value=9>9</option>
130: <option value=10>10</option>
131: <option value=11>11</option>
132: <option value=12>12</option>
133: <option value=13>13</option>
134: <option value=14>14</option>
135: <option value=15>15</option>
136: <option value=16>16</option>
137: <option value=17>17</option>
138: <option value=18>18</option>
139: <option value=19>19</option>
140: <option value=20>20</option>
141: <option value=21>21</option>
142: <option value=22>22</option>
143: <option value=23>23</option>
144: <option value=24>24</option>
145: <option value=25>25</option>
146: <option value=26>26</option>
147: <option value=27>27</option>
148: <option value=28>28</option>
149: <option value=29>29</option>
150: <option value=30>30</option>
151: <option value=31>31</option>
152: </select>
153: <select name="creationdateyearstart">
154: <option value=1976> </option>
155: <option value=1976>1976</option>
156: <option value=1977>1977</option>
157: <option value=1978>1978</option>
158: <option value=1979>1979</option>
159: <option value=1980>1980</option>
160: <option value=1981>1981</option>
161: <option value=1982>1982</option>
162: <option value=1983>1983</option>
163: <option value=1984>1984</option>
164: <option value=1985>1985</option>
165: <option value=1986>1986</option>
166: <option value=1987>1987</option>
167: <option value=1988>1988</option>
168: <option value=1989>1989</option>
169: <option value=1990>1990</option>
170: <option value=1991>1991</option>
171: <option value=1992>1992</option>
172: <option value=1993>1993</option>
173: <option value=1994>1994</option>
174: <option value=1995>1995</option>
175: <option value=1996>1996</option>
176: <option value=1997>1997</option>
177: <option value=1998>1998</option>
178: <option value=1999>1999</option>
179: <option value=2000>2000</option>
180: <option value=2001>2001</option>
181: <option value=2002>2002</option>
182: <option value=2003>2003</option>
183: <option value=2004>2004</option>
184: <option value=2005>2005</option>
185: <option value=2006>2006</option>
186: <option value=2007>2007</option>
187: <option value=2008>2008</option>
188: <option value=2009>2009</option>
189: <option value=2010>2010</option>
190: <option value=2011>2011</option>
191: <option value=2012>2012</option>
192: <option value=2013>2013</option>
193: <option value=2014>2014</option>
194: <option value=2015>2015</option>
195: <option value=2016>2016</option>
196: <option value=2017>2017</option>
197: <option value=2018>2018</option>
198: <option value=2019>2019</option>
199: <option value=2020>2020</option>
200: <option value=2021>2021</option>
201: <option value=2022>2022</option>
202: <option value=2023>2023</option>
203: <option value=2024>2024</option>
204: <option value=2025>2025</option>
205: <option value=2026>2026</option>
206: <option value=2027>2027</option>
207: <option value=2028>2028</option>
208: <option value=2029>2029</option>
209: <option value=2030>2030</option>
210: <option value=2031>2031</option>
211: <option value=2032>2032</option>
212: <option value=2033>2033</option>
213: <option value=2034>2034</option>
214: <option value=2035>2035</option>
215: <option value=2036>2036</option>
216: <option value=2037>2037</option>
217: <option value=2038>2038</option>
218: <option value=2039>2039</option>
219: <option value=2040>2040</option>
220: <option value=2041>2041</option>
221: <option value=2042>2042</option>
222: <option value=2043>2043</option>
223: <option value=2044>2044</option>
224: <option value=2045>2045</option>
225: <option value=2046>2046</option>
226: <option value=2047>2047</option>
227: <option value=2048>2048</option>
228: <option value=2049>2049</option>
229: <option value=2050>2050</option>
230: <option value=2051>2051</option>
231: </select>
232: and:<select name="creationdatemonthend">
233: <option value="12"> </option>
234: <option value="01">January</option>
235: <option value="02">February</option>
236: <option value="03">March</option>
237: <option value="04">April</option>
238: <option value="05">May</option>
239: <option value="06">June</option>
240: <option value="07">July</option>
241: <option value="08">August</option>
242: <option value="09">September</option>
243: <option value="10">October</option>
244: <option value="11">November</option>
245: <option value="12">December</option>
246: </select>
247: <select name="creationdatedayend">
248: <option value=28> </option>
249: <option value=1>1</option>
250: <option value=2>2</option>
251: <option value=3>3</option>
252: <option value=4>4</option>
253: <option value=5>5</option>
254: <option value=6>6</option>
255: <option value=7>7</option>
256: <option value=8>8</option>
257: <option value=9>9</option>
258: <option value=10>10</option>
259: <option value=11>11</option>
260: <option value=12>12</option>
261: <option value=13>13</option>
262: <option value=14>14</option>
263: <option value=15>15</option>
264: <option value=16>16</option>
265: <option value=17>17</option>
266: <option value=18>18</option>
267: <option value=19>19</option>
268: <option value=20>20</option>
269: <option value=21>21</option>
270: <option value=22>22</option>
271: <option value=23>23</option>
272: <option value=24>24</option>
273: <option value=25>25</option>
274: <option value=26>26</option>
275: <option value=27>27</option>
276: <option value=28>28</option>
277: <option value=29>29</option>
278: <option value=30>30</option>
279: <option value=31>31</option>
280: </select>
281: <select name="creationdateyearend">
282: <option value=2051> </option>
283: <option value=1976>1976</option>
284: <option value=1977>1977</option>
285: <option value=1978>1978</option>
286: <option value=1979>1979</option>
287: <option value=1980>1980</option>
288: <option value=1981>1981</option>
289: <option value=1982>1982</option>
290: <option value=1983>1983</option>
291: <option value=1984>1984</option>
292: <option value=1985>1985</option>
293: <option value=1986>1986</option>
294: <option value=1987>1987</option>
295: <option value=1988>1988</option>
296: <option value=1989>1989</option>
297: <option value=1990>1990</option>
298: <option value=1991>1991</option>
299: <option value=1992>1992</option>
300: <option value=1993>1993</option>
301: <option value=1994>1994</option>
302: <option value=1995>1995</option>
303: <option value=1996>1996</option>
304: <option value=1997>1997</option>
305: <option value=1998>1998</option>
306: <option value=1999>1999</option>
307: <option value=2000>2000</option>
308: <option value=2001>2001</option>
309: <option value=2002>2002</option>
310: <option value=2003>2003</option>
311: <option value=2004>2004</option>
312: <option value=2005>2005</option>
313: <option value=2006>2006</option>
314: <option value=2007>2007</option>
315: <option value=2008>2008</option>
316: <option value=2009>2009</option>
317: <option value=2010>2010</option>
318: <option value=2011>2011</option>
319: <option value=2012>2012</option>
320: <option value=2013>2013</option>
321: <option value=2014>2014</option>
322: <option value=2015>2015</option>
323: <option value=2016>2016</option>
324: <option value=2017>2017</option>
325: <option value=2018>2018</option>
326: <option value=2019>2019</option>
327: <option value=2020>2020</option>
328: <option value=2021>2021</option>
329: <option value=2022>2022</option>
330: <option value=2023>2023</option>
331: <option value=2024>2024</option>
332: <option value=2025>2025</option>
333: <option value=2026>2026</option>
334: <option value=2027>2027</option>
335: <option value=2028>2028</option>
336: <option value=2029>2029</option>
337: <option value=2030>2030</option>
338: <option value=2031>2031</option>
339: <option value=2032>2032</option>
340: <option value=2033>2033</option>
341: <option value=2034>2034</option>
342: <option value=2035>2035</option>
343: <option value=2036>2036</option>
344: <option value=2037>2037</option>
345: <option value=2038>2038</option>
346: <option value=2039>2039</option>
347: <option value=2040>2040</option>
348: <option value=2041>2041</option>
349: <option value=2042>2042</option>
350: <option value=2043>2043</option>
351: <option value=2044>2044</option>
352: <option value=2045>2045</option>
353: <option value=2046>2046</option>
354: <option value=2047>2047</option>
355: <option value=2048>2048</option>
356: <option value=2049>2049</option>
357: <option value=2050>2050</option>
358: <option value=2051>2051</option>
359: </select>
360: </p>
361: CREATIONDATEEND
362:
363: $scrout.=<<LASTREVISIONDATEEND;
364: <p>
365: <font color="#800000" face="helvetica"><b>LIMIT BY LAST REVISION DATE RANGE:
366: </b></font>
367: <br>between:<select name="lastrevisiondatemonthstart">
368: <option value="00"> </option>
369: <option value="01">January</option>
370: <option value="02">February</option>
371: <option value="03">March</option>
372: <option value="04">April</option>
373: <option value="05">May</option>
374: <option value="06">June</option>
375: <option value="07">July</option>
376: <option value="08">August</option>
377: <option value="09">September</option>
378: <option value="10">October</option>
379: <option value="11">November</option>
380: <option value="12">December</option>
381: </select>
382: <select name="lastrevisiondatedaystart">
383: <option value=1> </option>
384: <option value=1>1</option>
385: <option value=2>2</option>
386: <option value=3>3</option>
387: <option value=4>4</option>
388: <option value=5>5</option>
389: <option value=6>6</option>
390: <option value=7>7</option>
391: <option value=8>8</option>
392: <option value=9>9</option>
393: <option value=10>10</option>
394: <option value=11>11</option>
395: <option value=12>12</option>
396: <option value=13>13</option>
397: <option value=14>14</option>
398: <option value=15>15</option>
399: <option value=16>16</option>
400: <option value=17>17</option>
401: <option value=18>18</option>
402: <option value=19>19</option>
403: <option value=20>20</option>
404: <option value=21>21</option>
405: <option value=22>22</option>
406: <option value=23>23</option>
407: <option value=24>24</option>
408: <option value=25>25</option>
409: <option value=26>26</option>
410: <option value=27>27</option>
411: <option value=28>28</option>
412: <option value=29>29</option>
413: <option value=30>30</option>
414: <option value=31>31</option>
415: </select>
416: <select name="lastrevisiondateyearstart">
417: <option value=1976> </option>
418: <option value=1976>1976</option>
419: <option value=1977>1977</option>
420: <option value=1978>1978</option>
421: <option value=1979>1979</option>
422: <option value=1980>1980</option>
423: <option value=1981>1981</option>
424: <option value=1982>1982</option>
425: <option value=1983>1983</option>
426: <option value=1984>1984</option>
427: <option value=1985>1985</option>
428: <option value=1986>1986</option>
429: <option value=1987>1987</option>
430: <option value=1988>1988</option>
431: <option value=1989>1989</option>
432: <option value=1990>1990</option>
433: <option value=1991>1991</option>
434: <option value=1992>1992</option>
435: <option value=1993>1993</option>
436: <option value=1994>1994</option>
437: <option value=1995>1995</option>
438: <option value=1996>1996</option>
439: <option value=1997>1997</option>
440: <option value=1998>1998</option>
441: <option value=1999>1999</option>
442: <option value=2000>2000</option>
443: <option value=2001>2001</option>
444: <option value=2002>2002</option>
445: <option value=2003>2003</option>
446: <option value=2004>2004</option>
447: <option value=2005>2005</option>
448: <option value=2006>2006</option>
449: <option value=2007>2007</option>
450: <option value=2008>2008</option>
451: <option value=2009>2009</option>
452: <option value=2010>2010</option>
453: <option value=2011>2011</option>
454: <option value=2012>2012</option>
455: <option value=2013>2013</option>
456: <option value=2014>2014</option>
457: <option value=2015>2015</option>
458: <option value=2016>2016</option>
459: <option value=2017>2017</option>
460: <option value=2018>2018</option>
461: <option value=2019>2019</option>
462: <option value=2020>2020</option>
463: <option value=2021>2021</option>
464: <option value=2022>2022</option>
465: <option value=2023>2023</option>
466: <option value=2024>2024</option>
467: <option value=2025>2025</option>
468: <option value=2026>2026</option>
469: <option value=2027>2027</option>
470: <option value=2028>2028</option>
471: <option value=2029>2029</option>
472: <option value=2030>2030</option>
473: <option value=2031>2031</option>
474: <option value=2032>2032</option>
475: <option value=2033>2033</option>
476: <option value=2034>2034</option>
477: <option value=2035>2035</option>
478: <option value=2036>2036</option>
479: <option value=2037>2037</option>
480: <option value=2038>2038</option>
481: <option value=2039>2039</option>
482: <option value=2040>2040</option>
483: <option value=2041>2041</option>
484: <option value=2042>2042</option>
485: <option value=2043>2043</option>
486: <option value=2044>2044</option>
487: <option value=2045>2045</option>
488: <option value=2046>2046</option>
489: <option value=2047>2047</option>
490: <option value=2048>2048</option>
491: <option value=2049>2049</option>
492: <option value=2050>2050</option>
493: <option value=2051>2051</option>
494: </select>
495: and:<select name="lastrevisiondatemonthend">
496: <option value="12"> </option>
497: <option value="01">January</option>
498: <option value="02">February</option>
499: <option value="03">March</option>
500: <option value="04">April</option>
501: <option value="05">May</option>
502: <option value="06">June</option>
503: <option value="07">July</option>
504: <option value="08">August</option>
505: <option value="09">September</option>
506: <option value="10">October</option>
507: <option value="11">November</option>
508: <option value="12">December</option>
509: </select>
510: <select name="lastrevisiondatedayend">
511: <option value=28> </option>
512: <option value=1>1</option>
513: <option value=2>2</option>
514: <option value=3>3</option>
515: <option value=4>4</option>
516: <option value=5>5</option>
517: <option value=6>6</option>
518: <option value=7>7</option>
519: <option value=8>8</option>
520: <option value=9>9</option>
521: <option value=10>10</option>
522: <option value=11>11</option>
523: <option value=12>12</option>
524: <option value=13>13</option>
525: <option value=14>14</option>
526: <option value=15>15</option>
527: <option value=16>16</option>
528: <option value=17>17</option>
529: <option value=18>18</option>
530: <option value=19>19</option>
531: <option value=20>20</option>
532: <option value=21>21</option>
533: <option value=22>22</option>
534: <option value=23>23</option>
535: <option value=24>24</option>
536: <option value=25>25</option>
537: <option value=26>26</option>
538: <option value=27>27</option>
539: <option value=28>28</option>
540: <option value=29>29</option>
541: <option value=30>30</option>
542: <option value=31>31</option>
543: </select>
544: <select name="lastrevisiondateyearend">
545: <option value=2051> </option>
546: <option value=1976>1976</option>
547: <option value=1977>1977</option>
548: <option value=1978>1978</option>
549: <option value=1979>1979</option>
550: <option value=1980>1980</option>
551: <option value=1981>1981</option>
552: <option value=1982>1982</option>
553: <option value=1983>1983</option>
554: <option value=1984>1984</option>
555: <option value=1985>1985</option>
556: <option value=1986>1986</option>
557: <option value=1987>1987</option>
558: <option value=1988>1988</option>
559: <option value=1989>1989</option>
560: <option value=1990>1990</option>
561: <option value=1991>1991</option>
562: <option value=1992>1992</option>
563: <option value=1993>1993</option>
564: <option value=1994>1994</option>
565: <option value=1995>1995</option>
566: <option value=1996>1996</option>
567: <option value=1997>1997</option>
568: <option value=1998>1998</option>
569: <option value=1999>1999</option>
570: <option value=2000>2000</option>
571: <option value=2001>2001</option>
572: <option value=2002>2002</option>
573: <option value=2003>2003</option>
574: <option value=2004>2004</option>
575: <option value=2005>2005</option>
576: <option value=2006>2006</option>
577: <option value=2007>2007</option>
578: <option value=2008>2008</option>
579: <option value=2009>2009</option>
580: <option value=2010>2010</option>
581: <option value=2011>2011</option>
582: <option value=2012>2012</option>
583: <option value=2013>2013</option>
584: <option value=2014>2014</option>
585: <option value=2015>2015</option>
586: <option value=2016>2016</option>
587: <option value=2017>2017</option>
588: <option value=2018>2018</option>
589: <option value=2019>2019</option>
590: <option value=2020>2020</option>
591: <option value=2021>2021</option>
592: <option value=2022>2022</option>
593: <option value=2023>2023</option>
594: <option value=2024>2024</option>
595: <option value=2025>2025</option>
596: <option value=2026>2026</option>
597: <option value=2027>2027</option>
598: <option value=2028>2028</option>
599: <option value=2029>2029</option>
600: <option value=2030>2030</option>
601: <option value=2031>2031</option>
602: <option value=2032>2032</option>
603: <option value=2033>2033</option>
604: <option value=2034>2034</option>
605: <option value=2035>2035</option>
606: <option value=2036>2036</option>
607: <option value=2037>2037</option>
608: <option value=2038>2038</option>
609: <option value=2039>2039</option>
610: <option value=2040>2040</option>
611: <option value=2041>2041</option>
612: <option value=2042>2042</option>
613: <option value=2043>2043</option>
614: <option value=2044>2044</option>
615: <option value=2045>2045</option>
616: <option value=2046>2046</option>
617: <option value=2047>2047</option>
618: <option value=2048>2048</option>
619: <option value=2049>2049</option>
620: <option value=2050>2050</option>
621: <option value=2051>2051</option>
622: </select>
623: </p>
624: LASTREVISIONDATEEND
625:
626: $scrout.=&searchphrasefield('Limit by publisher/owner','owner',
627: $metadatafields{'owner'});
628:
629: $scrout.=&selectbox('Limit by copyright/distribution','copyright',
630: 'any',%cprtag);
631:
1.2 harris41 632: # ---------------------------------------------------------------- Print screen
1.1 www 633: $r->print(<<ENDDOCUMENT);
634: <html>
635: <head>
636: <title>The LearningOnline Network with CAPA</title>
1.7 ! harris41 637: <script>
! 638: function select_data() {
! 639: changeTitle();
! 640: changeURL();
! 641: }
! 642: function changeTitle() {
! 643: if (opener.inf.document.forms.resinfo.elements.t) {
! 644: opener.inf.document.forms.resinfo.elements.t.value="ABC";
! 645: }
! 646: }
! 647: function changeURL() {
! 648: if (opener.inf.document.forms.resinfo.elements.u) {
! 649: opener.inf.document.forms.resinfo.elements.u.value="DEF";
! 650: }
! 651: }
! 652: </script>
1.1 www 653: </head>
654: <body bgcolor="#FFFFFF">
1.5 harris41 655: <img align=right src=/adm/lonIcons/lonlogos.gif>
1.1 www 656: <h1>Search Catalog</h1>
1.3 harris41 657: <form method="post" action="/adm/searchcat">
658: <hr>
659: <h3>Basic Search</h3>
1.7 ! harris41 660: <p>
! 661: <INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"
! 662: onClick="javascript:select_data()">
! 663: </p>
1.3 harris41 664: <p>
665: Enter terms or phrases separated by search operators
666: such as AND or OR then press SEARCH below. Terms should be specific
667: to the title, author, subject, notes, or abstract information associated
668: with a resource.
669: <br>
670: <input type="text" name="basicexp">
671: <input type="checkbox" name="titleonly">
672: <font color="#800000">Title only</font>
673: <br>
674: <input type="submit" name="basicsubmit" value="SEARCH">
675: </p>
676: <hr>
677: <h3>Advanced Search</h3>
678: $scrout
679: <p>
680: <input type="submit" name="advancedsubmit" value="SEARCH">
681: </p>
682: </form>
1.1 www 683: </body>
684: </html>
685: ENDDOCUMENT
686: return OK;
687: }
1.3 harris41 688:
689: # --------------------------------------------------------- Various form fields
690:
691: sub textfield {
692: my ($title,$name,$value)=@_;
693: return "\n<p><b>$title:</b><br>".
694: '<input type=text name="'.$name.'" size=80 value="'.$value.'">';
695: }
696:
697: sub searchphrasefield {
698: my ($title,$name,$value)=@_;
699: my $instruction=<<END;
700: Enter terms or phrases separated by search operators such
701: as AND or OR.
702: END
703: my $uctitle=uc($title);
704: return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:</b>".
705: ":</FONT> $instruction<br>".
706: '<input type=text name="'.$name.'" size=80 value="'.$value.'">';
707: }
708:
709: sub selectbox {
710: my ($title,$name,$value,%options)=@_;
711: my $uctitle=uc($title);
712: my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
713: "</b></font><br>".'<select name="'.$name.'">';
714: map {
715: $selout.='<option value="'.$_.'"';
716: if ($_ eq $value) { $selout.=' selected'; }
717: $selout.='>'.$options{$_}.'</option>';
718: } sort keys %options;
719: return $selout.'</select>';
1.6 harris41 720: }
721:
722: # --------------------------------------------------- Performing a basic search
723: sub basicsearch {
724: my ($r,$expression)=@_;
725:
726: my $query=$expression;
727: # $query="select * from metadata where concat(title,':\@:',author) like '\%Sci\%'";
728: $query="select * from metadata where concat(title,\" \",author) like '\%$expression\%'";
729: # my $reply=&Apache::lonnet::reply("querysend:DESCRIBE metadata","msul3");
730: my $reply=&Apache::lonnet::reply("querysend:$query",'msul3');
731: # my $reply=&Apache::lonnet::reply('querysend:select * from metadata','msul3');
732:
733: my @results;
734:
735: my $replyfile='';
736: $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting
737: $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
738: $reply=~/(.*?)\_/;
739: my $hostname=$1;
740:
741: {
742: while (1) {
743: last if -e $replyfile;
744: sleep 1;
745: }
746: # QUESTION: how should I handle this error condition..
747: # I'm sure there is syntax elsewhere I can use..
748: my $fh=Apache::File->new($replyfile) or
749: ($r->print('file cannot be opened') and return OK);
750: @results=<$fh>;
751: }
752:
753: my $compiledresult='';
754:
755: foreach my $result (@results) {
756: my ($title,$author,$subject,$notes,$abstract,$mime,$lang,
757: $creationdate,$lastrevisiondate,$owner,$copyright
758: )=map {&Apache::lonnet::unescape($_)} (split(/\,/,$result));
759: my $shortabstract=$abstract;
760: $shortabstract=substr($abstract,0,200) if length($abstract)>200;
761: $compiledresult=<<END;
762: <p>
763: <b>Title:</b> $title<br>
764: <b>Author(s):</b> $author<br>
765: <b>Subject:</b> $subject<br>
766: <b>Keyword(s):</b> <i>not available yet</i><br>
767: <b>Notes:</b> $notes<br>
768: <b>Abstract:</b> $shortabstract<br>
769: <b>MIME Type:</b> $mimetag{$mime}<br>
770: <b>Language:</b> $language{$lang}<br>
771: <b>Creation Date:</b> $creationdate<br>
772: <b>Last Revision Date:</b> $lastrevisiondate<br>
773: <b>Publisher/Owner:</b> $owner<br>
774: <b>Copyright/Distribution:</b> $copyright<br>
775: <b>Repository Location:</b> $hostname
776: </p>
777: END
778: }
779:
780: unless ($compiledresult) {
781: $compiledresult="There were no results that matched your query";
782: }
783:
784: # Question... allow to ask question from this page, or click to
785: # search again?
786: $r->print(<<RESULTS);
787: <html>
788: <head>
789: <title>The LearningOnline Network with CAPA</title>
790: </head>
791: <body bgcolor="#ffffff">
792: <img align=right src=/adm/lonIcons/lonlogos.gif>
793: <h1>Search Catalog</h1>
794: <form method="post" action="/adm/searchcat">
795: <hr>
796: <h3>Search Query</h3>
797: <p>
798: $expression
799: </p>
800: <h3>Search Results</h3>
801: $compiledresult
802: </body>
803: </html>
804: RESULTS
805:
806: return OK;
1.3 harris41 807: }
1.1 www 808:
809: 1;
810: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>