');
+ }
+ } elsif ($env{'form.storefile'}) {
+ # Process file upload - phase one - upload and parse primary file.
+ my %allfiles = ();
+ my %codebase = ();
+ my ($upload_result,$upload_output,$uploadphase);
+ if ($env{'form.syllabusfile.filename'}) {
+ my ($url,$needlink) = &process_upload(\$upload_output,$cnum,$cdom,
+ \%allfiles,\%codebase);
+ $r->print($upload_output);
+ if ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E.*/[^/]+$}) {
+ my $exturl;
+ my $home=&Apache::lonnet::homeserver($cnum,$cdom);
+ if ($home ne 'no_host') {
+ my $protocol = $Apache::lonnet::protocol{$home};
+ $protocol = 'http' if ($protocol ne 'https');
+ $exturl = $protocol.'://'.&Apache::lonnet::hostname($home).$url;
+ }
+ my %storehash = (
+ uploadedsyllabus => $url,
+ );
+ if ($exturl) {
+ $storehash{'externalsyllabus'} = $exturl;
+ if ($exturl =~ /\.(html?|txt|js|css)$/) {
+ $exturl .= '?inhibitmenu=yes';
+ }
+ } else {
+ $storehash{'externalsyllabus'} = '',
+ }
+ my $putres =
+ &Apache::lonnet::put('environment',\%storehash,$cdom,$cnum);
+ if ($putres eq 'ok') {
+ &Apache::lonnet::make_public_indefinitely($url);
+ foreach my $key (keys(%storehash)) {
+ &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash{$key}});
+ }
+ $uploaded = $url;
+ if ($needlink) {
+ $r->print(&return_to_editor($cdom,$cnum).
+ &Apache::loncommon::end_page());
+ return OK;
+ }
+ }
+ }
+ }
+ } elsif ($env{'form.phase'} eq 'upload_embedded') {
+ # Process file upload - phase two - upload embedded objects
+ my $uploadphase = 'check_embedded';
+ my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
+ my $state = &embedded_form_elems($uploadphase,$primaryurl);
+ my $url_root = '/uploaded/'.$cdom.'/'.$cnum;
+ my $actionurl = "/public/$cdom/$cnum/syllabus";
+ my ($result,$flag,$numpathchgs) =
+ &Apache::loncommon::upload_embedded('syllabus','portfolio/syllabus',
+ $cnum,$cdom,'/userfiles',$url_root,undef,undef,undef,$state,
+ $actionurl);
+ unless ($numpathchgs) {
+ my $modres =
+ &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
+ $cnum,$cdom,
+ '/userfiles',$env{'form.primaryurl'});
+ $result .= $modres;
+ }
+ $r->print($result.&return_to_editor($cdom,$cnum).
+ &Apache::loncommon::end_page());
+ return OK;
+ } elsif ($env{'form.phase'} eq 'check_embedded') {
+ # Process file upload - phase three - modify references in HTML file
+ my $uploadphase = 'modified_orightml';
+ my $result =
+ &Apache::loncommon::modify_html_refs('syllabus','portfolio/syllabus',
+ $cnum,$cdom,
+ '/userfiles',$env{'form.primaryurl'});
+ $r->print($result.&return_to_editor($cdom,$cnum).
+ &Apache::loncommon::end_page());
+ return OK;
+ }
+ foreach my $field (keys(%syllabusfields)) {
+ if ($syllabus{$field} ne '') {
+ $displayfields{$field} = ' style="display:block;"';
+ } else {
+ $displayfields{$field} = ' style="display:none;"';
+ }
}
}
-#--------Functions
- if( ($allowed || $privileged) && $target ne 'tex') {
- my $functions=&Apache::lonhtmlcommon::start_funclist();
- if ($allowed) {
- #if you have the register flag, keep it
- if($env{'form.register'} == 1) {
- $functions.=&Apache::lonhtmlcommon::add_item_funclist(
- ''
- .&mt('Show Public View').''
- .&Apache::loncommon::help_open_topic(
- 'Uploaded_Templates_PublicView'));
- } else {
- $functions.=&Apache::lonhtmlcommon::add_item_funclist(
- ''
- .&mt('Show Public View').''
- .&Apache::loncommon::help_open_topic(
- 'Uploaded_Templates_PublicView'));
- }
- } elsif ($privileged) {
- if($env{'form.register'} == 1) {
- $functions.=&Apache::lonhtmlcommon::add_item_funclist(
- ''
- .&mt('Edit').'');
- } else {
- $functions.=&Apache::lonhtmlcommon::add_item_funclist(
- ''
- .&mt('Edit').'');
- }
+ if ($allowed) {
+#---------------------------------- Print External URL Syllabus Info if editing
+ if ($target ne 'tex') {
+ my $protocol = $Apache::lonnet::protocol{$homeserver};
+ $protocol = 'http' if ($protocol ne 'https');
+ $r->print('
'
+ .'
'
+ .&mt('This syllabus can be publicly viewed at [_1]'
+ ,''.$protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri.'')
+ .' '.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
+ .'
'
+ .'
');
+ my $lonhost = $r->dir_config('lonHostID');
+ $r->print(&chooser($external,$uploaded,$cdom,$cnum,$lonhost,\%syllabusfields,\%syllabus));
}
-
- $functions.=&Apache::lonhtmlcommon::end_funclist();
- $r->print(&Apache::loncommon::head_subbox($functions));
- }
-
-#---------------------Print External URL Syllabus Info and Help Text
- if( ($allowed) && ($target ne 'tex') ) {
- my $protocol = $Apache::lonnet::protocol{$homeserver};
- $protocol = 'http' if ($protocol ne 'https');
- $r->print('
'
- .&mt('This syllabus can be publicly viewed at [_1]'
- ,''.$protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri.'')
- .' '.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
- .'
'
- .'
'
- .&mt('Instead of using this template you can specify an external URL as Syllabus in the [_1]Course Configuration[_2].'
- ,'','')
- .'
'
- );
- #-Print Help Text
- $r->print(&Apache::loncommon::help_open_topic(
- 'Uploaded_Templates_TextBoxes',
- &mt('Help with filling in text boxes')));
- }
-
-#----------Print last update
- my $lastmod=$syllabus{'uploaded.lastmodified'};
- $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
- my $who;
- if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) {
- $who = &Apache::loncommon::aboutmewrapper(
- &Apache::loncommon::plainname($syllabus{'uploaded.name'},
- $syllabus{'uploaded.domain'}),$syllabus{'uploaded.name'},
- $syllabus{'uploaded.domain'});
} else {
- # Public user?
- # Only display name of user, but no link to personal information page
- $who = &Apache::loncommon::plainname(
- $syllabus{'uploaded.name'},
- $syllabus{'uploaded.domain'});
- }
-
- if ($target ne 'tex') {
- $r->print('
'.&mt('Last updated').': '.
- $lastmod . ' '.
- ($who ? &mt('by').' '.$who
+#--------------------------------------------- Print last update unless editing
+ my $lastmod=$syllabus{'uploaded.lastmodified'};
+ $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
+ my $who;
+ if ($syllabus{'uploaded.lastmodified'}) {
+ if (($env{'user.name'} ne 'public') && ($env{'user.domain'} ne 'public')) {
+ $who = &Apache::loncommon::aboutmewrapper(
+ &Apache::loncommon::plainname($syllabus{'uploaded.name'},
+ $syllabus{'uploaded.domain'}),$syllabus{'uploaded.name'},
+ $syllabus{'uploaded.domain'});
+ } else {
+# Public user?
+# Only display name of user, but no link to personal information page
+ $who = &Apache::loncommon::plainname(
+ $syllabus{'uploaded.name'},
+ $syllabus{'uploaded.domain'});
+ }
+ }
+ if ($target ne 'tex') {
+ $r->print('