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