[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 05 May 2004 17:29:06 -0000
This is a MIME encoded message
--matthew1083778146
Content-Type: text/plain
matthew Wed May 5 13:29:06 2004 EDT
Modified files:
/loncom/interface lonsearchcat.pm
Log:
&display_results now uses buttons instead of links for prev/refresh/next,
allows setting of the number of items to display and the output mode
(compact/detailed/xml/fielded/whatever).
Modified &compact_view and &detailed_citation_view.
Modified &prev_next_buttons to produce buttons instead of links.
--matthew1083778146
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20040505132906.txt"
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.222 loncom/interface/lonsearchcat.pm:1.223
--- loncom/interface/lonsearchcat.pm:1.222 Wed May 5 10:14:10 2004
+++ loncom/interface/lonsearchcat.pm Wed May 5 13:29:06 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.222 2004/05/05 14:14:10 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.223 2004/05/05 17:29:06 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -231,24 +231,19 @@
$hidden_fields = '<input type="hidden" name="persistent_db_id" value="'.
$ENV{'form.persistent_db_id'}.'" />'."\n";
if (exists($ENV{'form.catalogmode'})) {
- $hidden_fields .= '<input type="hidden" name="catalogmode" value="'.
- $ENV{'form.catalogmode'}.'" />'."\n";
+ $hidden_fields .= &hidden_field('catalogmode');
}
if (exists($ENV{'form.form'})) {
- $hidden_fields .= '<input type="hidden" name="form" value="'.
- $ENV{'form.form'}.'" />'."\n";
+ $hidden_fields .= &hidden_field('form');
}
if (exists($ENV{'form.element'})) {
- $hidden_fields .= '<input type="hidden" name="element" value="'.
- $ENV{'form.element'}.'" />'."\n";
+ $hidden_fields .= &hidden_field('element');
}
if (exists($ENV{'form.titleelement'})) {
- $hidden_fields .= '<input type="hidden" name="titleelement" value="'.
- $ENV{'form.titleelement'}.'" />'."\n";
+ $hidden_fields .= &hidden_field('titleelement');
}
if (exists($ENV{'form.mode'})) {
- $hidden_fields .= '<input type="hidden" name="mode" value="'.
- $ENV{'form.mode'}.'" />'."\n";
+ $hidden_fields .= &hidden_field('mode');
}
##
## Configure dynamic components of interface
@@ -422,6 +417,14 @@
}
}
+sub hidden_field {
+ my ($name,$value) = @_;
+ if (! defined($value)) {
+ $value = $ENV{'form.'.$name};
+ }
+ return '<input type="hidden" name="'.$name.'" value="'.$value.'" />'.$/;
+}
+
######################################################################
######################################################################
##
@@ -616,7 +619,8 @@
'<font size="-1">'.
'<input type="submit" name="basicsubmit" '.
'value="'.&mt('Search').'" />'.
- (' 'x2).$closebutton.(' 'x2).&viewoptions().
+ (' 'x2).$closebutton.(' 'x2).
+ &viewoptions().
'</font>'.
'</td></tr>'.$/;
$scrout .= '</table>'.$/.'</center>'.'</form>';
@@ -959,7 +963,7 @@
######################################################################
######################################################################
sub viewoptions {
- my $scrout="\n".'<nobr>';
+ my $scrout;
if (! defined($ENV{'form.viewselect'})) {
$ENV{'form.viewselect'}='detailed';
}
@@ -2308,32 +2312,16 @@
my ($current_min,$show,$total,$parms) = @_;
return '' if ($show eq 'all'); # No links if you get them all at once.
#
- # Create links
- my $prev_min = $current_min - $show;
- $prev_min = 1 if $prev_min < 1;
- my $prevlink =
- qq{<a href="/adm/searchcat?$parms&start=$prev_min&show=$show">};
- #
- my $next_min = $current_min + $show;
- $next_min = $current_min if ($next_min > $total);
- my $nextlink =
- qq{<a href="/adm/searchcat?$parms&start=$next_min&show=$show">};
- my $reloadlink =
- qq{<a href="/adm/searchcat?$parms&start=$current_min&$show=$show">};
- #
- # Determine which parameters to pass
- my $String = '[_1]prev[_2] [_3]reload[_4] [_5]next[_6]';
- if ($prev_min == $current_min) {
- $String =~ s:\[_[12]\]::g;
- }
- if ($next_min == $current_min) {
- $String =~ s:\[_[56]\]::g;
- }
- my $links = &mt($String,
- $prevlink, '</a>',
- $reloadlink,'</a>',
- $nextlink, '</a>');
- return $links;
+ # Create buttons
+ my $buttons = '<input type="submit" name="prev" value="'.&mt('Prev').'" ';
+ $buttons .= '/>';
+ $buttons .= ' 'x3;
+ $buttons .= '<input type="submit" name="reload" '.
+ 'value="'.&mt('Reload').'" />';
+ $buttons .= ' 'x3;
+ $buttons .= '<input type="submit" name="next" value="'.&mt('Next').'" ';
+ $buttons .= '/>';
+ return $buttons;
}
######################################################################
@@ -2396,8 +2384,15 @@
}
##
## Determine how many results we need to get
- $ENV{'form.start'} = 1 if (! exists($ENV{'form.start'}));
- $ENV{'form.show'} = 'all' if (! exists($ENV{'form.show'}));
+ $ENV{'form.start'} = 1 if (! exists($ENV{'form.start'}));
+ $ENV{'form.show'} = 20 if (! exists($ENV{'form.show'}));
+ if (exists($ENV{'form.prev'})) {
+ $ENV{'form.start'} -= $ENV{'form.show'};
+ } elsif (exists($ENV{'form.next'})) {
+ $ENV{'form.start'} += $ENV{'form.show'};
+ }
+ $ENV{'form.start'} = 1 if ($ENV{'form.start'}<1);
+ $ENV{'form.start'} = $total_results if ($ENV{'form.start'}>$total_results);
my $min = $ENV{'form.start'};
my $max;
if ($ENV{'form.show'} eq 'all') {
@@ -2407,14 +2402,19 @@
$max = $total_results if ($max > $total_results);
}
##
+ ## Output form elements
+ $r->print(&hidden_field('table').
+ &hidden_field('phase').
+ &hidden_field('persistent_db_id').
+ &hidden_field('start')
+ );
+ ##
## Output links (if necessary) for 'prev' and 'next' pages.
$r->print
- ('<center>'.
- &prev_next_buttons($min,$ENV{'form.show'},$total_results,
- "table=".$ENV{'form.table'}.
- "&phase=results".
- "&persistent_db_id=".$ENV{'form.persistent_db_id'})
- ."</center>\n"
+ ('<table width="100%"><tr><td width="50%" align="right">'.
+ &prev_next_buttons($min,$ENV{'form.show'},$total_results).
+ '</td><td align="right">'.
+ &viewoptions().'</td></tr></table>'
);
if ($total_results == 0) {
$r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2">'.
@@ -2753,7 +2753,7 @@
$result.=<<END;
</head>
$bodytag
-<form name="results" method="post" action="" >
+<form name="results" method="post" action="/adm/searchcat" >
<input type="hidden" name="Queue" value="" />
$importbutton
END
@@ -2832,10 +2832,9 @@
######################################################################
sub detailed_citation_view {
my ($prefix,%values) = @_;
- my $icon=
my $result;
$result .= '<b>'.$prefix.
- '<img src="'.&Apache::loncommon::icon($values{'url'}).' " />'.
+ '<img src="'.&Apache::loncommon::icon($values{'url'}).' " />'.' '.
'<a href="http://'.$ENV{'HTTP_HOST'}.$values{'url'}.'" '.
'target="search_preview">'.$values{'title'}."</a></b>\n";
$result .= "<p>\n";
@@ -2843,6 +2842,9 @@
' <i>'.$values{'owner'}.'</i><br />';
foreach my $field
(
+ { name=>'url',
+ translate => '<b>URL:</b> [_1]',
+ special => 'url link',},
{ name=>'subject',
translate => '<b>Subject:</b> [_1]',},
{ name=>'keywords',
@@ -2855,6 +2857,8 @@
translate => '<b>Standards:</b>[_1]',},
{ name=>'copyrighttag',
translate => '<b>Copyright/Distribution:</b> [_1]',},
+ { name=>'count',
+ translate => '<b>Access Count:</b> [_1]',},
{ name=>'stdno',
translate => '<b>Number of Students:</b> [_1]',},
{ name=>'avetries',
@@ -2874,11 +2878,29 @@
{ name=>'technical',
translate => '<b>Technical:</b> [_1]',},
) {
- $result.= &mt($field->{'translate'},$values{$field->{'name'}}).
- "<br />\n";
+ if (exists($values{$field->{'name'}}) &&
+ $values{$field->{'name'}} ne '') {
+ if ($field->{'special'} eq 'url link') {
+ $result.=
+ &mt($field->{'translate'},
+ '<a href="'.$values{'url'}.'" '.
+ 'target="search_preview">'.
+ $values{$field->{'name'}}.
+ '</a>');
+ } else {
+ $result.= &mt($field->{'translate'},
+ $values{$field->{'name'}});
+ }
+ $result .= "<br />\n";
+ }
+ }
+ $result .= "</p>";
+ if (exists($values{'extrashow'}) && $values{'extrashow'} ne '') {
+ $result .= '<p>'.$values{'extrashow'}.'</p>';
+ }
+ if (exists($values{'shortabstract'}) && $values{'shortabstract'} ne '') {
+ $result .= '<p>'.$values{'shortabstract'}.'</p>';
}
- $result .= "</p>".$values{'extrashow'}.
- '<p>'.$values{'shortabstract'}.'</p>';
$result .= '<hr align="left" width="200" noshade />'."\n";
return $result;
}
@@ -2932,7 +2954,8 @@
my ($prefix,%values) = @_;
my $icon=&Apache::loncommon::icon($values{'url'});
my $result=<<END;
-$prefix<img src="$icon" /><a href="http://$ENV{'HTTP_HOST'}$values{'url'}"
+$prefix<img src="$icon" />
+<a href="http://$ENV{'HTTP_HOST'}$values{'url'}"
target='search_preview'>$values{'author'}</a><br />
$values{'title'}<br />
$values{'owner'} -- $values{'lastrevisiondate'}<br />
@@ -2957,12 +2980,11 @@
######################################################################
sub compact_view {
my ($prefix,%values) = @_;
- my $icon=&Apache::loncommon::icon($values{'url'});
- my $result=<<END;
-$prefix <img src="$icon" /> <a href="http://$ENV{'HTTP_HOST'}$values{'url'}" target='search_preview'>
-$values{'title'}</a>
-<b>$values{'author'}</b><br />
-END
+ my $result =
+ $prefix.'<img src="'.&Apache::loncommon::icon($values{'url'}).
+ '"> <a href="'.$values{'url'}.'" target="search_preview">'.
+ $values{'title'}.'</a>'.(' 'x2).
+ '<b>'.$values{'author'}.'</b><br />';
return $result;
}
--matthew1083778146--