--- loncom/interface/lonsyllabus.pm 2013/04/24 02:43:59 1.117
+++ loncom/interface/lonsyllabus.pm 2013/05/05 02:21:20 1.119
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Syllabus
#
-# $Id: lonsyllabus.pm,v 1.117 2013/04/24 02:43:59 raeburn Exp $
+# $Id: lonsyllabus.pm,v 1.119 2013/05/05 02:21:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -522,15 +522,16 @@ ENDSCRIPT
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 $link = $protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri;
+ $r->print(''
+ .''
+ .''
+ .&mt('Public link (no log-in): [_1]',''.$link.'')
+ .' '.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
+ .''
+ .'
');
my $lonhost = $r->dir_config('lonHostID');
- $r->print(&chooser($external,$uploaded,$lonhost,\%syllabusfields,\%syllabus));
+ $r->print(&chooser($external,$uploaded,$cdom,$cnum,$lonhost,\%syllabusfields,\%syllabus));
}
} else {
#--------------------------------------------- Print last update unless editing
@@ -737,7 +738,7 @@ ENDSCRIPT
}
sub chooser {
- my ($external,$uploaded,$lonhost,$fields,$values) = @_;
+ my ($external,$uploaded,$cdom,$cnum,$lonhost,$fields,$values) = @_;
my %lt = &Apache::lonlocal::texthash(
'type' => 'Syllabus Type',
'url' => 'External URL',
@@ -797,9 +798,36 @@ sub chooser {
$protocol = 'http' if ($protocol ne 'https');
my $absurl = $protocol.'://'.&Apache::lonnet::hostname($lonhost).$uploaded;
my ($filename) = ($uploaded =~ m{([^/]+)$});
+ my $file=&Apache::lonnet::filelocation("",$uploaded);
+ my $depbutton;
+ if ($file =~ /\.html?$/) {
+ my $filecontents=&Apache::lonnet::getfile($file);
+ unless ($filecontents eq -1) {
+ my $mm = new File::MMagic;
+ my $mimetype = $mm->checktype_contents($filecontents);
+ if ($mimetype eq 'text/html') {
+ my (%codebase,%allfiles);
+ my $parse_result = &Apache::lonnet::extract_embedded_items($uploaded,\%allfiles,
+ \%codebase,\$filecontents);
+ my $actionurl = "/public/$cdom/$cnum/syllabus";
+ my ($ignore,$num,$numpathchanges,$existing,$mapping) =
+ &Apache::loncommon::ask_for_embedded_content($actionurl,undef,\%allfiles,
+ \%codebase,
+ {'context' => 'rewrites',
+ 'ignore_remote_references' => 1,});
+ if (keys(%allfiles)) {
+ $depbutton = (' ' x 3).
+ &editfile_button().
+ &editbutton_js($uploaded);
+ }
+ }
+ }
+ }
+
$output .= ''.$lt{'curr'}.' '.
''.
- ''.$filename.'
'.$lt{'rep'};
+ ''.$filename.''.$depbutton.
+ '
'.$lt{'rep'};
} else {
$output .= $lt{'upl'};
}
@@ -960,5 +988,25 @@ sub return_to_editor {
'';
}
+sub editfile_button {
+ my $buttontext=&mt('Edit');
+ return <<"END";
+
+END
+}
+
+sub editbutton_js {
+ my ($url) = @_;
+ return <
+ //
+
+ENDJS
+}
+
1;
__END__