--- loncom/interface/londocs.pm 2011/12/25 18:29:49 1.471
+++ loncom/interface/londocs.pm 2011/12/25 20:41:53 1.472
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.471 2011/12/25 18:29:49 raeburn Exp $
+# $Id: londocs.pm,v 1.472 2011/12/25 20:41:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,6 +41,7 @@ use Apache::lonratedt();
use Apache::lonxml;
use Apache::lonclonecourse;
use Apache::lonnavmaps;
+use Apache::lonnavdisplay();
use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
@@ -1127,37 +1128,33 @@ sub breadcrumbs {
my $isencrypted=0;
my $ishidden=0;
my $is_random_order=0;
- if (!$allowed) {
- my $description = $env{'course.'.$env{'request.course.id'}.'.description'};
- &Apache::lonhtmlcommon::add_breadcrumb(
- {'href' => '/adm/menu',
- 'title'=> 'Go to main menu',
- 'text' => $description,
- });
- $plain .= $description.' >';
- }
while (@folders) {
my $folder=shift(@folders);
my $foldername=shift(@folders);
if ($folderpath) {$folderpath.='&';}
$folderpath.=$folder.'&'.$foldername;
- my $url='/adm/coursedocs?folderpath='.
- &escape($folderpath);
- my $name=&unescape($foldername);
+ my $url;
+ if ($allowed) {
+ $url = '/adm/coursedocs?folderpath=';
+ } else {
+ $url = '/adm/supplemental?folderpath=';
+ }
+ $url .= &escape($folderpath);
+ my $name=&unescape($foldername);
# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
- $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
- if ($1 ne '') {
- $randompick=$1;
- } else {
- $randompick=-1;
- }
- if ($2) { $ishidden=1; }
- if ($3) { $isencrypted=1; }
- if ($4 ne '') { $is_random_order = 1; }
- if ($folder eq 'supplemental') {
- $name = &mt('Supplemental '.$crstype.' Documents');
- }
- &Apache::lonhtmlcommon::add_breadcrumb(
+ $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
+ if ($1 ne '') {
+ $randompick=$1;
+ } else {
+ $randompick=-1;
+ }
+ if ($2) { $ishidden=1; }
+ if ($3) { $isencrypted=1; }
+ if ($4 ne '') { $is_random_order = 1; }
+ if ($folder eq 'supplemental') {
+ $name = &mt('Supplemental '.$crstype.' Content');
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb(
{'href'=>$url.$cpinfo,
'title'=>$name,
'text'=>$name,
@@ -1167,7 +1164,8 @@ sub breadcrumbs {
}
$plain=~s/\>\;\s*$//;
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
- undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
+ undef, undef, 1 ),$randompick,$ishidden,
+ $isencrypted,$plain,$is_random_order);
}
sub log_docs {
@@ -1614,7 +1612,7 @@ sub handle_edit_cmd {
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
- $supplementalflag,$orderhash)=@_;
+ $supplementalflag,$orderhash,$iconpath)=@_;
my $container= ($env{'form.pagepath'}) ? 'page'
: 'sequence';
@@ -1630,8 +1628,10 @@ sub editor {
}
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
- &breadcrumbs($allowed,$crstype);
- $r->print($breadcrumbtrail);
+ &breadcrumbs($allowed,$crstype);
+ $r->print($breadcrumbtrail);
+
+ my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container";
unless ($allowed) {
$randompick = -1;
@@ -1788,9 +1788,22 @@ sub editor {
$tid = 2;
}
if ($allowed) {
- $r->print(&generate_edit_table($tid,$orderhash,$to_show));
+ $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto));
&print_paste_buffer($r,$container);
} else {
+ if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ #Function Box for Supplemental Content for users with mdc priv.
+ my $funcname = &mt('Folder Editor');
+ $r->print(
+ &Apache::loncommon::head_subbox(
+ &Apache::lonhtmlcommon::start_funclist().
+ &Apache::lonhtmlcommon::add_item_funclist(
+ ''.
+ ''.
+ '').
+ &Apache::lonhtmlcommon::end_funclist()));
+ }
$r->print($to_show);
}
return;
@@ -2086,18 +2099,23 @@ END
my $pagearg;
my $pagefile;
if ($uploaded) {
- if ($extension eq 'sequence') {
- $icon=$iconpath.'/navmap.folder.closed.gif';
- $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
- $url='/adm/coursedocs?';
- $folderarg=$1;
- $isfolder=1;
- } elsif ($extension eq 'page') {
- $icon=$iconpath.'/page.gif';
- $url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
- $pagearg=$1;
- $url='/adm/coursedocs?';
- $ispage=1;
+ if (($extension eq 'sequence') || ($extension eq 'page')) {
+ $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
+ my $containerarg = $1;
+ if ($extension eq 'sequence') {
+ $icon=$iconpath.'navmap.folder.closed.gif';
+ $folderarg=$containerarg;
+ $isfolder=1;
+ } else {
+ $icon=$iconpath.'page.gif';
+ $pagearg=$containerarg;
+ $ispage=1;
+ }
+ if ($allowed) {
+ $url='/adm/coursedocs?';
+ } else {
+ $url='/adm/supplemental?';
+ }
} else {
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
}
@@ -2200,7 +2218,7 @@ END
$reinit = &mt('(re-initialize course to access)');
}
$line.='
';
- if ($url=~m{/adm/coursedocs}) {
+ if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
$line.='';
} elsif ($url) {
$line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
@@ -2209,7 +2227,7 @@ END
$line.='';
}
$line.=' | ';
- if ($url=~m{/adm/coursedocs}) {
+ if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
$line.=''.$title.'';
} elsif ($url) {
$line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
@@ -2761,27 +2779,19 @@ sub create_form_ul {
sub startContentScreen {
my ($r,$mode)=@_;
$r->print('');
- $r->print('- '.&mt('Content Overview').'
');
-
- my $active = '';
-# does this user have privileges to modify docs?
- my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
-
- my $onclick;
- my $href;
-
- if ($allowed) {
+ if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
+ $r->print('- '.&mt('Content Overview').'
'."\n");
+ $r->print('- '.&mt('Content Search').'
'."\n");
+ $r->print('- '.&mt('Content Index').'
'."\n");
+ $r->print('- '.&mt('Supplemental Content').'
');
+ } else {
$r->print('- '.&mt('Content Editor').'
');
+ $r->print('- '.&mt('Supplemental Content Editor').'
');
}
- $r->print('- '.&mt('Content Search').'
');
- $r->print('- '.&mt('Content Index').'
');
- $r->print('- '.&mt('Supplemental Documents').'
');
- $r->print(' ');
- $r->print(''
- .' ');
- $r->print(' ');
+ $r->print("\n".''."\n");
+ $r->print(' ');
}
#
@@ -2794,7 +2804,7 @@ sub endContentScreen {
}
sub supplemental_base {
- return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Documents'));
+ return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
}
sub handler {
@@ -2828,8 +2838,14 @@ sub handler {
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
-# does this user have privileges to modify docs
- my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+
+ my $allowed;
+# URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
+ unless ($r->uri eq '/adm/supplemental') {
+ # does this user have privileges to modify content.
+ $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+ }
+
if ($allowed && $env{'form.verify'}) {
&init_breadcrumbs('verify','Verify Content');
&verifycontent($r);
@@ -2888,66 +2904,74 @@ sub handler {
if ($env{'form.command'} eq 'direct') {
my ($mapurl,$id,$resurl);
- if ($env{'form.symb'} eq '') {
- $mapurl = $env{'course.'.$env{'request.course.id'}.'.url'};
- } else {
+ if ($env{'form.symb'} ne '') {
($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.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;
- my $path;
- 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();
+ my $mapresobj;
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ $mapresobj = $navmap->getResourceByUrl($mapurl);
+ }
+ $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
+ my $type=$2;
+ my $path;
+ 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 .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
+ $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
&Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
':'.$mapresobj->randompick().
':'.$mapresobj->randomout().
':'.$mapresobj->encrypted().
':'.$mapresobj->randomorder();
- } else {
- my $maptitle = &Apache::lonnet::gettitle($mapurl);
- $path = '&default&...::::'.
- '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
- &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
- }
- $path = 'default&'.
- &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
- $path;
- if ($type eq 'sequence') {
- $env{'form.folderpath'}=$path;
- $env{'form.pagepath'}='';
- } else {
- $env{'form.pagepath'}=$path;
- $env{'form.folderpath'}='';
+ } else {
+ my $maptitle = &Apache::lonnet::gettitle($mapurl);
+ $path = '&default&...::::'.
+ '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
+ &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
+ }
+ $path = 'default&'.
+ &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
+ $path;
+ if ($type eq 'sequence') {
+ $env{'form.folderpath'}=$path;
+ $env{'form.pagepath'}='';
+ } else {
+ $env{'form.pagepath'}=$path;
+ $env{'form.folderpath'}='';
+ }
+ } elsif ($env{'form.supppath'} ne '') {
+ $env{'form.folderpath'}=$env{'form.supppath'};
}
+ } elsif ($env{'form.command'} eq 'editdocs') {
+ $env{'form.folderpath'} = 'default&'.
+ &Apache::lonhtmlcommon::entity_encode('Main Course Content');
+ $env{'form.pagepath'}='';
+ } elsif ($env{'form.command'} eq 'editsupp') {
+ $env{'form.folderpath'} = 'default&'.
+ &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
+ $env{'form.pagepath'}='';
}
# Where do we store these for when we come back?
@@ -2987,7 +3011,7 @@ sub handler {
} else {
$env{'form.folderpath'}='default';
}
- }
+ }
# Store this
&Apache::loncommon::store_course_settings($stored_folderpath,
@@ -3058,7 +3082,7 @@ sub handler {
}
}
my $tabidstr = join("','",@tabids);
- $script .= &editing_js($udom,$uname).
+ $script .= &editing_js($udom,$uname,$supplementalflag).
&resize_contentdiv_js($tabidstr);
$addentries = {
onload => "javascript:resize_contentdiv('contentscroll','1','1');",
@@ -3261,8 +3285,12 @@ HIDDENFORM
}
# Generate the tabs
- &startContentScreen($r,($supplementalflag?'supdocs':'docs'));
-
+ my $mode;
+ if (($supplementalflag) && (!$allowed)) {
+ &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
+ } else {
+ &startContentScreen($r,($supplementalflag?'suppdocs':'docs'));
+ }
#
@@ -3512,7 +3540,7 @@ unless ($env{'form.pagepath'}) {
$hadchanges=0;
unless ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,\%orderhash);
+ $supplementalflag,\%orderhash,$iconpath);
if ($error) {
$r->print(' '.$error.' ');
}
@@ -3624,14 +3652,14 @@ my %suporderhash = (
);
if ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,\%suporderhash);
+ $supplementalflag,\%suporderhash,$iconpath);
if ($error) {
$r->print(' '.$error.' ');
}
}
} elsif ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag);
+ $supplementalflag,'',$iconpath);
if ($error) {
$r->print(' '.$error.' ');
}
@@ -3734,7 +3762,7 @@ sub generate_admin_options {
sub generate_edit_table {
- my ($tid,$orderhash_ref,$to_show) = @_;
+ my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto) = @_;
return unless(ref($orderhash_ref) eq 'HASH');
my %orderhash = %{$orderhash_ref};
my $form;
@@ -3743,8 +3771,14 @@ sub generate_edit_table {
if($env{'form.active'} ne ''){
$activetab = $env{'form.active'};
}
+ my $backicon = $iconpath.'clickhere.gif';
+ my $backtext = &mt('Back to Overview');
$form = ' '.
- ' ';
+ ''.
+ '- '.
+ ''.
+ ''.
+ $backtext.'
';
foreach my $name (reverse(sort(keys(%orderhash)))) {
if($name ne '00'){
if($activetab eq '' || $activetab ne $name){
@@ -3784,7 +3818,7 @@ sub generate_edit_table {
}
sub editing_js {
- my ($udom,$uname) = @_;
+ my ($udom,$uname,$supplementalflag) = @_;
my $now = time();
my %lt = &Apache::lonlocal::texthash(
p_mnf => 'Name of New Folder',
@@ -3822,6 +3856,11 @@ sub editing_js {
my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
my $toplevelsupp = &supplemental_base();
+ my $backtourl = '/adm/navmaps';
+ if ($supplementalflag) {
+ $backtourl = '/adm/supplemental';
+ }
+
return < |