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