version 1.327, 2009/01/28 12:56:08
|
version 1.452, 2011/01/30 01:21:29
|
Line 1
|
Line 1
|
# The LearningOnline Network
|
# The LearningOnline Network |
# Documents
|
# Documents |
#
|
# |
# $Id$
|
# $Id$ |
#
|
# |
# Copyright Michigan State University Board of Trustees
|
# Copyright Michigan State University Board of Trustees |
#
|
# |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
#
|
# |
# LON-CAPA is free software; you can redistribute it and/or modify
|
# LON-CAPA is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or |
# (at your option) any later version.
|
# (at your option) any later version. |
#
|
# |
# LON-CAPA is distributed in the hope that it will be useful,
|
# LON-CAPA is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details.
|
# GNU General Public License for more details. |
#
|
# |
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License |
# along with LON-CAPA; if not, write to the Free Software
|
# along with LON-CAPA; if not, write to the Free Software |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
#
|
# |
# /home/httpd/html/adm/gpl.txt
|
# /home/httpd/html/adm/gpl.txt |
#
|
# |
# http://www.lon-capa.org/
|
# http://www.lon-capa.org/ |
#
|
# |
|
|
|
|
|
|
package Apache::londocs;
|
package Apache::londocs; |
|
|
use strict;
|
use strict; |
use Apache::Constants qw(:common :http);
|
use Apache::Constants qw(:common :http); |
use Apache::imsexport;
|
use Apache::imsexport; |
use Apache::lonnet;
|
use Apache::lonnet; |
use Apache::loncommon;
|
use Apache::loncommon; |
use LONCAPA::map();
|
use Apache::lonhtmlcommon; |
use Apache::lonratedt();
|
use LONCAPA::map(); |
use Apache::lonxml;
|
use Apache::lonratedt(); |
use Apache::lonclonecourse;
|
use Apache::lonxml; |
use Apache::lonnavmaps;
|
use Apache::lonclonecourse; |
use HTML::Entities;
|
use Apache::lonnavmaps; |
use GDBM_File;
|
use HTML::Entities; |
use Apache::lonlocal;
|
use GDBM_File; |
use Cwd;
|
use Apache::lonlocal; |
use LONCAPA qw(:DEFAULT :match);
|
use Cwd; |
|
use LONCAPA qw(:DEFAULT :match); |
my $iconpath;
|
|
|
my $iconpath; |
my %hash;
|
|
|
my %hash; |
my $hashtied;
|
|
my %alreadyseen=();
|
my $hashtied; |
|
my %alreadyseen=(); |
my $hadchanges;
|
|
|
my $hadchanges; |
|
|
my %help=();
|
|
|
my %help=(); |
|
|
sub mapread {
|
|
my ($coursenum,$coursedom,$map)=@_;
|
sub mapread { |
return
|
my ($coursenum,$coursedom,$map)=@_; |
&LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
|
return |
$map);
|
&LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
}
|
$map); |
|
} |
sub storemap {
|
|
my ($coursenum,$coursedom,$map)=@_;
|
sub storemap { |
my ($outtext,$errtext)=
|
my ($coursenum,$coursedom,$map)=@_; |
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
|
my ($outtext,$errtext)= |
$map,1);
|
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
if ($errtext) { return ($errtext,2); }
|
$map,1); |
|
if ($errtext) { return ($errtext,2); } |
$hadchanges=1;
|
|
return ($errtext,0);
|
$hadchanges=1; |
}
|
return ($errtext,0); |
|
} |
|
|
|
|
sub authorhosts {
|
|
my %outhash=();
|
sub authorhosts { |
my $home=0;
|
my %outhash=(); |
my $other=0;
|
my $home=0; |
foreach my $key (keys(%env)) {
|
my $other=0; |
if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
|
foreach my $key (keys(%env)) { |
my $role=$1;
|
if ($key=~/^user\.role\.(au|ca)\.(.+)$/) { |
my $realm=$2;
|
my $role=$1; |
my ($start,$end)=split(/\./,$env{$key});
|
my $realm=$2; |
if (($start) && ($start>time)) { next; }
|
my ($start,$end)=split(/\./,$env{$key}); |
if (($end) && (time>$end)) { next; }
|
if (($start) && ($start>time)) { next; } |
my ($ca,$cd);
|
if (($end) && (time>$end)) { next; } |
if ($1 eq 'au') {
|
my ($ca,$cd); |
$ca=$env{'user.name'};
|
if ($1 eq 'au') { |
$cd=$env{'user.domain'};
|
$ca=$env{'user.name'}; |
} else {
|
$cd=$env{'user.domain'}; |
($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
|
} else { |
}
|
($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/); |
my $allowed=0;
|
} |
my $myhome=&Apache::lonnet::homeserver($ca,$cd);
|
my $allowed=0; |
my @ids=&Apache::lonnet::current_machine_ids();
|
my $myhome=&Apache::lonnet::homeserver($ca,$cd); |
foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
|
my @ids=&Apache::lonnet::current_machine_ids(); |
if ($allowed) {
|
foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } } |
$home++;
|
if ($allowed) { |
$outhash{'home_'.$ca.'@'.$cd}=1;
|
$home++; |
} else {
|
$outhash{'home_'.$ca.'@'.$cd}=1; |
$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
|
} else { |
$other++;
|
$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome; |
}
|
$other++; |
}
|
} |
}
|
} |
return ($home,$other,%outhash);
|
} |
}
|
return ($home,$other,%outhash); |
|
} |
|
|
sub dumpbutton {
|
|
my ($home,$other,%outhash)=&authorhosts();
|
sub dumpbutton { |
my $type = &Apache::loncommon::course_type();
|
my ($home,$other,%outhash)=&authorhosts(); |
if ($home+$other==0) { return ''; }
|
my $crstype = &Apache::loncommon::course_type(); |
if ($home) {
|
if ($home+$other==0) { return ''; } |
return '<input type="submit" name="dumpcourse" value="'.
|
if ($home) { |
&mt('Dump '.$type.' DOCS to Construction Space').'" />'.
|
my $link = |
&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
|
"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"dumpcourse\", \"" |
} else {
|
.&mt('Dump '.$crstype.' Documents to Construction Space') |
return '<div>'.
|
."\")'>" |
&mt('Dump '.$type.
|
.&mt('Dump '.$crstype.' Documents to Construction Space') |
' DOCS to Construction Space: available on other servers').
|
.'</a>'; |
'</div>';
|
return |
}
|
$link.' ' |
}
|
.&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs') |
|
.'<br />'; |
sub clean {
|
} else { |
my ($title)=@_;
|
return |
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
|
&mt('Dump '.$crstype.' Documents to Construction Space: available on other servers'); |
return $title;
|
} |
}
|
} |
|
|
|
sub clean { |
|
my ($title)=@_; |
sub dumpcourse {
|
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; |
my ($r) = @_;
|
return $title; |
my $type = &Apache::loncommon::course_type();
|
} |
$r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
|
|
'<form name="dumpdoc" method="post">');
|
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space'));
|
|
my ($home,$other,%outhash)=&authorhosts();
|
sub dumpcourse { |
unless ($home) { return ''; }
|
my ($r) = @_; |
my $origcrsid=$env{'request.course.id'};
|
my $crstype = &Apache::loncommon::course_type(); |
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
|
$r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Documents to Construction Space'). |
if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
|
'<form name="dumpdoc" action="" method="post">'); |
# Do the dumping
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Documents to Construction Space')); |
unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
|
my ($home,$other,%outhash)=&authorhosts(); |
my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
|
unless ($home) { return ''; } |
$r->print('<h3>'.&mt('Copying Files').'</h3>');
|
my $origcrsid=$env{'request.course.id'}; |
my $title=$env{'form.authorfolder'};
|
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
$title=&clean($title);
|
if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) { |
my %replacehash=();
|
# Do the dumping |
foreach my $key (keys(%env)) {
|
unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; } |
if ($key=~/^form\.namefor\_(.+)/) {
|
my ($ca,$cd)=split(/\@/,$env{'form.authorspace'}); |
$replacehash{$1}=$env{$key};
|
$r->print('<h3>'.&mt('Copying Files').'</h3>'); |
}
|
my $title=$env{'form.authorfolder'}; |
}
|
$title=&clean($title); |
my $crs='/uploaded/'.$env{'request.course.id'}.'/';
|
my %replacehash=(); |
$crs=~s/\_/\//g;
|
foreach my $key (keys(%env)) { |
foreach my $item (keys(%replacehash)) {
|
if ($key=~/^form\.namefor\_(.+)/) { |
my $newfilename=$title.'/'.$replacehash{$item};
|
$replacehash{$1}=$env{$key}; |
$newfilename=~s/\.(\w+)$//;
|
} |
my $ext=$1;
|
} |
$newfilename=&clean($newfilename);
|
my $crs='/uploaded/'.$env{'request.course.id'}.'/'; |
$newfilename.='.'.$ext;
|
$crs=~s/\_/\//g; |
my @dirs=split(/\//,$newfilename);
|
foreach my $item (keys(%replacehash)) { |
my $path='/home/'.$ca.'/public_html';
|
my $newfilename=$title.'/'.$replacehash{$item}; |
my $makepath=$path;
|
$newfilename=~s/\.(\w+)$//; |
my $fail=0;
|
my $ext=$1; |
for (my $i=0;$i<$#dirs;$i++) {
|
$newfilename=&clean($newfilename); |
$makepath.='/'.$dirs[$i];
|
$newfilename.='.'.$ext; |
unless (-e $makepath) {
|
my @dirs=split(/\//,$newfilename); |
unless(mkdir($makepath,0777)) { $fail=1; }
|
my $path='/home/'.$ca.'/public_html'; |
}
|
my $makepath=$path; |
}
|
my $fail=0; |
$r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
|
for (my $i=0;$i<$#dirs;$i++) { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
|
$makepath.='/'.$dirs[$i]; |
if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
|
unless (-e $makepath) { |
print $fh &Apache::lonclonecourse::rewritefile(
|
unless(mkdir($makepath,0777)) { $fail=1; } |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
|
} |
(%replacehash,$crs => '')
|
} |
);
|
$r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '); |
} else {
|
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
print $fh
|
if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) { |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
|
print $fh &Apache::lonclonecourse::rewritefile( |
}
|
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
$fh->close();
|
(%replacehash,$crs => '') |
} else {
|
); |
$fail=1;
|
} else { |
}
|
print $fh |
if ($fail) {
|
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
$r->print('<span class="LC_error">'.&mt('fail').'</span>');
|
} |
} else {
|
$fh->close(); |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
} else { |
}
|
$fail=1; |
}
|
} |
} else {
|
if ($fail) { |
# Input form
|
$r->print('<span class="LC_error">'.&mt('fail').'</span>'); |
unless ($home==1) {
|
} else { |
$r->print(
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
'<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
|
} |
}
|
} |
foreach my $key (sort(keys(%outhash))) {
|
} else { |
if ($key=~/^home_(.+)$/) {
|
# Input form |
if ($home==1) {
|
unless ($home==1) { |
$r->print(
|
$r->print( |
'<input type="hidden" name="authorspace" value="'.$1.'" />');
|
'<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">'); |
} else {
|
} |
$r->print('<option value="'.$1.'">'.$1.' - '.
|
foreach my $key (sort(keys(%outhash))) { |
&Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
|
if ($key=~/^home_(.+)$/) { |
}
|
if ($home==1) { |
}
|
$r->print( |
}
|
'<input type="hidden" name="authorspace" value="'.$1.'" />'); |
unless ($home==1) {
|
} else { |
$r->print('</select>');
|
$r->print('<option value="'.$1.'">'.$1.' - '. |
}
|
&Apache::loncommon::plainname(split(/\@/,$1)).'</option>'); |
my $title=$origcrsdata{'description'};
|
} |
$title=~s/[\/\s]+/\_/gs;
|
} |
$title=&clean($title);
|
} |
$r->print('<h3>'.&mt('Folder in Construction Space').'</h3>'
|
unless ($home==1) { |
.'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
|
$r->print('</select>'); |
&tiehash();
|
} |
$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>'
|
my $title=$origcrsdata{'description'}; |
.&Apache::loncommon::start_data_table()
|
$title=~s/[\/\s]+/\_/gs; |
.&Apache::loncommon::start_data_table_header_row()
|
$title=&clean($title); |
.'<th>'.&mt('Internal Filename').'</th>'
|
$r->print('<h3>'.&mt('Folder in Construction Space').'</h3>' |
.'<th>'.&mt('Title').'</th>'
|
.'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />'); |
.'<th>'.&mt('Save as ...').'</th>'
|
&tiehash(); |
.&Apache::loncommon::end_data_table_header_row());
|
$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>' |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
|
.&Apache::loncommon::start_data_table() |
$r->print(&Apache::loncommon::start_data_table_row()
|
.&Apache::loncommon::start_data_table_header_row() |
.'<td>'.$file.'</td>');
|
.'<th>'.&mt('Internal Filename').'</th>' |
my ($ext)=($file=~/\.(\w+)$/);
|
.'<th>'.&mt('Title').'</th>' |
my $title=$hash{'title_'.$hash{
|
.'<th>'.&mt('Save as ...').'</th>' |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
|
.&Apache::loncommon::end_data_table_header_row()); |
$r->print('<td>'.($title?$title:' ').'</td>');
|
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
if (!$title) {
|
$r->print(&Apache::loncommon::start_data_table_row() |
$title=$file;
|
.'<td>'.$file.'</td>'); |
} else {
|
my ($ext)=($file=~/\.(\w+)$/); |
$title=~s|/|_|g;
|
my $title=$hash{'title_'.$hash{ |
}
|
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
$title=~s/\.(\w+)$//;
|
$r->print('<td>'.($title?$title:' ').'</td>'); |
$title=&clean($title);
|
if (!$title) { |
$title.='.'.$ext;
|
$title=$file; |
$r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
|
} else { |
.&Apache::loncommon::end_data_table_row());
|
$title=~s|/|_|g; |
}
|
} |
$r->print(&Apache::loncommon::end_data_table());
|
$title=~s/\.(\w+)$//; |
&untiehash();
|
$title=&clean($title); |
$r->print(
|
$title.='.'.$ext; |
'<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $type DOCS").'" /></p></form>');
|
$r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
}
|
.&Apache::loncommon::end_data_table_row()); |
}
|
} |
|
$r->print(&Apache::loncommon::end_data_table()); |
|
&untiehash(); |
|
$r->print( |
sub exportbutton {
|
'<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype Documents").'" /></p></form>'); |
my $type = &Apache::loncommon::course_type();
|
} |
return '<input type="submit" name="exportcourse" value="'.
|
} |
&mt('Export '.$type.' to IMS').'" />'.
|
|
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
|
|
}
|
|
|
sub exportbutton { |
|
my $crstype = &Apache::loncommon::course_type(); |
|
return "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"exportcourse\", \"".&mt('IMS Export')."\")'>".&mt('IMS Export')."</a>". |
sub exportcourse {
|
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'<br />'; |
my $r=shift;
|
} |
my $type = &Apache::loncommon::course_type();
|
|
my %discussiontime = &Apache::lonnet::dump('discussiontimes',
|
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
|
|
my $numdisc = keys(%discussiontime);
|
sub exportcourse { |
my $navmap = Apache::lonnavmaps::navmap->new();
|
my $r=shift; |
if (!defined($navmap)) {
|
my $crstype = &Apache::loncommon::course_type(); |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package').
|
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
'<h2>IMS Export Failed</h2>'.
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); |
'<div class="LC_error">'.
|
my $numdisc = keys(%discussiontime); |
&mt('Unable to retrieve information about course contents').
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
'</div><a href="/adm/coursedocs">'.&mt('Return to Course Editor').'</a>');
|
if (!defined($navmap)) { |
&Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
$r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package'). |
return;
|
'<h2>'.&mt('IMS Export Failed').'</h2>'. |
}
|
'<div class="LC_error">'); |
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
|
if ($crstype eq 'Community') { |
my $curRes;
|
$r->print(&mt('Unable to retrieve information about community contents')); |
my $outcome;
|
} else { |
|
$r->print(&mt('Unable to retrieve information about course contents')); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
} |
['finishexport']);
|
$r->print('</div><a href="/adm/coursedocs">'); |
if ($env{'form.finishexport'}) {
|
if ($crstype eq 'Community') { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
$r->print(&mt('Return to Community Editor')); |
['archive','discussion']);
|
} else { |
|
$r->print(&mt('Return to Course Editor')); |
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
|
} |
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
|
$r->print('</a>'); |
if (@exportitems == 0 && @discussions == 0) {
|
&Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); |
$outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
|
return; |
} else {
|
} |
my $now = time;
|
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); |
my %symbs;
|
my $curRes; |
my $manifestok = 0;
|
my $outcome; |
my $imsresources;
|
|
my $tempexport;
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
my $copyresult;
|
['finishexport']); |
my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
|
if ($env{'form.finishexport'}) { |
if ($manifestok) {
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
|
['archive','discussion']); |
close($ims_manifest);
|
|
|
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); |
#Create zip file in prtspool
|
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); |
my $imszipfile = '/prtspool/'.
|
if (@exportitems == 0 && @discussions == 0) { |
$env{'user.name'}.'_'.$env{'user.domain'}.'_'.
|
$outcome = |
time.'_'.rand(1000000000).'.zip';
|
'<p class="LC_warning">' |
my $cwd = &Cwd::getcwd();
|
.&mt('As you did not select any content items or discussions' |
my $imszip = '/home/httpd/'.$imszipfile;
|
.' for export, an IMS package has not been created.') |
chdir $tempexport;
|
.'</p>' |
open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
|
.'<p>' |
close(OUTPUT);
|
.&mt('Please [_1]go back[_2] to select either content items' |
chdir $cwd;
|
.' or discussions for export.' |
$outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);
|
,'<a href="javascript:history.go(-1)">' |
if ($copyresult) {
|
,'</a>') |
$outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
|
.'</p>'; |
}
|
} else { |
} else {
|
my $now = time; |
$outcome = '<br />'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'<br />';
|
my %symbs; |
}
|
my $manifestok = 0; |
}
|
my $imsresources; |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
|
my $tempexport; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
|
my $copyresult; |
$r->print($outcome);
|
my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport); |
$r->print(&Apache::loncommon::end_page());
|
if ($manifestok) { |
} else {
|
&build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest); |
my $display;
|
close($ims_manifest); |
$display = '<form name="exportdoc" method="post">'."\n";
|
|
$display .= &mt('Choose which items you wish to export from your '.$type.'.<br /><br />');
|
#Create zip file in prtspool |
$display .= '<table border="0" cellspacing="0" cellpadding="3">'.
|
my $imszipfile = '/prtspool/'. |
'<tr><td><fieldset><legend> <b>Content items</b></legend>'.
|
$env{'user.name'}.'_'.$env{'user.domain'}.'_'. |
'<input type="button" value="check all" '.
|
time.'_'.rand(1000000000).'.zip'; |
'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
|
my $cwd = &Cwd::getcwd(); |
' <input type="button" value="uncheck all"'.
|
my $imszip = '/home/httpd/'.$imszipfile; |
' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
|
chdir $tempexport; |
'<td> </td><td> </td>'.
|
open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); |
'<td align="right"><fieldset><legend> <b>Discussion posts'.
|
close(OUTPUT); |
'</b></legend><input type="button" value="check all"'.
|
chdir $cwd; |
' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
|
$outcome .= '<p>' |
' <input type="button" value="uncheck all"'.
|
.&mt('[_1]Your IMS package[_2] is ready for download.' |
' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
|
,'<a href="'.$imszipfile.'">','</a>') |
'</tr></table>';
|
.'</p>'; |
my $curRes;
|
if ($copyresult) { |
my $depth = 0;
|
$outcome .= '<p class="LC_error">' |
my $count = 0;
|
.&mt('The following errors occurred during export - [_1]' |
my $boards = 0;
|
,$copyresult) |
my $startcount = 5;
|
.'</p>'; |
my %parent = ();
|
} |
my %children = ();
|
} else { |
my $lastcontainer = $startcount;
|
$outcome = '<p class="LC_error">' |
my @bgcolors = ('#F6F6F6','#FFFFFF');
|
.&mt('Unfortunately you will not be able to retrieve' |
$display .= '<table cellspacing="0"><tr>'.
|
.' an IMS archive of your course at this time,' |
'<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n";
|
.' because there was a problem creating a' |
if ($numdisc > 0) {
|
.' manifest file.') |
$display.='<b>Export discussion posts?</b>'."\n";
|
.'</p>' |
}
|
.'<p><a href="javascript:history.go(-1)">' |
$display.=' </td></tr>';
|
.&mt('Go Back') |
while ($curRes = $it->next()) {
|
.'</a></p>'; |
if (ref($curRes)) {
|
} |
$count ++;
|
} |
}
|
$r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package')); |
if ($curRes == $it->BEGIN_MAP()) {
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); |
$depth++;
|
$r->print($outcome); |
$parent{$depth} = $lastcontainer;
|
$r->print(&Apache::loncommon::end_page()); |
}
|
} else { |
if ($curRes == $it->END_MAP()) {
|
my $display='<form name="exportdoc" action="" method="post">'."\n". |
$depth--;
|
'<p>'. |
$lastcontainer = $parent{$depth};
|
&mt('Choose which items you wish to export from your '.$crstype.'.'). |
}
|
'</p>'. |
if (ref($curRes)) {
|
'<div class="LC_columnSection"><fieldset>'. |
my $symb = $curRes->symb();
|
'<legend>'.&mt('Content items').'</legend>'. |
my $ressymb = $symb;
|
'<input type="button" value="'.&mt('check all').'" '. |
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
|
'onclick="javascript:checkAll(document.exportdoc.archive)" />'. |
unless ($ressymb =~ m|adm/wrapper/adm|) {
|
' <input type="button" value="'.&mt('uncheck all').'"'. |
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
|
' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset>'; |
}
|
if ($numdisc > 0) { |
}
|
$display .= '<fieldset>'. |
my $color = $count%2;
|
'<legend>'.&mt('Discussion posts').'</legend>'. |
$display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
|
'<input type="button" value="'.&mt('check all').'"'. |
'<input type="checkbox" name="archive" value="'.$count.'" ';
|
' onclick="javascript:checkAll(document.exportdoc.discussion)" />'. |
if (($curRes->is_sequence()) || ($curRes->is_page())) {
|
' <input type="button" value="'.&mt('uncheck all').'"'. |
my $checkitem = $count + $boards + $startcount;
|
' onclick="javascript:uncheckAll(document.exportdoc.discussion)" />'. |
$display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
|
'</fieldset>'; |
}
|
} |
$display .= ' />'."\n";
|
$display .= '</div>'; |
for (my $i=0; $i<$depth; $i++) {
|
my $curRes; |
$display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" /><img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" />'."\n";
|
my $depth = 0; |
}
|
my $count = 0; |
if ($curRes->is_sequence()) {
|
my $boards = 0; |
$display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n";
|
my $startcount = 5; |
$lastcontainer = $count + $startcount + $boards;
|
my %parent = (); |
} elsif ($curRes->is_page()) {
|
my %children = (); |
$display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n";
|
my $lastcontainer = $startcount; |
$lastcontainer = $count + $startcount + $boards;
|
$display .= &Apache::loncommon::start_data_table() |
}
|
.&Apache::loncommon::start_data_table_header_row() |
my $currelem = $count+$boards+$startcount;
|
.'<th>'.&mt('Export content item?').'</th>'; |
$children{$parent{$depth}} .= $currelem.':';
|
if ($numdisc > 0) { |
$display .= ' '.$curRes->title().'</td>';
|
$display .= '<th>'.&mt('Export discussion posts?').'</th>'; |
if ($discussiontime{$ressymb} > 0) {
|
} |
$boards ++;
|
$display .= &Apache::loncommon::end_data_table_header_row(); |
$currelem = $count+$boards+$startcount;
|
while ($curRes = $it->next()) { |
$display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n";
|
if (ref($curRes)) { |
} else {
|
$count ++; |
$display .= '<td colspan="2"> </td>'."\n";
|
} |
}
|
if ($curRes == $it->BEGIN_MAP()) { |
}
|
$depth++; |
}
|
$parent{$depth} = $lastcontainer; |
my $scripttag = qq|
|
} |
<script>
|
if ($curRes == $it->END_MAP()) { |
|
$depth--; |
function checkAll(field) {
|
$lastcontainer = $parent{$depth}; |
if (field.length > 0) {
|
} |
for (i = 0; i < field.length; i++) {
|
if (ref($curRes)) { |
field[i].checked = true ;
|
my $symb = $curRes->symb(); |
}
|
my $ressymb = $symb; |
} else {
|
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { |
field.checked = true
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
}
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
}
|
} |
|
} |
function uncheckAll(field) {
|
my $currelem = $count+$boards+$startcount; |
if (field.length > 0) {
|
$display .= &Apache::loncommon::start_data_table_row() |
for (i = 0; i < field.length; i++) {
|
.'<td>'."\n" |
field[i].checked = false ;
|
.'<input type="checkbox" name="archive" value="'.$count.'" '; |
}
|
if (($curRes->is_sequence()) || ($curRes->is_page())) { |
} else {
|
$lastcontainer = $currelem; |
field.checked = false ;
|
$display .= 'onclick="javascript:propagateCheck('."'$currelem'".')"'; |
}
|
} |
}
|
$display .= ' />'."\n"; |
|
for (my $i=0; $i<$depth; $i++) { |
function propagateCheck(item) {
|
$display .= ('<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" alt="" />' x2)."\n"; |
if (document.exportdoc.elements[item].checked == true) {
|
} |
containerCheck(item)
|
if ($curRes->is_sequence()) { |
}
|
$display .= '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" /> '."\n"; |
}
|
} elsif ($curRes->is_page()) { |
|
$display .= '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" /> '."\n"; |
function containerCheck(item) {
|
} |
document.exportdoc.elements[item].checked = true
|
$children{$parent{$depth}} .= $currelem.':'; |
var numitems = $count + $boards + $startcount
|
$display .= ' '.$curRes->title().'</td>'."\n"; |
var parents = new Array(numitems)
|
|
for (var i=$startcount; i<numitems; i++) {
|
# Existing discussion posts? |
parents[i] = new Array
|
if ($discussiontime{$ressymb} > 0) { |
}
|
$boards ++; |
|;
|
$display .= '<td align="right">' |
|
.'<input type="checkbox" name="discussion" value="'.$count.'" />' |
foreach my $container (sort { $a <=> $b } (keys(%children))) {
|
.'</td>'."\n"; |
my @contents = split(/:/,$children{$container});
|
} elsif ($numdisc > 0) { |
for (my $i=0; $i<@contents; $i ++) {
|
$display .= '<td> </td>'."\n"; |
$scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
|
} |
}
|
$display .= &Apache::loncommon::end_data_table_row(); |
}
|
} |
|
} |
$scripttag .= qq|
|
$display .= &Apache::loncommon::end_data_table(); |
if (parents[item].length > 0) {
|
my $scripttag = qq| |
for (var j=0; j<parents[item].length; j++) {
|
<script type="text/javascript"> |
containerCheck(parents[item][j])
|
// <![CDATA[ |
}
|
function checkAll(field) { |
}
|
if (field.length > 0) { |
}
|
for (i = 0; i < field.length; i++) { |
|
field[i].checked = true ; |
</script>
|
} |
|;
|
} else { |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package',
|
field.checked = true |
$scripttag));
|
} |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
|
} |
$r->print($display.'</table>'.
|
|
'<p><input type="hidden" name="finishexport" value="1">'.
|
function uncheckAll(field) { |
'<input type="submit" name="exportcourse" value="'.
|
if (field.length > 0) { |
&mt('Export '.$type.' DOCS').'" /></p></form>');
|
for (i = 0; i < field.length; i++) { |
}
|
field[i].checked = false ; |
}
|
} |
|
} else { |
sub create_ims_store {
|
field.checked = false ; |
my ($now,$manifestok,$outcome,$tempexport) = @_;
|
} |
$$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
|
} |
my $ims_manifest;
|
|
if (!-e $$tempexport) {
|
function propagateCheck(item) { |
mkdir($$tempexport,0700);
|
if (document.exportdoc.elements[item].checked == true) { |
}
|
containerCheck(item) |
$$tempexport .= '/'.$now;
|
} |
if (!-e $$tempexport) {
|
} |
mkdir($$tempexport,0700);
|
|
}
|
function containerCheck(item) { |
$$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
|
document.exportdoc.elements[item].checked = true |
if (!-e $$tempexport) {
|
var numitems = $count + $boards + $startcount |
mkdir($$tempexport,0700);
|
var parents = new Array(numitems) |
}
|
for (var i=$startcount; i<numitems; i++) { |
if (!-e "$$tempexport/resources") {
|
parents[i] = new Array |
mkdir("$$tempexport/resources",0700);
|
} |
}
|
|; |
# open manifest file
|
|
my $manifest = '/imsmanifest.xml';
|
foreach my $container (sort { $a <=> $b } (keys(%children))) { |
my $manifestfilename = $$tempexport.$manifest;
|
my @contents = split(/:/,$children{$container}); |
if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
|
for (my $i=0; $i<@contents; $i ++) { |
$$manifestok=1;
|
$scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n"; |
print $ims_manifest
|
} |
'<?xml version="1.0" encoding="UTF-8"?>'."\n".
|
} |
'<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
|
|
' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
|
$scripttag .= qq| |
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
|
if (parents[item].length > 0) { |
' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
|
for (var j=0; j<parents[item].length; j++) { |
' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
|
containerCheck(parents[item][j]) |
' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
|
} |
' <metadata>
|
} |
<schema></schema>
|
} |
<imsmd:lom>
|
// ]]> |
<imsmd:general>
|
</script> |
<imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier>
|
|; |
<imsmd:title>
|
$r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package', |
<imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring>
|
$scripttag)); |
</imsmd:title>
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); |
</imsmd:general>
|
$r->print($display. |
</imsmd:lom>
|
'<p><input type="hidden" name="finishexport" value="1" />'. |
</metadata>'."\n".
|
'<input type="submit" name="exportcourse" value="'. |
' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
|
&mt('Export').'" /></p></form>'); |
' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
|
} |
' structure="hierarchical">'."\n".
|
} |
' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'
|
|
} else {
|
sub create_ims_store { |
$$outcome .= 'An error occurred opening the IMS manifest file.<br />'
|
my ($now,$manifestok,$outcome,$tempexport) = @_; |
;
|
$$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports'; |
}
|
my $ims_manifest; |
return $ims_manifest;
|
if (!-e $$tempexport) { |
}
|
mkdir($$tempexport,0700); |
|
} |
sub build_package {
|
$$tempexport .= '/'.$now; |
my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
|
if (!-e $$tempexport) { |
# first iterator to look for dependencies
|
mkdir($$tempexport,0700); |
my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
|
} |
my $curRes;
|
$$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'}; |
my $count = 0;
|
if (!-e $$tempexport) { |
my $depth = 0;
|
mkdir($$tempexport,0700); |
my $lastcontainer = 0;
|
} |
my %parent = ();
|
if (!-e "$$tempexport/resources") { |
my @dependencies = ();
|
mkdir("$$tempexport/resources",0700); |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
|
} |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
|
# open manifest file |
while ($curRes = $it->next()) {
|
my $manifest = '/imsmanifest.xml'; |
if (ref($curRes)) {
|
my $manifestfilename = $$tempexport.$manifest; |
$count ++;
|
if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) { |
}
|
$$manifestok=1; |
if ($curRes == $it->BEGIN_MAP()) {
|
print $ims_manifest |
$depth++;
|
'<?xml version="1.0" encoding="UTF-8"?>'."\n". |
$parent{$depth} = $lastcontainer;
|
'<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'. |
}
|
' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'. |
if ($curRes == $it->END_MAP()) {
|
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
$depth--;
|
' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'. |
$lastcontainer = $parent{$depth};
|
' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'. |
}
|
' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n". |
if (ref($curRes)) {
|
' <metadata> |
if ($curRes->is_sequence() || $curRes->is_page()) {
|
<schema></schema> |
$lastcontainer = $count;
|
<imsmd:lom> |
}
|
<imsmd:general> |
if (grep(/^$count$/,@$exportitems)) {
|
<imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier> |
&get_dependencies($exportitems,\%parent,$depth,\@dependencies);
|
<imsmd:title> |
}
|
<imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring> |
}
|
</imsmd:title> |
}
|
</imsmd:general> |
# second iterator to build manifest and store resources
|
</imsmd:lom> |
$it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
|
</metadata>'."\n". |
$depth = 0;
|
' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n". |
my $prevdepth;
|
' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'. |
$count = 0;
|
' structure="hierarchical">'."\n". |
my $imsresources;
|
' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>' |
my $pkgdepth;
|
} else { |
while ($curRes = $it->next()) {
|
$$outcome .= 'An error occurred opening the IMS manifest file.<br />' |
if ($curRes == $it->BEGIN_MAP()) {
|
; |
$prevdepth = $depth;
|
} |
$depth++;
|
return $ims_manifest; |
}
|
} |
if ($curRes == $it->END_MAP()) {
|
|
$prevdepth = $depth;
|
sub build_package { |
$depth--;
|
my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_; |
}
|
# first iterator to look for dependencies |
|
my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef); |
if (ref($curRes)) {
|
my $curRes; |
$count ++;
|
my $count = 0; |
if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) {
|
my $depth = 0; |
my $symb = $curRes->symb();
|
my $lastcontainer = 0; |
my $isvisible = 'true';
|
my %parent = (); |
my $resourceref;
|
my @dependencies = (); |
if ($curRes->randomout()) {
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$isvisible = 'false';
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
}
|
while ($curRes = $it->next()) { |
unless ($curRes->is_sequence()) {
|
if (ref($curRes)) { |
$resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
|
$count ++; |
}
|
} |
my $step = $prevdepth - $depth;
|
if ($curRes == $it->BEGIN_MAP()) { |
if (($step >= 0) && ($count > 1)) {
|
$depth++; |
while ($step >= 0) {
|
$parent{$depth} = $lastcontainer; |
print $ims_manifest "\n".' </item>'."\n";
|
} |
$step --;
|
if ($curRes == $it->END_MAP()) { |
}
|
$depth--; |
}
|
$lastcontainer = $parent{$depth}; |
$prevdepth = $depth;
|
} |
|
if (ref($curRes)) { |
my $itementry =
|
if ($curRes->is_sequence() || $curRes->is_page()) { |
'<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count.
|
$lastcontainer = $count; |
'" isvisible="'.$isvisible.'" '.$resourceref.'>'.
|
} |
'<title>'.$curRes->title().'</title>';
|
if (grep(/^$count$/,@$exportitems)) { |
print $ims_manifest "\n".$itementry;
|
&get_dependencies($exportitems,\%parent,$depth,\@dependencies); |
|
} |
unless ($curRes->is_sequence()) {
|
} |
my $content_file;
|
} |
my @hrefs = ();
|
# second iterator to build manifest and store resources |
&process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
|
$it = $navmap->getIterator(undef,undef,undef,1,undef,undef); |
if ($content_file) {
|
$depth = 0; |
$imsresources .= "\n".
|
my $prevdepth; |
' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
|
$count = 0; |
'" type="webcontent" href="'.$content_file.'">'."\n".
|
my $imsresources; |
' <file href="'.$content_file.'" />'."\n";
|
my $pkgdepth; |
foreach my $item (@hrefs) {
|
while ($curRes = $it->next()) { |
$imsresources .=
|
if ($curRes == $it->BEGIN_MAP()) { |
' <file href="'.$item.'" />'."\n";
|
$prevdepth = $depth; |
}
|
$depth++; |
if (grep(/^$count$/,@$discussions)) {
|
} |
my $ressymb = $symb;
|
if ($curRes == $it->END_MAP()) { |
my $mode;
|
$prevdepth = $depth; |
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
|
$depth--; |
unless ($ressymb =~ m|adm/wrapper/adm|) {
|
} |
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
|
|
}
|
if (ref($curRes)) { |
$mode = 'board';
|
$count ++; |
}
|
if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) { |
my %extras = (
|
my $symb = $curRes->symb(); |
caller => 'imsexport',
|
my $isvisible = 'true'; |
tempexport => $tempexport.'/resources',
|
my $resourceref; |
count => $count
|
if ($curRes->randomout()) { |
);
|
$isvisible = 'false'; |
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
|
} |
}
|
unless ($curRes->is_sequence()) { |
$imsresources .= ' </resource>'."\n";
|
$resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"'; |
}
|
} |
}
|
my $step = $prevdepth - $depth; |
$pkgdepth = $depth;
|
if (($step >= 0) && ($count > 1)) { |
}
|
while ($step >= 0) { |
}
|
print $ims_manifest "\n".' </item>'."\n"; |
}
|
$step --; |
while ($pkgdepth > 0) {
|
} |
print $ims_manifest " </item>\n";
|
} |
$pkgdepth --;
|
$prevdepth = $depth; |
}
|
|
my $resource_text = qq|
|
my $itementry = |
</organization>
|
'<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count. |
</organizations>
|
'" isvisible="'.$isvisible.'" '.$resourceref.'>'. |
<resources>
|
'<title>'.$curRes->title().'</title>'; |
$imsresources
|
print $ims_manifest "\n".$itementry; |
</resources>
|
|
</manifest>
|
unless ($curRes->is_sequence()) { |
|;
|
my $content_file; |
print $ims_manifest $resource_text;
|
my @hrefs = (); |
}
|
&process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport); |
|
if ($content_file) { |
sub get_dependencies {
|
$imsresources .= "\n". |
my ($exportitems,$parent,$depth,$dependencies) = @_;
|
' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count. |
if ($depth > 1) {
|
'" type="webcontent" href="'.$content_file.'">'."\n". |
if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) {
|
' <file href="'.$content_file.'" />'."\n"; |
push(@{$dependencies},$$parent{$depth});
|
foreach my $item (@hrefs) { |
if ($depth > 2) {
|
$imsresources .= |
&get_dependencies($exportitems,$parent,$depth-1,$dependencies);
|
' <file href="'.$item.'" />'."\n"; |
}
|
} |
}
|
if (grep(/^$count$/,@$discussions)) { |
}
|
my $ressymb = $symb; |
}
|
my $mode; |
|
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { |
sub process_content {
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
my $content_type;
|
} |
my $message;
|
$mode = 'board'; |
my @uploads = ();
|
} |
if ($curRes->is_sequence()) {
|
my %extras = ( |
$content_type = 'sequence';
|
caller => 'imsexport', |
} elsif ($curRes->is_page()) {
|
tempexport => $tempexport.'/resources', |
$content_type = 'page'; # need to handle individual items in pages.
|
count => $count |
} elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
|
); |
$content_type = 'syllabus';
|
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras); |
my $contents = &Apache::imsexport::templatedpage($content_type);
|
} |
if ($contents) {
|
$imsresources .= ' </resource>'."\n"; |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
} |
}
|
} |
} elsif ($symb =~ m-\.sequence___\d+___ext-) {
|
$pkgdepth = $depth; |
$content_type = 'external';
|
} |
my $title = $curRes->title;
|
} |
my $contents = &Apache::imsexport::external($symb,$title);
|
} |
if ($contents) {
|
while ($pkgdepth > 0) { |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
print $ims_manifest " </item>\n"; |
}
|
$pkgdepth --; |
} elsif ($symb =~ m-adm/navmaps$-) {
|
} |
$content_type = 'navmap';
|
my $resource_text = qq| |
} elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
|
</organization> |
$content_type = 'simplepage';
|
</organizations> |
my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
|
<resources> |
if ($contents) {
|
$imsresources |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
</resources> |
}
|
</manifest> |
} elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
|
|; |
$content_type = 'simpleproblem';
|
print $ims_manifest $resource_text; |
my $contents = &Apache::imsexport::simpleproblem($symb);
|
} |
if ($contents) {
|
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
sub get_dependencies { |
}
|
my ($exportitems,$parent,$depth,$dependencies) = @_; |
} elsif ($symb =~ m-lib/templates/examupload\.problem$-) {
|
if ($depth > 1) { |
$content_type = 'examupload';
|
if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) { |
} elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) {
|
push(@{$dependencies},$$parent{$depth}); |
$content_type = 'bulletinboard';
|
if ($depth > 2) { |
my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
|
&get_dependencies($exportitems,$parent,$depth-1,$dependencies); |
if ($contents) {
|
} |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
} |
}
|
} |
} elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
|
} |
$content_type = 'aboutme';
|
|
my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
|
sub process_content { |
if ($contents) {
|
my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_; |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
my $content_type; |
}
|
my $message; |
} elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
|
my @uploads = (); |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
|
if ($curRes->is_sequence()) { |
} elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
|
$content_type = 'sequence'; |
my $canedit = 0;
|
} elsif ($curRes->is_page()) { |
if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) {
|
$content_type = 'page'; # need to handle individual items in pages. |
$canedit= 1;
|
} elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) { |
}
|
$content_type = 'syllabus'; |
# only include problem code where current user is author
|
my $contents = &Apache::imsexport::templatedpage($content_type); |
if ($canedit) {
|
if ($contents) { |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
} else {
|
} |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
|
} elsif ($symb =~ m-\.sequence___\d+___ext-) { |
}
|
$content_type = 'external'; |
} elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
|
my $title = $curRes->title; |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
|
my $contents = &Apache::imsexport::external($symb,$title); |
}
|
if ($contents) { |
if (@uploads > 0) {
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
foreach my $item (@uploads) {
|
} |
my $uploadmsg = '';
|
} elsif ($symb =~ m-adm/navmaps$-) { |
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
|
$content_type = 'navmap'; |
if ($uploadmsg) {
|
} elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) { |
$$copyresult .= $uploadmsg."\n";
|
$content_type = 'simplepage'; |
}
|
my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads); |
}
|
if ($contents) { |
}
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
if ($message) {
|
} |
$$copyresult .= $message."\n";
|
} elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) { |
}
|
$content_type = 'simpleproblem'; |
}
|
my $contents = &Apache::imsexport::simpleproblem($symb); |
|
if ($contents) { |
sub replicate_content {
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
|
} |
my ($map,$ind,$url);
|
} elsif ($symb =~ m-lib/templates/examupload\.problem$-) { |
if ($caller eq 'templateupload') {
|
$content_type = 'examupload'; |
$url = $symb;
|
} elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) { |
$url =~ s#//#/#g;
|
$content_type = 'bulletinboard'; |
} else {
|
my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2); |
($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
|
if ($contents) { |
}
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
my $content;
|
} |
my $filename;
|
} elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) { |
my $repstatus;
|
$content_type = 'aboutme'; |
my $content_name;
|
my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2); |
if ($url =~ m-/([^/]+)$-) {
|
if ($contents) { |
$filename = $1;
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
if (!-e $tempexport.'/resources') {
|
} |
mkdir($tempexport.'/resources',0700);
|
} elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) { |
}
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded'); |
if (!-e $tempexport.'/resources/'.$count) {
|
} elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) { |
mkdir($tempexport.'/resources/'.$count,0700);
|
my $canedit = 0; |
}
|
if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) { |
my $destination = $tempexport.'/resources/'.$count.'/'.$filename;
|
$canedit= 1; |
my $copiedfile;
|
} |
if ($copiedfile = Apache::File->new('>'.$destination)) {
|
# only include problem code where current user is author |
my $content;
|
if ($canedit) { |
if ($caller eq 'resource') {
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource'); |
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
|
} else { |
my $filepath = &Apache::lonnet::filelocation($respath,$url);
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit'); |
$content = &Apache::lonnet::getfile($filepath);
|
} |
if ($content eq -1) {
|
} elsif ($symb =~ m-uploaded/$cdom/$cnum-) { |
$$message = 'Could not copy file '.$filename;
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded'); |
} else {
|
} |
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource');
|
if (@uploads > 0) { |
$repstatus = 'ok';
|
foreach my $item (@uploads) { |
}
|
my $uploadmsg = ''; |
} elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
|
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload'); |
my $rtncode;
|
if ($uploadmsg) { |
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
|
$$copyresult .= $uploadmsg."\n"; |
if ($repstatus eq 'ok') {
|
} |
if ($url =~ /\.html?$/i) {
|
} |
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded');
|
} |
}
|
if ($message) { |
} else {
|
$$copyresult .= $message."\n"; |
$$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n";
|
} |
}
|
} |
} elsif ($caller eq 'noedit') {
|
|
# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this.
|
sub replicate_content { |
$repstatus = 'ok';
|
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_; |
$content = 'Not the owner of this resource';
|
my ($map,$ind,$url); |
}
|
if ($caller eq 'templateupload') { |
if ($repstatus eq 'ok') {
|
$url = $symb; |
print $copiedfile $content;
|
$url =~ s#//#/#g; |
}
|
} else { |
close($copiedfile);
|
($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); |
} else {
|
} |
$$message = 'Could not open destination file for '.$filename."<br />\n";
|
my $content; |
}
|
my $filename; |
} else {
|
my $repstatus; |
$$message = 'Could not determine name of file for '.$symb."<br />\n";
|
my $content_name; |
}
|
if ($url =~ m-/([^/]+)$-) { |
if ($repstatus eq 'ok') {
|
$filename = $1; |
$content_name = 'resources/'.$count.'/'.$filename;
|
if (!-e $tempexport.'/resources') { |
}
|
mkdir($tempexport.'/resources',0700); |
return $content_name;
|
} |
}
|
if (!-e $tempexport.'/resources/'.$count) { |
|
mkdir($tempexport.'/resources/'.$count,0700); |
sub extract_media {
|
} |
my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
|
my $destination = $tempexport.'/resources/'.$count.'/'.$filename; |
my ($dirpath,$container);
|
my $copiedfile; |
my %allfiles = ();
|
if ($copiedfile = Apache::File->new('>'.$destination)) { |
my %codebase = ();
|
my $content; |
if ($url =~ m-(.*/)([^/]+)$-) {
|
if ($caller eq 'resource') { |
$dirpath = $1;
|
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; |
$container = $2;
|
my $filepath = &Apache::lonnet::filelocation($respath,$url); |
} else {
|
$content = &Apache::lonnet::getfile($filepath); |
$dirpath = $url;
|
if ($content eq -1) { |
$container = '';
|
$$message = 'Could not copy file '.$filename; |
}
|
} else { |
&Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
|
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource'); |
foreach my $embed_file (keys(%allfiles)) {
|
$repstatus = 'ok'; |
my $filename;
|
} |
if ($embed_file =~ m#([^/]+)$#) {
|
} elsif ($caller eq 'uploaded' || $caller eq 'templateupload') { |
$filename = $1;
|
my $rtncode; |
} else {
|
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode); |
$filename = $embed_file;
|
if ($repstatus eq 'ok') { |
}
|
if ($url =~ /\.html?$/i) { |
my $newname = 'res/'.$filename;
|
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded'); |
my ($rtncode,$embed_content,$repstatus);
|
} |
my $embed_url;
|
} else { |
if ($embed_file =~ m-^/-) {
|
$$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n"; |
$embed_url = $embed_file; # points to absolute path
|
} |
} else {
|
} elsif ($caller eq 'noedit') { |
if ($embed_file =~ m-https?://-) {
|
# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. |
next; # points to url
|
$repstatus = 'ok'; |
} else {
|
$content = 'Not the owner of this resource'; |
$embed_url = $dirpath.$embed_file; # points to relative path
|
} |
}
|
if ($repstatus eq 'ok') { |
}
|
print $copiedfile $content; |
if ($caller eq 'resource') {
|
} |
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
|
close($copiedfile); |
my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url);
|
} else { |
$embed_content = &Apache::lonnet::getfile($embed_path);
|
$$message = 'Could not open destination file for '.$filename."<br />\n"; |
unless ($embed_content eq -1) {
|
} |
$repstatus = 'ok';
|
} else { |
}
|
$$message = 'Could not determine name of file for '.$symb."<br />\n"; |
} elsif ($caller eq 'uploaded') {
|
} |
|
if ($repstatus eq 'ok') { |
$repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
|
$content_name = 'resources/'.$count.'/'.$filename; |
}
|
} |
if ($repstatus eq 'ok') {
|
return $content_name; |
my $destination = $tempexport.'/resources/'.$count.'/res';
|
} |
if (!-e "$destination") {
|
|
mkdir($destination,0755);
|
sub extract_media { |
}
|
my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_; |
$destination .= '/'.$filename;
|
my ($dirpath,$container); |
my $copiedfile;
|
my %allfiles = (); |
if ($copiedfile = Apache::File->new('>'.$destination)) {
|
my %codebase = (); |
print $copiedfile $embed_content;
|
if ($url =~ m-(.*/)([^/]+)$-) { |
push(@{$href},'resources/'.$count.'/res/'.$filename);
|
$dirpath = $1; |
my $attrib_regexp = '';
|
$container = $2; |
if (@{$allfiles{$embed_file}} > 1) {
|
} else { |
$attrib_regexp = join('|',@{$allfiles{$embed_file}});
|
$dirpath = $url; |
} else {
|
$container = ''; |
$attrib_regexp = $allfiles{$embed_file}[0];
|
} |
}
|
&Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content); |
$$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
|
foreach my $embed_file (keys(%allfiles)) { |
if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
|
my $filename; |
$$content =~ s#\Q$embed_file\E#$newname#gi;
|
if ($embed_file =~ m#([^/]+)$#) { |
}
|
$filename = $1; |
}
|
} else { |
} else {
|
$filename = $embed_file; |
$$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n";
|
} |
}
|
my $newname = 'res/'.$filename; |
}
|
my ($rtncode,$embed_content,$repstatus); |
return;
|
my $embed_url; |
}
|
if ($embed_file =~ m-^/-) { |
|
$embed_url = $embed_file; # points to absolute path |
sub store_template {
|
} else { |
my ($contents,$tempexport,$count,$content_type) = @_;
|
if ($embed_file =~ m-https?://-) { |
if ($contents) {
|
next; # points to url |
if ($tempexport) {
|
} else { |
if (!-e $tempexport.'/resources') {
|
$embed_url = $dirpath.$embed_file; # points to relative path |
mkdir($tempexport.'/resources',0700);
|
} |
}
|
} |
if (!-e $tempexport.'/resources/'.$count) {
|
if ($caller eq 'resource') { |
mkdir($tempexport.'/resources/'.$count,0700);
|
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; |
}
|
my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url); |
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
|
$embed_content = &Apache::lonnet::getfile($embed_path); |
my $storetemplate;
|
unless ($embed_content eq -1) { |
if ($storetemplate = Apache::File->new('>'.$destination)) {
|
$repstatus = 'ok'; |
print $storetemplate $contents;
|
} |
close($storetemplate);
|
} elsif ($caller eq 'uploaded') { |
}
|
|
if ($content_type eq 'external') {
|
$repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode); |
return 'resources/'.$count.'/'.$content_type.'.html';
|
} |
} else {
|
if ($repstatus eq 'ok') { |
return 'resources/'.$count.'/'.$content_type.'.xml';
|
my $destination = $tempexport.'/resources/'.$count.'/res'; |
}
|
if (!-e "$destination") { |
}
|
mkdir($destination,0755); |
}
|
} |
}
|
$destination .= '/'.$filename; |
|
my $copiedfile; |
|
if ($copiedfile = Apache::File->new('>'.$destination)) { |
sub group_import {
|
print $copiedfile $embed_content; |
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
|
push(@{$href},'resources/'.$count.'/res/'.$filename); |
|
my $attrib_regexp = ''; |
while (@files) {
|
if (@{$allfiles{$embed_file}} > 1) { |
my ($name, $url, $residx) = @{ shift(@files) };
|
$attrib_regexp = join('|',@{$allfiles{$embed_file}}); |
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
|
} else { |
&& ($caller eq 'londocs')
|
$attrib_regexp = $allfiles{$embed_file}[0]; |
&& (!&Apache::lonnet::stat_file($url))) {
|
} |
|
$$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi; |
my $errtext = '';
|
if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) { |
my $fatal = 0;
|
$$content =~ s#\Q$embed_file\E#$newname#gi; |
my $newmapstr = '<map>'."\n".
|
} |
'<resource id="1" src="" type="start"></resource>'."\n".
|
} |
'<link from="1" to="2" index="1"></link>'."\n".
|
} else { |
'<resource id="2" src="" type="finish"></resource>'."\n".
|
$$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n"; |
'</map>';
|
} |
$env{'form.output'}=$newmapstr;
|
} |
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
|
return; |
'output',$1.$2);
|
} |
if ($result != m|^/uploaded/|) {
|
|
$errtext.='Map not saved: A network error occurred when trying to save the new map. ';
|
sub store_template { |
$fatal = 2;
|
my ($contents,$tempexport,$count,$content_type) = @_; |
}
|
if ($contents) { |
if ($fatal) {
|
if ($tempexport) { |
return ($errtext,$fatal);
|
if (!-e $tempexport.'/resources') { |
}
|
mkdir($tempexport.'/resources',0700); |
}
|
} |
if ($url) {
|
if (!-e $tempexport.'/resources/'.$count) { |
if (!$residx
|
mkdir($tempexport.'/resources/'.$count,0700); |
|| defined($LONCAPA::map::zombies[$residx])) {
|
} |
$residx = &LONCAPA::map::getresidx($url,$residx);
|
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml'; |
push(@LONCAPA::map::order, $residx);
|
my $storetemplate; |
}
|
if ($storetemplate = Apache::File->new('>'.$destination)) { |
my $ext = 'false';
|
print $storetemplate $contents; |
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
|
close($storetemplate); |
$url = &LONCAPA::map::qtunescape($url);
|
} |
$name = &LONCAPA::map::qtunescape($name);
|
if ($content_type eq 'external') { |
$LONCAPA::map::resources[$residx] =
|
return 'resources/'.$count.'/'.$content_type.'.html'; |
join(':', ($name, $url, $ext, 'normal', 'res'));
|
} else { |
}
|
return 'resources/'.$count.'/'.$content_type.'.xml'; |
}
|
} |
return &storemap($coursenum, $coursedom, $folder.'.'.$container);
|
} |
}
|
} |
|
} |
sub breadcrumbs {
|
|
my ($where,$allowed,$type)=@_;
|
|
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
sub group_import { |
my (@folders);
|
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; |
if ($env{'form.pagepath'}) {
|
|
@folders = split('&',$env{'form.pagepath'});
|
while (@files) { |
} else {
|
my ($name, $url, $residx) = @{ shift(@files) }; |
@folders=split('&',$env{'form.folderpath'});
|
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) |
}
|
&& ($caller eq 'londocs') |
my $folderpath;
|
&& (!&Apache::lonnet::stat_file($url))) { |
my $cpinfo='';
|
|
my $plain='';
|
my $errtext = ''; |
my $randompick=-1;
|
my $fatal = 0; |
my $isencrypted=0;
|
my $newmapstr = '<map>'."\n". |
my $ishidden=0;
|
'<resource id="1" src="" type="start"></resource>'."\n". |
my $is_random_order=0;
|
'<link from="1" to="2" index="1"></link>'."\n". |
while (@folders) {
|
'<resource id="2" src="" type="finish"></resource>'."\n". |
my $folder=shift(@folders);
|
'</map>'; |
my $foldername=shift(@folders);
|
$env{'form.output'}=$newmapstr; |
if ($folderpath) {$folderpath.='&';}
|
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, |
$folderpath.=$folder.'&'.$foldername;
|
'output',$1.$2); |
my $url='/adm/coursedocs?folderpath='.
|
if ($result != m|^/uploaded/|) { |
&escape($folderpath);
|
$errtext.='Map not saved: A network error occurred when trying to save the new map. '; |
my $name=&unescape($foldername);
|
$fatal = 2; |
# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
|
} |
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
|
if ($fatal) { |
if ($1 ne '') {
|
return ($errtext,$fatal); |
$randompick=$1;
|
} |
} else {
|
} |
$randompick=-1;
|
if ($url) { |
}
|
if (!$residx |
if ($2) { $ishidden=1; }
|
|| defined($LONCAPA::map::zombies[$residx])) { |
if ($3) { $isencrypted=1; }
|
$residx = &LONCAPA::map::getresidx($url,$residx); |
if ($4 ne '') { $is_random_order = 1; }
|
push(@LONCAPA::map::order, $residx); |
if ($folder eq 'supplemental') {
|
} |
if ($allowed) {
|
my $ext = 'false'; |
$name = &mt('Supplemental '.$type.' Documents');
|
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } |
} else {
|
$url = &LONCAPA::map::qtunescape($url); |
$name = &mt($type.' Documents');
|
$name = &LONCAPA::map::qtunescape($name); |
}
|
$LONCAPA::map::resources[$residx] = |
}
|
join(':', ($name, $url, $ext, 'normal', 'res')); |
&Apache::lonhtmlcommon::add_breadcrumb(
|
} |
{'href'=>$url.$cpinfo,
|
} |
'title'=>$name,
|
return &storemap($coursenum, $coursedom, $folder.'.'.$container); |
'text'=>'<font size="+1">'.
|
} |
$name.'</font>',
|
|
'no_mt'=>1,
|
sub breadcrumbs { |
});
|
my ($allowed,$crstype)=@_; |
$plain.=$name.' > ';
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
}
|
my (@folders); |
$plain=~s/\>\;\s*$//;
|
if ($env{'form.pagepath'}) { |
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
|
@folders = split('&',$env{'form.pagepath'}); |
'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
|
} else { |
}
|
@folders=split('&',$env{'form.folderpath'}); |
|
} |
sub log_docs {
|
my $folderpath; |
return &Apache::lonnet::instructor_log('docslog',@_);
|
my $cpinfo=''; |
}
|
my $plain=''; |
|
my $randompick=-1; |
{
|
my $isencrypted=0; |
my @oldresources=();
|
my $ishidden=0; |
my @oldorder=();
|
my $is_random_order=0; |
my $parmidx;
|
if (!$allowed) { |
my %parmaction=();
|
my $description = $env{'course.'.$env{'request.course.id'}.'.description'}; |
my %parmvalue=();
|
&Apache::lonhtmlcommon::add_breadcrumb( |
my $changedflag;
|
{'href' => '/adm/menu', |
|
'title'=> 'Go to main menu', |
sub snapshotbefore {
|
'text' => $description, |
@oldresources=@LONCAPA::map::resources;
|
}); |
@oldorder=@LONCAPA::map::order;
|
$plain .= $description.' >'; |
$parmidx=undef;
|
} |
%parmaction=();
|
while (@folders) { |
%parmvalue=();
|
my $folder=shift(@folders); |
$changedflag=0;
|
my $foldername=shift(@folders); |
}
|
if ($folderpath) {$folderpath.='&';} |
|
$folderpath.=$folder.'&'.$foldername; |
sub remember_parms {
|
my $url='/adm/coursedocs?folderpath='. |
my ($idx,$parameter,$action,$value)=@_;
|
&escape($folderpath); |
$parmidx=$idx;
|
my $name=&unescape($foldername); |
$parmaction{$parameter}=$action;
|
# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername |
$parmvalue{$parameter}=$value;
|
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; |
$changedflag=1;
|
if ($1 ne '') { |
}
|
$randompick=$1; |
|
} else { |
sub log_differences {
|
$randompick=-1; |
my ($plain)=@_;
|
} |
my %storehash=('folder' => $plain,
|
if ($2) { $ishidden=1; } |
'currentfolder' => $env{'form.folder'});
|
if ($3) { $isencrypted=1; } |
if ($parmidx) {
|
if ($4 ne '') { $is_random_order = 1; } |
$storehash{'parameter_res'}=$oldresources[$parmidx];
|
if ($folder eq 'supplemental') { |
foreach my $parm (keys(%parmaction)) {
|
$name = &mt('Supplemental '.$crstype.' Documents'); |
$storehash{'parameter_action_'.$parm}=$parmaction{$parm};
|
} |
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
|
&Apache::lonhtmlcommon::add_breadcrumb( |
}
|
{'href'=>$url.$cpinfo, |
}
|
'title'=>$name, |
my $maxidx=$#oldresources;
|
'text'=>$name, |
if ($#LONCAPA::map::resources>$#oldresources) {
|
'no_mt'=>1, |
$maxidx=$#LONCAPA::map::resources;
|
}); |
}
|
$plain.=$name.' > '; |
for (my $idx=0; $idx<=$maxidx; $idx++) {
|
} |
if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
|
$plain=~s/\>\;\s*$//; |
$storehash{'before_resources_'.$idx}=$oldresources[$idx];
|
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', |
$storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
|
undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); |
$changedflag=1;
|
} |
}
|
|
if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
|
sub log_docs { |
$storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
|
return &Apache::lonnet::instructor_log('docslog',@_); |
$storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
} |
$changedflag=1;
|
|
}
|
{ |
}
|
my @oldresources=(); |
$storehash{'maxidx'}=$maxidx;
|
my @oldorder=(); |
if ($changedflag) { &log_docs(\%storehash); }
|
my $parmidx; |
}
|
my %parmaction=(); |
}
|
my %parmvalue=(); |
|
my $changedflag; |
|
|
|
sub snapshotbefore { |
|
@oldresources=@LONCAPA::map::resources; |
|
@oldorder=@LONCAPA::map::order; |
sub docs_change_log {
|
$parmidx=undef; |
my ($r)=@_;
|
%parmaction=(); |
my $folder=$env{'form.folder'};
|
%parmvalue=(); |
$r->print(&Apache::loncommon::start_page('Course Document Change Log'));
|
$changedflag=0; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
|
} |
my %docslog=&Apache::lonnet::dump('nohist_docslog',
|
|
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
sub remember_parms { |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
my ($idx,$parameter,$action,$value)=@_; |
|
$parmidx=$idx; |
if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
|
$parmaction{$parameter}=$action; |
|
$parmvalue{$parameter}=$value; |
$r->print('<form action="/adm/coursedocs" method="post" name="docslog">'.
|
$changedflag=1; |
'<input type="hidden" name="docslog" value="1" />');
|
} |
|
|
my %saveable_parameters = ('show' => 'scalar',);
|
sub log_differences { |
&Apache::loncommon::store_course_settings('docs_log',
|
my ($plain)=@_; |
\%saveable_parameters);
|
my %storehash=('folder' => $plain, |
&Apache::loncommon::restore_course_settings('docs_log',
|
'currentfolder' => $env{'form.folder'}); |
\%saveable_parameters);
|
if ($parmidx) { |
if (!$env{'form.show'}) { $env{'form.show'}=10; }
|
$storehash{'parameter_res'}=$oldresources[$parmidx]; |
my %lt=('hiddenresource' => 'Resources hidden',
|
foreach my $parm (keys(%parmaction)) { |
'encrypturl' => 'URL hidden',
|
$storehash{'parameter_action_'.$parm}=$parmaction{$parm}; |
'randompick' => 'Randomly pick',
|
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm}; |
'randomorder' => 'Randomly ordered',
|
} |
'set' => 'set to',
|
} |
'del' => 'deleted');
|
my $maxidx=$#oldresources; |
$r->print(&Apache::loncommon::display_filter().
|
if ($#LONCAPA::map::resources>$#oldresources) { |
'<input type="hidden" name="folder" value="'.$folder.'" />'.
|
$maxidx=$#LONCAPA::map::resources; |
'<input type="submit" value="'.&mt('Display').'" /></form>');
|
} |
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
|
for (my $idx=0; $idx<=$maxidx; $idx++) { |
'<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
|
if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) { |
&mt('After').'</th>'.
|
$storehash{'before_resources_'.$idx}=$oldresources[$idx]; |
&Apache::loncommon::end_data_table_header_row());
|
$storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx]; |
my $shown=0;
|
$changedflag=1; |
foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
|
} |
if ($env{'form.displayfilter'} eq 'currentfolder') {
|
if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) { |
if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
|
$storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]]; |
}
|
$storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
my @changes=keys(%{$docslog{$id}{'logentry'}});
|
$changedflag=1; |
if ($env{'form.displayfilter'} eq 'containing') {
|
} |
my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
|
} |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
|
$storehash{'maxidx'}=$maxidx; |
foreach my $key (@changes) {
|
if ($changedflag) { &log_docs(\%storehash); } |
$wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
|
} |
}
|
} |
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
|
|
}
|
|
my $count = 0;
|
|
my $time =
|
|
&Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
|
|
my $plainname =
|
sub docs_change_log { |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
|
my ($r)=@_; |
$docslog{$id}{'exe_udom'});
|
my $folder=$env{'form.folder'}; |
my $about_me_link =
|
$r->print(&Apache::loncommon::start_page('Course Document Change Log')); |
&Apache::loncommon::aboutmewrapper($plainname,
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log')); |
$docslog{$id}{'exe_uname'},
|
my %docslog=&Apache::lonnet::dump('nohist_docslog', |
$docslog{$id}{'exe_udom'});
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
my $send_msg_link='';
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
|
|
|| ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
|
if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); } |
$send_msg_link ='<br />'.
|
|
&Apache::loncommon::messagewrapper(&mt('Send message'),
|
$r->print('<form action="/adm/coursedocs" method="post" name="docslog">'. |
$docslog{$id}{'exe_uname'},
|
'<input type="hidden" name="docslog" value="1" />'); |
$docslog{$id}{'exe_udom'});
|
|
}
|
my %saveable_parameters = ('show' => 'scalar',); |
$r->print(&Apache::loncommon::start_data_table_row());
|
&Apache::loncommon::store_course_settings('docs_log', |
$r->print('<td>'.$time.'</td>
|
\%saveable_parameters); |
<td>'.$about_me_link.
|
&Apache::loncommon::restore_course_settings('docs_log', |
'<br /><tt>'.$docslog{$id}{'exe_uname'}.
|
\%saveable_parameters); |
':'.$docslog{$id}{'exe_udom'}.'</tt>'.
|
if (!$env{'form.show'}) { $env{'form.show'}=10; } |
$send_msg_link.'</td><td>'.
|
# FIXME: internationalization seems wrong here |
$docslog{$id}{'logentry'}{'folder'}.'</td><td>');
|
my %lt=('hiddenresource' => 'Resources hidden', |
# Before
|
'encrypturl' => 'URL hidden', |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
'randompick' => 'Randomly pick', |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
'randomorder' => 'Randomly ordered', |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
'set' => 'set to', |
if ($oldname ne $newname) {
|
'del' => 'deleted'); |
$r->print(&LONCAPA::map::qtescape($oldname));
|
$r->print(&Apache::loncommon::display_filter(). |
}
|
'<input type="hidden" name="folder" value="'.$folder.'" />'. |
}
|
'<input type="submit" value="'.&mt('Display').'" /></form>'); |
$r->print('<ul>');
|
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
'<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'. |
if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
|
&mt('After').'</th>'. |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
|
&Apache::loncommon::end_data_table_header_row()); |
}
|
my $shown=0; |
}
|
foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) { |
$r->print('</ul>');
|
if ($env{'form.displayfilter'} eq 'currentfolder') { |
# After
|
if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; } |
$r->print('</td><td>');
|
} |
|
my @changes=keys(%{$docslog{$id}{'logentry'}}); |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
if ($env{'form.displayfilter'} eq 'containing') { |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'. |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'}); |
if ($oldname ne '' && $oldname ne $newname) {
|
foreach my $key (@changes) { |
$r->print(&LONCAPA::map::qtescape($newname));
|
$wholeentry.=':'.$docslog{$id}{'logentry'}{$key}; |
}
|
} |
}
|
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } |
$r->print('<ul>');
|
} |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
my $count = 0; |
if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
|
my $time = |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
|
&Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'}); |
}
|
my $plainname = |
}
|
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'}, |
$r->print('</ul>');
|
$docslog{$id}{'exe_udom'}); |
if ($docslog{$id}{'logentry'}{'parameter_res'}) {
|
my $about_me_link = |
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
|
&Apache::loncommon::aboutmewrapper($plainname, |
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
|
$docslog{$id}{'exe_uname'}, |
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
|
$docslog{$id}{'exe_udom'}); |
$r->print('<li>'.
|
my $send_msg_link=''; |
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
|
if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'}) |
$docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
|
|| ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) { |
.'</li>');
|
$send_msg_link ='<br />'. |
}
|
&Apache::loncommon::messagewrapper(&mt('Send message'), |
}
|
$docslog{$id}{'exe_uname'}, |
$r->print('</ul>');
|
$docslog{$id}{'exe_udom'}); |
}
|
} |
# End
|
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print('</td>'.&Apache::loncommon::end_data_table_row());
|
$r->print('<td>'.$time.'</td> |
$shown++;
|
<td>'.$about_me_link. |
if (!($env{'form.show'} eq &mt('all')
|
'<br /><tt>'.$docslog{$id}{'exe_uname'}. |
|| $shown<=$env{'form.show'})) { last; }
|
':'.$docslog{$id}{'exe_udom'}.'</tt>'. |
}
|
$send_msg_link.'</td><td>'. |
$r->print(&Apache::loncommon::end_data_table());
|
$docslog{$id}{'logentry'}{'folder'}.'</td><td>'); |
}
|
# Before |
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
sub update_paste_buffer {
|
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0]; |
my ($coursenum,$coursedom) = @_;
|
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0]; |
|
if ($oldname ne $newname) { |
return if (!defined($env{'form.markcopy'}));
|
$r->print(&LONCAPA::map::qtescape($oldname)); |
return if (!defined($env{'form.copyfolder'}));
|
} |
return if ($env{'form.markcopy'} < 0);
|
} |
|
$r->print('<ul>'); |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
$env{'form.copyfolder'});
|
if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) { |
|
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>'); |
return if ($fatal);
|
} |
|
} |
# Mark for copying
|
$r->print('</ul>'); |
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
|
# After |
if (&is_supplemental_title($title)) {
|
$r->print('</td><td>'); |
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
|
|
($title) = &parse_supplemental_title($title);
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
} elsif ($env{'docs.markedcopy_supplemental'}) {
|
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0]; |
&Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
|
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0]; |
}
|
if ($oldname ne '' && $oldname ne $newname) { |
$url=~s{http(:|:)//https(:|:)//}{https$2//};
|
$r->print(&LONCAPA::map::qtescape($newname)); |
|
} |
&Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
|
} |
'docs.markedcopy_url' => $url});
|
$r->print('<ul>'); |
delete($env{'form.markcopy'});
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
}
|
if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) { |
|
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>'); |
sub print_paste_buffer {
|
} |
my ($r,$container) = @_;
|
} |
return if (!defined($env{'docs.markedcopy_url'}));
|
$r->print('</ul>'); |
|
if ($docslog{$id}{'logentry'}{'parameter_res'}) { |
$r->print(<<ENDPASTE);
|
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>'); |
<form name="pasteform" action="/adm/coursedocs" method="post"><p>
|
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') { |
ENDPASTE
|
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) { |
$r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
|
# FIXME: internationalization seems wrong here |
|
$r->print('<li>'. |
my $type;
|
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]', |
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
|
$docslog{$id}{'logentry'}{'parameter_value_'.$parameter}) |
$type = &mt('External Resource');
|
.'</li>'); |
$r->print($type.': '.
|
} |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
|
} |
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
|
$r->print('</ul>'); |
} else {
|
} |
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
|
# End |
my $icon = &Apache::loncommon::icon($extension);
|
$r->print('</td>'.&Apache::loncommon::end_data_table_row()); |
if ($extension eq 'sequence' &&
|
$shown++; |
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
|
if (!($env{'form.show'} eq &mt('all') |
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
|
|| $shown<=$env{'form.show'})) { last; } |
$icon .= '/folder_closed.gif';
|
} |
}
|
$r->print(&Apache::loncommon::end_data_table()); |
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
|
} |
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
|
|
}
|
sub update_paste_buffer { |
if ($container eq 'page') {
|
my ($coursenum,$coursedom) = @_; |
$r->print('
|
|
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
|
return if (!defined($env{'form.markcopy'})); |
<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
|
return if (!defined($env{'form.copyfolder'})); |
');
|
return if ($env{'form.markcopy'} < 0); |
} else {
|
|
$r->print('
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
$env{'form.copyfolder'}); |
');
|
|
}
|
return if ($fatal); |
$r->print('</p></form>');
|
|
}
|
# Mark for copying |
|
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]); |
sub do_paste_from_buffer {
|
if (&is_supplemental_title($title)) { |
my ($coursenum,$coursedom,$folder) = @_;
|
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title}); |
|
($title) = &parse_supplemental_title($title); |
if (!$env{'form.pastemarked'}) {
|
} elsif ($env{'docs.markedcopy_supplemental'}) { |
return;
|
&Apache::lonnet::delenv('docs.markedcopy_supplemental'); |
}
|
} |
|
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
# paste resource to end of list
|
|
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
|
&Apache::lonnet::appenv({'docs.markedcopy_title' => $title, |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
|
'docs.markedcopy_url' => $url}); |
# Maps need to be copied first
|
delete($env{'form.markcopy'}); |
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
|
} |
$title=&mt('Copy of').' '.$title;
|
|
my $newid=$$.int(rand(100)).time;
|
sub print_paste_buffer { |
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
|
my ($r,$container) = @_; |
if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
|
return if (!defined($env{'docs.markedcopy_url'})); |
my $path = $1;
|
|
my $prefix = $2;
|
$r->print('<fieldset>' |
my $ancestor = $3;
|
.'<legend>'.&mt('Clipboard').'</legend>' |
if (length($ancestor) > 10) {
|
.'<form name="pasteform" action="/adm/coursedocs" method="post">' |
$ancestor = substr($ancestor,-10,10);
|
.'<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ' |
}
|
); |
$oldid = $path.$prefix.$ancestor;
|
|
}
|
my $type; |
my $counter = 0;
|
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
my $newurl=$oldid.$newid.'.'.$ext;
|
$type = &mt('External Resource'); |
my $is_unique = &uniqueness_check($newurl);
|
$r->print($type.': '. |
while (!$is_unique && $counter < 100) {
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('. |
$counter ++;
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')'); |
$newid ++;
|
} else { |
$newurl = $oldid.$newid;
|
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; |
$is_unique = &uniqueness_check($newurl);
|
my $icon = &Apache::loncommon::icon($extension); |
}
|
if ($extension eq 'sequence' && |
if (!$is_unique) {
|
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) { |
if ($url=~/\.page$/) {
|
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); |
return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
|
$icon .= '/navmap.folder.closed.gif'; |
} else {
|
} |
return &mt('Paste failed: an error occurred creating a unique URL for the folder');
|
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />'; |
}
|
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}))); |
}
|
} |
my $storefn=$newurl;
|
if ($container eq 'page') { |
$storefn=~s{^/\w+/$match_domain/$match_username/}{};
|
$r->print(' |
my $paste_map_result =
|
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" /> |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
|
<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" /> |
&Apache::lonnet::getfile($url));
|
'); |
if ($paste_map_result eq '/adm/notfound.html') {
|
} else { |
if ($url=~/\.page$/) {
|
$r->print(' |
return &mt('Paste failed: an error occurred saving the composite page');
|
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /> |
} else {
|
'); |
return &mt('Paste failed: an error occurred saving the folder');
|
} |
}
|
$r->print('</form></fieldset>'); |
}
|
} |
$url = $newurl;
|
|
}
|
sub do_paste_from_buffer { |
# published maps can only exists once, so remove it from paste buffer when done
|
my ($coursenum,$coursedom,$folder) = @_; |
if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
|
|
&Apache::lonnet::delenv('docs\\.markedcopy');
|
if (!$env{'form.pastemarked'}) { |
}
|
return; |
if ($url=~ m{/smppg$}) {
|
} |
my $db_name = &Apache::lonsimplepage::get_db_name($url);
|
|
if ($db_name =~ /^smppage_/) {
|
# paste resource to end of list |
#simple pages, need to copy the db contents to a new one.
|
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); |
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
|
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); |
my $now = time();
|
# Maps need to be copied first |
$db_name =~ s{_\d*$ }{_$now}x;
|
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) { |
my $result=&Apache::lonnet::put($db_name,\%contents,
|
$title=&mt('Copy of').' '.$title; |
$coursedom,$coursenum);
|
my $newid=$$.int(rand(100)).time; |
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
|
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/); |
$title=&mt('Copy of').' '.$title;
|
if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) { |
}
|
my $path = $1; |
}
|
my $prefix = $2; |
$title = &LONCAPA::map::qtunescape($title);
|
my $ancestor = $3; |
my $ext='false';
|
if (length($ancestor) > 10) { |
if ($url=~m{^http(|s)://}) { $ext='true'; }
|
$ancestor = substr($ancestor,-10,10); |
$url = &LONCAPA::map::qtunescape($url);
|
} |
# Now insert the URL at the bottom
|
$oldid = $path.$prefix.$ancestor; |
my $newidx = &LONCAPA::map::getresidx($url);
|
} |
if ($env{'docs.markedcopy_supplemental'}) {
|
my $counter = 0; |
if ($folder =~ /^supplemental/) {
|
my $newurl=$oldid.$newid.'.'.$ext; |
$title = $env{'docs.markedcopy_supplemental'};
|
my $is_unique = &uniqueness_check($newurl); |
} else {
|
while (!$is_unique && $counter < 100) { |
(undef,undef,$title) =
|
$counter ++; |
&parse_supplemental_title($env{'docs.markedcopy_supplemental'});
|
$newid ++; |
}
|
$newurl = $oldid.$newid; |
} else {
|
$is_unique = &uniqueness_check($newurl); |
if ($folder=~/^supplemental/) {
|
} |
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
if (!$is_unique) { |
$env{'user.domain'}.'___&&&___'.$title;
|
if ($url=~/\.page$/) { |
}
|
return &mt('Paste failed: an error occurred creating a unique URL for the composite page'); |
}
|
} else { |
|
return &mt('Paste failed: an error occurred creating a unique URL for the folder'); |
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
|
} |
push(@LONCAPA::map::order, $newidx);
|
} |
return 'ok';
|
my $storefn=$newurl; |
# Store the result
|
$storefn=~s{^/\w+/$match_domain/$match_username/}{}; |
}
|
my $paste_map_result = |
|
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, |
sub uniqueness_check {
|
&Apache::lonnet::getfile($url)); |
my ($newurl) = @_;
|
if ($paste_map_result eq '/adm/notfound.html') { |
my $unique = 1;
|
if ($url=~/\.page$/) { |
foreach my $res (@LONCAPA::map::order) {
|
return &mt('Paste failed: an error occurred saving the composite page'); |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
} else { |
$url=&LONCAPA::map::qtescape($url);
|
return &mt('Paste failed: an error occurred saving the folder'); |
if ($newurl eq $url) {
|
} |
$unique = 0;
|
} |
last;
|
$url = $newurl; |
}
|
} |
}
|
# published maps can only exists once, so remove it from paste buffer when done |
return $unique;
|
if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) { |
}
|
&Apache::lonnet::delenv('docs.markedcopy'); |
|
} |
my %parameter_type = ( 'randompick' => 'int_pos',
|
if ($url=~ m{/smppg$}) { |
'hiddenresource' => 'string_yesno',
|
my $db_name = &Apache::lonsimplepage::get_db_name($url); |
'encrypturl' => 'string_yesno',
|
if ($db_name =~ /^smppage_/) { |
'randomorder' => 'string_yesno',);
|
#simple pages, need to copy the db contents to a new one. |
my $valid_parameters_re = join('|',keys(%parameter_type));
|
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum); |
# set parameters
|
my $now = time(); |
sub update_parameter {
|
$db_name =~ s{_\d*$ }{_$now}x; |
|
my $result=&Apache::lonnet::put($db_name,\%contents, |
return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
|
$coursedom,$coursenum); |
|
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x; |
my $which = $env{'form.changeparms'};
|
$title=&mt('Copy of').' '.$title; |
my $idx = $env{'form.setparms'};
|
} |
if ($env{'form.'.$which.'_'.$idx}) {
|
} |
my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
|
$title = &LONCAPA::map::qtunescape($title); |
: 'yes';
|
my $ext='false'; |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
|
if ($url=~m{^http(|s)://}) { $ext='true'; } |
$parameter_type{$which});
|
$url = &LONCAPA::map::qtunescape($url); |
&remember_parms($idx,$which,'set',$value);
|
# Now insert the URL at the bottom |
} else {
|
my $newidx = &LONCAPA::map::getresidx($url); |
&LONCAPA::map::delparameter($idx,'parameter_'.$which);
|
if ($env{'docs.markedcopy_supplemental'}) { |
|
if ($folder =~ /^supplemental/) { |
&remember_parms($idx,$which,'del');
|
$title = $env{'docs.markedcopy_supplemental'}; |
}
|
} else { |
return 1;
|
(undef,undef,$title) = |
}
|
&parse_supplemental_title($env{'docs.markedcopy_supplemental'}); |
|
} |
|
} else { |
sub handle_edit_cmd {
|
if ($folder=~/^supplemental/) { |
my ($coursenum,$coursedom) =@_;
|
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
|
$env{'user.domain'}.'___&&&___'.$title; |
my ($cmd,$idx)=split('_',$env{'form.cmd'});
|
} |
|
} |
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
|
my ($title, $url, @rrest) = split(':', $ratstr);
|
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; |
|
push(@LONCAPA::map::order, $newidx); |
if ($cmd eq 'del') {
|
return 'ok'; |
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
|
# Store the result |
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
|
} |
&Apache::lonnet::removeuploadedurl($url);
|
|
} else {
|
sub uniqueness_check { |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
my ($newurl) = @_; |
}
|
my $unique = 1; |
splice(@LONCAPA::map::order, $idx, 1);
|
foreach my $res (@LONCAPA::map::order) { |
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
} elsif ($cmd eq 'cut') {
|
$url=&LONCAPA::map::qtescape($url); |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
if ($newurl eq $url) { |
splice(@LONCAPA::map::order, $idx, 1);
|
$unique = 0; |
|
last; |
} elsif ($cmd eq 'up'
|
} |
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
|
} |
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
|
return $unique; |
|
} |
} elsif ($cmd eq 'down'
|
|
&& defined($LONCAPA::map::order[$idx+1])) {
|
my %parameter_type = ( 'randompick' => 'int_pos', |
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
|
'hiddenresource' => 'string_yesno', |
|
'encrypturl' => 'string_yesno', |
} elsif ($cmd eq 'rename') {
|
'randomorder' => 'string_yesno',); |
|
my $valid_parameters_re = join('|',keys(%parameter_type)); |
my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
|
# set parameters |
if ($comment=~/\S/) {
|
sub update_parameter { |
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
|
|
$comment.':'.join(':', $url, @rrest);
|
return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/); |
}
|
|
# Devalidate title cache
|
my $which = $env{'form.changeparms'}; |
my $renamed_url=&LONCAPA::map::qtescape($url);
|
my $idx = $env{'form.setparms'}; |
&Apache::lonnet::devalidate_title_cache($renamed_url);
|
if ($env{'form.'.$which.'_'.$idx}) { |
} else {
|
my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx} |
return 0;
|
: 'yes'; |
}
|
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value, |
return 1;
|
$parameter_type{$which}); |
}
|
&remember_parms($idx,$which,'set',$value); |
|
} else { |
sub editor {
|
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
|
|
|
&remember_parms($idx,$which,'del'); |
my $container= ($env{'form.pagepath'}) ? 'page'
|
} |
: 'sequence';
|
return 1; |
|
} |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
|
$folder.'.'.$container);
|
|
return $errtext if ($fatal);
|
sub handle_edit_cmd { |
|
my ($coursenum,$coursedom) =@_; |
if ($#LONCAPA::map::order<1) {
|
|
my $idx=&LONCAPA::map::getresidx();
|
my ($cmd,$idx)=split('_',$env{'form.cmd'}); |
if ($idx<=0) { $idx=1; }
|
|
$LONCAPA::map::order[0]=$idx;
|
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
$LONCAPA::map::resources[$idx]='';
|
my ($title, $url, @rrest) = split(':', $ratstr); |
}
|
|
|
if ($cmd eq 'del') { |
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
|
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
&breadcrumbs($folder,$allowed,$type);
|
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { |
$r->print($breadcrumbtrail);
|
&Apache::lonnet::removeuploadedurl($url); |
|
} else { |
# ------------------------------------------------------------ Process commands
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
|
} |
# ---------------- if they are for this folder and user allowed to make changes
|
splice(@LONCAPA::map::order, $idx, 1); |
if (($allowed) && ($env{'form.folder'} eq $folder)) {
|
|
# set parameters and change order
|
} elsif ($cmd eq 'cut') { |
&snapshotbefore();
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
|
splice(@LONCAPA::map::order, $idx, 1); |
if (&update_parameter()) {
|
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
} elsif ($cmd eq 'up' |
return $errtext if ($fatal);
|
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) { |
}
|
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1]; |
|
|
if ($env{'form.newpos'} && $env{'form.currentpos'}) {
|
} elsif ($cmd eq 'down' |
# change order
|
&& defined($LONCAPA::map::order[$idx+1])) { |
my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
|
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1]; |
splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
|
|
|
} elsif ($cmd eq 'rename') { |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
|
return $errtext if ($fatal);
|
my $comment = &LONCAPA::map::qtunescape($env{'form.title'}); |
}
|
if ($comment=~/\S/) { |
|
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= |
if ($env{'form.pastemarked'}) {
|
$comment.':'.join(':', $url, @rrest); |
my $paste_res =
|
} |
&do_paste_from_buffer($coursenum,$coursedom,$folder);
|
# Devalidate title cache |
if ($paste_res eq 'ok') {
|
my $renamed_url=&LONCAPA::map::qtescape($url); |
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
|
&Apache::lonnet::devalidate_title_cache($renamed_url); |
return $errtext if ($fatal);
|
} else { |
} elsif ($paste_res ne '') {
|
return 0; |
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
|
} |
}
|
return 1; |
}
|
} |
|
|
$r->print($upload_output);
|
sub editor { |
|
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype)=@_; |
if (&handle_edit_cmd()) {
|
my $container= ($env{'form.pagepath'}) ? 'page' |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
: 'sequence'; |
return $errtext if ($fatal);
|
|
}
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
# Group import/search
|
$folder.'.'.$container); |
if ($env{'form.importdetail'}) {
|
return $errtext if ($fatal); |
my @imports;
|
|
foreach my $item (split(/\&/,$env{'form.importdetail'})) {
|
if ($#LONCAPA::map::order<1) { |
if (defined($item)) {
|
my $idx=&LONCAPA::map::getresidx(); |
my ($name,$url,$residx)=
|
if ($idx<=0) { $idx=1; } |
map {&unescape($_)} split(/\=/,$item);
|
$LONCAPA::map::order[0]=$idx; |
push(@imports, [$name, $url, $residx]);
|
$LONCAPA::map::resources[$idx]=''; |
}
|
} |
}
|
|
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
|
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = |
$container,'londocs',@imports);
|
&breadcrumbs($allowed,$crstype); |
return $errtext if ($fatal);
|
$r->print($breadcrumbtrail); |
}
|
|
# Loading a complete map
|
unless ($allowed) { |
if ($env{'form.loadmap'}) {
|
$randompick = -1; |
if ($env{'form.importmap'}=~/\w/) {
|
} |
foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
|
|
my ($title,$url,$ext,$type)=split(/\:/,$res);
|
# ------------------------------------------------------------ Process commands |
my $idx=&LONCAPA::map::getresidx($url);
|
|
$LONCAPA::map::resources[$idx]=$res;
|
# ---------------- if they are for this folder and user allowed to make changes |
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
|
if (($allowed) && ($env{'form.folder'} eq $folder)) { |
}
|
# set parameters and change order |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
&snapshotbefore(); |
$folder.'.'.$container);
|
|
return $errtext if ($fatal);
|
if (&update_parameter()) { |
} else {
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
|
return $errtext if ($fatal); |
|
} |
}
|
|
}
|
if ($env{'form.newpos'} && $env{'form.currentpos'}) { |
&log_differences($plain);
|
# change order |
}
|
my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1); |
# ---------------------------------------------------------------- End commands
|
splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res); |
# ---------------------------------------------------------------- Print screen
|
|
my $idx=0;
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
my $shown=0;
|
return $errtext if ($fatal); |
if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
|
} |
$r->print('<p>'.&mt('Parameters').':<ul>'.
|
|
($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
|
if ($env{'form.pastemarked'}) { |
($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
|
my $paste_res = |
($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
|
&do_paste_from_buffer($coursenum,$coursedom,$folder); |
'</ul></p>');
|
if ($paste_res eq 'ok') { |
}
|
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); |
if ($randompick>=0) {
|
return $errtext if ($fatal); |
$r->print('<p>'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'</p>');
|
} elsif ($paste_res ne '') { |
}
|
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>'); |
if ($is_random_order) {
|
} |
$r->print('<p>'.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown.').'</p>');
|
} |
}
|
|
$r->print('<table class="LC_docs_editor">');
|
$r->print($upload_output); |
foreach my $res (@LONCAPA::map::order) {
|
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
if (&handle_edit_cmd()) { |
$name=&LONCAPA::map::qtescape($name);
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
$url=&LONCAPA::map::qtescape($url);
|
return $errtext if ($fatal); |
unless ($name) { $name=(split(/\//,$url))[-1]; }
|
} |
unless ($name) { $idx++; next; }
|
# Group import/search |
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
|
if ($env{'form.importdetail'}) { |
$coursenum));
|
my @imports; |
$idx++;
|
foreach my $item (split(/\&/,$env{'form.importdetail'})) { |
$shown++;
|
if (defined($item)) { |
}
|
my ($name,$url,$residx)= |
unless ($shown) {
|
map {&unescape($_)} split(/\=/,$item); |
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
|
push(@imports, [$name, $url, $residx]); |
}
|
} |
$r->print("\n</table>\n");
|
} |
if ($allowed) {
|
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder, |
&print_paste_buffer($r,$container);
|
$container,'londocs',@imports); |
}
|
return $errtext if ($fatal); |
return;
|
} |
}
|
# Loading a complete map |
|
if ($env{'form.loadmap'}) { |
sub process_file_upload {
|
if ($env{'form.importmap'}=~/\w/) { |
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
|
foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { |
# upload a file, if present
|
my ($title,$url,$ext,$type)=split(/\:/,$res); |
my $parseaction;
|
my $idx=&LONCAPA::map::getresidx($url); |
if ($env{'form.parserflag'}) {
|
$LONCAPA::map::resources[$idx]=$res; |
$parseaction = 'parse';
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; |
}
|
} |
my $phase_status;
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
my $folder=$env{'form.folder'};
|
$folder.'.'.$container); |
if ($folder eq '') {
|
return $errtext if ($fatal); |
$folder='default';
|
} else { |
}
|
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>'); |
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
|
|
my $errtext='';
|
} |
my $fatal=0;
|
} |
my $container='sequence';
|
&log_differences($plain); |
if ($env{'form.pagepath'}) {
|
} |
$container='page';
|
# ---------------------------------------------------------------- End commands |
}
|
# ---------------------------------------------------------------- Print screen |
($errtext,$fatal)=
|
my $idx=0; |
&mapread($coursenum,$coursedom,$folder.'.'.$container);
|
my $shown=0; |
if ($#LONCAPA::map::order<1) {
|
if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) { |
$LONCAPA::map::order[0]=1;
|
$r->print('<div class="LC_Box">'. |
$LONCAPA::map::resources[1]='';
|
'<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'. |
}
|
($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':''). |
if ($fatal) {
|
($ishidden?'<li>'.&mt('contents hidden').'</li>':''). |
return 'failed';
|
($isencrypted?'<li>'.&mt('URLs hidden').'</li>':''). |
}
|
($is_random_order?'<li>'.&mt('random order').'</li>':''). |
my $destination = 'docs/';
|
'</ol>'); |
if ($folder =~ /^supplemental/) {
|
if ($randompick>=0) { |
$destination = 'supplemental/';
|
$r->print('<p class="LC_warning">' |
}
|
.&mt('Caution: this folder is set to randomly pick a subset' |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
.' of resources. Adding or removing resources from this' |
$destination .= 'default/';
|
.' folder will change the set of resources that the' |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
.' students see, resulting in spurious or missing credit' |
$destination .= $2.'/';
|
.' for completed problems, not limited to ones you' |
}
|
.' modify. Do not modify the contents of this folder if' |
# this is for a course, not a user, so set coursedoc flag
|
.' it is in active student use.') |
# probably the only place in the system where this should be "1"
|
.'</p>' |
my $newidx=&LONCAPA::map::getresidx();
|
); |
$destination .= $newidx;
|
} |
my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
|
if ($is_random_order) { |
$parseaction,$allfiles,
|
$r->print('<p class="LC_warning">' |
$codebase);
|
.&mt('Caution: this folder is set to randomly order its' |
my $ext='false';
|
.' contents. Adding or removing resources from this folder' |
if ($url=~m{^http://}) { $ext='true'; }
|
.' will change the order of resources shown.') |
$url = &LONCAPA::map::qtunescape($url);
|
.'</p>' |
my $comment=$env{'form.comment'};
|
); |
$comment = &LONCAPA::map::qtunescape($comment);
|
} |
if ($folder=~/^supplemental/) {
|
$r->print('</div>'); |
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
} |
$env{'user.domain'}.'___&&&___'.$comment;
|
|
}
|
my $output; |
|
|
$LONCAPA::map::resources[$newidx]=
|
&Apache::loncommon::start_data_table_count(); #setup a row counter |
$comment.':'.$url.':'.$ext.':normal:res';
|
foreach my $res (@LONCAPA::map::order) { |
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
$name=&LONCAPA::map::qtescape($name); |
$folder.'.'.$container);
|
$url=&LONCAPA::map::qtescape($url); |
if ($fatal) {
|
unless ($name) { $name=(split(/\//,$url))[-1]; } |
$$upload_output .= '<p><span class="LC_error">'.$errtext.'</span></p>';
|
unless ($name) { $idx++; next; } |
return 'failed';
|
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
} else {
|
$coursenum,$crstype); |
if ($parseaction eq 'parse') {
|
$idx++; |
my $total_embedded = keys(%{$allfiles});
|
$shown++; |
if ($total_embedded > 0) {
|
} |
my $num = 0;
|
&Apache::loncommon::end_data_table_count(); |
my $state = '
|
|
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
if ($shown) { |
<input type="hidden" name="cmd" value="upload_embedded" />
|
$r->print(&Apache::loncommon::start_scrollbox('900px','880px','400px') |
<input type="hidden" name="newidx" value="'.$newidx.'" />
|
.&Apache::loncommon::start_data_table()); |
<input type="hidden" name="primaryurl" value="'.&escape($url).'" />
|
if ($allowed) { |
<input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
|
$r->print(&Apache::loncommon::start_data_table_header_row() |
$phase_status = 'phasetwo';
|
.'<th colspan="2">'.&mt('Move').'</th>' |
|
.'<th>'.&mt('Actions').'</th>' |
$$upload_output .=
|
.'<th colspan="2">'.&mt('Document').'</th>'); |
'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
|
if ($folder !~ /^supplemental/) { |
&Apache::loncommon::ask_for_embedded_content(
|
$->print('<th colspan="4">'.&mt('Settings').'</th>'); |
'/adm/coursedocs',$state,$allfiles,$codebase);
|
} |
} else {
|
$r->print(&Apache::loncommon::end_data_table_header_row()); |
$$upload_output .= 'No embedded items identified<br />';
|
} |
}
|
$r->print($output |
}
|
.&Apache::loncommon::end_data_table() |
}
|
.&Apache::loncommon::end_scrollbox() |
}
|
); |
return $phase_status;
|
} else { |
}
|
$r->print('<p class="LC_info">' |
|
.&mt('Currently no documents.') |
sub process_secondary_uploads {
|
.'</p>' |
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
|
); |
my $folder=$env{'form.folder'};
|
} |
my $destination = 'docs/';
|
if ($allowed) { |
if ($folder =~ /^supplemental/) {
|
&print_paste_buffer($r,$container); |
$destination = 'supplemental/';
|
} |
}
|
return; |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
} |
$destination .= 'default/';
|
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
sub process_file_upload { |
$destination .= $2.'/';
|
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; |
}
|
# upload a file, if present |
$destination .= $newidx;
|
my ($parseaction,$showupload,$nextphase,$mimetype); |
my ($url,$filename);
|
if ($env{'form.parserflag'}) { |
$url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
|
$parseaction = 'parse'; |
($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
|
} |
return $filename;
|
my $folder=$env{'form.folder'}; |
}
|
if ($folder eq '') { |
|
$folder='default'; |
sub is_supplemental_title {
|
} |
my ($title) = @_;
|
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) { |
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
|
my $errtext=''; |
}
|
my $fatal=0; |
|
my $container='sequence'; |
sub parse_supplemental_title {
|
if ($env{'form.pagepath'}) { |
my ($title) = @_;
|
$container='page'; |
|
} |
my ($foldertitle,$renametitle);
|
($errtext,$fatal)= |
if ($title =~ /&&&/) {
|
&mapread($coursenum,$coursedom,$folder.'.'.$container); |
$title = &HTML::Entites::decode($title);
|
if ($#LONCAPA::map::order<1) { |
}
|
$LONCAPA::map::order[0]=1; |
if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
|
$LONCAPA::map::resources[1]=''; |
$renametitle=$4;
|
} |
my ($time,$uname,$udom) = ($1,$2,$3);
|
if ($fatal) { |
$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
|
$$upload_output = '<p><span class="LC_error">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</span></p>'; |
my $name = &Apache::loncommon::plainname($uname,$udom);
|
return; |
$name = &HTML::Entities::encode($name,'"<>&\'');
|
} |
$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
|
my $destination = 'docs/'; |
$name.': <br />'.$foldertitle;
|
if ($folder =~ /^supplemental/) { |
}
|
$destination = 'supplemental/'; |
if (wantarray) {
|
} |
return ($title,$foldertitle,$renametitle);
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
}
|
$destination .= 'default/'; |
return $title;
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
}
|
$destination .= $2.'/'; |
|
} |
# --------------------------------------------------------------- An entry line
|
# this is for a course, not a user, so set context to coursedoc. |
|
my $newidx=&LONCAPA::map::getresidx(); |
sub entryline {
|
$destination .= $newidx; |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
|
my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination, |
|
$parseaction,$allfiles, |
my ($foldertitle,$pagetitle,$renametitle);
|
$codebase,undef,undef,undef,undef, |
if (&is_supplemental_title($title)) {
|
undef,undef,\$mimetype); |
($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
|
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) { |
$pagetitle = $foldertitle;
|
my $stored = $1; |
} else {
|
$showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'. |
$title=&HTML::Entities::encode($title,'"<>&\'');
|
$stored.'</span>').'</p>'; |
$renametitle=$title;
|
} else { |
$foldertitle=$title;
|
my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$}); |
$pagetitle=$title;
|
|
}
|
$$upload_output = '<p><span class="LC_error">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</span></p>'; |
|
return; |
my $orderidx=$LONCAPA::map::order[$index];
|
} |
|
my $ext='false'; |
|
if ($url=~m{^http://}) { $ext='true'; } |
$renametitle=~s/\\/\\\\/g;
|
$url = &LONCAPA::map::qtunescape($url); |
$renametitle=~s/\"\;/\\\"/g;
|
my $comment=$env{'form.comment'}; |
$renametitle=~s/ /%20/g;
|
$comment = &LONCAPA::map::qtunescape($comment); |
my $line='<tr>';
|
if ($folder=~/^supplemental/) { |
my ($form_start,$form_end);
|
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
# Edit commands
|
$env{'user.domain'}.'___&&&___'.$comment; |
my ($container, $type, $esc_path, $path, $symb);
|
} |
if ($env{'form.folderpath'}) {
|
|
$type = 'folder';
|
$LONCAPA::map::resources[$newidx]= |
$container = 'sequence';
|
$comment.':'.$url.':'.$ext.':normal:res'; |
$esc_path=&escape($env{'form.folderpath'});
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx; |
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
|
$folder.'.'.$container); |
}
|
if ($fatal) { |
if ($env{'form.pagepath'}) {
|
$$upload_output = '<p><span class="LC_error">'.$errtext.'</span></p>'; |
$type = $container = 'page';
|
return; |
$esc_path=&escape($path = $env{'form.pagepath'});
|
} else { |
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
|
if ($parseaction eq 'parse' && $mimetype eq 'text/html') { |
$symb=&escape($env{'form.pagesymb'});
|
$$upload_output = $showupload; |
}
|
my $total_embedded = scalar(keys(%{$allfiles})); |
my $cpinfo='';
|
if ($total_embedded > 0) { |
if ($allowed) {
|
my $uploadphase = 'upload_embedded'; |
my $incindex=$index+1;
|
my $primaryurl = &HTML::Entities::encode($url,'<>&"'); |
my $selectbox='';
|
my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); |
if (($folder!~/^supplemental/) &&
|
my ($embedded,$num) = |
($#LONCAPA::map::order>0) &&
|
&Apache::loncommon::ask_for_embedded_content( |
((split(/\:/,
|
'/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url}); |
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
|
if ($embedded) { |
ne '') &&
|
if ($num) { |
((split(/\:/,
|
$$upload_output .= |
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
|
'<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded; |
ne '')) {
|
$nextphase = $uploadphase; |
$selectbox=
|
} else { |
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
|
$$upload_output .= $embedded; |
'<select name="newpos" onChange="this.form.submit()">';
|
} |
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
|
} else { |
if ($i==$incindex) {
|
$$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />'; |
$selectbox.='<option value="" selected="1">('.$i.')</option>';
|
} |
} else {
|
} else { |
$selectbox.='<option value="'.$i.'">'.$i.'</option>';
|
$$upload_output .= &mt('No embedded items identified').'<br />'; |
}
|
} |
}
|
} |
$selectbox.='</select>';
|
} |
}
|
} |
my %lt=&Apache::lonlocal::texthash(
|
return $nextphase; |
'up' => 'Move Up',
|
} |
'dw' => 'Move Down',
|
|
'rm' => 'Remove',
|
sub is_supplemental_title { |
'ct' => 'Cut',
|
my ($title) = @_; |
'rn' => 'Rename',
|
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/); |
'cp' => 'Copy');
|
} |
my $nocopy=0;
|
|
my $nocut=0;
|
sub parse_supplemental_title { |
if ($url=~/\.(page|sequence)$/) {
|
my ($title) = @_; |
if ($url =~ m{/res/}) {
|
|
# no copy for published maps
|
my ($foldertitle,$renametitle); |
$nocopy = 1;
|
if ($title =~ /&&&/) { |
} else {
|
$title = &HTML::Entites::decode($title); |
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
|
} |
my ($title,$url,$ext,$type)=split(/\:/,$item);
|
if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) { |
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
|
$renametitle=$4; |
$nocopy=1;
|
my ($time,$uname,$udom) = ($1,$2,$3); |
last;
|
$foldertitle=&Apache::lontexconvert::msgtexconverted($4); |
}
|
my $name = &Apache::loncommon::plainname($uname,$udom); |
}
|
$name = &HTML::Entities::encode($name,'"<>&\''); |
}
|
$renametitle = &HTML::Entities::encode($renametitle,'"<>&\''); |
}
|
$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '. |
if ($url=~/^\/res\/lib\/templates\//) {
|
$name.': <br />'.$foldertitle; |
$nocopy=1;
|
} |
$nocut=1;
|
if (wantarray) { |
}
|
return ($title,$foldertitle,$renametitle); |
my $copylink=' ';
|
} |
my $cutlink=' ';
|
return $title; |
|
} |
my $skip_confirm = 0;
|
|
if ( $folder =~ /^supplemental/
|
# --------------------------------------------------------------- An entry line |
|| ($url =~ m{( /smppg$
|
|
|/syllabus$
|
sub entryline { |
|/aboutme$
|
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_; |
|/navmaps$
|
my ($foldertitle,$pagetitle,$renametitle); |
|/bulletinboard$
|
if (&is_supplemental_title($title)) { |
|\.html$
|
($title,$foldertitle,$renametitle) = &parse_supplemental_title($title); |
|^/adm/wrapper/ext)}x)) {
|
$pagetitle = $foldertitle; |
$skip_confirm = 1;
|
} else { |
}
|
$title=&HTML::Entities::encode($title,'"<>&\''); |
|
$renametitle=$title; |
if (!$nocopy) {
|
$foldertitle=$title; |
$copylink=(<<ENDCOPY);
|
$pagetitle=$title; |
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
|
} |
ENDCOPY
|
|
}
|
my $orderidx=$LONCAPA::map::order[$index]; |
if (!$nocut) {
|
|
$cutlink=(<<ENDCUT);
|
|
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
|
$renametitle=~s/\\/\\\\/g; |
ENDCUT
|
$renametitle=~s/\"\;/\\\"/g; |
}
|
$renametitle=~s/ /%20/g; |
$form_start = (<<END);
|
my $line=&Apache::loncommon::start_data_table_row(); |
<form action="/adm/coursedocs" method="post">
|
my ($form_start,$form_end); |
<input type="hidden" name="${type}path" value="$path" />
|
# Edit commands |
<input type="hidden" name="${type}symb" value="$symb" />
|
my ($container, $type, $esc_path, $path, $symb); |
<input type="hidden" name="setparms" value="$orderidx" />
|
if ($env{'form.folderpath'}) { |
<input type="hidden" name="changeparms" value="0" />
|
$type = 'folder'; |
END
|
$container = 'sequence'; |
$form_end = '</form>';
|
$esc_path=&escape($env{'form.folderpath'}); |
$line.=(<<END);
|
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
<td>
|
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"'); |
<table class="LC_docs_entry_move">
|
} |
<tr>
|
if ($env{'form.pagepath'}) { |
<td>
|
$type = $container = 'page'; |
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /></a>
|
$esc_path=&escape($env{'form.pagepath'}); |
</td>
|
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); |
</tr>
|
$symb=&escape($env{'form.pagesymb'}); |
<tr>
|
} |
<td>
|
my $cpinfo=''; |
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /></a>
|
if ($allowed) { |
</td>
|
my $incindex=$index+1; |
</tr>
|
my $selectbox=''; |
</table>
|
if (($folder!~/^supplemental/) && |
</td>
|
($#LONCAPA::map::order>0) && |
<td>
|
((split(/\:/, |
$form_start
|
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1] |
$selectbox
|
ne '') && |
$form_end
|
((split(/\:/, |
</td>
|
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1] |
<td class="LC_docs_entry_commands">
|
ne '')) { |
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
|
$selectbox= |
$cutlink
|
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'. |
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
|
'<select name="newpos" onchange="this.form.submit()">'; |
$copylink
|
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) { |
</td>
|
if ($i==$incindex) { |
END
|
$selectbox.='<option value="" selected="selected">('.$i.')</option>'; |
|
} else { |
}
|
$selectbox.='<option value="'.$i.'">'.$i.'</option>'; |
# Figure out what kind of a resource this is
|
} |
my ($extension)=($url=~/\.(\w+)$/);
|
} |
my $uploaded=($url=~/^\/*uploaded\//);
|
$selectbox.='</select>'; |
my $icon=&Apache::loncommon::icon($url);
|
} |
my $isfolder=0;
|
my %lt=&Apache::lonlocal::texthash( |
my $ispage=0;
|
'up' => 'Move Up', |
my $folderarg;
|
'dw' => 'Move Down', |
my $pagearg;
|
'rm' => 'Remove', |
my $pagefile;
|
'ct' => 'Cut', |
if ($uploaded) {
|
'rn' => 'Rename', |
if ($extension eq 'sequence') {
|
'cp' => 'Copy'); |
$icon=$iconpath.'/folder_closed.gif';
|
my $nocopy=0; |
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
|
my $nocut=0; |
$url='/adm/coursedocs?';
|
if ($url=~/\.(page|sequence)$/) { |
$folderarg=$1;
|
if ($url =~ m{/res/}) { |
$isfolder=1;
|
# no copy for published maps |
} elsif ($extension eq 'page') {
|
$nocopy = 1; |
$icon=$iconpath.'/page.gif';
|
} else { |
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
|
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) { |
$pagearg=$1;
|
my ($title,$url,$ext,$type)=split(/\:/,$item); |
$url='/adm/coursedocs?';
|
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { |
$ispage=1;
|
$nocopy=1; |
} else {
|
last; |
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
|
} |
}
|
} |
}
|
} |
|
} |
my $orig_url = $url;
|
if ($url=~/^\/res\/lib\/templates\//) { |
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
|
$nocopy=1; |
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
|
$nocut=1; |
my $symb=&Apache::lonnet::symbclean(
|
} |
&Apache::lonnet::declutter('uploaded/'.
|
my $copylink=' '; |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
my $cutlink=' '; |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
|
|
'.sequence').
|
my $skip_confirm = 0; |
'___'.$residx.'___'.
|
if ( $folder =~ /^supplemental/ |
&Apache::lonnet::declutter($url));
|
|| ($url =~ m{( /smppg$ |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
|
|/syllabus$ |
$url=&Apache::lonnet::clutter($url);
|
|/aboutme$ |
if ($url=~/^\/*uploaded\//) {
|
|/navmaps$ |
$url=~/\.(\w+)$/;
|
|/bulletinboard$ |
my $embstyle=&Apache::loncommon::fileembstyle($1);
|
|\.html$ |
if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
|
|^/adm/wrapper/ext)}x)) { |
$url='/adm/wrapper'.$url;
|
$skip_confirm = 1; |
} elsif ($embstyle eq 'ssi') {
|
} |
#do nothing with these
|
|
} elsif ($url!~/\.(sequence|page)$/) {
|
if (!$nocopy) { |
$url='/adm/coursedocs/showdoc'.$url;
|
$copylink=(<<ENDCOPY); |
}
|
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a> |
} elsif ($url=~m|^/ext/|) {
|
ENDCOPY |
$url='/adm/wrapper'.$url;
|
} |
$external = 1;
|
if (!$nocut) { |
}
|
$cutlink=(<<ENDCUT); |
if (&Apache::lonnet::symbverify($symb,$url)) {
|
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a> |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
ENDCUT |
} else {
|
} |
$url='';
|
$form_start = (<<END); |
}
|
<form action="/adm/coursedocs" method="post"> |
if ($container eq 'page') {
|
<input type="hidden" name="${type}path" value="$path" /> |
my $symb=$env{'form.pagesymb'};
|
<input type="hidden" name="${type}symb" value="$symb" /> |
|
<input type="hidden" name="setparms" value="$orderidx" /> |
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
|
<input type="hidden" name="changeparms" value="0" /> |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
END |
}
|
$form_end = '</form>'; |
}
|
$line.=(<<END); |
my ($parameterset,$rand_order_text) = (' ', ' ');
|
<td> |
if ($isfolder || $extension eq 'sequence') {
|
<div class="LC_docs_entry_move"> |
my $foldername=&escape($foldertitle);
|
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
my $folderpath=$env{'form.folderpath'};
|
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /> |
if ($folderpath) { $folderpath.='&' };
|
</a> |
# Append randompick number, hidden, and encrypted with ":" to foldername,
|
</div> |
# so it gets transferred between levels
|
<div class="LC_docs_entry_move"> |
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
|
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
'parameter_randompick'))[0]
|
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /> |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
</a> |
'parameter_hiddenresource'))[0]=~/^yes$/i)
|
</div> |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
</td> |
'parameter_encrypturl'))[0]=~/^yes$/i)
|
<td> |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
$form_start |
'parameter_randomorder'))[0]=~/^yes$/i);
|
$selectbox |
$url.='folderpath='.&escape($folderpath).$cpinfo;
|
$form_end |
$parameterset='<label>'.&mt('Randomly Pick: ').
|
</td> |
'<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
|
<td class="LC_docs_entry_commands"> |
(&LONCAPA::map::getparameter($orderidx,
|
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a> |
'parameter_randompick'))[0].
|
$cutlink |
'" />'.
|
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a> |
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
|
$copylink |
my $ro_set=
|
</td> |
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
|
END |
$rand_order_text ='
|
|
<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';
|
} |
}
|
# Figure out what kind of a resource this is |
if ($ispage) {
|
my ($extension)=($url=~/\.(\w+)$/); |
my $pagename=&escape($pagetitle);
|
my $uploaded=($url=~/^\/*uploaded\//); |
my $pagepath;
|
my $icon=&Apache::loncommon::icon($url); |
my $folderpath=$env{'form.folderpath'};
|
my $isfolder=0; |
if ($folderpath) { $pagepath = $folderpath.'&' };
|
my $ispage=0; |
$pagepath.=$pagearg.'&'.$pagename;
|
my $folderarg; |
my $symb=$env{'form.pagesymb'};
|
my $pagearg; |
if (!$symb) {
|
my $pagefile; |
my $path='uploaded/'.
|
if ($uploaded) { |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
if ($extension eq 'sequence') { |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/';
|
$icon=$iconpath.'/navmap.folder.closed.gif'; |
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; |
$residx,
|
$url='/adm/coursedocs?'; |
$path.$pagearg.'.page');
|
$folderarg=$1; |
}
|
$isfolder=1; |
$url.='pagepath='.&escape($pagepath).
|
} elsif ($extension eq 'page') { |
'&pagesymb='.&escape($symb).$cpinfo;
|
$icon=$iconpath.'/page.gif'; |
}
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/; |
if ($external) {
|
$pagearg=$1; |
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
|
$url='/adm/coursedocs?'; |
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
|
$ispage=1; |
} else {
|
} else { |
undef($external);
|
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url); |
}
|
} |
$line.='
|
} |
<td class="LC_docs_entry_icon">
|
|
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
|
my $orig_url = $url; |
</td>
|
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
<td class="LC_docs_entry_title">
|
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}); |
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
|
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { |
</td>";
|
my $symb=&Apache::lonnet::symbclean( |
if (($allowed) && ($folder!~/^supplemental/)) {
|
&Apache::lonnet::declutter('uploaded/'. |
my %lt=&Apache::lonlocal::texthash(
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
'hd' => 'Hidden',
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. |
'ec' => 'URL hidden');
|
'.sequence'). |
my $enctext=
|
'___'.$residx.'___'. |
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
|
&Apache::lonnet::declutter($url)); |
my $hidtext=
|
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
|
$url=&Apache::lonnet::clutter($url); |
$line.=(<<ENDPARMS);
|
if ($url=~/^\/*uploaded\//) { |
<td class="LC_docs_entry_parameter">
|
$url=~/\.(\w+)$/; |
$form_start
|
my $embstyle=&Apache::loncommon::fileembstyle($1); |
<label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
|
if (($embstyle eq 'img') || ($embstyle eq 'emb')) { |
$form_end
|
$url='/adm/wrapper'.$url; |
</td>
|
} elsif ($embstyle eq 'ssi') { |
<td class="LC_docs_entry_parameter">
|
#do nothing with these |
$form_start
|
} elsif ($url!~/\.(sequence|page)$/) { |
<label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
|
$url='/adm/coursedocs/showdoc'.$url; |
$form_end
|
} |
</td>
|
} elsif ($url=~m|^/ext/|) { |
<td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
|
$url='/adm/wrapper'.$url; |
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
|
$external = 1; |
ENDPARMS
|
} |
}
|
if (&Apache::lonnet::symbverify($symb,$url)) { |
$line.="</tr>";
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
return $line;
|
} else { |
}
|
$url=''; |
|
} |
=pod
|
if ($container eq 'page') { |
|
my $symb=$env{'form.pagesymb'}; |
=item tiehash()
|
|
|
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); |
tie the hash
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
|
} |
=cut
|
} |
|
my ($parameterset,$rand_order_text) = (' ', ' '); |
sub tiehash {
|
if ($isfolder || $extension eq 'sequence') { |
my ($mode)=@_;
|
my $foldername=&escape($foldertitle); |
$hashtied=0;
|
my $folderpath=$env{'form.folderpath'}; |
if ($env{'request.course.fn'}) {
|
if ($folderpath) { $folderpath.='&' }; |
if ($mode eq 'write') {
|
# Append randompick number, hidden, and encrypted with ":" to foldername, |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
# so it gets transferred between levels |
&GDBM_WRCREAT(),0640)) {
|
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx, |
$hashtied=2;
|
'parameter_randompick'))[0] |
}
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
} else {
|
'parameter_hiddenresource'))[0]=~/^yes$/i) |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
&GDBM_READER(),0640)) {
|
'parameter_encrypturl'))[0]=~/^yes$/i) |
$hashtied=1;
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
}
|
'parameter_randomorder'))[0]=~/^yes$/i); |
}
|
$url.='folderpath='.&escape($folderpath).$cpinfo; |
}
|
$parameterset='<label>'.&mt('Randomly Pick: '). |
}
|
'<input type="text" size="4" onchange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'. |
|
(&LONCAPA::map::getparameter($orderidx, |
sub untiehash {
|
'parameter_randompick'))[0]. |
if ($hashtied) { untie %hash; }
|
'" />'. |
$hashtied=0;
|
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>'; |
return OK;
|
my $ro_set= |
}
|
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); |
|
$rand_order_text =' |
|
<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'; |
|
} |
|
if ($ispage) { |
sub checkonthis {
|
my $pagename=&escape($pagetitle); |
my ($r,$url,$level,$title)=@_;
|
my $pagepath; |
$url=&unescape($url);
|
my $folderpath=$env{'form.folderpath'}; |
$alreadyseen{$url}=1;
|
if ($folderpath) { $pagepath = $folderpath.'&' }; |
$r->rflush();
|
$pagepath.=$pagearg.'&'.$pagename; |
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
|
my $symb=$env{'form.pagesymb'}; |
$r->print("\n<br />");
|
if (!$symb) { |
if ($level==0) {
|
my $path='uploaded/'. |
$r->print("<br />");
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
}
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'; |
for (my $i=0;$i<=$level*5;$i++) {
|
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', |
$r->print(' ');
|
$residx, |
}
|
$path.$pagearg.'.page'); |
$r->print('<a href="'.$url.'" target="cat">'.
|
} |
($title?$title:$url).'</a> ');
|
$url.='pagepath='.&escape($pagepath). |
if ($url=~/^\/res\//) {
|
'&pagesymb='.&escape($symb).$cpinfo; |
my $result=&Apache::lonnet::repcopy(
|
} |
&Apache::lonnet::filelocation('',$url));
|
if (($external) && ($allowed)) { |
if ($result eq 'ok') {
|
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext'; |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>'; |
$r->rflush();
|
} else { |
&Apache::lonnet::countacc($url);
|
undef($external); |
$url=~/\.(\w+)$/;
|
} |
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
|
my $reinit; |
$r->print('<br />');
|
if ($crstype eq 'Community') { |
$r->rflush();
|
$reinit = &mt('(re-initialize community to access)'); |
for (my $i=0;$i<=$level*5;$i++) {
|
} else { |
$r->print(' ');
|
$reinit = &mt('(re-initialize course to access)'); |
}
|
} |
$r->print('- '.&mt('Rendering:').' ');
|
$line.=' |
my ($errorcount,$warningcount)=split(/:/,
|
<td> |
&Apache::lonnet::ssi_body($url,
|
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').' |
('grade_target'=>'web',
|
</td> |
'return_only_error_and_warning_counts' => 1)));
|
<td> |
if (($errorcount) ||
|
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.$reinit.'</span>').$external." |
($warningcount)) {
|
</td>"; |
if ($errorcount) {
|
if (($allowed) && ($folder!~/^supplemental/)) { |
$r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
|
my %lt=&Apache::lonlocal::texthash( |
&mt('[quant,_1,error]',$errorcount).'</span>');
|
'hd' => 'Hidden', |
}
|
'ec' => 'URL hidden'); |
if ($warningcount) {
|
my $enctext= |
$r->print('<span class="LC_warning">'.
|
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':''); |
&mt('[quant,_1,warning]',$warningcount).'</span>');
|
my $hidtext= |
}
|
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':''); |
} else {
|
$line.=(<<ENDPARMS); |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
<td class="LC_docs_entry_parameter"> |
}
|
$form_start |
$r->rflush();
|
<label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label> |
}
|
$form_end |
my $dependencies=
|
</td> |
&Apache::lonnet::metadata($url,'dependencies');
|
<td class="LC_docs_entry_parameter"> |
foreach my $dep (split(/\,/,$dependencies)) {
|
$form_start |
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
|
<label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label> |
&checkonthis($r,$dep,$level+1);
|
$form_end |
}
|
</td> |
}
|
<td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td> |
} elsif ($result eq 'unavailable') {
|
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td> |
$r->print('<span class="LC_error">'.&mt('connection down').'</span>');
|
ENDPARMS |
} elsif ($result eq 'not_found') {
|
} |
unless ($url=~/\$/) {
|
$line.=&Apache::loncommon::end_data_table_row(); |
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
|
return $line; |
} else {
|
} |
$r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
|
|
}
|
=pod |
} else {
|
|
$r->print('<span class="LC_error">'.&mt('access denied').'</span>');
|
=item tiehash() |
}
|
|
}
|
tie the hash |
}
|
|
}
|
=cut |
|
|
|
sub tiehash { |
|
my ($mode)=@_; |
=pod
|
$hashtied=0; |
|
if ($env{'request.course.fn'}) { |
=item list_symbs()
|
if ($mode eq 'write') { |
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
List Symbs
|
&GDBM_WRCREAT(),0640)) { |
|
$hashtied=2; |
=cut
|
} |
|
} else { |
sub list_symbs {
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
my ($r) = @_;
|
&GDBM_READER(),0640)) { |
|
$hashtied=1; |
my $type = &Apache::loncommon::course_type();
|
} |
$r->print(&Apache::loncommon::start_page('Symb List'));
|
} |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
|
} |
my $navmap = Apache::lonnavmaps::navmap->new();
|
} |
if (!defined($navmap)) {
|
|
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
|
sub untiehash { |
'<div class="LC_error">'.
|
if ($hashtied) { untie %hash; } |
&mt('Unable to retrieve information about course contents').
|
$hashtied=0; |
'</div>');
|
return OK; |
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
} |
} else {
|
|
$r->print("<pre>\n");
|
|
foreach my $res ($navmap->retrieveResources()) {
|
|
$r->print($res->compTitle()."\t".$res->symb()."\n");
|
|
}
|
sub checkonthis { |
$r->print("\n</pre>\n");
|
my ($r,$url,$level,$title)=@_; |
}
|
$url=&unescape($url); |
$r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
|
$alreadyseen{$url}=1; |
}
|
$r->rflush(); |
|
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) { |
|
$r->print("\n<br />"); |
sub verifycontent {
|
if ($level==0) { |
my ($r) = @_;
|
$r->print("<br />"); |
my $type = &Apache::loncommon::course_type();
|
} |
my $loaderror=&Apache::lonnet::overloaderror($r);
|
for (my $i=0;$i<=$level*5;$i++) { |
if ($loaderror) { return $loaderror; }
|
$r->print(' '); |
$r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
|
} |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
|
$r->print('<a href="'.$url.'" target="cat">'. |
$hashtied=0;
|
($title?$title:$url).'</a> '); |
undef %alreadyseen;
|
if ($url=~/^\/res\//) { |
%alreadyseen=();
|
my $result=&Apache::lonnet::repcopy( |
&tiehash();
|
&Apache::lonnet::filelocation('',$url)); |
foreach my $key (keys(%hash)) {
|
if ($result eq 'ok') { |
if ($hash{$key}=~/\.(page|sequence)$/) {
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
|
$r->rflush(); |
$r->print('<hr /><span class="LC_error">'.
|
&Apache::lonnet::countacc($url); |
&mt('The following sequence or page is included more than once in your '.$type.': ').
|
$url=~/\.(\w+)$/; |
&unescape($hash{$key}).'</span><br />'.
|
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { |
&mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
|
$r->print('<br />'); |
}
|
$r->rflush(); |
}
|
for (my $i=0;$i<=$level*5;$i++) { |
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
|
$r->print(' '); |
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
|
} |
}
|
$r->print('- '.&mt('Rendering:').' '); |
}
|
my ($errorcount,$warningcount)=split(/:/, |
&untiehash();
|
&Apache::lonnet::ssi_body($url, |
$r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
|
('grade_target'=>'web', |
&mt('Return to DOCS').'</a>');
|
'return_only_error_and_warning_counts' => 1))); |
}
|
if (($errorcount) || |
|
($warningcount)) { |
|
if ($errorcount) { |
sub devalidateversioncache {
|
$r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'. |
my $src=shift;
|
&mt('[quant,_1,error]',$errorcount).'</span>'); |
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
|
} |
&Apache::lonnet::clutter($src));
|
if ($warningcount) { |
}
|
$r->print('<span class="LC_warning">'. |
|
&mt('[quant,_1,warning]',$warningcount).'</span>'); |
sub checkversions {
|
} |
my ($r) = @_;
|
} else { |
my $type = &Apache::loncommon::course_type();
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
$r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
|
} |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
|
$r->rflush(); |
my $header='';
|
} |
my $startsel='';
|
my $dependencies= |
my $monthsel='';
|
&Apache::lonnet::metadata($url,'dependencies'); |
my $weeksel='';
|
foreach my $dep (split(/\,/,$dependencies)) { |
my $daysel='';
|
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) { |
my $allsel='';
|
&checkonthis($r,$dep,$level+1); |
my %changes=();
|
} |
my $starttime=0;
|
} |
my $haschanged=0;
|
} elsif ($result eq 'unavailable') { |
my %setversions=&Apache::lonnet::dump('resourceversions',
|
$r->print('<span class="LC_error">'.&mt('connection down').'</span>'); |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
} elsif ($result eq 'not_found') { |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
unless ($url=~/\$/) { |
|
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>'); |
$hashtied=0;
|
} else { |
&tiehash();
|
$r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>'); |
my %newsetversions=();
|
} |
if ($env{'form.setmostrecent'}) {
|
} else { |
$haschanged=1;
|
$r->print('<span class="LC_error">'.&mt('access denied').'</span>'); |
foreach my $key (keys(%hash)) {
|
} |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
} |
$newsetversions{$1}='mostrecent';
|
} |
&devalidateversioncache($1);
|
} |
}
|
|
}
|
|
} elsif ($env{'form.setcurrent'}) {
|
|
$haschanged=1;
|
=pod |
foreach my $key (keys(%hash)) {
|
|
if ($key=~/^ids\_(\/res\/.+)$/) {
|
=item list_symbs() |
my $getvers=&Apache::lonnet::getversion($1);
|
|
if ($getvers>0) {
|
List Symbs |
$newsetversions{$1}=$getvers;
|
|
&devalidateversioncache($1);
|
=cut |
}
|
|
}
|
sub list_symbs { |
}
|
my ($r) = @_; |
} elsif ($env{'form.setversions'}) {
|
|
$haschanged=1;
|
my $crstype = &Apache::loncommon::course_type(); |
foreach my $key (keys(%env)) {
|
$r->print(&Apache::loncommon::start_page('Symb List')); |
if ($key=~/^form\.set_version_(.+)$/) {
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); |
my $src=$1;
|
&startContentScreen($r,'tools'); |
if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
$newsetversions{$src}=$env{$key};
|
if (!defined($navmap)) { |
&devalidateversioncache($src);
|
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'. |
}
|
'<div class="LC_error">'. |
}
|
&mt('Unable to retrieve information about course contents'). |
}
|
'</div>'); |
}
|
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); |
if ($haschanged) {
|
} else { |
if (&Apache::lonnet::put('resourceversions',\%newsetversions,
|
$r->print("<pre>\n"); |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
foreach my $res ($navmap->retrieveResources()) { |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
|
$r->print($res->compTitle()."\t".$res->symb()."\n"); |
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>');
|
} |
} else {
|
$r->print("\n</pre>\n"); |
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>');
|
} |
}
|
} |
&mark_hash_old();
|
|
}
|
|
&changewarning($r,'');
|
sub verifycontent { |
if ($env{'form.timerange'} eq 'all') {
|
my ($r) = @_; |
# show all documents
|
my $crstype = &Apache::loncommon::course_type(); |
$header=&mt('All Documents in '.$type);
|
$r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents')); |
$allsel=1;
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents')); |
foreach my $key (keys(%hash)) {
|
&startContentScreen($r,'tools'); |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
$hashtied=0; |
my $src=$1;
|
undef %alreadyseen; |
$changes{$src}=1;
|
%alreadyseen=(); |
}
|
&tiehash(); |
}
|
foreach my $key (keys(%hash)) { |
} else {
|
if ($hash{$key}=~/\.(page|sequence)$/) { |
# show documents which changed
|
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) { |
%changes=&Apache::lonnet::dump
|
$r->print('<hr /><span class="LC_error">'. |
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
|
&mt('The following sequence or page is included more than once in your '.$crstype.':').' '. |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
&unescape($hash{$key}).'</span><br />'. |
my $firstkey=(keys(%changes))[0];
|
&mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />'); |
unless ($firstkey=~/^error\:/) {
|
} |
unless ($env{'form.timerange'}) {
|
} |
$env{'form.timerange'}=604800;
|
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) { |
}
|
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1}); |
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
|
} |
.&mt('seconds');
|
} |
if ($env{'form.timerange'}==-1) {
|
&untiehash(); |
$seltext='since start of course';
|
$r->print('<p class="LC_success">'.&mt('Done').'</p>'); |
$startsel='selected';
|
} |
$env{'form.timerange'}=time;
|
|
}
|
|
$starttime=time-$env{'form.timerange'};
|
sub devalidateversioncache { |
if ($env{'form.timerange'}==2592000) {
|
my $src=shift; |
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. |
$monthsel='selected';
|
&Apache::lonnet::clutter($src)); |
} elsif ($env{'form.timerange'}==604800) {
|
} |
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
|
$weeksel='selected';
|
sub checkversions { |
} elsif ($env{'form.timerange'}==86400) {
|
my ($r) = @_; |
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
my $crstype = &Apache::loncommon::course_type(); |
$daysel='selected';
|
$r->print(&Apache::loncommon::start_page("Check $crstype Document Versions")); |
}
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions")); |
$header=&mt('Content changed').' '.$seltext;
|
&startContentScreen($r,'tools'); |
} else {
|
|
$header=&mt('No content modifications yet.');
|
my $header=''; |
}
|
my $startsel=''; |
}
|
my $monthsel=''; |
%setversions=&Apache::lonnet::dump('resourceversions',
|
my $weeksel=''; |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
my $daysel=''; |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
my $allsel=''; |
my %lt=&Apache::lonlocal::texthash
|
my %changes=(); |
('st' => 'Version changes since start of '.$type,
|
my $starttime=0; |
'lm' => 'Version changes since last Month',
|
my $haschanged=0; |
'lw' => 'Version changes since last Week',
|
my %setversions=&Apache::lonnet::dump('resourceversions', |
'sy' => 'Version changes since Yesterday',
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
'al' => 'All Resources (possibly large output)',
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
'sd' => 'Display',
|
|
'fi' => 'File',
|
$hashtied=0; |
'md' => 'Modification Date',
|
&tiehash(); |
'mr' => 'Most recently published Version',
|
my %newsetversions=(); |
've' => 'Version used in '.$type,
|
if ($env{'form.setmostrecent'}) { |
'vu' => 'Set Version to be used in '.$type,
|
$haschanged=1; |
'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
|
foreach my $key (keys(%hash)) { |
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
|
$newsetversions{$1}='mostrecent'; |
'di' => 'Differences');
|
&devalidateversioncache($1); |
$r->print(<<ENDHEADERS);
|
} |
<form action="/adm/coursedocs" method="post">
|
} |
<input type="hidden" name="versions" value="1" />
|
} elsif ($env{'form.setcurrent'}) { |
<input type="submit" name="setmostrecent" value="$lt{'sm'}" />
|
$haschanged=1; |
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
|
foreach my $key (keys(%hash)) { |
<select name="timerange">
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
<option value='all' $allsel>$lt{'al'}</option>
|
my $getvers=&Apache::lonnet::getversion($1); |
<option value="-1" $startsel>$lt{'st'}</option>
|
if ($getvers>0) { |
<option value="2592000" $monthsel>$lt{'lm'}</option>
|
$newsetversions{$1}=$getvers; |
<option value="604800" $weeksel>$lt{'lw'}</option>
|
&devalidateversioncache($1); |
<option value="86400" $daysel>$lt{'sy'}</option>
|
} |
</select>
|
} |
<input type="submit" name="display" value="$lt{'sd'}" />
|
} |
<h3>$header</h3>
|
} elsif ($env{'form.setversions'}) { |
<input type="submit" name="setversions" value="$lt{'sv'}" />
|
$haschanged=1; |
<table border="0">
|
foreach my $key (keys(%env)) { |
ENDHEADERS
|
if ($key=~/^form\.set_version_(.+)$/) { |
foreach my $key (sort(keys(%changes))) {
|
my $src=$1; |
if ($changes{$key}>$starttime) {
|
if (($env{$key}) && ($env{$key} ne $setversions{$src})) { |
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
|
$newsetversions{$src}=$env{$key}; |
my $currentversion=&Apache::lonnet::getversion($key);
|
&devalidateversioncache($src); |
if ($currentversion<0) {
|
} |
$currentversion=&mt('Could not be determined.');
|
} |
}
|
} |
my $linkurl=&Apache::lonnet::clutter($key);
|
} |
$r->print(
|
if ($haschanged) { |
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
|
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
&Apache::lonnet::gettitle($linkurl).
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
'</b></font></td></tr>'.
|
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
'<tr><td> </td>'.
|
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>'); |
'<td colspan="4">'.
|
} else { |
'<a href="'.$linkurl.'" target="cat">'.$linkurl.
|
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>'); |
'</a></td></tr>'.
|
} |
'<tr><td></td>'.
|
&mark_hash_old(); |
'<td title="'.$lt{'md'}.'">'.
|
} |
&Apache::lonlocal::locallocaltime(
|
&changewarning($r,''); |
&Apache::lonnet::metadata($root.'.'.$extension,
|
if ($env{'form.timerange'} eq 'all') { |
'lastrevisiondate')
|
# show all documents |
).
|
$header=&mt('All Documents in '.$crstype); |
'</td>'.
|
$allsel=1; |
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
|
foreach my $key (keys(%hash)) { |
'<font size="+1">'.$currentversion.'</font>'.
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
'</span></td>'.
|
my $src=$1; |
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
|
$changes{$src}=1; |
'<font size="+1">');
|
} |
# Used in course
|
} |
my $usedversion=$hash{'version_'.$linkurl};
|
} else { |
if (($usedversion) && ($usedversion ne 'mostrecent')) {
|
# show documents which changed |
$r->print($usedversion);
|
%changes=&Apache::lonnet::dump |
} else {
|
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$r->print($currentversion);
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
}
|
my $firstkey=(keys(%changes))[0]; |
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'.
|
unless ($firstkey=~/^error\:/) { |
'<span class="LC_nobreak">Use: ');
|
unless ($env{'form.timerange'}) { |
# Set version
|
$env{'form.timerange'}=604800; |
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
|
} |
'set_version_'.$linkurl,
|
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' ' |
('select_form_order' =>
|
.&mt('seconds'); |
['',1..$currentversion,'mostrecent'],
|
if ($env{'form.timerange'}==-1) { |
'' => '',
|
$seltext='since start of course'; |
'mostrecent' => 'most recent',
|
$startsel='selected'; |
map {$_,$_} (1..$currentversion))));
|
$env{'form.timerange'}=time; |
$r->print('</span></td></tr><tr><td></td>');
|
} |
my $lastold=1;
|
$starttime=time-$env{'form.timerange'}; |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
|
if ($env{'form.timerange'}==2592000) { |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
|
$monthsel='selected'; |
$starttime) {
|
} elsif ($env{'form.timerange'}==604800) { |
$lastold=$prevvers;
|
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
}
|
$weeksel='selected'; |
}
|
} elsif ($env{'form.timerange'}==86400) { |
#
|
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
# Code to figure out how many version entries should go in
|
$daysel='selected'; |
# each of the four columns
|
} |
my $entries_per_col = 0;
|
$header=&mt('Content changed').' '.$seltext; |
my $num_entries = ($currentversion-$lastold);
|
} else { |
if ($num_entries % 4 == 0) {
|
$header=&mt('No content modifications yet.'); |
$entries_per_col = $num_entries/4;
|
} |
} else {
|
} |
$entries_per_col = $num_entries/4 + 1;
|
%setversions=&Apache::lonnet::dump('resourceversions', |
}
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
my $entries_count = 0;
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$r->print('<td valign="top"><font size="-2">');
|
my %lt=&Apache::lonlocal::texthash |
my $cols_output = 1;
|
('st' => 'Version changes since start of '.$crstype, |
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
|
'lm' => 'Version changes since last Month', |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
'lw' => 'Version changes since last Week', |
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
|
'sy' => 'Version changes since Yesterday', |
'">'.&mt('Version').' '.$prevvers.'</a> ('.
|
'al' => 'All Resources (possibly large output)', |
&Apache::lonlocal::locallocaltime(
|
'sd' => 'Display', |
&Apache::lonnet::metadata($url,
|
'fi' => 'File', |
'lastrevisiondate')
|
'md' => 'Modification Date', |
).
|
'mr' => 'Most recently published Version', |
')');
|
've' => 'Version used in '.$crstype, |
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
|
'vu' => 'Set Version to be used in '.$crstype, |
$r->print(' <a href="/adm/diff?filename='.
|
'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below', |
&Apache::lonnet::clutter($root.'.'.$extension).
|
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', |
'&versionone='.$prevvers.
|
'sc' => 'Set all Resource Versions to current Version (Fix Versions)', |
'">'.&mt('Diffs').'</a>');
|
'di' => 'Differences'); |
}
|
$r->print(<<ENDHEADERS); |
$r->print('</span><br />');
|
<form action="/adm/coursedocs" method="post"> |
if (++$entries_count % $entries_per_col == 0) {
|
<input type="hidden" name="versions" value="1" /> |
$r->print('</font></td>');
|
<input type="submit" name="setmostrecent" value="$lt{'sm'}" /> |
if ($cols_output != 4) {
|
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr /> |
$r->print('<td valign="top"><font size="-2">');
|
<select name="timerange"> |
$cols_output++;
|
<option value='all' $allsel>$lt{'al'}</option> |
}
|
<option value="-1" $startsel>$lt{'st'}</option> |
}
|
<option value="2592000" $monthsel>$lt{'lm'}</option> |
}
|
<option value="604800" $weeksel>$lt{'lw'}</option> |
while($cols_output++ < 4) {
|
<option value="86400" $daysel>$lt{'sy'}</option> |
$r->print('</font></td><td><font>')
|
</select> |
}
|
<input type="submit" name="display" value="$lt{'sd'}" /> |
$r->print('</font></td></tr>'."\n");
|
<h3>$header</h3> |
}
|
<input type="submit" name="setversions" value="$lt{'sv'}" /> |
}
|
<table border="0"> |
$r->print('</table></form>');
|
ENDHEADERS |
$r->print('<h1>'.&mt('Done').'.</h1>');
|
foreach my $key (sort(keys(%changes))) { |
|
if ($changes{$key}>$starttime) { |
&untiehash();
|
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); |
}
|
my $currentversion=&Apache::lonnet::getversion($key); |
|
if ($currentversion<0) { |
sub mark_hash_old {
|
$currentversion=&mt('Could not be determined.'); |
my $retie_hash=0;
|
} |
if ($hashtied) {
|
my $linkurl=&Apache::lonnet::clutter($key); |
$retie_hash=1;
|
$r->print( |
&untiehash();
|
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'. |
}
|
&Apache::lonnet::gettitle($linkurl). |
&tiehash('write');
|
'</b></font></td></tr>'. |
$hash{'old'}=1;
|
'<tr><td> </td>'. |
&untiehash();
|
'<td colspan="4">'. |
if ($retie_hash) { &tiehash(); }
|
'<a href="'.$linkurl.'" target="cat">'.$linkurl. |
}
|
'</a></td></tr>'. |
|
'<tr><td></td>'. |
sub is_hash_old {
|
'<td title="'.$lt{'md'}.'">'. |
my $untie_hash=0;
|
&Apache::lonlocal::locallocaltime( |
if (!$hashtied) {
|
&Apache::lonnet::metadata($root.'.'.$extension, |
$untie_hash=1;
|
'lastrevisiondate') |
&tiehash();
|
). |
}
|
'</td>'. |
my $return=$hash{'old'};
|
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '. |
if ($untie_hash) { &untiehash(); }
|
'<font size="+1">'.$currentversion.'</font>'. |
return $return;
|
'</span></td>'. |
}
|
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$crstype.': '. |
|
'<font size="+1">'); |
sub changewarning {
|
# Used in course |
my ($r,$postexec,$message,$url)=@_;
|
my $usedversion=$hash{'version_'.$linkurl}; |
if (!&is_hash_old()) { return; }
|
if (($usedversion) && ($usedversion ne 'mostrecent')) { |
my $pathvar='folderpath';
|
$r->print($usedversion); |
my $path=&escape($env{'form.folderpath'});
|
} else { |
if (!defined($url)) {
|
$r->print($currentversion); |
if (defined($env{'form.pagepath'})) {
|
} |
$pathvar='pagepath';
|
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'. |
$path=&escape($env{'form.pagepath'});
|
'<span class="LC_nobreak">Use: '); |
$path.='&pagesymb='.&escape($env{'form.pagesymb'});
|
# Set version |
}
|
$r->print(&Apache::loncommon::select_form($setversions{$linkurl}, |
$url='/adm/coursedocs?'.$pathvar.'='.$path;
|
'set_version_'.$linkurl, |
}
|
{'select_form_order' => |
my $course_type = &Apache::loncommon::course_type();
|
['',1..$currentversion,'mostrecent'], |
if (!defined($message)) {
|
'' => '', |
$message='Changes will become active for your current session after [_1], or the next time you log in.';
|
'mostrecent' => &mt('most recent'), |
}
|
map {$_,$_} (1..$currentversion)})); |
$r->print("\n\n".
|
$r->print('</span></td></tr><tr><td></td>'); |
'<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
|
my $lastold=1; |
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
|
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
'<input type="hidden" name="orgurl" value="'.$url.
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
'" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
|
if (&Apache::lonnet::metadata($url,'lastrevisiondate')< |
&mt($message,' <input type="hidden" name="'.
|
$starttime) { |
$env{'request.role'}.'" value="1" /><input type="button" value="'.
|
$lastold=$prevvers; |
&mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
|
} |
$help{'Caching'}.'</span></h3></form>'."\n\n");
|
} |
}
|
# |
|
# Code to figure out how many version entries should go in |
|
# each of the four columns |
sub init_breadcrumbs {
|
my $entries_per_col = 0; |
my ($form,$text)=@_;
|
my $num_entries = ($currentversion-$lastold); |
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
if ($num_entries % 4 == 0) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
|
$entries_per_col = $num_entries/4; |
text=>"Edit ".&Apache::loncommon::course_type(),
|
} else { |
faq=>273,
|
$entries_per_col = $num_entries/4 + 1; |
bug=>'Instructor Interface',
|
} |
help => 'Docs_Adding_Course_Doc'});
|
my $entries_count = 0; |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
|
$r->print('<td valign="top"><font size="-2">'); |
text=>$text,
|
my $cols_output = 1; |
faq=>273,
|
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { |
bug=>'Instructor Interface'});
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
}
|
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url). |
|
'">'.&mt('Version').' '.$prevvers.'</a> ('. |
|
&Apache::lonlocal::locallocaltime( |
|
&Apache::lonnet::metadata($url, |
|
'lastrevisiondate') |
sub handler {
|
). |
my $r = shift;
|
')'); |
&Apache::loncommon::content_type($r,'text/html');
|
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { |
$r->send_http_header;
|
$r->print(' <a href="/adm/diff?filename='. |
return OK if $r->header_only;
|
&Apache::lonnet::clutter($root.'.'.$extension). |
my $type = &Apache::loncommon::course_type();
|
'&versionone='.$prevvers. |
|
'">'.&mt('Diffs').'</a>'); |
|
} |
# --------------------------------------------- Initialize help topics for this
|
$r->print('</span><br />'); |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
|
if (++$entries_count % $entries_per_col == 0) { |
'Adding_External_Resource','Navigate_Content',
|
$r->print('</font></td>'); |
'Adding_Folders','Docs_Overview', 'Load_Map',
|
if ($cols_output != 4) { |
'Supplemental','Score_Upload_Form','Adding_Pages',
|
$r->print('<td valign="top"><font size="-2">'); |
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
|
$cols_output++; |
'Check_Resource_Versions','Verify_Content') {
|
} |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
|
} |
}
|
} |
# Composite help files
|
while($cols_output++ < 4) { |
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
|
$r->print('</font></td><td><font>') |
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
|
} |
$help{'Simple Page'} = &Apache::loncommon::help_open_topic(
|
$r->print('</font></td></tr>'."\n"); |
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
|
} |
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
|
} |
'Option_Response_Simple');
|
$r->print('</table></form>'); |
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
|
$r->print('<p class="LC_success">'.&mt('Done').'</p>'); |
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
|
|
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
|
&untiehash(); |
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
|
} |
$help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
|
|
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
|
sub mark_hash_old { |
|
my $retie_hash=0; |
# does this user have privileges to modify docs
|
if ($hashtied) { |
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
|
$retie_hash=1; |
if ($allowed && $env{'form.verify'}) {
|
&untiehash(); |
&init_breadcrumbs('verify','Verify Content');
|
} |
&verifycontent($r);
|
&tiehash('write'); |
} elsif ($allowed && $env{'form.listsymbs'}) {
|
$hash{'old'}=1; |
&init_breadcrumbs('listsymbs','List Symbs');
|
&untiehash(); |
&list_symbs($r);
|
if ($retie_hash) { &tiehash(); } |
} elsif ($allowed && $env{'form.docslog'}) {
|
} |
&init_breadcrumbs('docslog','Show Log');
|
|
&docs_change_log($r);
|
sub is_hash_old { |
} elsif ($allowed && $env{'form.versions'}) {
|
my $untie_hash=0; |
&init_breadcrumbs('versions','Check/Set Resource Versions');
|
if (!$hashtied) { |
&checkversions($r);
|
$untie_hash=1; |
} elsif ($allowed && $env{'form.dumpcourse'}) {
|
&tiehash(); |
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
|
} |
&dumpcourse($r);
|
my $return=$hash{'old'}; |
} elsif ($allowed && $env{'form.exportcourse'}) {
|
if ($untie_hash) { &untiehash(); } |
&init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
|
return $return; |
&exportcourse($r);
|
} |
} else {
|
|
# is this a standard course?
|
sub changewarning { |
|
my ($r,$postexec,$message,$url)=@_; |
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
|
if (!&is_hash_old()) { return; } |
my $forcestandard = 0;
|
my $pathvar='folderpath'; |
my $forcesupplement;
|
my $path=&escape($env{'form.folderpath'}); |
my $script='';
|
if (!defined($url)) { |
my $showdoc=0;
|
if (defined($env{'form.pagepath'})) { |
my $containertag;
|
$pathvar='pagepath'; |
my $uploadtag;
|
$path=&escape($env{'form.pagepath'}); |
|
$path.='&pagesymb='.&escape($env{'form.pagesymb'}); |
|
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
$url='/adm/coursedocs?'.$pathvar.'='.$path; |
['folderpath','pagepath',
|
} |
'pagesymb']);
|
my $course_type = &Apache::loncommon::course_type(); |
# No folderpath, no pagepath, see if we have something stored
|
if (!defined($message)) { |
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
|
$message='Changes will become active for your current session after [_1], or the next time you log in.'; |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
} |
{'folderpath' => 'scalar'});
|
$r->print("\n\n". |
}
|
'<script type="text/javascript">'."\n". |
if (!$env{'form.folderpath'}) {
|
'// <![CDATA['."\n". |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
'function reinit(tf) { tf.submit();'.$postexec.' }'."\n". |
{'pagepath' => 'scalar'});
|
'// ]]>'."\n". |
}
|
'</script>'."\n". |
if ($env{'form.pagepath'}) {
|
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'. |
$env{'form.folderpath'}='';
|
'<input type="hidden" name="orgurl" value="'.$url. |
}
|
'" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'. |
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
|
&mt($message,' <input type="hidden" name="'. |
$env{'form.folderpath'} = 'supplemental&'.
|
$env{'request.role'}.'" value="1" /><input type="button" value="'. |
&escape(&mt('Supplemental '.$type.' Documents')).'&'.
|
&mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />'). |
$env{'form.folderpath'};
|
$help{'Caching'}.'</p></form>'."\n\n"); |
}
|
} |
&Apache::loncommon::store_course_settings('docs_folderpath',
|
|
{'pagepath' => 'scalar',
|
|
'folderpath' => 'scalar'});
|
sub init_breadcrumbs { |
if ($env{'form.folderpath'}) {
|
my ($form,$text)=@_; |
my (@folderpath)=split('&',$env{'form.folderpath'});
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
$env{'form.foldername'}=&unescape(pop(@folderpath));
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs", |
$env{'form.folder'}=pop(@folderpath);
|
text=>&Apache::loncommon::course_type().' Editor', |
}
|
faq=>273, |
if ($env{'form.pagepath'}) {
|
bug=>'Instructor Interface', |
my (@pagepath)=split('&',$env{'form.pagepath'});
|
help => 'Docs_Adding_Course_Doc'}); |
$env{'form.pagename'}=&unescape(pop(@pagepath));
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1', |
$env{'form.folder'}=pop(@pagepath);
|
text=>$text, |
$containertag = '<input type="hidden" name="pagepath" value="" />'.
|
faq=>273, |
'<input type="hidden" name="pagesymb" value="" />';
|
bug=>'Instructor Interface'}); |
$uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
|
} |
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
|
|
}
|
# subroutine to list form elements |
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
|
sub create_list_elements { |
$showdoc='/'.$1;
|
my @formarr = @_; |
}
|
my $list = ''; |
unless ($showdoc) { # got called from remote
|
for my $button (@formarr){ |
if (($env{'form.folder'}=~/^(?:group|default)_/) ||
|
for my $picture(keys %$button) { |
($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
|
$list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); |
$forcestandard = 1;
|
} |
}
|
} |
$forcesupplement=($env{'form.folder'}=~/^supplemental_/);
|
return $list; |
|
} |
if ($allowed) {
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
|
# subroutine to create ul from list elements |
$script=&Apache::lonratedt::editscript('simple');
|
sub create_form_ul { |
}
|
my $list = shift; |
} else { # got called in sequence from course
|
my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'}); |
$allowed=0;
|
return $ul; |
}
|
} |
|
|
# get course data
|
# |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
|
# Start tabs |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
# |
|
|
# get personal data
|
sub startContentScreen { |
my $uname=$env{'user.name'};
|
my ($r,$mode)=@_; |
my $udom=$env{'user.domain'};
|
$r->print('<ul class="LC_TabContentBigger" id="mainnav">'); |
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
|
$r->print('<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'); |
|
|
# graphics settings
|
my $active = ''; |
|
# does this user have privileges to modify docs? |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
|
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
|
|
if ($allowed) {
|
my $onclick; |
$script .= &editing_js($udom,$uname);
|
my $href; |
}
|
|
# -------------------------------------------------------------------- Body tag
|
if ($allowed) { |
$script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
|
$r->print('<li '.(($mode eq 'docs')?' class="active"':''). |
my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
|
'><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'); |
$r->print(&Apache::loncommon::start_page("$type Documents", $script,
|
} |
{'force_register' => $showdoc,
|
$r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'); |
'bread_crumbs' => $brcrum}).
|
$r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'); |
&Apache::loncommon::help_open_menu('','',273,'RAT'));
|
$r->print('<li '.(($mode eq 'supdocs')?' class="active"':''). |
|
'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Documents').'</b></a></li>'); |
my %allfiles = ();
|
$r->print('</ul>'); |
my %codebase = ();
|
$r->print('<div class="LC_Box" style="clear:both;margin:0;">' |
my ($upload_result,$upload_output);
|
.'<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'); |
if ($allowed) {
|
$r->print('<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">'); |
if (($env{'form.uploaddoc.filename'}) &&
|
} |
($env{'form.cmd'}=~/^upload_(\w+)/)) {
|
|
# Process file upload - phase one - upload and parse primary file.
|
# |
undef($hadchanges);
|
# End tabs |
$upload_result = &process_file_upload(\$upload_output,$coursenum,
|
# |
$coursedom,\%allfiles,
|
|
\%codebase,$1);
|
sub endContentScreen { |
if ($hadchanges) {
|
my ($r)=@_; |
&mark_hash_old();
|
$r->print('</div></div></div>'); |
}
|
} |
if ($upload_result eq 'phasetwo') {
|
|
$r->print($upload_output);
|
sub supplemental_base { |
}
|
return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Documents')); |
} elsif ($env{'form.phasetwo'}) {
|
} |
my %newname = ();
|
|
my %origname = ();
|
sub handler { |
my %attribs = ();
|
my $r = shift; |
my $updateflag = 0;
|
&Apache::loncommon::content_type($r,'text/html'); |
my $residx = $env{'form.newidx'};
|
$r->send_http_header; |
my $primary_url = &unescape($env{'form.primaryurl'});
|
return OK if $r->header_only; |
# Process file upload - phase two - gather secondary files.
|
my $crstype = &Apache::loncommon::course_type(); |
for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
|
|
if ($env{'form.embedded_item_'.$i.'.filename'}) {
|
# |
my $javacodebase;
|
# --------------------------------------------- Initialize help topics for this |
$newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
|
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', |
$origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
|
'Adding_External_Resource','Navigate_Content', |
if (exists($env{'form.embedded_codebase_'.$i})) {
|
'Adding_Folders','Docs_Overview', 'Load_Map', |
$javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
|
'Supplemental','Score_Upload_Form','Adding_Pages', |
$origname{$i} =~ s#^\Q$javacodebase\E/##;
|
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', |
}
|
'Check_Resource_Versions','Verify_Content') { |
my @attributes = ();
|
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
|
} |
@attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
|
# Composite help files |
} else {
|
$help{'Syllabus'} = &Apache::loncommon::help_open_topic( |
@attributes = ($env{'form.embedded_attrib_'.$i});
|
'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); |
}
|
$help{'Simple Page'} = &Apache::loncommon::help_open_topic( |
foreach my $attr (@attributes) {
|
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); |
push(@{$attribs{$i}},&unescape($attr));
|
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic( |
}
|
'Option_Response_Simple'); |
if ($javacodebase) {
|
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( |
$codebase{$i} = $javacodebase;
|
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); |
$codebase{$i} =~ s#/$##;
|
$help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic( |
$updateflag = 1;
|
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); |
}
|
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
}
|
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
unless ($newname{$i} eq $origname{$i}) {
|
|
$updateflag = 1;
|
# does this user have privileges to modify docs |
}
|
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
}
|
if ($allowed && $env{'form.verify'}) { |
# Process file upload - phase three - modify primary file
|
&init_breadcrumbs('verify','Verify Content'); |
if ($updateflag) {
|
&verifycontent($r); |
my ($content,$rtncode);
|
} elsif ($allowed && $env{'form.listsymbs'}) { |
my $updateflag = 0;
|
&init_breadcrumbs('listsymbs','List Symbs'); |
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
|
&list_symbs($r); |
if ($getstatus eq 'ok') {
|
} elsif ($allowed && $env{'form.docslog'}) { |
foreach my $item (keys(%newname)) {
|
&init_breadcrumbs('docslog','Show Log'); |
if ($newname{$item} ne $origname{$item}) {
|
&docs_change_log($r); |
my $attrib_regexp = '';
|
} elsif ($allowed && $env{'form.versions'}) { |
if (@{$attribs{$item}} > 1) {
|
&init_breadcrumbs('versions','Check/Set Resource Versions'); |
$attrib_regexp = join('|',@{$attribs{$item}});
|
&checkversions($r); |
} else {
|
} elsif ($allowed && $env{'form.dumpcourse'}) { |
$attrib_regexp = $attribs{$item}[0];
|
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Documents to Construction Space'); |
}
|
&dumpcourse($r); |
if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
|
} elsif ($allowed && $env{'form.exportcourse'}) { |
}
|
&init_breadcrumbs('exportcourse','IMS Export'); |
$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
|
&exportcourse($r); |
}
|
} else { |
if (exists($codebase{$item})) {
|
# |
$content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
|
# Done catching special calls |
}
|
# The whole rest is for course and supplemental documents |
}
|
# Get the parameters that may be needed |
# Save edited file.
|
# |
my $saveresult;
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
|
['folderpath','pagepath', |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
'pagesymb','forcesupplement','forcestandard']); |
my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
|
|
} else {
|
# standard=1: this is a "new-style" course with an uploaded map as top level |
&Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
|
# standard=2: this is a "old-style" course, and there is nothing we can do |
}
|
|
}
|
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//); |
}
|
|
}
|
# Decide whether this should display supplemental or main content |
|
# supplementalflag=1: show supplemental documents |
unless ($showdoc || $upload_result eq 'phasetwo') {
|
# supplementalflag=0: show standard documents |
# -----------------------------------------------------------------------------
|
|
my %lt=&Apache::lonlocal::texthash(
|
|
'uplm' => 'Upload a new main '.lc($type).' document',
|
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
'upls' => 'Upload a new supplemental '.lc($type).' document',
|
if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) { |
'impp' => 'Import a document',
|
$supplementalflag=0; |
'pubd' => 'Published Documents',
|
} |
'copm' => 'All documents out of a published map into this folder',
|
if ($env{'form.forcesupplement'}) { $supplementalflag=1; } |
'upld' => 'Upload Document',
|
if ($env{'form.forcestandard'}) { $supplementalflag=0; } |
'srch' => 'Search',
|
unless ($allowed) { $supplementalflag=1; } |
'impo' => 'Import',
|
unless ($standard) { $supplementalflag=1; } |
'book' => 'Import Bookmarks',
|
|
'selm' => 'Select Map',
|
my $script=''; |
'load' => 'Load Map',
|
my $showdoc=0; |
'reco' => 'Recover Deleted Resources',
|
my $containertag; |
'newf' => 'New Folder',
|
my $uploadtag; |
'newp' => 'New Composite Page',
|
|
'extr' => 'External Resource',
|
# Where do we store these for when we come back? |
'syll' => 'Syllabus',
|
my $stored_folderpath='docs_folderpath'; |
'navc' => 'Navigate Contents',
|
if ($supplementalflag) { |
'sipa' => 'Simple Page',
|
$stored_folderpath='docs_sup_folderpath'; |
'sipr' => 'Simple Problem',
|
} |
'drbx' => 'Drop Box',
|
|
'scuf' => 'Score Upload Form',
|
# No folderpath, no pagepath, see if we have something stored |
'bull' => 'Bulletin Board',
|
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) { |
'mypi' => 'My Personal Info',
|
&Apache::loncommon::restore_course_settings($stored_folderpath, |
'grpo' => 'Group Files',
|
{'folderpath' => 'scalar'}); |
'rost' => 'Course Roster',
|
} |
'abou' => 'About User',
|
|
'imsf' => 'Import IMS package',
|
# If we are not allowed to make changes, all we can see are supplemental docs |
'file' => 'File',
|
if (!$allowed) { |
'title' => 'Title',
|
$env{'form.pagepath'}=''; |
'comment' => 'Comment',
|
unless ($env{'form.folderpath'} =~ /^supplemental/) { |
'parse' => 'Upload embedded images/multimedia files if HTML file!',
|
$env{'form.folderpath'} = &supplemental_base(); |
'nd' => 'New Document',
|
} |
'pm' => 'Published Map',
|
} |
'sd' => 'Special Document',
|
# If we still not have a folderpath, see if we can resurrect at pagepath |
'mo' => 'More Options',
|
if (!$env{'form.folderpath'} && $allowed) { |
'hao' => 'Hide all Options'
|
&Apache::loncommon::restore_course_settings($stored_folderpath, |
);
|
{'pagepath' => 'scalar'}); |
# -----------------------------------------------------------------------------
|
} |
my $fileupload=(<<FIUP);
|
# Make the zeroth entry in supplemental docs page paths, so we can get to top level |
$lt{'file'}:<br />
|
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) { |
<input type="file" name="uploaddoc" size="40" />
|
$env{'form.folderpath'} = &supplemental_base() |
FIUP
|
.'&'. |
|
$env{'form.folderpath'}; |
my $checkbox=(<<CHBO);
|
} |
<!-- <label>$lt{'parse'}?
|
# If after all of this, we still don't have any paths, make them |
<input type="checkbox" name="parserflag" />
|
unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) { |
</label> -->
|
if ($supplementalflag) { |
<label>
|
$env{'form.folderpath'}=&supplemental_base(); |
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
|
} else { |
</label>
|
$env{'form.folderpath'}='default'; |
CHBO
|
} |
|
} |
my $fileuploadform=(<<FUFORM);
|
|
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
# Store this |
$fileupload
|
&Apache::loncommon::store_course_settings($stored_folderpath, |
<br />
|
{'pagepath' => 'scalar', |
$lt{'title'}:<br />
|
'folderpath' => 'scalar'}); |
<input type="text" size="50" name="comment" />
|
|
$uploadtag
|
if ($env{'form.folderpath'}) { |
<input type="hidden" name="cmd" value="upload_default" />
|
my (@folderpath)=split('&',$env{'form.folderpath'}); |
<br />
|
$env{'form.foldername'}=&unescape(pop(@folderpath)); |
<span class="LC_nobreak">
|
$env{'form.folder'}=pop(@folderpath); |
$checkbox
|
} |
</span>
|
if ($env{'form.pagepath'}) { |
<br />
|
my (@pagepath)=split('&',$env{'form.pagepath'}); |
<br />
|
$env{'form.pagename'}=&unescape(pop(@pagepath)); |
<span class="LC_nobreak">
|
$env{'form.folder'}=pop(@pagepath); |
<input type="submit" value="$lt{'upld'}" />
|
$containertag = '<input type="hidden" name="pagepath" value="" />'. |
$help{'Uploading_From_Harddrive'}
|
'<input type="hidden" name="pagesymb" value="" />'; |
</span>
|
$uploadtag = |
</form>
|
'<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'. |
FUFORM
|
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'. |
|
'<input type="hidden" name="folderpath" value="" />'; |
my $simpleeditdefaultform=(<<SEDFFORM);
|
} else { |
<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
|
my $folderpath=$env{'form.folderpath'}; |
$lt{'pubd'}<br />
|
if (!$folderpath) { |
$uploadtag
|
if ($env{'form.folder'} eq '' || |
<input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
|
$env{'form.folder'} eq 'supplemental') { |
<br />
|
$folderpath='default&'. |
<span class="LC_nobreak">
|
&escape(&mt('Main '.$crstype.' Documents')); |
<input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
|
} |
$help{'Importing_LON-CAPA_Resource'}
|
} |
</span>
|
$containertag = '<input type="hidden" name="folderpath" value="" />'; |
<br />
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; |
<input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
|
} |
<hr />
|
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { |
<p>
|
$showdoc='/'.$1; |
$lt{'copm'}<br />
|
} |
<input type="text" size="40" name="importmap" /><br />
|
if ($showdoc) { # got called in sequence from course |
<span class="LC_nobreak"><input type="button"
|
$allowed=0; |
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
|
} else { |
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
|
if ($allowed) { |
$help{'Load_Map'}</span>
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); |
</p>
|
$script=&Apache::lonratedt::editscript('simple'); |
</form>
|
} |
SEDFFORM
|
} |
|
|
my $extresourcesform=(<<ERFORM);
|
# get course data |
<form action="/adm/coursedocs" method="post" name="newext">
|
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
$uploadtag
|
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
# get personal data |
<input name="newext" type="button" onClick="javascript:makenewext('newext');"
|
my $uname=$env{'user.name'}; |
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
my $udom=$env{'user.domain'}; |
</span>
|
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom)); |
</form>
|
|
ERFORM
|
# graphics settings |
|
|
if ($allowed) {
|
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); |
&update_paste_buffer($coursenum,$coursedom);
|
|
my $dumpbut=&dumpbutton();
|
if ($allowed) { |
my $exportbut=&exportbutton();
|
$script .= &editing_js($udom,$uname); |
my %lt=&Apache::lonlocal::texthash(
|
} |
'vc' => 'Verify Content',
|
# -------------------------------------------------------------------- Body tag |
'cv' => 'Check/Set Resource Versions',
|
$script = '<script type="text/javascript">'."\n" |
'ls' => 'List Symbs',
|
.'// <![CDATA['."\n" |
'sl' => 'Show Log'
|
.$script."\n" |
);
|
.'// ]]>'."\n" |
|
.'</script>'."\n"; |
my $folderpath=$env{'form.folderpath'};
|
|
if (!$folderpath) {
|
# Breadcrumbs |
if ($env{'form.folder'} eq '' ||
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
$env{'form.folder'} eq 'supplemental') {
|
unless ($showdoc) { |
$folderpath='default&'.
|
&Apache::lonhtmlcommon::add_breadcrumb({ |
&escape(&mt('Main '.$type.' Documents'));
|
href=>"/adm/coursedocs",text=>"$crstype Contents"}); |
}
|
|
}
|
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script, |
unless ($env{'form.pagepath'}) {
|
{'force_register' => $showdoc,}) |
$containertag = '<input type="hidden" name="folderpath" value="" />';
|
.&Apache::loncommon::help_open_menu('','',273,'RAT') |
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
|
.&Apache::lonhtmlcommon::breadcrumbs( |
}
|
'Editing the Table of Contents for your '.$crstype, |
$r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env));
|
'Docs_Adding_Course_Doc') |
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
|
); |
&mt('Editing the Table of Contents for your '.$type)));
|
} else { |
}
|
$r->print(&Apache::loncommon::start_page("$crstype documents",undef, |
# --------------------------------------------------------- Standard documents
|
{'force_register' => $showdoc,})); |
$r->print('<table class="LC_docs_documents">');
|
} |
|
|
if (($standard) && ($allowed) && (!$forcesupplement)) {
|
my %allfiles = (); |
$r->print('<tr><td class="LC_docs_document">');
|
my %codebase = (); |
# '<h2>'.&mt('Main Course Documents').
|
my ($upload_result,$upload_output,$uploadphase); |
# ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
|
if ($allowed) { |
my $folder=$env{'form.folder'};
|
if (($env{'form.uploaddoc.filename'}) && |
if ($folder eq '' || $folder eq 'supplemental') {
|
($env{'form.cmd'}=~/^upload_(\w+)/)) { |
$folder='default';
|
my $context = $1; |
$env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
|
# Process file upload - phase one - upload and parse primary file. |
$uploadtag = '<input type="hidden" name="folderpath" value="'.
|
undef($hadchanges); |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
|
$uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom, |
}
|
\%allfiles,\%codebase,$context); |
my $postexec='';
|
if ($hadchanges) { |
if ($folder eq 'default') {
|
&mark_hash_old(); |
$r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
|
} |
} else {
|
$r->print($upload_output); |
#$postexec='self.close();';
|
} elsif ($env{'form.phase'} eq 'upload_embedded') { |
}
|
# Process file upload - phase two - upload embedded objects |
$hadchanges=0;
|
$uploadphase = 'check_embedded'; |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
|
my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"'); |
$upload_output,$type);
|
my $state = &embedded_form_elems($uploadphase,$primaryurl, |
if ($error) {
|
$env{'form.newidx'}); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
}
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
if ($hadchanges) {
|
my ($destination,$dir_root) = &embedded_destination(); |
&mark_hash_old();
|
my $url_root = '/uploaded/'.$docudom.'/'.$docuname; |
}
|
my $actionurl = '/adm/coursedocs'; |
&changewarning($r,$postexec);
|
my ($result,$flag) = |
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
&Apache::loncommon::upload_embedded('coursedoc',$destination, |
'.sequence';
|
$docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state, |
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
$actionurl); |
'.page';
|
$r->print($result.&return_to_editor()); |
my $container='sequence';
|
} elsif ($env{'form.phase'} eq 'check_embedded') { |
if ($env{'form.pagepath'}) {
|
# Process file upload - phase three - modify references in HTML file |
$container='page';
|
$uploadphase = 'modified_orightml'; |
}
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my ($destination,$dir_root) = &embedded_destination(); |
|
$r->print(&Apache::loncommon::modify_html_refs('coursedoc',$destination, |
|
$docuname,$docudom,undef, |
my $recoverform=(<<RFORM);
|
$dir_root). |
<form action="/adm/groupsort" method="post" name="recover">
|
&return_to_editor()); |
<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
|
} |
</form>
|
} |
RFORM
|
|
|
unless ($showdoc || $uploadphase) { |
my $imspform=(<<IMSPFORM);
|
# ----------------------------------------------------------------------------- |
<form action="/adm/imsimportdocs" method="post" name="ims">
|
my %lt=&Apache::lonlocal::texthash( |
<input type="hidden" name="folder" value="$folder" />
|
'uplm' => 'Upload a new main '.lc($crstype).' document', |
<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
|
'upls' => 'Upload a new supplemental '.lc($crstype).' document', |
</form>
|
'impp' => 'Import a document', |
IMSPFORM
|
'copm' => 'All documents out of a published map into this folder', |
|
'upld' => 'Import Document', |
my $newnavform=(<<NNFORM);
|
'srch' => 'Search', |
<form action="/adm/coursedocs" method="post" name="newnav">
|
'impo' => 'Import', |
$uploadtag
|
'wish' => 'Import from Wishlist', |
<input type="hidden" name="importdetail"
|
'selm' => 'Select Map', |
value="$lt{'navc'}=/adm/navmaps" />
|
'load' => 'Load Map', |
<span class="LC_nobreak">
|
'reco' => 'Recover Deleted Documents', |
<input name="newnav" type="submit" value="$lt{'navc'}" />
|
'newf' => 'New Folder', |
$help{'Navigate_Content'}
|
'newp' => 'New Composite Page', |
</span>
|
'extr' => 'External Resource', |
</form>
|
'syll' => 'Syllabus', |
NNFORM
|
'navc' => 'Table of Contents', |
my $newsmppageform=(<<NSPFORM);
|
'sipa' => 'Simple Course Page', |
<form action="/adm/coursedocs" method="post" name="newsmppg">
|
'sipr' => 'Simple Problem', |
$uploadtag
|
'drbx' => 'Drop Box', |
<input type="hidden" name="importdetail" value="" />
|
'scuf' => 'External Scores (handgrade, upload, clicker)', |
<span class="LC_nobreak">
|
'bull' => 'Discussion Board', |
<input name="newsmppg" type="button" value="$lt{'sipa'}"
|
'mypi' => 'My Personal Information Page', |
onClick="javascript:makesmppage();" /> $help{'Simple Page'}
|
'grpo' => 'Group Portfolio', |
</span>
|
'rost' => 'Course Roster', |
</form>
|
'abou' => 'Personal Information Page for a User', |
NSPFORM
|
'imsf' => 'IMS Import', |
|
'imsl' => 'Import IMS package', |
my $newsmpproblemform=(<<NSPROBFORM);
|
'file' => 'File', |
<form action="/adm/coursedocs" method="post" name="newsmpproblem">
|
'title' => 'Title', |
$uploadtag
|
'comment' => 'Comment', |
<input type="hidden" name="importdetail" value="" />
|
'parse' => 'Upload embedded images/multimedia files if HTML file', |
<span class="LC_nobreak">
|
'nd' => 'Upload Document', |
<input name="newsmpproblem" type="button" value="$lt{'sipr'}"
|
'pm' => 'Published Map', |
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
|
'sd' => 'Special Document', |
</span>
|
'mo' => 'More Options', |
</form>
|
); |
|
# ----------------------------------------------------------------------------- |
NSPROBFORM
|
my $fileupload=(<<FIUP); |
|
$lt{'file'}:<br /> |
my $newdropboxform=(<<NDBFORM);
|
<input type="file" name="uploaddoc" size="40" /> |
<form action="/adm/coursedocs" method="post" name="newdropbox">
|
FIUP |
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
my $checkbox=(<<CHBO); |
<span class="LC_nobreak">
|
<!-- <label>$lt{'parse'}? |
<input name="newdropbox" type="button" value="$lt{'drbx'}"
|
<input type="checkbox" name="parserflag" /> |
onClick="javascript:makedropbox();" />
|
</label> --> |
</span>
|
<label> |
</form>
|
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'} |
NDBFORM
|
</label> |
|
CHBO |
my $newexuploadform=(<<NEXUFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newexamupload">
|
my $fileuploada = "<input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}"; |
$uploadtag
|
my $fileuploadform=(<<FUFORM); |
<input type="hidden" name="importdetail" value="" />
|
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
<span class="LC_nobreak">
|
<input type="hidden" name="active" value="aa" /> |
<input name="newexamupload" type="button" value="$lt{'scuf'}"
|
$fileupload |
onClick="javascript:makeexamupload();" />
|
<br /> |
$help{'Score_Upload_Form'}
|
$lt{'title'}:<br /> |
</span>
|
<input type="text" size="80" name="comment" /> |
</form>
|
$uploadtag |
NEXUFORM
|
<input type="hidden" name="cmd" value="upload_default" /> |
|
<br /> |
my $newbulform=(<<NBFORM);
|
<span class="LC_nobreak"> |
<form action="/adm/coursedocs" method="post" name="newbul">
|
$checkbox |
$uploadtag
|
</span> |
<input type="hidden" name="importdetail" value="" />
|
FUFORM |
<span class="LC_nobreak">
|
$fileuploadform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$fileuploada,{class => 'LC_menubuttons_inline_text'})).'</form>'; |
<input name="newbulletin" type="button" value="$lt{'bull'}"
|
|
onClick="javascript:makebulboard();" />
|
my $simpleeditdefaultform=(<<SEDFFORM); |
$help{'Bulletin Board'}
|
<form action="/adm/coursedocs" method="post" name="simpleeditdefault"> |
</span>
|
<input type="hidden" name="active" value="bb" /> |
</form>
|
SEDFFORM |
NBFORM
|
my @simpleeditdefaultforma = ( |
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
my $newaboutmeform=(<<NAMFORM);
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
<form action="/adm/coursedocs" method="post" name="newaboutme">
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{wish}.'" onclick="javascript:open_Wishlist_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_Wishlist_Import();'>$lt{'wish'}</a>" }, |
$uploadtag
|
); |
<input type="hidden" name="importdetail"
|
$simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma)); |
value="$plainname=/adm/$udom/$uname/aboutme" />
|
$simpleeditdefaultform .=(<<SEDFFORM); |
<span class="LC_nobreak">
|
<hr /> |
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
<p> |
$help{'My Personal Info'}
|
$lt{'copm'}<br /> |
</span>
|
<input type="text" size="40" name="importmap" /><br /> |
</form>
|
<span class="LC_nobreak"><input type="button" |
NAMFORM
|
onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" |
|
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" /> |
my $newaboutsomeoneform=(<<NASOFORM);
|
$help{'Load_Map'}</span> |
<form action="/adm/coursedocs" method="post" name="newaboutsomeone">
|
</p> |
$uploadtag
|
</form> |
<input type="hidden" name="importdetail" value="" />
|
SEDFFORM |
<span class="LC_nobreak">
|
|
<input name="newaboutsomeone" type="button" value="$lt{'abou'}"
|
my $extresourcesform=(<<ERFORM); |
onClick="javascript:makeabout();" />
|
<form action="/adm/coursedocs" method="post" name="newext"> |
</span>
|
$uploadtag |
</form>
|
<input type="hidden" name="importdetail" value="" /> |
NASOFORM
|
<a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'} |
|
</form> |
|
ERFORM |
my $newrosterform=(<<NROSTFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newroster">
|
|
$uploadtag
|
if ($allowed) { |
<input type="hidden" name="importdetail"
|
&update_paste_buffer($coursenum,$coursedom); |
value="$lt{'rost'}=/adm/viewclasslist" />
|
my %lt=&Apache::lonlocal::texthash( |
<span class="LC_nobreak">
|
'vc' => 'Verify Content', |
<input name="newroster" type="submit" value="$lt{'rost'}" />
|
'cv' => 'Check/Set Resource Versions', |
$help{'Course Roster'}
|
'ls' => 'List Symbs', |
</span>
|
'sl' => 'Show Log' |
</form>
|
); |
NROSTFORM
|
|
|
$r->print(<<HIDDENFORM); |
$r->print(<<ENDFORM);
|
<form name="renameform" method="post" action="/adm/coursedocs"> |
|
<input type="hidden" name="title" /> |
<ul class="LC_TabContent">
|
<input type="hidden" name="cmd" /> |
<li>$lt{'nd'}</li>
|
<input type="hidden" name="markcopy" /> |
<li>$lt{'pm'}</li>
|
<input type="hidden" name="copyfolder" /> |
<li>$lt{'pubd'}</li>
|
$containertag |
<li>$lt{'sd'}</li>
|
</form> |
<li>$lt{'mo'}</li>
|
<form name="simpleedit" method="post" action="/adm/coursedocs"> |
<li>$lt{'hao'}</li>
|
<input type="hidden" name="importdetail" value="" /> |
</ul>
|
$uploadtag |
|
</form> |
<table class="LC_docs_adddocs">
|
HIDDENFORM |
<!-- <tr>
|
} |
<th>$lt{'uplm'}</th>
|
|
<th>$lt{'impp'}</th>
|
# Generate the tabs |
<th>$lt{'spec'}</th>
|
&startContentScreen($r,($supplementalflag?'supdocs':'docs')); |
</tr> -->
|
|
<tr>
|
|
<td>
|
# |
$fileuploadform
|
|
</td>
|
my $savefolderpath; |
<td>
|
|
$simpleeditdefaultform
|
if ($allowed) { |
<hr />
|
my $folder=$env{'form.folder'}; |
$recoverform
|
if ($folder eq '' || $supplementalflag) { |
ENDFORM
|
$folder='default'; |
unless ($env{'form.pagepath'}) {
|
$savefolderpath = $env{'form.folderpath'}; |
$r->print(<<ENDFORM);
|
$env{'form.folderpath'}='default&'.&escape(&mt('Content')); |
<hr />
|
$uploadtag = '<input type="hidden" name="folderpath" value="'. |
$extresourcesform
|
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'; |
<br />
|
} |
$imspform
|
my $postexec=''; |
ENDFORM
|
if ($folder eq 'default') { |
}
|
$r->print('<script type="text/javascript">'."\n" |
$r->print('</td><td>');
|
.'// <![CDATA['."\n" |
unless ($env{'form.pagepath'}) {
|
.'this.window.name="loncapaclient";'."\n" |
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
.'// ]]>'."\n" |
|
.'</script>'."\n" |
|
); |
|
} else { |
my $newpageform=(<<NPFORM);
|
#$postexec='self.close();'; |
<form action="/adm/coursedocs" method="post" name="newpage">
|
} |
<input type="hidden" name="folderpath" value="$path" />
|
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
<input type="hidden" name="importdetail" value="" />
|
'.sequence'; |
<span class="LC_nobreak">
|
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
<input name="newpage" type="button"
|
'.page'; |
onClick="javascript:makenewpage(this.form,'$pageseq');"
|
my $container='sequence'; |
value="$lt{'newp'}" />$help{'Adding_Pages'}
|
if ($env{'form.pagepath'}) { |
</span>
|
$container='page'; |
</form>
|
} |
NPFORM
|
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; |
|
|
my $newfolderform=(<<NFFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newfolder">
|
|
<input type="hidden" name="folderpath" value="$path" />
|
my $recoverform=(<<RFORM); |
<input type="hidden" name="importdetail" value="" />
|
<form action="/adm/groupsort" method="post" name="recover"> |
<span class="LC_nobreak">
|
<a class="LC_menubuttons_link" href="javascript:groupopen('$readfile',1)">$lt{'reco'}</a> |
<input name="newfolder" type="button"
|
</form> |
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
RFORM |
value="$lt{'newf'}" />$help{'Adding_Folders'}
|
|
</span>
|
my $imspform=(<<IMSPFORM); |
</form>
|
<form action="/adm/imsimportdocs" method="post" name="ims"> |
NFFORM
|
<input type="hidden" name="folder" value="$folder" /> |
|
<a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a> |
my $newsylform=(<<NSYLFORM);
|
</form> |
<form action="/adm/coursedocs" method="post" name="newsyl">
|
IMSPFORM |
$uploadtag
|
|
<input type="hidden" name="importdetail"
|
my $newnavform=(<<NNFORM); |
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
|
<form action="/adm/coursedocs" method="post" name="newnav"> |
<span class="LC_nobreak">
|
<input type="hidden" name="active" value="cc" /> |
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
$uploadtag |
$help{'Syllabus'}
|
<input type="hidden" name="importdetail" |
</span>
|
value="$lt{'navc'}=/adm/navmaps" /> |
</form>
|
<a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a> |
NSYLFORM
|
$help{'Navigate_Content'} |
|
</form> |
my $newgroupfileform=(<<NGFFORM);
|
NNFORM |
<form action="/adm/coursedocs" method="post" name="newgroupfiles">
|
my $newsmppageform=(<<NSPFORM); |
$uploadtag
|
<form action="/adm/coursedocs" method="post" name="newsmppg"> |
<input type="hidden" name="importdetail"
|
<input type="hidden" name="active" value="cc" /> |
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
|
$uploadtag |
<span class="LC_nobreak">
|
<input type="hidden" name="importdetail" value="" /> |
<input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
|
<a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a> |
$help{'Group Files'}
|
$help{'Simple Page'} |
</span>
|
</form> |
</form>
|
NSPFORM |
NGFFORM
|
|
|
my $newsmpproblemform=(<<NSPROBFORM); |
|
<form action="/adm/coursedocs" method="post" name="newsmpproblem"> |
$r->print(<<ENDFORM);
|
<input type="hidden" name="active" value="cc" /> |
<br />
|
$uploadtag |
$newfolderform
|
<input type="hidden" name="importdetail" value="" /> |
<br />
|
<a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a> |
$newpageform
|
$help{'Simple Problem'} |
<br />
|
</form> |
$newsylform
|
|
<br />
|
NSPROBFORM |
$newnavform
|
|
<br />
|
my $newdropboxform=(<<NDBFORM); |
$newsmppageform
|
<form action="/adm/coursedocs" method="post" name="newdropbox"> |
<br />
|
<input type="hidden" name="active" value="cc" /> |
$newsmpproblemform
|
$uploadtag |
<br />
|
<input type="hidden" name="importdetail" value="" /> |
$newdropboxform
|
<a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a> |
<br />
|
</form> |
$newexuploadform
|
NDBFORM |
<br />
|
|
$newbulform
|
my $newexuploadform=(<<NEXUFORM); |
<br />
|
<form action="/adm/coursedocs" method="post" name="newexamupload"> |
$newaboutmeform
|
<input type="hidden" name="active" value="cc" /> |
<br />
|
$uploadtag |
$newaboutsomeoneform
|
<input type="hidden" name="importdetail" value="" /> |
<br />
|
<a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a> |
$newgroupfileform
|
$help{'Score_Upload_Form'} |
<br />
|
</form> |
$newrosterform
|
NEXUFORM |
ENDFORM
|
|
}
|
my $newbulform=(<<NBFORM); |
if ($env{'form.pagepath'}) {
|
<form action="/adm/coursedocs" method="post" name="newbul"> |
$r->print(<<ENDBLOCK);
|
<input type="hidden" name="active" value="cc" /> |
$newsmpproblemform
|
$uploadtag |
<br />
|
<input type="hidden" name="importdetail" value="" /> |
$newexuploadform
|
<a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a> |
ENDBLOCK
|
$help{'Bulletin Board'} |
}
|
</form> |
$r->print('</td></tr>'."\n".
|
NBFORM |
'</table>');
|
|
$r->print('</td></tr>');
|
my $newaboutmeform=(<<NAMFORM); |
}
|
<form action="/adm/coursedocs" method="post" name="newaboutme"> |
# ----------------------------------------------------- Supplemental documents
|
<input type="hidden" name="active" value="cc" /> |
if (!$forcestandard) {
|
$uploadtag |
$r->print('<tr><td class="LC_docs_document">');
|
<input type="hidden" name="importdetail" |
# '<h2>'.&mt('Supplemental Course Documents').
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
# ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
|
<a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a> |
my $folder=$env{'form.folder'};
|
$help{'My Personal Information Page'} |
unless ($folder=~/^supplemental/) {
|
</form> |
$folder='supplemental';
|
NAMFORM |
}
|
|
if ($folder =~ /^supplemental$/ &&
|
my $newaboutsomeoneform=(<<NASOFORM); |
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
|
<form action="/adm/coursedocs" method="post" name="newaboutsomeone"> |
$env{'form.folderpath'} = 'supplemental&'.
|
<input type="hidden" name="active" value="cc" /> |
&escape(&mt('Supplemental '.$type.' Documents'));
|
$uploadtag |
}
|
<input type="hidden" name="importdetail" value="" /> |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
|
<a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a> |
if ($error) {
|
</form> |
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
NASOFORM |
}
|
|
if ($allowed) {
|
|
my $folderseq=
|
my $newrosterform=(<<NROSTFORM); |
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
|
<form action="/adm/coursedocs" method="post" name="newroster"> |
'.sequence';
|
<input type="hidden" name="active" value="cc" /> |
|
$uploadtag |
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
<input type="hidden" name="importdetail" |
|
value="$lt{'rost'}=/adm/viewclasslist" /> |
my $supupdocform=(<<SUPDOCFORM);
|
<a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a> |
<form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
$help{'Course Roster'} |
$fileupload
|
</form> |
<br />
|
NROSTFORM |
<br />
|
|
<span class="LC_nobreak">
|
my $specialdocumentsform; |
$checkbox
|
my @specialdocumentsforma; |
</span>
|
my $gradingform; |
<br /><br />
|
my @gradingforma; |
$lt{'comment'}:<br />
|
my $communityform; |
<textarea cols=50 rows=4 name='comment'>
|
my @communityforma; |
</textarea>
|
my $newfolderform; |
<br />
|
my $newfolderb; |
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="cmd" value="upload_supplemental" />
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
<span class="LC_nobreak">
|
|
<input type="submit" value="$lt{'upld'}" />
|
my $newpageform=(<<NPFORM); |
$help{'Uploading_From_Harddrive'}
|
<form action="/adm/coursedocs" method="post" name="newpage"> |
</span>
|
<input type="hidden" name="folderpath" value="$path" /> |
</form>
|
<input type="hidden" name="importdetail" value="" /> |
SUPDOCFORM
|
<input type="hidden" name="active" value="cc" /> |
|
<a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a> |
my $supnewfolderform=(<<SNFFORM);
|
$help{'Adding_Pages'} |
<form action="/adm/coursedocs" method="post" name="supnewfolder">
|
</form> |
<input type="hidden" name="folderpath" value="$path" />
|
NPFORM |
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
|
<input name="newfolder" type="button"
|
$newfolderform=(<<NFFORM); |
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
<form action="/adm/coursedocs" method="post" name="newfolder"> |
value="$lt{'newf'}" /> $help{'Adding_Folders'}
|
<input type="hidden" name="folderpath" value="$path" /> |
</span>
|
<input type="hidden" name="importdetail" value="" /> |
</form>
|
<input type="hidden" name="active" value="aa" /> |
SNFFORM
|
<a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'} |
|
</form> |
|
NFFORM |
my $supnewextform=(<<SNEFORM);
|
|
<form action="/adm/coursedocs" method="post" name="supnewext">
|
my $newsylform=(<<NSYLFORM); |
<input type="hidden" name="folderpath" value="$path" />
|
<form action="/adm/coursedocs" method="post" name="newsyl"> |
<input type="hidden" name="importdetail" value="" />
|
<input type="hidden" name="active" value="cc" /> |
<span class="LC_nobreak">
|
$uploadtag |
<input name="newext" type="button"
|
<input type="hidden" name="importdetail" |
onClick="javascript:makenewext('supnewext');"
|
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" /> |
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
<a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a> |
</span>
|
$help{'Syllabus'} |
</form>
|
|
SNEFORM
|
</form> |
|
NSYLFORM |
my $supnewsylform=(<<SNSFORM);
|
|
<form action="/adm/coursedocs" method="post" name="supnewsyl">
|
my $newgroupfileform=(<<NGFFORM); |
<input type="hidden" name="folderpath" value="$path" />
|
<form action="/adm/coursedocs" method="post" name="newgroupfiles"> |
<input type="hidden" name="importdetail"
|
<input type="hidden" name="active" value="cc" /> |
value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
|
$uploadtag |
<span class="LC_nobreak">
|
<input type="hidden" name="importdetail" |
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" /> |
$help{'Syllabus'}
|
<a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a> |
</span>
|
$help{'Group Portfolio'} |
</form>
|
</form> |
SNSFORM
|
NGFFORM |
|
@specialdocumentsforma=( |
my $supnewaboutmeform=(<<SNAMFORM);
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform}, |
<form action="/adm/coursedocs" method="post" name="subnewaboutme">
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform}, |
<input type="hidden" name="folderpath" value="$path" />
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform}, |
<input type="hidden" name="importdetail"
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform}, |
value="$plainname=/adm/$udom/$uname/aboutme" />
|
); |
<span class="LC_nobreak">
|
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma)); |
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
|
$help{'My Personal Info'}
|
|
</span>
|
my @importdoc = ( |
</form>
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform}, |
SNAMFORM
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},); |
|
$fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr/>' . $fileuploadform; |
$r->print(<<ENDSUPFORM);
|
|
<ul class="LC_TabContent">
|
@gradingforma=( |
<li>$lt{'nd'}</li>
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
<li>$lt{'sd'}</li>
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform}, |
<li>$lt{'hao'}</li>
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform}, |
</ul>
|
|
<table class="LC_docs_adddocs">
|
); |
<tr><td>
|
$gradingform = &create_form_ul(&create_list_elements(@gradingforma)); |
$supupdocform
|
|
</td>
|
@communityforma=( |
<td>
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform}, |
$supnewfolderform
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform}, |
<br />
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform}, |
$supnewextform
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform}, |
<br />
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform}, |
$supnewsylform
|
); |
<br />
|
$communityform = &create_form_ul(&create_list_elements(@communityforma)); |
$supnewaboutmeform
|
|
</td></tr>
|
|
</table></td></tr>
|
|
ENDSUPFORM
|
my @tools = ( |
}
|
# {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" />'=>$extresourcesform}, |
}
|
# {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" />'=>$imspform}, |
$r->print('</table>');
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/recover.png" alt="'.$lt{reco}.'" onclick="javascript:groupopen(\''.$readfile.'\',1)" />'=>$recoverform}, |
if ($allowed) {
|
); |
$r->print('
|
|
<form method="post" name="extimport" action="/adm/coursedocs">
|
my %orderhash = ( |
<input type="hidden" name="title" />
|
'aa' => ['Import Documents',$fileuploadform], |
<input type="hidden" name="url" />
|
'bb' => ['Published Resources',$simpleeditdefaultform], |
<input type="hidden" name="useform" />
|
'cc' => ['Grading Resources',$gradingform], |
<input type="hidden" name="residx" />
|
'ff' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)], |
</form>');
|
); |
}
|
unless ($env{'form.pagepath'}) { |
} else {
|
$orderhash{'00'} = ['Newfolder',$newfolderform]; |
unless ($upload_result eq 'phasetwo') {
|
$orderhash{'dd'} = ['Community Resources',$communityform]; |
# -------------------------------------------------------- This is showdoc mode
|
$orderhash{'ee'} = ['Special Documents',$specialdocumentsform]; |
$r->print("<h1>".&mt('Uploaded Document').' - '.
|
} |
&Apache::lonnet::gettitle($r->uri).'</h1><p>'.
|
|
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
|
$hadchanges=0; |
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
|
unless ($supplementalflag) { |
}
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); |
}
|
if ($error) { |
}
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
$r->print(&Apache::loncommon::end_page());
|
} |
return OK;
|
if ($hadchanges) { |
}
|
&mark_hash_old(); |
|
} |
sub generate_admin_options {
|
|
my ($containertag,$uploadtag,$lt_ref,$help_ref,$env_ref) = @_;
|
&changewarning($r,''); |
my %lt = %{$lt_ref};
|
$r->print(&generate_edit_table('1',\%orderhash)); |
my %help = %{$help_ref};
|
} |
my %env = %{$env_ref};
|
|
my $dumpbut=&dumpbutton();
|
} |
my $exportbut=&exportbutton();
|
|
return (<<ENDOPTIONFORM);
|
# Supplemental documents start here |
<form name="renameform" method="post" action="/adm/coursedocs">
|
|
<input type="hidden" name="title" />
|
my $folder=$env{'form.folder'}; |
<input type="hidden" name="cmd" />
|
unless ($supplementalflag) { |
<input type="hidden" name="markcopy" />
|
$folder='supplemental'; |
<input type="hidden" name="copyfolder" />
|
} |
$containertag
|
if ($folder =~ /^supplemental$/ && |
</form>
|
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) { |
<form name="simpleedit" method="post" action="/adm/coursedocs">
|
$env{'form.folderpath'} = &supplemental_base(); |
<input type="hidden" name="importdetail" value="" />
|
} elsif ($allowed) { |
$uploadtag
|
$env{'form.folderpath'} = $savefolderpath; |
</form>
|
} |
<form action="/adm/coursedocs" method="post" name="courseverify">
|
$env{'form.pagepath'} = ''; |
<ul style="list-style-type:none">
|
if ($allowed) { |
<li>
|
my $folderseq= |
<input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
|
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. |
</li>
|
'.sequence'; |
<li>
|
|
<input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
</li>
|
|
<li>
|
my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}"; |
$dumpbut
|
my $supupdocform=(<<SUPDOCFORM); |
</li>
|
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> |
<li>
|
<input type="hidden" name="active" value="ee" /> |
$exportbut
|
$fileupload |
</li>
|
<br /> |
<li>
|
<br /> |
<input type="submit" name="listsymbs" value="$lt{'ls'}" />
|
<span class="LC_nobreak"> |
</li>
|
$checkbox |
<li>
|
</span> |
<input type="hidden" name="folder" value="$env{'form.folder'}" />
|
<br /><br /> |
<input type="submit" name="docslog" value="$lt{'sl'}" />
|
$lt{'comment'}:<br /> |
</li>
|
<textarea cols="50" rows="4" name="comment"></textarea> |
</ul>
|
<br /> |
</form>
|
<input type="hidden" name="folderpath" value="$path" /> |
<div style="clear: both; height: 0px;"> </div>
|
<input type="hidden" name="cmd" value="upload_supplemental" /> |
ENDOPTIONFORM
|
SUPDOCFORM |
}
|
$supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>"; |
|
|
sub generate_edit_table {
|
my $supnewfolderform=(<<SNFFORM); |
my ($optionhash_ref,$namehash_ref,$orderhash_ref) = @_;
|
<form action="/adm/coursedocs" method="post" name="supnewfolder"> |
my %optionhash = %{$optionhash_ref}; #id verlinkt mit inhalt
|
<input type="hidden" name="active" value="ee" /> |
my %namehash = %{$namehash_ref}; #name verlinkt mit id
|
<input type="hidden" name="folderpath" value="$path" /> |
my %orderhash = %{$orderhash_ref}; #name mit kürzel verlinkt mit name
|
<input type="hidden" name="importdetail" value="" /> |
my $form;
|
<a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> |
$form = '<div class="LC_ContentBoxSpecial"><h4 class="LC_hcell">'.&mt('Upload Course Documents').'<h4>';
|
$help{'Adding_Folders'} |
$form .= '<ul class="LC_TabContent">';
|
</form> |
foreach my $name (sort(keys(%orderhash))){
|
SNFFORM |
if($name eq 'zz_hide'){
|
|
$form .= '<li><a onclick="hideAllSection();" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
|
}else{
|
my $supnewextform=(<<SNEFORM); |
$form .= '<li><a onclick="popUpSection(\''.$namehash{$orderhash{$name}}.'\');" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
<form action="/adm/coursedocs" method="post" name="supnewext"> |
}
|
<input type="hidden" name="active" value="ff" /> |
}
|
<input type="hidden" name="folderpath" value="$path" /> |
foreach my $field (keys(%optionhash)){
|
<input type="hidden" name="importdetail" value="" /> |
$form .= '<div id="'.$field.'" class="LC_ContentBox LC_hideThis">'.$optionhash{$field}.'</div>';
|
<a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'} |
}
|
</form> |
$form .= '</div>';
|
SNEFORM |
return $form;
|
|
}
|
my $supnewsylform=(<<SNSFORM); |
|
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
sub editing_js {
|
<input type="hidden" name="active" value="ff" /> |
my ($udom,$uname) = @_;
|
<input type="hidden" name="folderpath" value="$path" /> |
my $now = time();
|
<input type="hidden" name="importdetail" |
my %lt = &Apache::lonlocal::texthash(
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus" /> |
p_mnf => 'Name of New Folder',
|
<a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a> |
t_mnf => 'New Folder',
|
$help{'Syllabus'} |
p_mnp => 'Name of New Page',
|
</form> |
t_mnp => 'New Page',
|
SNSFORM |
p_mxu => 'Title for the Uploaded Score',
|
|
p_msp => 'Title for the Page',
|
my $supnewaboutmeform=(<<SNAMFORM); |
p_msb => 'Title for the Problem',
|
<form action="/adm/coursedocs" method="post" name="supnewaboutme"> |
p_mdb => 'Title for the Drop Box',
|
<input type="hidden" name="active" value="ff" /> |
p_mbb => 'Title for the Bulletin Board',
|
<input type="hidden" name="folderpath" value="$path" /> |
p_mab => "Enter user:domain for User's 'About Me' Page",
|
<input type="hidden" name="importdetail" |
p_mab2 => "About [_99]",
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
p_mab_alrt1 => 'Not a valid user:domain',
|
<a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a> |
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
|
$help{'My Personal Information Page'} |
p_chn => 'New Title',
|
</form> |
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
|
SNAMFORM |
p_rmr2a => 'Remove[_99]',
|
|
p_rmr2b => '?[_99]',
|
|
p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
|
my @specialdocs = ( |
p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />' |
p_ctr2a => 'Cut[_98]',
|
=>$supnewsylform}, |
p_ctr2b => '?[_98]'
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />' |
);
|
=>$supnewaboutmeform}, |
|
); |
return <<ENDNEWSCRIPT;
|
my @supimportdoc = ( |
function makenewfolder(targetform,folderseq) {
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />' |
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
|
=>$supnewextform}, |
if (foldername) {
|
); |
targetform.importdetail.value=escape(foldername)+"="+folderseq;
|
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr/>' . $supupdocform; |
targetform.submit();
|
my %suporderhash = ( |
}
|
'00' => ['Supnewfolder', $supnewfolderform], |
}
|
'ee' => ['Import Documents',$supupdocform], |
|
'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))] |
function makenewpage(targetform,folderseq) {
|
); |
var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
|
if ($supplementalflag) { |
if (pagename) {
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); |
targetform.importdetail.value=escape(pagename)+"="+folderseq;
|
if ($error) { |
targetform.submit();
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
}
|
} |
}
|
$r->print(&generate_edit_table('2',\%suporderhash)); |
|
} |
function makenewext(targetname) {
|
} elsif ($supplementalflag) { |
this.document.forms.extimport.useform.value=targetname;
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype); |
this.document.forms.extimport.title.value='';
|
if ($error) { |
this.document.forms.extimport.url.value='';
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
this.document.forms.extimport.residx.value='';
|
} |
window.open('/adm/rat/extpickframe.html');
|
} |
}
|
|
|
&endContentScreen($r); |
function edittext(targetname,residx,title,url) {
|
|
this.document.forms.extimport.useform.value=targetname;
|
if ($allowed) { |
this.document.forms.extimport.residx.value=residx;
|
$r->print(' |
this.document.forms.extimport.url.value=url;
|
<form method="post" name="extimport" action="/adm/coursedocs"> |
this.document.forms.extimport.title.value=title;
|
<input type="hidden" name="title" /> |
window.open('/adm/rat/extpickframe.html');
|
<input type="hidden" name="url" /> |
}
|
<input type="hidden" name="useform" /> |
|
<input type="hidden" name="residx" /> |
function makeexamupload() {
|
</form>'); |
var title=prompt('$lt{"p_mxu"}');
|
} |
if (title) {
|
} else { |
this.document.forms.newexamupload.importdetail.value=
|
unless ($uploadphase) { |
escape(title)+'=/res/lib/templates/examupload.problem';
|
# -------------------------------------------------------- This is showdoc mode |
this.document.forms.newexamupload.submit();
|
$r->print("<h1>".&mt('Uploaded Document').' - '. |
}
|
&Apache::lonnet::gettitle($r->uri).'</h1><p>'. |
}
|
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>". |
|
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
function makesmppage() {
|
} |
var title=prompt('$lt{"p_msp"}');
|
} |
if (title) {
|
} |
this.document.forms.newsmppg.importdetail.value=
|
$r->print(&Apache::loncommon::end_page()); |
escape(title)+'=/adm/$udom/$uname/$now/smppg';
|
return OK; |
this.document.forms.newsmppg.submit();
|
} |
}
|
|
}
|
sub embedded_form_elems { |
|
my ($phase,$primaryurl,$newidx) = @_; |
function makesmpproblem() {
|
my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
var title=prompt('$lt{"p_msb"}');
|
return <<STATE; |
if (title) {
|
<input type="hidden" name="folderpath" value="$folderpath" /> |
this.document.forms.newsmpproblem.importdetail.value=
|
<input type="hidden" name="cmd" value="upload_embedded" /> |
escape(title)+'=/res/lib/templates/simpleproblem.problem';
|
<input type="hidden" name="newidx" value="$newidx" /> |
this.document.forms.newsmpproblem.submit();
|
<input type="hidden" name="phase" value="$phase" /> |
}
|
<input type="hidden" name="primaryurl" value="$primaryurl" /> |
}
|
STATE |
|
} |
function makedropbox() {
|
|
var title=prompt('$lt{"p_mdb"}');
|
sub embedded_destination { |
if (title) {
|
my $folder=$env{'form.folder'}; |
this.document.forms.newdropbox.importdetail.value=
|
my $destination = 'docs/'; |
escape(title)+'=/res/lib/templates/DropBox.problem';
|
if ($folder =~ /^supplemental/) { |
this.document.forms.newdropbox.submit();
|
$destination = 'supplemental/'; |
}
|
} |
}
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
|
$destination .= 'default/'; |
function makebulboard() {
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
var title=prompt('$lt{"p_mbb"}');
|
$destination .= $2.'/'; |
if (title) {
|
} |
this.document.forms.newbul.importdetail.value=
|
$destination .= $env{'form.newidx'}; |
escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
|
my $dir_root = '/userfiles'; |
this.document.forms.newbul.submit();
|
return ($destination,$dir_root); |
}
|
} |
}
|
|
|
sub return_to_editor { |
function makeabout() {
|
my $actionurl = '/adm/coursedocs'; |
var user=prompt("$lt{'p_mab'}");
|
return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n". |
if (user) {
|
'<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n". |
var comp=new Array();
|
'<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor'). |
comp=user.split(':');
|
'</a></p>'; |
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
|
} |
if ((comp[0]) && (comp[1])) {
|
|
this.document.forms.newaboutsomeone.importdetail.value=
|
sub generate_admin_options { |
'$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
|
my ($help_ref,$env_ref) = @_; |
this.document.forms.newaboutsomeone.submit();
|
my %lt=&Apache::lonlocal::texthash( |
} else {
|
'vc' => 'Verify Content', |
alert("$lt{'p_mab_alrt1'}");
|
'cv' => 'Check/Set Resource Versions', |
}
|
'ls' => 'List Symbs', |
} else {
|
'sl' => 'Show Log', |
alert("$lt{'p_mab_alrt2'}");
|
'imse' => 'IMS Export', |
}
|
'dcd' => 'Dump Course Documents to Construction Space: available on other servers' |
}
|
); |
}
|
my %help = %{$help_ref}; |
|
my %env = %{$env_ref}; |
function makeims() {
|
my $dumpbut=&dumpbutton(); |
var caller = document.forms.ims.folder.value;
|
my $exportbut=&exportbutton(); |
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
|
my @list = ( |
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/verify.png" alt="'.$lt{vc}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "verify", "'.$lt{'vc'}.'")\' />' |
newWindow.location.href = newlocation;
|
=> "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"verify\", \"$lt{'vc'}\")'>$lt{'vc'}</a>$help{'Verify_Content'}"}, |
}
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/resversion.png" alt="'.$lt{cv}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "versions", "'.$lt{'cv'}.'")\' />' |
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"versions\", \"$lt{'cv'}\")'>$lt{'cv'}</a>$help{'Check_Resource_Versions'}"}, |
|
); |
function finishpick() {
|
if($dumpbut ne ''){ |
var title=this.document.forms.extimport.title.value;
|
push @list, {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dump.png" alt="'.$lt{dcd}.'" />'=>$dumpbut}; |
var url=this.document.forms.extimport.url.value;
|
} |
var form=this.document.forms.extimport.useform.value;
|
push @list, ({'<img class="LC_noBorder LC_middle" src="/res/adm/pages/imsexport.png" alt="'.$lt{imse}.'" onclick="javascript:injectData(document.courseverify, \'dummy\', \'exportcourse\', \''.&mt('IMS Export').'\');" />' |
var residx=this.document.forms.extimport.residx.value;
|
=>$exportbut}, |
eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/symbs.png" alt="'.$lt{ls}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "listsymbs", "'.$lt{'ls'}.'")\' />' |
}
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"listsymbs\", \"$lt{'ls'}\")'>$lt{'ls'}</a><input type='hidden' name='folder' value='$env{'form.folder'}' />"}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/document-properties.png" alt="'.$lt{sl}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "docslog", "'.$lt{'sl'}.'")\' />' |
function changename(folderpath,index,oldtitle,container,pagesymb) {
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"docslog\", \"$lt{'sl'}\")'>$lt{'sl'}</a>"}, |
var title=prompt('$lt{"p_chn"}',oldtitle);
|
); |
if (title) {
|
return '<form action="/adm/coursedocs" method="post" name="courseverify"><input type="hidden" id="dummy" />'.&create_form_ul(&create_list_elements(@list)).'</form>'; |
this.document.forms.renameform.markcopy.value=-1;
|
|
this.document.forms.renameform.title.value=title;
|
} |
this.document.forms.renameform.cmd.value='rename_'+index;
|
|
if (container == 'sequence') {
|
|
this.document.forms.renameform.folderpath.value=folderpath;
|
sub generate_edit_table { |
}
|
my ($tid,$orderhash_ref) = @_; |
if (container == 'page') {
|
return unless(ref($orderhash_ref) eq 'HASH'); |
this.document.forms.renameform.pagepath.value=folderpath;
|
my %orderhash = %{$orderhash_ref}; |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
my $form; |
}
|
my $activetab; |
this.document.forms.renameform.submit();
|
my $active; |
}
|
if($env{'form.active'} ne ''){ |
}
|
$activetab = $env{'form.active'}; |
|
} |
function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
|
$form = '<div class="LC_Box" style="margin-right:0">'; |
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
|
$form .= '<ul id="navigation'.$tid.'" class="LC_TabContent">'; |
this.document.forms.renameform.markcopy.value=-1;
|
foreach my $name (sort(keys(%orderhash))){ |
this.document.forms.renameform.cmd.value='del_'+index;
|
if($name ne '00'){ |
if (container == 'sequence') {
|
if($activetab eq '' || $activetab ne $name){ |
this.document.forms.renameform.folderpath.value=folderpath;
|
$active = ''; |
}
|
}elsif($activetab eq $name){ |
if (container == 'page') {
|
$active = 'class="active"'; |
this.document.forms.renameform.pagepath.value=folderpath;
|
} |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
$form .= '<li '.$active |
}
|
.' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"' |
this.document.forms.renameform.submit();
|
.' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'; |
}
|
} else { |
}
|
$form .= '<li '.$active.'>'.${$orderhash{$name}}[1].'</li>'; |
|
|
function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
|
} |
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
|
} |
this.document.forms.renameform.cmd.value='cut_'+index;
|
$form .= '</ul>'; |
this.document.forms.renameform.markcopy.value=index;
|
$form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; clear: both;">'; |
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
foreach my $field (keys(%orderhash)){ |
if (container == 'sequence') {
|
if($field ne '00'){ |
this.document.forms.renameform.folderpath.value=folderpath;
|
if($activetab eq '' || $activetab ne $field){ |
}
|
$active = 'style="display: none;"'; |
if (container == 'page') {
|
}elsif($activetab eq $field){ |
this.document.forms.renameform.pagepath.value=folderpath;
|
$active = 'style="display:block;"'; |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
} |
}
|
$form .= '<div id="'.$field.$tid.'"' |
this.document.forms.renameform.submit();
|
.' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1] |
}
|
.'</div>'; |
}
|
} |
|
} |
function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
|
$form .= '</div></div>'; |
this.document.forms.renameform.markcopy.value=index;
|
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
return $form; |
if (container == 'sequence') {
|
} |
this.document.forms.renameform.folderpath.value=folderpath;
|
|
}
|
sub editing_js { |
if (container == 'page') {
|
my ($udom,$uname) = @_; |
this.document.forms.renameform.pagepath.value=folderpath;
|
my $now = time(); |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
my %lt = &Apache::lonlocal::texthash( |
}
|
p_mnf => 'Name of New Folder', |
this.document.forms.renameform.submit();
|
t_mnf => 'New Folder', |
}
|
p_mnp => 'Name of New Page', |
|
t_mnp => 'New Page', |
|
p_mxu => 'Title for the External Score', |
ENDNEWSCRIPT
|
p_msp => 'Name of Simple Course Page', |
}
|
p_msb => 'Title for the Problem', |
1;
|
p_mdb => 'Title for the Drop Box', |
__END__
|
p_mbb => 'Title for the Discussion Board', |
|
p_mab => "Enter user:domain for User's Personal Information Page", |
|
p_mab2 => 'Personal Information Page of ', |
=head1 NAME
|
p_mab_alrt1 => 'Not a valid user:domain', |
|
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain', |
Apache::londocs.pm
|
p_chn => 'New Title', |
|
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!', |
=head1 SYNOPSIS
|
p_rmr2a => 'Remove[_99]', |
|
p_rmr2b => '?[_99]', |
This is part of the LearningOnline Network with CAPA project
|
p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!', |
described at http://www.lon-capa.org.
|
p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.', |
|
p_ctr2a => 'Cut[_98]', |
=head1 SUBROUTINES
|
p_ctr2b => '?[_98]' |
|
); |
=over
|
|
|
my $crstype = &Apache::loncommon::course_type(); |
=item %help=()
|
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
|
my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"'); |
Available help topics
|
my $main_container_page; |
|
if ($docs_folderpath eq '') { |
=item mapread()
|
if ($docs_pagepath ne '') { |
|
$main_container_page = 1; |
Mapread read maps into LONCAPA::map:: global arrays
|
} |
@order and @resources, determines status
|
} |
sets @order - pointer to resources in right order
|
my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents'; |
sets @resources - array with the resources with correct idx
|
my $toplevelsupp = &supplemental_base(); |
|
|
=item authorhosts()
|
return <<ENDNEWSCRIPT; |
|
function makenewfolder(targetform,folderseq) { |
Return hash with valid author names
|
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}'); |
|
if (foldername) { |
=item dumpbutton()
|
targetform.importdetail.value=escape(foldername)+"="+folderseq; |
|
targetform.submit(); |
Generate "dump" button
|
} |
|
} |
=item clean()
|
|
|
function makenewpage(targetform,folderseq) { |
=item dumpcourse()
|
var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}'); |
|
if (pagename) { |
Actually dump course
|
targetform.importdetail.value=escape(pagename)+"="+folderseq; |
|
targetform.submit(); |
|
} |
=item exportbutton()
|
} |
|
|
Generate "export" button
|
function makenewext(targetname) { |
|
this.document.forms.extimport.useform.value=targetname; |
=item exportcourse()
|
this.document.forms.extimport.title.value=''; |
|
this.document.forms.extimport.url.value=''; |
=item create_ims_store()
|
this.document.forms.extimport.residx.value=''; |
|
window.open('/adm/rat/extpickframe.html'); |
=item build_package()
|
} |
|
|
=item get_dependencies()
|
function edittext(targetname,residx,title,url) { |
|
this.document.forms.extimport.useform.value=targetname; |
=item process_content()
|
this.document.forms.extimport.residx.value=residx; |
|
this.document.forms.extimport.url.value=url; |
=item replicate_content()
|
this.document.forms.extimport.title.value=title; |
|
window.open('/adm/rat/extpickframe.html'); |
=item extract_media()
|
} |
|
|
=item store_template()
|
function makeexamupload() { |
|
var title=prompt('$lt{"p_mxu"}'); |
=item group_import()
|
if (title) { |
|
this.document.forms.newexamupload.importdetail.value= |
Imports the given (name, url) resources into the course
|
escape(title)+'=/res/lib/templates/examupload.problem'; |
coursenum, coursedom, and folder must precede the list
|
this.document.forms.newexamupload.submit(); |
|
} |
=item breadcrumbs()
|
} |
|
|
=item log_docs()
|
function makesmppage() { |
|
var title=prompt('$lt{"p_msp"}'); |
=item docs_change_log()
|
if (title) { |
|
this.document.forms.newsmppg.importdetail.value= |
=item update_paste_buffer()
|
escape(title)+'=/adm/$udom/$uname/$now/smppg'; |
|
this.document.forms.newsmppg.submit(); |
=item print_paste_buffer()
|
} |
|
} |
=item do_paste_from_buffer()
|
|
|
function makesmpproblem() { |
=item update_parameter()
|
var title=prompt('$lt{"p_msb"}'); |
|
if (title) { |
=item handle_edit_cmd()
|
this.document.forms.newsmpproblem.importdetail.value= |
|
escape(title)+'=/res/lib/templates/simpleproblem.problem'; |
=item editor()
|
this.document.forms.newsmpproblem.submit(); |
|
} |
=item process_file_upload()
|
} |
|
|
=item process_secondary_uploads()
|
function makedropbox() { |
|
var title=prompt('$lt{"p_mdb"}'); |
=item is_supplemental_title()
|
if (title) { |
|
this.document.forms.newdropbox.importdetail.value= |
=item parse_supplemental_title()
|
escape(title)+'=/res/lib/templates/DropBox.problem'; |
|
this.document.forms.newdropbox.submit(); |
=item entryline()
|
} |
|
} |
=item tiehash()
|
|
|
function makebulboard() { |
=item untiehash()
|
var title=prompt('$lt{"p_mbb"}'); |
|
if (title) { |
=item checkonthis()
|
this.document.forms.newbul.importdetail.value= |
|
escape(title)+'=/adm/$udom/$uname/$now/bulletinboard'; |
check on this
|
this.document.forms.newbul.submit(); |
|
} |
=item verifycontent()
|
} |
|
|
Verify Content
|
function makeabout() { |
|
var user=prompt("$lt{'p_mab'}"); |
=item devalidateversioncache() & checkversions()
|
if (user) { |
|
var comp=new Array(); |
Check Versions
|
comp=user.split(':'); |
|
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { |
=item mark_hash_old()
|
if ((comp[0]) && (comp[1])) { |
|
this.document.forms.newaboutsomeone.importdetail.value= |
=item is_hash_old()
|
'$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; |
|
this.document.forms.newaboutsomeone.submit(); |
=item changewarning()
|
} else { |
|
alert("$lt{'p_mab_alrt1'}"); |
=item init_breadcrumbs()
|
} |
|
} else { |
Breadcrumbs for special functions
|
alert("$lt{'p_mab_alrt2'}"); |
|
} |
=back
|
} |
|
} |
=cut
|
|
|
function makeims() { |
|
var caller = document.forms.ims.folder.value; |
|
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; |
|
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); |
|
newWindow.location.href = newlocation; |
|
} |
|
|
|
|
|
function finishpick() { |
|
var title=this.document.forms.extimport.title.value; |
|
var url=this.document.forms.extimport.url.value; |
|
var form=this.document.forms.extimport.useform.value; |
|
var residx=this.document.forms.extimport.residx.value; |
|
eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();'); |
|
} |
|
|
|
function changename(folderpath,index,oldtitle,container,pagesymb) { |
|
var title=prompt('$lt{"p_chn"}',oldtitle); |
|
if (title) { |
|
this.document.forms.renameform.markcopy.value=-1; |
|
this.document.forms.renameform.title.value=title; |
|
this.document.forms.renameform.cmd.value='rename_'+index; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) { |
|
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) { |
|
this.document.forms.renameform.markcopy.value=-1; |
|
this.document.forms.renameform.cmd.value='del_'+index; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) { |
|
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) { |
|
this.document.forms.renameform.cmd.value='cut_'+index; |
|
this.document.forms.renameform.markcopy.value=index; |
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) { |
|
this.document.forms.renameform.markcopy.value=index; |
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
|
|
function unselectInactive(nav) { |
|
currentNav = document.getElementById(nav); |
|
currentLis = currentNav.getElementsByTagName('LI'); |
|
for (i = 0; i < currentLis.length; i++) { |
|
if(currentLis[i].className == 'right active' || currentLis[i].className == 'right'){ |
|
currentLis[i].className = 'right'; |
|
}else{ |
|
currentLis[i].className = 'i'; |
|
} |
|
} |
|
} |
|
|
|
function hideAll(current, nav, data) { |
|
unselectInactive(nav); |
|
if(current.className == 'right'){ |
|
current.className = 'right active' |
|
}else{ |
|
current.className = 'active'; |
|
} |
|
currentData = document.getElementById(data); |
|
currentDivs = currentData.getElementsByTagName('DIV'); |
|
for (i = 0; i < currentDivs.length; i++) { |
|
if(currentDivs[i].className == 'LC_ContentBox'){ |
|
currentDivs[i].style.display = 'none'; |
|
} |
|
} |
|
} |
|
|
|
function openTabs(pageId) { |
|
tabnav = document.getElementById(pageId).getElementsByTagName('UL'); |
|
if(tabnav.length > 2 ){ |
|
currentNav = document.getElementById(tabnav[1].id); |
|
currentLis = currentNav.getElementsByTagName('LI'); |
|
for(i = 0; i< currentLis.length; i++){ |
|
if(currentLis[i].className == 'active') { |
|
funcString = currentLis[i].onclick.toString(); |
|
tab = funcString.split('"'); |
|
if(tab.length < 2) { |
|
tab = funcString.split("'"); |
|
} |
|
currentData = document.getElementById(tab[1]); |
|
currentData.style.display = 'block'; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function showPage(current, pageId, nav, data) { |
|
hideAll(current, nav, data); |
|
openTabs(pageId); |
|
unselectInactive(nav); |
|
current.className = 'active'; |
|
currentData = document.getElementById(pageId); |
|
currentData.style.display = 'block'; |
|
if (nav == 'mainnav') { |
|
var storedpath = "$docs_folderpath"; |
|
if (storedpath == '') { |
|
storedpath = "$docs_pagepath"; |
|
} |
|
var storedpage = "$main_container_page"; |
|
var reg = new RegExp("^supplemental"); |
|
if (pageId == 'mainCourseDocuments') { |
|
if (storedpage == 1) { |
|
document.simpleedit.folderpath.value = ''; |
|
document.uploaddocument.folderpath.value = ''; |
|
} else { |
|
if (reg.test(storedpath)) { |
|
document.simpleedit.folderpath.value = '$toplevelmain'; |
|
document.uploaddocument.folderpath.value = '$toplevelmain'; |
|
document.newext.folderpath.value = '$toplevelmain'; |
|
} else { |
|
document.simpleedit.folderpath.value = storedpath; |
|
document.uploaddocument.folderpath.value = storedpath; |
|
document.newext.folderpath.value = storedpath; |
|
} |
|
} |
|
} else { |
|
if (reg.test(storedpath)) { |
|
document.simpleedit.folderpath.value = storedpath; |
|
document.supuploaddocument.folderpath.value = storedpath; |
|
document.supnewext.folderpath.value = storedpath; |
|
} else { |
|
document.simpleedit.folderpath.value = '$toplevelsupp'; |
|
document.supuploaddocument.folderpath.value = '$toplevelsupp'; |
|
document.supnewext.folderpath.value = '$toplevelsupp'; |
|
} |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
function injectData(current, hiddenField, name, value) { |
|
currentElement = document.getElementById(hiddenField); |
|
currentElement.name = name; |
|
currentElement.value = value; |
|
current.submit(); |
|
} |
|
|
|
ENDNEWSCRIPT |
|
} |
|
1; |
|
__END__ |
|
|
|
|
|
=head1 NAME |
|
|
|
Apache::londocs.pm |
|
|
|
=head1 SYNOPSIS |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 SUBROUTINES |
|
|
|
=over |
|
|
|
=item %help=() |
|
|
|
Available help topics |
|
|
|
=item mapread() |
|
|
|
Mapread read maps into LONCAPA::map:: global arrays |
|
@order and @resources, determines status |
|
sets @order - pointer to resources in right order |
|
sets @resources - array with the resources with correct idx |
|
|
|
=item authorhosts() |
|
|
|
Return hash with valid author names |
|
|
|
=item dumpbutton() |
|
|
|
Generate "dump" button |
|
|
|
=item clean() |
|
|
|
=item dumpcourse() |
|
|
|
Actually dump course |
|
|
|
|
|
=item exportbutton() |
|
|
|
Generate "export" button |
|
|
|
=item exportcourse() |
|
|
|
=item create_ims_store() |
|
|
|
=item build_package() |
|
|
|
=item get_dependencies() |
|
|
|
=item process_content() |
|
|
|
=item replicate_content() |
|
|
|
=item extract_media() |
|
|
|
=item store_template() |
|
|
|
=item group_import() |
|
|
|
Imports the given (name, url) resources into the course |
|
coursenum, coursedom, and folder must precede the list |
|
|
|
=item breadcrumbs() |
|
|
|
=item log_docs() |
|
|
|
=item docs_change_log() |
|
|
|
=item update_paste_buffer() |
|
|
|
=item print_paste_buffer() |
|
|
|
=item do_paste_from_buffer() |
|
|
|
=item update_parameter() |
|
|
|
=item handle_edit_cmd() |
|
|
|
=item editor() |
|
|
|
=item process_file_upload() |
|
|
|
=item process_secondary_uploads() |
|
|
|
=item is_supplemental_title() |
|
|
|
=item parse_supplemental_title() |
|
|
|
=item entryline() |
|
|
|
=item tiehash() |
|
|
|
=item untiehash() |
|
|
|
=item checkonthis() |
|
|
|
check on this |
|
|
|
=item verifycontent() |
|
|
|
Verify Content |
|
|
|
=item devalidateversioncache() & checkversions() |
|
|
|
Check Versions |
|
|
|
=item mark_hash_old() |
|
|
|
=item is_hash_old() |
|
|
|
=item changewarning() |
|
|
|
=item init_breadcrumbs() |
|
|
|
Breadcrumbs for special functions |
|
|
|
=back |
|
|
|
=cut |