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