--- loncom/xml/lonxml.pm 2012/05/25 15:01:31 1.531.2.3 +++ loncom/xml/lonxml.pm 2013/06/05 15:39:34 1.531.2.9 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.531.2.3 2012/05/25 15:01:31 raeburn Exp $ +# $Id: lonxml.pm,v 1.531.2.9 2013/06/05 15:39:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -743,9 +743,9 @@ sub setup_globals { sub init_safespace { my ($target,$safeeval,$safehole,$safeinit) = @_; - $safeeval->reval('use Math::Complex;'); $safeeval->reval('use LaTeX::Table;'); $safeeval->deny_only(':dangerous'); + $safeeval->reval('use Math::Complex;'); $safeeval->permit_only(":default"); $safeeval->permit("entereval"); $safeeval->permit(":base_math"); @@ -1604,7 +1604,7 @@ sub renderingoptions { } sub inserteditinfo { - my ($filecontents,$filetype,$filename,$symb,$itemtitle) = @_; + my ($filecontents,$filetype,$filename,$symb,$itemtitle,$folderpath,$uri) = @_; $filecontents = &HTML::Entities::encode($filecontents,'<>&"'); my $xml_help = ''; my $initialize=''; @@ -1629,11 +1629,32 @@ sub inserteditinfo { // ]]> FULLPAGE + my $textareaclass; if ($filetype eq 'html') { - if ($symb) { - $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n"; - $initialize .= - &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle)."\n"; + my $context; + if ($env{'request.course.id'}) { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E}) { + $context = 'syllabus'; + $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n"; + $initialize .= + &Apache::lonhtmlcommon::dependencycheck_js(undef,&mt('Syllabus'), + $uri,undef, + "/public/$cdom/$cnum/syllabus"). + "\n"; + if (&Apache::lonhtmlcommon::htmlareabrowser()) { + $textareaclass = 'class="LC_richDefaultOn"'; + } + } + } + unless ($context eq 'syllabus') { + if ($symb || $folderpath) { + $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n"; + $initialize .= + &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle, + undef,$folderpath,$uri)."\n"; + } } $dragmath_button = ''.&Apache::lonhtmlcommon::dragmath_button('filecont',1).''; $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup'); @@ -1646,7 +1667,6 @@ FULLPAGE } my $titledisplay=&display_title(); - my $textareaclass; my %lt=&Apache::lonlocal::texthash('st' => 'Save and Edit', 'vi' => 'Save and View', 'dv' => 'Discard Edits and View', @@ -1662,7 +1682,9 @@ FULLPAGE $htmlerror=''.$htmlerror.''; } if (&Apache::lonhtmlcommon::htmlareabrowser()) { - $textareaclass = 'class="LC_richDefaultOff"'; + unless ($textareaclass) { + $textareaclass = 'class="LC_richDefaultOff"'; + } } } my $editfooter=(<uri; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['todocs']); + } + my ($cdom,$cnum); + if ($env{'request.course.id'}) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($filetype eq 'html') { + if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E.+$}) { + if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['editmode']); + } + } + } + } if ($filetype eq 'sty') { $breadcrumbtext = 'Style File Editor'; } elsif ($filetype eq 'js') { @@ -1865,7 +1905,7 @@ ENDNOTFOUND my $brcrum; if ($env{'request.state'} eq 'construct') { $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), - 'text' => 'Construction Space'}, + 'text' => 'Authoring Space'}, {'href' => '', 'text' => $breadcrumbtext}]; } else { @@ -1891,14 +1931,33 @@ ENDNOTFOUND my ($displayfile,$url,$symb,$itemtitle); $displayfile=$request->uri; if ($request->uri =~ m{^/uploaded/}) { - ($symb,$itemtitle,$displayfile) = - &get_courseupload_hierarchy($request->uri); + if ($env{'request.course.id'}) { + if ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/supplemental/\E}) { + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['folderpath','title']); + } elsif ($request->uri =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) { + my $filename = $1; + if ($1 eq 'loncapa.html') { + $displayfile = &mt('Syllabus (minimal template)'); + } else { + $displayfile = &mt('Syllabus file: [_1]',$1); + } + $itemtitle = &mt('Syllabus'); + } + } + unless ($itemtitle) { + ($symb,$itemtitle,$displayfile) = + &get_courseupload_hierarchy($request->uri, + $env{'form.folderpath'}, + $env{'form.title'}); + } } else { $displayfile=~s/^\/[^\/]*//; } my ($edit_info, $add_to_onload, $add_to_onresize)= - &inserteditinfo($filecontents,$filetype,$displayfile,$symb,$itemtitle); + &inserteditinfo($filecontents,$filetype,$displayfile,$symb, + $itemtitle,$env{'form.folderpath'},$request->uri); my %options = ('add_entries' => @@ -1908,7 +1967,7 @@ ENDNOTFOUND if ($env{'request.state'} eq 'construct') { $options{'bread_crumbs'} = [{ 'href' => &Apache::loncommon::authorspace($request->uri), - 'text' => 'Construction Space'}, + 'text' => 'Authoring Space'}, {'href' => '', 'text' => $breadcrumbtext}]; $header = &Apache::loncommon::head_subbox( @@ -1943,26 +2002,41 @@ sub display_title { $title = substr($title, rindex($title, '/') + 1); } $result = ""; + .&mt('Authoring Space')."';"; } return $result; } sub get_courseupload_hierarchy { - my ($url) = @_; + my ($url,$folderpath,$title) = @_; my ($symb,$itemtitle,$displaypath); if ($env{'request.course.id'}) { - $symb = &Apache::lonnet::symbread(); - my ($map,$id,$res)=&Apache::lonnet::decode_symb($symb); - my $navmap=Apache::lonnavmaps::navmap->new; - if (ref($navmap)) { - my $res = $navmap->getBySymb($symb); - if (ref($res)) { - my @pathitems = - &Apache::loncommon::get_folder_hierarchy($navmap,$map,1); - $itemtitle = $res->compTitle(); - push(@pathitems,$itemtitle); - $displaypath = join(' » ',@pathitems); + if ($folderpath =~ /^supplemental/) { + my @folders = split(/\&/,$folderpath); + my @pathitems; + while (@folders) { + my $folder=shift(@folders); + my $foldername=shift(@folders); + $foldername =~ s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//; + push(@pathitems,&unescape($foldername)); + } + if ($title) { + push(@pathitems,&unescape($title)); + } + $displaypath = join(' » ',@pathitems); + } else { + $symb = &Apache::lonnet::symbread($url); + my ($map,$id,$res)=&Apache::lonnet::decode_symb($symb); + my $navmap=Apache::lonnavmaps::navmap->new; + if (ref($navmap)) { + my $res = $navmap->getBySymb($symb); + if (ref($res)) { + my @pathitems = + &Apache::loncommon::get_folder_hierarchy($navmap,$map,1); + $itemtitle = $res->compTitle(); + push(@pathitems,$itemtitle); + $displaypath = join(' » ',@pathitems); + } } } } @@ -2119,13 +2193,18 @@ sub add_messages { } sub get_param { - my ($param,$parstack,$safeeval,$context,$case_insensitive) = @_; + my ($param,$parstack,$safeeval,$context,$case_insensitive, $noelide) = @_; if ( ! $context ) { $context = -1; } my $args =''; if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; } if ( ! $Apache::lonxml::usestyle ) { $args=$Apache::lonxml::style_values.$args; } + + if ($noelide) { + $args =~ s/'\$/'\\\$/g; + } + if ( ! $args ) { return undef; } if ( $case_insensitive ) { if ($args =~ s/(my (?:.*))(\$\Q$param\E[,\)])/$1.lc($2)/ei) {