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