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