[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm lonmeta.pm lonsearchcat.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 01 Jan 2004 20:13:17 -0000
This is a MIME encoded message
--www1072987997
Content-Type: text/plain
www Thu Jan 1 15:13:17 2004 EDT
Modified files:
/loncom/interface lonhtmlcommon.pm lonmeta.pm lonsearchcat.pm
Log:
Cleanup - saving my work
--www1072987997
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20040101151317.txt"
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.37 loncom/interface/lonhtmlcommon.pm:1.38
--- loncom/interface/lonhtmlcommon.pm:1.37 Mon Dec 29 16:17:00 2003
+++ loncom/interface/lonhtmlcommon.pm Thu Jan 1 15:13:17 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.37 2003/12/29 21:17:00 www Exp $
+# $Id: lonhtmlcommon.pm,v 1.38 2004/01/01 20:13:17 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -91,8 +91,9 @@
##############################################
##############################################
sub checkbox {
- my ($name) = @_;
- my $Str = '<input type="checkbox" name="'.$name.'" />';
+ my ($name,$value) = @_;
+ my $Str = '<input type="checkbox" name="'.$name.'"'.
+ ($value?' checked="1"':'').' />';
return $Str;
}
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.53 loncom/interface/lonmeta.pm:1.54
--- loncom/interface/lonmeta.pm:1.53 Wed Dec 31 10:34:32 2003
+++ loncom/interface/lonmeta.pm Thu Jan 1 15:13:17 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.53 2003/12/31 15:34:32 www Exp $
+# $Id: lonmeta.pm,v 1.54 2004/01/01 20:13:17 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -329,8 +329,13 @@
}
# ============================================== Pretty input of metadata field
+sub direct {
+ return shift;
+}
+
sub selectbox {
my ($name,$value,$functionref,@idlist)=@_;
+ unless (defined($functionref)) { $functionref=\&direct; }
my $selout='<select name="'.$name.'">';
foreach (@idlist) {
$selout.='<option value=\''.$_.'\'';
@@ -342,59 +347,77 @@
return $selout.'</select>';
}
+sub relatedfield {
+ my ($show,$relatedsearchflag,$relatedsep,$fieldname,$relatedvalue)=@_;
+ unless ($relatedsearchflag) { return ''; }
+ unless (defined($relatedsep)) { $relatedsep=' '; }
+ unless ($show) { return $relatedsep.' '; }
+ return $relatedsep.'<input type="checkbox" name="'.$fieldname.'_related"'.
+ ($relatedvalue?' checked="1"':'').' />';
+}
sub prettyinput {
- my ($type,$value,$fieldname,$formname)=@_;
+ my ($type,$value,$fieldname,$formname,
+ $relatedsearchflag,$relatedsep,$relatedvalue)=@_;
# Language
if ($type eq 'language') {
return &selectbox($fieldname,
$value,
\&Apache::loncommon::languagedescription,
- (&Apache::loncommon::languageids));
+ (&Apache::loncommon::languageids)).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
}
# Copyright
if ($type eq 'copyright') {
return &selectbox($fieldname,
$value,
\&Apache::loncommon::copyrightdescription,
- (&Apache::loncommon::copyrightids));
+ (&Apache::loncommon::copyrightids)).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
}
# Gradelevels
if (($type eq 'lowestgradelevel') ||
($type eq 'highestgradelevel')) {
- return &Apache::loncommon::select_level_form($value,$fieldname);
+ return &Apache::loncommon::select_level_form($value,$fieldname).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
}
# Obsolete
if ($type eq 'obsolete') {
return '<input type="checkbox" name="'.$fieldname.'"'.
- ($value?' checked="1"':'').' />';
+ ($value?' checked="1"':'').' />'.
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
}
# Obsolete replacement file
if ($type eq 'obsoletereplacement') {
return '<input type="text" name="'.$fieldname.
'" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.
"('".$formname."','".$fieldname."'".
- ",'')\">".&mt('Select').'</a>';
+ ",'')\">".&mt('Select').'</a>'.
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
}
# Customdistribution file
if ($type eq 'customdistributionfile') {
return '<input type="text" name="'.$fieldname.
'" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.
"('".$formname."','".$fieldname."'".
- ",'rights')\">".&mt('Select').'</a>';
+ ",'rights')\">".&mt('Select').'</a>'.
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
}
# Dates
if (($type eq 'creationdate') ||
($type eq 'lastrevisiondate')) {
return &Apache::lonhtmlcommon::date_setter($formname,
- $fieldname,$value);
+ $fieldname,$value).
+ &relatedfield(0,$relatedsearchflag,$relatedsep);
}
# No pretty input found
$value=~s/^\s+//gs;
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
$value=~s/\"/\&quod\;/gs;
- return '<input type="text" name="'.$fieldname.'" size="80" value="'.$value.'" />';
+ return
+ '<input type="text" name="'.$fieldname.'" size="80" value="'.$value.'" />'.
+ &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,$relatedvalue);
}
# ================================================================ Main Handler
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.199 loncom/interface/lonsearchcat.pm:1.200
--- loncom/interface/lonsearchcat.pm:1.199 Sun Dec 28 15:12:59 2003
+++ loncom/interface/lonsearchcat.pm Thu Jan 1 15:13:17 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.199 2003/12/28 20:12:59 www Exp $
+# $Id: lonsearchcat.pm,v 1.200 2004/01/01 20:13:17 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -70,6 +70,8 @@
use GDBM_File;
use Apache::loncommon();
use Apache::lonmysql();
+use Apache::lonmeta;
+use Apache::lonhtmlcommon;
use Apache::lonlocal;
######################################################################
@@ -83,16 +85,14 @@
# groupsearch RAT interface.
my %persistent_db; # gdbm hash which holds data which is supposed to
# 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);
######################################################################
######################################################################
@@ -366,9 +366,9 @@
if ($ENV{'form.crsrelated'}) {
($search_string,@New_Words) = &related_version($ENV{'form.courseexp'});
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 {
- $pretty_search_string .= " with no related words.";
+ $pretty_search_string .= ' '.&mt('with no related words').".";
}
}
my $fulltext=$ENV{'form.crsfulltext'};
@@ -498,15 +498,19 @@
<table>
<tr><td>
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 $domaincheckbox = &simplecheckbox('domains',$domain);
+ my $domaincheckbox = &Apache::lonhtmlcommon::checkbox('domains',
+ $ENV{'form.domains'});
my $srch=&mt('Search');
my $header=&mt('Advanced Search');
my $userelatedwords=&mt('use related words');
my $onlysearchdomain=&mt('only search domain');
+ my $view=&viewoptions();
$scrout.=<<END;
</td><td><a
href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}"
@@ -515,18 +519,11 @@
<td>$domaincheckbox $onlysearchdomain <b>$domain</b></td></tr>
</table>
</p>
+$view
<p>
<input type="submit" name="basicsubmit" value='$srch' />
$closebutton
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;
</p>
</form>
@@ -537,6 +534,8 @@
'srch' => 'Search',
'header' => 'Course Search',
'note' => 'Enter terms or phrases, then press "Search" below',
+ 'use' => 'use related words',
+ 'full' =>'fulltext search (time consuming)'
);
$scrout.=(<<ENDCOURSESEARCH);
<hr />
@@ -552,15 +551,18 @@
<tr><td>
ENDCOURSESEARCH
$scrout.=' '.
- &simpletextfield('courseexp',$ENV{'form.courseexp'},40);
+ &Apache::lonhtmlcommon::textbox('courseexp',
+ $ENV{'form.courseexp'},40);
my $crscheckbox =
- &simplecheckbox('crsfulltext',$ENV{'form.crsfulltext'});
+ &Apache::lonhtmlcommon::checkbox('crsfulltext',
+ $ENV{'form.crsfulltext'});
my $relcheckbox =
- &simplecheckbox('crsrelated',$ENV{'form.crsrelated'});
+ &Apache::lonhtmlcommon::checkbox('crsrelated',
+ $ENV{'form.crsrelated'});
$scrout.=(<<ENDENDCOURSE);
</td></tr>
-<tr><td>$relcheckbox use related words</td><td></td></tr>
-<tr><td>$crscheckbox fulltext search (time consuming)</td><td></td></tr>
+<tr><td>$relcheckbox $lt{'use'}</td><td></td></tr>
+<tr><td>$crscheckbox $lt{'full'}</td><td></td></tr>
</table><p>
<input type="submit" name="coursesubmit" value='$lt{'srch'}' />
</p>
@@ -589,12 +591,15 @@
sub print_advanced_search_form{
my ($r,$closebutton,$hidden_fields) = @_;
+ my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
+ 'reset' => 'Reset',
+ 'help' => 'Help');
my $advanced_buttons = <<"END";
<p>
-<input type="submit" name="advancedsubmit" value='SEARCH' />
-<input type="reset" name="reset" value='RESET' />
+<input type="submit" name="advancedsubmit" value='$lt{"srch"}' />
+<input type="reset" name="reset" value='$lt{"reset"}' />
$closebutton
-<input type="button" value="HELP" onClick="openhelp()" />
+<input type="button" value="$lt{'help'}" onClick="openhelp()" />
</p>
END
if (!defined($ENV{'form.viewselect'})) {
@@ -616,59 +621,46 @@
$bodytag
Enter terms or phrases separated by search operators
such as AND, OR, or NOT.<br />
-<form method="post" action="/adm/searchcat">
+<form method="post" action="/adm/searchcat" name="advsearch">
$advanced_buttons
$hidden_fields
<input type="hidden" name="phase" value="adv_search" />
-<table>
-<tr><td><font color="#800000" face="helvetica"><b>VIEW:</b></font></td>
-<td>
ENDHEADER
- $scrout.=&selectbox(undef,'viewselect',
- $ENV{'form.viewselect'},
- undef,undef,undef,
- sort(keys(%Views)));
- $scrout.=' ';
- $scrout.=&selectbox(undef,'show',
- $ENV{'form.show'},
- undef,undef,undef,
- (10,20,50,100));
- $scrout.=' '.
- '<font color="#800000" face="helvetica">'.&mt('Per Page').'</font>';
- $scrout.="</td><td>".&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";
- $scrout.=&searchphrasefield_with_related('title', 'title' ,
- $ENV{'form.title'});
- $scrout.=&searchphrasefield('author', 'author' ,$ENV{'form.author'});
- $scrout.=&searchphrasefield_with_related('subject', 'subject' ,
- $ENV{'form.subject'});
- $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'});
+ $scrout.=&viewoptions();
+ my %fields=&Apache::lonmeta::fieldnames();
+# set undefined to "any"
+ $ENV{'form.language'}='any' unless length($ENV{'form.language'});
+ $ENV{'form.domains'} = 'any' if (! exists($ENV{'form.domains'}));
+ $ENV{'form.category'}='any' if (! defined($ENV{'form.category'}));
+
+
+ $scrout.='<table>';
+ $scrout.="<tr><th>".&mt('Field').'</th><th>'.&mt('Value').'</th><th>'
+ .&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";
+ foreach ('title','author','keywords','notes','abstract','standards',
+ 'lowestgradelevel','highestgradelevel','mime') {
+ $scrout.='<tr><td>'.&titlefield($fields{$_}).'</td><td>'.
+ &Apache::lonmeta::prettyinput($_,$ENV{'form.'.$_},$_,'advsearch',
+ 1,'</td><td>',$ENV{'form.'.$_.'_related'}).
+ '</td></tr>';
+ }
# Hack - an empty table row.
$scrout.="<tr><td> </td><td> </td><td> </td></tr>\n";
- $scrout.=&searchphrasefield('file<br />extension','extension',
- $ENV{'form.extension'});
- $scrout.="<tr><td> </td><td> </td><td> </td></tr>\n";
- $scrout.=&searchphrasefield('publisher<br />owner','owner',
- $ENV{'form.owner'});
+# $scrout.=&searchphrasefield('file<br />extension','extension',
+# $ENV{'form.extension'});
+# $scrout.="<tr><td> </td><td> </td><td> </td></tr>\n";
+# $scrout.=&searchphrasefield('publisher<br />owner','owner',
+ # $ENV{'form.owner'});
$scrout.="</table>\n";
- $ENV{'form.category'}='any' if (! defined($ENV{'form.category'}));
- $scrout.=&selectbox('File Category','category',
- $ENV{'form.category'},
- 'any','Any category',
- undef,
- (&Apache::loncommon::filecategories()));
- $ENV{'form.language'}='any' unless length($ENV{'form.language'});
+# $scrout.=&Apache::lonmeta::selectbox('File Category','category',
+# $ENV{'form.category'},
+# 'any','Any category',
+# undef,
+# (&Apache::loncommon::filecategories()));
#----------------------------------------------------------------
# Allow restriction to multiple domains.
# 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'}}
: ($ENV{'form.domains'}) );
my %domain_hash = ();
@@ -679,8 +671,7 @@
# adjust the size of the select box
my $size = 4;
$size = (scalar @domains < ($size - 1) ? scalar @domains + 1 : $size);
- $scrout.="\n".'<font color="#800000" face="helvetica"><b>'.
- 'DOMAINS TO BE SEARCHED</b></font><br />'.
+ $scrout.="\n".&titlefield(&mt('Domain to be searched')).
'<select name="domains" size="'.$size.'" multiple>'."\n".
'<option name="any" value="any" '.
($domain_hash{'any'}? 'selected ' :'').
@@ -690,59 +681,7 @@
($domain_hash{$dom} ? 'selected ' :'').">$dom</option>\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
# $scrout.=<<CUSTOMMETADATA;
#<p>
@@ -772,6 +711,82 @@
$r->print($scrout);
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;
+}
######################################################################
######################################################################
@@ -934,288 +949,6 @@
}
######################################################################
-# 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
@@ -1284,7 +1017,7 @@
my $font = '<font color="#800000" face="helvetica">';
# Evaluate logical expression AND/OR/NOT phrase fields.
foreach my $field ('title','author','subject','notes','abstract','url',
- 'keywords','version','owner') {
+ 'keywords','version','owner','standards') {
if ($ENV{'form.'.$field}) {
my $searchphrase = $ENV{'form.'.$field};
$pretty_search_string .= $font."$field</font> contains <b>".
@@ -2527,48 +2260,12 @@
###########################################################
sub parse_raw_result {
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
my %Fields=&Apache::lonmeta::metadata_col_to_hash(
map {
&Apache::lonnet::unescape($_);
} (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;
}
--www1072987997--