version 1.264, 2006/12/05 02:55:52
|
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 qw(:DEFAULT :match); |
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=~/^\/($match_domain)\/($match_username)$/); |
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/($match_domain)/($match_username)/(\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/($match_domain)/($match_username)/(\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/($match_domain)/($match_username)/(\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=~m{^http://} || $url=~m{^https://}) { $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;
|
'currentfolder' => $env{'form.folder'}); |
@oldorder=@LONCAPA::map::order;
|
if ($parmidx) { |
$parmidx=undef;
|
$storehash{'parameter_res'}=$oldresources[$parmidx]; |
%parmaction=();
|
foreach my $parm (keys %parmaction) { |
%parmvalue=();
|
$storehash{'parameter_action_'.$parm}=$parmaction{$parm}; |
$changedflag=0;
|
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm}; |
}
|
} |
|
} |
sub remember_parms {
|
my $maxidx=$#oldresources; |
my ($idx,$parameter,$action,$value)=@_;
|
if ($#LONCAPA::map::resources>$#oldresources) { |
$parmidx=$idx;
|
$maxidx=$#LONCAPA::map::resources; |
$parmaction{$parameter}=$action;
|
} |
$parmvalue{$parameter}=$value;
|
for (my $idx=0; $idx<=$maxidx; $idx++) { |
$changedflag=1;
|
if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) { |
}
|
$storehash{'before_resources_'.$idx}=$oldresources[$idx]; |
|
$storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx]; |
sub log_differences {
|
$changedflag=1; |
my ($plain)=@_;
|
} |
my %storehash=('folder' => $plain,
|
if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) { |
'currentfolder' => $env{'form.folder'});
|
$storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]]; |
if ($parmidx) {
|
$storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
$storehash{'parameter_res'}=$oldresources[$parmidx];
|
$changedflag=1; |
foreach my $parm (keys(%parmaction)) {
|
} |
$storehash{'parameter_action_'.$parm}=$parmaction{$parm};
|
} |
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
|
$storehash{'maxidx'}=$maxidx; |
}
|
if ($changedflag) { &log_docs(\%storehash); } |
}
|
} |
my $maxidx=$#oldresources;
|
} |
if ($#LONCAPA::map::resources>$#oldresources) {
|
|
$maxidx=$#LONCAPA::map::resources;
|
|
}
|
# |
for (my $idx=0; $idx<=$maxidx; $idx++) {
|
# Docs Change Log |
if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
|
# |
$storehash{'before_resources_'.$idx}=$oldresources[$idx];
|
sub docs_change_log { |
$storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
|
my ($r)=@_; |
$changedflag=1;
|
my $folder=$env{'form.folder'}; |
}
|
$r->print(&Apache::loncommon::start_page('Course Document Change Log')); |
if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log')); |
$storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
|
my %docslog=&Apache::lonnet::dump('nohist_docslog', |
$storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$changedflag=1;
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
}
|
|
}
|
if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); } |
$storehash{'maxidx'}=$maxidx;
|
|
if ($changedflag) { &log_docs(\%storehash); }
|
$r->print('<form action="/adm/coursedocs" method="post" name="docslog">'. |
}
|
'<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); |
sub docs_change_log {
|
if (!$env{'form.show'}) { $env{'form.show'}=10; } |
my ($r)=@_;
|
my %lt=('hiddenresource' => 'Resources hidden', |
my $folder=$env{'form.folder'};
|
'encrypturl' => 'URL hidden', |
$r->print(&Apache::loncommon::start_page('Course Document Change Log'));
|
'randompick' => 'Randomly pick', |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
|
'set' => 'set to', |
my %docslog=&Apache::lonnet::dump('nohist_docslog',
|
'del' => 'deleted'); |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
$r->print(&Apache::loncommon::display_filter(). |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
'<input type="hidden" name="folder" value="'.$folder.'" />'. |
|
'<input type="submit" value="'.&mt('Display').'" /></form>'); |
if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
|
$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>'. |
$r->print('<form action="/adm/coursedocs" method="post" name="docslog">'.
|
&mt('After').'</th>'. |
'<input type="hidden" name="docslog" value="1" />');
|
&Apache::loncommon::end_data_table_header_row()); |
|
my $shown=0; |
my %saveable_parameters = ('show' => 'scalar',);
|
foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) { |
&Apache::loncommon::store_course_settings('docs_log',
|
if ($env{'form.displayfilter'} eq 'currentfolder') { |
\%saveable_parameters);
|
if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; } |
&Apache::loncommon::restore_course_settings('docs_log',
|
} |
\%saveable_parameters);
|
my @changes=keys(%{$docslog{$id}{'logentry'}}); |
if (!$env{'form.show'}) { $env{'form.show'}=10; }
|
if ($env{'form.displayfilter'} eq 'containing') { |
my %lt=('hiddenresource' => 'Resources hidden',
|
my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'. |
'encrypturl' => 'URL hidden',
|
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'}); |
'randompick' => 'Randomly pick',
|
foreach my $key (@changes) { |
'randomorder' => 'Randomly ordered',
|
$wholeentry.=':'.$docslog{$id}{'logentry'}{$key}; |
'set' => 'set to',
|
} |
'del' => 'deleted');
|
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } |
$r->print(&Apache::loncommon::display_filter().
|
} |
'<input type="hidden" name="folder" value="'.$folder.'" />'.
|
my $count = 0; |
'<input type="submit" value="'.&mt('Display').'" /></form>');
|
my $time = |
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
|
&Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'}); |
'<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
|
my $plainname = |
&mt('After').'</th>'.
|
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'}, |
&Apache::loncommon::end_data_table_header_row());
|
$docslog{$id}{'exe_udom'}); |
my $shown=0;
|
my $about_me_link = |
foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
|
&Apache::loncommon::aboutmewrapper($plainname, |
if ($env{'form.displayfilter'} eq 'currentfolder') {
|
$docslog{$id}{'exe_uname'}, |
if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
|
$docslog{$id}{'exe_udom'}); |
}
|
my $send_msg_link=''; |
my @changes=keys(%{$docslog{$id}{'logentry'}});
|
if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'}) |
if ($env{'form.displayfilter'} eq 'containing') {
|
|| ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) { |
my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
|
$send_msg_link ='<br />'. |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
|
&Apache::loncommon::messagewrapper(&mt('Send message'), |
foreach my $key (@changes) {
|
$docslog{$id}{'exe_uname'}, |
$wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
|
$docslog{$id}{'exe_udom'}); |
}
|
} |
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
|
$r->print(&Apache::loncommon::start_data_table_row()); |
}
|
$r->print('<td>'.$time.'</td> |
my $count = 0;
|
<td>'.$about_me_link. |
my $time =
|
'<br /><tt>'.$docslog{$id}{'exe_uname'}. |
&Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
|
':'.$docslog{$id}{'exe_udom'}.'</tt>'. |
my $plainname =
|
$send_msg_link.'</td><td>'. |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
|
$docslog{$id}{'logentry'}{'folder'}.'</td><td>'); |
$docslog{$id}{'exe_udom'});
|
# Before |
my $about_me_link =
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
&Apache::loncommon::aboutmewrapper($plainname,
|
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0]; |
$docslog{$id}{'exe_uname'},
|
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0]; |
$docslog{$id}{'exe_udom'});
|
if ($oldname ne $newname) { |
my $send_msg_link='';
|
$r->print(&LONCAPA::map::qtescape($oldname)); |
if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
|
} |
|| ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
|
} |
$send_msg_link ='<br />'.
|
$r->print('<ul>'); |
&Apache::loncommon::messagewrapper(&mt('Send message'),
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
$docslog{$id}{'exe_uname'},
|
if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) { |
$docslog{$id}{'exe_udom'});
|
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>'); |
}
|
} |
$r->print(&Apache::loncommon::start_data_table_row());
|
} |
$r->print('<td>'.$time.'</td>
|
$r->print('</ul>'); |
<td>'.$about_me_link.
|
# After |
'<br /><tt>'.$docslog{$id}{'exe_uname'}.
|
$r->print('</td><td>'); |
':'.$docslog{$id}{'exe_udom'}.'</tt>'.
|
|
$send_msg_link.'</td><td>'.
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
$docslog{$id}{'logentry'}{'folder'}.'</td><td>');
|
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0]; |
# Before
|
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0]; |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
if ($oldname ne $newname) { |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
$r->print(&LONCAPA::map::qtescape($newname)); |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
} |
if ($oldname ne $newname) {
|
} |
$r->print(&LONCAPA::map::qtescape($oldname));
|
$r->print('<ul>'); |
}
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
}
|
if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) { |
$r->print('<ul>');
|
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>'); |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
} |
if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
|
} |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
|
$r->print('</ul>'); |
}
|
if ($docslog{$id}{'logentry'}{'parameter_res'}) { |
}
|
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>'); |
$r->print('</ul>');
|
foreach my $parameter ('randompick','hiddenresource','encrypturl') { |
# After
|
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) { |
$r->print('</td><td>');
|
$r->print('<li>'. |
|
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]', |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
$docslog{$id}{'logentry'}{'parameter_value_'.$parameter}) |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
.'</li>'); |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
} |
if ($oldname ne '' && $oldname ne $newname) {
|
} |
$r->print(&LONCAPA::map::qtescape($newname));
|
$r->print('</ul>'); |
}
|
} |
}
|
# End |
$r->print('<ul>');
|
$r->print('</td>'.&Apache::loncommon::end_data_table_row()); |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
$shown++; |
if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
|
if (!($env{'form.show'} eq &mt('all') |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
|
|| $shown<=$env{'form.show'})) { last; } |
}
|
} |
}
|
$r->print(&Apache::loncommon::end_data_table()); |
$r->print('</ul>');
|
$r->print(&Apache::loncommon::end_page()); |
if ($docslog{$id}{'logentry'}{'parameter_res'}) {
|
} |
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
|
|
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
|
sub editor { |
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
|
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output)=@_; |
$r->print('<li>'.
|
my $errtext=''; |
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
|
my $fatal=0; |
$docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
|
my $container='sequence'; |
.'</li>');
|
if ($env{'form.pagepath'}) { |
}
|
$container='page'; |
}
|
} |
$r->print('</ul>');
|
($errtext,$fatal)= |
}
|
&mapread($coursenum,$coursedom,$folder.'.'.$container); |
# End
|
if ($#LONCAPA::map::order<1) { |
$r->print('</td>'.&Apache::loncommon::end_data_table_row());
|
my $idx=&LONCAPA::map::getresidx(); |
$shown++;
|
if ($idx<=0) { $idx=1; } |
if (!($env{'form.show'} eq &mt('all')
|
$LONCAPA::map::order[0]=$idx; |
|| $shown<=$env{'form.show'})) { last; }
|
$LONCAPA::map::resources[$idx]=''; |
}
|
} |
$r->print(&Apache::loncommon::end_data_table());
|
if (defined($env{'form.markcopy'})) { |
}
|
# Mark for copying |
|
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]); |
sub update_paste_buffer {
|
$env{'form.markedcopy_title'}=$title; |
my ($coursenum,$coursedom) = @_;
|
$env{'form.markedcopy_url'}=$url; |
|
} |
return if (!defined($env{'form.markcopy'}));
|
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain)=&breadcrumbs($folder); |
return if (!defined($env{'form.copyfolder'}));
|
$r->print($breadcrumbtrail); |
return if ($env{'form.markcopy'} < 0);
|
if ($fatal) { |
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
} else { |
$env{'form.copyfolder'});
|
# ------------------------------------------------------------ Process commands |
|
|
return if ($fatal);
|
# ---------------- if they are for this folder and user allowed to make changes |
|
if (($allowed) && ($env{'form.folder'} eq $folder)) { |
# Mark for copying
|
# set parameters and change order |
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
|
&snapshotbefore(); |
if (&is_supplemental_title($title)) {
|
if ($env{'form.changeparms'}) { |
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
|
my $idx=$env{'form.setparms'}; |
($title) = &parse_supplemental_title($title);
|
# set parameters |
} elsif ($env{'docs.markedcopy_supplemental'}) {
|
if ($env{'form.changeparms'} eq 'randompick') { |
&Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
|
if ($env{'form.randpick_'.$idx}) { |
}
|
&LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos'); |
$url=~s{http(:|:)//https(:|:)//}{https$2//};
|
&remember_parms($idx,'randompick','set',$env{'form.randpick_'.$idx}); |
|
} else { |
&Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
|
&LONCAPA::map::delparameter($idx,'parameter_randompick'); |
'docs.markedcopy_url' => $url});
|
&remember_parms($idx,'randompick','del'); |
delete($env{'form.markcopy'});
|
} |
}
|
} |
|
if ($env{'form.changeparms'} eq 'hiddenresource') { |
sub print_paste_buffer {
|
if ($env{'form.hidprs_'.$idx}) { |
my ($r,$container) = @_;
|
&LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno'); |
return if (!defined($env{'docs.markedcopy_url'}));
|
&remember_parms($idx,'hiddenresource','set',$env{'form.hidprs_'.$idx}); |
|
} else { |
$r->print(<<ENDPASTE);
|
&LONCAPA::map::delparameter($idx,'parameter_hiddenresource'); |
<form name="pasteform" action="/adm/coursedocs" method="post"><p>
|
&remember_parms($idx,'hiddenresource','del'); |
ENDPASTE
|
} |
$r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
|
} |
|
if ($env{'form.changeparms'} eq 'encrypturl') { |
my $type;
|
if ($env{'form.encprs_'.$idx}) { |
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
|
&LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno'); |
$type = &mt('External Resource');
|
&remember_parms($idx,'encrypturl','set',$env{'form.encprs_'.$idx}); |
$r->print($type.': '.
|
} else { |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
|
&LONCAPA::map::delparameter($idx,'parameter_encrypturl'); |
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
|
&remember_parms($idx,'encrypturl','del'); |
} else {
|
} |
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
|
} |
my $icon = &Apache::loncommon::icon($extension);
|
# store the changed version |
if ($extension eq 'sequence' &&
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
|
if ($fatal) { |
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
$icon .= '/folder_closed.gif';
|
return; |
}
|
} |
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
|
} |
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
|
|
}
|
if ($env{'form.newpos'}) { |
if ($container eq 'page') {
|
# change order |
$r->print('
|
my $newpos=$env{'form.newpos'}-1; |
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
|
my $currentpos=$env{'form.currentpos'}-1; |
<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
|
my $i; |
');
|
my @neworder=(); |
} else {
|
if ($newpos>$currentpos) { |
$r->print('
|
# moving stuff up |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
for ($i=0;$i<$currentpos;$i++) { |
');
|
$neworder[$i]=$LONCAPA::map::order[$i]; |
}
|
} |
$r->print('</p></form>');
|
for ($i=$currentpos;$i<$newpos;$i++) { |
}
|
$neworder[$i]=$LONCAPA::map::order[$i+1]; |
|
} |
sub do_paste_from_buffer {
|
$neworder[$newpos]=$LONCAPA::map::order[$currentpos]; |
my ($coursenum,$coursedom,$folder) = @_;
|
for ($i=$newpos+1;$i<=$#LONCAPA::map::order;$i++) { |
|
$neworder[$i]=$LONCAPA::map::order[$i]; |
if (!$env{'form.pastemarked'}) {
|
} |
return;
|
} else { |
}
|
# moving stuff down |
|
for ($i=0;$i<$newpos;$i++) { |
# paste resource to end of list
|
$neworder[$i]=$LONCAPA::map::order[$i]; |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
|
} |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
|
$neworder[$newpos]=$LONCAPA::map::order[$currentpos]; |
# Maps need to be copied first
|
for ($i=$newpos+1;$i<$currentpos+1;$i++) { |
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
|
$neworder[$i]=$LONCAPA::map::order[$i-1]; |
$title=&mt('Copy of').' '.$title;
|
} |
my $newid=$$.int(rand(100)).time;
|
for ($i=$currentpos+1;$i<=$#LONCAPA::map::order;$i++) { |
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
|
$neworder[$i]=$LONCAPA::map::order[$i]; |
if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
|
} |
my $path = $1;
|
} |
my $prefix = $2;
|
@LONCAPA::map::order=@neworder; |
my $ancestor = $3;
|
# store the changed version |
if (length($ancestor) > 10) {
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
$ancestor = substr($ancestor,-10,10);
|
if ($fatal) { |
}
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
$oldid = $path.$prefix.$ancestor;
|
return; |
}
|
} |
my $counter = 0;
|
} |
my $newurl=$oldid.$newid.'.'.$ext;
|
|
my $is_unique = &uniqueness_check($newurl);
|
if ($env{'form.pastemarked'}) { |
while (!$is_unique && $counter < 100) {
|
# paste resource to end of list |
$counter ++;
|
my $url=$env{'form.markedcopy_url'}; |
$newid ++;
|
my $title=$env{'form.markedcopy_title'}; |
$newurl = $oldid.$newid;
|
# Maps need to be copied first |
$is_unique = &uniqueness_check($newurl);
|
if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) { |
}
|
$title=&mt('Copy of').' '.$title; |
if (!$is_unique) {
|
my $newid=$$.time; |
if ($url=~/\.page$/) {
|
$url=~/^(.+)\.(\w+)$/; |
return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
|
my $newurl=$1.$newid.'.'.$2; |
} else {
|
my $storefn=$newurl; |
return &mt('Paste failed: an error occurred creating a unique URL for the folder');
|
$storefn=~s{^/\w+/$match_domain/$match_username/}{}; |
}
|
&Apache::lonclonecourse::writefile |
}
|
($env{'request.course.id'},$storefn, |
my $storefn=$newurl;
|
&Apache::lonnet::getfile($url)); |
$storefn=~s{^/\w+/$match_domain/$match_username/}{};
|
$url=$newurl; |
my $paste_map_result =
|
} |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
|
$title=~s/\</\<\;/g; |
&Apache::lonnet::getfile($url));
|
$title=~s/\>/\>\;/g; |
if ($paste_map_result eq '/adm/notfound.html') {
|
$title=~s/\:/\:/g; |
if ($url=~/\.page$/) {
|
my $ext='false'; |
return &mt('Paste failed: an error occurred saving the composite page');
|
if ($url=~/^http\:\/\//) { $ext='true'; } |
} else {
|
$url=~s/\:/\:/g; |
return &mt('Paste failed: an error occurred saving the folder');
|
# Now insert the URL at the bottom |
}
|
my $newidx=&LONCAPA::map::getresidx($url); |
}
|
$LONCAPA::map::resources[$newidx]= |
$url = $newurl;
|
$title.':'.$url.':'.$ext.':normal:res'; |
}
|
$LONCAPA::map::order[1+$#LONCAPA::map::order]=$newidx; |
# published maps can only exists once, so remove it from paste buffer when done
|
# Store the result |
if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
&Apache::lonnet::delenv('docs\\.markedcopy');
|
if ($fatal) { |
}
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
if ($url=~ m{/smppg$}) {
|
return; |
my $db_name = &Apache::lonsimplepage::get_db_name($url);
|
} |
if ($db_name =~ /^smppage_/) {
|
|
#simple pages, need to copy the db contents to a new one.
|
} |
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
|
$r->print($upload_output); |
my $now = time();
|
if ($env{'form.cmd'}) { |
$db_name =~ s{_\d*$ }{_$now}x;
|
my ($cmd,$idx)=split(/\_/,$env{'form.cmd'}); |
my $result=&Apache::lonnet::put($db_name,\%contents,
|
if ($cmd eq 'del') { |
$coursedom,$coursenum);
|
my (undef,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); |
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
|
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
$title=&mt('Copy of').' '.$title;
|
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { |
}
|
&Apache::lonnet::removeuploadedurl($url); |
}
|
} else { |
$title = &LONCAPA::map::qtunescape($title);
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
my $ext='false';
|
} |
if ($url=~m{^http(|s)://}) { $ext='true'; }
|
for (my $i=$idx;$i<$#LONCAPA::map::order;$i++) { |
$url = &LONCAPA::map::qtunescape($url);
|
$LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1]; |
# Now insert the URL at the bottom
|
} |
my $newidx = &LONCAPA::map::getresidx($url);
|
$#LONCAPA::map::order--; |
if ($env{'docs.markedcopy_supplemental'}) {
|
} elsif ($cmd eq 'cut') { |
if ($folder =~ /^supplemental/) {
|
my (undef,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); |
$title = $env{'docs.markedcopy_supplemental'};
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
} else {
|
for (my $i=$idx;$i<$#LONCAPA::map::order;$i++) { |
(undef,undef,$title) =
|
$LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1]; |
&parse_supplemental_title($env{'docs.markedcopy_supplemental'});
|
} |
}
|
$#LONCAPA::map::order--; |
} else {
|
} elsif ($cmd eq 'up') { |
if ($folder=~/^supplemental/) {
|
if (($idx) && (defined($LONCAPA::map::order[$idx-1]))) { |
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
my $i=$LONCAPA::map::order[$idx-1]; |
$env{'user.domain'}.'___&&&___'.$title;
|
$LONCAPA::map::order[$idx-1] = $LONCAPA::map::order[$idx]; |
}
|
$LONCAPA::map::order[$idx] = $i; |
}
|
} |
|
} elsif ($cmd eq 'down') { |
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
|
if (defined($LONCAPA::map::order[$idx+1])) { |
push(@LONCAPA::map::order, $newidx);
|
my $i=$LONCAPA::map::order[$idx+1]; |
return 'ok';
|
$LONCAPA::map::order[$idx+1] = $LONCAPA::map::order[$idx]; |
# Store the result
|
$LONCAPA::map::order[$idx] = $i; |
}
|
} |
|
} elsif ($cmd eq 'rename') { |
sub uniqueness_check {
|
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
my ($newurl) = @_;
|
my ($rtitle,@rrest)=split(/\:/, |
my $unique = 1;
|
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]); |
foreach my $res (@LONCAPA::map::order) {
|
my $comment= |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
&HTML::Entities::decode($env{'form.title'}); |
$url=&LONCAPA::map::qtescape($url);
|
$comment=~s/\</\<\;/g; |
if ($newurl eq $url) {
|
$comment=~s/\>/\>\;/g; |
$unique = 0;
|
$comment=~s/\:/\:/g; |
last;
|
if ($comment=~/\S/) { |
}
|
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= |
}
|
$comment.':'.join(':',@rrest); |
return $unique;
|
} |
}
|
# Devalidate title cache |
|
my $renamed_url=$rrest[0]; |
my %parameter_type = ( 'randompick' => 'int_pos',
|
# Has the :-escaping |
'hiddenresource' => 'string_yesno',
|
$renamed_url=~s/\&colon\;/\:/g; |
'encrypturl' => 'string_yesno',
|
&Apache::lonnet::devalidate_title_cache($renamed_url); |
'randomorder' => 'string_yesno',);
|
} |
my $valid_parameters_re = join('|',keys(%parameter_type));
|
# Store the changed version |
# set parameters
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
sub update_parameter {
|
$folder.'.'.$container); |
|
if ($fatal) { |
return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
|
return; |
my $which = $env{'form.changeparms'};
|
} |
my $idx = $env{'form.setparms'};
|
} |
if ($env{'form.'.$which.'_'.$idx}) {
|
# Group import/search |
my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
|
if ($env{'form.importdetail'}) { |
: 'yes';
|
my @imports; |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
|
# &Apache::lonnet::logthis("imp detail ".$env{'form.importdetail'}); |
$parameter_type{$which});
|
foreach (split(/\&/,$env{'form.importdetail'})) { |
&remember_parms($idx,$which,'set',$value);
|
if (defined($_)) { |
} else {
|
my ($name,$url)=split(/\=/,$_); |
&LONCAPA::map::delparameter($idx,'parameter_'.$which);
|
$name=&unescape($name); |
|
$url=&unescape($url); |
&remember_parms($idx,$which,'del');
|
push @imports, $name, $url; |
}
|
} |
return 1;
|
} |
}
|
# Store the changed version |
|
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder, |
|
$container,'londocs',@imports); |
sub handle_edit_cmd {
|
if ($fatal) { |
my ($coursenum,$coursedom) =@_;
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
|
return; |
my ($cmd,$idx)=split('_',$env{'form.cmd'});
|
} |
|
} |
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
# Loading a complete map |
my ($title, $url, @rrest) = split(':', $ratstr);
|
if ($env{'form.loadmap'}) { |
|
if ($env{'form.importmap'}=~/\w/) { |
if ($cmd eq 'del') {
|
foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { |
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
|
my ($title,$url,$ext,$type)=split(/\:/,$_); |
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
|
my $idx=&LONCAPA::map::getresidx($url); |
&Apache::lonnet::removeuploadedurl($url);
|
$LONCAPA::map::resources[$idx]=$_; |
} else {
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
} |
}
|
# Store the changed version |
splice(@LONCAPA::map::order, $idx, 1);
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
|
$folder.'.'.$container); |
} elsif ($cmd eq 'cut') {
|
if ($fatal) { |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
$r->print('<p><font color="red">'.$errtext.'</font></p>'); |
splice(@LONCAPA::map::order, $idx, 1);
|
return; |
|
} |
} elsif ($cmd eq 'up'
|
} else { |
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
|
$r->print('<p><font color="red">'.&mt('No map selected.').'</font></p>'); |
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
|
} |
|
} |
} elsif ($cmd eq 'down'
|
&log_differences($plain); |
&& defined($LONCAPA::map::order[$idx+1])) {
|
} |
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
|
# ---------------------------------------------------------------- End commands |
|
# ---------------------------------------------------------------- Print screen |
} elsif ($cmd eq 'rename') {
|
my $idx=0; |
|
my $shown=0; |
my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
|
if (($ishidden) || ($isencrypted) || ($randompick>=0)) { |
if ($comment=~/\S/) {
|
$r->print('<p>'.&mt('Parameters').':<ul>'. |
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
|
($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':''). |
$comment.':'.join(':', $url, @rrest);
|
($ishidden?'<li>'.&mt('contents hidden').'</li>':''). |
}
|
($isencrypted?'<li>'.&mt('URLs hidden').'</li>':''). |
# Devalidate title cache
|
'</ul></p>'); |
my $renamed_url=&LONCAPA::map::qtescape($url);
|
} |
&Apache::lonnet::devalidate_title_cache($renamed_url);
|
if ($randompick>=0) { |
} else {
|
$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>'); |
return 0;
|
} |
}
|
$r->print('<table>'); |
return 1;
|
foreach (@LONCAPA::map::order) { |
}
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]); |
|
$name=&LONCAPA::map::qtescape($name); |
sub editor {
|
$url=&LONCAPA::map::qtescape($url); |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
|
unless ($name) { $name=(split(/\//,$url))[-1]; } |
|
unless ($name) { $idx++; next; } |
my $container= ($env{'form.pagepath'}) ? 'page'
|
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum)); |
: 'sequence';
|
$idx++; |
|
$shown++; |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
} |
$folder.'.'.$container);
|
unless ($shown) { |
return $errtext if ($fatal);
|
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>'); |
|
} |
if ($#LONCAPA::map::order<1) {
|
$r->print("\n</table>\n"); |
my $idx=&LONCAPA::map::getresidx();
|
if ($env{'form.markedcopy_url'}) { |
if ($idx<=0) { $idx=1; }
|
$r->print(<<ENDPASTE); |
$LONCAPA::map::order[0]=$idx;
|
<p><form name="pasteform" action="/adm/coursedocs" method="post"> |
$LONCAPA::map::resources[$idx]='';
|
<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" /> |
}
|
<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" /> |
|
ENDPASTE |
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
|
$r->print( |
&breadcrumbs($folder,$allowed,$type);
|
'<input type="submit" name="pastemarked" value="'.&mt('Paste'). |
$r->print($breadcrumbtrail);
|
'" /> '.&Apache::loncommon::filedescription( |
|
(split(/\./,$env{'form.markedcopy_url'}))[-1]).': '. |
# ------------------------------------------------------------ Process commands
|
$env{'form.markedcopy_title'}); |
|
if ($container eq 'page') { |
# ---------------- if they are for this folder and user allowed to make changes
|
$r->print(<<PAGEINFO); |
if (($allowed) && ($env{'form.folder'} eq $folder)) {
|
<input type="hidden" name="pagepath" value="$env{'form.pagepath'}" /> |
# set parameters and change order
|
<input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" /> |
&snapshotbefore();
|
PAGEINFO |
|
} else { |
if (&update_parameter()) {
|
$r->print(<<FOLDERINFO); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
return $errtext if ($fatal);
|
FOLDERINFO |
}
|
} |
|
$r->print('</form></p>'); |
if ($env{'form.newpos'} && $env{'form.currentpos'}) {
|
} |
# change order
|
} |
my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
|
} |
splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
|
|
|
sub process_file_upload { |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; |
return $errtext if ($fatal);
|
# upload a file, if present |
}
|
my $parseaction; |
|
if ($env{'form.parserflag'}) { |
if ($env{'form.pastemarked'}) {
|
$parseaction = 'parse'; |
my $paste_res =
|
} |
&do_paste_from_buffer($coursenum,$coursedom,$folder);
|
my $phase_status; |
if ($paste_res eq 'ok') {
|
my $folder=$env{'form.folder'}; |
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
|
if ($folder eq '') { |
return $errtext if ($fatal);
|
$folder='default'; |
} elsif ($paste_res ne '') {
|
} |
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
|
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) { |
}
|
my $errtext=''; |
}
|
my $fatal=0; |
|
my $container='sequence'; |
$r->print($upload_output);
|
if ($env{'form.pagepath'}) { |
|
$container='page'; |
if (&handle_edit_cmd()) {
|
} |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
($errtext,$fatal)= |
return $errtext if ($fatal);
|
&mapread($coursenum,$coursedom,$folder.'.'.$container); |
}
|
if ($#LONCAPA::map::order<1) { |
# Group import/search
|
$LONCAPA::map::order[0]=1; |
if ($env{'form.importdetail'}) {
|
$LONCAPA::map::resources[1]=''; |
my @imports;
|
} |
foreach my $item (split(/\&/,$env{'form.importdetail'})) {
|
if ($fatal) { |
if (defined($item)) {
|
return 'failed'; |
my ($name,$url,$residx)=
|
} |
map {&unescape($_)} split(/\=/,$item);
|
my $destination = 'docs/'; |
push(@imports, [$name, $url, $residx]);
|
if ($folder =~ /^supplemental/) { |
}
|
$destination = 'supplemental/'; |
}
|
} |
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
$container,'londocs',@imports);
|
$destination .= 'default/'; |
return $errtext if ($fatal);
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
}
|
$destination .= $2.'/'; |
# Loading a complete map
|
} |
if ($env{'form.loadmap'}) {
|
# this is for a course, not a user, so set coursedoc flag |
if ($env{'form.importmap'}=~/\w/) {
|
# probably the only place in the system where this should be "1" |
foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
|
my $newidx=&LONCAPA::map::getresidx(); |
my ($title,$url,$ext,$type)=split(/\:/,$res);
|
$destination .= $newidx; |
my $idx=&LONCAPA::map::getresidx($url);
|
my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination, |
$LONCAPA::map::resources[$idx]=$res;
|
$parseaction,$allfiles, |
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
|
$codebase); |
}
|
my $ext='false'; |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
if ($url=~/^http\:\/\//) { $ext='true'; } |
$folder.'.'.$container);
|
$url=~s/\:/\:/g; |
return $errtext if ($fatal);
|
my $comment=$env{'form.comment'}; |
} else {
|
$comment=~s/\</\<\;/g; |
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
|
$comment=~s/\>/\>\;/g; |
|
$comment=~s/\:/\:/g; |
}
|
if ($folder=~/^supplemental/) { |
}
|
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
&log_differences($plain);
|
$env{'user.domain'}.'___&&&___'.$comment; |
}
|
} |
# ---------------------------------------------------------------- End commands
|
|
# ---------------------------------------------------------------- Print screen
|
$LONCAPA::map::resources[$newidx]= |
my $idx=0;
|
$comment.':'.$url.':'.$ext.':normal:res'; |
my $shown=0;
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx; |
if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
$r->print('<p>'.&mt('Parameters').':<ul>'.
|
$folder.'.'.$container); |
($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
|
if ($fatal) { |
($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
|
$$upload_output .= '<p><font color="red">'.$errtext.'</font></p>'; |
($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
|
return 'failed'; |
'</ul></p>');
|
} else { |
}
|
if ($parseaction eq 'parse') { |
if ($randompick>=0) {
|
my $total_embedded = keys(%{$allfiles}); |
$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>');
|
if ($total_embedded > 0) { |
}
|
my $num = 0; |
if ($is_random_order) {
|
$$upload_output .= 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br /> |
$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>');
|
<form name="upload_embedded" action="/adm/coursedocs" |
}
|
method="post" enctype="multipart/form-data"> |
$r->print('<table class="LC_docs_editor">');
|
<input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" /> <input type="hidden" name="cmd" value="upload_embedded" /> |
foreach my $res (@LONCAPA::map::order) {
|
<input type="hidden" name="newidx" value="'.$newidx.'" /> |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
<input type="hidden" name="primaryurl" value="'.&escape($url).'" /> |
$name=&LONCAPA::map::qtescape($name);
|
<input type="hidden" name="phasetwo" value="'.$total_embedded.'" />'; |
$url=&LONCAPA::map::qtescape($url);
|
$$upload_output .= '<b>Upload embedded files</b>:<br /> |
unless ($name) { $name=(split(/\//,$url))[-1]; }
|
<table>'; |
unless ($name) { $idx++; next; }
|
foreach my $embed_file (keys(%{$allfiles})) { |
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
|
$$upload_output .= '<tr><td>'.$embed_file. |
$coursenum));
|
'<input name="embedded_item_'.$num.'" type="file" /> |
$idx++;
|
<input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />'; |
$shown++;
|
my $attrib; |
}
|
if (@{$$allfiles{$embed_file}} > 1) { |
unless ($shown) {
|
$attrib = join(':',@{$$allfiles{$embed_file}}); |
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
|
} else { |
}
|
$attrib = $$allfiles{$embed_file}[0]; |
$r->print("\n</table>\n");
|
} |
if ($allowed) {
|
$$upload_output .= |
&print_paste_buffer($r,$container);
|
'<input name="embedded_attrib_'.$num.'" type="hidden" value="'.$attrib.'" />'; |
}
|
if (exists($$codebase{$embed_file})) { |
return;
|
$$upload_output .= |
}
|
'<input name="codebase_'.$num.'" type="hidden" value="'.&escape($$codebase{$embed_file}).'" />'; |
|
} |
sub process_file_upload {
|
$$upload_output .= '</td></tr>'; |
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
|
$num ++; |
# upload a file, if present
|
} |
my $parseaction;
|
$phase_status = 'phasetwo'; |
if ($env{'form.parserflag'}) {
|
$$upload_output .= '</table><br /> |
$parseaction = 'parse';
|
<input type ="submit" value="Complete upload" /> |
}
|
</form>'; |
my $phase_status;
|
} else { |
my $folder=$env{'form.folder'};
|
$$upload_output .= 'No embedded items identified<br />'; |
if ($folder eq '') {
|
} |
$folder='default';
|
} |
}
|
} |
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
|
} |
my $errtext='';
|
return $phase_status; |
my $fatal=0;
|
} |
my $container='sequence';
|
|
if ($env{'form.pagepath'}) {
|
sub process_secondary_uploads { |
$container='page';
|
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_; |
}
|
my $folder=$env{'form.folder'}; |
($errtext,$fatal)=
|
my $destination = 'docs/'; |
&mapread($coursenum,$coursedom,$folder.'.'.$container);
|
if ($folder =~ /^supplemental/) { |
if ($#LONCAPA::map::order<1) {
|
$destination = 'supplemental/'; |
$LONCAPA::map::order[0]=1;
|
} |
$LONCAPA::map::resources[1]='';
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
}
|
$destination .= 'default/'; |
if ($fatal) {
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
return 'failed';
|
$destination .= $2.'/'; |
}
|
} |
my $destination = 'docs/';
|
$destination .= $newidx; |
if ($folder =~ /^supplemental/) {
|
my ($url,$filename); |
$destination = 'supplemental/';
|
$url=&Apache::lonnet::userfileupload($formname.$num,1,$destination); |
}
|
($filename) = ($url =~ m-^/uploaded/$coursedom/$coursenum/$destination/(.+)$-); |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
return $filename; |
$destination .= 'default/';
|
} |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
|
$destination .= $2.'/';
|
# --------------------------------------------------------------- An entry line |
}
|
|
# this is for a course, not a user, so set coursedoc flag
|
sub entryline { |
# probably the only place in the system where this should be "1"
|
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_; |
my $newidx=&LONCAPA::map::getresidx();
|
$title=~s/\&colon\;/\:/g; |
$destination .= $newidx;
|
$title=&HTML::Entities::encode(&HTML::Entities::decode( |
my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
|
&unescape($title)),'"<>&\''); |
$parseaction,$allfiles,
|
my $renametitle=$title; |
$codebase);
|
my $foldertitle=$title; |
my $ext='false';
|
my $pagetitle=$title; |
if ($url=~m{^http://}) { $ext='true'; }
|
my $orderidx=$LONCAPA::map::order[$index]; |
$url = &LONCAPA::map::qtunescape($url);
|
if ($title=~ /^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/ ) { |
my $comment=$env{'form.comment'};
|
$foldertitle=&Apache::lontexconvert::msgtexconverted($4); |
$comment = &LONCAPA::map::qtunescape($comment);
|
$renametitle=$4; |
if ($folder=~/^supplemental/) {
|
$title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '. |
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
&Apache::loncommon::plainname($2,$3).': <br />'. |
$env{'user.domain'}.'___&&&___'.$comment;
|
$foldertitle; |
}
|
} |
|
$renametitle=~s/\\/\\\\/g; |
$LONCAPA::map::resources[$newidx]=
|
$renametitle=~s/\"\;/\\\"/g; |
$comment.':'.$url.':'.$ext.':normal:res';
|
my $line='<tr>'; |
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
|
# Edit commands |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
my $container; |
$folder.'.'.$container);
|
my $folderpath; |
if ($fatal) {
|
if ($env{'form.folderpath'}) { |
$$upload_output .= '<p><span class="LC_error">'.$errtext.'</span></p>';
|
$container = 'sequence'; |
return 'failed';
|
$folderpath=&escape($env{'form.folderpath'}); |
} else {
|
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"'); |
if ($parseaction eq 'parse') {
|
} |
my $total_embedded = keys(%{$allfiles});
|
my ($pagepath,$pagesymb); |
if ($total_embedded > 0) {
|
if ($env{'form.pagepath'}) { |
my $num = 0;
|
$container = 'page'; |
my $state = '
|
$pagepath=&escape($env{'form.pagepath'}); |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
$pagesymb=&escape($env{'form.pagesymb'}); |
<input type="hidden" name="cmd" value="upload_embedded" />
|
} |
<input type="hidden" name="newidx" value="'.$newidx.'" />
|
my $cpinfo=''; |
<input type="hidden" name="primaryurl" value="'.&escape($url).'" />
|
if ($env{'form.markedcopy_url'}) { |
<input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
|
$cpinfo='&markedcopy_url='. |
$phase_status = 'phasetwo';
|
&escape($env{'form.markedcopy_url'}). |
|
'&markedcopy_title='. |
$$upload_output .=
|
&escape($env{'form.markedcopy_title'}); |
'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
|
} |
&Apache::loncommon::ask_for_embedded_content(
|
if ($allowed) { |
'/adm/coursedocs',$state,$allfiles,$codebase);
|
my $incindex=$index+1; |
} else {
|
my $selectbox=''; |
$$upload_output .= 'No embedded items identified<br />';
|
if (($folder!~/^supplemental/) && |
}
|
($#LONCAPA::map::order>0) && |
}
|
((split(/\:/, |
}
|
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1] |
}
|
ne '') && |
return $phase_status;
|
((split(/\:/, |
}
|
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1] |
|
ne '')) { |
sub process_secondary_uploads {
|
$selectbox= |
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
|
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'. |
my $folder=$env{'form.folder'};
|
'<select name="newpos" onChange="this.form.submit()">'; |
my $destination = 'docs/';
|
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) { |
if ($folder =~ /^supplemental/) {
|
if ($i==$incindex) { |
$destination = 'supplemental/';
|
$selectbox.='<option value="" selected="1">('.$i.')</option>'; |
}
|
} else { |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
$selectbox.='<option value="'.$i.'">'.$i.'</option>'; |
$destination .= 'default/';
|
} |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
} |
$destination .= $2.'/';
|
$selectbox.='</select>'; |
}
|
} |
$destination .= $newidx;
|
my %lt=&Apache::lonlocal::texthash( |
my ($url,$filename);
|
'up' => 'Move Up', |
$url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
|
'dw' => 'Move Down', |
($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
|
'rm' => 'Remove', |
return $filename;
|
'ct' => 'Cut', |
}
|
'rn' => 'Rename', |
|
'cp' => 'Copy'); |
sub is_supplemental_title {
|
my $nocopy=0; |
my ($title) = @_;
|
if ($url=~/\.(page|sequence)$/) { |
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
|
foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) { |
}
|
my ($title,$url,$ext,$type)=split(/\:/,$_); |
|
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { |
sub parse_supplemental_title {
|
$nocopy=1; |
my ($title) = @_;
|
last; |
|
} |
my ($foldertitle,$renametitle);
|
} |
if ($title =~ /&&&/) {
|
} |
$title = &HTML::Entites::decode($title);
|
my $copylink=' '; |
}
|
if ($env{'form.pagepath'}) { |
if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
|
unless ($nocopy) { |
$renametitle=$4;
|
$copylink=(<<ENDCOPY); |
my ($time,$uname,$udom) = ($1,$2,$3);
|
<a href='javascript:markcopy("$pagepath","$index","$renametitle","page","$pagesymb");'> |
$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
|
<font size="-2" color="#000099">$lt{'cp'}</font></a></td> |
my $name = &Apache::loncommon::plainname($uname,$udom);
|
ENDCOPY |
$name = &HTML::Entities::encode($name,'"<>&\'');
|
} |
$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
|
$line.=(<<END); |
$name.': <br />'.$foldertitle;
|
<form name="entry_$index" action="/adm/coursedocs" method="post"> |
}
|
<input type="hidden" name="pagepath" value="$env{'form.pagepath'}" /> |
if (wantarray) {
|
<input type="hidden" name="pagesymb" value="$env{'form.pagesymb'}" /> |
return ($title,$foldertitle,$renametitle);
|
<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" /> |
}
|
<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" /> |
return $title;
|
<input type="hidden" name="setparms" value="$orderidx" /> |
}
|
<input type="hidden" name="changeparms" value="0" /> |
|
<td><table border='0' cellspacing='2' cellpadding='0'> |
# --------------------------------------------------------------- An entry line
|
<tr><td bgcolor="#DDDDDD"> |
|
<a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'> |
sub entryline {
|
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr> |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
|
<tr><td bgcolor="#DDDDDD"> |
|
<a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb$cpinfo'> |
my ($foldertitle,$pagetitle,$renametitle);
|
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr> |
if (&is_supplemental_title($title)) {
|
</table></td> |
($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
|
<td>$selectbox |
$pagetitle = $foldertitle;
|
</td><td bgcolor="#DDDDDD"> |
} else {
|
<a href='javascript:removeres("$pagepath","$index","$renametitle","page","$pagesymb");'> |
$title=&HTML::Entities::encode($title,'"<>&\'');
|
<font size="-2" color="#990000">$lt{'rm'}</font></a> |
$renametitle=$title;
|
<a href='javascript:cutres("$pagepath","$index","$renametitle","page","$pagesymb");'> |
$foldertitle=$title;
|
<font size="-2" color="#550044">$lt{'ct'}</font></a> |
$pagetitle=$title;
|
<a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'> |
}
|
<font size="-2" color="#009900">$lt{'rn'}</font></a> |
|
$copylink |
my $orderidx=$LONCAPA::map::order[$index];
|
END |
|
} else { |
|
unless ($nocopy) { |
$renametitle=~s/\\/\\\\/g;
|
$copylink=(<<ENDCOPY); |
$renametitle=~s/\"\;/\\\"/g;
|
<a href='javascript:markcopy("$folderpath","$index","$renametitle","sequence");'> |
$renametitle=~s/ /%20/g;
|
<font size="-2" color="#000099">$lt{'cp'}</font></a></td> |
my $line='<tr>';
|
ENDCOPY |
my ($form_start,$form_end);
|
} |
# Edit commands
|
$line.=(<<END); |
my ($container, $type, $esc_path, $path, $symb);
|
<form name="entry_$index" action="/adm/coursedocs" method="post"> |
if ($env{'form.folderpath'}) {
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
$type = 'folder';
|
<input type="hidden" name="markedcopy_url" value="$env{'form.markedcopy_url'}" /> |
$container = 'sequence';
|
<input type="hidden" name="markedcopy_title" value="$env{'form.markedcopy_title'}" /> |
$esc_path=&escape($env{'form.folderpath'});
|
<input type="hidden" name="setparms" value="$orderidx" /> |
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
<input type="hidden" name="changeparms" value="0" /> |
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
|
<td><table border='0' cellspacing='2' cellpadding='0'> |
}
|
<tr><td bgcolor="#DDDDDD"> |
if ($env{'form.pagepath'}) {
|
<a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath$cpinfo'> |
$type = $container = 'page';
|
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr> |
$esc_path=&escape($path = $env{'form.pagepath'});
|
<tr><td bgcolor="#DDDDDD"> |
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
|
<a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath$cpinfo'> |
$symb=&escape($env{'form.pagesymb'});
|
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr> |
}
|
</table></td> |
my $cpinfo='';
|
<td>$selectbox |
if ($allowed) {
|
</td><td bgcolor="#DDDDDD"> |
my $incindex=$index+1;
|
<a href='javascript:removeres("$folderpath","$index","$renametitle","sequence");'> |
my $selectbox='';
|
<font size="-2" color="#990000">$lt{'rm'}</font></a> |
if (($folder!~/^supplemental/) &&
|
<a href='javascript:cutres("$folderpath","$index","$renametitle","sequence");'> |
($#LONCAPA::map::order>0) &&
|
<font size="-2" color="#550044">$lt{'ct'}</font></a> |
((split(/\:/,
|
<a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'> |
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
|
<font size="-2" color="#009900">$lt{'rn'}</font></a> |
ne '') &&
|
$copylink |
((split(/\:/,
|
END |
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
|
} |
ne '')) {
|
} |
$selectbox=
|
# Figure out what kind of a resource this is |
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
|
my ($extension)=($url=~/\.(\w+)$/); |
'<select name="newpos" onChange="this.form.submit()">';
|
my $uploaded=($url=~/^\/*uploaded\//); |
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
|
my $icon=&Apache::loncommon::icon($url); |
if ($i==$incindex) {
|
my $isfolder=0; |
$selectbox.='<option value="" selected="1">('.$i.')</option>';
|
my $ispage=0; |
} else {
|
my $folderarg; |
$selectbox.='<option value="'.$i.'">'.$i.'</option>';
|
my $pagearg; |
}
|
my $pagefile; |
}
|
if ($uploaded) { |
$selectbox.='</select>';
|
if ($extension eq 'sequence') { |
}
|
$icon=$iconpath.'/folder_closed.gif'; |
my %lt=&Apache::lonlocal::texthash(
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; |
'up' => 'Move Up',
|
$url='/adm/coursedocs?'; |
'dw' => 'Move Down',
|
$folderarg=$1; |
'rm' => 'Remove',
|
$isfolder=1; |
'ct' => 'Cut',
|
} elsif ($extension eq 'page') { |
'rn' => 'Rename',
|
$icon=$iconpath.'/page.gif'; |
'cp' => 'Copy');
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/; |
my $nocopy=0;
|
$pagearg=$1; |
my $nocut=0;
|
$url='/adm/coursedocs?'; |
if ($url=~/\.(page|sequence)$/) {
|
$ispage=1; |
if ($url =~ m{/res/}) {
|
} else { |
# no copy for published maps
|
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url); |
$nocopy = 1;
|
} |
} else {
|
} |
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
|
$url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-; |
my ($title,$url,$ext,$type)=split(/\:/,$item);
|
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { |
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
|
my $symb=&Apache::lonnet::symbclean( |
$nocopy=1;
|
&Apache::lonnet::declutter('uploaded/'. |
last;
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
}
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. |
}
|
'.sequence'). |
}
|
'___'.$residx.'___'. |
}
|
&Apache::lonnet::declutter($url)); |
if ($url=~/^\/res\/lib\/templates\//) {
|
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
$nocopy=1;
|
$url=&Apache::lonnet::clutter($url); |
$nocut=1;
|
if ($url=~/^\/*uploaded\//) { |
}
|
$url=~/\.(\w+)$/; |
my $copylink=' ';
|
my $embstyle=&Apache::loncommon::fileembstyle($1); |
my $cutlink=' ';
|
if (($embstyle eq 'img') || ($embstyle eq 'emb')) { |
|
$url='/adm/wrapper'.$url; |
my $skip_confirm = 0;
|
} elsif ($embstyle eq 'ssi') { |
if ( $folder =~ /^supplemental/
|
#do nothing with these |
|| ($url =~ m{( /smppg$
|
} elsif ($url!~/\.(sequence|page)$/) { |
|/syllabus$
|
$url='/adm/coursedocs/showdoc'.$url; |
|/aboutme$
|
} |
|/navmaps$
|
} elsif ($url=~m|^/ext/|) { |
|/bulletinboard$
|
$url='/adm/wrapper'.$url; |
|\.html$
|
} |
|^/adm/wrapper/ext)}x)) {
|
if (&Apache::lonnet::symbverify($symb,$url)) { |
$skip_confirm = 1;
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
}
|
} else { |
|
$url=''; |
if (!$nocopy) {
|
} |
$copylink=(<<ENDCOPY);
|
if ($container eq 'page') { |
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
|
my $symb=$env{'form.pagesymb'}; |
ENDCOPY
|
|
}
|
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); |
if (!$nocut) {
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
$cutlink=(<<ENDCUT);
|
} |
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
|
} |
ENDCUT
|
my $parameterset=' '; |
}
|
if ($isfolder || $extension eq 'sequence') { |
$form_start = (<<END);
|
my $foldername=&escape($foldertitle); |
<form action="/adm/coursedocs" method="post">
|
my $folderpath=$env{'form.folderpath'}; |
<input type="hidden" name="${type}path" value="$path" />
|
if ($folderpath) { $folderpath.='&' }; |
<input type="hidden" name="${type}symb" value="$symb" />
|
# Append randompick number, hidden, and encrypted with ":" to foldername, |
<input type="hidden" name="setparms" value="$orderidx" />
|
# so it gets transferred between levels |
<input type="hidden" name="changeparms" value="0" />
|
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx, |
END
|
'parameter_randompick'))[0] |
$form_end = '</form>';
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
$line.=(<<END);
|
'parameter_hiddenresource'))[0]=~/^yes$/i) |
<td>
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
<table class="LC_docs_entry_move">
|
'parameter_encrypturl'))[0]=~/^yes$/i); |
<tr>
|
$url.='folderpath='.&escape($folderpath).$cpinfo; |
<td>
|
$parameterset='<label>'.&mt('Randomly Pick: '). |
<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>
|
'<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randpick_'.$orderidx.'" value="'. |
</td>
|
(&LONCAPA::map::getparameter($orderidx, |
</tr>
|
'parameter_randompick'))[0]. |
<tr>
|
'" />'. |
<td>
|
'<font size="-2"><a href="javascript:void(0)">'.&mt('Store').'</a></font></label>'; |
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /></a>
|
|
</td>
|
} |
</tr>
|
if ($ispage) { |
</table>
|
my $pagename=&escape($pagetitle); |
</td>
|
my $pagepath; |
<td>
|
my $folderpath=$env{'form.folderpath'}; |
$form_start
|
if ($folderpath) { $pagepath = $folderpath.'&' }; |
$selectbox
|
$pagepath.=$pagearg.'&'.$pagename; |
$form_end
|
my $symb=$env{'form.pagesymb'}; |
</td>
|
if (!$symb) { |
<td class="LC_docs_entry_commands">
|
my $path='uploaded/'. |
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
$cutlink
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'; |
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
|
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', |
$copylink
|
$residx, |
</td>
|
$path.$pagearg.'.page'); |
END
|
} |
|
$url.='pagepath='.&escape($pagepath). |
}
|
'&pagesymb='.&escape($symb).$cpinfo; |
# Figure out what kind of a resource this is
|
} |
my ($extension)=($url=~/\.(\w+)$/);
|
$line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon. |
my $uploaded=($url=~/^\/*uploaded\//);
|
'" border="0"></a></td>'. |
my $icon=&Apache::loncommon::icon($url);
|
"<td bgcolor='#FFFFBB'>".($url?"<a href=\"$url\">":'').$title. |
my $isfolder=0;
|
($url?'</a>':' <font size="-2">'.&mt('(re-initialize course to access)').'</font>')."</td>"; |
my $ispage=0;
|
if (($allowed) && ($folder!~/^supplemental/)) { |
my $folderarg;
|
my %lt=&Apache::lonlocal::texthash( |
my $pagearg;
|
'hd' => 'Hidden', |
my $pagefile;
|
'ec' => 'URL hidden'); |
if ($uploaded) {
|
my $enctext= |
if ($extension eq 'sequence') {
|
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':''); |
$icon=$iconpath.'/folder_closed.gif';
|
my $hidtext= |
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
|
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':''); |
$url='/adm/coursedocs?';
|
$line.=(<<ENDPARMS); |
$folderarg=$1;
|
<td bgcolor="#BBBBFF"><font size='-2'> |
$isfolder=1;
|
<nobr><label><input type="checkbox" name="hidprs_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label></nobr></td> |
} elsif ($extension eq 'page') {
|
<td bgcolor="#BBBBFF"><font size='-2'> |
$icon=$iconpath.'/page.gif';
|
<nobr><label><input type="checkbox" name="encprs_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label></nobr></td> |
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
|
<td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td> |
$pagearg=$1;
|
ENDPARMS |
$url='/adm/coursedocs?';
|
} |
$ispage=1;
|
$line.="</form></tr>"; |
} else {
|
return $line; |
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
|
} |
}
|
|
}
|
# ---------------------------------------------------------------- tie the hash |
|
|
my $orig_url = $url;
|
sub tiehash { |
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
|
my ($mode)=@_; |
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
|
$hashtied=0; |
my $symb=&Apache::lonnet::symbclean(
|
if ($env{'request.course.fn'}) { |
&Apache::lonnet::declutter('uploaded/'.
|
if ($mode eq 'write') { |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
|
&GDBM_WRCREAT(),0640)) { |
'.sequence').
|
$hashtied=2; |
'___'.$residx.'___'.
|
} |
&Apache::lonnet::declutter($url));
|
} else { |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
$url=&Apache::lonnet::clutter($url);
|
&GDBM_READER(),0640)) { |
if ($url=~/^\/*uploaded\//) {
|
$hashtied=1; |
$url=~/\.(\w+)$/;
|
} |
my $embstyle=&Apache::loncommon::fileembstyle($1);
|
} |
if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
|
} |
$url='/adm/wrapper'.$url;
|
} |
} elsif ($embstyle eq 'ssi') {
|
|
#do nothing with these
|
sub untiehash { |
} elsif ($url!~/\.(sequence|page)$/) {
|
if ($hashtied) { untie %hash; } |
$url='/adm/coursedocs/showdoc'.$url;
|
$hashtied=0; |
}
|
return OK; |
} elsif ($url=~m|^/ext/|) {
|
} |
$url='/adm/wrapper'.$url;
|
|
$external = 1;
|
# --------------------------------------------------------------- check on this |
}
|
|
if (&Apache::lonnet::symbverify($symb,$url)) {
|
sub checkonthis { |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
my ($r,$url,$level,$title)=@_; |
} else {
|
$url=&unescape($url); |
$url='';
|
$alreadyseen{$url}=1; |
}
|
$r->rflush(); |
if ($container eq 'page') {
|
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) { |
my $symb=$env{'form.pagesymb'};
|
$r->print("\n<br />"); |
|
for (my $i=0;$i<=$level*5;$i++) { |
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
|
$r->print(' '); |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
} |
}
|
$r->print('<a href="'.$url.'" target="cat">'. |
}
|
($title?$title:$url).'</a> '); |
my ($parameterset,$rand_order_text) = (' ', ' ');
|
if ($url=~/^\/res\//) { |
if ($isfolder || $extension eq 'sequence') {
|
my $result=&Apache::lonnet::repcopy( |
my $foldername=&escape($foldertitle);
|
&Apache::lonnet::filelocation('',$url)); |
my $folderpath=$env{'form.folderpath'};
|
if ($result eq 'ok') { |
if ($folderpath) { $folderpath.='&' };
|
$r->print('<font color="green">'.&mt('ok').'</font>'); |
# Append randompick number, hidden, and encrypted with ":" to foldername,
|
$r->rflush(); |
# so it gets transferred between levels
|
&Apache::lonnet::countacc($url); |
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
|
$url=~/\.(\w+)$/; |
'parameter_randompick'))[0]
|
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
$r->print('<br />'); |
'parameter_hiddenresource'))[0]=~/^yes$/i)
|
$r->rflush(); |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
for (my $i=0;$i<=$level*5;$i++) { |
'parameter_encrypturl'))[0]=~/^yes$/i)
|
$r->print(' '); |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
} |
'parameter_randomorder'))[0]=~/^yes$/i);
|
$r->print('- '.&mt('Rendering').': '); |
$url.='folderpath='.&escape($folderpath).$cpinfo;
|
my ($errorcount,$warningcount)=split(/:/, |
$parameterset='<label>'.&mt('Randomly Pick: ').
|
&Apache::lonnet::ssi_body($url, |
'<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
|
('grade_target'=>'web', |
(&LONCAPA::map::getparameter($orderidx,
|
'return_only_error_and_warning_counts' => 1))); |
'parameter_randompick'))[0].
|
if (($errorcount) || |
'" />'.
|
($warningcount)) { |
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
|
if ($errorcount) { |
my $ro_set=
|
$r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'. |
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
|
$errorcount.' '. |
$rand_order_text ='
|
&mt('error(s)').'</b></font> '); |
<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';
|
} |
}
|
if ($warningcount) { |
if ($ispage) {
|
$r->print('<font color="blue">'. |
my $pagename=&escape($pagetitle);
|
$warningcount.' '. |
my $pagepath;
|
&mt('warning(s)').'</font>'); |
my $folderpath=$env{'form.folderpath'};
|
} |
if ($folderpath) { $pagepath = $folderpath.'&' };
|
} else { |
$pagepath.=$pagearg.'&'.$pagename;
|
$r->print('<font color="green">'.&mt('ok').'</font>'); |
my $symb=$env{'form.pagesymb'};
|
} |
if (!$symb) {
|
$r->rflush(); |
my $path='uploaded/'.
|
} |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
my $dependencies= |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/';
|
&Apache::lonnet::metadata($url,'dependencies'); |
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
|
foreach (split(/\,/,$dependencies)) { |
$residx,
|
if (($_=~/^\/res\//) && (!$alreadyseen{$_})) { |
$path.$pagearg.'.page');
|
&checkonthis($r,$_,$level+1); |
}
|
} |
$url.='pagepath='.&escape($pagepath).
|
} |
'&pagesymb='.&escape($symb).$cpinfo;
|
} elsif ($result eq 'unavailable') { |
}
|
$r->print('<font color="red"><b>'.&mt('connection down').'</b></font>'); |
if ($external) {
|
} elsif ($result eq 'not_found') { |
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
|
unless ($url=~/\$/) { |
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
|
$r->print('<font color="red"><b>'.&mt('not found').'</b></font>'); |
} else {
|
} else { |
undef($external);
|
$r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>'); |
}
|
} |
$line.='
|
} else { |
<td class="LC_docs_entry_icon">
|
$r->print('<font color="red"><b>'.&mt('access denied').'</b></font>'); |
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
|
} |
</td>
|
} |
<td class="LC_docs_entry_title">
|
} |
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
|
} |
</td>";
|
|
if (($allowed) && ($folder!~/^supplemental/)) {
|
|
my %lt=&Apache::lonlocal::texthash(
|
# |
'hd' => 'Hidden',
|
# ----------------------------------------------------------------- List Symbs |
'ec' => 'URL hidden');
|
# |
my $enctext=
|
sub list_symbs { |
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
|
my ($r) = @_; |
my $hidtext=
|
|
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
|
$r->print(&Apache::loncommon::start_page('Symb List')); |
$line.=(<<ENDPARMS);
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); |
<td class="LC_docs_entry_parameter">
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
$form_start
|
$r->print("<pre>\n"); |
<label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
|
foreach my $res ($navmap->retrieveResources()) { |
$form_end
|
$r->print($res->compTitle()."\t".$res->symb()."\n"); |
</td>
|
} |
<td class="LC_docs_entry_parameter">
|
$r->print("\n</pre>\n"); |
$form_start
|
$r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>'); |
<label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
|
} |
$form_end
|
|
</td>
|
|
<td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
|
# |
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
|
# -------------------------------------------------------------- Verify Content |
ENDPARMS
|
# |
}
|
sub verifycontent { |
$line.="</tr>";
|
my ($r) = @_; |
return $line;
|
my $type = &Apache::loncommon::course_type(); |
}
|
my $loaderror=&Apache::lonnet::overloaderror($r); |
|
if ($loaderror) { return $loaderror; } |
=pod
|
$r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents')); |
=item tiehash()
|
$hashtied=0; |
|
undef %alreadyseen; |
tie the hash
|
%alreadyseen=(); |
|
&tiehash(); |
=cut
|
foreach (keys %hash) { |
|
if ($hash{$_}=~/\.(page|sequence)$/) { |
sub tiehash {
|
if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) { |
my ($mode)=@_;
|
$r->print('<hr /><font color="red">'. |
$hashtied=0;
|
&mt('The following sequence or page is included more than once in your '.$type.': '). |
if ($env{'request.course.fn'}) {
|
&unescape($hash{$_}).'</font><br />'. |
if ($mode eq 'write') {
|
&mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />')); |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
} |
&GDBM_WRCREAT(),0640)) {
|
} |
$hashtied=2;
|
if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$_})})) { |
}
|
&checkonthis($r,$hash{$_},0,$hash{'title_'.$1}); |
} else {
|
} |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
} |
&GDBM_READER(),0640)) {
|
&untiehash(); |
$hashtied=1;
|
$r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'. |
}
|
&mt('Return to DOCS').'</a>'); |
}
|
} |
}
|
|
}
|
|
|
# -------------------------------------------------------------- Check Versions |
sub untiehash {
|
|
if ($hashtied) { untie %hash; }
|
sub devalidateversioncache { |
$hashtied=0;
|
my $src=shift; |
return OK;
|
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. |
}
|
&Apache::lonnet::clutter($src)); |
|
} |
|
|
|
sub checkversions { |
|
my ($r) = @_; |
sub checkonthis {
|
my $type = &Apache::loncommon::course_type(); |
my ($r,$url,$level,$title)=@_;
|
$r->print(&Apache::loncommon::start_page("Check $type Document Versions")); |
$url=&unescape($url);
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions")); |
$alreadyseen{$url}=1;
|
my $header=''; |
$r->rflush();
|
my $startsel=''; |
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
|
my $monthsel=''; |
$r->print("\n<br />");
|
my $weeksel=''; |
if ($level==0) {
|
my $daysel=''; |
$r->print("<br />");
|
my $allsel=''; |
}
|
my %changes=(); |
for (my $i=0;$i<=$level*5;$i++) {
|
my $starttime=0; |
$r->print(' ');
|
my $haschanged=0; |
}
|
my %setversions=&Apache::lonnet::dump('resourceversions', |
$r->print('<a href="'.$url.'" target="cat">'.
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
($title?$title:$url).'</a> ');
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
if ($url=~/^\/res\//) {
|
|
my $result=&Apache::lonnet::repcopy(
|
$hashtied=0; |
&Apache::lonnet::filelocation('',$url));
|
&tiehash(); |
if ($result eq 'ok') {
|
my %newsetversions=(); |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
if ($env{'form.setmostrecent'}) { |
$r->rflush();
|
$haschanged=1; |
&Apache::lonnet::countacc($url);
|
foreach (keys %hash) { |
$url=~/\.(\w+)$/;
|
if ($_=~/^ids\_(\/res\/.+)$/) { |
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
|
$newsetversions{$1}='mostrecent'; |
$r->print('<br />');
|
&devalidateversioncache($1); |
$r->rflush();
|
} |
for (my $i=0;$i<=$level*5;$i++) {
|
} |
$r->print(' ');
|
} elsif ($env{'form.setcurrent'}) { |
}
|
$haschanged=1; |
$r->print('- '.&mt('Rendering:').' ');
|
foreach (keys %hash) { |
my ($errorcount,$warningcount)=split(/:/,
|
if ($_=~/^ids\_(\/res\/.+)$/) { |
&Apache::lonnet::ssi_body($url,
|
my $getvers=&Apache::lonnet::getversion($1); |
('grade_target'=>'web',
|
if ($getvers>0) { |
'return_only_error_and_warning_counts' => 1)));
|
$newsetversions{$1}=$getvers; |
if (($errorcount) ||
|
&devalidateversioncache($1); |
($warningcount)) {
|
} |
if ($errorcount) {
|
} |
$r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
|
} |
&mt('[quant,_1,error]',$errorcount).'</span>');
|
} elsif ($env{'form.setversions'}) { |
}
|
$haschanged=1; |
if ($warningcount) {
|
foreach (keys %env) { |
$r->print('<span class="LC_warning">'.
|
if ($_=~/^form\.set_version_(.+)$/) { |
&mt('[quant,_1,warning]',$warningcount).'</span>');
|
my $src=$1; |
}
|
if (($env{$_}) && ($env{$_} ne $setversions{$src})) { |
} else {
|
$newsetversions{$src}=$env{$_}; |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
&devalidateversioncache($src); |
}
|
} |
$r->rflush();
|
} |
}
|
} |
my $dependencies=
|
} |
&Apache::lonnet::metadata($url,'dependencies');
|
if ($haschanged) { |
foreach my $dep (split(/\,/,$dependencies)) {
|
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
&checkonthis($r,$dep,$level+1);
|
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
}
|
$r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>'); |
}
|
} else { |
} elsif ($result eq 'unavailable') {
|
$r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>'); |
$r->print('<span class="LC_error">'.&mt('connection down').'</span>');
|
} |
} elsif ($result eq 'not_found') {
|
&mark_hash_old(); |
unless ($url=~/\$/) {
|
} |
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
|
&changewarning($r,''); |
} else {
|
if ($env{'form.timerange'} eq 'all') { |
$r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
|
# show all documents |
}
|
$header=&mt('All Documents in '.$type); |
} else {
|
$allsel=1; |
$r->print('<span class="LC_error">'.&mt('access denied').'</span>');
|
foreach (keys %hash) { |
}
|
if ($_=~/^ids\_(\/res\/.+)$/) { |
}
|
my $src=$1; |
}
|
$changes{$src}=1; |
}
|
} |
|
} |
|
} else { |
|
# show documents which changed |
=pod
|
%changes=&Apache::lonnet::dump |
|
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'}, |
=item list_symbs()
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
my $firstkey=(keys %changes)[0]; |
List Symbs
|
unless ($firstkey=~/^error\:/) { |
|
unless ($env{'form.timerange'}) { |
=cut
|
$env{'form.timerange'}=604800; |
|
} |
sub list_symbs {
|
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' ' |
my ($r) = @_;
|
.&mt('seconds'); |
|
if ($env{'form.timerange'}==-1) { |
my $type = &Apache::loncommon::course_type();
|
$seltext='since start of course'; |
$r->print(&Apache::loncommon::start_page('Symb List'));
|
$startsel='selected'; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
|
$env{'form.timerange'}=time; |
my $navmap = Apache::lonnavmaps::navmap->new();
|
} |
if (!defined($navmap)) {
|
$starttime=time-$env{'form.timerange'}; |
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
|
if ($env{'form.timerange'}==2592000) { |
'<div class="LC_error">'.
|
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
&mt('Unable to retrieve information about course contents').
|
$monthsel='selected'; |
'</div>');
|
} elsif ($env{'form.timerange'}==604800) { |
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
} else {
|
$weeksel='selected'; |
$r->print("<pre>\n");
|
} elsif ($env{'form.timerange'}==86400) { |
foreach my $res ($navmap->retrieveResources()) {
|
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
$r->print($res->compTitle()."\t".$res->symb()."\n");
|
$daysel='selected'; |
}
|
} |
$r->print("\n</pre>\n");
|
$header=&mt('Content changed').' '.$seltext; |
}
|
} else { |
$r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
|
$header=&mt('No content modifications yet.'); |
}
|
} |
|
} |
|
%setversions=&Apache::lonnet::dump('resourceversions', |
sub verifycontent {
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
my ($r) = @_;
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
my $type = &Apache::loncommon::course_type();
|
my %lt=&Apache::lonlocal::texthash |
my $loaderror=&Apache::lonnet::overloaderror($r);
|
('st' => 'Version changes since start of '.$type, |
if ($loaderror) { return $loaderror; }
|
'lm' => 'Version changes since last Month', |
$r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
|
'lw' => 'Version changes since last Week', |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
|
'sy' => 'Version changes since Yesterday', |
$hashtied=0;
|
'al' => 'All Resources (possibly large output)', |
undef %alreadyseen;
|
'sd' => 'Display', |
%alreadyseen=();
|
'fi' => 'File', |
&tiehash();
|
'md' => 'Modification Date', |
foreach my $key (keys(%hash)) {
|
'mr' => 'Most recently published Version', |
if ($hash{$key}=~/\.(page|sequence)$/) {
|
've' => 'Version used in '.$type, |
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
|
'vu' => 'Set Version to be used in '.$type, |
$r->print('<hr /><span class="LC_error">'.
|
'sv' => 'Set Versions to be used in '.$type.' according to Selections below', |
&mt('The following sequence or page is included more than once in your '.$type.': ').
|
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', |
&unescape($hash{$key}).'</span><br />'.
|
'sc' => 'Set all Resource Versions to current Version (Fix Versions)', |
&mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
|
'di' => 'Differences'); |
}
|
$r->print(<<ENDHEADERS); |
}
|
<form action="/adm/coursedocs" method="post"> |
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
|
<input type="hidden" name="versions" value="1" /> |
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
|
<input type="submit" name="setmostrecent" value="$lt{'sm'}" /> |
}
|
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr /> |
}
|
<select name="timerange"> |
&untiehash();
|
<option value='all' $allsel>$lt{'al'}</option> |
$r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
|
<option value="-1" $startsel>$lt{'st'}</option> |
&mt('Return to DOCS').'</a>');
|
<option value="2592000" $monthsel>$lt{'lm'}</option> |
}
|
<option value="604800" $weeksel>$lt{'lw'}</option> |
|
<option value="86400" $daysel>$lt{'sy'}</option> |
|
</select> |
sub devalidateversioncache {
|
<input type="submit" name="display" value="$lt{'sd'}" /> |
my $src=shift;
|
<h3>$header</h3> |
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
|
<input type="submit" name="setversions" value="$lt{'sv'}" /> |
&Apache::lonnet::clutter($src));
|
<table border="0"> |
}
|
ENDHEADERS |
|
foreach (sort keys %changes) { |
sub checkversions {
|
if ($changes{$_}>$starttime) { |
my ($r) = @_;
|
my ($root,$extension)=($_=~/^(.*)\.(\w+)$/); |
my $type = &Apache::loncommon::course_type();
|
my $currentversion=&Apache::lonnet::getversion($_); |
$r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
|
if ($currentversion<0) { |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
|
$currentversion=&mt('Could not be determined.'); |
my $header='';
|
} |
my $startsel='';
|
my $linkurl=&Apache::lonnet::clutter($_); |
my $monthsel='';
|
$r->print( |
my $weeksel='';
|
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'. |
my $daysel='';
|
&Apache::lonnet::gettitle($linkurl). |
my $allsel='';
|
'</b></font></td></tr>'. |
my %changes=();
|
'<tr><td> </td>'. |
my $starttime=0;
|
'<td colspan="4">'. |
my $haschanged=0;
|
'<a href="'.$linkurl.'" target="cat">'.$linkurl. |
my %setversions=&Apache::lonnet::dump('resourceversions',
|
'</a></td></tr>'. |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
'<tr><td></td>'. |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
'<td title="'.$lt{'md'}.'">'. |
|
&Apache::lonlocal::locallocaltime( |
$hashtied=0;
|
&Apache::lonnet::metadata($root.'.'.$extension, |
&tiehash();
|
'lastrevisiondate') |
my %newsetversions=();
|
). |
if ($env{'form.setmostrecent'}) {
|
'</td>'. |
$haschanged=1;
|
'<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '. |
foreach my $key (keys(%hash)) {
|
'<font size="+1">'.$currentversion.'</font>'. |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
'</nobr></td>'. |
$newsetversions{$1}='mostrecent';
|
'<td title="'.$lt{'ve'}.'"><nobr>In '.$type.': '. |
&devalidateversioncache($1);
|
'<font size="+1">'); |
}
|
# Used in course |
}
|
my $usedversion=$hash{'version_'.$linkurl}; |
} elsif ($env{'form.setcurrent'}) {
|
if (($usedversion) && ($usedversion ne 'mostrecent')) { |
$haschanged=1;
|
$r->print($usedversion); |
foreach my $key (keys(%hash)) {
|
} else { |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
$r->print($currentversion); |
my $getvers=&Apache::lonnet::getversion($1);
|
} |
if ($getvers>0) {
|
$r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'. |
$newsetversions{$1}=$getvers;
|
'<nobr>Use: '); |
&devalidateversioncache($1);
|
# Set version |
}
|
$r->print(&Apache::loncommon::select_form($setversions{$linkurl}, |
}
|
'set_version_'.$linkurl, |
}
|
('select_form_order' => |
} elsif ($env{'form.setversions'}) {
|
['',1..$currentversion,'mostrecent'], |
$haschanged=1;
|
'' => '', |
foreach my $key (keys(%env)) {
|
'mostrecent' => 'most recent', |
if ($key=~/^form\.set_version_(.+)$/) {
|
map {$_,$_} (1..$currentversion)))); |
my $src=$1;
|
$r->print('</nobr></td></tr><tr><td></td>'); |
if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
|
my $lastold=1; |
$newsetversions{$src}=$env{$key};
|
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
&devalidateversioncache($src);
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
}
|
if (&Apache::lonnet::metadata($url,'lastrevisiondate')< |
}
|
$starttime) { |
}
|
$lastold=$prevvers; |
}
|
} |
if ($haschanged) {
|
} |
if (&Apache::lonnet::put('resourceversions',\%newsetversions,
|
# |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
# Code to figure out how many version entries should go in |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
|
# each of the four columns |
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>');
|
my $entries_per_col = 0; |
} else {
|
my $num_entries = ($currentversion-$lastold); |
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>');
|
if ($num_entries % 4 == 0) { |
}
|
$entries_per_col = $num_entries/4; |
&mark_hash_old();
|
} else { |
}
|
$entries_per_col = $num_entries/4 + 1; |
&changewarning($r,'');
|
} |
if ($env{'form.timerange'} eq 'all') {
|
my $entries_count = 0; |
# show all documents
|
$r->print('<td valign="top"><font size="-2">'); |
$header=&mt('All Documents in '.$type);
|
my $cols_output = 1; |
$allsel=1;
|
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { |
foreach my $key (keys(%hash)) {
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
$r->print('<nobr><a href="'.&Apache::lonnet::clutter($url). |
my $src=$1;
|
'">'.&mt('Version').' '.$prevvers.'</a> ('. |
$changes{$src}=1;
|
&Apache::lonlocal::locallocaltime( |
}
|
&Apache::lonnet::metadata($url, |
}
|
'lastrevisiondate') |
} else {
|
). |
# show documents which changed
|
')'); |
%changes=&Apache::lonnet::dump
|
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { |
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
|
$r->print(' <a href="/adm/diff?filename='. |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
&Apache::lonnet::clutter($root.'.'.$extension). |
my $firstkey=(keys(%changes))[0];
|
'&versionone='.$prevvers. |
unless ($firstkey=~/^error\:/) {
|
'">'.&mt('Diffs').'</a>'); |
unless ($env{'form.timerange'}) {
|
} |
$env{'form.timerange'}=604800;
|
$r->print('</nobr><br />'); |
}
|
if (++$entries_count % $entries_per_col == 0) { |
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
|
$r->print('</font></td>'); |
.&mt('seconds');
|
if ($cols_output != 4) { |
if ($env{'form.timerange'}==-1) {
|
$r->print('<td valign="top"><font size="-2">'); |
$seltext='since start of course';
|
$cols_output++; |
$startsel='selected';
|
} |
$env{'form.timerange'}=time;
|
} |
}
|
} |
$starttime=time-$env{'form.timerange'};
|
while($cols_output++ < 4) { |
if ($env{'form.timerange'}==2592000) {
|
$r->print('</font></td><td><font>') |
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
} |
$monthsel='selected';
|
$r->print('</font></td></tr>'."\n"); |
} elsif ($env{'form.timerange'}==604800) {
|
} |
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
} |
$weeksel='selected';
|
$r->print('</table></form>'); |
} elsif ($env{'form.timerange'}==86400) {
|
$r->print('<h1>'.&mt('Done').'.</h1>'); |
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
|
$daysel='selected';
|
&untiehash(); |
}
|
} |
$header=&mt('Content changed').' '.$seltext;
|
|
} else {
|
sub mark_hash_old { |
$header=&mt('No content modifications yet.');
|
my $retie_hash=0; |
}
|
if ($hashtied) { |
}
|
$retie_hash=1; |
%setversions=&Apache::lonnet::dump('resourceversions',
|
&untiehash(); |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
} |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
&tiehash('write'); |
my %lt=&Apache::lonlocal::texthash
|
$hash{'old'}=1; |
('st' => 'Version changes since start of '.$type,
|
&untiehash(); |
'lm' => 'Version changes since last Month',
|
if ($retie_hash) { &tiehash(); } |
'lw' => 'Version changes since last Week',
|
} |
'sy' => 'Version changes since Yesterday',
|
|
'al' => 'All Resources (possibly large output)',
|
sub is_hash_old { |
'sd' => 'Display',
|
my $untie_hash=0; |
'fi' => 'File',
|
if (!$hashtied) { |
'md' => 'Modification Date',
|
$untie_hash=1; |
'mr' => 'Most recently published Version',
|
&tiehash(); |
've' => 'Version used in '.$type,
|
} |
'vu' => 'Set Version to be used in '.$type,
|
my $return=$hash{'old'}; |
'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
|
if ($untie_hash) { &untiehash(); } |
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
|
return $return; |
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
|
} |
'di' => 'Differences');
|
|
$r->print(<<ENDHEADERS);
|
sub changewarning { |
<form action="/adm/coursedocs" method="post">
|
my ($r,$postexec,$message,$url)=@_; |
<input type="hidden" name="versions" value="1" />
|
if (!&is_hash_old()) { return; } |
<input type="submit" name="setmostrecent" value="$lt{'sm'}" />
|
my $pathvar='folderpath'; |
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
|
my $path=&escape($env{'form.folderpath'}); |
<select name="timerange">
|
if (!defined($url)) { |
<option value='all' $allsel>$lt{'al'}</option>
|
if (defined($env{'form.pagepath'})) { |
<option value="-1" $startsel>$lt{'st'}</option>
|
$pathvar='pagepath'; |
<option value="2592000" $monthsel>$lt{'lm'}</option>
|
$path=&escape($env{'form.pagepath'}); |
<option value="604800" $weeksel>$lt{'lw'}</option>
|
$path.='&pagesymb='.&escape($env{'form.pagesymb'}); |
<option value="86400" $daysel>$lt{'sy'}</option>
|
} |
</select>
|
$url='/adm/coursedocs?'.$pathvar.'='.$path; |
<input type="submit" name="display" value="$lt{'sd'}" />
|
} |
<h3>$header</h3>
|
my $course_type = &Apache::loncommon::course_type(); |
<input type="submit" name="setversions" value="$lt{'sv'}" />
|
if (!defined($message)) { |
<table border="0">
|
$message='Changes will become active for your current session after [_1], or the next time you log in.'; |
ENDHEADERS
|
} |
foreach my $key (sort(keys(%changes))) {
|
$r->print("\n\n". |
if ($changes{$key}>$starttime) {
|
'<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n". |
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
|
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'. |
my $currentversion=&Apache::lonnet::getversion($key);
|
'<input type="hidden" name="orgurl" value="'.$url. |
if ($currentversion<0) {
|
'" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'. |
$currentversion=&mt('Could not be determined.');
|
&mt($message,' <input type="hidden" name="'. |
}
|
$env{'request.role'}.'" value="1" /><input type="button" value="'. |
my $linkurl=&Apache::lonnet::clutter($key);
|
&mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />'). |
$r->print(
|
$help{'Caching'}.'</font></h3></form>'."\n\n"); |
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
|
} |
&Apache::lonnet::gettitle($linkurl).
|
|
'</b></font></td></tr>'.
|
# =========================================== Breadcrumbs for special functions |
'<tr><td> </td>'.
|
|
'<td colspan="4">'.
|
sub init_breadcrumbs { |
'<a href="'.$linkurl.'" target="cat">'.$linkurl.
|
my ($form,$text)=@_; |
'</a></td></tr>'.
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
'<tr><td></td>'.
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs", |
'<td title="'.$lt{'md'}.'">'.
|
text=>&Apache::loncommon::course_type()." Documents", |
&Apache::lonlocal::locallocaltime(
|
faq=>273, |
&Apache::lonnet::metadata($root.'.'.$extension,
|
bug=>'Instructor Interface', |
'lastrevisiondate')
|
help => 'Docs_Adding_Course_Doc'}); |
).
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1', |
'</td>'.
|
text=>$text, |
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
|
faq=>273, |
'<font size="+1">'.$currentversion.'</font>'.
|
bug=>'Instructor Interface'}); |
'</span></td>'.
|
} |
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
|
|
'<font size="+1">');
|
# ================================================================ Main Handler |
# Used in course
|
sub handler { |
my $usedversion=$hash{'version_'.$linkurl};
|
my $r = shift; |
if (($usedversion) && ($usedversion ne 'mostrecent')) {
|
&Apache::loncommon::content_type($r,'text/html'); |
$r->print($usedversion);
|
$r->send_http_header; |
} else {
|
return OK if $r->header_only; |
$r->print($currentversion);
|
my $type = &Apache::loncommon::course_type(); |
}
|
|
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'.
|
# --------------------------------------------- Initialize help topics for this |
'<span class="LC_nobreak">Use: ');
|
foreach ('Adding_Course_Doc','Main_Course_Documents', |
# Set version
|
'Adding_External_Resource','Navigate_Content', |
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
|
'Adding_Folders','Docs_Overview', 'Load_Map', |
'set_version_'.$linkurl,
|
'Supplemental','Score_Upload_Form','Adding_Pages', |
('select_form_order' =>
|
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', |
['',1..$currentversion,'mostrecent'],
|
'Check_Resource_Versions','Verify_Content') { |
'' => '',
|
$help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); |
'mostrecent' => 'most recent',
|
} |
map {$_,$_} (1..$currentversion))));
|
# Composite help files |
$r->print('</span></td></tr><tr><td></td>');
|
$help{'Syllabus'} = &Apache::loncommon::help_open_topic( |
my $lastold=1;
|
'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
|
$help{'Simple Page'} = &Apache::loncommon::help_open_topic( |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); |
if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
|
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic( |
$starttime) {
|
'Option_Response_Simple'); |
$lastold=$prevvers;
|
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( |
}
|
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); |
}
|
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic( |
#
|
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); |
# Code to figure out how many version entries should go in
|
$help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
# each of the four columns
|
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
my $entries_per_col = 0;
|
|
my $num_entries = ($currentversion-$lastold);
|
# does this user have privileges to modify docs |
if ($num_entries % 4 == 0) {
|
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
$entries_per_col = $num_entries/4;
|
if ($allowed && $env{'form.verify'}) { |
} else {
|
&init_breadcrumbs('verify','Verify Content'); |
$entries_per_col = $num_entries/4 + 1;
|
&verifycontent($r); |
}
|
} elsif ($allowed && $env{'form.listsymbs'}) { |
my $entries_count = 0;
|
&init_breadcrumbs('listsymbs','List Symbs'); |
$r->print('<td valign="top"><font size="-2">');
|
&list_symbs($r); |
my $cols_output = 1;
|
} elsif ($allowed && $env{'form.docslog'}) { |
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
|
&init_breadcrumbs('docslog','Show Log'); |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
&docs_change_log($r); |
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
|
} elsif ($allowed && $env{'form.versions'}) { |
'">'.&mt('Version').' '.$prevvers.'</a> ('.
|
&init_breadcrumbs('versions','Check/Set Resource Versions'); |
&Apache::lonlocal::locallocaltime(
|
&checkversions($r); |
&Apache::lonnet::metadata($url,
|
} elsif ($allowed && $env{'form.dumpcourse'}) { |
'lastrevisiondate')
|
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space'); |
).
|
&dumpcourse($r); |
')');
|
} elsif ($allowed && $env{'form.exportcourse'}) { |
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
|
&init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS'); |
$r->print(' <a href="/adm/diff?filename='.
|
&exportcourse($r); |
&Apache::lonnet::clutter($root.'.'.$extension).
|
} else { |
'&versionone='.$prevvers.
|
# is this a standard course? |
'">'.&mt('Diffs').'</a>');
|
|
}
|
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//); |
$r->print('</span><br />');
|
my $forcestandard = 0; |
if (++$entries_count % $entries_per_col == 0) {
|
my $forcesupplement; |
$r->print('</font></td>');
|
my $script=''; |
if ($cols_output != 4) {
|
my $showdoc=0; |
$r->print('<td valign="top"><font size="-2">');
|
my $containertag; |
$cols_output++;
|
my $uploadtag; |
}
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
}
|
['folderpath','pagepath', |
}
|
'pagesymb','markedcopy_url', |
while($cols_output++ < 4) {
|
'markedcopy_title']); |
$r->print('</font></td><td><font>')
|
if ($env{'form.folderpath'}) { |
}
|
my (@folderpath)=split('&',$env{'form.folderpath'}); |
$r->print('</font></td></tr>'."\n");
|
$env{'form.foldername'}=&unescape(pop(@folderpath)); |
}
|
$env{'form.folder'}=pop(@folderpath); |
}
|
} |
$r->print('</table></form>');
|
if ($env{'form.pagepath'}) { |
$r->print('<h1>'.&mt('Done').'.</h1>');
|
my (@pagepath)=split('&',$env{'form.pagepath'}); |
|
$env{'form.pagename'}=&unescape(pop(@pagepath)); |
&untiehash();
|
$env{'form.folder'}=pop(@pagepath); |
}
|
$containertag = '<input type="hidden" name="pagepath" value="" />'. |
|
'<input type="hidden" name="pagesymb" value="" />'; |
sub mark_hash_old {
|
$uploadtag = '<input type="hidden" name="pagepath" value="'.$env{'form.pagepath'}.'" />'. |
my $retie_hash=0;
|
'<input type="hidden" name="pagesymb" value="'.$env{'form.pagesymb'}.'" />'; |
if ($hashtied) {
|
} |
$retie_hash=1;
|
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { |
&untiehash();
|
$showdoc='/'.$1; |
}
|
} |
&tiehash('write');
|
unless ($showdoc) { # got called from remote |
$hash{'old'}=1;
|
if (($env{'form.folder'}=~/^(?:group|default)_/) || |
&untiehash();
|
($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) { |
if ($retie_hash) { &tiehash(); }
|
$forcestandard = 1; |
}
|
} |
|
$forcesupplement=($env{'form.folder'}=~/^supplemental_/); |
sub is_hash_old {
|
|
my $untie_hash=0;
|
if ($allowed) { |
if (!$hashtied) {
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); |
$untie_hash=1;
|
$script=&Apache::lonratedt::editscript('simple'); |
&tiehash();
|
} |
}
|
} else { # got called in sequence from course |
my $return=$hash{'old'};
|
$allowed=0; |
if ($untie_hash) { &untiehash(); }
|
} |
return $return;
|
|
}
|
# get course data |
|
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
sub changewarning {
|
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my ($r,$postexec,$message,$url)=@_;
|
|
if (!&is_hash_old()) { return; }
|
# get personal data |
my $pathvar='folderpath';
|
my $uname=$env{'user.name'}; |
my $path=&escape($env{'form.folderpath'});
|
my $udom=$env{'user.domain'}; |
if (!defined($url)) {
|
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom)); |
if (defined($env{'form.pagepath'})) {
|
|
$pathvar='pagepath';
|
# graphics settings |
$path=&escape($env{'form.pagepath'});
|
|
$path.='&pagesymb='.&escape($env{'form.pagesymb'});
|
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); |
}
|
|
$url='/adm/coursedocs?'.$pathvar.'='.$path;
|
if ($allowed) { |
}
|
$script .= &editing_js($udom,$uname); |
my $course_type = &Apache::loncommon::course_type();
|
} |
if (!defined($message)) {
|
# -------------------------------------------------------------------- Body tag |
$message='Changes will become active for your current session after [_1], or the next time you log in.';
|
$script = '<script type="text/javascript">'."\n".$script."\n".'</script>'; |
}
|
$r->print(&Apache::loncommon::start_page("$type Documents", $script, |
$r->print("\n\n".
|
{'force_register' => $showdoc,}). |
'<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
|
&Apache::loncommon::help_open_menu('','',273,'RAT')); |
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
|
|
'<input type="hidden" name="orgurl" value="'.$url.
|
my %allfiles = (); |
'" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
|
my %codebase = (); |
&mt($message,' <input type="hidden" name="'.
|
my ($upload_result,$upload_output); |
$env{'request.role'}.'" value="1" /><input type="button" value="'.
|
if ($allowed) { |
&mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
|
if (($env{'form.uploaddoc.filename'}) && |
$help{'Caching'}.'</span></h3></form>'."\n\n");
|
($env{'form.cmd'}=~/^upload_(\w+)/)) { |
}
|
# Process file upload - phase one - upload and parse primary file. |
|
$upload_result = &process_file_upload(\$upload_output,$coursenum, |
|
$coursedom,\%allfiles, |
sub init_breadcrumbs {
|
\%codebase,$1); |
my ($form,$text)=@_;
|
if ($upload_result eq 'phasetwo') { |
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
$r->print($upload_output); |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
|
} |
text=>"Edit ".&Apache::loncommon::course_type(),
|
} elsif ($env{'form.phasetwo'}) { |
faq=>273,
|
my %newname = (); |
bug=>'Instructor Interface',
|
my %origname = (); |
help => 'Docs_Adding_Course_Doc'});
|
my %attribs = (); |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
|
my $updateflag = 0; |
text=>$text,
|
my $residx = $env{'form.newidx'}; |
faq=>273,
|
my $primary_url = &unescape($env{'form.primaryurl'}); |
bug=>'Instructor Interface'});
|
# Process file upload - phase two - gather secondary files. |
}
|
for (my $i=0; $i<$env{'form.phasetwo'}; $i++) { |
|
if ($env{'form.embedded_item_'.$i.'.filename'}) { |
|
my $javacodebase; |
|
$newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx); |
|
$origname{$i} = &unescape($env{'form.embedded_orig_'.$i}); |
sub handler {
|
if (exists($env{'form.embedded_codebase_'.$i})) { |
my $r = shift;
|
$javacodebase = &unescape($env{'form.embedded_codebase_'.$i}); |
&Apache::loncommon::content_type($r,'text/html');
|
$origname{$i} =~ s#^\Q$javacodebase\E/##; |
$r->send_http_header;
|
} |
return OK if $r->header_only;
|
my @attributes = (); |
my $type = &Apache::loncommon::course_type();
|
if ($env{'form.embedded_attrib_'.$i} =~ /:/) { |
|
@attributes = split/:/,$env{'form.embedded_attrib_'.$i}; |
|
} else { |
# --------------------------------------------- Initialize help topics for this
|
@attributes = ($env{'form.embedded_attrib_'.$i}); |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
|
} |
'Adding_External_Resource','Navigate_Content',
|
foreach (@attributes) { |
'Adding_Folders','Docs_Overview', 'Load_Map',
|
push(@{$attribs{$i}},&unescape($_)); |
'Supplemental','Score_Upload_Form','Adding_Pages',
|
} |
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
|
if ($javacodebase) { |
'Check_Resource_Versions','Verify_Content') {
|
$codebase{$i} = $javacodebase; |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
|
$codebase{$i} =~ s#/$##; |
}
|
$updateflag = 1; |
# Composite help files
|
} |
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
|
} |
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
|
unless ($newname{$i} eq $origname{$i}) { |
$help{'Simple Page'} = &Apache::loncommon::help_open_topic(
|
$updateflag = 1; |
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
|
} |
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
|
} |
'Option_Response_Simple');
|
# Process file upload - phase three - modify primary file |
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
|
if ($updateflag) { |
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
|
my ($content,$rtncode); |
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
|
my $updateflag = 0; |
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
|
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode); |
$help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
|
if ($getstatus eq 'ok') { |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
|
foreach my $item (keys %newname) { |
|
if ($newname{$item} ne $origname{$item}) { |
# does this user have privileges to modify docs
|
my $attrib_regexp = ''; |
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
|
if (@{$attribs{$item}} > 1) { |
if ($allowed && $env{'form.verify'}) {
|
$attrib_regexp = join('|',@{$attribs{$item}}); |
&init_breadcrumbs('verify','Verify Content');
|
} else { |
&verifycontent($r);
|
$attrib_regexp = $attribs{$item}[0]; |
} elsif ($allowed && $env{'form.listsymbs'}) {
|
} |
&init_breadcrumbs('listsymbs','List Symbs');
|
if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) { |
&list_symbs($r);
|
} |
} elsif ($allowed && $env{'form.docslog'}) {
|
$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi; |
&init_breadcrumbs('docslog','Show Log');
|
} |
&docs_change_log($r);
|
if (exists($codebase{$item})) { |
} elsif ($allowed && $env{'form.versions'}) {
|
$content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs |
&init_breadcrumbs('versions','Check/Set Resource Versions');
|
} |
&checkversions($r);
|
} |
} elsif ($allowed && $env{'form.dumpcourse'}) {
|
# Save edited file. |
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
|
my $saveresult; |
&dumpcourse($r);
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
} elsif ($allowed && $env{'form.exportcourse'}) {
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
&init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
|
my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult); |
&exportcourse($r);
|
} else { |
} else {
|
&Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus); |
# is this a standard course?
|
} |
|
} |
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
|
} |
my $forcestandard = 0;
|
} |
my $forcesupplement;
|
|
my $script='';
|
unless ($showdoc || $upload_result eq 'phasetwo') { |
my $showdoc=0;
|
# ----------------------------------------------------------------------------- |
my $containertag;
|
my %lt=&Apache::lonlocal::texthash( |
my $uploadtag;
|
'uplm' => 'Upload a new main '.lc($type).' document', |
|
'upls' => 'Upload a new supplemental '.lc($type).' document', |
|
'impp' => 'Import a document', |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
'pubd' => 'Published documents', |
['folderpath','pagepath',
|
'copm' => 'All documents out of a published map into this folder', |
'pagesymb']);
|
'spec' => 'Special documents', |
# No folderpath, no pagepath, see if we have something stored
|
'upld' => 'Upload Document', |
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
|
'srch' => 'Search', |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
'impo' => 'Import', |
{'folderpath' => 'scalar'});
|
'book' => 'Import Bookmarks', |
}
|
'selm' => 'Select Map', |
if (!$env{'form.folderpath'}) {
|
'load' => 'Load Map', |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
'reco' => 'Recover Deleted Resources', |
{'pagepath' => 'scalar'});
|
'newf' => 'New Folder', |
}
|
'newp' => 'New Composite Page', |
if ($env{'form.pagepath'}) {
|
'extr' => 'External Resource', |
$env{'form.folderpath'}='';
|
'syll' => 'Syllabus', |
}
|
'navc' => 'Navigate Contents', |
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
|
'sipa' => 'Simple Page', |
$env{'form.folderpath'} = 'supplemental&'.
|
'sipr' => 'Simple Problem', |
&escape(&mt('Supplemental '.$type.' Documents')).'&'.
|
'drbx' => 'Drop Box', |
$env{'form.folderpath'};
|
'scuf' => 'Score Upload Form', |
}
|
'bull' => 'Bulletin Board', |
&Apache::loncommon::store_course_settings('docs_folderpath',
|
'mypi' => 'My Personal Info', |
{'pagepath' => 'scalar',
|
'grpo' => 'Group Files', |
'folderpath' => 'scalar'});
|
'abou' => 'About User', |
if ($env{'form.folderpath'}) {
|
'imsf' => 'Import IMS package', |
my (@folderpath)=split('&',$env{'form.folderpath'});
|
'file' => 'File', |
$env{'form.foldername'}=&unescape(pop(@folderpath));
|
'title' => 'Title', |
$env{'form.folder'}=pop(@folderpath);
|
'comment' => 'Comment', |
}
|
'parse' => 'If HTML file, upload embedded images/multimedia files' |
if ($env{'form.pagepath'}) {
|
); |
my (@pagepath)=split('&',$env{'form.pagepath'});
|
# ----------------------------------------------------------------------------- |
$env{'form.pagename'}=&unescape(pop(@pagepath));
|
if ($allowed) { |
$env{'form.folder'}=pop(@pagepath);
|
my $dumpbut=&dumpbutton(); |
$containertag = '<input type="hidden" name="pagepath" value="" />'.
|
my $exportbut=&exportbutton(); |
'<input type="hidden" name="pagesymb" value="" />';
|
my %lt=&Apache::lonlocal::texthash( |
$uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
|
'vc' => 'Verify Content', |
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
|
'cv' => 'Check/Set Resource Versions', |
}
|
'ls' => 'List Symbs', |
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
|
'sl' => 'Show Log' |
$showdoc='/'.$1;
|
); |
}
|
|
unless ($showdoc) { # got called from remote
|
my $folderpath=$env{'form.folderpath'}; |
if (($env{'form.folder'}=~/^(?:group|default)_/) ||
|
if (!$folderpath) { |
($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
|
if ($env{'form.folder'} eq '' || |
$forcestandard = 1;
|
$env{'form.folder'} eq 'supplemental') { |
}
|
$folderpath='default&'. |
$forcesupplement=($env{'form.folder'}=~/^supplemental_/);
|
&escape(&mt('Main '.$type.' Documents')); |
|
} |
if ($allowed) {
|
} |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
|
unless ($env{'form.pagepath'}) { |
$script=&Apache::lonratedt::editscript('simple');
|
$containertag = '<input type="hidden" name="folderpath" value="" />'; |
}
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.$folderpath.'" />'; |
} else { # got called in sequence from course
|
} |
$allowed=0;
|
|
}
|
$r->print(<<ENDCOURSEVERIFY); |
|
<form name="renameform" method="post" action="/adm/coursedocs"> |
# get course data
|
<input type="hidden" name="title" /> |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
|
<input type="hidden" name="cmd" /> |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
<input type="hidden" name="markcopy" /> |
|
$containertag |
# get personal data
|
</form> |
my $uname=$env{'user.name'};
|
<form name="simpleedit" method="post" action="/adm/coursedocs"> |
my $udom=$env{'user.domain'};
|
<input type="hidden" name="importdetail" value="" /> |
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
|
$uploadtag |
|
</form> |
# graphics settings
|
<form action="/adm/coursedocs" method="post" name="courseverify"> |
|
<table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4"> |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
|
<tr><td bgcolor="#DDDDCC"> |
|
<input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'} |
if ($allowed) {
|
</td><td bgcolor="#DDDDCC"> |
$script .= &editing_js($udom,$uname);
|
<input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'} |
}
|
$dumpbut |
# -------------------------------------------------------------------- Body tag
|
$exportbut |
$script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
|
</td><td bgcolor="#DDDDCC"> |
my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
|
<input type="submit" name="listsymbs" value="$lt{'ls'}" /> |
$r->print(&Apache::loncommon::start_page("$type Documents", $script,
|
</td><td bgcolor="#DDDDCC"> |
{'force_register' => $showdoc,
|
<input type="hidden" name="folder" value="$env{'form.folder'}" /> |
'bread_crumbs' => $brcrum}).
|
<input type="submit" name="docslog" value="$lt{'sl'}" /> |
&Apache::loncommon::help_open_menu('','',273,'RAT'));
|
</td></tr></table> |
|
</form> |
my %allfiles = ();
|
ENDCOURSEVERIFY |
my %codebase = ();
|
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', |
my ($upload_result,$upload_output);
|
&mt('Editing the Table of Contents for your '.$type))); |
if ($allowed) {
|
} |
if (($env{'form.uploaddoc.filename'}) &&
|
# --------------------------------------------------------- Standard documents |
($env{'form.cmd'}=~/^upload_(\w+)/)) {
|
$r->print('<table border=2 cellspacing=4 cellpadding=4>'); |
# Process file upload - phase one - upload and parse primary file.
|
if (($standard) && ($allowed) && (!$forcesupplement)) { |
undef($hadchanges);
|
$r->print('<tr><td bgcolor="#BBBBBB">'); |
$upload_result = &process_file_upload(\$upload_output,$coursenum,
|
# '<h2>'.&mt('Main Course Documents'). |
$coursedom,\%allfiles,
|
# ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>'); |
\%codebase,$1);
|
my $folder=$env{'form.folder'}; |
if ($hadchanges) {
|
if ($folder eq '' || $folder eq 'supplemental') { |
&mark_hash_old();
|
$folder='default'; |
}
|
$env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents')); |
if ($upload_result eq 'phasetwo') {
|
} |
$r->print($upload_output);
|
my $postexec=''; |
}
|
if ($folder eq 'default') { |
} elsif ($env{'form.phasetwo'}) {
|
$r->print('<script>this.window.name="loncapaclient";</script>'); |
my %newname = ();
|
} else { |
my %origname = ();
|
#$postexec='self.close();'; |
my %attribs = ();
|
} |
my $updateflag = 0;
|
$hadchanges=0; |
my $residx = $env{'form.newidx'};
|
&editor($r,$coursenum,$coursedom,$folder,$allowed,$upload_output); |
my $primary_url = &unescape($env{'form.primaryurl'});
|
if ($hadchanges) { |
# Process file upload - phase two - gather secondary files.
|
&mark_hash_old() |
for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
|
} |
if ($env{'form.embedded_item_'.$i.'.filename'}) {
|
&changewarning($r,$postexec); |
my $javacodebase;
|
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
$newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
|
'.sequence'; |
$origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
|
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
if (exists($env{'form.embedded_codebase_'.$i})) {
|
'.page'; |
$javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
|
my $container='sequence'; |
$origname{$i} =~ s#^\Q$javacodebase\E/##;
|
if ($env{'form.pagepath'}) { |
}
|
$container='page'; |
my @attributes = ();
|
} |
if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
|
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; |
@attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
|
$r->print(<<ENDFORM); |
} else {
|
<table cellspacing=4 cellpadding=4><tr> |
@attributes = ($env{'form.embedded_attrib_'.$i});
|
<th bgcolor="#DDDDDD">$lt{'uplm'}</th> |
}
|
<th bgcolor="#DDDDDD">$lt{'impp'}</th> |
foreach my $attr (@attributes) {
|
<th bgcolor="#DDDDDD">$lt{'spec'}</th> |
push(@{$attribs{$i}},&unescape($attr));
|
</tr> |
}
|
<tr><td bgcolor="#DDDDDD"> |
if ($javacodebase) {
|
$lt{'file'}:<br /> |
$codebase{$i} = $javacodebase;
|
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
$codebase{$i} =~ s#/$##;
|
<input type="file" name="uploaddoc" size="40"> |
$updateflag = 1;
|
<br /> |
}
|
$lt{'title'}:<br /> |
}
|
<input type="text" size="50" name="comment"> |
unless ($newname{$i} eq $origname{$i}) {
|
$uploadtag |
$updateflag = 1;
|
<input type="hidden" name="cmd" value="upload_default"> |
}
|
<br /> |
}
|
<nobr> |
# Process file upload - phase three - modify primary file
|
<label>$lt{'parse'}? |
if ($updateflag) {
|
<input type="checkbox" name="parserflag" /> |
my ($content,$rtncode);
|
</label> |
my $updateflag = 0;
|
</nobr> |
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
|
<br /> |
if ($getstatus eq 'ok') {
|
<br /> |
foreach my $item (keys(%newname)) {
|
<nobr> |
if ($newname{$item} ne $origname{$item}) {
|
<input type="submit" value="$lt{'upld'}"> |
my $attrib_regexp = '';
|
$help{'Uploading_From_Harddrive'} |
if (@{$attribs{$item}} > 1) {
|
</nobr> |
$attrib_regexp = join('|',@{$attribs{$item}});
|
</form> |
} else {
|
</td> |
$attrib_regexp = $attribs{$item}[0];
|
<td bgcolor="#DDDDDD"> |
}
|
<form action="/adm/coursedocs" method="post" name="simpleeditdefault"> |
if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
|
$lt{'pubd'}<br /> |
}
|
$uploadtag |
$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
|
<input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}" /> |
}
|
<br /> |
if (exists($codebase{$item})) {
|
<nobr> |
$content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
|
<input type=button onClick="javascript:groupimport();" value="$lt{'impo'}" /> |
}
|
$help{'Importing_LON-CAPA_Resource'} |
}
|
</nobr> |
# Save edited file.
|
<br /> |
my $saveresult;
|
<input type=button onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" /> |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
|
<p> |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
<hr /> |
my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
|
$lt{'copm'}<br /> |
} else {
|
<input type="text" size="40" name="importmap"><br /> |
&Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
|
<nobr><input type=button |
}
|
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" |
}
|
value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}"> |
}
|
$help{'Load_Map'}</nobr> |
}
|
</p> |
|
</form> |
unless ($showdoc || $upload_result eq 'phasetwo') {
|
<hr /> |
# -----------------------------------------------------------------------------
|
<form action="/adm/groupsort" method="post" name="recover"> |
my %lt=&Apache::lonlocal::texthash(
|
<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" /> |
'uplm' => 'Upload a new main '.lc($type).' document',
|
</form> |
'upls' => 'Upload a new supplemental '.lc($type).' document',
|
ENDFORM |
'impp' => 'Import a document',
|
unless ($env{'form.pagepath'}) { |
'pubd' => 'Published Documents',
|
$r->print(<<ENDFORM); |
'copm' => 'All documents out of a published map into this folder',
|
<hr /> |
'upld' => 'Upload Document',
|
<form action="/adm/coursedocs" method="post" name="newext"> |
'srch' => 'Search',
|
$uploadtag |
'impo' => 'Import',
|
<input type="hidden" name="importdetail" value="" /> |
'book' => 'Import Bookmarks',
|
<nobr> |
'selm' => 'Select Map',
|
<input name="newext" type="button" onClick="javascript:makenewext('newext');" |
'load' => 'Load Map',
|
value="$lt{'extr'}" /> $help{'Adding_External_Resource'} |
'reco' => 'Recover Deleted Resources',
|
</nobr> |
'newf' => 'New Folder',
|
</form> |
'newp' => 'New Composite Page',
|
<br /><form action="/adm/imsimportdocs" method="post" name="ims"> |
'extr' => 'External Resource',
|
<input type="hidden" name="folder" value="$folder" /> |
'syll' => 'Syllabus',
|
<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" /> |
'navc' => 'Navigate Contents',
|
</nobr> |
'sipa' => 'Simple Page',
|
</form> |
'sipr' => 'Simple Problem',
|
ENDFORM |
'drbx' => 'Drop Box',
|
} |
'scuf' => 'Score Upload Form',
|
$r->print('</td><td bgcolor="#DDDDDD">'); |
'bull' => 'Bulletin Board',
|
unless ($env{'form.pagepath'}) { |
'mypi' => 'My Personal Info',
|
$r->print(<<ENDFORM); |
'grpo' => 'Group Files',
|
<br /><form action="/adm/coursedocs" method="post" name="newfolder"> |
'rost' => 'Course Roster',
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
'abou' => 'About User',
|
<input type="hidden" name="importdetail" value="" /> |
'imsf' => 'Import IMS package',
|
<nobr> |
'file' => 'File',
|
<input name="newfolder" type="button" |
'title' => 'Title',
|
onClick="javascript:makenewfolder(this.form,'$folderseq');" |
'comment' => 'Comment',
|
value="$lt{'newf'}" />$help{'Adding_Folders'} |
'parse' => 'Upload embedded images/multimedia files if HTML file!',
|
</nobr> |
'nd' => 'New Document',
|
</form> |
'pm' => 'Published Map',
|
<br /><form action="/adm/coursedocs" method="post" name="newpage"> |
'sd' => 'Special Document',
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
'mo' => 'More Options',
|
<input type="hidden" name="importdetail" value="" /> |
'hao' => 'Hide all Options'
|
<nobr> |
);
|
<input name="newpage" type="button" |
# -----------------------------------------------------------------------------
|
onClick="javascript:makenewpage(this.form,'$pageseq');" |
my $fileupload=(<<FIUP);
|
value="$lt{'newp'}" />$help{'Adding_Pages'} |
$lt{'file'}:<br />
|
</nobr> |
<input type="file" name="uploaddoc" size="40" />
|
</form> |
FIUP
|
<br /><form action="/adm/coursedocs" method="post" name="newsyl"> |
|
$uploadtag |
my $checkbox=(<<CHBO);
|
<input type="hidden" name="importdetail" |
<!-- <label>$lt{'parse'}?
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus" /> |
<input type="checkbox" name="parserflag" />
|
<nobr> |
</label> -->
|
<input name="newsyl" type="submit" value="$lt{'syll'}" /> |
<label>
|
$help{'Syllabus'} |
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
|
</nobr> |
</label>
|
</form> |
CHBO
|
<br /><form action="/adm/coursedocs" method="post" name="newnav"> |
|
$uploadtag |
my $fileuploadform=(<<FUFORM);
|
<input type="hidden" name="importdetail" |
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
value="Navigate Content=/adm/navmaps" /> |
$fileupload
|
<nobr> |
<br />
|
<input name="newnav" type="submit" value="$lt{'navc'}" /> |
$lt{'title'}:<br />
|
$help{'Navigate_Content'} |
<input type="text" size="50" name="comment" />
|
</nobr> |
$uploadtag
|
</form> |
<input type="hidden" name="cmd" value="upload_default" />
|
<br /><form action="/adm/coursedocs" method="post" name="newsmppg"> |
<br />
|
$uploadtag |
<span class="LC_nobreak">
|
<input type="hidden" name="importdetail" value="" /> |
$checkbox
|
<nobr> |
</span>
|
<input name="newsmppg" type="button" value="$lt{'sipa'}" |
<br />
|
onClick="javascript:makesmppage();" /> $help{'Simple Page'} |
<br />
|
</nobr> |
<span class="LC_nobreak">
|
</form> |
<input type="submit" value="$lt{'upld'}" />
|
<br /><form action="/adm/coursedocs" method="post" name="newsmpproblem"> |
$help{'Uploading_From_Harddrive'}
|
$uploadtag |
</span>
|
<input type="hidden" name="importdetail" value="" /> |
</form>
|
<nobr> |
FUFORM
|
<input name="newsmpproblem" type="button" value="$lt{'sipr'}" |
|
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'} |
my $simpleeditdefaultform=(<<SEDFFORM);
|
</nobr> |
<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
|
</form> |
$lt{'pubd'}<br />
|
<br /><form action="/adm/coursedocs" method="post" name="newdropbox"> |
$uploadtag
|
$uploadtag |
<input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
|
<input type="hidden" name="importdetail" value="" /> |
<br />
|
<nobr> |
<span class="LC_nobreak">
|
<input name="newdropbox" type="button" value="$lt{'drbx'}" |
<input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
|
onClick="javascript:makedropbox();" /> |
$help{'Importing_LON-CAPA_Resource'}
|
</nobr> |
</span>
|
</form> |
<br />
|
<br /><form action="/adm/coursedocs" method="post" name="newexamupload"> |
<input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
|
$uploadtag |
<hr />
|
<input type="hidden" name="importdetail" value="" /> |
<p>
|
<nobr> |
$lt{'copm'}<br />
|
<input name="newexamupload" type="button" value="$lt{'scuf'}" |
<input type="text" size="40" name="importmap" /><br />
|
onClick="javascript:makeexamupload();" /> |
<span class="LC_nobreak"><input type="button"
|
$help{'Score_Upload_Form'} |
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
|
</nobr> |
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
|
</form> |
$help{'Load_Map'}</span>
|
<br /><form action="/adm/coursedocs" method="post" name="newbul"> |
</p>
|
$uploadtag |
</form>
|
<input type="hidden" name="importdetail" value="" /> |
SEDFFORM
|
<nobr> |
|
<input name="newbulletin" type="button" value="$lt{'bull'}" |
my $extresourcesform=(<<ERFORM);
|
onClick="javascript:makebulboard();" /> |
<form action="/adm/coursedocs" method="post" name="newext">
|
$help{'Bulletin Board'} |
$uploadtag
|
</nobr> |
<input type="hidden" name="importdetail" value="" />
|
</form> |
<span class="LC_nobreak">
|
<br /><form action="/adm/coursedocs" method="post" name="newaboutme"> |
<input name="newext" type="button" onClick="javascript:makenewext('newext');"
|
$uploadtag |
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
<input type="hidden" name="importdetail" |
</span>
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
</form>
|
<nobr> |
ERFORM
|
<input name="newaboutme" type="submit" value="$lt{'mypi'}" /> |
|
$help{'My Personal Info'} |
if ($allowed) {
|
</nobr> |
&update_paste_buffer($coursenum,$coursedom);
|
</form> |
my $dumpbut=&dumpbutton();
|
<br /><form action="/adm/coursedocs" method="post" name="newaboutsomeone"> |
my $exportbut=&exportbutton();
|
$uploadtag |
my %lt=&Apache::lonlocal::texthash(
|
<input type="hidden" name="importdetail" value="" /> |
'vc' => 'Verify Content',
|
<nobr> |
'cv' => 'Check/Set Resource Versions',
|
<input name="newaboutsomeone" type="button" value="$lt{'abou'}" |
'ls' => 'List Symbs',
|
onClick="javascript:makeabout();" /> |
'sl' => 'Show Log'
|
</nobr> |
);
|
</form> |
|
<br /><form action="/adm/coursedocs" method="post" name="newgroupfiles"> |
my $folderpath=$env{'form.folderpath'};
|
$uploadtag |
if (!$folderpath) {
|
<input type="hidden" name="importdetail" |
if ($env{'form.folder'} eq '' ||
|
value="Group Files=/adm/$coursedom/$coursenum/aboutme" /> |
$env{'form.folder'} eq 'supplemental') {
|
<nobr> |
$folderpath='default&'.
|
<input name="newgroupfiles" type="submit" value="$lt{'grpo'}" /> |
&escape(&mt('Main '.$type.' Documents'));
|
$help{'Group Files'} |
}
|
</nobr> |
}
|
</form> |
unless ($env{'form.pagepath'}) {
|
ENDFORM |
$containertag = '<input type="hidden" name="folderpath" value="" />';
|
} |
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
|
if ($env{'form.pagepath'}) { |
}
|
$r->print(<<ENDBLOCK); |
$r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env));
|
<form action="/adm/coursedocs" method="post" name="newsmpproblem"> |
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
|
$uploadtag |
&mt('Editing the Table of Contents for your '.$type)));
|
<input type="hidden" name="importdetail" value="" /> |
}
|
<nobr> |
# --------------------------------------------------------- Standard documents
|
<input name="newsmpproblem" type="button" value="$lt{'sipr'}" |
$r->print('<table class="LC_docs_documents">');
|
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'} |
|
</nobr> |
if (($standard) && ($allowed) && (!$forcesupplement)) {
|
</form> |
$r->print('<tr><td class="LC_docs_document">');
|
<br /><form action="/adm/coursedocs" method="post" name="newexamupload"> |
# '<h2>'.&mt('Main Course Documents').
|
$uploadtag |
# ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
|
<input type="hidden" name="importdetail" value="" /> |
my $folder=$env{'form.folder'};
|
<nobr> |
if ($folder eq '' || $folder eq 'supplemental') {
|
<input name="newexamupload" type="button" value="$lt{'scuf'}" |
$folder='default';
|
onClick="javascript:makeexamupload();" /> |
$env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
|
$help{'Score_Upload_Form'} |
$uploadtag = '<input type="hidden" name="folderpath" value="'.
|
</nobr> |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
|
</form> |
}
|
ENDBLOCK |
my $postexec='';
|
} |
if ($folder eq 'default') {
|
$r->print('</td></tr>'."\n". |
$r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
|
'</table>'); |
} else {
|
$r->print('</td></tr>'); |
#$postexec='self.close();';
|
} |
}
|
# ----------------------------------------------------- Supplemental documents |
$hadchanges=0;
|
if (!$forcestandard) { |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
|
$r->print('<tr><td bgcolor="#BBBBBB">'); |
$upload_output,$type);
|
# '<h2>'.&mt('Supplemental Course Documents'). |
if ($error) {
|
# ($allowed?' '.$help{'Supplemental'}:'').'</h2>'); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
my $folder=$env{'form.folder'}; |
}
|
unless ($folder=~/^supplemental/) { |
if ($hadchanges) {
|
$folder='supplemental'; |
&mark_hash_old();
|
} |
}
|
if ($folder =~ /^supplemental$/ && |
&changewarning($r,$postexec);
|
$env{'form.folderpath'} =~ /^default\&/) { |
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
$env{'form.folderpath'}='supplemental&'. |
'.sequence';
|
&escape(&mt('Supplemental '.$type.' Documents')); |
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
} |
'.page';
|
&editor($r,$coursenum,$coursedom,$folder,$allowed); |
my $container='sequence';
|
if ($allowed) { |
if ($env{'form.pagepath'}) {
|
my $folderseq= |
$container='page';
|
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. |
}
|
'.sequence'; |
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
|
|
|
$r->print(<<ENDSUPFORM); |
|
<table cellspacing=4 cellpadding=4><tr> |
|
<th bgcolor="#DDDDDD">$lt{'upls'}</th> |
my $recoverform=(<<RFORM);
|
<th bgcolor="#DDDDDD">$lt{'spec'}</th> |
<form action="/adm/groupsort" method="post" name="recover">
|
</tr> |
<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
|
<tr><td bgcolor="#DDDDDD"> |
</form>
|
<form action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
RFORM
|
<input type="file" name="uploaddoc" size="40"> |
|
<br /> |
my $imspform=(<<IMSPFORM);
|
<br /> |
<form action="/adm/imsimportdocs" method="post" name="ims">
|
<nobr> |
<input type="hidden" name="folder" value="$folder" />
|
<label>$lt{'parse'}? |
<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
|
<input type="checkbox" name="parserflag" /> |
</form>
|
</label> |
IMSPFORM
|
</nobr> |
|
<br /><br /> |
my $newnavform=(<<NNFORM);
|
$lt{'comment'}:<br /> |
<form action="/adm/coursedocs" method="post" name="newnav">
|
<textarea cols=50 rows=4 name='comment'> |
$uploadtag
|
</textarea> |
<input type="hidden" name="importdetail"
|
<br /> |
value="$lt{'navc'}=/adm/navmaps" />
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
<span class="LC_nobreak">
|
<input type="hidden" name="cmd" value="upload_supplemental"> |
<input name="newnav" type="submit" value="$lt{'navc'}" />
|
<nobr> |
$help{'Navigate_Content'}
|
<input type="submit" value="$lt{'upld'}"> |
</span>
|
$help{'Uploading_From_Harddrive'} |
</form>
|
</nobr> |
NNFORM
|
</form> |
my $newsmppageform=(<<NSPFORM);
|
</td> |
<form action="/adm/coursedocs" method="post" name="newsmppg">
|
<td bgcolor="#DDDDDD"> |
$uploadtag
|
<form action="/adm/coursedocs" method="post" name="supnewfolder"> |
<input type="hidden" name="importdetail" value="" />
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
<span class="LC_nobreak">
|
<input type="hidden" name="importdetail" value="" /> |
<input name="newsmppg" type="button" value="$lt{'sipa'}"
|
<nobr> |
onClick="javascript:makesmppage();" /> $help{'Simple Page'}
|
<input name="newfolder" type="button" |
</span>
|
onClick="javascript:makenewfolder(this.form,'$folderseq');" |
</form>
|
value="$lt{'newf'}" /> $help{'Adding_Folders'} |
NSPFORM
|
</nobr> |
|
</form> |
my $newsmpproblemform=(<<NSPROBFORM);
|
<br /><form action="/adm/coursedocs" method="post" name="supnewext"> |
<form action="/adm/coursedocs" method="post" name="newsmpproblem">
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
$uploadtag
|
<input type="hidden" name="importdetail" value="" /> |
<input type="hidden" name="importdetail" value="" />
|
<nobr> |
<span class="LC_nobreak">
|
<input name="newext" type="button" |
<input name="newsmpproblem" type="button" value="$lt{'sipr'}"
|
onClick="javascript:makenewext('supnewext');" |
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
|
value="$lt{'extr'}" /> $help{'Adding_External_Resource'} |
</span>
|
</nobr> |
</form>
|
</form> |
|
<br /><form action="/adm/coursedocs" method="post" name="supnewsyl"> |
NSPROBFORM
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
|
<input type="hidden" name="importdetail" |
my $newdropboxform=(<<NDBFORM);
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus" /> |
<form action="/adm/coursedocs" method="post" name="newdropbox">
|
<nobr> |
$uploadtag
|
<input name="newsyl" type="submit" value="$lt{'syll'}" /> |
<input type="hidden" name="importdetail" value="" />
|
$help{'Syllabus'} |
<span class="LC_nobreak">
|
</nobr> |
<input name="newdropbox" type="button" value="$lt{'drbx'}"
|
</form> |
onClick="javascript:makedropbox();" />
|
<br /><form action="/adm/coursedocs" method="post" name="subnewaboutme"> |
</span>
|
<input type="hidden" name="folderpath" value="$env{'form.folderpath'}" /> |
</form>
|
<input type="hidden" name="importdetail" |
NDBFORM
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
|
<nobr> |
my $newexuploadform=(<<NEXUFORM);
|
<input name="newaboutme" type="submit" value="$lt{'mypi'}" /> |
<form action="/adm/coursedocs" method="post" name="newexamupload">
|
$help{'My Personal Info'} |
$uploadtag
|
</nobr> |
<input type="hidden" name="importdetail" value="" />
|
</form> |
<span class="LC_nobreak">
|
</td></tr> |
<input name="newexamupload" type="button" value="$lt{'scuf'}"
|
</table></td></tr> |
onClick="javascript:makeexamupload();" />
|
ENDSUPFORM |
$help{'Score_Upload_Form'}
|
} |
</span>
|
} |
</form>
|
if ($allowed) { |
NEXUFORM
|
$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>'); |
|
} |
my $newbulform=(<<NBFORM);
|
$r->print('</table>'); |
<form action="/adm/coursedocs" method="post" name="newbul">
|
} else { |
$uploadtag
|
unless ($upload_result eq 'phasetwo') { |
<input type="hidden" name="importdetail" value="" />
|
# -------------------------------------------------------- This is showdoc mode |
<span class="LC_nobreak">
|
$r->print("<h1>".&mt('Uploaded Document').' - '. |
<input name="newbulletin" type="button" value="$lt{'bull'}"
|
&Apache::lonnet::gettitle($r->uri).'</h1><p>'. |
onClick="javascript:makebulboard();" />
|
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>". |
$help{'Bulletin Board'}
|
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>'); |
</span>
|
} |
</form>
|
} |
NBFORM
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
my $newaboutmeform=(<<NAMFORM);
|
return OK; |
<form action="/adm/coursedocs" method="post" name="newaboutme">
|
} |
$uploadtag
|
|
<input type="hidden" name="importdetail"
|
|
value="$plainname=/adm/$udom/$uname/aboutme" />
|
sub editing_js { |
<span class="LC_nobreak">
|
my ($udom,$uname) = @_; |
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
my $now = time(); |
$help{'My Personal Info'}
|
|
</span>
|
return <<ENDNEWSCRIPT; |
</form>
|
function makenewfolder(targetform,folderseq) { |
NAMFORM
|
var foldername=prompt('Name of New Folder','New Folder'); |
|
if (foldername) { |
my $newaboutsomeoneform=(<<NASOFORM);
|
targetform.importdetail.value=escape(foldername)+"="+folderseq; |
<form action="/adm/coursedocs" method="post" name="newaboutsomeone">
|
targetform.submit(); |
$uploadtag
|
} |
<input type="hidden" name="importdetail" value="" />
|
} |
<span class="LC_nobreak">
|
|
<input name="newaboutsomeone" type="button" value="$lt{'abou'}"
|
function makenewpage(targetform,folderseq) { |
onClick="javascript:makeabout();" />
|
var pagename=prompt('Name of New Page','New Page'); |
</span>
|
if (pagename) { |
</form>
|
targetform.importdetail.value=escape(pagename)+"="+folderseq; |
NASOFORM
|
targetform.submit(); |
|
} |
|
} |
my $newrosterform=(<<NROSTFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newroster">
|
function makenewext(targetname) { |
$uploadtag
|
this.document.forms.extimport.useform.value=targetname; |
<input type="hidden" name="importdetail"
|
window.open('/adm/rat/extpickframe.html'); |
value="$lt{'rost'}=/adm/viewclasslist" />
|
} |
<span class="LC_nobreak">
|
|
<input name="newroster" type="submit" value="$lt{'rost'}" />
|
function makeexamupload() { |
$help{'Course Roster'}
|
var title=prompt('Listed Title for the Uploaded Score'); |
</span>
|
if (title) { |
</form>
|
this.document.forms.newexamupload.importdetail.value= |
NROSTFORM
|
escape(title)+'=/res/lib/templates/examupload.problem'; |
|
this.document.forms.newexamupload.submit(); |
$r->print(<<ENDFORM);
|
} |
|
} |
<ul class="LC_TabContent">
|
|
<li>$lt{'nd'}</li>
|
function makesmppage() { |
<li>$lt{'pm'}</li>
|
var title=prompt('Listed Title for the Page'); |
<li>$lt{'pubd'}</li>
|
if (title) { |
<li>$lt{'sd'}</li>
|
this.document.forms.newsmppg.importdetail.value= |
<li>$lt{'mo'}</li>
|
escape(title)+'=/adm/$udom/$uname/$now/smppg'; |
<li>$lt{'hao'}</li>
|
this.document.forms.newsmppg.submit(); |
</ul>
|
} |
|
} |
<table class="LC_docs_adddocs">
|
|
<!-- <tr>
|
function makesmpproblem() { |
<th>$lt{'uplm'}</th>
|
var title=prompt('Listed Title for the Problem'); |
<th>$lt{'impp'}</th>
|
if (title) { |
<th>$lt{'spec'}</th>
|
this.document.forms.newsmpproblem.importdetail.value= |
</tr> -->
|
escape(title)+'=/res/lib/templates/simpleproblem.problem'; |
<tr>
|
this.document.forms.newsmpproblem.submit(); |
<td>
|
} |
$fileuploadform
|
} |
</td>
|
|
<td>
|
function makedropbox() { |
$simpleeditdefaultform
|
var title=prompt('Listed Title for the Drop Box'); |
<hr />
|
if (title) { |
$recoverform
|
this.document.forms.newdropbox.importdetail.value= |
ENDFORM
|
escape(title)+'=/res/lib/templates/DropBox.problem'; |
unless ($env{'form.pagepath'}) {
|
this.document.forms.newdropbox.submit(); |
$r->print(<<ENDFORM);
|
} |
<hr />
|
} |
$extresourcesform
|
|
<br />
|
function makebulboard() { |
$imspform
|
var title=prompt('Listed Title for the Bulletin Board'); |
ENDFORM
|
if (title) { |
}
|
this.document.forms.newbul.importdetail.value= |
$r->print('</td><td>');
|
escape(title)+'=/adm/$udom/$uname/$now/bulletinboard'; |
unless ($env{'form.pagepath'}) {
|
this.document.forms.newbul.submit(); |
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
} |
|
} |
|
|
|
function makeabout() { |
my $newpageform=(<<NPFORM);
|
var user=prompt("Enter user:domain for User's 'About Me' Page"); |
<form action="/adm/coursedocs" method="post" name="newpage">
|
if (user) { |
<input type="hidden" name="folderpath" value="$path" />
|
var comp=new Array(); |
<input type="hidden" name="importdetail" value="" />
|
comp=user.split(':'); |
<span class="LC_nobreak">
|
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { |
<input name="newpage" type="button"
|
if ((comp[0]) && (comp[1])) { |
onClick="javascript:makenewpage(this.form,'$pageseq');"
|
this.document.forms.newaboutsomeone.importdetail.value= |
value="$lt{'newp'}" />$help{'Adding_Pages'}
|
'About '+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; |
</span>
|
this.document.forms.newaboutsomeone.submit(); |
</form>
|
} else { |
NPFORM
|
alert("Not a valid user:domain"); |
|
} |
my $newfolderform=(<<NFFORM);
|
} else { |
<form action="/adm/coursedocs" method="post" name="newfolder">
|
alert("Please enter both user and domain in the format user:domain"); |
<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');"
|
function makeims() { |
value="$lt{'newf'}" />$help{'Adding_Folders'}
|
var caller = document.forms.ims.folder.value; |
</span>
|
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; |
</form>
|
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); |
NFFORM
|
newWindow.location.href = newlocation; |
|
} |
my $newsylform=(<<NSYLFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newsyl">
|
|
$uploadtag
|
function finishpick() { |
<input type="hidden" name="importdetail"
|
var title=this.document.forms.extimport.title.value; |
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
|
var url=this.document.forms.extimport.url.value; |
<span class="LC_nobreak">
|
var form=this.document.forms.extimport.useform.value; |
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
eval |
$help{'Syllabus'}
|
('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+ |
</span>
|
'";this.document.forms.'+form+'.submit();'); |
</form>
|
} |
NSYLFORM
|
|
|
function changename(folderpath,index,oldtitle,container,pagesymb) { |
my $newgroupfileform=(<<NGFFORM);
|
var title=prompt('New Title',oldtitle); |
<form action="/adm/coursedocs" method="post" name="newgroupfiles">
|
if (title) { |
$uploadtag
|
this.document.forms.renameform.title.value=title; |
<input type="hidden" name="importdetail"
|
this.document.forms.renameform.cmd.value='rename_'+index; |
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
|
if (container == 'sequence') { |
<span class="LC_nobreak">
|
this.document.forms.renameform.folderpath.value=folderpath; |
<input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
|
} |
$help{'Group Files'}
|
if (container == 'page') { |
</span>
|
this.document.forms.renameform.pagepath.value=folderpath; |
</form>
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
NGFFORM
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
$r->print(<<ENDFORM);
|
} |
<br />
|
|
$newfolderform
|
function removeres(folderpath,index,oldtitle,container,pagesymb) { |
<br />
|
if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) { |
$newpageform
|
this.document.forms.renameform.cmd.value='del_'+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 cutres(folderpath,index,oldtitle,container,pagesymb) { |
<br />
|
if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) { |
$newbulform
|
this.document.forms.renameform.cmd.value='cut_'+index; |
<br />
|
this.document.forms.renameform.markcopy.value=index; |
$newaboutmeform
|
if (container == 'sequence') { |
<br />
|
this.document.forms.renameform.folderpath.value=folderpath; |
$newaboutsomeoneform
|
} |
<br />
|
if (container == 'page') { |
$newgroupfileform
|
this.document.forms.renameform.pagepath.value=folderpath; |
<br />
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
$newrosterform
|
} |
ENDFORM
|
this.document.forms.renameform.submit(); |
}
|
} |
if ($env{'form.pagepath'}) {
|
} |
$r->print(<<ENDBLOCK);
|
|
$newsmpproblemform
|
function markcopy(folderpath,index,oldtitle,container,pagesymb) { |
<br />
|
this.document.forms.renameform.markcopy.value=index; |
$newexuploadform
|
if (container == 'sequence') { |
ENDBLOCK
|
this.document.forms.renameform.folderpath.value=folderpath; |
}
|
} |
$r->print('</td></tr>'."\n".
|
if (container == 'page') { |
'</table>');
|
this.document.forms.renameform.pagepath.value=folderpath; |
$r->print('</td></tr>');
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
}
|
} |
# ----------------------------------------------------- Supplemental documents
|
this.document.forms.renameform.submit(); |
if (!$forcestandard) {
|
} |
$r->print('<tr><td class="LC_docs_document">');
|
|
# '<h2>'.&mt('Supplemental Course Documents').
|
ENDNEWSCRIPT |
# ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
|
} |
my $folder=$env{'form.folder'};
|
1; |
unless ($folder=~/^supplemental/) {
|
__END__ |
$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
|