[LON-CAPA-cvs] cvs: loncom /interface lonsimplepage.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Tue, 11 May 2004 18:43:21 -0000
This is a MIME encoded message
--sakharuk1084301001
Content-Type: text/plain
sakharuk Tue May 11 14:43:21 2004 EDT
Modified files:
/loncom/interface lonsimplepage.pm
Log:
Now allows to print pictures. + some additional cleanup.
--sakharuk1084301001
Content-Type: text/plain
Content-Disposition: attachment; filename="sakharuk-20040511144321.txt"
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.17 loncom/interface/lonsimplepage.pm:1.18
--- loncom/interface/lonsimplepage.pm:1.17 Fri Apr 30 19:13:52 2004
+++ loncom/interface/lonsimplepage.pm Tue May 11 14:43:21 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Simple Page Editor
#
-# $Id: lonsimplepage.pm,v 1.17 2004/04/30 23:13:52 albertel Exp $
+# $Id: lonsimplepage.pm,v 1.18 2004/05/11 18:43:21 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,9 +43,9 @@
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
-
+ my $target=$ENV{'form.grade_target'};
# ------------------------------------------------------------ Print the screen
- if ($ENV{'form.grade_target'} ne 'tex') {
+ if ($target ne 'tex') {
$r->print(<<ENDDOCUMENT);
<html>
<head>
@@ -57,7 +57,7 @@
my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
# Is this even in a course?
unless ($ENV{'request.course.id'}) {
- if ($ENV{'form.grade_target'} ne 'tex') {
+ if ($target ne 'tex') {
$r->print('</head><body>Not in a course</body></html>');
return OK;
} else {
@@ -94,7 +94,7 @@
}
# --------------------------------------------------------------- Force Student
my $forcestudent='';
- if ($ENV{'form.forcestudent'} ||$ENV{'form.grade_target'} eq 'tex' ) { $forcestudent='student'; };
+ if ($ENV{'form.forcestudent'} || $target eq 'tex' ) { $forcestudent='student'; };
my $forceedit='';
if ($ENV{'form.forceedit'}) { $forceedit='edit'; }
@@ -103,7 +103,7 @@
# --------------------------------------- There is such a user, get environment
- if ($ENV{'form.grade_target'} ne 'tex') {
+ if ($target ne 'tex') {
$r->print('</head>'.&Apache::loncommon::bodytag
("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'}));
}
@@ -114,119 +114,122 @@
$forcestudent='student';
}
- if ($forcestudent) { $allowed=0; }
-
- if ($ENV{'form.grade_target'} ne 'tex') {
- if ($allowed) {
- $r->print('<p>'.
- &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">'.&mt('Show Student View').'</font></a>'.
- &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
- } elsif ($privileged) {
- $r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'.&mt('Edit').'</font></a>');
- }
- }
- if (($ENV{'form.uploaddoc.filename'}) &&
- ($ENV{'form.storeupl'}) && ($allowed)) {
- if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
- if ($syllabus{'uploaded.photourl'}) {
- &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
- }
- $syllabus{'uploaded.photourl'}=
- &Apache::lonnet::userfileupload('uploaddoc',1,'simplepage');
- }
- $syllabus{'uploaded.lastmodified'}=time;
- &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
- }
- if (($allowed) && ($ENV{'form.storesyl'})) {
- foreach (keys %syllabusfields) {
- my $field=$ENV{'form.'.$_};
- $field=~s/\s+$//s;
- $field=&Apache::lonfeedback::clear_out_html($field,1);
- $syllabus{$_}=$field;
- }
- $syllabus{'uploaded.lastmodified'}=time;
- &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
- }
+ if ($forcestudent or $target eq 'tex') { $allowed=0; }
+
+ if ($allowed) {
+ $r->print('<p>'.
+ &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">'.&mt('Show Student View').'</font></a>'.
+ &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
+ } elsif ($privileged and $target ne 'tex') {
+ $r->print('<a href="'.$r->uri.'?forceedit=edit"><font size="+1">'.&mt('Edit').'</font></a>');
+ }
+ if (($ENV{'form.uploaddoc.filename'} and $target ne 'tex') &&
+ ($ENV{'form.storeupl'}) && ($allowed)) {
+ if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
+ if ($syllabus{'uploaded.photourl'}) {
+ &Apache::lonnet::removeuploadedurl($syllabus{'uploaded.photourl'});
+ }
+ $syllabus{'uploaded.photourl'}=
+ &Apache::lonnet::userfileupload('uploaddoc',1,'simplepage');
+ }
+ $syllabus{'uploaded.lastmodified'}=time;
+ &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
+ }
+ if (($allowed) && ($ENV{'form.storesyl'})) {
+ foreach (keys %syllabusfields) {
+ my $field=$ENV{'form.'.$_};
+ $field=~s/\s+$//s;
+ $field=&Apache::lonfeedback::clear_out_html($field,1);
+ $syllabus{$_}=$field;
+ }
+ $syllabus{'uploaded.lastmodified'}=time;
+ &Apache::lonnet::put('smppage_'.$marker,\%syllabus,$dom,$crs);
+ }
# ---------------------------------------------------------------- Get syllabus
if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
- if ($syllabus{'uploaded.photourl'}) {
- if ($ENV{'form.grade_target'} ne 'tex') {
- &Apache::lonnet::allowuploaded('/adm/smppg',
- $syllabus{'uploaded.photourl'});
- $r->print('<img src="'.$syllabus{'uploaded.photourl'}.
- '" align="right" />');
- }
- }
- if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {
- $r->print(
- '<form method="post" enctype="multipart/form-data">'.
- '<input type="hidden" name="forceedit" value="edit" />'.
- '<h3>Upload a Photo</h3>'.
- '<input type="file" name="uploaddoc" size="50">'.
- '<input type="submit" name="storeupl" value="Upload">'.
- '</form><form method="post">');
- }
- foreach (sort keys %syllabusfields) {
- if (($syllabus{$_}) || ($allowed)) {
- my $message=$syllabus{$_};
- $message=~s/\n/\<br \/\>/g;
- $message
- =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
- $message=&Apache::lontexconvert::msgtexconverted($message);
- unless ($_ eq 'aaa_title') {
- if (($_ ne 'bbb_content') || ($allowed)) {
- if ($ENV{'form.grade_target'} ne 'tex') {
- $r->print('<h3>'.$syllabusfields{$_}.'</h3>');
- } else {
- my $safeinit;
- $r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>'));
+ if ($syllabus{'uploaded.photourl'}) {
+ if ($target ne 'tex') {
+ &Apache::lonnet::allowuploaded('/adm/smppg',
+ $syllabus{'uploaded.photourl'});
+ $r->print('<img src="'.$syllabus{'uploaded.photourl'}.
+ '" align="right" />');
+ } else {
+ &Apache::lonnet::allowuploaded('/adm/smppg',
+ $syllabus{'uploaded.photourl'});
+ $r->print(&Apache::lonxml::xmlparse($r,'tex','<img src="'.$syllabus{'uploaded.photourl'}.
+ '" align="right" />'));
+ }
+ }
+ if ($allowed) {
+ $r->print(
+ '<form method="post" enctype="multipart/form-data">'.
+ '<input type="hidden" name="forceedit" value="edit" />'.
+ '<h3>Upload a Photo</h3>'.
+ '<input type="file" name="uploaddoc" size="50">'.
+ '<input type="submit" name="storeupl" value="Upload">'.
+ '</form><form method="post">');
+ }
+ foreach (sort keys %syllabusfields) {
+ if (($syllabus{$_}) || ($allowed)) {
+ my $message=$syllabus{$_};
+ $message=~s/\n/\<br \/\>/g;
+ $message
+ =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
+ $message=&Apache::lontexconvert::msgtexconverted($message);
+ unless ($_ eq 'aaa_title') {
+ if (($_ ne 'bbb_content') || ($allowed)) {
+ if ($target ne 'tex') {
+ $r->print('<h3>'.$syllabusfields{$_}.'</h3>');
+ } else {
+ my $safeinit;
+ $r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>'));
+ }
}
- }
- if ($ENV{'form.grade_target'} ne 'tex') {
- $r->print('<blockquote>'.
- $message.'</blockquote>');
- } else {
+ if ($target ne 'tex') {
+ $r->print('<blockquote>'.
+ $message.'</blockquote>');
+ } else {
my $safeinit;
$r->print(&Apache::lonxml::xmlparse($r,'tex',$message));
- }
- if ($allowed) {
- if ($ENV{'form.grade_target'} ne 'tex') {
- $r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'.
- $syllabus{$_}.
- '</textarea><input type="submit" name="storesyl" value="Store" />');
- } else {
- my $safeinit;
- $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
- }
- }
- } else {
- if ($ENV{'form.grade_target'} ne 'tex') {
- $r->print('<h1>'.$message.'</h1>');
+ }
+ if ($allowed) {
+ if ($target ne 'tex') {
+ $r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'.
+ $syllabus{$_}.
+ '</textarea><input type="submit" name="storesyl" value="Store" />');
+ } else {
+ my $safeinit;
+ $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
+ }
+ }
} else {
- my $safeinit;
- $r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>'));
- }
- if ($allowed) {
- if ($ENV{'form.grade_target'} ne 'tex') {
- $r->print(
- '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.
- $syllabus{$_}.
- '</textarea><input type="submit" name="storesyl" value="Store" />');
+ if ($target ne 'tex') {
+ $r->print('<h1>'.$message.'</h1>');
} else {
my $safeinit;
- $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
+ $r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>'));
+ }
+ if ($allowed) {
+ if ($ENV{'form.grade_target'} ne 'tex') {
+ $r->print(
+ '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.
+ $syllabus{$_}.
+ '</textarea><input type="submit" name="storesyl" value="Store" />');
+ } else {
+ my $safeinit;
+ $r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
+ }
}
- }
- }
- }
- }
- if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {
- $r->print('</form>');
- }
- if ($ENV{'form.grade_target'} ne 'tex') {$r->print('</p>');}
+ }
+ }
+ }
+ if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {
+ $r->print('</form>');
+ }
+ if ($ENV{'form.grade_target'} ne 'tex') {$r->print('</p>');}
} else {
- $r->print('<p>No page information provided.</p>');
+ $r->print('<p>No page information provided.</p>');
}
if ($ENV{'form.grade_target'} ne 'tex') {
$r->print('</body></html>');
--sakharuk1084301001--