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