--- loncom/xml/londefdef.pm 2023/03/25 18:38:27 1.470 +++ loncom/xml/londefdef.pm 2024/04/14 17:12:28 1.475 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.470 2023/03/25 18:38:27 raeburn Exp $ +# $Id: londefdef.pm,v 1.475 2024/04/14 17:12:28 raeburn Exp $ # # # Copyright Michigan State University Board of Trustees @@ -50,7 +50,7 @@ use Apache::lonlocal; use Apache::loncommon(); use Apache::Constants qw(:common); use File::Basename; -use LONCAPA(); +use LONCAPA; # use Data::Dumper; BEGIN { @@ -591,9 +591,18 @@ sub start_body { &Apache::lonhtmlcommon::clear_breadcrumbs(); if ($env{'request.state'} eq 'construct') { my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'}); + my $text = 'Authoring Space'; + my $href = &Apache::loncommon::authorspace($url); + if ($env{'request.course.id'}) { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if ($href eq "/priv/$cdom/$cnum/") { + $text = 'Course Authoring Space'; + } + } &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Authoring Space', - 'href' => &Apache::loncommon::authorspace($url), + 'text' => $text, + 'href' => $href, }); &Apache::lonhtmlcommon::add_breadcrumb({ 'text' => 'HTML Editor', @@ -612,6 +621,9 @@ sub start_body { if ($env{'request.use_absolute'}) { $args->{'use_absolute'} = $env{'request.use_absolute'}; } + if ($env{'form.only_body'}) { + $args->{'only_body'} = 1; + } } $currentstring = &Apache::loncommon::start_page($Apache::londefdef::title, @@ -646,9 +658,10 @@ sub start_body { sub edit_controls { my ($nochgview) = @_; - my $result .= ' + my ($is_course_doc,$is_supp,$supp_path,$supp_title); + my $result = '
-
'; +
'."\n"; unless ($nochgview) { $result .= '
'. @@ -657,12 +670,20 @@ sub edit_controls {
'; } $result .= ' -
'; +
+ +'."\n"; if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) { my $uri = $env{'request.uri'}; - my $daxeurl = '/daxepage'.$uri; - $result .= ''; + if ($uri =~ /\.(xml|html|htm|xhtml|xhtm)$/) { + my %editors = &Apache::loncommon::permitted_editors($uri); + if ($editors{'daxe'}) { + my $daxeurl = '/daxepage'.$uri; + $result .= ''."\n"; + } + } } if (($env{'request.course.id'}) && ($env{'form.forceedit'})) { my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'}); @@ -671,11 +692,19 @@ sub edit_controls { if ($env{'request.course.id'}) { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($url =~ m{^\Q/uploaded/$cdom/$cnum/\E(supplemental|docs)/}) { + if ($1 eq 'supplemental') { + $is_supp = 1; + } + $is_course_doc = 1; + } if ($env{'request.filename'} =~ m{/userfiles/supplemental/default|\d+/}) { - if (&Apache::lonnet::is_course_upload($env{'request.filename'}, - $cnum,$cdom)) { + my $fn=&Apache::lonnet::declutter($env{'request.filename'}); + if (&Apache::lonnet::is_course_upload($fn,$cnum,$cdom)) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['folderpath','title']); + $supp_path = &escape(&HTML::Entities::decode($Apache::lonnet::env{'form.folderpath'})); + $supp_title = &escape(&HTML::Entities::decode($Apache::lonnet::env{'form.title'})); } } } @@ -703,7 +732,9 @@ sub edit_controls {
'; - return $result; + my $setedit_js = &Apache::lonxml::seteditor_javascript($is_course_doc,$is_supp, + $supp_path,$supp_title); + return $setedit_js."\n".$result; } sub end_body { @@ -4313,10 +4344,10 @@ sub resize_image { $height_param=$TeXwidth/$old_width_param*$height_param; } } elsif ($TeXheight) { - $height_param = $TeXheight; if ($height_param) { $width_param = $TeXheight/$height_param*$width_param; } + $height_param = $TeXheight; } elsif ($width) { my $old_width_param=$width_param; $width_param = $width*$scaling;