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