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