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