version 1.199, 2003/12/28 20:12:59
|
version 1.200, 2004/01/01 20:13:17
|
Line 70 use Text::Query;
|
Line 70 use Text::Query;
|
use GDBM_File; |
use GDBM_File; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonmysql(); |
use Apache::lonmysql(); |
|
use Apache::lonmeta; |
|
use Apache::lonhtmlcommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
|
###################################################################### |
###################################################################### |
Line 83 my %groupsearch_db; # Database hash use
|
Line 85 my %groupsearch_db; # Database hash use
|
# groupsearch RAT interface. |
# groupsearch RAT interface. |
my %persistent_db; # gdbm hash which holds data which is supposed to |
my %persistent_db; # gdbm hash which holds data which is supposed to |
# persist across calls to lonsearchcat.pm |
# persist across calls to lonsearchcat.pm |
## %Views: |
|
## Hash which associates an output view description with the function |
|
## that produces it. |
|
# View Description/Name Function Pointer |
|
my %Views = ("Detailed Citation View" => \&detailed_citation_view, |
|
"Summary View" => \&summary_view, |
|
"Fielded Format" => \&fielded_format_view, |
|
"XML/SGML" => \&xml_sgml_view, |
|
"Compact View" => \&compact_view); |
|
|
|
|
# The different view modes and associated functions |
|
|
|
my %Views = ("detailed" => \&detailed_citation_view, |
|
"summary" => \&summary_view, |
|
"fielded" => \&fielded_format_view, |
|
"xml" => \&xml_sgml_view, |
|
"compact" => \&compact_view); |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 366 sub course_search {
|
Line 366 sub course_search {
|
if ($ENV{'form.crsrelated'}) { |
if ($ENV{'form.crsrelated'}) { |
($search_string,@New_Words) = &related_version($ENV{'form.courseexp'}); |
($search_string,@New_Words) = &related_version($ENV{'form.courseexp'}); |
if (@New_Words) { |
if (@New_Words) { |
$pretty_search_string .= " with related words: <b>@New_Words</b>."; |
$pretty_search_string .= ' '.&mt("with related words").": <b>@New_Words</b>."; |
} else { |
} else { |
$pretty_search_string .= " with no related words."; |
$pretty_search_string .= ' '.&mt('with no related words')."."; |
} |
} |
} |
} |
my $fulltext=$ENV{'form.crsfulltext'}; |
my $fulltext=$ENV{'form.crsfulltext'}; |
Line 498 $Statement.
|
Line 498 $Statement.
|
<table> |
<table> |
<tr><td> |
<tr><td> |
ENDDOCUMENT |
ENDDOCUMENT |
$scrout.=' '.&simpletextfield('basicexp',$ENV{'form.basicexp'},40). |
$scrout.=' '.&Apache::lonhtmlcommon::textbox('basicexp', |
|
$ENV{'form.basicexp'},40). |
' '; |
' '; |
my $relatedcheckbox = &simplecheckbox('related','related',$ENV{'form.related'}); |
my $relatedcheckbox = &Apache::lonhtmlcommon::checkbox('related', |
|
$ENV{'form.related'}); |
my $domain = $r->dir_config('lonDefDomain'); |
my $domain = $r->dir_config('lonDefDomain'); |
my $domaincheckbox = &simplecheckbox('domains',$domain); |
my $domaincheckbox = &Apache::lonhtmlcommon::checkbox('domains', |
|
$ENV{'form.domains'}); |
my $srch=&mt('Search'); |
my $srch=&mt('Search'); |
my $header=&mt('Advanced Search'); |
my $header=&mt('Advanced Search'); |
my $userelatedwords=&mt('use related words'); |
my $userelatedwords=&mt('use related words'); |
my $onlysearchdomain=&mt('only search domain'); |
my $onlysearchdomain=&mt('only search domain'); |
|
my $view=&viewoptions(); |
$scrout.=<<END; |
$scrout.=<<END; |
</td><td><a |
</td><td><a |
href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}" |
href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}" |
Line 515 href="/adm/searchcat?phase=disp_adv&cata
|
Line 519 href="/adm/searchcat?phase=disp_adv&cata
|
<td>$domaincheckbox $onlysearchdomain <b>$domain</b></td></tr> |
<td>$domaincheckbox $onlysearchdomain <b>$domain</b></td></tr> |
</table> |
</table> |
</p> |
</p> |
|
$view |
<p> |
<p> |
<input type="submit" name="basicsubmit" value='$srch' /> |
<input type="submit" name="basicsubmit" value='$srch' /> |
$closebutton |
$closebutton |
END |
END |
$scrout.=&selectbox('View','viewselect', |
|
$ENV{'form.viewselect'}, |
|
undef,undef,undef, |
|
sort(keys(%Views))); |
|
$scrout.=&selectbox('Per Page','show', |
|
$ENV{'form.show'}, |
|
undef,undef,undef, |
|
(10,20,50,100)); |
|
$scrout.=<<ENDDOCUMENT; |
$scrout.=<<ENDDOCUMENT; |
</p> |
</p> |
</form> |
</form> |
Line 537 ENDDOCUMENT
|
Line 534 ENDDOCUMENT
|
'srch' => 'Search', |
'srch' => 'Search', |
'header' => 'Course Search', |
'header' => 'Course Search', |
'note' => 'Enter terms or phrases, then press "Search" below', |
'note' => 'Enter terms or phrases, then press "Search" below', |
|
'use' => 'use related words', |
|
'full' =>'fulltext search (time consuming)' |
); |
); |
$scrout.=(<<ENDCOURSESEARCH); |
$scrout.=(<<ENDCOURSESEARCH); |
<hr /> |
<hr /> |
Line 552 $lt{'note'}.
|
Line 551 $lt{'note'}.
|
<tr><td> |
<tr><td> |
ENDCOURSESEARCH |
ENDCOURSESEARCH |
$scrout.=' '. |
$scrout.=' '. |
&simpletextfield('courseexp',$ENV{'form.courseexp'},40); |
&Apache::lonhtmlcommon::textbox('courseexp', |
|
$ENV{'form.courseexp'},40); |
my $crscheckbox = |
my $crscheckbox = |
&simplecheckbox('crsfulltext',$ENV{'form.crsfulltext'}); |
&Apache::lonhtmlcommon::checkbox('crsfulltext', |
|
$ENV{'form.crsfulltext'}); |
my $relcheckbox = |
my $relcheckbox = |
&simplecheckbox('crsrelated',$ENV{'form.crsrelated'}); |
&Apache::lonhtmlcommon::checkbox('crsrelated', |
|
$ENV{'form.crsrelated'}); |
$scrout.=(<<ENDENDCOURSE); |
$scrout.=(<<ENDENDCOURSE); |
</td></tr> |
</td></tr> |
<tr><td>$relcheckbox use related words</td><td></td></tr> |
<tr><td>$relcheckbox $lt{'use'}</td><td></td></tr> |
<tr><td>$crscheckbox fulltext search (time consuming)</td><td></td></tr> |
<tr><td>$crscheckbox $lt{'full'}</td><td></td></tr> |
</table><p> |
</table><p> |
<input type="submit" name="coursesubmit" value='$lt{'srch'}' /> |
<input type="submit" name="coursesubmit" value='$lt{'srch'}' /> |
</p> |
</p> |
Line 589 Returns a scalar which holds html for th
|
Line 591 Returns a scalar which holds html for th
|
|
|
sub print_advanced_search_form{ |
sub print_advanced_search_form{ |
my ($r,$closebutton,$hidden_fields) = @_; |
my ($r,$closebutton,$hidden_fields) = @_; |
|
my %lt=&Apache::lonlocal::texthash('srch' => 'Search', |
|
'reset' => 'Reset', |
|
'help' => 'Help'); |
my $advanced_buttons = <<"END"; |
my $advanced_buttons = <<"END"; |
<p> |
<p> |
<input type="submit" name="advancedsubmit" value='SEARCH' /> |
<input type="submit" name="advancedsubmit" value='$lt{"srch"}' /> |
<input type="reset" name="reset" value='RESET' /> |
<input type="reset" name="reset" value='$lt{"reset"}' /> |
$closebutton |
$closebutton |
<input type="button" value="HELP" onClick="openhelp()" /> |
<input type="button" value="$lt{'help'}" onClick="openhelp()" /> |
</p> |
</p> |
END |
END |
if (!defined($ENV{'form.viewselect'})) { |
if (!defined($ENV{'form.viewselect'})) { |
Line 616 END
|
Line 621 END
|
$bodytag |
$bodytag |
Enter terms or phrases separated by search operators |
Enter terms or phrases separated by search operators |
such as AND, OR, or NOT.<br /> |
such as AND, OR, or NOT.<br /> |
<form method="post" action="/adm/searchcat"> |
<form method="post" action="/adm/searchcat" name="advsearch"> |
$advanced_buttons |
$advanced_buttons |
$hidden_fields |
$hidden_fields |
<input type="hidden" name="phase" value="adv_search" /> |
<input type="hidden" name="phase" value="adv_search" /> |
<table> |
|
<tr><td><font color="#800000" face="helvetica"><b>VIEW:</b></font></td> |
|
<td> |
|
ENDHEADER |
ENDHEADER |
$scrout.=&selectbox(undef,'viewselect', |
$scrout.=&viewoptions(); |
$ENV{'form.viewselect'}, |
my %fields=&Apache::lonmeta::fieldnames(); |
undef,undef,undef, |
# set undefined to "any" |
sort(keys(%Views))); |
$ENV{'form.language'}='any' unless length($ENV{'form.language'}); |
$scrout.=' '; |
$ENV{'form.domains'} = 'any' if (! exists($ENV{'form.domains'})); |
$scrout.=&selectbox(undef,'show', |
$ENV{'form.category'}='any' if (! defined($ENV{'form.category'})); |
$ENV{'form.show'}, |
|
undef,undef,undef, |
|
(10,20,50,100)); |
$scrout.='<table>'; |
$scrout.=' '. |
$scrout.="<tr><th>".&mt('Field').'</th><th>'.&mt('Value').'</th><th>' |
'<font color="#800000" face="helvetica">'.&mt('Per Page').'</font>'; |
.&mt('Related').'<br />'.&mt('Words')."</td></tr>\n"; |
$scrout.="</td><td>".&mt('Related').'<br />'.&mt('Words')."</td></tr>\n"; |
foreach ('title','author','keywords','notes','abstract','standards', |
$scrout.=&searchphrasefield_with_related('title', 'title' , |
'lowestgradelevel','highestgradelevel','mime') { |
$ENV{'form.title'}); |
$scrout.='<tr><td>'.&titlefield($fields{$_}).'</td><td>'. |
$scrout.=&searchphrasefield('author', 'author' ,$ENV{'form.author'}); |
&Apache::lonmeta::prettyinput($_,$ENV{'form.'.$_},$_,'advsearch', |
$scrout.=&searchphrasefield_with_related('subject', 'subject' , |
1,'</td><td>',$ENV{'form.'.$_.'_related'}). |
$ENV{'form.subject'}); |
'</td></tr>'; |
$scrout.=&searchphrasefield_with_related('keywords','keywords', |
} |
$ENV{'form.keywords'}); |
|
$scrout.=&searchphrasefield('URL', 'url' ,$ENV{'form.url'}); |
|
$scrout.=&searchphrasefield_with_related('notes', 'notes' , |
|
$ENV{'form.notes'}); |
|
$scrout.=&searchphrasefield_with_related('abstract','abstract', |
|
$ENV{'form.abstract'}); |
|
$scrout.=&searchphrasefield('Standards','standards',$ENV{'form.standards'}); |
|
# Hack - an empty table row. |
# Hack - an empty table row. |
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
$scrout.=&searchphrasefield('file<br />extension','extension', |
# $scrout.=&searchphrasefield('file<br />extension','extension', |
$ENV{'form.extension'}); |
# $ENV{'form.extension'}); |
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
# $scrout.="<tr><td> </td><td> </td><td> </td></tr>\n"; |
$scrout.=&searchphrasefield('publisher<br />owner','owner', |
# $scrout.=&searchphrasefield('publisher<br />owner','owner', |
$ENV{'form.owner'}); |
# $ENV{'form.owner'}); |
$scrout.="</table>\n"; |
$scrout.="</table>\n"; |
$ENV{'form.category'}='any' if (! defined($ENV{'form.category'})); |
# $scrout.=&Apache::lonmeta::selectbox('File Category','category', |
$scrout.=&selectbox('File Category','category', |
# $ENV{'form.category'}, |
$ENV{'form.category'}, |
# 'any','Any category', |
'any','Any category', |
# undef, |
undef, |
# (&Apache::loncommon::filecategories())); |
(&Apache::loncommon::filecategories())); |
|
$ENV{'form.language'}='any' unless length($ENV{'form.language'}); |
|
#---------------------------------------------------------------- |
#---------------------------------------------------------------- |
# Allow restriction to multiple domains. |
# Allow restriction to multiple domains. |
# I make the crazy assumption that there will never be a domain 'any'. |
# I make the crazy assumption that there will never be a domain 'any'. |
# |
# |
$ENV{'form.domains'} = 'any' if (! exists($ENV{'form.domains'})); |
|
my @allowed_domains = (ref($ENV{'form.domains'}) ? @{$ENV{'form.domains'}} |
my @allowed_domains = (ref($ENV{'form.domains'}) ? @{$ENV{'form.domains'}} |
: ($ENV{'form.domains'}) ); |
: ($ENV{'form.domains'}) ); |
my %domain_hash = (); |
my %domain_hash = (); |
Line 679 ENDHEADER
|
Line 671 ENDHEADER
|
# adjust the size of the select box |
# adjust the size of the select box |
my $size = 4; |
my $size = 4; |
$size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size); |
$size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size); |
$scrout.="\n".'<font color="#800000" face="helvetica"><b>'. |
$scrout.="\n".&titlefield(&mt('Domain to be searched')). |
'DOMAINS TO BE SEARCHED</b></font><br />'. |
|
'<select name="domains" size="'.$size.'" multiple>'."\n". |
'<select name="domains" size="'.$size.'" multiple>'."\n". |
'<option name="any" value="any" '. |
'<option name="any" value="any" '. |
($domain_hash{'any'}? 'selected ' :''). |
($domain_hash{'any'}? 'selected ' :''). |
Line 690 ENDHEADER
|
Line 681 ENDHEADER
|
($domain_hash{$dom} ? 'selected ' :'').">$dom</option>\n"; |
($domain_hash{$dom} ? 'selected ' :'').">$dom</option>\n"; |
} |
} |
$scrout.="</select>\n"; |
$scrout.="</select>\n"; |
#---------------------------------------------------------------- |
|
$scrout.=&selectbox('Limit by language','language', |
|
$ENV{'form.language'},'any','Any Language', |
|
\&Apache::loncommon::languagedescription, |
|
(&Apache::loncommon::languageids), |
|
); |
|
# ------------------------------------------------ Compute date selection boxes |
|
$scrout.=<<CREATIONDATESTART; |
|
<p> |
|
<font color="#800000" face="helvetica"><b>LIMIT BY CREATION DATE RANGE:</b> |
|
</font> |
|
<br /> |
|
between: |
|
CREATIONDATESTART |
|
$scrout.=&dateboxes('creationdatestart',1,1,1976, |
|
$ENV{'form.creationdatestart_month'}, |
|
$ENV{'form.creationdatestart_day'}, |
|
$ENV{'form.creationdatestart_year'}, |
|
); |
|
$scrout.="and:\n"; |
|
$scrout.=&dateboxes('creationdateend',12,31,2051, |
|
$ENV{'form.creationdateend_month'}, |
|
$ENV{'form.creationdateend_day'}, |
|
$ENV{'form.creationdateend_year'}, |
|
); |
|
$scrout.="</p>"; |
|
$scrout.=<<LASTREVISIONDATESTART; |
|
<p> |
|
<font color="#800000" face="helvetica"><b>LIMIT BY LAST REVISION DATE RANGE: |
|
</b></font> |
|
<br />between: |
|
LASTREVISIONDATESTART |
|
$scrout.=&dateboxes('lastrevisiondatestart',1,1,1976, |
|
$ENV{'form.lastrevisiondatestart_month'}, |
|
$ENV{'form.lastrevisiondatestart_day'}, |
|
$ENV{'form.lastrevisiondatestart_year'}, |
|
); |
|
$scrout.=<<LASTREVISIONDATEEND; |
|
and: |
|
LASTREVISIONDATEEND |
|
$scrout.=&dateboxes('lastrevisiondateend',12,31,2051, |
|
$ENV{'form.lastrevisiondateend_month'}, |
|
$ENV{'form.lastrevisiondateend_day'}, |
|
$ENV{'form.lastrevisiondateend_year'}, |
|
); |
|
$scrout.='</p>'; |
|
$ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'}); |
|
$scrout.=&selectbox('Limit by copyright/distribution','copyright', |
|
$ENV{'form.copyright'}, |
|
'any','Any copyright/distribution', |
|
\&Apache::loncommon::copyrightdescription, |
|
(&Apache::loncommon::copyrightids), |
|
); |
|
# ------------------------------------------- Compute customized metadata field |
# ------------------------------------------- Compute customized metadata field |
# $scrout.=<<CUSTOMMETADATA; |
# $scrout.=<<CUSTOMMETADATA; |
#<p> |
#<p> |
Line 772 ENDDOCUMENT
|
Line 711 ENDDOCUMENT
|
$r->print($scrout); |
$r->print($scrout); |
return; |
return; |
} |
} |
|
###################################################################### |
|
###################################################################### |
|
|
|
=pod |
|
|
|
=item &titlefield |
|
|
|
Inputs: title text |
|
|
|
Outputs: titletext with font wrapper |
|
|
|
=cut |
|
|
|
###################################################################### |
|
###################################################################### |
|
|
|
sub titlefield { |
|
my $title=shift; |
|
return '<font face="arial" color="#800000">'.$title.'</font>'; |
|
} |
|
###################################################################### |
|
###################################################################### |
|
|
|
=pod |
|
|
|
=item viewoptiontext |
|
|
|
Inputs: codename for view option |
|
|
|
Outputs: displayed text |
|
|
|
=cut |
|
|
|
###################################################################### |
|
###################################################################### |
|
|
|
sub viewoptiontext { |
|
my $code=shift; |
|
my %desc=&Apache::lonlocal::texthash('detailed' => "Detailed Citation View", |
|
'xml' => 'XML/SGML', |
|
'compact' => 'Compact View', |
|
'fielded' => 'Fielded Format', |
|
'summary' => 'Summary View'); |
|
return $desc{$code}; |
|
} |
|
###################################################################### |
|
|
|
=pod |
|
|
|
=item viewoptions |
|
|
|
Inputs: none |
|
|
|
Outputs: text for box with view options |
|
|
|
=cut |
|
|
|
###################################################################### |
|
###################################################################### |
|
|
|
sub viewoptions { |
|
my $scrout="\n\n".'<table bgcolor="#FFFFBB"><tr><th>'.&mt('View Options').'</th><th>'. |
|
&mt('Records per Page').'</th></tr><tr><td>'; |
|
unless ($ENV{'form.viewselect'}) { $ENV{'form.viewselect'}='detailed'; } |
|
$scrout.=&Apache::lonmeta::selectbox('viewselect', |
|
$ENV{'form.viewselect'}, |
|
\&viewoptiontext, |
|
sort(keys(%Views))); |
|
$scrout.='</td><td>'; |
|
$scrout.=&Apache::lonmeta::selectbox('show', |
|
$ENV{'form.show'}, |
|
undef, |
|
(10,20,50,100,1000,10000)); |
|
$scrout.="</td></tr></table>\n\n"; |
|
return $scrout; |
|
} |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
Line 934 sub make_form_data_persistent {
|
Line 949 sub make_form_data_persistent {
|
} |
} |
|
|
###################################################################### |
###################################################################### |
# HTML form building functions # |
|
###################################################################### |
|
|
|
=pod |
|
|
|
=item HTML form building functions |
|
|
|
=over 4 |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &simpletextfield() |
|
|
|
Inputs: $name,$value,$size |
|
|
|
Returns a text input field with the given name, value, and size. |
|
If size is not specified, a value of 20 is used. |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
|
sub simpletextfield { |
|
my ($name,$value,$size)=@_; |
|
$size = 20 if (! defined($size)); |
|
return '<input type="text" name="'.$name. |
|
'" size="'.$size.'" value="'.$value.'" />'; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &simplecheckbox() |
|
|
|
Inputs: $name,$value,$checked |
|
|
|
Returns a simple check box with the given $name. |
|
If $value eq 'on' the box is checked. |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
|
sub simplecheckbox{ |
|
my ($name,$value,$checked)=@_; |
|
$checked="checked" if ($value eq $checked || $value eq 'on'); |
|
return '<input type="checkbox" name="'.$name.'" value="'.$value.'" '. |
|
$checked.' />'; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &fieldtitle() |
|
|
|
Input: $title |
|
|
|
Returns a scalar with html which will display $title as a search |
|
field heading. |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
|
sub fieldtitle { |
|
my $title = uc(&mt(shift())); |
|
return '<font color="#800000" face="helvetica"><b>'.$title. |
|
': </b></font>'; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &searchphrasefield() |
|
|
|
Inputs: $title,$name,$value |
|
|
|
Returns html for a title line and an input field for entering search terms. |
|
The entry field (which is where the $name and $value are used) is a 50 column |
|
simpletextfield. The html returned is for a row in a three column table. |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
|
sub searchphrasefield { |
|
my ($title,$name,$value)=@_; |
|
return '<tr><td>'.&fieldtitle($title).'</td><td>'. |
|
&simpletextfield($name,$value,50)."</td><td> </td></tr>\n"; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &searchphrasefield_with_related() |
|
|
|
Inputs: $title,$name,$value |
|
|
|
Returns html for a title line and an input field for entering search terms |
|
and a check box for 'related words'. The entry field (which is where the |
|
$name and $value are used) is a 50 column simpletextfield. The name of |
|
the related words checkbox is "$name_related". |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
|
sub searchphrasefield_with_related { |
|
my ($title,$name,$value)=@_; |
|
return '<tr><td>'.&fieldtitle($title).'</td><td>'. |
|
&simpletextfield($name,$value,50).'</td><td align="center"> '. |
|
&simplecheckbox($name.'_related',$ENV{'form.'.$name.'_related'}). |
|
" </td></tr>\n"; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &dateboxes() |
|
|
|
Returns html selection form elements for the specification of |
|
the day, month, and year. |
|
|
|
=cut |
|
|
|
############################################### |
|
############################################### |
|
|
|
sub dateboxes { |
|
my ($name,$defaultmonth,$defaultday,$defaultyear, |
|
$currentmonth,$currentday,$currentyear)=@_; |
|
($defaultmonth,$defaultday,$defaultyear)=('','',''); |
|
# |
|
# Day |
|
my $day=<<END; |
|
<select name="${name}_day"> |
|
<option value='$defaultday'> </option> |
|
END |
|
for (my $i = 1; $i<=31; $i++) { |
|
$day.="<option value=\"$i\">$i</option>\n"; |
|
} |
|
$day.="</select>\n"; |
|
$day=~s/(\"$currentday\")/$1 SELECTED/ if length($currentday); |
|
# |
|
# Month |
|
my $month=<<END; |
|
<select name="${name}_month"> |
|
<option value='$defaultmonth'> </option> |
|
END |
|
my $i = 1; |
|
foreach (qw/January February March April May June |
|
July August September October November December /){ |
|
$month .="<option value=\"$i\">".&mt($_)."</option>\n"; |
|
$i++; |
|
} |
|
$month.="</select>\n"; |
|
$month=~s/(\"$currentmonth\")/$1 SELECTED/ if length($currentmonth); |
|
# |
|
# Year (obviously) |
|
my $year=<<END; |
|
<select name="${name}_year"> |
|
<option value='$defaultyear'> </option> |
|
END |
|
my $maxyear = 2051; |
|
for (my $i = 1976; $i<=$maxyear; $i++) { |
|
$year.="<option value=\"$i\">$i</option>\n"; |
|
} |
|
$year.="</select>\n"; |
|
$year=~s/(\"$currentyear\")/$1 SELECTED/ if length($currentyear); |
|
return "$month$day$year"; |
|
} |
|
|
|
############################################### |
|
############################################### |
|
|
|
=pod |
|
|
|
=item &selectbox() |
|
|
|
Returns a scalar containing an html <select> form. |
|
|
|
Inputs: |
|
|
|
=over 4 |
|
|
|
=item $title |
|
|
|
Printed above the select box, in uppercase. If undefined, only a select |
|
box will be returned, with no additional html. |
|
|
|
=item $name |
|
|
|
The name element of the <select> tag. |
|
|
|
=item $default |
|
|
|
The default value of the form. Can be $anyvalue, or in @idlist. |
|
|
|
=item $anyvalue |
|
|
|
The <option value="..."> used to indicate a default of |
|
none of the values. Can be undef. |
|
|
|
=item $anytag |
|
|
|
The text associate with $anyvalue above. |
|
|
|
=item $functionref |
|
|
|
Each element in @idlist will be passed as a parameter |
|
to the function referenced here. The return value of the function should |
|
be a scalar description of the items. If this value is undefined the |
|
description of each item in @idlist will be the item name. |
|
|
|
=item @idlist |
|
|
|
The items to be selected from. One of these or $anyvalue will be the |
|
value returned by the form element, $ENV{form.$name}. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
############################################### |
|
|
|
sub selectbox { |
|
my ($title,$name,$default,$anyvalue,$anytag,$functionref,@idlist)=@_; |
|
if (! defined($functionref)) { $functionref = sub { $_[0]}; } |
|
my $selout=''; |
|
$title=&mt($title); |
|
if (defined($title)) { |
|
my $uctitle=uc($title); |
|
$selout="\n".'<p><font color="#800000" face="helvetica">'. |
|
'<b>'.$uctitle.': </b></font>'; |
|
} |
|
$selout .= '<select name="'.$name.'">'; |
|
unshift @idlist,$anyvalue if (defined($anyvalue)); |
|
foreach (@idlist) { |
|
$selout.='<option value="'.$_.'"'; |
|
if ($_ eq $default and !/^any$/) { |
|
$selout.=' selected >'.&mt(&{$functionref}($_)).'</option>'; |
|
} |
|
elsif ($_ eq $default and /^$anyvalue$/) { |
|
$selout.=' selected >'.&mt($anytag).'</option>'; |
|
} |
|
else {$selout.='>'.&mt(&{$functionref}($_)).'</option>';} |
|
} |
|
return $selout.'</select>'.(defined($title)?'</p>':' '); |
|
} |
|
|
|
###################################################################### |
|
# End of HTML form building functions # |
|
###################################################################### |
|
|
|
=pod |
|
|
|
=back |
|
|
|
=cut |
|
|
|
|
|
###################################################################### |
|
###################################################################### |
###################################################################### |
|
|
=pod |
=pod |
Line 1284 sub parse_advanced_search {
|
Line 1017 sub parse_advanced_search {
|
my $font = '<font color="#800000" face="helvetica">'; |
my $font = '<font color="#800000" face="helvetica">'; |
# Evaluate logical expression AND/OR/NOT phrase fields. |
# Evaluate logical expression AND/OR/NOT phrase fields. |
foreach my $field ('title','author','subject','notes','abstract','url', |
foreach my $field ('title','author','subject','notes','abstract','url', |
'keywords','version','owner') { |
'keywords','version','owner','standards') { |
if ($ENV{'form.'.$field}) { |
if ($ENV{'form.'.$field}) { |
my $searchphrase = $ENV{'form.'.$field}; |
my $searchphrase = $ENV{'form.'.$field}; |
$pretty_search_string .= $font."$field</font> contains <b>". |
$pretty_search_string .= $font."$field</font> contains <b>". |
Line 2527 The 'title' field is set to "Untitled" i
|
Line 2260 The 'title' field is set to "Untitled" i
|
########################################################### |
########################################################### |
sub parse_raw_result { |
sub parse_raw_result { |
my ($result,$hostname) = @_; |
my ($result,$hostname) = @_; |
# Check for a comma - if it is there then we do not need to unescape the |
|
# string. There seems to be some kind of problem with some items in |
|
# the database - the entire string gets sent out unescaped...? |
|
# unless ($result =~ /,/) { |
|
# $result = &Apache::lonnet::unescape($result); |
|
# } |
|
# conclude from self to others regarding fields |
# conclude from self to others regarding fields |
my %Fields=&Apache::lonmeta::metadata_col_to_hash( |
my %Fields=&Apache::lonmeta::metadata_col_to_hash( |
map { |
map { |
&Apache::lonnet::unescape($_); |
&Apache::lonnet::unescape($_); |
} (split(/\,/,$result)) |
} (split(/\,/,$result)) |
); |
); |
# prettier display |
|
$Fields{'language'} = |
|
&Apache::loncommon::languagedescription($Fields{'language'}); |
|
$Fields{'copyrighttag'} = |
|
&Apache::loncommon::copyrightdescription($Fields{'copyright'}); |
|
$Fields{'mimetag'} = |
|
&Apache::loncommon::filedescription($Fields{'mime'}); |
|
if ($Fields{'author'}=~/^(\s*|error)$/) { |
|
$Fields{'author'}="Unknown Author"; |
|
} |
|
# Put spaces in the keyword list, if needed. |
|
$Fields{'keywords'}=~ s/,([A-z])/, $1/g; |
|
if ($Fields{'title'}=~ /^\s*$/ ) { |
|
$Fields{'title'}='Untitled'; |
|
} |
|
unless ($ENV{'user.adv'}) { |
|
# do not show descriptive information to non-advanced users |
|
$Fields{'keywords'} = '- not displayed -'; |
|
$Fields{'notes'} = '- not displayed -'; |
|
$Fields{'abstract'} = '- not displayed -'; |
|
$Fields{'subject'} = '- not displayed -'; |
|
} |
|
if (length($Fields{'abstract'})>200) { |
|
$Fields{'abstract'} = |
|
substr($Fields{'abstract'},0,200).'...'; |
|
} |
|
if (length($Fields{'keywords'})>200) { |
|
$Fields{'keywords'} = |
|
substr($Fields{'keywords'},0,200).'...'; |
|
} |
|
return %Fields; |
return %Fields; |
} |
} |
|
|