--- loncom/publisher/lonpublisher.pm 2008/05/12 23:47:49 1.234
+++ loncom/publisher/lonpublisher.pm 2008/07/26 16:03:46 1.240
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.234 2008/05/12 23:47:49 www Exp $
+# $Id: lonpublisher.pm,v 1.240 2008/07/26 16:03:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -274,7 +274,7 @@ sub metaread {
}
&metaeval($metastring,$prefix);
return '
'.&mt('Processed file').': '.
- &Apache::loncfile::display($fn).'';
+ &Apache::loncfile::display($fn).'
';
}
#########################################
@@ -325,30 +325,34 @@ string which presents the form field (fo
#########################################
#########################################
sub textfield {
- my ($title,$name,$value)=@_;
+ my ($title,$name,$value,$noline)=@_;
$value=~s/^\s+//gs;
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
$title=&mt($title);
$env{'form.'.$name}=$value;
- return "\n
$title:".
- "
".
- '';
+ return "\n".&Apache::lonhtmlcommon::row_title($title)
+ .''
+ .&Apache::lonhtmlcommon::row_closure($noline);
}
sub text_with_browse_field {
- my ($title,$name,$value,$restriction)=@_;
+ my ($title,$name,$value,$restriction,$noline)=@_;
$value=~s/^\s+//gs;
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
$title=&mt($title);
$env{'form.'.$name}=$value;
- return "\n$title:".
- "
".
- ''.
- ''.&mt('Select').' '.
- ''.&mt('Search').'';
-
+ return "\n".&Apache::lonhtmlcommon::row_title($title)
+ .''
+ .'
'
+ .''
+ .&mt('Select')
+ .' '
+ .''
+ .&mt('Search')
+ .''
+ .&Apache::lonhtmlcommon::row_closure($noline);
}
sub hiddenfield {
@@ -372,8 +376,8 @@ sub selectbox {
} else {
$env{'form.'.$name}=$idlist[0];
}
- my $selout="\n$title:".
- '
'.&Apache::lonhtmlcommon::row_closure();
+ return $selout;
}
sub select_level_form {
@@ -665,6 +670,7 @@ sub fix_ids_and_indices {
"Max Index: $maxindex (min 10)\n";
}
my $outstring='';
+ my $responsecounter=1;
my @parser;
$parser[0]=HTML::LCParser->new(\$content);
$parser[-1]->xml_mode(1);
@@ -680,6 +686,10 @@ sub fix_ids_and_indices {
next;
}
if ($lctag eq 'base') { next; }
+ if (($lctag eq 'part') || ($lctag eq 'problem')) {
+ $responsecounter=0;
+ }
+ if ($lctag=~/response$/) { $responsecounter++; }
my %parms=%{$token->[2]};
$counter=$addid{$tag};
if (!$counter) { $counter=$addid{$lctag}; }
@@ -775,7 +785,7 @@ sub fix_ids_and_indices {
}
if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; }
$outstring.='<'.$tag.$newparmstring.$endtag.'>';
- if ($lctag eq 'm' || $lctag eq 'script'
+ if ($lctag eq 'm' || $lctag eq 'script' || $lctag eq 'answer'
|| $lctag eq 'display' || $lctag eq 'tex') {
$outstring.=&get_all_text_unbalanced('/'.$lctag,\@parser);
}
@@ -784,7 +794,12 @@ sub fix_ids_and_indices {
unless ($token->[1] eq 'allow') {
$outstring.=''.$token->[1].'>';
}
- }
+ }
+ if ((($token->[1] eq 'part') || ($token->[1] eq 'problem'))
+ && (!$responsecounter)) {
+ my $outstring=''.&mt('Found [_1] without responses. This resource cannot be published.',$token->[1]).'';
+ return ($outstring,1);
+ }
} else {
$outstring.=$token->[1];
}
@@ -840,8 +855,7 @@ sub store_metadata {
return ($error,undef);
}
my $dbh = &Apache::lonmysql::get_dbh();
- if (($metadata{'obsolete'}) || ($metadata{'copyright'} eq 'priv') ||
- ($metadata{'copyright'} eq 'custom')) {
+ if (($metadata{'obsolete'}) || ($metadata{'copyright'} eq 'priv')) {
# remove this entry
my $delitem = 'url = '.$dbh->quote($metadata{'url'});
$status = &LONCAPA::lonmetadata::delete_metadata($dbh,undef,$delitem);
@@ -954,7 +968,7 @@ sub publish {
print $logfile "Copied original file to ".$copyfile."\n";
} else {
print $logfile "Unable to write backup ".$copyfile.':'.$!."\n";
- return ("Failed to write backup copy, $!,FAIL",1);
+ return ("".&mt("Failed to write backup copy, [_1], FAIL",$1)."",1);
}
# ------------------------------------------------------------- IDs and indices
@@ -1030,7 +1044,7 @@ sub publish {
unless ($batch) {
$scrout.=''.&mt('Metadata Information').' ' .
- Apache::loncommon::help_open_topic("Metadata_Description")
+ &Apache::loncommon::help_open_topic("Metadata_Description")
. '
';
}
@@ -1181,9 +1195,18 @@ sub publish {
# $env{'from.'..} so that it can be used by the phase two handler in
# batch mode
- my $intr_scrout.=
- '';
+ $scrout.=$intr_scrout
+ .&Apache::lonhtmlcommon::end_pick_box()
+ .''
+ .'';
}
return($scrout,0);
}
@@ -1579,7 +1601,7 @@ sub phasetwo {
unless ($srcd=~/^\/home\/httpd\/html\/res/) {
print $logfile "\nPANIC: Target dir is ".$srcd;
$r->print(
- "Invalid target directory, FAIL");
+ "".&mt('Invalid target directory, FAIL')."");
return 0;
}
opendir(DIR,$srcd);
@@ -1701,7 +1723,7 @@ sub phasetwo {
$r->print(
'
'.
&mt('View Published Version').''.
- ''.
+ ''.
&mt('Back to Source').'
'.
''.
@@ -2104,28 +2126,55 @@ sub handler {
my $thistype=$1;
my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);
if ($thistype eq 'page') { $thisembstyle = 'rat'; }
- $r->print(''.&mt('Publishing').' '.
- &Apache::loncommon::filedescription($thistype).' ');
+ $r->print(''.&mt('Publishing [_1]',''.$thisdisfn.'').'
');
+
+ $r->print(''.&mt('Resource Details').'
');
+
+ $r->print(&Apache::lonhtmlcommon::start_pick_box());
+
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Type'))
+ .&Apache::loncommon::filedescription($thistype)
+ .&Apache::lonhtmlcommon::row_closure()
+ );
+
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Link to Resource'))
+ .''
+ );
$r->print(<
$thisdisfn
ENDCAPTION
- $r->print(''.&mt('Target').': '.
- $thisdistarget.'
');
-
+ $r->print(''
+ .&Apache::lonhtmlcommon::row_closure()
+ );
+
+ $r->print(&Apache::lonhtmlcommon::row_title(&mt('Target'))
+ .''.$thisdistarget.''
+ );
+# SB - ToDo:
if (($cuname ne $env{'user.name'})||($cudom ne $env{'user.domain'})) {
- $r->print('
'.&mt('Co-Author').': '.
- $cuname.&mt(' at ').$cudom.'
');
+# $r->print(&Apache::lonhtmlcommon::row_title(''.&mt('Co-Author').'')
+ $r->print(&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(&mt('Co-Author'))
+ .''
+ .&mt('[_1] at [_2]',$cuname,$cudom)
+ .''
+ );
}
if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {
+ $r->print(&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(&mt('Diffs')));
$r->print(<
ENDDIFF
- $r->print(&mt('Diffs with Current Version').'
');
+ $r->print(&mt('Diffs with Current Version').'');
}
+
+ $r->print(&Apache::lonhtmlcommon::row_closure(1)
+ .&Apache::lonhtmlcommon::end_pick_box()
+ );
# ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
@@ -2140,7 +2189,7 @@ ENDDIFF
&publish($thisfn,$thistarget,$thisembstyle);
$r->print('
'.$outstring);
} else {
- $r->print(''.
+ $r->print(''.
&mt('The document contains errors and cannot be published.').
'
');
}