[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm lonmenu.pm /lonnet/perl lonnet.pm rat lonwrapper.pm
raeburn
raeburn at source.lon-capa.org
Tue Nov 27 18:45:22 EST 2012
raeburn Tue Nov 27 23:45:22 2012 EDT
Modified files:
/loncom/interface lonhtmlcommon.pm lonmenu.pm
/rat lonwrapper.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Breadcrumbs trail for uploaded content in nested folders in
Supplemental Content.
- Breadcrumbs trail for external resource in Supplemental Content.
- lonwrapper.pm
- more sanity checking in lonwrapper.pm.
- increase offset for iframe when functions box is populated.
-------------- next part --------------
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.331 loncom/interface/lonhtmlcommon.pm:1.332
--- loncom/interface/lonhtmlcommon.pm:1.331 Fri Nov 16 23:37:16 2012
+++ loncom/interface/lonhtmlcommon.pm Tue Nov 27 23:45:08 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.331 2012/11/16 23:37:16 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.332 2012/11/27 23:45:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1505,6 +1505,7 @@
unless ($env{'request.course.id'}) { return 0; }
if ($env{'request.noversionuri'}=~m{^/priv/} ||
$env{'request.uri'}=~m{^/priv/}) { return 1; }
+ return if ($env{'request.noversionuri'} eq '/adm/supplemental');
if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)})
|| ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) {
@@ -1654,7 +1655,7 @@
if ($env{'request.noversionuri'} =~
m{^/public/($match_domain)/($match_courseid)/syllabus$}) {
unless (($env{'course.'.$env{'request.course.id'}.'.domain'} eq $1) &&
- ($env{'course.'.$env{'request.course.id'}.'.num'} eq $2)) {
+ ($env{'course.'.$env{'request.course.id'}.'.num'} eq $2)) {
$description = 'Menu';
$no_mt_descr = 0;
}
@@ -1883,16 +1884,16 @@
} # End of scope for @Crumbs
sub docs_breadcrumbs {
- my ($allowed,$crstype,$contenteditor)=@_;
+ my ($allowed,$crstype,$contenteditor,$title,$precleared)=@_;
my ($folderpath, at folders);
if ($env{'form.pagepath'}) {
@folders = split('&',$env{'form.pagepath'});
} else {
- @folders=split('&',$env{'form.folderpath'});
+ @folders = split('&',$env{'form.folderpath'});
}
my $plain='';
my ($randompick,$isencrypted,$ishidden,$is_random_order) = (-1,0,0,0);
- &clear_breadcrumbs();
+ my @docs_crumbs;
while (@folders) {
my $folder=shift(@folders);
my $foldername=shift(@folders);
@@ -1920,28 +1921,40 @@
if ($4 ne '') { $is_random_order = 1; }
}
if ($folder eq 'supplemental') {
- $name = &mt('Supplemental '.$crstype.' Content');
+ $name = &mt('Supplemental '.$crstype.' Contents');
}
if ($contenteditor) {
$plain.=$name.' > ';
}
- &add_breadcrumb(
+ push(@docs_crumbs,
{'href' => $url,
'title' => $name,
'text' => $name,
'no_mt' => 1,
});
}
- unless ($contenteditor) {
- if ($env{'httpref.'.$env{'request.noversionuri'}} ne '') {
- &add_breadcrumb({text => 'View Resource'});
+ if (wantarray) {
+ unless ($precleared) {
+ &clear_breadcrumbs();
+ }
+ &add_breadcrumb(@docs_crumbs);
+ if ($title) {
+ &add_breadcrumb({text => $title});
}
+ if ($contenteditor) {
+ $plain=~s/\>\;\s*$//;
+ }
+ my $menulink = 0;
+ if (!$allowed && !$contenteditor) {
+ $menulink = 1;
+ }
+ return (&breadcrumbs(undef,undef,$menulink,'nohelp',undef,undef,
+ $contenteditor),
+ $randompick,$ishidden,$isencrypted,$plain,
+ $is_random_order);
} else {
- $plain=~s/\>\;\s*$//;
+ return \@docs_crumbs;
}
- return (&breadcrumbs(undef,undef,0,'nohelp',undef,undef,$contenteditor),
- $randompick,$ishidden,$isencrypted,$plain,
- $is_random_order);
}
############################################################
@@ -3091,13 +3104,18 @@
}
sub jump_to_editres {
- my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb) = @_;
+ my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath,
+ $title,$idx,$suppurl) = @_;
my $jscall;
if ($switchserver) {
- if ($symb && $home) {
+ if ($home) {
$cfile = '/adm/switchserver?otherserver='.$home.'&role='.
- &HTML::Entities::encode($env{'request.role'},'"<>&').
- '&symb='.&HTML::Entities::encode($symb,'"<>&');
+ &HTML::Entities::encode($env{'request.role'},'"<>&');
+ if ($symb) {
+ $cfile .= '&symb='.&HTML::Entities::encode($symb,'"<>&');
+ } elsif ($folderpath) {
+ $cfile .= '&folderpath='.&HTML::Entities::encode($folderpath,'"<>&');
+ }
if ($forceedit) {
$cfile .= '&forceedit=1';
}
@@ -3109,7 +3127,21 @@
} else {
unless ($cfile =~ m{^/priv/}) {
if ($symb) {
- $cfile .= (($cfile=~/\?/)?'&':'?')."symb=$symb";
+ $cfile .= (($cfile=~/\?/)?'&':'?')."symb=$symb";
+ } elsif ($folderpath) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').
+ 'folderpath='.&HTML::Entities::encode(&escape($folderpath),'"<>&');
+ if ($title) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').
+ 'title='.&HTML::Entities::encode(&escape($title),'"<>&');
+ }
+ if ($idx) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').'idx='.$idx;
+ }
+ if ($suppurl) {
+ $cfile .= (($cfile=~/\?/)?'&':'?').
+ 'suppurl='.&HTML::Entities::encode(&escape($suppurl));
+ }
}
if ($forceedit) {
$cfile .= (($cfile=~/\?/)?'&':'?').'forceedit=1';
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.392 loncom/interface/lonmenu.pm:1.393
--- loncom/interface/lonmenu.pm:1.392 Fri Nov 16 23:37:16 2012
+++ loncom/interface/lonmenu.pm Tue Nov 27 23:45:08 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.392 2012/11/16 23:37:16 raeburn Exp $
+# $Id: lonmenu.pm,v 1.393 2012/11/27 23:45:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -441,63 +441,64 @@
undef(@inlineremote);
- my $resurl;
+ my ($mapurl,$resurl);
- if ($env{'request.course.id'} && $env{'request.symb'} eq '') {
- $resurl = $env{'request.noversionuri'};
- }
-
- if ( $env{'request.symb'} && $env{'request.course.id'} ) {
-
- (my $mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
- my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
+ if ($env{'request.course.id'}) {
+ if ($env{'request.symb'}) {
+ ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
+ my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
- my $maptitle = &Apache::lonnet::gettitle($mapurl);
- my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
+ my $maptitle = &Apache::lonnet::gettitle($mapurl);
+ my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
#SD
#course_type only Course and Community?
#
- my @crumbs;
- unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
- && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
- @crumbs = ({text => Apache::loncommon::course_type()
- . ' Contents',
- href => "Javascript:gopost('/adm/navmaps','')"});
- }
- if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
- push(@crumbs, {text => '...',
- no_mt => 1});
- }
-
- push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
- && $maptitle ne 'default.sequence'
- && $maptitle ne $coursetitle);
+ my @crumbs;
+ unless (($forcereg) &&
+ ($env{'request.noversionuri'} eq '/adm/navmaps') &&
+ ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
+ @crumbs = ({text => Apache::loncommon::course_type()
+ . ' Contents',
+ href => "Javascript:gopost('/adm/navmaps','')"});
+ }
+ if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
+ push(@crumbs, {text => '...',
+ no_mt => 1});
+ }
+
+ push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
+ && $maptitle ne 'default.sequence'
+ && $maptitle ne $coursetitle);
- push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
-
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
- } elsif ($env{'request.course.id'}) {
- my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
- if ($env{'request.noversionuri'} =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
- my $crstype = &Apache::loncommon::course_type();
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
- if ($env{'form.folderpath'}) {
- my ($trail) =
- &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
- return $trail;
- } else {
+ push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
+ } else {
+ $resurl = $env{'request.noversionuri'};
+ my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
+ my $crstype = &Apache::loncommon::course_type();
+ my $title = &mt('View Resource');
+ if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
- &Apache::lonhtmlcommon::add_breadcrumb(
+ if ($env{'form.title'}) {
+ $title = $env{'form.title'};
+ }
+ if ($env{'form.folderpath'}) {
+ my $editbutton =
+ &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
+ my ($trail) =
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ return $trail;
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb(
{text => "Supplemental $crstype Content",
href => "javascript:gopost('/adm/supplemental','')"});
- if ($env{'httpref.'.$env{'request.noversionuri'}} ne '') {
- &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
+ $title = &mt('View Resource');
+ return &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
}
- return &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
}
- } else {
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
}
@@ -564,13 +565,17 @@
"gocmd('/adm/parmset','set')",
'Content Settings');
}
-# End grades/submissions check
+# End grades/submissions check
#
-# This applies to items inside a folder/page modifiable in the course.
+# This applies to items inside a folder/page modifiable in the course.
#
if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
- &switch('','',7,4,'docs-22x22.png','Folder/Page Content','parms[_2]',
+ my $text = 'Edit Folder';
+ if ($mapurl =~ /\.page$/) {
+ $text = 'Edit Page';
+ }
+ &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
"gocmd('/adm/coursedocs','direct')",
'Folder/Page Content');
}
@@ -745,7 +750,10 @@
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
my $jscall =
&Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
- $forceedit,$forcereg,$env{'request.symb'});
+ $forceedit,$forcereg,$env{'request.symb'},
+ &escape($env{'form.folderpath'}),
+ &escape($env{'form.title'}),$env{'form.idx'},
+ &escape($env{'form.suppurl'}));
if ($jscall) {
my $icon = 'pcstr.png';
my $label = 'Edit';
@@ -761,7 +769,7 @@
}
sub prepare_functions {
- my ($resurl,$forcereg,$group,$bread_crumbs,$advtools) = @_;
+ my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
unless ($env{'request.registered'}) {
undef(@inlineremote);
}
@@ -824,6 +832,16 @@
$editbutton = &get_editbutton($cfile,$home,$switchserver,
$forceedit,$forceview,$forcereg);
}
+ } elsif (($resurl eq '/adm/extresedit') &&
+ (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
+ ($cfile,$home,$switchserver,$forceedit,$forceview) =
+ &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
+ $env{'form.symb'});
+ if ($cfile ne '') {
+ $editbutton = &get_editbutton($cfile,$home,$switchserver,
+ $forceedit,$forceview,$forcereg,
+ $env{'form.title'},$env{'form.suppurl'});
+ }
} elsif ($resurl !~ m{^adm/($match_domain)/($match_username)/aboutme$}) {
if ($env{'request.filename'}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
@@ -839,8 +857,8 @@
}
# End determination of 'Edit' icon/button display
-# This applies to about me page for users in a course
if ($env{'request.course.id'}) {
+# This applies to about me page for users in a course
if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
my ($sdom,$sname) = ($1,$2);
unless (&Apache::lonnet::is_course($sdom,$sname)) {
@@ -878,12 +896,36 @@
'Add records');
}
}
+ } elsif ($resurl =~ m{^/?adm/viewclasslist}) {
+# This applies to viewclasslist page for users in a course
+ if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
+ &switch('','',6,4,'pparm.png','Settings',
+ '',
+ "go('/adm/courseprefs?actions=classlists&phase=display')",
+ 'Student-viewable classlist options');
+ }
+ }
+ if (($env{'form.folderpath'} =~ /^supplemental/) &&
+ (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
+ (($resurl =~ m{^/adm/wrapper/ext/}) ||
+ ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
+ ($resurl eq '/adm/supplemental'))) {
+ my @folders=split('&',$env{'form.folderpath'});
+ if (@folders > 2) {
+ my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
+ &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
+ "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
+ 'Folder/Page Content');
+ }
}
}
# End checking for items for about me page for users in a course
-
- if ($env{'request.registered'}) {
+ if ($docscrumbs) {
+ &Apache::lonhtmlcommon::clear_breadcrumb_tools();
+ &advtools_crumbs(@inlineremote);
+ return $editbutton;
+ } elsif ($env{'request.registered'}) {
return $editbutton;
} else {
if (ref($bread_crumbs) eq 'ARRAY') {
@@ -911,7 +953,10 @@
} elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
&Apache::lonhtmlcommon::add_breadcrumb_tool(
'advtools', @funcs[61,71,72,73,74,92]);
- }
+ } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
+ &Apache::lonhtmlcommon::add_breadcrumb_tool(
+ 'advtools', @funcs[64]);
+ }
}
# ================================================================== Raw Config
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.41 rat/lonwrapper.pm:1.42
--- rat/lonwrapper.pm:1.41 Mon Nov 7 20:06:29 2011
+++ rat/lonwrapper.pm Tue Nov 27 23:45:15 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Wrapper for external and binary files as standalone resources
#
-# $Id: lonwrapper.pm,v 1.41 2011/11/07 20:06:29 www Exp $
+# $Id: lonwrapper.pm,v 1.42 2012/11/27 23:45:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,21 +33,51 @@
use Apache::Constants qw(:common);
use Apache::lonenc();
use Apache::lonnet;
+use Apache::lonlocal;
+use Apache::loncommon();
+use Apache::lonhtmlcommon();
+use Apache::lonextresedit();
# ================================================================ Main Handler
sub wrapper {
- my $url = shift;
+ my ($url,$brcrum) = @_;
- my $startpage = Apache::loncommon::start_page('Menu',undef,
- { 'force_register' =>1, 'bgcolor' => '#FFFFFF',}) ;
+ my $forcereg;
+ unless ($env{'form.folderpath'}) {
+ $forcereg = 1;
+ }
+
+ my $args = {'bgcolor' => '#FFFFFF'};
+ if ($forcereg) {
+ $args->{'force_register'} = $forcereg;
+ }
+ if (ref($brcrum) eq 'ARRAY') {
+ $args->{'bread_crumbs'} = $brcrum;
+ }
+
+ my $startpage = Apache::loncommon::start_page('Menu',undef,$args);
my $endpage = Apache::loncommon::end_page();
my $script = Apache::lonhtmlcommon::scripttag(<<SCRIPT );
\$(document).ready( function() {
\$(window).unbind('resize').resize(function(){
- var header = \$('.LC_head_subbox')[0] ? \$('.LC_head_subbox')
- : \$('#LC_breadcrumbs');
- var pos = header.height() + header.position().top + 5;
+ var header;
+ var offset = 5;
+ var height = 0;
+ var hdrtop = 0;
+ if (\$('div.LC_head_subbox:first').length) {
+ header = \$('div.LC_head_subbox:first');
+ offset = 9;
+ } else {
+ if (\$('#LC_breadcrumbs').length) {
+ header = \$('#LC_breadcrumbs');
+ }
+ }
+ if (header.length) {
+ height = header.height();
+ hdrtop = header.position().top;
+ }
+ var pos = height + hdrtop + offset;
\$('.LC_iframecontainer').css('top', pos);
});
});
@@ -73,7 +103,7 @@
return OK if $r->header_only;
my $url = $r->uri;
- my $is_ext;
+ my ($is_ext,$brcrum);
for ($url){
s|^/adm/wrapper||;
@@ -82,6 +112,37 @@
s|:|:|g;
}
+ if ($is_ext) {
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['forceedit','register','folderpath','symb','idx','title']);
+ if (($env{'form.forceedit'}) &&
+ (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
+ (($env{'form.folderpath'} =~ /^supplemental/) ||
+ ($env{'form.symb'} =~ /^uploaded/))) {
+ $r->print(
+ &Apache::lonextresedit::display_editor($url,$env{'form.folderpath'},
+ $env{'form.symb'},
+ $env{'form.idx'}));
+ return OK;
+ } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
+ my $crstype = &Apache::loncommon::course_type();
+ $brcrum =
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$env{'form.title'},1);
+ if (ref($brcrum) eq 'ARRAY') {
+ my $last = $env{'form.title'};
+ if ($last eq '') {
+ $last = &mt('External Resource');
+ }
+ push(@{$brcrum},
+ {'title' => $last,
+ 'text' => $last,
+ 'no_mt' => 1,
+ });
+
+ }
+ }
+ }
+
#
# Actual URL
#
@@ -97,7 +158,7 @@
#
if ($is_ext) {
$ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
- $ENV{'QUERY_STRING'} =~ s/\&$//;
+ $ENV{'QUERY_STRING'} =~ s/\&$//;
}
unless ($ENV{'QUERY_STRING'} eq '') {
@@ -107,7 +168,7 @@
# encrypt url if not external
&Apache::lonenc::check_encrypt(\$url) if $url !~ /^https?\:/ ;
- $r->print( wrapper($url) );
+ $r->print( wrapper($url,$brcrum) );
} # not just the menu
@@ -134,9 +195,11 @@
=over
-=item wrapper($url)
+=item wrapper($url,$brcrum)
Wraps $url in an iframe and generates a page for it.
+$brcrum contains breadcrumbs for unregistered urls
+(i.e., external resources in Supplemental Content).
Returns markup for the entire page.
=item handler()
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1198 loncom/lonnet/perl/lonnet.pm:1.1199
--- loncom/lonnet/perl/lonnet.pm:1.1198 Sun Nov 11 17:33:26 2012
+++ loncom/lonnet/perl/lonnet.pm Tue Nov 27 23:45:22 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1198 2012/11/11 17:33:26 raeburn Exp $
+# $Id: lonnet.pm,v 1.1199 2012/11/27 23:45:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2671,7 +2671,7 @@
#
# For aboutme pages user can only edit his/her own.
#
- if ($resurl =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) {
+ if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
my ($sdom,$sname) = ($1,$2);
if (($sdom eq $env{'user.domain'}) && ($sname eq $env{'user.name'})) {
$home = $env{'user.home'};
@@ -2751,12 +2751,17 @@
$forceedit = 1;
}
$cfile = $resurl;
- } elsif (($resurl eq '/res/lib/templates/simpleproblem.problem')) {
+ } elsif ($resurl eq '/res/lib/templates/simpleproblem.problem') {
$incourse = 1;
$cfile = $resurl.'/smpedit';
- } elsif ($resurl =~ /ext/) {
+ } elsif ($resurl =~ m{^/adm/wrapper/ext/}) {
$incourse = 1;
- # is external
+ if ($env{'form.forceedit'}) {
+ $forceview = 1;
+ } else {
+ $forceedit = 1;
+ }
+ $cfile = $resurl;
}
} elsif ($resurl eq '/res/lib/templates/simpleproblem.problem/smpedit') {
my $template = '/res/lib/templates/simpleproblem.problem';
@@ -2765,6 +2770,26 @@
$forceview = 1;
$cfile = $template;
}
+ } elsif (($resurl =~ m{^/adm/wrapper/ext/}) && ($env{'form.folderpath'} =~ /^supplemental/)) {
+ $incourse = 1;
+ if ($env{'form.forceedit'}) {
+ $forceview = 1;
+ } else {
+ $forceedit = 1;
+ }
+ $cfile = $resurl;
+ } elsif (($resurl eq '/adm/extresedit') && ($symb || $env{'form.folderpath'})) {
+ $incourse = 1;
+ $forceview = 1;
+ if ($symb) {
+ my ($map,$id,$res)=&decode_symb($symb);
+ $env{'request.symb'} = $symb;
+ $cfile = &clutter($res);
+ } else {
+ $cfile = $env{'form.suppurl'};
+ $cfile =~ s{^http://}{};
+ $cfile = '/adm/wrapper/ext/'.$cfile;
+ }
}
}
if ($uploaded || $incourse) {
@@ -10262,6 +10287,72 @@
return $title;
}
+sub getdocspath {
+ my ($symb) = @_;
+ my $path;
+ if ($symb) {
+ my ($mapurl,$id,$resurl) = &decode_symb($symb);
+ if ($resurl=~/\.(sequence|page)$/) {
+ $mapurl=$resurl;
+ } elsif ($resurl eq 'adm/navmaps') {
+ $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'};
+ }
+ my $mapresobj;
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ $mapresobj = $navmap->getResourceByUrl($mapurl);
+ }
+ $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
+ my $type=$2;
+ if (ref($mapresobj)) {
+ my $pcslist = $mapresobj->map_hierarchy();
+ if ($pcslist ne '') {
+ foreach my $pc (split(/,/,$pcslist)) {
+ next if ($pc <= 1);
+ my $res = $navmap->getByMapPc($pc);
+ if (ref($res)) {
+ my $thisurl = $res->src();
+ $thisurl=~s{^.*/([^/]+)\.\w+$}{$1};
+ my $thistitle = $res->title();
+ $path .= '&'.
+ &Apache::lonhtmlcommon::entity_encode($thisurl).'&'.
+ &Apache::lonhtmlcommon::entity_encode($thistitle).
+ ':'.$res->randompick().
+ ':'.$res->randomout().
+ ':'.$res->encrypted().
+ ':'.$res->randomorder();
+ }
+ }
+ }
+ $path =~ s/^\&//;
+ my $maptitle = $mapresobj->title();
+ if ($mapurl eq 'default') {
+ $maptitle = 'Main Course Documents';
+ }
+ $path .= ($path ne '')? '&' : ''.
+ &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
+ &Apache::lonhtmlcommon::entity_encode($maptitle).
+ ':'.$mapresobj->randompick().
+ ':'.$mapresobj->randomout().
+ ':'.$mapresobj->encrypted().
+ ':'.$mapresobj->randomorder();
+ } else {
+ my $maptitle = &gettitle($mapurl);
+ if ($mapurl eq 'default') {
+ $maptitle = 'Main Course Documents';
+ }
+ $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
+ &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
+ }
+ unless ($mapurl eq 'default') {
+ $path = 'default&'.
+ &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
+ '::::&'.$path;
+ }
+ }
+ return $path;
+}
+
sub get_slot {
my ($which,$cnum,$cdom)=@_;
if (!$cnum || !$cdom) {
More information about the LON-CAPA-cvs
mailing list