--- loncom/interface/lonsearchcat.pm 2006/03/15 20:56:16 1.256
+++ loncom/interface/lonsearchcat.pm 2008/05/28 22:22:27 1.295
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.256 2006/03/15 20:56:16 albertel Exp $
+# $Id: lonsearchcat.pm,v 1.295 2008/05/28 22:22:27 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -78,6 +78,7 @@ use HTML::Entities();
use Parse::RecDescent;
use Apache::lonnavmaps;
use Apache::lonindexer();
+use LONCAPA;
######################################################################
######################################################################
@@ -116,9 +117,6 @@ sub handler {
my $diropendb; # The full path to the (temporary) search database file.
# This is set and used in &handler() and is also used in
# &output_results().
- my $bodytag; # LON-CAPA standard body tag, gotten from
- # &Apache::lonnet::bodytag.
- # No title, no table, just a
tag.
my $loaderror=&Apache::lonnet::overloaderror($r);
if ($loaderror) { return $loaderror; }
@@ -140,7 +138,7 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['catalogmode','launch','acts','mode','form','element','pause',
'phase','persistent_db_id','table','start','show',
- 'cleargroupsort','titleelement']);
+ 'cleargroupsort','titleelement','area','inhibitmenu']);
##
## The following is a trick - we wait a few seconds if asked to so
## the daemon running the search can get ahead of the daemon
@@ -156,7 +154,7 @@ sub handler {
##
my $domain = $r->dir_config('lonDefDomain');
$diropendb= "/home/httpd/perl/tmp/".
- "$env{'user.domain'}_$env{'user.name'}_searchcat.db";
+ "$env{'user.domain'}_$env{'user.name'}_sel_res.db";
#
# set the name of the persistent database
# $env{'form.persistent_db_id'} can only have digits in it.
@@ -165,32 +163,40 @@ sub handler {
($env{'form.launch'} eq '1')) {
$env{'form.persistent_db_id'} = time;
}
- $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);
+
my $persistent_db_file = "/home/httpd/perl/tmp/".
- &Apache::lonnet::escape($domain).
- '_'.&Apache::lonnet::escape($env{'user.name'}).
+ &escape($domain).
+ '_'.&escape($env{'user.name'}).
'_'.$env{'form.persistent_db_id'}.'_persistent_search.db';
##
&Apache::lonhtmlcommon::clear_breadcrumbs();
+
+ my @allowed_searches = ('portfolio');
+ if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
+ push(@allowed_searches,'res');
+ }
if (exists($env{'request.course.id'}) && $env{'request.course.id'} ne '') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/searchcat?'.
- 'catalogmode='.$env{'form.catalogmode'}.
- '&launch='.$env{'form.launch'}.
- '&mode='.$env{'form.mode'},
- text=>"Course and Catalog Search",
- target=>'_top',
- bug=>'Searching',});
- } else {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/searchcat?'.
- 'catalogmode='.$env{'form.catalogmode'}.
- '&launch='.$env{'form.launch'}.
- '&mode='.$env{'form.mode'},
- text=>"Catalog Search",
+ push(@allowed_searches,'course');
+ }
+ my $crumb_text = 'Portfolio Search';
+ if (@allowed_searches == 3) {
+ $crumb_text = 'Course, Portfolio and Catalog Search';
+ } elsif (@allowed_searches ==2) {
+ if (grep(/^res$/,@allowed_searches)) {
+ $crumb_text = 'Portfolio and Catalog Search';
+ } elsif (grep(/^course$/,@allowed_searches)) {
+ $crumb_text = 'Portfolio and Course Search';
+ }
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/searchcat?'.
+ &Apache::loncommon::inhibit_menu_check().
+ '&catalogmode='.$env{'form.catalogmode'}.
+ '&launch='.$env{'form.launch'}.
+ '&mode='.$env{'form.mode'},
+ text=>"$crumb_text",
target=>'_top',
bug=>'Searching',});
- }
#
if ($env{'form.phase'} !~ m/(basic|adv|course)_search/) {
if (! &get_persistent_form_data($persistent_db_file)) {
@@ -202,7 +208,9 @@ sub handler {
'We were unable to retrieve data describing your search. '.
'This is a serious error and has been logged. '.
'Please alert your LON-CAPA administrator.';
- return &error_page($r,$msg);
+ &Apache::loncommon::simple_error_page($r,'Search Error',
+ $msg);
+ return OK;
}
}
} else {
@@ -214,7 +222,7 @@ sub handler {
untie %groupsearch_db if (tied(%groupsearch_db));
if (($env{'form.cleargroupsort'} eq '1') ||
(($env{'form.launch'} eq '1') &&
- ($env{'form.catalogmode'} eq 'groupsearch'))) {
+ ($env{'form.catalogmode'} eq 'import'))) {
if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
&start_fresh_session();
untie %groupsearch_db;
@@ -223,7 +231,9 @@ sub handler {
# This is a stupid error to give to the user.
# It really tells them nothing.
my $msg = 'Unable to tie hash to db file.';
- return &error_page($r,$msg);
+ &Apache::loncommon::simple_error_page($r,'Search Error',
+ $msg);
+ return OK;
}
}
##
@@ -246,19 +256,25 @@ sub handler {
if (exists($env{'form.mode'})) {
$hidden_fields .= &hidden_field('mode');
}
+ if (exists($env{'form.area'})) {
+ $hidden_fields .= &hidden_field('area');
+ }
+ if (exists($env{'form.inhibitmenu'})) {
+ $hidden_fields .= &hidden_field('inhibitmenu');
+ }
##
## Configure dynamic components of interface
##
if ($env{'form.catalogmode'} eq 'interactive') {
- $closebutton=" '/adm/searchcat?phase=disp_adv&'.
- 'catalogmode='.$env{'form.catalogmode'}.
+ ({href=>'/adm/searchcat?'.&Apache::loncommon::inhibit_menu_check().
+ '&phase=disp_adv'.
+ '&catalogmode='.$env{'form.catalogmode'}.
'&launch='.$env{'form.launch'}.
'&mode='.$env{'form.mode'},
- text=>"Advanced Search",
+ text=>"Advanced $srchtype Search",
bug=>'Searching',});
} elsif ($env{'form.searchmode'} eq 'course search') {
&Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/searchcat?phase=disp_adv&'.
+ ({href=>'/adm/searchcat?'.&Apache::loncommon::inhibit_menu_check().
+ '&phase=disp_adv'.
'catalogmode='.$env{'form.catalogmode'}.
'&launch='.$env{'form.launch'}.
'&mode='.$env{'form.mode'},
@@ -315,7 +337,8 @@ END
} elsif ($env{'form.phase'} eq 'disp_adv') {
&print_advanced_search_form($r,$closebutton,$hidden_fields);
} elsif ($env{'form.phase'} eq 'results') {
- &display_results($r,$importbutton,$closebutton,$diropendb);
+ &display_results($r,$importbutton,$closebutton,$diropendb,
+ $env{'form.area'});
} elsif ($env{'form.phase'} =~ /^(sort|run_search)$/) {
my ($query,$customquery,$customshow,$libraries,$pretty_string) =
&get_persistent_data($persistent_db_file,
@@ -325,7 +348,7 @@ END
&print_sort_form($r,$pretty_string);
} elsif ($env{'form.phase'} eq 'run_search') {
&run_search($r,$query,$customquery,$customshow,
- $libraries,$pretty_string);
+ $libraries,$pretty_string,$env{'form.area'});
}
} elsif ($env{'form.phase'} eq 'course_search') {
&course_search($r);
@@ -355,23 +378,27 @@ END
$persistent_db_file);
#
# Set up table
- if (! defined(&create_results_table())) {
+ if (! defined(&create_results_table($env{'form.area'}))) {
my $errorstring=&Apache::lonmysql::get_error();
&Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '.
'needed table. lonmysql error:'.
$errorstring);
my $msg =
- 'Unable to create table in which to store search results. '.
+ 'Unable to create table in which to save search results. '.
'The search has been aborted.';
- return &error_page($r,$msg);
+ &Apache::loncommon::simple_error_page($r,'Search Error',
+ $msg);
+ return OK;
}
delete($env{'form.launch'});
if (! &make_form_data_persistent($r,$persistent_db_file)) {
my $msg=
- 'Unable to properly store search information. '.
+ 'Unable to properly save search information. '.
'The search has been aborted.';
- return &error_page($r,$msg);
+ &Apache::loncommon::simple_error_page($r,'Search Error',
+ $msg);
+ return OK;
}
##
## Print out the frames interface
@@ -383,14 +410,6 @@ END
return OK;
}
-sub error_page {
- my ($r,$msg) = @_;
- $r->print(&Apache::loncommon::start_page('Search Error').
- &mt($msg).
- &Apache::loncommon::end_page());
- return OK;
-}
-
#
# The mechanism used to store values away and retrieve them does not
# handle the case of missing environment variables being significant.
@@ -508,7 +527,7 @@ sub course_search {
my $applies = 0;
my $symb = $resource->symb();
my $ressymb = $symb;
- if ($symb =~ m#(___adm/\w+/\w+)/(\d+)/bulletinboard$#) {
+ if ($symb =~ m#(___adm/$LONCAPA::domain_re/$LONCAPA::username_re)/(\d+)/bulletinboard$#) {
$ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) {
$ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#;
@@ -554,7 +573,7 @@ sub course_search {
} else {
$url .= '?symb=';
}
- $url .= &Apache::lonnet::escape($resource->symb());
+ $url .= &escape($resource->symb());
my $title = $resource->compTitle();
$r->print(''.
($title?$title:$url).' - '.$disctype.' ');
@@ -590,7 +609,7 @@ sub checkonthis {
my ($extension)=($url=~/\.(\w+)$/);
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' &&
($url) && ($fulltext)) {
- $result.=&Apache::lonnet::ssi_body($url.'?symb='.&Apache::lonnet::escape($symb));
+ $result.=&Apache::lonnet::ssi_body($url.'?symb='.&escape($symb));
}
$result=~s/\s+/ /gs;
my $applies = 0;
@@ -606,7 +625,7 @@ sub checkonthis {
$href=&Apache::lonenc::encrypted($href)
.'?symb='.&Apache::lonenc::encrypted($symb);
} else {
- $href.='?symb='.&Apache::lonnet::escape($symb);
+ $href.='?symb='.&escape($symb);
}
$r->print(''.($title?$title:$url).
' ');
@@ -661,76 +680,18 @@ Prints the form for the basic search. S
######################################################################
sub print_basic_search_form {
my ($r,$closebutton,$hidden_fields) = @_;
- my $result = ($env{'form.catalogmode'} ne 'groupsearch');
+ my $result = ($env{'form.catalogmode'} ne 'import');
my $bread_crumb =
- &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic',
- undef,undef,
- $env{'form.catalogmode'} ne 'groupsearch');
+ &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',
+ $env{'form.catalogmode'} ne 'import');
my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb;
+# Search form for resource space
if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
- # Define interface components
- my $userelatedwords= ''.
- &mt('[_1] use related words',
- &Apache::lonhtmlcommon::checkbox
- ('related',$env{'form.related'},'related')).' ';
- my $onlysearchdomain=''.
- &mt('[_1] only search domain [_2]',
- &Apache::lonhtmlcommon::checkbox('domains',
- $env{'form.domains'},
- $r->dir_config('lonDefDomain')
- ),
- $r->dir_config('lonDefDomain')
- ).' ';
- my $inclext= ''.
- &mt('[_1] include external resources',
- &Apache::lonhtmlcommon::checkbox
- ('inclext',$env{'form.inclext'})).' ';
- my $adv_search_link =
- ''.&mt('Advanced Search').' ';
- #
- $scrout.='';
+ $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
+ $scrout .= ' ';
}
+# Search form for accessible portfolio files
+ $scrout.= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
if ($env{'request.course.id'}) {
my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
'header' => 'Course Search',
@@ -781,6 +742,75 @@ ENDENDCOURSE
$r->print($scrout);
return;
}
+
+sub setup_basic_search {
+ my ($r,$area,$hidden_fields,$closebutton) = @_;
+ # Define interface components
+ my %lt = &Apache::lonlocal::texthash (
+ res => 'LON-CAPA Catalog Search',
+ portfolio => 'Portfolio Search',
+ );
+ my ($userelatedwords,$onlysearchdomain,$inclext,$adv_search_link,$scrout);
+ $userelatedwords = ''.&mt('[_1] use related words',
+ &Apache::lonhtmlcommon::checkbox('related',$env{'form.related'},'related')).
+ ' ';
+ $onlysearchdomain = ''.&mt('[_1] only search domain [_2]',
+ &Apache::lonhtmlcommon::checkbox('domains',$env{'form.domains'},
+ $r->dir_config('lonDefDomain')),
+ $r->dir_config('lonDefDomain')).
+ ' ';
+ $adv_search_link = ''.&mt('Advanced Search').' ';
+ #
+ $scrout.='';
+ return $scrout;
+}
+
######################################################################
######################################################################
@@ -797,10 +827,8 @@ Prints the advanced search form.
sub print_advanced_search_form{
my ($r,$closebutton,$hidden_fields) = @_;
my $bread_crumb =
- &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',
- 'Search_Advanced',
- undef,undef,
- $env{'form.catalogmode'} ne 'groupsearch');
+ &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Advanced',
+ $env{'form.catalogmode'} ne 'import');
my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
'reset' => 'Reset',
'help' => 'Help');
@@ -809,7 +837,22 @@ sub print_advanced_search_form{
$closebutton
END
- my $scrout= &Apache::loncommon::start_page('Advanced Catalog Search');
+ my $srchtype = 'Catalog';
+ my $jscript;
+ if ($env{'form.area'} eq 'portfolio') {
+ $srchtype = 'Portfolio';
+ $jscript = '';
+ }
+ my $scrout= &Apache::loncommon::start_page("Advanced $srchtype Search",
+ $jscript);
$scrout .= <<"ENDHEADER";
$bread_crumb
';
$r->print($result.&Apache::loncommon::end_page());
return;
}
@@ -2179,7 +2308,7 @@ my @Fullindicies;
Creates the table of search results by calling lonmysql. Stores the
table id in $env{'form.table'}
-Inputs: none.
+Inputs: search area - either res or portfolio
Returns: the identifier of the table on success, undef on error.
@@ -2188,8 +2317,9 @@ Returns: the identifier of the table on
######################################################################
######################################################################
sub set_up_table_structure {
+ my ($tabletype) = @_;
my ($datatypes,$fullindicies) =
- &LONCAPA::lonmetadata::describe_metadata_storage();
+ &LONCAPA::lonmetadata::describe_metadata_storage($tabletype);
# Copy the table description before modifying it...
@Datatypes = @{$datatypes};
unshift(@Datatypes,{name => 'id',
@@ -2202,7 +2332,12 @@ sub set_up_table_structure {
}
sub create_results_table {
- &set_up_table_structure();
+ my ($area) = @_;
+ if ($area eq 'portfolio') {
+ &set_up_table_structure('portfolio_search');
+ } else {
+ &set_up_table_structure('metadata');
+ }
my $table = &Apache::lonmysql::create_table
( { columns => \@Datatypes,
FULLTEXT => [{'columns' => \@Fullindicies},],
@@ -2308,13 +2443,14 @@ Returns: html string for a 'revise searc
######################################################################
######################################################################
sub revise_button {
+ my $revisetext = &mt('Revise search');
my $revise_phase = 'disp_basic';
$revise_phase = 'disp_adv' if ($env{'form.searchmode'} eq 'advanced');
my $newloc = '/adm/searchcat'.
'?persistent_db_id='.$env{'form.persistent_db_id'}.
'&cleargroupsort=1'.
'&phase='.$revise_phase;
- my $result = qq{ };
return $result;
}
@@ -2334,23 +2470,26 @@ results into MySQL.
######################################################################
######################################################################
sub run_search {
- my ($r,$query,$customquery,$customshow,$serverlist,$pretty_string) = @_;
- my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);
- $bodytag.=&Apache::lonhtmlcommon::breadcrumbs
- (undef,'Searching','Searching',undef,undef,
- $env{'form.catalogmode'} ne 'groupsearch');
+ my ($r,$query,$customquery,$customshow,$serverlist,
+ $pretty_string,$area) = @_;
+ my $tabletype = 'metadata';
+ if ($area eq 'portfolio') {
+ $tabletype = 'portfolio_search';
+ }
my $connection = $r->connection;
#
# Print run_search header
#
- my $html = &Apache::lonxml::xmlbegin();
- my $head = &Apache::loncommon::head('Search Status');
+ my $start_page = &Apache::loncommon::start_page('Search Status',undef,
+ {'no_title' => 1});
+ my $breadcrumbs =
+ &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
+ $env{'form.catalogmode'} ne 'import');
$r->print(<
-
+
END
# Remove leading and trailing
$pretty_string =~ s:^\s* ::i;
@@ -2375,14 +2514,15 @@ END
@Servers_to_contact = ($serverlist);
}
} else {
- @Servers_to_contact = sort(keys(%Apache::lonnet::libserv));
+ my %all_library_servers = &Apache::lonnet::all_library();
+ @Servers_to_contact = sort(keys(%all_library_servers));
}
my %Server_status;
#
# Check on the mysql table we will use to store results.
my $table =$env{'form.table'};
if (! defined($table) || $table eq '' || $table =~ /\D/ ) {
- $r->print("Unable to determine table id to store search results in.".
+ $r->print("Unable to determine table id to save search results in.".
"The search has been aborted.".
&Apache::loncommon::end_page());
return;
@@ -2411,6 +2551,7 @@ END
##
## Prepare for the big loop.
my $hitcountsum;
+ my %matches;
my $server;
my $status;
my $revise = &revise_button();
@@ -2465,7 +2606,7 @@ END
delete ($Server_status{$server});
next;
}
- $status=~s|/||g;
+ $status=~s|/||g;
my $datafile=$r->dir_config('lonDaemons').'/tmp/'.$status;
if (-e $datafile && ! -e "$datafile.end") {
&update_status($r,&mt('Receiving results from [_1]',$server));
@@ -2494,14 +2635,18 @@ END
next if (! $result);
#
# Parse the result.
- my %Fields = &parse_raw_result($result,$server);
+ my %Fields = &parse_raw_result($result,$server,$tabletype);
$Fields{'hostname'} = $server;
#
- # Skip if external and we did not want that
- next if ((! $env{'form.inclext'}) && ($Fields{'url'}=~/^\/ext\//));
# Skip based on copyright
next if (! ©right_check(\%Fields));
+ if ($area eq 'portfolio') {
+ next if (defined($matches{$Fields{'url'}}));
+ # Skip if inaccessible
+ next if (!&Apache::lonnet::portfolio_access($Fields{'url'}));
+ $matches{$Fields{'url'}} = 1;
+ }
#
# Store the result in the mysql database
my $result = &Apache::lonmysql::store_row($table,\%Fields);
@@ -2535,7 +2680,7 @@ END
# results to get, so let the client know the top frame needs to be
# loaded from /adm/searchcat
$r->print(&Apache::loncommon::end_page());
-# if ($env{'form.catalogmode'} ne 'groupsearch') {
+# if ($env{'form.catalogmode'} ne 'import') {
$r->print("
SCRIPT
- my $end_head = &Apache::loncommon::endheadtag();
- my $bodytag = &Apache::loncommon::bodytag(undef,undef,undef,1);
- $result.=<
-
+ my $start_page = &Apache::loncommon::start_page(undef,$js,
+ {'only_body' =>1});
+ my $result=<
$importbutton
END
return $result;
}
-######################################################################
-######################################################################
-sub search_status_header {
- my $bodytag = &Apache::loncommon::bodytag(undef,undef,undef,1);
- my $html = &Apache::lonxml::xmlbegin();
- my $head = &Apache::loncommon::head('Search Status');
- return <Search Status
-Sending search request to LON-CAPA servers.
-ENDSTATUS
-}
-
sub results_link {
my $basic_link = "/adm/searchcat?"."&table=".$env{'form.table'}.
"&persistent_db_id=".$env{'form.persistent_db_id'};
@@ -3135,22 +3285,27 @@ sub print_frames_interface {
"&persistent_db_id=".$env{'form.persistent_db_id'};
my $run_search_link = $basic_link."&phase=run_search";
my $results_link = &results_link();
- my $html = &Apache::lonxml::xmlbegin();
- my $head = &Apache::loncommon::headtag('LON-CAPA Digital Library Search Results');
- my $end_head = &Apache::loncommon::endheadtag();
- my $result = <<"ENDFRAMES";
-$html
-$head
-
-$end_head
-
+JS
+
+ my $start_page =
+ &Apache::loncommon::start_page('LON-CAPA Digital Library Search Results',
+ $js,
+ {'frameset' => 1,
+ 'add_entries' => {
+ 'rows' => "150,*",},});
+ my $end_page =
+ &Apache::loncommon::end_page({'frameset' => 1});
+
+ my $result = <<"ENDFRAMES";
+$start_page
-
-
+$end_page
ENDFRAMES
$r->print($result);
@@ -3218,11 +3373,11 @@ sub detailed_citation_view {
my ($prefix,%values) = @_;
my $result;
my $jumpurl=$values{'url'};
- $jumpurl=~s/^\/ext\//http\:\/\//;
+ $jumpurl=~s|^/ext/|http://|;
$result .= ''.$prefix.
- ' '.' '.
- ''.$values{'title'}." \n";
+ ' '.' '.
+ ''.$values{'title'}." \n";
$result .= "\n";
$result .= ''.$values{'author'}.' ,'.
' '.$values{'owner'}.' ';
@@ -3286,25 +3441,18 @@ sub detailed_citation_view {
next if (! exists($values{$field->{'name'}}) ||
$values{$field->{'name'}} eq '');
if (exists($field->{'type'}) && $field->{'type'} eq 'list') {
- $result .= ''.&mt($field->{'translate'}).'
';
+ $result .= ''.&mt($field->{'translate'}).' ';
foreach my $item (split(',',$values{$field->{'name'}})){
- $result .= ''.
- ''.$item.' ';
+ $item = &Apache::lonnet::clutter($item);
+ $result .= &display_url($item,[2,0,1]);
}
- $result .= ' ';
} elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
$result.= &mt($field->{'translate'},
sprintf($field->{'format'},
$values{$field->{'name'}}))." \n";
} else {
if ($field->{'special'} eq 'url link') {
- $result.=
- &mt($field->{'translate'},
- ''.
- $values{$field->{'name'}}.
- ' ');
+ $result .= &display_url($jumpurl,[3,0,1]);
} else {
$result.= &mt($field->{'translate'},
$values{$field->{'name'}});
@@ -3360,11 +3508,13 @@ sub summary_view {
$result .= ' '.$tmp.' ';
}
my $jumpurl=$values{'url'};
- $jumpurl=~s/^\/ext\//http\:\/\//;
+ $jumpurl=~s|^/ext/|http://|;
+ my $link = &display_url($jumpurl,[2,0,1]);
$result.=<$values{'title'}
+$values{'title'}
+$link
$values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}
$values{'copyrighttag'}
$values{'extrashow'}
@@ -3397,8 +3547,10 @@ sub summary_preview {
sub compact_view {
my ($prefix,%values) = @_;
my $jumpurl=$values{'url'};
- $jumpurl=~s/^\/ext\//http\:\/\//;
+ $jumpurl=~s|^/ext/|http://|;
+ my $link = &display_url($jumpurl,[1,1,1]);
+
my $result =
$prefix.' ';
if (exists($env{'form.sortfield'}) &&
@@ -3407,12 +3559,30 @@ sub compact_view {
if (! defined($tmp)) { $tmp = 'undefined'; }
$result .= ' '.$tmp.' ';
}
- $result.=' '.
- $values{'title'}.' '.(' 'x2).
- ''.$values{'author'}.' ('.$values{'domain'}.') ';
+ $jumpurl = &HTML::Entities::encode($jumpurl,'<>&"');
+ $result.=' '.
+ ''.
+ &HTML::Entities::encode($values{'title'},'<>&"').' '.
+ $link.' '.$values{'author'}.' ('.$values{'domain'}.') ';
return $result;
}
+sub display_url {
+ my ($url,$crumb_args) = @_;
+ my $link;
+ if ($url=~m|^/ext/|) {
+ $url=~s|^/ext/|http://|;
+ $link=''.$url.' ';
+ } elsif ($url=~m{^(http://|/uploaded/)}) {
+ $link=''.$url.' ';
+ } else {
+ $link=&Apache::lonhtmlcommon::crumbs($url,
+ 'preview',
+ '',
+ (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),@{$crumb_args}).' ';
+ }
+ return $link;
+}
######################################################################
######################################################################
@@ -3430,14 +3600,14 @@ sub fielded_format_view {
my $icon=&Apache::loncommon::icon($values{'url'});
my %Translated = &Apache::lonmeta::fieldnames();
my $jumpurl=$values{'url'};
- $jumpurl=~s/^\/ext\//http\:\/\//;
+ $jumpurl=~s|^/ext/|http://|;
my $result=<
URL:
- $values{'url'}
+ $values{'url'}
END
foreach my $field ('title','author','domain','subject','keywords','notes',
'mimetag','language','creationdate','lastrevisiondate',
@@ -3621,7 +3791,6 @@ $parms is extra information to include i
######################################################################
sub output_blank_field_error {
my ($r,$closebutton,$parms,$hidden_fields)=@_;
- my $bodytag=&Apache::loncommon::bodytag('Search');
my $errormsg = &mt('You did not fill in enough information for the search to be started. You need to fill in relevant fields on the search page in order for a query to be processed.');
my $revise = &mt('Revise Search Request');
my $heading = &mt('Unactionable Search Queary');