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