[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm

bisitz lon-capa-cvs-allow@mail.lon-capa.org
Tue, 19 Aug 2008 10:43:59 -0000


bisitz		Tue Aug 19 06:43:59 2008 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  - Optimized dependencies warnings (linebreaks; div; only show headline, if warnings occur)
  - Don't display horizontal line anymore, if resource is without errors
  - Wrapped some messages in div-Tags instead of using linebreaks for nicer output
  - Added warning style to "enter metadata" message
  - Added missing &mt() calls to store metadata error messages
  - Optimized some &mt() calls
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.245 loncom/publisher/lonpublisher.pm:1.246
--- loncom/publisher/lonpublisher.pm:1.245	Thu Aug 14 09:39:02 2008
+++ loncom/publisher/lonpublisher.pm	Tue Aug 19 06:43:59 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.245 2008/08/14 13:39:02 onken Exp $
+# $Id: lonpublisher.pm,v 1.246 2008/08/19 10:43:59 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -266,8 +266,9 @@
     my ($logfile,$fn,$prefix)=@_;
     unless (-e $fn) {
 	print($logfile 'No file '.$fn."\n");
-        return '<br /><b>'.&mt('No file').':</b> <tt>'.
-	    &Apache::loncfile::display($fn).'</tt>';
+        return '<div><b>'
+              .&mt('No file: [_1]'
+                  ,'</b> <tt>'.&Apache::loncfile::display($fn).'</tt></div>');
     }
     print($logfile 'Processing '.$fn."\n");
     my $metastring;
@@ -276,8 +277,9 @@
 	$metastring=join('',<$metafh>);
     }
     &metaeval($metastring,$prefix);
-    return '<br /><b>'.&mt('Processed file').':</b> <tt>'.
-	&Apache::loncfile::display($fn).'</tt><br />';
+    return '<div><b>'
+          .&mt('Processed file: [_1]'
+              ,'</b> <tt>'.&Apache::loncfile::display($fn).'</tt></div>');
 }
 
 #########################################
@@ -845,15 +847,17 @@
     # Determine if the table exists
     my $status = &Apache::lonmysql::check_table('metadata');
     if (! defined($status)) {
-        $error='<span class="LC_error">WARNING: Cannot connect to '.
-            'database!</span>';
+        $error='<span class="LC_error">'
+              .&mt('WARNING: Cannot connect to database!')
+              .'</span>';
         &Apache::lonnet::logthis($error);
         return ($error,undef);
     }
     if ($status == 0) {
         # It would be nice to actually create the table....
-        $error ='<span class="LC_error">WARNING: The metadata table does not '.
-            'exist in the LON-CAPA database.</span>';
+        $error ='<span class="LC_error">'
+               .&mt('WARNING: The metadata table does not exist in the LON-CAPA database!')
+               .'</span>';
         &Apache::lonnet::logthis($error);
         return ($error,undef);
     }
@@ -868,8 +872,9 @@
                                                          \%metadata);
     }
     if (defined($status) && $status ne '') {
-        $error='<span class="LC_error">Error occured saving new values in '.
-            'metadata table in LON-CAPA database</span>';
+        $error='<span class="LC_error">'
+              .&mt('Error occured saving new values in metadata table in LON-CAPA database!')
+              .'</span>';
         &Apache::lonnet::logthis($error);
         &Apache::lonnet::logthis($status);
         return ($error,undef);
@@ -985,30 +990,30 @@
 	if ($error) { return ($outstring,$error); }
 # ------------------------------------------------------------ Construct Allows
     
-	$scrout.='<h3>'.&mt('Dependencies').'</h3>';
+        my $outdep=''; # Collect dependencies output data
         my $allowstr='';
         foreach my $thisdep (sort(keys(%allow))) {
 	   if ($thisdep !~ /[^\s]/) { next; }
            if ($thisdep =~/\$/) {
-              $scrout.='<br /><span class="LC_warning">'
+              $outdep.='<div class="LC_warning">'
                        .&mt('The resource depends on another resource with variable filename, i.e., [_1].','<tt>'.$thisdep.'</tt>').'<br />'
                        .&mt('You likely need to explicitly allow access to all possible dependencies using the [_1]-tag.','<tt>&lt;allow&gt;</tt>')
-                       .'</span><br />';
+                       ."</div>\n";
            }
            unless ($style eq 'rat') { 
               $allowstr.="\n".'<allow src="'.$thisdep.'" />';
 	   }
-           $scrout.='<br />';
+          $outdep.='<div>';
            if ($thisdep!~/[\*\$]/ && $thisdep!~m|^/adm/|) {
-	       $scrout.='<a href="'.$thisdep.'">';
+	       $outdep.='<a href="'.$thisdep.'">';
            }
-           $scrout.='<tt>'.$thisdep.'</tt>';
+           $outdep.='<tt>'.$thisdep.'</tt>';
            if ($thisdep!~/[\*\$]/ && $thisdep!~m|^/adm/|) {
-	       $scrout.='</a>';
+	       $outdep.='</a>';
                if (
        &Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'.
                                             $thisdep.'.meta') eq '-1') {
-		   $scrout.= ' - <span class="LC_error">'.&mt('Currently not available').
+		   $outdep.= ' - <span class="LC_error">'.&mt('Currently not available').
 		       '</span>';
                } else {
                    my %temphash=(&Apache::lonnet::declutter($target).'___'.
@@ -1021,6 +1026,12 @@
 		   }
 	       }
            }
+           $outdep.='</div><br />';
+        }
+
+        if ($outdep) {
+            $scrout.='<h3>'.&mt('Dependencies').'</h3>'
+                    .$outdep
         }
         $outstring=~s/\n*(\<\/[^\>]+\>[^<]*)$/$allowstr\n$1\n/s;
 
@@ -1210,7 +1221,7 @@
     my $intr_scrout.='<br />'
                     .'<form name="pubform" action="/adm/publish" method="post">';
     unless ($env{'form.makeobsolete'}) {
-       $intr_scrout.='<p>'
+       $intr_scrout.='<p class="LC_warning">'
                     .&mt('Searching for your resource will be based on the following metadata. Please provide as much data as possible.')
                     .'</p>'
                     .'<p><input type="submit" value="'
@@ -2176,9 +2187,7 @@
         $r->print(&Apache::lonhtmlcommon::row_title(&mt('Target'))
                  .'<tt>'.$thisdistarget.'</tt>'
                  );
-# SB - ToDo:   
 	if (($cuname ne $env{'user.name'})||($cudom ne $env{'user.domain'})) {
-#           $r->print(&Apache::lonhtmlcommon::row_title('<span class="LC_warning">'.&mt('Co-Author').'</span>')
             $r->print(&Apache::lonhtmlcommon::row_closure()
                      .&Apache::lonhtmlcommon::row_title(&mt('Co-Author'))
                      .'<span class="LC_warning">'
@@ -2211,7 +2220,7 @@
 	    unless ($errorcount) {
 		my ($outstring,$error)=
 		    &publish($thisfn,$thistarget,$thisembstyle);
-		$r->print('<hr />'.$outstring);
+		$r->print($outstring);
 	    } else {
 		$r->print('<h3 class="LC_error">'.
 			  &mt('The document contains errors and cannot be published.').