[LON-CAPA-cvs] cvs: modules /gerd/harvesting lonrecommender.pm
www
www at source.lon-capa.org
Thu Jul 19 10:32:53 EDT 2012
www Thu Jul 19 14:32:53 2012 EDT
Modified files:
/modules/gerd/harvesting lonrecommender.pm
Log:
Standard table layouts and fixed keyword search
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.28 modules/gerd/harvesting/lonrecommender.pm:1.29
--- modules/gerd/harvesting/lonrecommender.pm:1.28 Thu Jul 19 13:10:47 2012
+++ modules/gerd/harvesting/lonrecommender.pm Thu Jul 19 14:32:53 2012
@@ -5,7 +5,7 @@
#
# MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
#
-# $Id: lonrecommender.pm,v 1.28 2012/07/19 13:10:47 www Exp $
+# $Id: lonrecommender.pm,v 1.29 2012/07/19 14:32:53 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -299,7 +299,7 @@
#
sub keyword_search {
- my ($filter,$baseids, at keywords)=@_;
+ my (@keywords)=@_;
my %output=();
my $skey=join(',', at keywords);
$skey=~s/^\W+//gs;
@@ -478,9 +478,12 @@
sub display {
my ($r,$taxonomy_categories,$selectedids,$filter,$lower,$interval,$idhash)=@_;
&filter($filter,$selectedids,$idhash);
+ $r->print("\n<br />".&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
+ '<th>'.&mt("Recommendations")."</th>".&Apache::loncommon::end_data_table_header_row()."<tr><td>\n");
&prevnext($r,$lower,$interval);
&display_list($r,0,$taxonomy_categories,&urlres_array((&sorted_list($selectedids,keys(%$idhash)))[$lower..$lower+$interval-1]));
&prevnext($r,$lower,$interval);
+ $r->print('</td></tr>'.&Apache::loncommon::end_data_table());
}
# =================================================================================
@@ -491,13 +494,13 @@
my ($r,$editflag,$taxocats, at urls)=@_;
my %urlids=&urlres(@urls);
my %taxoids=&taxoids(values(%urlids));
- $r->print("\n<table border='1' bgcolor='".($editflag?'#DDDDFF':'#FFFFDD')."'>\n");
+ $r->print(&Apache::loncommon::start_data_table());
foreach my $url (@urls) {
if ($url) {
$r->print(&display_line($url,$taxocats,$taxoids{$urlids{$url}},$editflag));
}
}
- $r->print("\n</table>\n");
+ $r->print(&Apache::loncommon::end_data_table());
}
# =================================================================================
@@ -507,15 +510,15 @@
sub display_line {
my ($url,$taxocats,$taxonomy,$editflag)=@_;
- return "\n<tr><td>".
+ return "\n".&Apache::loncommon::start_data_table_row().'<th>'.
&submit_link(($editflag?'Remove':'Add'),($editflag?'rem:':'add:').$url).
- "</td><td>".
+ "</th><td>".
&submit_link(&Apache::lonnet::gettitle($url),'indiv:'.$url).
"</td><td>".
join(',',map {&showtaxo($$taxocats{'cleartext_'.$_})} split(/\,/,$taxonomy)).
"</td><td>".
&showurl($url).
- "</td></tr>\n";
+ "</td>".&Apache::loncommon::end_data_table_row()."\n";
}
# =================================================================================
@@ -581,7 +584,7 @@
sub list_nextlevel_cats {
my ($current,$taxocats)=@_;
- my $output='<b>'.$current.' ...</b><br />';
+ my $output='<p>'.&Apache::loncommon::start_data_table().'<tr><th>'.$current.' ...</th></tr><tr><td>';
foreach my $key (sort(keys(%$taxocats))) {
if ($key=~/^count\_(.+)$/) {
my $cat=$1;
@@ -594,6 +597,7 @@
}
}
}
+ $output.='</td></tr>'.&Apache::loncommon::end_data_table().'</p>';
return $output;
}
@@ -633,9 +637,11 @@
}
}
# @list now has the files from the directory or sequence
+ $r->print("\n<br />".&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
+ '<th>'.&mt("Directory Listing")."</th>".&Apache::loncommon::end_data_table_header_row()."<tr><td>\n");
$r->print(&submit_link(&mt('Domain Level'),'dir:/res')."<br />\n");
$r->print('<h2>'.$uri.'</h2>');
- $r->print('<table border="1" bgcolor="#DDFFDD">');
+ $r->print(&Apache::loncommon::start_data_table());
# Now go through the list
foreach my $line (@list) {
my @components=split(/\&/,$line);
@@ -683,13 +689,13 @@
$addflag=0;
}
}
- $r->print("<tr><td>");
+ $r->print(&Apache::loncommon::start_data_table_row());
if ($addflag) {
- $r->print(&submit_link(&mt('Add'),'add:'.$fn));
+ $r->print('<th>'.&submit_link(&mt('Add'),'add:'.$fn).'</th>');
} else {
- $r->print(' ');
+ $r->print('<td> </td>');
}
- $r->print('</td><td>');
+ $r->print('<td>');
$r->print('<img src="'.$icon.'" />');
$r->print('</td><td>');
if ($title) {
@@ -699,9 +705,10 @@
}
$r->print('</td><td>');
$r->print(&showurl($fn,$dirflag));
- $r->print("</td></tr>\n");
+ $r->print("</td>".&Apache::loncommon::end_data_table_row()."\n");
}
- $r->print("</table>\n");
+ $r->print(&Apache::loncommon::end_data_table());
+ $r->print("\n</td></tr>".&Apache::loncommon::end_data_table());
}
# =================================================================================
@@ -814,24 +821,28 @@
# ------ Make header row
my $searchterm=$env{'form.searchterm'};
$searchterm=~s/[\"\']//gs;
- $r->print("<table width='100%'><tr>\n");
- $r->print("<td><input type='text' size='40' name='searchterm' value='$searchterm' />".
+ if ($cmd ne 'search') { $searchterm=''; }
+ $r->print(&Apache::loncommon::start_data_table().'<tr>');
+ $r->print("<td><input type='text' size='40' name='searchterm' value='$searchterm'".
+ " onChange='this.form.cmd.value=\"search\";this.form.submit();'>".
&submit_link(&mt('Search'),'search')."</td>");
- $r->print("<td rowspan='3' align='right' bgcolor='#DDDDFF'>".
+ $r->print("<th rowspan='3' align='right' bgcolor='#DDDDFF'>".
"<font size='+1'><a href='/adm/groupsort?inhibitmenu=yes'>".&mt("Checkout")."</a></font><br /> <br />".
&submit_link(&mt('Your cart ([_1] item(s))',$#selectedurls+1),'showbasket').
- "</td>");
+ "</th>");
$r->print("</tr>\n<tr>");
$r->print('<td>'.&list_toplevel_cats(\%taxonomy_categories).'</td>');
$r->print("</tr>\n<tr>");
$r->print("<td>".&mt("Filter Lists").' '.&filter_menu($filter)."</td>");
- $r->print("\n</tr></table>");
+ $r->print("\n</tr>".&Apache::loncommon::end_data_table());
# ------ End header row
if (($cmd eq 'showbasket') || ($cmd=~/^(add|rem)\:/)) {
$r->print("\n<h1>".&mt("Current Cart")."</h1>\n");
&display_list($r,1,\%taxonomy_categories, at selectedurls);
&display($r,\%taxonomy_categories,\%selectedids,$filter,$lower,20,&associated(values(%selectedids)));
} elsif ($cmd eq 'search') {
+ $r->print('<p>'.&mt('Searching for [_1] ...',$env{'form.searchterm'}).'</p>');
+ $r->rflush();
&display($r,\%taxonomy_categories,\%selectedids,$filter,$lower,20,&keyword_search($env{'form.searchterm'}));
} elsif ($cmd=~/^taxo\:(.*)$/) {
my $taxocat=$1;
More information about the LON-CAPA-cvs
mailing list