[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Wed, 13 Aug 2003 19:40:07 -0000
This is a MIME encoded message
--albertel1060803607
Content-Type: text/plain
albertel Wed Aug 13 15:40:07 2003 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
- get_name now properly handles no set name case (can remove the other random code trying to do this)
- added get_course, modified all locations to use get_course
- modified all locations to not put a - on the top of the page if there isn't a current course (CSTR for instance)
--albertel1060803607
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20030813154007.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.212 loncom/interface/lonprintout.pm:1.213
--- loncom/interface/lonprintout.pm:1.212 Wed Aug 13 15:38:16 2003
+++ loncom/interface/lonprintout.pm Wed Aug 13 15:40:07 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.212 2003/08/13 19:38:16 albertel Exp $
+# $Id: lonprintout.pm,v 1.213 2003/08/13 19:40:07 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -467,32 +467,38 @@
if (!defined($uname)) { $uname=$ENV{'user.name'}; }
if (!defined($udom)) { $udom=$ENV{'user.domain'}; }
my $plainname=&Apache::loncommon::plainname($uname,$udom);
- if ($plainname=~/^\s*$/) { $plainname=$uname; }
- return &Apache::lonxml::latex_special_symbols($plainname,'header');
+ if ($plainname=~/^\s*$/) { $plainname=$uname.'@'.$udom; }
+ $plainname=&Apache::lonxml::latex_special_symbols($plainname,'header');
+ return $plainname;
}
+sub get_course {
+ my $courseidinfo;
+ if (defined($ENV{'request.course.id'})) {
+ $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'header');
+ }
+ return $courseidinfo;
+}
sub page_format_transformation {
my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents) = @_;
my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin);
- $assignment=~s/_/ /g;
- if ($numberofcolumns != 1) {
- ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin);
- } else {
- ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'});
- }
- my $name = &get_name();
- if ($name =~ /^\s*$/) {
- $name=&Apache::lonxml::latex_special_symbols($ENV{'user.name'},'header');
+ $assignment=~s/_/ /g;
+ if ($numberofcolumns != 1) {
+ ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin);
+ } else {
+ ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'});
}
- my $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'header');
+ my $name = &get_name();
+ my $courseidinfo = &get_course();
+ if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
if ($layout eq 'album') {
my $topmargintoinsert = '';
if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';}
- $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}} \\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1} /;
+ $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}} \\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1} /;
} elsif ($layout eq 'book') {
if ($choice ne 'All class print') {
- $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
+ $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
} else {
$text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1} \\vskip 5 mm /;
}
@@ -710,13 +716,11 @@
}
# $result .= $texversion;
if (($selectionmade == 4) and ($assignment ne $prevassignment) and ($i>=1)) {
- my $name = &get_name();
- if ($name =~ /^\s*$/) {
- $name=&Apache::lonxml::latex_special_symbols($ENV{'user.name'},'header');
- }
- my $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'header');
+ my ($name,$courseidinfo) = &get_name;
+ my $courseidinfo = &get_course();
+ if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
$prevassignment=$assignment;
- $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}} - '.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm ';
+ $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm ';
}
$result .= $texversion;
$flag_latex_header_remove = 'YES';
@@ -768,13 +772,15 @@
$flag_latex_header_remove = 'YES';
}
}
- my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+ my $courseidinfo = &get_course();
+ if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
+
if ($current_output=~/\\documentclass/) {
- $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$helper->{VARS}->{'assignment'}}}\\vskip 3 mm /;
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$helper->{VARS}->{'assignment'}}}\\vskip 3 mm /;
} else {
my $blanspages = '';
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blanspages.='\clearpage\strut\clearpage';}
- $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}} - '.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$helper->{VARS}->{'assignment'}.'}}} \vskip -5 mm '.$current_output;
+ $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$helper->{VARS}->{'assignment'}.'}}} \vskip -5 mm '.$current_output;
}
$result .= $current_output;
&Apache::lonnet::delenv('form.counter');
--albertel1060803607--