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