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