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