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