[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm

bisitz lon-capa-cvs-allow@mail.lon-capa.org
Fri, 19 Sep 2008 08:50:45 -0000


This is a MIME encoded message

--bisitz1221814245
Content-Type: text/plain

bisitz		Fri Sep 19 04:50:45 2008 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm 
  Log:
  "Browse Resources" table:
    - Now uses LON-CAPA standard table
    - Removed hardcoded styles
  
  Note:
  Due to the usage of standard sub routines some styles are lost now, e.g. special background color for absolute links and vertical alignment in some cases (which actually needed to be improved anyway). I kept these code lines as comments starting with "#SB".
  Another idea is to use a different background color for domain and folder rows.
  
  
  
--bisitz1221814245
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20080919045045.txt"

Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.181 loncom/interface/lonindexer.pm:1.182
--- loncom/interface/lonindexer.pm:1.181	Fri Aug  1 10:53:42 2008
+++ loncom/interface/lonindexer.pm	Fri Sep 19 04:50:42 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.181 2008/08/01 14:53:42 bisitz Exp $
+# $Id: lonindexer.pm,v 1.182 2008/09/19 08:50:42 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -104,7 +104,7 @@
     my $lonhost = $r->dir_config('lonHostID');
     my $tabdir  = $r->dir_config('lonTabDir');
 
-    my $fileclr='#ffffe6';
+#SB my $fileclr='#ffffe6';
     my $line;
     my (@attrchk,@openpath,$typeselect);
     my $uri=$r->uri;
@@ -177,7 +177,8 @@
 
 # --------------------- define extra fields and buttons in case of special mode
 	if ($env{'form.catalogmode'} eq 'interactive') {
-	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
+#SB	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
+            $extrafield='<td valign="bottom">'.
 		'<img alt="" src="'.$iconpath.'whitespace1.gif"'.
 		' class="LC_icon" /></td>';
 	    $colspan=" colspan='2' ";
@@ -187,7 +188,8 @@
 END
         }
 	elsif ($env{'form.catalogmode'} eq 'import') {
-	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
+#SB	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
+            $extrafield='<td valign="bottom">'.
 		'<img alt="" src="'.$iconpath.'whitespace1.gif"'.
 		' class="LC_icon" /></td>';
 	    $colspan=" colspan='2' ";
@@ -533,37 +535,37 @@
 	    $r->print('<input type="button" value="'.&mt("Uncheck All").'" id="uncheckallbutton" onClick="javascript:uncheckAll()" />');
 	}
 # ----------------- output starting row to the indexed file/directory hierarchy
-        my $titleclr="#ddffff";
         #$r->print(&initdebug());
         #$r->print(&writedebug("Omit:@Omit")) if (@Omit);
         #$r->print(&writedebug("Only:@Only")) if (@Only);
-        $r->print('<table width="100%" border="0"><tr><td bgcolor="#777777">'."\n");
-	$r->print('<table width="100%" border="0"><tr bgcolor="'.$titleclr.'">'."\n");
-	$r->print("<td $colspan><b>".&mt('Name')."</b></td>\n");
-	$r->print("<td><b>".&mt('Title')."</b></td>\n") 
+        $r->print('<br /><br />');
+        $r->print(&Apache::loncommon::start_data_table()
+                 .&Apache::loncommon::start_data_table_header_row());
+	$r->print("<th $colspan>".&mt('Name')."</th>\n");
+	$r->print("<th>".&mt('Title')."</th>\n") 
 	    if ($hash{'display_attrs_0'} == 1);
-	$r->print("<td align=right><b>".&mt("Size")." (".&mt("bytes").") ".
-		  "</b></td>\n") if ($hash{'display_attrs_1'} == 1);
-	$r->print("<td><b>".&mt("Last accessed")."</b></td>\n") 
+	$r->print('<th align="right">'.&mt("Size")." (".&mt("bytes").") ".
+		  "</th>\n") if ($hash{'display_attrs_1'} == 1);
+	$r->print("<th>".&mt("Last accessed")."</th>\n") 
 	    if ($hash{'display_attrs_2'} == 1);
-	$r->print("<td><b>".&mt("Last modified")."</b></td>\n")
+	$r->print("<th>".&mt("Last modified")."</th>\n")
 	    if ($hash{'display_attrs_3'} == 1);
-	$r->print("<td><b>".&mt("Author(s)")."</b></td>\n")
+	$r->print("<th>".&mt("Author(s)")."</th>\n")
 	    if ($hash{'display_attrs_4'} == 1);
-	$r->print("<td><b>".&mt("Keywords")."</b></td>\n")
+	$r->print("<th>".&mt("Keywords")."</th>\n")
 	    if ($hash{'display_attrs_5'} == 1);
-	$r->print("<td><b>".&mt("Language")."</b></td>\n")
+	$r->print("<th>".&mt("Language")."</th>\n")
 	    if ($hash{'display_attrs_6'} == 1);
-	$r->print("<td><b>".&mt("Usage Statistics")." <br />(".
-		  &mt("Courses/Network Hits").")</b> ".&mt('updated periodically')."</td>\n")
+	$r->print("<th>".&mt("Usage Statistics")." <br />(".
+		  &mt("Courses/Network Hits").") ".&mt('updated periodically')."</th>\n")
 	    if ($hash{'display_attrs_8'} == 1);
-	$r->print("<td><b>".&mt("Source Available")."</b></td>\n")
+	$r->print("<th>".&mt("Source Available")."</th>\n")
 	    if ($hash{'display_attrs_10'} == 1);
-	$r->print("<td><b>".&mt("Linked/Related Resources")."</b></td>\n")
+	$r->print("<th>".&mt("Linked/Related Resources")."</th>\n")
 	    if ($hash{'display_attrs_11'} == 1);
-	$r->print("<td><b>".&mt("Resource")."</b></td>\n")
+	$r->print("<th>".&mt("Resource")."</th>\n")
 	    if ($hash{'display_attrs_7'} == 1);
-	$r->print('</tr>');
+        $r->print(&Apache::loncommon::end_data_table_header_row());
 
 # ----------------- read in what directories have previously been set to "open"
 	foreach (keys %hash) {
@@ -613,15 +615,13 @@
 
 # -------- recursively go through all the directories and output as appropriate
 	&scanDir ($r,$toplevel,$indent,\%hash);
-	
 
 # -------------------------------------------------------------- end the tables
-	$r->print('</table>');
+        $r->print(&Apache::loncommon::end_data_table());
+
 # ---------------------------- embed hidden information useful for group import
 	$r->print("<form name='fnum' action=''>");
 	$r->print("<input type='hidden' name='fnum' value='$fnum' /></form>");
-# -------------------------------------------------------------- end the tables
-	$r->print('</td></tr></table>');
 
 # --------------------------------------------------- end the output and return
 	$r->print(&Apache::loncommon::end_page()."\n");
@@ -818,7 +818,7 @@
 	$pathprefix=$startdir;
     }
     my $dirptr=16384;
-    my $fileclr="#ffffe6";
+#SB my $fileclr="#ffffe6";
     my $iconpath= $r->dir_config('lonIconsURL') . '/';
 
     my @filecom = split (/\&/,$line);
@@ -845,7 +845,9 @@
 	$updir='/'.(split(/\.(page|sequence)\/\//,$startdir))[-1];
 	$updir=~s/\/+/\//g;
 
-	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\">$extrafield");
+#SB	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\">$extrafield");
+        $r->print(&Apache::loncommon::start_data_table_row()); # valign="$valign" ?!?
+        $r->print($extrafield);
 	$r->print("<td>\n");
 	$r->print ('<form method="post" name="dirpathUP" action="'.$updir.
 		   '/" '.
@@ -860,7 +862,8 @@
 	$r->print ('<input src="'.$iconpath.'arrow_up.gif"');
 	$r->print (' name="'.$msg.'" type="image" class="LC_indexer_icon" />'.
 		   "\n");
-	$r->print(&mt("Up")."</form>$tabtag</tr>\n");
+	$r->print(&mt("Up")."</form>$tabtag");
+        $r->print(&Apache::loncommon::end_data_table_row());
 	return OK;
     }
 # Do we have permission to look at this?
@@ -868,13 +871,15 @@
     if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])); }
 
 # make absolute links appear on different background
-    if ($absolute) { $fileclr='#ccdd99'; }
+#SB    if ($absolute) { $fileclr='#ccdd99'; }
 
 # display domain
     if ($filecom[1] eq 'domain') {
  	$r->print ('<input type="hidden" name="dirPointer" value="on" />'."\n")
  	    if ($env{'form.dirPointer'} eq "on");
-	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\">$extrafield");
+#SB	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\">$extrafield");
+	$r->print(&Apache::loncommon::start_data_table_row()); # valign="$valign" ?!?"
+        $r->print($extrafield);
 	$r->print("<td>");
 	&begin_form ($r,$filecom[0]);
 	my $anchor = $filecom[0];
@@ -894,7 +899,8 @@
 	    $r->print("(".&Apache::lonnet::domain($listname,'description').
 		      ")");
 	}
-	$r->print ("</form>$tabtag</tr>\n");
+	$r->print("</form>$tabtag");
+         $r->print(&Apache::loncommon::end_data_table_row());
 	return OK;
 
 # display user directory
@@ -904,7 +910,9 @@
 	my $curdir = $startdir.$filecom[0].'/';
 	my $anchor = $curdir;
 	$anchor =~ s/\W//g;
-	$r->print("<tr bgcolor=\"$fileclr\">$extrafield<td valign=$valign>");
+#SB	$r->print("<tr bgcolor=\"$fileclr\">$extrafield<td valign=$valign>");
+        $r->print(&Apache::loncommon::start_data_table_row()
+                 .$extrafield.'<td valign="'.$valign.'">');
 	&begin_form ($r,$curdir);
 	$r->print ('<a name="'.$anchor.'"></a><img alt="" src="'.$iconpath.
 		   'whitespace1.gif" class="LC_icon" />'."\n");
@@ -921,7 +929,8 @@
 	my $plainname=&Apache::loncommon::plainname($listname,$domain);
 	$r->print ($listname);
 	if (defined($plainname) && $plainname) { $r->print(" ($plainname) "); }
-	$r->print ('</form>'.$tabtag.'</tr>'."\n");
+	$r->print('</form>'.$tabtag);
+        $r->print(&Apache::loncommon::end_data_table_row());
 	return OK;
     }
 
@@ -944,7 +953,9 @@
         }
 	# Set the icon for the file
 	my $iconname = &Apache::loncommon::icon($listname);
-	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\"><td nowrap='nowrap' valign='top'>");
+#SB	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\"><td nowrap='nowrap' valign='top'>");
+	$r->print(&Apache::loncommon::start_data_table_row()); # valign="$valign" ?!?"
+        $r->print('<td nowrap="nowrap" valign="top">');
 	
         if ($env{'form.catalogmode'} eq 'interactive') {
 	    my $quotable_filelink = &Apache::loncommon::escape_single($filelink);
@@ -1103,7 +1114,7 @@
            $r->print('<td> '.($output eq '' ? '&nbsp;':$output).
 		      " </td>\n");
         }
-	$r->print("</tr>\n");
+        $r->print(&Apache::loncommon::end_data_table_row());
     }
 
 # -- display directory
@@ -1111,7 +1122,10 @@
 	my $curdir = $startdir.$filecom[0].'/';
 	my $anchor = $curdir;
 	$anchor =~ s/\W//g;
-	$r->print("<tr bgcolor=\"$fileclr\">$extrafield<td valign=$valign>");
+#SB	$r->print("<tr bgcolor=\"$fileclr\">$extrafield<td valign=$valign>");
+        $r->print(&Apache::loncommon::start_data_table_row()); # SB: bgcolor suggestion: darkgrey ("LC_info_row"?!?)
+#	$r->print('<tr class="LC_info_row">');
+        $r->print($extrafield.'<td valign="'.$valign.'">');
 	&begin_form ($r,$curdir);
 	my $indentm1 = $indent-1;
 	if ($indentm1 < 11 and $indentm1 > 0) {
@@ -1149,7 +1163,7 @@
 	    $r->print('<td> '.($title eq '' ? '&nbsp;' : $title).
 		      ' </td>'."\n");
 	}
-	$r->print('<td align=right> ',
+	$r->print('<td align="right"> ',
 		  $filecom[8]," </td>\n") 
 	    if $hash{'display_attrs_1'} == 1;
 	$r->print('<td> '.
@@ -1188,7 +1202,7 @@
 	if ($hash{'display_attrs_7'} == 1) {
 	   $r->print('<td>&nbsp;</td>');
         }
-	$r->print('</tr>');
+        $r->print(&Apache::loncommon::end_data_table_row());
     }
 
 }

--bisitz1221814245--