version 1.327, 2009/01/28 12:56:08
|
version 1.458, 2011/09/09 20:13:17
|
Line 1
|
Line 1
|
# The LearningOnline Network
|
# The LearningOnline Network |
# Documents
|
# Documents |
#
|
# |
# $Id$
|
# $Id$ |
#
|
# |
# Copyright Michigan State University Board of Trustees
|
# Copyright Michigan State University Board of Trustees |
#
|
# |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
|
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
#
|
# |
# LON-CAPA is free software; you can redistribute it and/or modify
|
# LON-CAPA is free software; you can redistribute it and/or modify |
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by |
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or |
# (at your option) any later version.
|
# (at your option) any later version. |
#
|
# |
# LON-CAPA is distributed in the hope that it will be useful,
|
# LON-CAPA is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# GNU General Public License for more details.
|
# GNU General Public License for more details. |
#
|
# |
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License |
# along with LON-CAPA; if not, write to the Free Software
|
# along with LON-CAPA; if not, write to the Free Software |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
#
|
# |
# /home/httpd/html/adm/gpl.txt
|
# /home/httpd/html/adm/gpl.txt |
#
|
# |
# http://www.lon-capa.org/
|
# http://www.lon-capa.org/ |
#
|
# |
|
|
|
|
|
|
package Apache::londocs;
|
package Apache::londocs; |
|
|
use strict;
|
use strict; |
use Apache::Constants qw(:common :http);
|
use Apache::Constants qw(:common :http); |
use Apache::imsexport;
|
use Apache::imsexport; |
use Apache::lonnet;
|
use Apache::lonnet; |
use Apache::loncommon;
|
use Apache::loncommon; |
use LONCAPA::map();
|
use Apache::lonhtmlcommon; |
use Apache::lonratedt();
|
use LONCAPA::map(); |
use Apache::lonxml;
|
use Apache::lonratedt(); |
use Apache::lonclonecourse;
|
use Apache::lonxml; |
use Apache::lonnavmaps;
|
use Apache::lonclonecourse; |
use HTML::Entities;
|
use Apache::lonnavmaps; |
use GDBM_File;
|
use HTML::Entities; |
use Apache::lonlocal;
|
use GDBM_File; |
use Cwd;
|
use Apache::lonlocal; |
use LONCAPA qw(:DEFAULT :match);
|
use Cwd; |
|
use LONCAPA qw(:DEFAULT :match); |
my $iconpath;
|
|
|
my $iconpath; |
my %hash;
|
|
|
my %hash; |
my $hashtied;
|
|
my %alreadyseen=();
|
my $hashtied; |
|
my %alreadyseen=(); |
my $hadchanges;
|
|
|
my $hadchanges; |
|
|
my %help=();
|
|
|
my %help=(); |
|
|
sub mapread {
|
|
my ($coursenum,$coursedom,$map)=@_;
|
sub mapread { |
return
|
my ($coursenum,$coursedom,$map)=@_; |
&LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
|
return |
$map);
|
&LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
}
|
$map); |
|
} |
sub storemap {
|
|
my ($coursenum,$coursedom,$map)=@_;
|
sub storemap { |
my ($outtext,$errtext)=
|
my ($coursenum,$coursedom,$map)=@_; |
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
|
my ($outtext,$errtext)= |
$map,1);
|
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. |
if ($errtext) { return ($errtext,2); }
|
$map,1); |
|
if ($errtext) { return ($errtext,2); } |
$hadchanges=1;
|
|
return ($errtext,0);
|
$hadchanges=1; |
}
|
return ($errtext,0); |
|
} |
|
|
|
|
sub authorhosts {
|
|
my %outhash=();
|
sub authorhosts { |
my $home=0;
|
my %outhash=(); |
my $other=0;
|
my $home=0; |
foreach my $key (keys(%env)) {
|
my $other=0; |
if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
|
foreach my $key (keys(%env)) { |
my $role=$1;
|
if ($key=~/^user\.role\.(au|ca)\.(.+)$/) { |
my $realm=$2;
|
my $role=$1; |
my ($start,$end)=split(/\./,$env{$key});
|
my $realm=$2; |
if (($start) && ($start>time)) { next; }
|
my ($start,$end)=split(/\./,$env{$key}); |
if (($end) && (time>$end)) { next; }
|
if (($start) && ($start>time)) { next; } |
my ($ca,$cd);
|
if (($end) && (time>$end)) { next; } |
if ($1 eq 'au') {
|
my ($ca,$cd); |
$ca=$env{'user.name'};
|
if ($1 eq 'au') { |
$cd=$env{'user.domain'};
|
$ca=$env{'user.name'}; |
} else {
|
$cd=$env{'user.domain'}; |
($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
|
} else { |
}
|
($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/); |
my $allowed=0;
|
} |
my $myhome=&Apache::lonnet::homeserver($ca,$cd);
|
my $allowed=0; |
my @ids=&Apache::lonnet::current_machine_ids();
|
my $myhome=&Apache::lonnet::homeserver($ca,$cd); |
foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
|
my @ids=&Apache::lonnet::current_machine_ids(); |
if ($allowed) {
|
foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } } |
$home++;
|
if ($allowed) { |
$outhash{'home_'.$ca.'@'.$cd}=1;
|
$home++; |
} else {
|
$outhash{'home_'.$ca.'@'.$cd}=1; |
$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
|
} else { |
$other++;
|
$outhash{'otherhome_'.$ca.'@'.$cd}=$myhome; |
}
|
$other++; |
}
|
} |
}
|
} |
return ($home,$other,%outhash);
|
} |
}
|
return ($home,$other,%outhash); |
|
} |
|
|
sub dumpbutton {
|
|
my ($home,$other,%outhash)=&authorhosts();
|
sub dumpbutton { |
my $type = &Apache::loncommon::course_type();
|
my ($home,$other,%outhash)=&authorhosts(); |
if ($home+$other==0) { return ''; }
|
my $crstype = &Apache::loncommon::course_type(); |
if ($home) {
|
if ($home+$other==0) { return ''; } |
return '<input type="submit" name="dumpcourse" value="'.
|
if ($home) { |
&mt('Dump '.$type.' DOCS to Construction Space').'" />'.
|
my $link = |
&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
|
"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"dumpcourse\", \"" |
} else {
|
.&mt('Dump '.$crstype.' Documents to Construction Space') |
return '<div>'.
|
."\")'>" |
&mt('Dump '.$type.
|
.&mt('Dump '.$crstype.' Documents to Construction Space') |
' DOCS to Construction Space: available on other servers').
|
.'</a>'; |
'</div>';
|
return |
}
|
$link.' ' |
}
|
.&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs') |
|
.'<br />'; |
sub clean {
|
} else { |
my ($title)=@_;
|
return |
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
|
&mt('Dump '.$crstype.' Documents to Construction Space: available on other servers'); |
return $title;
|
} |
}
|
} |
|
|
|
sub clean { |
|
my ($title)=@_; |
sub dumpcourse {
|
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs; |
my ($r) = @_;
|
return $title; |
my $type = &Apache::loncommon::course_type();
|
} |
$r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
|
|
'<form name="dumpdoc" method="post">');
|
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space'));
|
|
my ($home,$other,%outhash)=&authorhosts();
|
sub dumpcourse { |
unless ($home) { return ''; }
|
my ($r) = @_; |
my $origcrsid=$env{'request.course.id'};
|
my $crstype = &Apache::loncommon::course_type(); |
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
|
$r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Documents to Construction Space'). |
if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
|
'<form name="dumpdoc" action="" method="post">'); |
# Do the dumping
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Documents to Construction Space')); |
unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
|
my ($home,$other,%outhash)=&authorhosts(); |
my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
|
unless ($home) { return ''; } |
$r->print('<h3>'.&mt('Copying Files').'</h3>');
|
my $origcrsid=$env{'request.course.id'}; |
my $title=$env{'form.authorfolder'};
|
my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid); |
$title=&clean($title);
|
if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) { |
my %replacehash=();
|
# Do the dumping |
foreach my $key (keys(%env)) {
|
unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; } |
if ($key=~/^form\.namefor\_(.+)/) {
|
my ($ca,$cd)=split(/\@/,$env{'form.authorspace'}); |
$replacehash{$1}=$env{$key};
|
$r->print('<h3>'.&mt('Copying Files').'</h3>'); |
}
|
my $title=$env{'form.authorfolder'}; |
}
|
$title=&clean($title); |
my $crs='/uploaded/'.$env{'request.course.id'}.'/';
|
my %replacehash=(); |
$crs=~s/\_/\//g;
|
foreach my $key (keys(%env)) { |
foreach my $item (keys(%replacehash)) {
|
if ($key=~/^form\.namefor\_(.+)/) { |
my $newfilename=$title.'/'.$replacehash{$item};
|
$replacehash{$1}=$env{$key}; |
$newfilename=~s/\.(\w+)$//;
|
} |
my $ext=$1;
|
} |
$newfilename=&clean($newfilename);
|
my $crs='/uploaded/'.$env{'request.course.id'}.'/'; |
$newfilename.='.'.$ext;
|
$crs=~s/\_/\//g; |
my @dirs=split(/\//,$newfilename);
|
foreach my $item (keys(%replacehash)) { |
my $path='/home/'.$ca.'/public_html';
|
my $newfilename=$title.'/'.$replacehash{$item}; |
my $makepath=$path;
|
$newfilename=~s/\.(\w+)$//; |
my $fail=0;
|
my $ext=$1; |
for (my $i=0;$i<$#dirs;$i++) {
|
$newfilename=&clean($newfilename); |
$makepath.='/'.$dirs[$i];
|
$newfilename.='.'.$ext; |
unless (-e $makepath) {
|
my @dirs=split(/\//,$newfilename); |
unless(mkdir($makepath,0777)) { $fail=1; }
|
my $path='/home/'.$ca.'/public_html'; |
}
|
my $makepath=$path; |
}
|
my $fail=0; |
$r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
|
for (my $i=0;$i<$#dirs;$i++) { |
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
|
$makepath.='/'.$dirs[$i]; |
if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
|
unless (-e $makepath) { |
print $fh &Apache::lonclonecourse::rewritefile(
|
unless(mkdir($makepath,0777)) { $fail=1; } |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
|
} |
(%replacehash,$crs => '')
|
} |
);
|
$r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: '); |
} else {
|
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { |
print $fh
|
if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) { |
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
|
print $fh &Apache::lonclonecourse::rewritefile( |
}
|
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item), |
$fh->close();
|
(%replacehash,$crs => '') |
} else {
|
); |
$fail=1;
|
} else { |
}
|
print $fh |
if ($fail) {
|
&Apache::lonclonecourse::readfile($env{'request.course.id'},$item); |
$r->print('<span class="LC_error">'.&mt('fail').'</span>');
|
} |
} else {
|
$fh->close(); |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
} else { |
}
|
$fail=1; |
}
|
} |
} else {
|
if ($fail) { |
# Input form
|
$r->print('<span class="LC_error">'.&mt('fail').'</span>'); |
unless ($home==1) {
|
} else { |
$r->print(
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
'<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
|
} |
}
|
} |
foreach my $key (sort(keys(%outhash))) {
|
} else { |
if ($key=~/^home_(.+)$/) {
|
# Input form |
if ($home==1) {
|
unless ($home==1) { |
$r->print(
|
$r->print( |
'<input type="hidden" name="authorspace" value="'.$1.'" />');
|
'<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">'); |
} else {
|
} |
$r->print('<option value="'.$1.'">'.$1.' - '.
|
foreach my $key (sort(keys(%outhash))) { |
&Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
|
if ($key=~/^home_(.+)$/) { |
}
|
if ($home==1) { |
}
|
$r->print( |
}
|
'<input type="hidden" name="authorspace" value="'.$1.'" />'); |
unless ($home==1) {
|
} else { |
$r->print('</select>');
|
$r->print('<option value="'.$1.'">'.$1.' - '. |
}
|
&Apache::loncommon::plainname(split(/\@/,$1)).'</option>'); |
my $title=$origcrsdata{'description'};
|
} |
$title=~s/[\/\s]+/\_/gs;
|
} |
$title=&clean($title);
|
} |
$r->print('<h3>'.&mt('Folder in Construction Space').'</h3>'
|
unless ($home==1) { |
.'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
|
$r->print('</select>'); |
&tiehash();
|
} |
$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>'
|
my $title=$origcrsdata{'description'}; |
.&Apache::loncommon::start_data_table()
|
$title=~s/[\/\s]+/\_/gs; |
.&Apache::loncommon::start_data_table_header_row()
|
$title=&clean($title); |
.'<th>'.&mt('Internal Filename').'</th>'
|
$r->print('<h3>'.&mt('Folder in Construction Space').'</h3>' |
.'<th>'.&mt('Title').'</th>'
|
.'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />'); |
.'<th>'.&mt('Save as ...').'</th>'
|
&tiehash(); |
.&Apache::loncommon::end_data_table_header_row());
|
$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>' |
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
|
.&Apache::loncommon::start_data_table() |
$r->print(&Apache::loncommon::start_data_table_row()
|
.&Apache::loncommon::start_data_table_header_row() |
.'<td>'.$file.'</td>');
|
.'<th>'.&mt('Internal Filename').'</th>' |
my ($ext)=($file=~/\.(\w+)$/);
|
.'<th>'.&mt('Title').'</th>' |
my $title=$hash{'title_'.$hash{
|
.'<th>'.&mt('Save as ...').'</th>' |
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
|
.&Apache::loncommon::end_data_table_header_row()); |
$r->print('<td>'.($title?$title:' ').'</td>');
|
foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) { |
if (!$title) {
|
$r->print(&Apache::loncommon::start_data_table_row() |
$title=$file;
|
.'<td>'.$file.'</td>'); |
} else {
|
my ($ext)=($file=~/\.(\w+)$/); |
$title=~s|/|_|g;
|
my $title=$hash{'title_'.$hash{ |
}
|
'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}}; |
$title=~s/\.(\w+)$//;
|
$r->print('<td>'.($title?$title:' ').'</td>'); |
$title=&clean($title);
|
if (!$title) { |
$title.='.'.$ext;
|
$title=$file; |
$r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
|
} else { |
.&Apache::loncommon::end_data_table_row());
|
$title=~s|/|_|g; |
}
|
} |
$r->print(&Apache::loncommon::end_data_table());
|
$title=~s/\.(\w+)$//; |
&untiehash();
|
$title=&clean($title); |
$r->print(
|
$title.='.'.$ext; |
'<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $type DOCS").'" /></p></form>');
|
$r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>" |
}
|
.&Apache::loncommon::end_data_table_row()); |
}
|
} |
|
$r->print(&Apache::loncommon::end_data_table()); |
|
&untiehash(); |
|
$r->print( |
sub exportbutton {
|
'<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype Documents").'" /></p></form>'); |
my $type = &Apache::loncommon::course_type();
|
} |
return '<input type="submit" name="exportcourse" value="'.
|
} |
&mt('Export '.$type.' to IMS').'" />'.
|
|
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
|
|
}
|
|
|
sub exportbutton { |
|
my $crstype = &Apache::loncommon::course_type(); |
|
return "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"exportcourse\", \"".&mt('IMS Export')."\")'>".&mt('IMS Export')."</a>". |
sub exportcourse {
|
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'<br />'; |
my $r=shift;
|
} |
my $type = &Apache::loncommon::course_type();
|
|
my %discussiontime = &Apache::lonnet::dump('discussiontimes',
|
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
|
|
my $numdisc = keys(%discussiontime);
|
sub exportcourse { |
my $navmap = Apache::lonnavmaps::navmap->new();
|
my $r=shift; |
if (!defined($navmap)) {
|
my $crstype = &Apache::loncommon::course_type(); |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package').
|
my %discussiontime = &Apache::lonnet::dump('discussiontimes', |
'<h2>IMS Export Failed</h2>'.
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); |
'<div class="LC_error">'.
|
my $numdisc = keys(%discussiontime); |
&mt('Unable to retrieve information about course contents').
|
my $numprobs = 0; |
'</div><a href="/adm/coursedocs">'.&mt('Return to Course Editor').'</a>');
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
&Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
if (!defined($navmap)) { |
return;
|
$r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package'). |
}
|
'<h2>'.&mt('IMS Export Failed').'</h2>'. |
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
|
'<div class="LC_error">'); |
my $curRes;
|
if ($crstype eq 'Community') { |
my $outcome;
|
$r->print(&mt('Unable to retrieve information about community contents')); |
|
} else { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
$r->print(&mt('Unable to retrieve information about course contents')); |
['finishexport']);
|
} |
if ($env{'form.finishexport'}) {
|
$r->print('</div><a href="/adm/coursedocs">'); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
if ($crstype eq 'Community') { |
['archive','discussion']);
|
$r->print(&mt('Return to Community Editor')); |
|
} else { |
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
|
$r->print(&mt('Return to Course Editor')); |
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
|
} |
if (@exportitems == 0 && @discussions == 0) {
|
$r->print('</a>'); |
$outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
|
&Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); |
} else {
|
return; |
my $now = time;
|
} |
my %symbs;
|
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); |
my $manifestok = 0;
|
my $curRes; |
my $imsresources;
|
my $outcome; |
my $tempexport;
|
|
my $copyresult;
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
|
['finishexport']); |
if ($manifestok) {
|
if ($env{'form.finishexport'}) { |
&build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
close($ims_manifest);
|
['archive','discussion']); |
|
|
#Create zip file in prtspool
|
my $format = $env{'form.format'}; |
my $imszipfile = '/prtspool/'.
|
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); |
$env{'user.name'}.'_'.$env{'user.domain'}.'_'.
|
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); |
time.'_'.rand(1000000000).'.zip';
|
if (@exportitems == 0 && @discussions == 0) { |
my $cwd = &Cwd::getcwd();
|
$outcome = |
my $imszip = '/home/httpd/'.$imszipfile;
|
'<p class="LC_warning">' |
chdir $tempexport;
|
.&mt('As you did not select any content items or discussions' |
open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
|
.' for export, an IMS package has not been created.') |
close(OUTPUT);
|
.'</p>' |
chdir $cwd;
|
.'<p>' |
$outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);
|
.&mt('Please [_1]go back[_2] to select either content items' |
if ($copyresult) {
|
.' or discussions for export.' |
$outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
|
,'<a href="javascript:history.go(-1)">' |
}
|
,'</a>') |
} else {
|
.'</p>'; |
$outcome = '<br />'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'<br />';
|
} else { |
}
|
my $now = time; |
}
|
my %symbs; |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
|
my $manifestok = 0; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
|
my $imsresources; |
$r->print($outcome);
|
my $tempexport; |
$r->print(&Apache::loncommon::end_page());
|
my $copyresult; |
} else {
|
my $testbank; |
my $display;
|
my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport,$format,\$testbank); |
$display = '<form name="exportdoc" method="post">'."\n";
|
if ($manifestok) { |
$display .= &mt('Choose which items you wish to export from your '.$type.'.<br /><br />');
|
&build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest,$format,$testbank); |
$display .= '<table border="0" cellspacing="0" cellpadding="3">'.
|
close($ims_manifest); |
'<tr><td><fieldset><legend> <b>Content items</b></legend>'.
|
|
'<input type="button" value="check all" '.
|
#Create zip file in prtspool |
'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
|
my $imszipfile = '/prtspool/'. |
' <input type="button" value="uncheck all"'.
|
$env{'user.name'}.'_'.$env{'user.domain'}.'_'. |
' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
|
time.'_'.rand(1000000000).'.zip'; |
'<td> </td><td> </td>'.
|
my $cwd = &Cwd::getcwd(); |
'<td align="right"><fieldset><legend> <b>Discussion posts'.
|
my $imszip = '/home/httpd/'.$imszipfile; |
'</b></legend><input type="button" value="check all"'.
|
chdir $tempexport; |
' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
|
open(OUTPUT, "zip -r $imszip * 2> /dev/null |"); |
' <input type="button" value="uncheck all"'.
|
close(OUTPUT); |
' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
|
chdir $cwd; |
'</tr></table>';
|
$outcome .= '<p>' |
my $curRes;
|
.&mt('[_1]Your IMS package[_2] is ready for download.' |
my $depth = 0;
|
,'<a href="'.$imszipfile.'">','</a>') |
my $count = 0;
|
.'</p>'; |
my $boards = 0;
|
if ($copyresult) { |
my $startcount = 5;
|
$outcome .= '<p class="LC_error">' |
my %parent = ();
|
.&mt('The following errors occurred during export - [_1]' |
my %children = ();
|
,$copyresult) |
my $lastcontainer = $startcount;
|
.'</p>'; |
my @bgcolors = ('#F6F6F6','#FFFFFF');
|
} |
$display .= '<table cellspacing="0"><tr>'.
|
} else { |
'<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n";
|
$outcome = '<p class="LC_error">' |
if ($numdisc > 0) {
|
.&mt('Unfortunately you will not be able to retrieve' |
$display.='<b>Export discussion posts?</b>'."\n";
|
.' an IMS archive of your course at this time,' |
}
|
.' because there was a problem creating a' |
$display.=' </td></tr>';
|
.' manifest file.') |
while ($curRes = $it->next()) {
|
.'</p>' |
if (ref($curRes)) {
|
.'<p><a href="javascript:history.go(-1)">' |
$count ++;
|
.&mt('Go Back') |
}
|
.'</a></p>'; |
if ($curRes == $it->BEGIN_MAP()) {
|
} |
$depth++;
|
} |
$parent{$depth} = $lastcontainer;
|
$r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package')); |
}
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); |
if ($curRes == $it->END_MAP()) {
|
$r->print($outcome); |
$depth--;
|
$r->print(&Apache::loncommon::end_page()); |
$lastcontainer = $parent{$depth};
|
} else { |
}
|
my $display='<form name="exportdoc" action="" method="post">'."\n". |
if (ref($curRes)) {
|
'<p>'. |
my $symb = $curRes->symb();
|
&mt('Choose which items you wish to export from your '.$crstype.'.'). |
my $ressymb = $symb;
|
'</p>'. |
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
|
'<div class="LC_columnSection"><fieldset>'. |
unless ($ressymb =~ m|adm/wrapper/adm|) {
|
'<legend>'.&mt('Content items').'</legend>'. |
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
|
'<input type="button" value="'.&mt('check all').'" '. |
}
|
'onclick="javascript:checkAll(document.exportdoc.archive)" />'. |
}
|
' <input type="button" value="'.&mt('uncheck all').'"'. |
my $color = $count%2;
|
' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset>'; |
$display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
|
if ($numdisc > 0) { |
'<input type="checkbox" name="archive" value="'.$count.'" ';
|
$display .= '<fieldset>'. |
if (($curRes->is_sequence()) || ($curRes->is_page())) {
|
'<legend>'.&mt('Discussion posts').'</legend>'. |
my $checkitem = $count + $boards + $startcount;
|
'<input type="button" value="'.&mt('check all').'"'. |
$display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
|
' onclick="javascript:checkAll(document.exportdoc.discussion)" />'. |
}
|
' <input type="button" value="'.&mt('uncheck all').'"'. |
$display .= ' />'."\n";
|
' onclick="javascript:uncheckAll(document.exportdoc.discussion)" />'. |
for (my $i=0; $i<$depth; $i++) {
|
'</fieldset>'; |
$display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" /><img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" />'."\n";
|
} |
}
|
$display .= '</div>'; |
if ($curRes->is_sequence()) {
|
my $curRes; |
$display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n";
|
my $depth = 0; |
$lastcontainer = $count + $startcount + $boards;
|
my $count = 0; |
} elsif ($curRes->is_page()) {
|
my $boards = 0; |
$display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n";
|
my $startcount = 5; |
$lastcontainer = $count + $startcount + $boards;
|
my %parent = (); |
}
|
my %children = (); |
my $currelem = $count+$boards+$startcount;
|
my $lastcontainer = $startcount; |
$children{$parent{$depth}} .= $currelem.':';
|
$display .= &Apache::loncommon::start_data_table() |
$display .= ' '.$curRes->title().'</td>';
|
.&Apache::loncommon::start_data_table_header_row() |
if ($discussiontime{$ressymb} > 0) {
|
.'<th>'.&mt('Export content item?').'</th>'; |
$boards ++;
|
if ($numdisc > 0) { |
$currelem = $count+$boards+$startcount;
|
$display .= '<th>'.&mt('Export discussion posts?').'</th>'; |
$display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n";
|
} |
} else {
|
$display .= &Apache::loncommon::end_data_table_header_row(); |
$display .= '<td colspan="2"> </td>'."\n";
|
while ($curRes = $it->next()) { |
}
|
if (ref($curRes)) { |
}
|
$count ++; |
}
|
} |
my $scripttag = qq|
|
if ($curRes == $it->BEGIN_MAP()) { |
<script>
|
$depth++; |
|
$parent{$depth} = $lastcontainer; |
function checkAll(field) {
|
} |
if (field.length > 0) {
|
if ($curRes == $it->END_MAP()) { |
for (i = 0; i < field.length; i++) {
|
$depth--; |
field[i].checked = true ;
|
$lastcontainer = $parent{$depth}; |
}
|
} |
} else {
|
if (ref($curRes)) { |
field.checked = true
|
my $symb = $curRes->symb(); |
}
|
my $ressymb = $symb; |
}
|
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { |
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
function uncheckAll(field) {
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
if (field.length > 0) {
|
} |
for (i = 0; i < field.length; i++) {
|
} |
field[i].checked = false ;
|
my $currelem = $count+$boards+$startcount; |
}
|
$display .= &Apache::loncommon::start_data_table_row() |
} else {
|
.'<td>'."\n" |
field.checked = false ;
|
.'<input type="checkbox" name="archive" value="'.$count.'" '; |
}
|
if (($curRes->is_sequence()) || ($curRes->is_page())) { |
}
|
$lastcontainer = $currelem; |
|
$display .= 'onclick="javascript:propagateCheck('."'$currelem'".')"'; |
function propagateCheck(item) {
|
} elsif ($curRes->is_problem()) { |
if (document.exportdoc.elements[item].checked == true) {
|
$numprobs ++; |
containerCheck(item)
|
} |
}
|
$display .= ' />'."\n"; |
}
|
for (my $i=0; $i<$depth; $i++) { |
|
$display .= ('<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" alt="" />' x2)."\n"; |
function containerCheck(item) {
|
} |
document.exportdoc.elements[item].checked = true
|
if ($curRes->is_sequence()) { |
var numitems = $count + $boards + $startcount
|
$display .= '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" /> '."\n"; |
var parents = new Array(numitems)
|
} elsif ($curRes->is_page()) { |
for (var i=$startcount; i<numitems; i++) {
|
$display .= '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" /> '."\n"; |
parents[i] = new Array
|
} |
}
|
$children{$parent{$depth}} .= $currelem.':'; |
|;
|
$display .= ' '.$curRes->title().'</td>'."\n"; |
|
|
foreach my $container (sort { $a <=> $b } (keys(%children))) {
|
# Existing discussion posts? |
my @contents = split(/:/,$children{$container});
|
if ($discussiontime{$ressymb} > 0) { |
for (my $i=0; $i<@contents; $i ++) {
|
$boards ++; |
$scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
|
$display .= '<td align="right">' |
}
|
.'<input type="checkbox" name="discussion" value="'.$count.'" />' |
}
|
.'</td>'."\n"; |
|
} elsif ($numdisc > 0) { |
$scripttag .= qq|
|
$display .= '<td> </td>'."\n"; |
if (parents[item].length > 0) {
|
} |
for (var j=0; j<parents[item].length; j++) {
|
$display .= &Apache::loncommon::end_data_table_row(); |
containerCheck(parents[item][j])
|
} |
}
|
} |
}
|
$display .= &Apache::loncommon::end_data_table(); |
}
|
my $scripttag = qq| |
|
<script type="text/javascript"> |
</script>
|
// <![CDATA[ |
|;
|
function checkAll(field) { |
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package',
|
if (field.length > 0) { |
$scripttag));
|
for (i = 0; i < field.length; i++) { |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
|
field[i].checked = true ; |
$r->print($display.'</table>'.
|
} |
'<p><input type="hidden" name="finishexport" value="1">'.
|
} else { |
'<input type="submit" name="exportcourse" value="'.
|
field.checked = true |
&mt('Export '.$type.' DOCS').'" /></p></form>');
|
} |
}
|
} |
}
|
|
|
function uncheckAll(field) { |
sub create_ims_store {
|
if (field.length > 0) { |
my ($now,$manifestok,$outcome,$tempexport) = @_;
|
for (i = 0; i < field.length; i++) { |
$$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
|
field[i].checked = false ; |
my $ims_manifest;
|
} |
if (!-e $$tempexport) {
|
} else { |
mkdir($$tempexport,0700);
|
field.checked = false ; |
}
|
} |
$$tempexport .= '/'.$now;
|
} |
if (!-e $$tempexport) {
|
|
mkdir($$tempexport,0700);
|
function propagateCheck(item) { |
}
|
if (document.exportdoc.elements[item].checked == true) { |
$$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
|
containerCheck(item) |
if (!-e $$tempexport) {
|
} |
mkdir($$tempexport,0700);
|
} |
}
|
|
if (!-e "$$tempexport/resources") {
|
function containerCheck(item) { |
mkdir("$$tempexport/resources",0700);
|
document.exportdoc.elements[item].checked = true |
}
|
var numitems = $count + $boards + $startcount |
# open manifest file
|
var parents = new Array(numitems) |
my $manifest = '/imsmanifest.xml';
|
for (var i=$startcount; i<numitems; i++) { |
my $manifestfilename = $$tempexport.$manifest;
|
parents[i] = new Array |
if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
|
} |
$$manifestok=1;
|
|; |
print $ims_manifest
|
|
'<?xml version="1.0" encoding="UTF-8"?>'."\n".
|
foreach my $container (sort { $a <=> $b } (keys(%children))) { |
'<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
|
my @contents = split(/:/,$children{$container}); |
' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
|
for (my $i=0; $i<@contents; $i ++) { |
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
|
$scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n"; |
' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
|
} |
' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
|
} |
' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
|
|
' <metadata>
|
$scripttag .= qq| |
<schema></schema>
|
if (parents[item].length > 0) { |
<imsmd:lom>
|
for (var j=0; j<parents[item].length; j++) { |
<imsmd:general>
|
containerCheck(parents[item][j]) |
<imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier>
|
} |
<imsmd:title>
|
} |
<imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring>
|
} |
</imsmd:title>
|
// ]]> |
</imsmd:general>
|
</script> |
</imsmd:lom>
|
|; |
</metadata>'."\n".
|
$r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package', |
' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
|
$scripttag)); |
' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); |
' structure="hierarchical">'."\n".
|
if ($numprobs > 0) { |
' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'
|
$display .= '<p><span class="LC_nobreak">'. |
} else {
|
&mt('Export format for LON-CAPA problems:'). |
$$outcome .= 'An error occurred opening the IMS manifest file.<br />'
|
'<label><input type="radio" name="format" value="xml" checked="checked" />'. |
;
|
' '.&mt('XML').'</label>'.(' ' x3). |
}
|
'<label><input type="radio" name="format" value="html" />'. |
return $ims_manifest;
|
' '.&mt('HTML').'</label>'.(' ' x3). |
}
|
'<label><input type="radio" name="format" value="plaintext" />'. |
|
' '.&mt('Text').'</label></span></p>'; |
sub build_package {
|
} |
my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
|
$r->print($display. |
# first iterator to look for dependencies
|
'<p><input type="hidden" name="finishexport" value="1" />'. |
my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
|
'<input type="submit" name="exportcourse" value="'. |
my $curRes;
|
&mt('Export').'" /></p></form>'); |
my $count = 0;
|
} |
my $depth = 0;
|
} |
my $lastcontainer = 0;
|
|
my %parent = ();
|
sub create_ims_store { |
my @dependencies = ();
|
my ($now,$manifestok,$outcome,$tempexport,$format,$testbank) = @_; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
|
$$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports'; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
|
my $ims_manifest; |
while ($curRes = $it->next()) {
|
if (!-e $$tempexport) { |
if (ref($curRes)) {
|
mkdir($$tempexport,0700); |
$count ++;
|
} |
}
|
$$tempexport .= '/'.$now; |
if ($curRes == $it->BEGIN_MAP()) {
|
if (!-e $$tempexport) { |
$depth++;
|
mkdir($$tempexport,0700); |
$parent{$depth} = $lastcontainer;
|
} |
}
|
$$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'}; |
if ($curRes == $it->END_MAP()) {
|
if (!-e $$tempexport) { |
$depth--;
|
mkdir($$tempexport,0700); |
$lastcontainer = $parent{$depth};
|
} |
}
|
if (!-e "$$tempexport/resources") { |
if (ref($curRes)) {
|
mkdir("$$tempexport/resources",0700); |
if ($curRes->is_sequence() || $curRes->is_page()) {
|
} |
$lastcontainer = $count;
|
# open manifest file |
}
|
my $manifest = '/imsmanifest.xml'; |
if (grep(/^$count$/,@$exportitems)) {
|
my $manifestfilename = $$tempexport.$manifest; |
&get_dependencies($exportitems,\%parent,$depth,\@dependencies);
|
if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) { |
}
|
$$manifestok=1; |
}
|
print $ims_manifest |
}
|
'<?xml version="1.0" encoding="UTF-8"?>'."\n". |
# second iterator to build manifest and store resources
|
'<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'. |
$it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
|
' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'. |
$depth = 0;
|
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
my $prevdepth;
|
' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'. |
$count = 0;
|
' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'. |
my $imsresources;
|
' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n". |
my $pkgdepth;
|
' <metadata> |
while ($curRes = $it->next()) {
|
<schema></schema> |
if ($curRes == $it->BEGIN_MAP()) {
|
<imsmd:lom> |
$prevdepth = $depth;
|
<imsmd:general> |
$depth++;
|
<imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier> |
}
|
<imsmd:title> |
if ($curRes == $it->END_MAP()) {
|
<imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring> |
$prevdepth = $depth;
|
</imsmd:title> |
$depth--;
|
</imsmd:general> |
}
|
</imsmd:lom> |
|
</metadata>'."\n". |
if (ref($curRes)) {
|
' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n". |
$count ++;
|
' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'. |
if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) {
|
' structure="hierarchical">'."\n". |
my $symb = $curRes->symb();
|
' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'; |
my $isvisible = 'true';
|
if ($format eq 'plaintext') { |
my $resourceref;
|
my $testbankfilename = $$tempexport.'/testbank.txt'; |
if ($curRes->randomout()) {
|
$$testbank = Apache::File->new('>'.$testbankfilename); |
$isvisible = 'false';
|
} |
}
|
} else { |
unless ($curRes->is_sequence()) {
|
$$outcome .= 'An error occurred opening the IMS manifest file.<br />' |
$resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
|
; |
}
|
} |
my $step = $prevdepth - $depth;
|
return $ims_manifest; |
if (($step >= 0) && ($count > 1)) {
|
} |
while ($step >= 0) {
|
|
print $ims_manifest "\n".' </item>'."\n";
|
sub build_package { |
$step --;
|
my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult, |
}
|
$ims_manifest,$format,$testbank) = @_; |
}
|
# first iterator to look for dependencies |
$prevdepth = $depth;
|
my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef); |
|
my $curRes; |
my $itementry =
|
my $count = 0; |
'<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count.
|
my $depth = 0; |
'" isvisible="'.$isvisible.'" '.$resourceref.'>'.
|
my $lastcontainer = 0; |
'<title>'.$curRes->title().'</title>';
|
my %parent = (); |
print $ims_manifest "\n".$itementry;
|
my @dependencies = (); |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
unless ($curRes->is_sequence()) {
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $content_file;
|
while ($curRes = $it->next()) { |
my @hrefs = ();
|
if (ref($curRes)) { |
&process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
|
$count ++; |
if ($content_file) {
|
} |
$imsresources .= "\n".
|
if ($curRes == $it->BEGIN_MAP()) { |
' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
|
$depth++; |
'" type="webcontent" href="'.$content_file.'">'."\n".
|
$parent{$depth} = $lastcontainer; |
' <file href="'.$content_file.'" />'."\n";
|
} |
foreach my $item (@hrefs) {
|
if ($curRes == $it->END_MAP()) { |
$imsresources .=
|
$depth--; |
' <file href="'.$item.'" />'."\n";
|
$lastcontainer = $parent{$depth}; |
}
|
} |
if (grep(/^$count$/,@$discussions)) {
|
if (ref($curRes)) { |
my $ressymb = $symb;
|
if ($curRes->is_sequence() || $curRes->is_page()) { |
my $mode;
|
$lastcontainer = $count; |
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
|
} |
unless ($ressymb =~ m|adm/wrapper/adm|) {
|
if (grep(/^$count$/,@$exportitems)) { |
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
|
&get_dependencies($exportitems,\%parent,$depth,\@dependencies); |
}
|
} |
$mode = 'board';
|
} |
}
|
} |
my %extras = (
|
# second iterator to build manifest and store resources |
caller => 'imsexport',
|
$it = $navmap->getIterator(undef,undef,undef,1,undef,undef); |
tempexport => $tempexport.'/resources',
|
$depth = 0; |
count => $count
|
my $prevdepth; |
);
|
$count = 0; |
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
|
my $imsresources; |
}
|
my $pkgdepth; |
$imsresources .= ' </resource>'."\n";
|
my $currdirpath = 'Top'; |
}
|
while ($curRes = $it->next()) { |
}
|
if ($curRes == $it->BEGIN_MAP()) { |
$pkgdepth = $depth;
|
$prevdepth = $depth; |
}
|
$depth++; |
}
|
} |
}
|
if ($curRes == $it->END_MAP()) { |
while ($pkgdepth > 0) {
|
$prevdepth = $depth; |
print $ims_manifest " </item>\n";
|
$depth--; |
$pkgdepth --;
|
} |
}
|
|
my $resource_text = qq|
|
if (ref($curRes)) { |
</organization>
|
$count ++; |
</organizations>
|
if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) { |
<resources>
|
my $symb = $curRes->symb(); |
$imsresources
|
my $isvisible = 'true'; |
</resources>
|
my $resourceref; |
</manifest>
|
if ($curRes->randomout()) { |
|;
|
$isvisible = 'false'; |
print $ims_manifest $resource_text;
|
} |
}
|
unless ($curRes->is_sequence()) { |
|
$resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"'; |
sub get_dependencies {
|
} |
my ($exportitems,$parent,$depth,$dependencies) = @_;
|
my $step = $prevdepth - $depth; |
if ($depth > 1) {
|
if (($step >= 0) && ($count > 1)) { |
if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) {
|
while ($step >= 0) { |
push(@{$dependencies},$$parent{$depth});
|
print $ims_manifest "\n".' </item>'."\n"; |
if ($depth > 2) {
|
$step --; |
&get_dependencies($exportitems,$parent,$depth-1,$dependencies);
|
} |
}
|
} |
}
|
$prevdepth = $depth; |
}
|
|
}
|
my $itementry = |
|
'<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count. |
sub process_content {
|
'" isvisible="'.$isvisible.'" '.$resourceref.'>'. |
my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
|
'<title>'.$curRes->title().'</title>'; |
my $content_type;
|
print $ims_manifest "\n".$itementry; |
my $message;
|
|
my @uploads = ();
|
if ($curRes->is_sequence()) { |
if ($curRes->is_sequence()) {
|
$currdirpath = 'Top'; |
$content_type = 'sequence';
|
my $pcslist = $curRes->map_hierarchy(); |
} elsif ($curRes->is_page()) {
|
if ($pcslist ne '') { |
$content_type = 'page'; # need to handle individual items in pages.
|
foreach my $pc (split(/,/,$pcslist),$curRes->map_pc()) { |
} elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
|
next if ($pc <= 1); |
$content_type = 'syllabus';
|
my $res = $navmap->getByMapPc($pc); |
my $contents = &Apache::imsexport::templatedpage($content_type);
|
if (ref($res)) { |
if ($contents) {
|
my $encloser = $res->title(); |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
if ($encloser) { |
}
|
if ($currdirpath) { |
} elsif ($symb =~ m-\.sequence___\d+___ext-) {
|
$currdirpath .= ' -> '; |
$content_type = 'external';
|
} |
my $title = $curRes->title;
|
$currdirpath .= $encloser; |
my $contents = &Apache::imsexport::external($symb,$title);
|
} |
if ($contents) {
|
} |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
} |
}
|
} |
} elsif ($symb =~ m-adm/navmaps$-) {
|
} else { |
$content_type = 'navmap';
|
my $content_file; |
} elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
|
my @hrefs = (); |
$content_type = 'simplepage';
|
&process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport,$format,$currdirpath,$testbank); |
my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
|
if ($content_file) { |
if ($contents) {
|
$imsresources .= "\n". |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count. |
}
|
'" type="webcontent" href="'.$content_file.'">'."\n". |
} elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
|
' <file href="'.$content_file.'" />'."\n"; |
$content_type = 'simpleproblem';
|
foreach my $item (@hrefs) { |
my $contents = &Apache::imsexport::simpleproblem($symb);
|
$imsresources .= |
if ($contents) {
|
' <file href="'.$item.'" />'."\n"; |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
} |
}
|
if (grep(/^$count$/,@$discussions)) { |
} elsif ($symb =~ m-lib/templates/examupload\.problem$-) {
|
my $ressymb = $symb; |
$content_type = 'examupload';
|
my $mode; |
} elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) {
|
if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { |
$content_type = 'bulletinboard';
|
unless ($ressymb =~ m|adm/wrapper/adm|) { |
my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
|
$ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; |
if ($contents) {
|
} |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
$mode = 'board'; |
}
|
} |
} elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
|
my %extras = ( |
$content_type = 'aboutme';
|
caller => 'imsexport', |
my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
|
tempexport => $tempexport.'/resources', |
if ($contents) {
|
count => $count |
$$content_file = &store_template($contents,$tempexport,$count,$content_type);
|
); |
}
|
my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras); |
} elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
|
} |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
|
$imsresources .= ' </resource>'."\n"; |
} elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
|
} |
my $canedit = 0;
|
} |
if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) {
|
$pkgdepth = $depth; |
$canedit= 1;
|
} |
}
|
} |
# only include problem code where current user is author
|
} |
if ($canedit) {
|
while ($pkgdepth > 0) { |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
|
print $ims_manifest " </item>\n"; |
} else {
|
$pkgdepth --; |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
|
} |
}
|
my $resource_text = qq| |
} elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
|
</organization> |
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
|
</organizations> |
}
|
<resources> |
if (@uploads > 0) {
|
$imsresources |
foreach my $item (@uploads) {
|
</resources> |
my $uploadmsg = '';
|
</manifest> |
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
|
|; |
if ($uploadmsg) {
|
print $ims_manifest $resource_text; |
$$copyresult .= $uploadmsg."\n";
|
} |
}
|
|
}
|
sub get_dependencies { |
}
|
my ($exportitems,$parent,$depth,$dependencies) = @_; |
if ($message) {
|
if ($depth > 1) { |
$$copyresult .= $message."\n";
|
if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) { |
}
|
push(@{$dependencies},$$parent{$depth}); |
}
|
if ($depth > 2) { |
|
&get_dependencies($exportitems,$parent,$depth-1,$dependencies); |
sub replicate_content {
|
} |
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
|
} |
my ($map,$ind,$url);
|
} |
if ($caller eq 'templateupload') {
|
} |
$url = $symb;
|
|
$url =~ s#//#/#g;
|
sub process_content { |
} else {
|
my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport,$format,$currdirpath,$testbank) = @_; |
($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
|
my $content_type; |
}
|
my $message; |
my $content;
|
my @uploads = (); |
my $filename;
|
if ($curRes->is_sequence()) { |
my $repstatus;
|
$content_type = 'sequence'; |
my $content_name;
|
} elsif ($curRes->is_page()) { |
if ($url =~ m-/([^/]+)$-) {
|
$content_type = 'page'; # need to handle individual items in pages. |
$filename = $1;
|
} elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) { |
if (!-e $tempexport.'/resources') {
|
$content_type = 'syllabus'; |
mkdir($tempexport.'/resources',0700);
|
my $contents = &Apache::imsexport::templatedpage($content_type); |
}
|
if ($contents) { |
if (!-e $tempexport.'/resources/'.$count) {
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
mkdir($tempexport.'/resources/'.$count,0700);
|
} |
}
|
} elsif ($symb =~ m-\.sequence___\d+___ext-) { |
my $destination = $tempexport.'/resources/'.$count.'/'.$filename;
|
$content_type = 'external'; |
my $copiedfile;
|
my $title = $curRes->title; |
if ($copiedfile = Apache::File->new('>'.$destination)) {
|
my $contents = &Apache::imsexport::external($symb,$title); |
my $content;
|
if ($contents) { |
if ($caller eq 'resource') {
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
|
} |
my $filepath = &Apache::lonnet::filelocation($respath,$url);
|
} elsif ($symb =~ m-adm/navmaps$-) { |
$content = &Apache::lonnet::getfile($filepath);
|
$content_type = 'navmap'; |
if ($content eq -1) {
|
} elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) { |
$$message = 'Could not copy file '.$filename;
|
$content_type = 'simplepage'; |
} else {
|
my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads); |
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource');
|
if ($contents) { |
$repstatus = 'ok';
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
}
|
} |
} elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
|
} elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) { |
my $rtncode;
|
$content_type = 'simpleproblem'; |
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
|
my $contents = &Apache::imsexport::simpleproblem($symb); |
if ($repstatus eq 'ok') {
|
if ($contents) { |
if ($url =~ /\.html?$/i) {
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded');
|
} |
}
|
} elsif ($symb =~ m-lib/templates/examupload\.problem$-) { |
} else {
|
$content_type = 'examupload'; |
$$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n";
|
} elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) { |
}
|
$content_type = 'bulletinboard'; |
} elsif ($caller eq 'noedit') {
|
my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2); |
# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this.
|
if ($contents) { |
$repstatus = 'ok';
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
$content = 'Not the owner of this resource';
|
} |
}
|
} elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) { |
if ($repstatus eq 'ok') {
|
$content_type = 'aboutme'; |
print $copiedfile $content;
|
my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2); |
}
|
if ($contents) { |
close($copiedfile);
|
$$content_file = &store_template($contents,$tempexport,$count,$content_type); |
} else {
|
} |
$$message = 'Could not open destination file for '.$filename."<br />\n";
|
} elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) { |
}
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded'); |
} else {
|
} elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) { |
$$message = 'Could not determine name of file for '.$symb."<br />\n";
|
my $canedit = 0; |
}
|
if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) { |
if ($repstatus eq 'ok') {
|
$canedit= 1; |
$content_name = 'resources/'.$count.'/'.$filename;
|
} |
}
|
# only include problem code where current user is author |
return $content_name;
|
if (($format eq 'html') || ($format eq 'plaintext')) { |
}
|
my $title = $curRes->title; |
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,$format,$currdirpath,$title,$testbank); |
sub extract_media {
|
} elsif ($format eq 'xml') { |
my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
|
if ($canedit) { |
my ($dirpath,$container);
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource'); |
my %allfiles = ();
|
} else { |
my %codebase = ();
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit'); |
if ($url =~ m-(.*/)([^/]+)$-) {
|
} |
$dirpath = $1;
|
} |
$container = $2;
|
} elsif ($symb =~ m-uploaded/$cdom/$cnum-) { |
} else {
|
$$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded'); |
$dirpath = $url;
|
} |
$container = '';
|
if (@uploads > 0) { |
}
|
foreach my $item (@uploads) { |
&Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
|
my $uploadmsg = ''; |
foreach my $embed_file (keys(%allfiles)) {
|
&replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload'); |
my $filename;
|
if ($uploadmsg) { |
if ($embed_file =~ m#([^/]+)$#) {
|
$$copyresult .= $uploadmsg."\n"; |
$filename = $1;
|
} |
} else {
|
} |
$filename = $embed_file;
|
} |
}
|
if ($message) { |
my $newname = 'res/'.$filename;
|
$$copyresult .= $message."\n"; |
my ($rtncode,$embed_content,$repstatus);
|
} |
my $embed_url;
|
} |
if ($embed_file =~ m-^/-) {
|
|
$embed_url = $embed_file; # points to absolute path
|
sub replicate_content { |
} else {
|
my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller,$currdirpath, |
if ($embed_file =~ m-https?://-) {
|
$title,$testbank) = @_; |
next; # points to url
|
my ($map,$ind,$url); |
} else {
|
if ($caller eq 'templateupload') { |
$embed_url = $dirpath.$embed_file; # points to relative path
|
$url = $symb; |
}
|
$url =~ s#//#/#g; |
}
|
} else { |
if ($caller eq 'resource') {
|
($map,$ind,$url)=&Apache::lonnet::decode_symb($symb); |
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
|
} |
my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url);
|
my $content; |
$embed_content = &Apache::lonnet::getfile($embed_path);
|
my $filename; |
unless ($embed_content eq -1) {
|
my $repstatus; |
$repstatus = 'ok';
|
my $content_name; |
}
|
if ($url =~ m-/([^/]+)$-) { |
} elsif ($caller eq 'uploaded') {
|
$filename = $1; |
|
if (!-e $tempexport.'/resources') { |
$repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
|
mkdir($tempexport.'/resources',0700); |
}
|
} |
if ($repstatus eq 'ok') {
|
if (!-e $tempexport.'/resources/'.$count) { |
my $destination = $tempexport.'/resources/'.$count.'/res';
|
mkdir($tempexport.'/resources/'.$count,0700); |
if (!-e "$destination") {
|
} |
mkdir($destination,0755);
|
my $destination = $tempexport.'/resources/'.$count.'/'.$filename; |
}
|
my $copiedfile; |
$destination .= '/'.$filename;
|
if ($copiedfile = Apache::File->new('>'.$destination)) { |
my $copiedfile;
|
my $content; |
if ($copiedfile = Apache::File->new('>'.$destination)) {
|
if ($caller eq 'resource') { |
print $copiedfile $embed_content;
|
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; |
push(@{$href},'resources/'.$count.'/res/'.$filename);
|
my $filepath = &Apache::lonnet::filelocation($respath,$url); |
my $attrib_regexp = '';
|
$content = &Apache::lonnet::getfile($filepath); |
if (@{$allfiles{$embed_file}} > 1) {
|
if ($content eq -1) { |
$attrib_regexp = join('|',@{$allfiles{$embed_file}});
|
$$message = 'Could not copy file '.$filename; |
} else {
|
} else { |
$attrib_regexp = $allfiles{$embed_file}[0];
|
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource'); |
}
|
$repstatus = 'ok'; |
$$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
|
} |
if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
|
} elsif ($caller eq 'uploaded' || $caller eq 'templateupload') { |
$$content =~ s#\Q$embed_file\E#$newname#gi;
|
my $rtncode; |
}
|
$repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode); |
}
|
if ($repstatus eq 'ok') { |
} else {
|
if ($url =~ /\.html?$/i) { |
$$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n";
|
&extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded'); |
}
|
} |
}
|
} else { |
return;
|
$$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n"; |
}
|
} |
|
} elsif (($caller eq 'noedit') || ($caller eq 'html') || |
sub store_template {
|
($caller eq 'plaintext')) { |
my ($contents,$tempexport,$count,$content_type) = @_;
|
# Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. |
if ($contents) {
|
my %form = ( |
if ($tempexport) {
|
grade_symb => $symb, |
if (!-e $tempexport.'/resources') {
|
grade_courseid => $cdom.'_'.$cnum, |
mkdir($tempexport.'/resources',0700);
|
grade_domain => $env{'user.domain'}, |
}
|
grade_username => $env{'user.name'}, |
if (!-e $tempexport.'/resources/'.$count) {
|
grade_imsexport => 1, |
mkdir($tempexport.'/resources/'.$count,0700);
|
instructor_comments => 'hide', |
}
|
); |
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
|
my $feedurl=&Apache::lonnet::clutter($url); |
my $storetemplate;
|
my ($userview,$response)=&Apache::lonnet::ssi_body($feedurl,%form); |
if ($storetemplate = Apache::File->new('>'.$destination)) {
|
if (ref($response)) { |
print $storetemplate $contents;
|
if ($response->is_success) { |
close($storetemplate);
|
$content = $userview; |
}
|
$content =~ s/\Qonchange="javascript:setSubmittedPart('\E[^\']+\Q');"\E//g; |
if ($content_type eq 'external') {
|
$content =~ s/^\s*[\n\r]+$//; |
return 'resources/'.$count.'/'.$content_type.'.html';
|
if ($caller eq 'plaintext') { |
} else {
|
my @lines = split(/[\n\r]+/,$content); |
return 'resources/'.$count.'/'.$content_type.'.xml';
|
my @tosave; |
}
|
my $foilcounter = 0; |
}
|
my @alphabet = ('a'..'z'); |
}
|
my $mc_answer; |
}
|
foreach my $line (@lines) { |
|
next if ($line =~ /^\s*$/); |
|
if ($line =~ m{(|\Q<\label>\E)\Q<br />Incorrect:<label>\E}) { |
sub group_import {
|
$foilcounter ++; |
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
|
} elsif ($line =~ m{(|\Q</label>\E)\Q<br />Correct:<b><label>\E}) { |
|
$foilcounter ++; |
while (@files) {
|
$mc_answer = $alphabet[$foilcounter-1]; |
my ($name, $url, $residx) = @{ shift(@files) };
|
} elsif ($line !~ m{\Q</label>\E(|\Q</b>\E)\Q<br />\E}) { |
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
|
$line =~ s/^(\s+|\s+)$//g; |
&& ($caller eq 'londocs')
|
$line =~ s{^\Q<b>\E([^<]+)\Q</b>\E$}{1}; |
&& (!&Apache::lonnet::stat_file($url))) {
|
$tosave[$foilcounter] .= $line.' '; |
|
} |
my $errtext = '';
|
$content = join("\t",@tosave); |
my $fatal = 0;
|
if ($mc_answer) { |
my $newmapstr = '<map>'."\n".
|
$content .= "\t".$mc_answer."\n"; |
'<resource id="1" src="" type="start"></resource>'."\n".
|
} |
'<link from="1" to="2" index="1"></link>'."\n".
|
} |
'<resource id="2" src="" type="finish"></resource>'."\n".
|
if (@tosave) { |
'</map>';
|
my $qtype; |
$env{'form.output'}=$newmapstr;
|
if ($mc_answer) { |
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
|
$qtype = 'MC'; |
'output',$1.$2);
|
} |
if ($result != m|^/uploaded/|) {
|
$content = $currdirpath."\t".$title."\t$qtype\t".join("\t",@tosave); |
$errtext.='Map not saved: A network error occurred when trying to save the new map. ';
|
if ($mc_answer) { |
$fatal = 2;
|
$content .= "\t".$mc_answer; |
}
|
} |
if ($fatal) {
|
$content .= "\n"; |
return ($errtext,$fatal);
|
} |
}
|
} else { |
}
|
$content = '<html><body>'.$content.'</body></html>'; |
if ($url) {
|
} |
if (!$residx
|
if (($caller eq 'plaintext') && ($testbank)) { |
|| defined($LONCAPA::map::zombies[$residx])) {
|
print $testbank $content; |
$residx = &LONCAPA::map::getresidx($url,$residx);
|
} |
push(@LONCAPA::map::order, $residx);
|
} else { |
}
|
$content = 'Not the owner of this resource'; |
my $ext = 'false';
|
} |
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
|
} else { |
$url = &LONCAPA::map::qtunescape($url);
|
$content = 'Not the owner of this resource'; |
$name = &LONCAPA::map::qtunescape($name);
|
} |
$LONCAPA::map::resources[$residx] =
|
$repstatus = 'ok'; |
join(':', ($name, $url, $ext, 'normal', 'res'));
|
} |
}
|
if ($repstatus eq 'ok') { |
}
|
print $copiedfile $content; |
return &storemap($coursenum, $coursedom, $folder.'.'.$container);
|
} |
}
|
close($copiedfile); |
|
} else { |
sub breadcrumbs {
|
$$message = 'Could not open destination file for '.$filename."<br />\n"; |
my ($where,$allowed,$type)=@_;
|
} |
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
} else { |
my (@folders);
|
$$message = 'Could not determine name of file for '.$symb."<br />\n"; |
if ($env{'form.pagepath'}) {
|
} |
@folders = split('&',$env{'form.pagepath'});
|
if ($repstatus eq 'ok') { |
} else {
|
$content_name = 'resources/'.$count.'/'.$filename; |
@folders=split('&',$env{'form.folderpath'});
|
} |
}
|
return $content_name; |
my $folderpath;
|
} |
my $cpinfo='';
|
|
my $plain='';
|
sub extract_media { |
my $randompick=-1;
|
my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_; |
my $isencrypted=0;
|
my ($dirpath,$container); |
my $ishidden=0;
|
my %allfiles = (); |
my $is_random_order=0;
|
my %codebase = (); |
while (@folders) {
|
if ($url =~ m-(.*/)([^/]+)$-) { |
my $folder=shift(@folders);
|
$dirpath = $1; |
my $foldername=shift(@folders);
|
$container = $2; |
if ($folderpath) {$folderpath.='&';}
|
} else { |
$folderpath.=$folder.'&'.$foldername;
|
$dirpath = $url; |
my $url='/adm/coursedocs?folderpath='.
|
$container = ''; |
&escape($folderpath);
|
} |
my $name=&unescape($foldername);
|
&Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content); |
# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
|
foreach my $embed_file (keys(%allfiles)) { |
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
|
my $filename; |
if ($1 ne '') {
|
if ($embed_file =~ m#([^/]+)$#) { |
$randompick=$1;
|
$filename = $1; |
} else {
|
} else { |
$randompick=-1;
|
$filename = $embed_file; |
}
|
} |
if ($2) { $ishidden=1; }
|
my $newname = 'res/'.$filename; |
if ($3) { $isencrypted=1; }
|
my ($rtncode,$embed_content,$repstatus); |
if ($4 ne '') { $is_random_order = 1; }
|
my $embed_url; |
if ($folder eq 'supplemental') {
|
if ($embed_file =~ m-^/-) { |
if ($allowed) {
|
$embed_url = $embed_file; # points to absolute path |
$name = &mt('Supplemental '.$type.' Documents');
|
} else { |
} else {
|
if ($embed_file =~ m-https?://-) { |
$name = &mt($type.' Documents');
|
next; # points to url |
}
|
} else { |
}
|
$embed_url = $dirpath.$embed_file; # points to relative path |
&Apache::lonhtmlcommon::add_breadcrumb(
|
} |
{'href'=>$url.$cpinfo,
|
} |
'title'=>$name,
|
if ($caller eq 'resource') { |
'text'=>'<font size="+1">'.
|
my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res'; |
$name.'</font>',
|
my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url); |
'no_mt'=>1,
|
$embed_content = &Apache::lonnet::getfile($embed_path); |
});
|
unless ($embed_content eq -1) { |
$plain.=$name.' > ';
|
$repstatus = 'ok'; |
}
|
} |
$plain=~s/\>\;\s*$//;
|
} elsif ($caller eq 'uploaded') { |
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
|
$repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode); |
'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
|
} |
}
|
if ($repstatus eq 'ok') { |
|
my $destination = $tempexport.'/resources/'.$count.'/res'; |
sub log_docs {
|
if (!-e "$destination") { |
return &Apache::lonnet::instructor_log('docslog',@_);
|
mkdir($destination,0755); |
}
|
} |
|
$destination .= '/'.$filename; |
{
|
my $copiedfile; |
my @oldresources=();
|
if ($copiedfile = Apache::File->new('>'.$destination)) { |
my @oldorder=();
|
print $copiedfile $embed_content; |
my $parmidx;
|
push(@{$href},'resources/'.$count.'/res/'.$filename); |
my %parmaction=();
|
my $attrib_regexp = ''; |
my %parmvalue=();
|
if (@{$allfiles{$embed_file}} > 1) { |
my $changedflag;
|
$attrib_regexp = join('|',@{$allfiles{$embed_file}}); |
|
} else { |
sub snapshotbefore {
|
$attrib_regexp = $allfiles{$embed_file}[0]; |
@oldresources=@LONCAPA::map::resources;
|
} |
@oldorder=@LONCAPA::map::order;
|
$$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi; |
$parmidx=undef;
|
if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) { |
%parmaction=();
|
$$content =~ s#\Q$embed_file\E#$newname#gi; |
%parmvalue=();
|
} |
$changedflag=0;
|
} |
}
|
} else { |
|
$$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n"; |
sub remember_parms {
|
} |
my ($idx,$parameter,$action,$value)=@_;
|
} |
$parmidx=$idx;
|
return; |
$parmaction{$parameter}=$action;
|
} |
$parmvalue{$parameter}=$value;
|
|
$changedflag=1;
|
sub store_template { |
}
|
my ($contents,$tempexport,$count,$content_type) = @_; |
|
if ($contents) { |
sub log_differences {
|
if ($tempexport) { |
my ($plain)=@_;
|
if (!-e $tempexport.'/resources') { |
my %storehash=('folder' => $plain,
|
mkdir($tempexport.'/resources',0700); |
'currentfolder' => $env{'form.folder'});
|
} |
if ($parmidx) {
|
if (!-e $tempexport.'/resources/'.$count) { |
$storehash{'parameter_res'}=$oldresources[$parmidx];
|
mkdir($tempexport.'/resources/'.$count,0700); |
foreach my $parm (keys(%parmaction)) {
|
} |
$storehash{'parameter_action_'.$parm}=$parmaction{$parm};
|
my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml'; |
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
|
my $storetemplate; |
}
|
if ($storetemplate = Apache::File->new('>'.$destination)) { |
}
|
print $storetemplate $contents; |
my $maxidx=$#oldresources;
|
close($storetemplate); |
if ($#LONCAPA::map::resources>$#oldresources) {
|
} |
$maxidx=$#LONCAPA::map::resources;
|
if ($content_type eq 'external') { |
}
|
return 'resources/'.$count.'/'.$content_type.'.html'; |
for (my $idx=0; $idx<=$maxidx; $idx++) {
|
} else { |
if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
|
return 'resources/'.$count.'/'.$content_type.'.xml'; |
$storehash{'before_resources_'.$idx}=$oldresources[$idx];
|
} |
$storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
|
} |
$changedflag=1;
|
} |
}
|
} |
if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
|
|
$storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
|
|
$storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
sub group_import { |
$changedflag=1;
|
my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; |
}
|
|
}
|
while (@files) { |
$storehash{'maxidx'}=$maxidx;
|
my ($name, $url, $residx) = @{ shift(@files) }; |
if ($changedflag) { &log_docs(\%storehash); }
|
if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) |
}
|
&& ($caller eq 'londocs') |
}
|
&& (!&Apache::lonnet::stat_file($url))) { |
|
|
|
my $errtext = ''; |
|
my $fatal = 0; |
|
my $newmapstr = '<map>'."\n". |
|
'<resource id="1" src="" type="start"></resource>'."\n". |
sub docs_change_log {
|
'<link from="1" to="2" index="1"></link>'."\n". |
my ($r)=@_;
|
'<resource id="2" src="" type="finish"></resource>'."\n". |
my $folder=$env{'form.folder'};
|
'</map>'; |
$r->print(&Apache::loncommon::start_page('Course Document Change Log'));
|
$env{'form.output'}=$newmapstr; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
|
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom, |
my %docslog=&Apache::lonnet::dump('nohist_docslog',
|
'output',$1.$2); |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
if ($result != m|^/uploaded/|) { |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
$errtext.='Map not saved: A network error occurred when trying to save the new map. '; |
|
$fatal = 2; |
if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
|
} |
|
if ($fatal) { |
$r->print('<form action="/adm/coursedocs" method="post" name="docslog">'.
|
return ($errtext,$fatal); |
'<input type="hidden" name="docslog" value="1" />');
|
} |
|
} |
my %saveable_parameters = ('show' => 'scalar',);
|
if ($url) { |
&Apache::loncommon::store_course_settings('docs_log',
|
if (!$residx |
\%saveable_parameters);
|
|| defined($LONCAPA::map::zombies[$residx])) { |
&Apache::loncommon::restore_course_settings('docs_log',
|
$residx = &LONCAPA::map::getresidx($url,$residx); |
\%saveable_parameters);
|
push(@LONCAPA::map::order, $residx); |
if (!$env{'form.show'}) { $env{'form.show'}=10; }
|
} |
my %lt=('hiddenresource' => 'Resources hidden',
|
my $ext = 'false'; |
'encrypturl' => 'URL hidden',
|
if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } |
'randompick' => 'Randomly pick',
|
$url = &LONCAPA::map::qtunescape($url); |
'randomorder' => 'Randomly ordered',
|
$name = &LONCAPA::map::qtunescape($name); |
'set' => 'set to',
|
$LONCAPA::map::resources[$residx] = |
'del' => 'deleted');
|
join(':', ($name, $url, $ext, 'normal', 'res')); |
$r->print(&Apache::loncommon::display_filter().
|
} |
'<input type="hidden" name="folder" value="'.$folder.'" />'.
|
} |
'<input type="submit" value="'.&mt('Display').'" /></form>');
|
return &storemap($coursenum, $coursedom, $folder.'.'.$container); |
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
|
} |
'<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
|
|
&mt('After').'</th>'.
|
sub breadcrumbs { |
&Apache::loncommon::end_data_table_header_row());
|
my ($allowed,$crstype)=@_; |
my $shown=0;
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
|
my (@folders); |
if ($env{'form.displayfilter'} eq 'currentfolder') {
|
if ($env{'form.pagepath'}) { |
if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
|
@folders = split('&',$env{'form.pagepath'}); |
}
|
} else { |
my @changes=keys(%{$docslog{$id}{'logentry'}});
|
@folders=split('&',$env{'form.folderpath'}); |
if ($env{'form.displayfilter'} eq 'containing') {
|
} |
my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
|
my $folderpath; |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
|
my $cpinfo=''; |
foreach my $key (@changes) {
|
my $plain=''; |
$wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
|
my $randompick=-1; |
}
|
my $isencrypted=0; |
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
|
my $ishidden=0; |
}
|
my $is_random_order=0; |
my $count = 0;
|
if (!$allowed) { |
my $time =
|
my $description = $env{'course.'.$env{'request.course.id'}.'.description'}; |
&Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
|
&Apache::lonhtmlcommon::add_breadcrumb( |
my $plainname =
|
{'href' => '/adm/menu', |
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
|
'title'=> 'Go to main menu', |
$docslog{$id}{'exe_udom'});
|
'text' => $description, |
my $about_me_link =
|
}); |
&Apache::loncommon::aboutmewrapper($plainname,
|
$plain .= $description.' >'; |
$docslog{$id}{'exe_uname'},
|
} |
$docslog{$id}{'exe_udom'});
|
while (@folders) { |
my $send_msg_link='';
|
my $folder=shift(@folders); |
if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
|
my $foldername=shift(@folders); |
|| ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
|
if ($folderpath) {$folderpath.='&';} |
$send_msg_link ='<br />'.
|
$folderpath.=$folder.'&'.$foldername; |
&Apache::loncommon::messagewrapper(&mt('Send message'),
|
my $url='/adm/coursedocs?folderpath='. |
$docslog{$id}{'exe_uname'},
|
&escape($folderpath); |
$docslog{$id}{'exe_udom'});
|
my $name=&unescape($foldername); |
}
|
# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername |
$r->print(&Apache::loncommon::start_data_table_row());
|
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; |
$r->print('<td>'.$time.'</td>
|
if ($1 ne '') { |
<td>'.$about_me_link.
|
$randompick=$1; |
'<br /><tt>'.$docslog{$id}{'exe_uname'}.
|
} else { |
':'.$docslog{$id}{'exe_udom'}.'</tt>'.
|
$randompick=-1; |
$send_msg_link.'</td><td>'.
|
} |
$docslog{$id}{'logentry'}{'folder'}.'</td><td>');
|
if ($2) { $ishidden=1; } |
# Before
|
if ($3) { $isencrypted=1; } |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
if ($4 ne '') { $is_random_order = 1; } |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
if ($folder eq 'supplemental') { |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
$name = &mt('Supplemental '.$crstype.' Documents'); |
if ($oldname ne $newname) {
|
} |
$r->print(&LONCAPA::map::qtescape($oldname));
|
&Apache::lonhtmlcommon::add_breadcrumb( |
}
|
{'href'=>$url.$cpinfo, |
}
|
'title'=>$name, |
$r->print('<ul>');
|
'text'=>$name, |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
'no_mt'=>1, |
if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
|
}); |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
|
$plain.=$name.' > '; |
}
|
} |
}
|
$plain=~s/\>\;\s*$//; |
$r->print('</ul>');
|
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', |
# After
|
undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); |
$r->print('</td><td>');
|
} |
|
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
sub log_docs { |
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
|
return &Apache::lonnet::instructor_log('docslog',@_); |
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
|
} |
if ($oldname ne '' && $oldname ne $newname) {
|
|
$r->print(&LONCAPA::map::qtescape($newname));
|
{ |
}
|
my @oldresources=(); |
}
|
my @oldorder=(); |
$r->print('<ul>');
|
my $parmidx; |
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
|
my %parmaction=(); |
if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
|
my %parmvalue=(); |
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
|
my $changedflag; |
}
|
|
}
|
sub snapshotbefore { |
$r->print('</ul>');
|
@oldresources=@LONCAPA::map::resources; |
if ($docslog{$id}{'logentry'}{'parameter_res'}) {
|
@oldorder=@LONCAPA::map::order; |
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
|
$parmidx=undef; |
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
|
%parmaction=(); |
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
|
%parmvalue=(); |
$r->print('<li>'.
|
$changedflag=0; |
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
|
} |
$docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
|
|
.'</li>');
|
sub remember_parms { |
}
|
my ($idx,$parameter,$action,$value)=@_; |
}
|
$parmidx=$idx; |
$r->print('</ul>');
|
$parmaction{$parameter}=$action; |
}
|
$parmvalue{$parameter}=$value; |
# End
|
$changedflag=1; |
$r->print('</td>'.&Apache::loncommon::end_data_table_row());
|
} |
$shown++;
|
|
if (!($env{'form.show'} eq &mt('all')
|
sub log_differences { |
|| $shown<=$env{'form.show'})) { last; }
|
my ($plain)=@_; |
}
|
my %storehash=('folder' => $plain, |
$r->print(&Apache::loncommon::end_data_table());
|
'currentfolder' => $env{'form.folder'}); |
}
|
if ($parmidx) { |
|
$storehash{'parameter_res'}=$oldresources[$parmidx]; |
sub update_paste_buffer {
|
foreach my $parm (keys(%parmaction)) { |
my ($coursenum,$coursedom) = @_;
|
$storehash{'parameter_action_'.$parm}=$parmaction{$parm}; |
|
$storehash{'parameter_value_'.$parm}=$parmvalue{$parm}; |
return if (!defined($env{'form.markcopy'}));
|
} |
return if (!defined($env{'form.copyfolder'}));
|
} |
return if ($env{'form.markcopy'} < 0);
|
my $maxidx=$#oldresources; |
|
if ($#LONCAPA::map::resources>$#oldresources) { |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
$maxidx=$#LONCAPA::map::resources; |
$env{'form.copyfolder'});
|
} |
|
for (my $idx=0; $idx<=$maxidx; $idx++) { |
return if ($fatal);
|
if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) { |
|
$storehash{'before_resources_'.$idx}=$oldresources[$idx]; |
# Mark for copying
|
$storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx]; |
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
|
$changedflag=1; |
if (&is_supplemental_title($title)) {
|
} |
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
|
if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) { |
($title) = &parse_supplemental_title($title);
|
$storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]]; |
} elsif ($env{'docs.markedcopy_supplemental'}) {
|
$storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
&Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
|
$changedflag=1; |
}
|
} |
$url=~s{http(:|:)//https(:|:)//}{https$2//};
|
} |
|
$storehash{'maxidx'}=$maxidx; |
&Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
|
if ($changedflag) { &log_docs(\%storehash); } |
'docs.markedcopy_url' => $url});
|
} |
delete($env{'form.markcopy'});
|
} |
}
|
|
|
|
sub print_paste_buffer {
|
|
my ($r,$container) = @_;
|
|
return if (!defined($env{'docs.markedcopy_url'}));
|
|
|
sub docs_change_log { |
$r->print(<<ENDPASTE);
|
my ($r)=@_; |
<form name="pasteform" action="/adm/coursedocs" method="post"><p>
|
my $folder=$env{'form.folder'}; |
ENDPASTE
|
$r->print(&Apache::loncommon::start_page('Course Document Change Log')); |
$r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log')); |
|
my %docslog=&Apache::lonnet::dump('nohist_docslog', |
my $type;
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$type = &mt('External Resource');
|
|
$r->print($type.': '.
|
if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); } |
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
|
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
|
$r->print('<form action="/adm/coursedocs" method="post" name="docslog">'. |
} else {
|
'<input type="hidden" name="docslog" value="1" />'); |
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
|
|
my $icon = &Apache::loncommon::icon($extension);
|
my %saveable_parameters = ('show' => 'scalar',); |
if ($extension eq 'sequence' &&
|
&Apache::loncommon::store_course_settings('docs_log', |
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
|
\%saveable_parameters); |
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
|
&Apache::loncommon::restore_course_settings('docs_log', |
$icon .= '/folder_closed.gif';
|
\%saveable_parameters); |
}
|
if (!$env{'form.show'}) { $env{'form.show'}=10; } |
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
|
# FIXME: internationalization seems wrong here |
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
|
my %lt=('hiddenresource' => 'Resources hidden', |
}
|
'encrypturl' => 'URL hidden', |
if ($container eq 'page') {
|
'randompick' => 'Randomly pick', |
$r->print('
|
'randomorder' => 'Randomly ordered', |
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
|
'set' => 'set to', |
<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
|
'del' => 'deleted'); |
');
|
$r->print(&Apache::loncommon::display_filter(). |
} else {
|
'<input type="hidden" name="folder" value="'.$folder.'" />'. |
$r->print('
|
'<input type="submit" value="'.&mt('Display').'" /></form>'); |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). |
');
|
'<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'. |
}
|
&mt('After').'</th>'. |
$r->print('</p></form>');
|
&Apache::loncommon::end_data_table_header_row()); |
}
|
my $shown=0; |
|
foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) { |
sub do_paste_from_buffer {
|
if ($env{'form.displayfilter'} eq 'currentfolder') { |
my ($coursenum,$coursedom,$folder) = @_;
|
if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; } |
|
} |
if (!$env{'form.pastemarked'}) {
|
my @changes=keys(%{$docslog{$id}{'logentry'}}); |
return;
|
if ($env{'form.displayfilter'} eq 'containing') { |
}
|
my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'. |
|
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'}); |
# paste resource to end of list
|
foreach my $key (@changes) { |
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
|
$wholeentry.=':'.$docslog{$id}{'logentry'}{$key}; |
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
|
} |
# Maps need to be copied first
|
if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; } |
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
|
} |
$title=&mt('Copy of').' '.$title;
|
my $count = 0; |
my $newid=$$.int(rand(100)).time;
|
my $time = |
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
|
&Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'}); |
if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
|
my $plainname = |
my $path = $1;
|
&Apache::loncommon::plainname($docslog{$id}{'exe_uname'}, |
my $prefix = $2;
|
$docslog{$id}{'exe_udom'}); |
my $ancestor = $3;
|
my $about_me_link = |
if (length($ancestor) > 10) {
|
&Apache::loncommon::aboutmewrapper($plainname, |
$ancestor = substr($ancestor,-10,10);
|
$docslog{$id}{'exe_uname'}, |
}
|
$docslog{$id}{'exe_udom'}); |
$oldid = $path.$prefix.$ancestor;
|
my $send_msg_link=''; |
}
|
if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'}) |
my $counter = 0;
|
|| ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) { |
my $newurl=$oldid.$newid.'.'.$ext;
|
$send_msg_link ='<br />'. |
my $is_unique = &uniqueness_check($newurl);
|
&Apache::loncommon::messagewrapper(&mt('Send message'), |
while (!$is_unique && $counter < 100) {
|
$docslog{$id}{'exe_uname'}, |
$counter ++;
|
$docslog{$id}{'exe_udom'}); |
$newid ++;
|
} |
$newurl = $oldid.$newid;
|
$r->print(&Apache::loncommon::start_data_table_row()); |
$is_unique = &uniqueness_check($newurl);
|
$r->print('<td>'.$time.'</td> |
}
|
<td>'.$about_me_link. |
if (!$is_unique) {
|
'<br /><tt>'.$docslog{$id}{'exe_uname'}. |
if ($url=~/\.page$/) {
|
':'.$docslog{$id}{'exe_udom'}.'</tt>'. |
return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
|
$send_msg_link.'</td><td>'. |
} else {
|
$docslog{$id}{'logentry'}{'folder'}.'</td><td>'); |
return &mt('Paste failed: an error occurred creating a unique URL for the folder');
|
# Before |
}
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
}
|
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0]; |
my $storefn=$newurl;
|
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0]; |
$storefn=~s{^/\w+/$match_domain/$match_username/}{};
|
if ($oldname ne $newname) { |
my $paste_map_result =
|
$r->print(&LONCAPA::map::qtescape($oldname)); |
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
|
} |
&Apache::lonnet::getfile($url));
|
} |
if ($paste_map_result eq '/adm/notfound.html') {
|
$r->print('<ul>'); |
if ($url=~/\.page$/) {
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
return &mt('Paste failed: an error occurred saving the composite page');
|
if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) { |
} else {
|
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>'); |
return &mt('Paste failed: an error occurred saving the folder');
|
} |
}
|
} |
}
|
$r->print('</ul>'); |
$url = $newurl;
|
# After |
}
|
$r->print('</td><td>'); |
# published maps can only exists once, so remove it from paste buffer when done
|
|
if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
&Apache::lonnet::delenv('docs\\.markedcopy');
|
my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0]; |
}
|
my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0]; |
if ($url=~ m{/smppg$}) {
|
if ($oldname ne '' && $oldname ne $newname) { |
my $db_name = &Apache::lonsimplepage::get_db_name($url);
|
$r->print(&LONCAPA::map::qtescape($newname)); |
if ($db_name =~ /^smppage_/) {
|
} |
#simple pages, need to copy the db contents to a new one.
|
} |
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
|
$r->print('<ul>'); |
my $now = time();
|
for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) { |
$db_name =~ s{_\d*$ }{_$now}x;
|
if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) { |
my $result=&Apache::lonnet::put($db_name,\%contents,
|
$r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>'); |
$coursedom,$coursenum);
|
} |
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
|
} |
$title=&mt('Copy of').' '.$title;
|
$r->print('</ul>'); |
}
|
if ($docslog{$id}{'logentry'}{'parameter_res'}) { |
}
|
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>'); |
$title = &LONCAPA::map::qtunescape($title);
|
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') { |
my $ext='false';
|
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) { |
if ($url=~m{^http(|s)://}) { $ext='true'; }
|
# FIXME: internationalization seems wrong here |
$url = &LONCAPA::map::qtunescape($url);
|
$r->print('<li>'. |
# Now insert the URL at the bottom
|
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]', |
my $newidx = &LONCAPA::map::getresidx($url);
|
$docslog{$id}{'logentry'}{'parameter_value_'.$parameter}) |
if ($env{'docs.markedcopy_supplemental'}) {
|
.'</li>'); |
if ($folder =~ /^supplemental/) {
|
} |
$title = $env{'docs.markedcopy_supplemental'};
|
} |
} else {
|
$r->print('</ul>'); |
(undef,undef,$title) =
|
} |
&parse_supplemental_title($env{'docs.markedcopy_supplemental'});
|
# End |
}
|
$r->print('</td>'.&Apache::loncommon::end_data_table_row()); |
} else {
|
$shown++; |
if ($folder=~/^supplemental/) {
|
if (!($env{'form.show'} eq &mt('all') |
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
|| $shown<=$env{'form.show'})) { last; } |
$env{'user.domain'}.'___&&&___'.$title;
|
} |
}
|
$r->print(&Apache::loncommon::end_data_table()); |
}
|
} |
|
|
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
|
sub update_paste_buffer { |
push(@LONCAPA::map::order, $newidx);
|
my ($coursenum,$coursedom) = @_; |
return 'ok';
|
|
# Store the result
|
return if (!defined($env{'form.markcopy'})); |
}
|
return if (!defined($env{'form.copyfolder'})); |
|
return if ($env{'form.markcopy'} < 0); |
sub uniqueness_check {
|
|
my ($newurl) = @_;
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
my $unique = 1;
|
$env{'form.copyfolder'}); |
foreach my $res (@LONCAPA::map::order) {
|
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
return if ($fatal); |
$url=&LONCAPA::map::qtescape($url);
|
|
if ($newurl eq $url) {
|
# Mark for copying |
$unique = 0;
|
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]); |
last;
|
if (&is_supplemental_title($title)) { |
}
|
&Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title}); |
}
|
($title) = &parse_supplemental_title($title); |
return $unique;
|
} elsif ($env{'docs.markedcopy_supplemental'}) { |
}
|
&Apache::lonnet::delenv('docs.markedcopy_supplemental'); |
|
} |
my %parameter_type = ( 'randompick' => 'int_pos',
|
$url=~s{http(:|:)//https(:|:)//}{https$2//}; |
'hiddenresource' => 'string_yesno',
|
|
'encrypturl' => 'string_yesno',
|
&Apache::lonnet::appenv({'docs.markedcopy_title' => $title, |
'randomorder' => 'string_yesno',);
|
'docs.markedcopy_url' => $url}); |
my $valid_parameters_re = join('|',keys(%parameter_type));
|
delete($env{'form.markcopy'}); |
# set parameters
|
} |
sub update_parameter {
|
|
|
sub print_paste_buffer { |
return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
|
my ($r,$container) = @_; |
|
return if (!defined($env{'docs.markedcopy_url'})); |
my $which = $env{'form.changeparms'};
|
|
my $idx = $env{'form.setparms'};
|
$r->print('<fieldset>' |
if ($env{'form.'.$which.'_'.$idx}) {
|
.'<legend>'.&mt('Clipboard').'</legend>' |
my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
|
.'<form name="pasteform" action="/adm/coursedocs" method="post">' |
: 'yes';
|
.'<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ' |
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
|
); |
$parameter_type{$which});
|
|
&remember_parms($idx,$which,'set',$value);
|
my $type; |
} else {
|
if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) { |
&LONCAPA::map::delparameter($idx,'parameter_'.$which);
|
$type = &mt('External Resource'); |
|
$r->print($type.': '. |
&remember_parms($idx,$which,'del');
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('. |
}
|
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')'); |
return 1;
|
} else { |
}
|
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1]; |
|
my $icon = &Apache::loncommon::icon($extension); |
|
if ($extension eq 'sequence' && |
sub handle_edit_cmd {
|
$env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) { |
my ($coursenum,$coursedom) =@_;
|
$icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); |
|
$icon .= '/navmap.folder.closed.gif'; |
my ($cmd,$idx)=split('_',$env{'form.cmd'});
|
} |
|
$icon = '<img src="'.$icon.'" alt="" class="LC_icon" />'; |
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
|
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}))); |
my ($title, $url, @rrest) = split(':', $ratstr);
|
} |
|
if ($container eq 'page') { |
if ($cmd eq 'del') {
|
$r->print(' |
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
|
<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" /> |
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
|
<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" /> |
&Apache::lonnet::removeuploadedurl($url);
|
'); |
} else {
|
} else { |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
$r->print(' |
}
|
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /> |
splice(@LONCAPA::map::order, $idx, 1);
|
'); |
|
} |
} elsif ($cmd eq 'cut') {
|
$r->print('</form></fieldset>'); |
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
|
} |
splice(@LONCAPA::map::order, $idx, 1);
|
|
|
sub do_paste_from_buffer { |
} elsif ($cmd eq 'up'
|
my ($coursenum,$coursedom,$folder) = @_; |
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
|
|
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
|
if (!$env{'form.pastemarked'}) { |
|
return; |
} elsif ($cmd eq 'down'
|
} |
&& defined($LONCAPA::map::order[$idx+1])) {
|
|
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
|
# paste resource to end of list |
|
my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}); |
} elsif ($cmd eq 'rename') {
|
my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}); |
|
# Maps need to be copied first |
my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
|
if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) { |
if ($comment=~/\S/) {
|
$title=&mt('Copy of').' '.$title; |
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
|
my $newid=$$.int(rand(100)).time; |
$comment.':'.join(':', $url, @rrest);
|
my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/); |
}
|
if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) { |
# Devalidate title cache
|
my $path = $1; |
my $renamed_url=&LONCAPA::map::qtescape($url);
|
my $prefix = $2; |
&Apache::lonnet::devalidate_title_cache($renamed_url);
|
my $ancestor = $3; |
} else {
|
if (length($ancestor) > 10) { |
return 0;
|
$ancestor = substr($ancestor,-10,10); |
}
|
} |
return 1;
|
$oldid = $path.$prefix.$ancestor; |
}
|
} |
|
my $counter = 0; |
sub editor {
|
my $newurl=$oldid.$newid.'.'.$ext; |
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
|
my $is_unique = &uniqueness_check($newurl); |
|
while (!$is_unique && $counter < 100) { |
my $container= ($env{'form.pagepath'}) ? 'page'
|
$counter ++; |
: 'sequence';
|
$newid ++; |
|
$newurl = $oldid.$newid; |
my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
|
$is_unique = &uniqueness_check($newurl); |
$folder.'.'.$container);
|
} |
return $errtext if ($fatal);
|
if (!$is_unique) { |
|
if ($url=~/\.page$/) { |
if ($#LONCAPA::map::order<1) {
|
return &mt('Paste failed: an error occurred creating a unique URL for the composite page'); |
my $idx=&LONCAPA::map::getresidx();
|
} else { |
if ($idx<=0) { $idx=1; }
|
return &mt('Paste failed: an error occurred creating a unique URL for the folder'); |
$LONCAPA::map::order[0]=$idx;
|
} |
$LONCAPA::map::resources[$idx]='';
|
} |
}
|
my $storefn=$newurl; |
|
$storefn=~s{^/\w+/$match_domain/$match_username/}{}; |
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
|
my $paste_map_result = |
&breadcrumbs($folder,$allowed,$type);
|
&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn, |
$r->print($breadcrumbtrail);
|
&Apache::lonnet::getfile($url)); |
|
if ($paste_map_result eq '/adm/notfound.html') { |
# ------------------------------------------------------------ Process commands
|
if ($url=~/\.page$/) { |
|
return &mt('Paste failed: an error occurred saving the composite page'); |
# ---------------- if they are for this folder and user allowed to make changes
|
} else { |
if (($allowed) && ($env{'form.folder'} eq $folder)) {
|
return &mt('Paste failed: an error occurred saving the folder'); |
# set parameters and change order
|
} |
&snapshotbefore();
|
} |
|
$url = $newurl; |
if (&update_parameter()) {
|
} |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
# published maps can only exists once, so remove it from paste buffer when done |
return $errtext if ($fatal);
|
if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) { |
}
|
&Apache::lonnet::delenv('docs.markedcopy'); |
|
} |
if ($env{'form.newpos'} && $env{'form.currentpos'}) {
|
if ($url=~ m{/smppg$}) { |
# change order
|
my $db_name = &Apache::lonsimplepage::get_db_name($url); |
my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
|
if ($db_name =~ /^smppage_/) { |
splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
|
#simple pages, need to copy the db contents to a new one. |
|
my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum); |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
my $now = time(); |
return $errtext if ($fatal);
|
$db_name =~ s{_\d*$ }{_$now}x; |
}
|
my $result=&Apache::lonnet::put($db_name,\%contents, |
|
$coursedom,$coursenum); |
if ($env{'form.pastemarked'}) {
|
$url =~ s{/(\d*)/smppg$ }{/$now/smppg}x; |
my $paste_res =
|
$title=&mt('Copy of').' '.$title; |
&do_paste_from_buffer($coursenum,$coursedom,$folder);
|
} |
if ($paste_res eq 'ok') {
|
} |
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
|
$title = &LONCAPA::map::qtunescape($title); |
return $errtext if ($fatal);
|
my $ext='false'; |
} elsif ($paste_res ne '') {
|
if ($url=~m{^http(|s)://}) { $ext='true'; } |
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
|
$url = &LONCAPA::map::qtunescape($url); |
}
|
# Now insert the URL at the bottom |
}
|
my $newidx = &LONCAPA::map::getresidx($url); |
|
if ($env{'docs.markedcopy_supplemental'}) { |
$r->print($upload_output);
|
if ($folder =~ /^supplemental/) { |
|
$title = $env{'docs.markedcopy_supplemental'}; |
if (&handle_edit_cmd()) {
|
} else { |
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
|
(undef,undef,$title) = |
return $errtext if ($fatal);
|
&parse_supplemental_title($env{'docs.markedcopy_supplemental'}); |
}
|
} |
# Group import/search
|
} else { |
if ($env{'form.importdetail'}) {
|
if ($folder=~/^supplemental/) { |
my @imports;
|
$title=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
foreach my $item (split(/\&/,$env{'form.importdetail'})) {
|
$env{'user.domain'}.'___&&&___'.$title; |
if (defined($item)) {
|
} |
my ($name,$url,$residx)=
|
} |
map {&unescape($_)} split(/\=/,$item);
|
|
push(@imports, [$name, $url, $residx]);
|
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res'; |
}
|
push(@LONCAPA::map::order, $newidx); |
}
|
return 'ok'; |
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
|
# Store the result |
$container,'londocs',@imports);
|
} |
return $errtext if ($fatal);
|
|
}
|
sub uniqueness_check { |
# Loading a complete map
|
my ($newurl) = @_; |
if ($env{'form.loadmap'}) {
|
my $unique = 1; |
if ($env{'form.importmap'}=~/\w/) {
|
foreach my $res (@LONCAPA::map::order) { |
foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
my ($title,$url,$ext,$type)=split(/\:/,$res);
|
$url=&LONCAPA::map::qtescape($url); |
my $idx=&LONCAPA::map::getresidx($url);
|
if ($newurl eq $url) { |
$LONCAPA::map::resources[$idx]=$res;
|
$unique = 0; |
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
|
last; |
}
|
} |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
} |
$folder.'.'.$container);
|
return $unique; |
return $errtext if ($fatal);
|
} |
} else {
|
|
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
|
my %parameter_type = ( 'randompick' => 'int_pos', |
|
'hiddenresource' => 'string_yesno', |
}
|
'encrypturl' => 'string_yesno', |
}
|
'randomorder' => 'string_yesno',); |
&log_differences($plain);
|
my $valid_parameters_re = join('|',keys(%parameter_type)); |
}
|
# set parameters |
# ---------------------------------------------------------------- End commands
|
sub update_parameter { |
# ---------------------------------------------------------------- Print screen
|
|
my $idx=0;
|
return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/); |
my $shown=0;
|
|
if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
|
my $which = $env{'form.changeparms'}; |
$r->print('<p>'.&mt('Parameters').':<ul>'.
|
my $idx = $env{'form.setparms'}; |
($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
|
if ($env{'form.'.$which.'_'.$idx}) { |
($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
|
my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx} |
($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
|
: 'yes'; |
'</ul></p>');
|
&LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value, |
}
|
$parameter_type{$which}); |
if ($randompick>=0) {
|
&remember_parms($idx,$which,'set',$value); |
$r->print('<p>'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'</p>');
|
} else { |
}
|
&LONCAPA::map::delparameter($idx,'parameter_'.$which); |
if ($is_random_order) {
|
|
$r->print('<p>'.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown.').'</p>');
|
&remember_parms($idx,$which,'del'); |
}
|
} |
$r->print('<table class="LC_docs_editor">');
|
return 1; |
foreach my $res (@LONCAPA::map::order) {
|
} |
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
|
|
$name=&LONCAPA::map::qtescape($name);
|
|
$url=&LONCAPA::map::qtescape($url);
|
sub handle_edit_cmd { |
unless ($name) { $name=(split(/\//,$url))[-1]; }
|
my ($coursenum,$coursedom) =@_; |
unless ($name) { $idx++; next; }
|
|
$r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
|
my ($cmd,$idx)=split('_',$env{'form.cmd'}); |
$coursenum));
|
|
$idx++;
|
my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; |
$shown++;
|
my ($title, $url, @rrest) = split(':', $ratstr); |
}
|
|
unless ($shown) {
|
if ($cmd eq 'del') { |
$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
|
if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && |
}
|
($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { |
$r->print("\n</table>\n");
|
&Apache::lonnet::removeuploadedurl($url); |
if ($allowed) {
|
} else { |
&print_paste_buffer($r,$container);
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
}
|
} |
return;
|
splice(@LONCAPA::map::order, $idx, 1); |
}
|
|
|
} elsif ($cmd eq 'cut') { |
sub process_file_upload {
|
&LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); |
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
|
splice(@LONCAPA::map::order, $idx, 1); |
# upload a file, if present
|
|
my $parseaction;
|
} elsif ($cmd eq 'up' |
if ($env{'form.parserflag'}) {
|
&& ($idx) && (defined($LONCAPA::map::order[$idx-1]))) { |
$parseaction = 'parse';
|
@LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1]; |
}
|
|
my $phase_status;
|
} elsif ($cmd eq 'down' |
my $folder=$env{'form.folder'};
|
&& defined($LONCAPA::map::order[$idx+1])) { |
if ($folder eq '') {
|
@LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1]; |
$folder='default';
|
|
}
|
} elsif ($cmd eq 'rename') { |
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
|
|
my $errtext='';
|
my $comment = &LONCAPA::map::qtunescape($env{'form.title'}); |
my $fatal=0;
|
if ($comment=~/\S/) { |
my $container='sequence';
|
$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]= |
if ($env{'form.pagepath'}) {
|
$comment.':'.join(':', $url, @rrest); |
$container='page';
|
} |
}
|
# Devalidate title cache |
($errtext,$fatal)=
|
my $renamed_url=&LONCAPA::map::qtescape($url); |
&mapread($coursenum,$coursedom,$folder.'.'.$container);
|
&Apache::lonnet::devalidate_title_cache($renamed_url); |
if ($#LONCAPA::map::order<1) {
|
} else { |
$LONCAPA::map::order[0]=1;
|
return 0; |
$LONCAPA::map::resources[1]='';
|
} |
}
|
return 1; |
if ($fatal) {
|
} |
return 'failed';
|
|
}
|
sub editor { |
my $destination = 'docs/';
|
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, |
if ($folder =~ /^supplemental/) {
|
$supplementalflag,$orderhash)=@_; |
$destination = 'supplemental/';
|
my $container= ($env{'form.pagepath'}) ? 'page' |
}
|
: 'sequence'; |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
|
$destination .= 'default/';
|
my ($errtext,$fatal) = &mapread($coursenum,$coursedom, |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
$folder.'.'.$container); |
$destination .= $2.'/';
|
return $errtext if ($fatal); |
}
|
|
# this is for a course, not a user, so set coursedoc flag
|
if ($#LONCAPA::map::order<1) { |
# probably the only place in the system where this should be "1"
|
my $idx=&LONCAPA::map::getresidx(); |
my $newidx=&LONCAPA::map::getresidx();
|
if ($idx<=0) { $idx=1; } |
$destination .= $newidx;
|
$LONCAPA::map::order[0]=$idx; |
my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
|
$LONCAPA::map::resources[$idx]=''; |
$parseaction,$allfiles,
|
} |
$codebase);
|
|
my $ext='false';
|
my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = |
if ($url=~m{^http://}) { $ext='true'; }
|
&breadcrumbs($allowed,$crstype); |
$url = &LONCAPA::map::qtunescape($url);
|
$r->print($breadcrumbtrail); |
my $comment=$env{'form.comment'};
|
|
$comment = &LONCAPA::map::qtunescape($comment);
|
unless ($allowed) { |
if ($folder=~/^supplemental/) {
|
$randompick = -1; |
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
|
} |
$env{'user.domain'}.'___&&&___'.$comment;
|
|
}
|
# ------------------------------------------------------------ Process commands |
|
|
$LONCAPA::map::resources[$newidx]=
|
# ---------------- if they are for this folder and user allowed to make changes |
$comment.':'.$url.':'.$ext.':normal:res';
|
if (($allowed) && ($env{'form.folder'} eq $folder)) { |
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
|
# set parameters and change order |
($errtext,$fatal)=&storemap($coursenum,$coursedom,
|
&snapshotbefore(); |
$folder.'.'.$container);
|
|
if ($fatal) {
|
if (&update_parameter()) { |
$$upload_output .= '<p><span class="LC_error">'.$errtext.'</span></p>';
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
return 'failed';
|
return $errtext if ($fatal); |
} else {
|
} |
if ($parseaction eq 'parse') {
|
|
my $total_embedded = keys(%{$allfiles});
|
if ($env{'form.newpos'} && $env{'form.currentpos'}) { |
if ($total_embedded > 0) {
|
# change order |
my $num = 0;
|
my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1); |
my $state = '
|
splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res); |
<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
|
|
<input type="hidden" name="cmd" value="upload_embedded" />
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
<input type="hidden" name="newidx" value="'.$newidx.'" />
|
return $errtext if ($fatal); |
<input type="hidden" name="primaryurl" value="'.&escape($url).'" />
|
} |
<input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
|
|
$phase_status = 'phasetwo';
|
if ($env{'form.pastemarked'}) { |
|
my $paste_res = |
$$upload_output .=
|
&do_paste_from_buffer($coursenum,$coursedom,$folder); |
'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
|
if ($paste_res eq 'ok') { |
&Apache::loncommon::ask_for_embedded_content(
|
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container); |
'/adm/coursedocs',$state,$allfiles,$codebase);
|
return $errtext if ($fatal); |
} else {
|
} elsif ($paste_res ne '') { |
$$upload_output .= 'No embedded items identified<br />';
|
$r->print('<p><span class="LC_error">'.$paste_res.'</span></p>'); |
}
|
} |
}
|
} |
}
|
|
}
|
$r->print($upload_output); |
return $phase_status;
|
|
}
|
if (&handle_edit_cmd()) { |
|
($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container); |
sub process_secondary_uploads {
|
return $errtext if ($fatal); |
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
|
} |
my $folder=$env{'form.folder'};
|
# Group import/search |
my $destination = 'docs/';
|
if ($env{'form.importdetail'}) { |
if ($folder =~ /^supplemental/) {
|
my @imports; |
$destination = 'supplemental/';
|
foreach my $item (split(/\&/,$env{'form.importdetail'})) { |
}
|
if (defined($item)) { |
if (($folder eq 'default') || ($folder eq 'supplemental')) {
|
my ($name,$url,$residx)= |
$destination .= 'default/';
|
map {&unescape($_)} split(/\=/,$item); |
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
|
push(@imports, [$name, $url, $residx]); |
$destination .= $2.'/';
|
} |
}
|
} |
$destination .= $newidx;
|
($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder, |
my ($url,$filename);
|
$container,'londocs',@imports); |
$url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
|
return $errtext if ($fatal); |
($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
|
} |
return $filename;
|
# Loading a complete map |
}
|
if ($env{'form.loadmap'}) { |
|
if ($env{'form.importmap'}=~/\w/) { |
sub is_supplemental_title {
|
foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { |
my ($title) = @_;
|
my ($title,$url,$ext,$type)=split(/\:/,$res); |
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
|
my $idx=&LONCAPA::map::getresidx($url); |
}
|
$LONCAPA::map::resources[$idx]=$res; |
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; |
sub parse_supplemental_title {
|
} |
my ($title) = @_;
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
|
$folder.'.'.$container); |
my ($foldertitle,$renametitle);
|
return $errtext if ($fatal); |
if ($title =~ /&&&/) {
|
} else { |
$title = &HTML::Entites::decode($title);
|
$r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>'); |
}
|
|
if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
|
} |
$renametitle=$4;
|
} |
my ($time,$uname,$udom) = ($1,$2,$3);
|
&log_differences($plain); |
$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
|
} |
my $name = &Apache::loncommon::plainname($uname,$udom);
|
# ---------------------------------------------------------------- End commands |
$name = &HTML::Entities::encode($name,'"<>&\'');
|
# ---------------------------------------------------------------- Print screen |
$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
|
my $idx=0; |
$name.': <br />'.$foldertitle;
|
my $shown=0; |
}
|
if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) { |
if (wantarray) {
|
$r->print('<div class="LC_Box">'. |
return ($title,$foldertitle,$renametitle);
|
'<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'. |
}
|
($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':''). |
return $title;
|
($ishidden?'<li>'.&mt('contents hidden').'</li>':''). |
}
|
($isencrypted?'<li>'.&mt('URLs hidden').'</li>':''). |
|
($is_random_order?'<li>'.&mt('random order').'</li>':''). |
# --------------------------------------------------------------- An entry line
|
'</ol>'); |
|
if ($randompick>=0) { |
sub entryline {
|
$r->print('<p class="LC_warning">' |
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
|
.&mt('Caution: this folder is set to randomly pick a subset' |
|
.' of resources. Adding or removing resources from this' |
my ($foldertitle,$pagetitle,$renametitle);
|
.' folder will change the set of resources that the' |
if (&is_supplemental_title($title)) {
|
.' students see, resulting in spurious or missing credit' |
($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
|
.' for completed problems, not limited to ones you' |
$pagetitle = $foldertitle;
|
.' modify. Do not modify the contents of this folder if' |
} else {
|
.' it is in active student use.') |
$title=&HTML::Entities::encode($title,'"<>&\'');
|
.'</p>' |
$renametitle=$title;
|
); |
$foldertitle=$title;
|
} |
$pagetitle=$title;
|
if ($is_random_order) { |
}
|
$r->print('<p class="LC_warning">' |
|
.&mt('Caution: this folder is set to randomly order its' |
my $orderidx=$LONCAPA::map::order[$index];
|
.' contents. Adding or removing resources from this folder' |
|
.' will change the order of resources shown.') |
|
.'</p>' |
$renametitle=~s/\\/\\\\/g;
|
); |
$renametitle=~s/\"\;/\\\"/g;
|
} |
$renametitle=~s/ /%20/g;
|
$r->print('</div>'); |
my $line='<tr>';
|
} |
my ($form_start,$form_end);
|
|
# Edit commands
|
my ($to_show,$output); |
my ($container, $type, $esc_path, $path, $symb);
|
|
if ($env{'form.folderpath'}) {
|
&Apache::loncommon::start_data_table_count(); #setup a row counter |
$type = 'folder';
|
foreach my $res (@LONCAPA::map::order) { |
$container = 'sequence';
|
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]); |
$esc_path=&escape($env{'form.folderpath'});
|
$name=&LONCAPA::map::qtescape($name); |
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
$url=&LONCAPA::map::qtescape($url); |
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
|
unless ($name) { $name=(split(/\//,$url))[-1]; } |
}
|
unless ($name) { $idx++; next; } |
if ($env{'form.pagepath'}) {
|
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res, |
$type = $container = 'page';
|
$coursenum,$crstype); |
$esc_path=&escape($path = $env{'form.pagepath'});
|
$idx++; |
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
|
$shown++; |
$symb=&escape($env{'form.pagesymb'});
|
} |
}
|
&Apache::loncommon::end_data_table_count(); |
my $cpinfo='';
|
|
if ($allowed) {
|
if ($shown) { |
my $incindex=$index+1;
|
$to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll') |
my $selectbox='';
|
.&Apache::loncommon::start_data_table(undef,'contentlist'); |
if (($folder!~/^supplemental/) &&
|
if ($allowed) { |
($#LONCAPA::map::order>0) &&
|
$to_show .= &Apache::loncommon::start_data_table_header_row() |
((split(/\:/,
|
.'<th colspan="2">'.&mt('Move').'</th>' |
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
|
.'<th>'.&mt('Actions').'</th>' |
ne '') &&
|
.'<th colspan="2">'.&mt('Document').'</th>'; |
((split(/\:/,
|
if ($folder !~ /^supplemental/) { |
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
|
$to_show .= '<th colspan="4">'.&mt('Settings').'</th>'; |
ne '')) {
|
} |
$selectbox=
|
$to_show .= &Apache::loncommon::end_data_table_header_row(); |
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
|
} |
'<select name="newpos" onChange="this.form.submit()">';
|
$to_show .= $output.' ' |
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
|
.&Apache::loncommon::end_data_table() |
if ($i==$incindex) {
|
.'<br style="line-height:2px;" />' |
$selectbox.='<option value="" selected="1">('.$i.')</option>';
|
.&Apache::loncommon::end_scrollbox(); |
} else {
|
} else { |
$selectbox.='<option value="'.$i.'">'.$i.'</option>';
|
$to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll') |
}
|
.'<div class="LC_info" id="contentlist">' |
}
|
.&mt('Currently no documents.') |
$selectbox.='</select>';
|
.'</div>' |
}
|
.&Apache::loncommon::end_scrollbox(); |
my %lt=&Apache::lonlocal::texthash(
|
} |
'up' => 'Move Up',
|
my $tid = 1; |
'dw' => 'Move Down',
|
if ($supplementalflag) { |
'rm' => 'Remove',
|
$tid = 2; |
'ct' => 'Cut',
|
} |
'rn' => 'Rename',
|
$r-print(&generate_edit_table($tid,$orderhash,$to_show)); |
'cp' => 'Copy');
|
if ($allowed) { |
my $nocopy=0;
|
&print_paste_buffer($r,$container); |
my $nocut=0;
|
} |
if ($url=~/\.(page|sequence)$/) {
|
return; |
if ($url =~ m{/res/}) {
|
} |
# no copy for published maps
|
|
$nocopy = 1;
|
sub process_file_upload { |
} else {
|
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; |
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
|
# upload a file, if present |
my ($title,$url,$ext,$type)=split(/\:/,$item);
|
my ($parseaction,$showupload,$nextphase,$mimetype); |
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
|
if ($env{'form.parserflag'}) { |
$nocopy=1;
|
$parseaction = 'parse'; |
last;
|
} |
}
|
my $folder=$env{'form.folder'}; |
}
|
if ($folder eq '') { |
}
|
$folder='default'; |
}
|
} |
if ($url=~/^\/res\/lib\/templates\//) {
|
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) { |
$nocopy=1;
|
my $errtext=''; |
$nocut=1;
|
my $fatal=0; |
}
|
my $container='sequence'; |
my $copylink=' ';
|
if ($env{'form.pagepath'}) { |
my $cutlink=' ';
|
$container='page'; |
|
} |
my $skip_confirm = 0;
|
($errtext,$fatal)= |
if ( $folder =~ /^supplemental/
|
&mapread($coursenum,$coursedom,$folder.'.'.$container); |
|| ($url =~ m{( /smppg$
|
if ($#LONCAPA::map::order<1) { |
|/syllabus$
|
$LONCAPA::map::order[0]=1; |
|/aboutme$
|
$LONCAPA::map::resources[1]=''; |
|/navmaps$
|
} |
|/bulletinboard$
|
if ($fatal) { |
|\.html$
|
$$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>'; |
|^/adm/wrapper/ext)}x)) {
|
return; |
$skip_confirm = 1;
|
} |
}
|
my $destination = 'docs/'; |
|
if ($folder =~ /^supplemental/) { |
if (!$nocopy) {
|
$destination = 'supplemental/'; |
$copylink=(<<ENDCOPY);
|
} |
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
ENDCOPY
|
$destination .= 'default/'; |
}
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
if (!$nocut) {
|
$destination .= $2.'/'; |
$cutlink=(<<ENDCUT);
|
} |
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
|
# this is for a course, not a user, so set context to coursedoc. |
ENDCUT
|
my $newidx=&LONCAPA::map::getresidx(); |
}
|
$destination .= $newidx; |
$form_start = (<<END);
|
my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination, |
<form action="/adm/coursedocs" method="post">
|
$parseaction,$allfiles, |
<input type="hidden" name="${type}path" value="$path" />
|
$codebase,undef,undef,undef,undef, |
<input type="hidden" name="${type}symb" value="$symb" />
|
undef,undef,\$mimetype); |
<input type="hidden" name="setparms" value="$orderidx" />
|
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) { |
<input type="hidden" name="changeparms" value="0" />
|
my $stored = $1; |
END
|
$showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'. |
$form_end = '</form>';
|
$stored.'</span>').'</p>'; |
$line.=(<<END);
|
} else { |
<td>
|
my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$}); |
<table class="LC_docs_entry_move">
|
|
<tr>
|
$$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>'; |
<td>
|
return; |
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /></a>
|
} |
</td>
|
my $ext='false'; |
</tr>
|
if ($url=~m{^http://}) { $ext='true'; } |
<tr>
|
$url = &LONCAPA::map::qtunescape($url); |
<td>
|
my $comment=$env{'form.comment'}; |
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /></a>
|
$comment = &LONCAPA::map::qtunescape($comment); |
</td>
|
if ($folder=~/^supplemental/) { |
</tr>
|
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
</table>
|
$env{'user.domain'}.'___&&&___'.$comment; |
</td>
|
} |
<td>
|
|
$form_start
|
$LONCAPA::map::resources[$newidx]= |
$selectbox
|
$comment.':'.$url.':'.$ext.':normal:res'; |
$form_end
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx; |
</td>
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
<td class="LC_docs_entry_commands">
|
$folder.'.'.$container); |
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
|
if ($fatal) { |
$cutlink
|
$$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>'; |
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
|
return; |
$copylink
|
} else { |
</td>
|
if ($parseaction eq 'parse' && $mimetype eq 'text/html') { |
END
|
$$upload_output = $showupload; |
|
my $total_embedded = scalar(keys(%{$allfiles})); |
}
|
if ($total_embedded > 0) { |
# Figure out what kind of a resource this is
|
my $uploadphase = 'upload_embedded'; |
my ($extension)=($url=~/\.(\w+)$/);
|
my $primaryurl = &HTML::Entities::encode($url,'<>&"'); |
my $uploaded=($url=~/^\/*uploaded\//);
|
my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); |
my $icon=&Apache::loncommon::icon($url);
|
my ($embedded,$num) = |
my $isfolder=0;
|
&Apache::loncommon::ask_for_embedded_content( |
my $ispage=0;
|
'/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url}); |
my $folderarg;
|
if ($embedded) { |
my $pagearg;
|
if ($num) { |
my $pagefile;
|
$$upload_output .= |
if ($uploaded) {
|
'<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded; |
if ($extension eq 'sequence') {
|
$nextphase = $uploadphase; |
$icon=$iconpath.'/folder_closed.gif';
|
} else { |
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
|
$$upload_output .= $embedded; |
$url='/adm/coursedocs?';
|
} |
$folderarg=$1;
|
} else { |
$isfolder=1;
|
$$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />'; |
} elsif ($extension eq 'page') {
|
} |
$icon=$iconpath.'/page.gif';
|
} else { |
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
|
$$upload_output .= &mt('No embedded items identified').'<br />'; |
$pagearg=$1;
|
} |
$url='/adm/coursedocs?';
|
$$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>'; |
$ispage=1;
|
} |
} else {
|
} |
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
|
} |
}
|
return $nextphase; |
}
|
} |
|
|
my $orig_url = $url;
|
sub is_supplemental_title { |
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
|
my ($title) = @_; |
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
|
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/); |
my $symb=&Apache::lonnet::symbclean(
|
} |
&Apache::lonnet::declutter('uploaded/'.
|
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
sub parse_supplemental_title { |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
|
my ($title) = @_; |
'.sequence').
|
|
'___'.$residx.'___'.
|
my ($foldertitle,$renametitle); |
&Apache::lonnet::declutter($url));
|
if ($title =~ /&&&/) { |
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
|
$title = &HTML::Entites::decode($title); |
$url=&Apache::lonnet::clutter($url);
|
} |
if ($url=~/^\/*uploaded\//) {
|
if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) { |
$url=~/\.(\w+)$/;
|
$renametitle=$4; |
my $embstyle=&Apache::loncommon::fileembstyle($1);
|
my ($time,$uname,$udom) = ($1,$2,$3); |
if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
|
$foldertitle=&Apache::lontexconvert::msgtexconverted($4); |
$url='/adm/wrapper'.$url;
|
my $name = &Apache::loncommon::plainname($uname,$udom); |
} elsif ($embstyle eq 'ssi') {
|
$name = &HTML::Entities::encode($name,'"<>&\''); |
#do nothing with these
|
$renametitle = &HTML::Entities::encode($renametitle,'"<>&\''); |
} elsif ($url!~/\.(sequence|page)$/) {
|
$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '. |
$url='/adm/coursedocs/showdoc'.$url;
|
$name.': <br />'.$foldertitle; |
}
|
} |
} elsif ($url=~m|^/ext/|) {
|
if (wantarray) { |
$url='/adm/wrapper'.$url;
|
return ($title,$foldertitle,$renametitle); |
$external = 1;
|
} |
}
|
return $title; |
if (&Apache::lonnet::symbverify($symb,$url)) {
|
} |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
|
} else {
|
# --------------------------------------------------------------- An entry line |
$url='';
|
|
}
|
sub entryline { |
if ($container eq 'page') {
|
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_; |
my $symb=$env{'form.pagesymb'};
|
my ($foldertitle,$pagetitle,$renametitle); |
|
if (&is_supplemental_title($title)) { |
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
|
($title,$foldertitle,$renametitle) = &parse_supplemental_title($title); |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
$pagetitle = $foldertitle; |
}
|
} else { |
}
|
$title=&HTML::Entities::encode($title,'"<>&\''); |
my ($parameterset,$rand_order_text) = (' ', ' ');
|
$renametitle=$title; |
if ($isfolder || $extension eq 'sequence') {
|
$foldertitle=$title; |
my $foldername=&escape($foldertitle);
|
$pagetitle=$title; |
my $folderpath=$env{'form.folderpath'};
|
} |
if ($folderpath) { $folderpath.='&' };
|
|
# Append randompick number, hidden, and encrypted with ":" to foldername,
|
my $orderidx=$LONCAPA::map::order[$index]; |
# so it gets transferred between levels
|
|
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
|
|
'parameter_randompick'))[0]
|
$renametitle=~s/\\/\\\\/g; |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
$renametitle=~s/\"\;/\\\"/g; |
'parameter_hiddenresource'))[0]=~/^yes$/i)
|
$renametitle=~s/ /%20/g; |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
my $line=&Apache::loncommon::start_data_table_row(); |
'parameter_encrypturl'))[0]=~/^yes$/i)
|
my ($form_start,$form_end); |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
# Edit commands |
'parameter_randomorder'))[0]=~/^yes$/i);
|
my ($container, $type, $esc_path, $path, $symb); |
$url.='folderpath='.&escape($folderpath).$cpinfo;
|
if ($env{'form.folderpath'}) { |
$parameterset='<label>'.&mt('Randomly Pick: ').
|
$type = 'folder'; |
'<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
|
$container = 'sequence'; |
(&LONCAPA::map::getparameter($orderidx,
|
$esc_path=&escape($env{'form.folderpath'}); |
'parameter_randompick'))[0].
|
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
'" />'.
|
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"'); |
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
|
} |
my $ro_set=
|
if ($env{'form.pagepath'}) { |
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
|
$type = $container = 'page'; |
$rand_order_text ='
|
$esc_path=&escape($env{'form.pagepath'}); |
<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>';
|
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); |
}
|
$symb=&escape($env{'form.pagesymb'}); |
if ($ispage) {
|
} |
my $pagename=&escape($pagetitle);
|
my $cpinfo=''; |
my $pagepath;
|
if ($allowed) { |
my $folderpath=$env{'form.folderpath'};
|
my $incindex=$index+1; |
if ($folderpath) { $pagepath = $folderpath.'&' };
|
my $selectbox=''; |
$pagepath.=$pagearg.'&'.$pagename;
|
if (($folder!~/^supplemental/) && |
my $symb=$env{'form.pagesymb'};
|
($#LONCAPA::map::order>0) && |
if (!$symb) {
|
((split(/\:/, |
my $path='uploaded/'.
|
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1] |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
ne '') && |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/';
|
((split(/\:/, |
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
|
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1] |
$residx,
|
ne '')) { |
$path.$pagearg.'.page');
|
$selectbox= |
}
|
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'. |
$url.='pagepath='.&escape($pagepath).
|
'<select name="newpos" onchange="this.form.submit()">'; |
'&pagesymb='.&escape($symb).$cpinfo;
|
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) { |
}
|
if ($i==$incindex) { |
if ($external) {
|
$selectbox.='<option value="" selected="selected">('.$i.')</option>'; |
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
|
} else { |
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
|
$selectbox.='<option value="'.$i.'">'.$i.'</option>'; |
} else {
|
} |
undef($external);
|
} |
}
|
$selectbox.='</select>'; |
$line.='
|
} |
<td class="LC_docs_entry_icon">
|
my %lt=&Apache::lonlocal::texthash( |
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
|
'up' => 'Move Up', |
</td>
|
'dw' => 'Move Down', |
<td class="LC_docs_entry_title">
|
'rm' => 'Remove', |
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
|
'ct' => 'Cut', |
</td>";
|
'rn' => 'Rename', |
if (($allowed) && ($folder!~/^supplemental/)) {
|
'cp' => 'Copy'); |
my %lt=&Apache::lonlocal::texthash(
|
my $nocopy=0; |
'hd' => 'Hidden',
|
my $nocut=0; |
'ec' => 'URL hidden');
|
if ($url=~/\.(page|sequence)$/) { |
my $enctext=
|
if ($url =~ m{/res/}) { |
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
|
# no copy for published maps |
my $hidtext=
|
$nocopy = 1; |
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
|
} else { |
$line.=(<<ENDPARMS);
|
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) { |
<td class="LC_docs_entry_parameter">
|
my ($title,$url,$ext,$type)=split(/\:/,$item); |
$form_start
|
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { |
<label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
|
$nocopy=1; |
$form_end
|
last; |
</td>
|
} |
<td class="LC_docs_entry_parameter">
|
} |
$form_start
|
} |
<label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
|
} |
$form_end
|
if ($url=~/^\/res\/lib\/templates\//) { |
</td>
|
$nocopy=1; |
<td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
|
$nocut=1; |
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
|
} |
ENDPARMS
|
my $copylink=' '; |
}
|
my $cutlink=' '; |
$line.="</tr>";
|
|
return $line;
|
my $skip_confirm = 0; |
}
|
if ( $folder =~ /^supplemental/ |
|
|| ($url =~ m{( /smppg$ |
=pod
|
|/syllabus$ |
|
|/aboutme$ |
=item tiehash()
|
|/navmaps$ |
|
|/bulletinboard$ |
tie the hash
|
|\.html$ |
|
|^/adm/wrapper/ext)}x)) { |
=cut
|
$skip_confirm = 1; |
|
} |
sub tiehash {
|
|
my ($mode)=@_;
|
if (!$nocopy) { |
$hashtied=0;
|
$copylink=(<<ENDCOPY); |
if ($env{'request.course.fn'}) {
|
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a> |
if ($mode eq 'write') {
|
ENDCOPY |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
} |
&GDBM_WRCREAT(),0640)) {
|
if (!$nocut) { |
$hashtied=2;
|
$cutlink=(<<ENDCUT); |
}
|
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a> |
} else {
|
ENDCUT |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
} |
&GDBM_READER(),0640)) {
|
$form_start = (<<END); |
$hashtied=1;
|
<form action="/adm/coursedocs" method="post"> |
}
|
<input type="hidden" name="${type}path" value="$path" /> |
}
|
<input type="hidden" name="${type}symb" value="$symb" /> |
}
|
<input type="hidden" name="setparms" value="$orderidx" /> |
}
|
<input type="hidden" name="changeparms" value="0" /> |
|
END |
sub untiehash {
|
$form_end = '</form>'; |
if ($hashtied) { untie %hash; }
|
$line.=(<<END); |
$hashtied=0;
|
<td> |
return OK;
|
<div class="LC_docs_entry_move"> |
}
|
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
|
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /> |
|
</a> |
|
</div> |
|
<div class="LC_docs_entry_move"> |
sub checkonthis {
|
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
my ($r,$url,$level,$title)=@_;
|
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /> |
$url=&unescape($url);
|
</a> |
$alreadyseen{$url}=1;
|
</div> |
$r->rflush();
|
</td> |
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
|
<td> |
$r->print("\n<br />");
|
$form_start |
if ($level==0) {
|
$selectbox |
$r->print("<br />");
|
$form_end |
}
|
</td> |
for (my $i=0;$i<=$level*5;$i++) {
|
<td class="LC_docs_entry_commands"> |
$r->print(' ');
|
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a> |
}
|
$cutlink |
$r->print('<a href="'.$url.'" target="cat">'.
|
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a> |
($title?$title:$url).'</a> ');
|
$copylink |
if ($url=~/^\/res\//) {
|
</td> |
my $result=&Apache::lonnet::repcopy(
|
END |
&Apache::lonnet::filelocation('',$url));
|
|
if ($result eq 'ok') {
|
} |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
# Figure out what kind of a resource this is |
$r->rflush();
|
my ($extension)=($url=~/\.(\w+)$/); |
&Apache::lonnet::countacc($url);
|
my $uploaded=($url=~/^\/*uploaded\//); |
$url=~/\.(\w+)$/;
|
my $icon=&Apache::loncommon::icon($url); |
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
|
my $isfolder=0; |
$r->print('<br />');
|
my $ispage=0; |
$r->rflush();
|
my $folderarg; |
for (my $i=0;$i<=$level*5;$i++) {
|
my $pagearg; |
$r->print(' ');
|
my $pagefile; |
}
|
if ($uploaded) { |
$r->print('- '.&mt('Rendering:').' ');
|
if ($extension eq 'sequence') { |
my ($errorcount,$warningcount)=split(/:/,
|
$icon=$iconpath.'/navmap.folder.closed.gif'; |
&Apache::lonnet::ssi_body($url,
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; |
('grade_target'=>'web',
|
$url='/adm/coursedocs?'; |
'return_only_error_and_warning_counts' => 1)));
|
$folderarg=$1; |
if (($errorcount) ||
|
$isfolder=1; |
($warningcount)) {
|
} elsif ($extension eq 'page') { |
if ($errorcount) {
|
$icon=$iconpath.'/page.gif'; |
$r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/; |
&mt('[quant,_1,error]',$errorcount).'</span>');
|
$pagearg=$1; |
}
|
$url='/adm/coursedocs?'; |
if ($warningcount) {
|
$ispage=1; |
$r->print('<span class="LC_warning">'.
|
} else { |
&mt('[quant,_1,warning]',$warningcount).'</span>');
|
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url); |
}
|
} |
} else {
|
} |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
|
}
|
my $orig_url = $url; |
$r->rflush();
|
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
}
|
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}); |
my $dependencies=
|
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { |
&Apache::lonnet::metadata($url,'dependencies');
|
my $symb=&Apache::lonnet::symbclean( |
foreach my $dep (split(/\,/,$dependencies)) {
|
&Apache::lonnet::declutter('uploaded/'. |
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
&checkonthis($r,$dep,$level+1);
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. |
}
|
'.sequence'). |
}
|
'___'.$residx.'___'. |
} elsif ($result eq 'unavailable') {
|
&Apache::lonnet::declutter($url)); |
$r->print('<span class="LC_error">'.&mt('connection down').'</span>');
|
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
} elsif ($result eq 'not_found') {
|
$url=&Apache::lonnet::clutter($url); |
unless ($url=~/\$/) {
|
if ($url=~/^\/*uploaded\//) { |
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
|
$url=~/\.(\w+)$/; |
} else {
|
my $embstyle=&Apache::loncommon::fileembstyle($1); |
$r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
|
if (($embstyle eq 'img') || ($embstyle eq 'emb')) { |
}
|
$url='/adm/wrapper'.$url; |
} else {
|
} elsif ($embstyle eq 'ssi') { |
$r->print('<span class="LC_error">'.&mt('access denied').'</span>');
|
#do nothing with these |
}
|
} elsif ($url!~/\.(sequence|page)$/) { |
}
|
$url='/adm/coursedocs/showdoc'.$url; |
}
|
} |
}
|
} elsif ($url=~m|^/ext/|) { |
|
$url='/adm/wrapper'.$url; |
|
$external = 1; |
|
} |
=pod
|
if (&Apache::lonnet::symbverify($symb,$url)) { |
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
=item list_symbs()
|
} else { |
|
$url=''; |
List Symbs
|
} |
|
if ($container eq 'page') { |
=cut
|
my $symb=$env{'form.pagesymb'}; |
|
|
sub list_symbs {
|
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); |
my ($r) = @_;
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
|
} |
my $type = &Apache::loncommon::course_type();
|
} |
$r->print(&Apache::loncommon::start_page('Symb List'));
|
my ($parameterset,$rand_order_text) = (' ', ' '); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
|
if ($isfolder || $extension eq 'sequence') { |
my $navmap = Apache::lonnavmaps::navmap->new();
|
my $foldername=&escape($foldertitle); |
if (!defined($navmap)) {
|
my $folderpath=$env{'form.folderpath'}; |
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
|
if ($folderpath) { $folderpath.='&' }; |
'<div class="LC_error">'.
|
# Append randompick number, hidden, and encrypted with ":" to foldername, |
&mt('Unable to retrieve information about course contents').
|
# so it gets transferred between levels |
'</div>');
|
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx, |
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
'parameter_randompick'))[0] |
} else {
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
$r->print("<pre>\n");
|
'parameter_hiddenresource'))[0]=~/^yes$/i) |
foreach my $res ($navmap->retrieveResources()) {
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
$r->print($res->compTitle()."\t".$res->symb()."\n");
|
'parameter_encrypturl'))[0]=~/^yes$/i) |
}
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
$r->print("\n</pre>\n");
|
'parameter_randomorder'))[0]=~/^yes$/i); |
}
|
$url.='folderpath='.&escape($folderpath).$cpinfo; |
$r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
|
$parameterset='<label>'.&mt('Randomly Pick: '). |
}
|
'<input type="text" size="4" onchange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'. |
|
(&LONCAPA::map::getparameter($orderidx, |
|
'parameter_randompick'))[0]. |
sub verifycontent {
|
'" />'. |
my ($r) = @_;
|
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>'; |
my $type = &Apache::loncommon::course_type();
|
my $ro_set= |
my $loaderror=&Apache::lonnet::overloaderror($r);
|
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); |
if ($loaderror) { return $loaderror; }
|
$rand_order_text =' |
$r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
|
<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>'; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
|
} |
$hashtied=0;
|
if ($ispage) { |
undef %alreadyseen;
|
my $pagename=&escape($pagetitle); |
%alreadyseen=();
|
my $pagepath; |
&tiehash();
|
my $folderpath=$env{'form.folderpath'}; |
foreach my $key (keys(%hash)) {
|
if ($folderpath) { $pagepath = $folderpath.'&' }; |
if ($hash{$key}=~/\.(page|sequence)$/) {
|
$pagepath.=$pagearg.'&'.$pagename; |
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
|
my $symb=$env{'form.pagesymb'}; |
$r->print('<hr /><span class="LC_error">'.
|
if (!$symb) { |
&mt('The following sequence or page is included more than once in your '.$type.': ').
|
my $path='uploaded/'. |
&unescape($hash{$key}).'</span><br />'.
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
&mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'; |
}
|
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', |
}
|
$residx, |
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
|
$path.$pagearg.'.page'); |
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
|
} |
}
|
$url.='pagepath='.&escape($pagepath). |
}
|
'&pagesymb='.&escape($symb).$cpinfo; |
&untiehash();
|
} |
$r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
|
if (($external) && ($allowed)) { |
&mt('Return to DOCS').'</a>');
|
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext'; |
}
|
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>'; |
|
} else { |
|
undef($external); |
sub devalidateversioncache {
|
} |
my $src=shift;
|
my $reinit; |
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
|
if ($crstype eq 'Community') { |
&Apache::lonnet::clutter($src));
|
$reinit = &mt('(re-initialize community to access)'); |
}
|
} else { |
|
$reinit = &mt('(re-initialize course to access)'); |
sub checkversions {
|
} |
my ($r) = @_;
|
$line.=' |
my $type = &Apache::loncommon::course_type();
|
<td> |
$r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
|
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').' |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
|
</td> |
my $header='';
|
<td> |
my $startsel='';
|
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.$reinit.'</span>').$external." |
my $monthsel='';
|
</td>"; |
my $weeksel='';
|
if (($allowed) && ($folder!~/^supplemental/)) { |
my $daysel='';
|
my %lt=&Apache::lonlocal::texthash( |
my $allsel='';
|
'hd' => 'Hidden', |
my %changes=();
|
'ec' => 'URL hidden'); |
my $starttime=0;
|
my $enctext= |
my $haschanged=0;
|
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':''); |
my %setversions=&Apache::lonnet::dump('resourceversions',
|
my $hidtext= |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':''); |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
$line.=(<<ENDPARMS); |
|
<td class="LC_docs_entry_parameter"> |
$hashtied=0;
|
$form_start |
&tiehash();
|
<label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label> |
my %newsetversions=();
|
$form_end |
if ($env{'form.setmostrecent'}) {
|
<br /> |
$haschanged=1;
|
$form_start |
foreach my $key (keys(%hash)) {
|
<label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label> |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
$form_end |
$newsetversions{$1}='mostrecent';
|
</td> |
&devalidateversioncache($1);
|
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end<br /> |
}
|
$form_start $rand_order_text $form_end</td> |
}
|
ENDPARMS |
} elsif ($env{'form.setcurrent'}) {
|
} |
$haschanged=1;
|
$line.=&Apache::loncommon::end_data_table_row(); |
foreach my $key (keys(%hash)) {
|
return $line; |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
} |
my $getvers=&Apache::lonnet::getversion($1);
|
|
if ($getvers>0) {
|
=pod |
$newsetversions{$1}=$getvers;
|
|
&devalidateversioncache($1);
|
=item tiehash() |
}
|
|
}
|
tie the hash |
}
|
|
} elsif ($env{'form.setversions'}) {
|
=cut |
$haschanged=1;
|
|
foreach my $key (keys(%env)) {
|
sub tiehash { |
if ($key=~/^form\.set_version_(.+)$/) {
|
my ($mode)=@_; |
my $src=$1;
|
$hashtied=0; |
if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
|
if ($env{'request.course.fn'}) { |
$newsetversions{$src}=$env{$key};
|
if ($mode eq 'write') { |
&devalidateversioncache($src);
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
}
|
&GDBM_WRCREAT(),0640)) { |
}
|
$hashtied=2; |
}
|
} |
}
|
} else { |
if ($haschanged) {
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
if (&Apache::lonnet::put('resourceversions',\%newsetversions,
|
&GDBM_READER(),0640)) { |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
$hashtied=1; |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
|
} |
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>');
|
} |
} else {
|
} |
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>');
|
} |
}
|
|
&mark_hash_old();
|
sub untiehash { |
}
|
if ($hashtied) { untie %hash; } |
&changewarning($r,'');
|
$hashtied=0; |
if ($env{'form.timerange'} eq 'all') {
|
return OK; |
# show all documents
|
} |
$header=&mt('All Documents in '.$type);
|
|
$allsel=1;
|
|
foreach my $key (keys(%hash)) {
|
|
if ($key=~/^ids\_(\/res\/.+)$/) {
|
|
my $src=$1;
|
sub checkonthis { |
$changes{$src}=1;
|
my ($r,$url,$level,$title)=@_; |
}
|
$url=&unescape($url); |
}
|
$alreadyseen{$url}=1; |
} else {
|
$r->rflush(); |
# show documents which changed
|
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) { |
%changes=&Apache::lonnet::dump
|
$r->print("\n<br />"); |
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
|
if ($level==0) { |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
$r->print("<br />"); |
my $firstkey=(keys(%changes))[0];
|
} |
unless ($firstkey=~/^error\:/) {
|
for (my $i=0;$i<=$level*5;$i++) { |
unless ($env{'form.timerange'}) {
|
$r->print(' '); |
$env{'form.timerange'}=604800;
|
} |
}
|
$r->print('<a href="'.$url.'" target="cat">'. |
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
|
($title?$title:$url).'</a> '); |
.&mt('seconds');
|
if ($url=~/^\/res\//) { |
if ($env{'form.timerange'}==-1) {
|
my $result=&Apache::lonnet::repcopy( |
$seltext='since start of course';
|
&Apache::lonnet::filelocation('',$url)); |
$startsel='selected';
|
if ($result eq 'ok') { |
$env{'form.timerange'}=time;
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
}
|
$r->rflush(); |
$starttime=time-$env{'form.timerange'};
|
&Apache::lonnet::countacc($url); |
if ($env{'form.timerange'}==2592000) {
|
$url=~/\.(\w+)$/; |
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { |
$monthsel='selected';
|
$r->print('<br />'); |
} elsif ($env{'form.timerange'}==604800) {
|
$r->rflush(); |
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
for (my $i=0;$i<=$level*5;$i++) { |
$weeksel='selected';
|
$r->print(' '); |
} elsif ($env{'form.timerange'}==86400) {
|
} |
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
$r->print('- '.&mt('Rendering:').' '); |
$daysel='selected';
|
my ($errorcount,$warningcount)=split(/:/, |
}
|
&Apache::lonnet::ssi_body($url, |
$header=&mt('Content changed').' '.$seltext;
|
('grade_target'=>'web', |
} else {
|
'return_only_error_and_warning_counts' => 1))); |
$header=&mt('No content modifications yet.');
|
if (($errorcount) || |
}
|
($warningcount)) { |
}
|
if ($errorcount) { |
%setversions=&Apache::lonnet::dump('resourceversions',
|
$r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'. |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
&mt('[quant,_1,error]',$errorcount).'</span>'); |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
} |
my %lt=&Apache::lonlocal::texthash
|
if ($warningcount) { |
('st' => 'Version changes since start of '.$type,
|
$r->print('<span class="LC_warning">'. |
'lm' => 'Version changes since last Month',
|
&mt('[quant,_1,warning]',$warningcount).'</span>'); |
'lw' => 'Version changes since last Week',
|
} |
'sy' => 'Version changes since Yesterday',
|
} else { |
'al' => 'All Resources (possibly large output)',
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
'sd' => 'Display',
|
} |
'fi' => 'File',
|
$r->rflush(); |
'md' => 'Modification Date',
|
} |
'mr' => 'Most recently published Version',
|
my $dependencies= |
've' => 'Version used in '.$type,
|
&Apache::lonnet::metadata($url,'dependencies'); |
'vu' => 'Set Version to be used in '.$type,
|
foreach my $dep (split(/\,/,$dependencies)) { |
'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
|
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) { |
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
|
&checkonthis($r,$dep,$level+1); |
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
|
} |
'di' => 'Differences');
|
} |
$r->print(<<ENDHEADERS);
|
} elsif ($result eq 'unavailable') { |
<form action="/adm/coursedocs" method="post">
|
$r->print('<span class="LC_error">'.&mt('connection down').'</span>'); |
<input type="hidden" name="versions" value="1" />
|
} elsif ($result eq 'not_found') { |
<input type="submit" name="setmostrecent" value="$lt{'sm'}" />
|
unless ($url=~/\$/) { |
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
|
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>'); |
<select name="timerange">
|
} else { |
<option value='all' $allsel>$lt{'al'}</option>
|
$r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>'); |
<option value="-1" $startsel>$lt{'st'}</option>
|
} |
<option value="2592000" $monthsel>$lt{'lm'}</option>
|
} else { |
<option value="604800" $weeksel>$lt{'lw'}</option>
|
$r->print('<span class="LC_error">'.&mt('access denied').'</span>'); |
<option value="86400" $daysel>$lt{'sy'}</option>
|
} |
</select>
|
} |
<input type="submit" name="display" value="$lt{'sd'}" />
|
} |
<h3>$header</h3>
|
} |
<input type="submit" name="setversions" value="$lt{'sv'}" />
|
|
<table border="0">
|
|
ENDHEADERS
|
|
foreach my $key (sort(keys(%changes))) {
|
=pod |
if ($changes{$key}>$starttime) {
|
|
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
|
=item list_symbs() |
my $currentversion=&Apache::lonnet::getversion($key);
|
|
if ($currentversion<0) {
|
List Symbs |
$currentversion=&mt('Could not be determined.');
|
|
}
|
=cut |
my $linkurl=&Apache::lonnet::clutter($key);
|
|
$r->print(
|
sub list_symbs { |
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
|
my ($r) = @_; |
&Apache::lonnet::gettitle($linkurl).
|
|
'</b></font></td></tr>'.
|
my $crstype = &Apache::loncommon::course_type(); |
'<tr><td> </td>'.
|
$r->print(&Apache::loncommon::start_page('Symb List')); |
'<td colspan="4">'.
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); |
'<a href="'.$linkurl.'" target="cat">'.$linkurl.
|
&startContentScreen($r,'tools'); |
'</a></td></tr>'.
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
'<tr><td></td>'.
|
if (!defined($navmap)) { |
'<td title="'.$lt{'md'}.'">'.
|
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'. |
&Apache::lonlocal::locallocaltime(
|
'<div class="LC_error">'. |
&Apache::lonnet::metadata($root.'.'.$extension,
|
&mt('Unable to retrieve information about course contents'). |
'lastrevisiondate')
|
'</div>'); |
).
|
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); |
'</td>'.
|
} else { |
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
|
$r->print("<pre>\n"); |
'<font size="+1">'.$currentversion.'</font>'.
|
foreach my $res ($navmap->retrieveResources()) { |
'</span></td>'.
|
$r->print($res->compTitle()."\t".$res->symb()."\n"); |
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
|
} |
'<font size="+1">');
|
$r->print("\n</pre>\n"); |
# Used in course
|
} |
my $usedversion=$hash{'version_'.$linkurl};
|
} |
if (($usedversion) && ($usedversion ne 'mostrecent')) {
|
|
$r->print($usedversion);
|
|
} else {
|
sub verifycontent { |
$r->print($currentversion);
|
my ($r) = @_; |
}
|
my $crstype = &Apache::loncommon::course_type(); |
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'.
|
$r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents')); |
'<span class="LC_nobreak">Use: ');
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents')); |
# Set version
|
&startContentScreen($r,'tools'); |
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
|
$hashtied=0; |
'set_version_'.$linkurl,
|
undef %alreadyseen; |
('select_form_order' =>
|
%alreadyseen=(); |
['',1..$currentversion,'mostrecent'],
|
&tiehash(); |
'' => '',
|
foreach my $key (keys(%hash)) { |
'mostrecent' => 'most recent',
|
if ($hash{$key}=~/\.(page|sequence)$/) { |
map {$_,$_} (1..$currentversion))));
|
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) { |
$r->print('</span></td></tr><tr><td></td>');
|
$r->print('<hr /><span class="LC_error">'. |
my $lastold=1;
|
&mt('The following sequence or page is included more than once in your '.$crstype.':').' '. |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
|
&unescape($hash{$key}).'</span><br />'. |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
&mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />'); |
if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
|
} |
$starttime) {
|
} |
$lastold=$prevvers;
|
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) { |
}
|
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1}); |
}
|
} |
#
|
} |
# Code to figure out how many version entries should go in
|
&untiehash(); |
# each of the four columns
|
$r->print('<p class="LC_success">'.&mt('Done').'</p>'); |
my $entries_per_col = 0;
|
} |
my $num_entries = ($currentversion-$lastold);
|
|
if ($num_entries % 4 == 0) {
|
|
$entries_per_col = $num_entries/4;
|
sub devalidateversioncache { |
} else {
|
my $src=shift; |
$entries_per_col = $num_entries/4 + 1;
|
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. |
}
|
&Apache::lonnet::clutter($src)); |
my $entries_count = 0;
|
} |
$r->print('<td valign="top"><font size="-2">');
|
|
my $cols_output = 1;
|
sub checkversions { |
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
|
my ($r) = @_; |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
my $crstype = &Apache::loncommon::course_type(); |
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
|
$r->print(&Apache::loncommon::start_page("Check $crstype Document Versions")); |
'">'.&mt('Version').' '.$prevvers.'</a> ('.
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions")); |
&Apache::lonlocal::locallocaltime(
|
&startContentScreen($r,'tools'); |
&Apache::lonnet::metadata($url,
|
|
'lastrevisiondate')
|
my $header=''; |
).
|
my $startsel=''; |
')');
|
my $monthsel=''; |
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
|
my $weeksel=''; |
$r->print(' <a href="/adm/diff?filename='.
|
my $daysel=''; |
&Apache::lonnet::clutter($root.'.'.$extension).
|
my $allsel=''; |
'&versionone='.$prevvers.
|
my %changes=(); |
'">'.&mt('Diffs').'</a>');
|
my $starttime=0; |
}
|
my $haschanged=0; |
$r->print('</span><br />');
|
my %setversions=&Apache::lonnet::dump('resourceversions', |
if (++$entries_count % $entries_per_col == 0) {
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$r->print('</font></td>');
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
if ($cols_output != 4) {
|
|
$r->print('<td valign="top"><font size="-2">');
|
$hashtied=0; |
$cols_output++;
|
&tiehash(); |
}
|
my %newsetversions=(); |
}
|
if ($env{'form.setmostrecent'}) { |
}
|
$haschanged=1; |
while($cols_output++ < 4) {
|
foreach my $key (keys(%hash)) { |
$r->print('</font></td><td><font>')
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
}
|
$newsetversions{$1}='mostrecent'; |
$r->print('</font></td></tr>'."\n");
|
&devalidateversioncache($1); |
}
|
} |
}
|
} |
$r->print('</table></form>');
|
} elsif ($env{'form.setcurrent'}) { |
$r->print('<h1>'.&mt('Done').'.</h1>');
|
$haschanged=1; |
|
foreach my $key (keys(%hash)) { |
&untiehash();
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
}
|
my $getvers=&Apache::lonnet::getversion($1); |
|
if ($getvers>0) { |
sub mark_hash_old {
|
$newsetversions{$1}=$getvers; |
my $retie_hash=0;
|
&devalidateversioncache($1); |
if ($hashtied) {
|
} |
$retie_hash=1;
|
} |
&untiehash();
|
} |
}
|
} elsif ($env{'form.setversions'}) { |
&tiehash('write');
|
$haschanged=1; |
$hash{'old'}=1;
|
foreach my $key (keys(%env)) { |
&untiehash();
|
if ($key=~/^form\.set_version_(.+)$/) { |
if ($retie_hash) { &tiehash(); }
|
my $src=$1; |
}
|
if (($env{$key}) && ($env{$key} ne $setversions{$src})) { |
|
$newsetversions{$src}=$env{$key}; |
sub is_hash_old {
|
&devalidateversioncache($src); |
my $untie_hash=0;
|
} |
if (!$hashtied) {
|
} |
$untie_hash=1;
|
} |
&tiehash();
|
} |
}
|
if ($haschanged) { |
my $return=$hash{'old'};
|
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
if ($untie_hash) { &untiehash(); }
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
return $return;
|
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
}
|
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>'); |
|
} else { |
sub changewarning {
|
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>'); |
my ($r,$postexec,$message,$url)=@_;
|
} |
if (!&is_hash_old()) { return; }
|
&mark_hash_old(); |
my $pathvar='folderpath';
|
} |
my $path=&escape($env{'form.folderpath'});
|
&changewarning($r,''); |
if (!defined($url)) {
|
if ($env{'form.timerange'} eq 'all') { |
if (defined($env{'form.pagepath'})) {
|
# show all documents |
$pathvar='pagepath';
|
$header=&mt('All Documents in '.$crstype); |
$path=&escape($env{'form.pagepath'});
|
$allsel=1; |
$path.='&pagesymb='.&escape($env{'form.pagesymb'});
|
foreach my $key (keys(%hash)) { |
}
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
$url='/adm/coursedocs?'.$pathvar.'='.$path;
|
my $src=$1; |
}
|
$changes{$src}=1; |
my $course_type = &Apache::loncommon::course_type();
|
} |
if (!defined($message)) {
|
} |
$message='Changes will become active for your current session after [_1], or the next time you log in.';
|
} else { |
}
|
# show documents which changed |
$r->print("\n\n".
|
%changes=&Apache::lonnet::dump |
'<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
|
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'}, |
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
'<input type="hidden" name="orgurl" value="'.$url.
|
my $firstkey=(keys(%changes))[0]; |
'" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
|
unless ($firstkey=~/^error\:/) { |
&mt($message,' <input type="hidden" name="'.
|
unless ($env{'form.timerange'}) { |
$env{'request.role'}.'" value="1" /><input type="button" value="'.
|
$env{'form.timerange'}=604800; |
&mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
|
} |
$help{'Caching'}.'</span></h3></form>'."\n\n");
|
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' ' |
}
|
.&mt('seconds'); |
|
if ($env{'form.timerange'}==-1) { |
|
$seltext='since start of course'; |
sub init_breadcrumbs {
|
$startsel='selected'; |
my ($form,$text)=@_;
|
$env{'form.timerange'}=time; |
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
} |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
|
$starttime=time-$env{'form.timerange'}; |
text=>"Edit ".&Apache::loncommon::course_type(),
|
if ($env{'form.timerange'}==2592000) { |
faq=>273,
|
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
bug=>'Instructor Interface',
|
$monthsel='selected'; |
help => 'Docs_Adding_Course_Doc'});
|
} elsif ($env{'form.timerange'}==604800) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
|
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
text=>$text,
|
$weeksel='selected'; |
faq=>273,
|
} elsif ($env{'form.timerange'}==86400) { |
bug=>'Instructor Interface'});
|
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
}
|
$daysel='selected'; |
|
} |
|
$header=&mt('Content changed').' '.$seltext; |
|
} else { |
|
$header=&mt('No content modifications yet.'); |
sub handler {
|
} |
my $r = shift;
|
} |
&Apache::loncommon::content_type($r,'text/html');
|
%setversions=&Apache::lonnet::dump('resourceversions', |
$r->send_http_header;
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
return OK if $r->header_only;
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
my $type = &Apache::loncommon::course_type();
|
my %lt=&Apache::lonlocal::texthash |
|
('st' => 'Version changes since start of '.$crstype, |
|
'lm' => 'Version changes since last Month', |
# --------------------------------------------- Initialize help topics for this
|
'lw' => 'Version changes since last Week', |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
|
'sy' => 'Version changes since Yesterday', |
'Adding_External_Resource','Navigate_Content',
|
'al' => 'All Resources (possibly large output)', |
'Adding_Folders','Docs_Overview', 'Load_Map',
|
'sd' => 'Display', |
'Supplemental','Score_Upload_Form','Adding_Pages',
|
'fi' => 'File', |
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
|
'md' => 'Modification Date', |
'Check_Resource_Versions','Verify_Content') {
|
'mr' => 'Most recently published Version', |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
|
've' => 'Version used in '.$crstype, |
}
|
'vu' => 'Set Version to be used in '.$crstype, |
# Composite help files
|
'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below', |
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
|
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', |
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
|
'sc' => 'Set all Resource Versions to current Version (Fix Versions)', |
$help{'Simple Page'} = &Apache::loncommon::help_open_topic(
|
'di' => 'Differences'); |
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
|
$r->print(<<ENDHEADERS); |
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
|
<form action="/adm/coursedocs" method="post"> |
'Option_Response_Simple');
|
<input type="hidden" name="versions" value="1" /> |
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
|
<input type="submit" name="setmostrecent" value="$lt{'sm'}" /> |
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
|
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr /> |
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
|
<select name="timerange"> |
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
|
<option value='all' $allsel>$lt{'al'}</option> |
$help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
|
<option value="-1" $startsel>$lt{'st'}</option> |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
|
<option value="2592000" $monthsel>$lt{'lm'}</option> |
|
<option value="604800" $weeksel>$lt{'lw'}</option> |
# does this user have privileges to modify docs
|
<option value="86400" $daysel>$lt{'sy'}</option> |
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
|
</select> |
if ($allowed && $env{'form.verify'}) {
|
<input type="submit" name="display" value="$lt{'sd'}" /> |
&init_breadcrumbs('verify','Verify Content');
|
<h3>$header</h3> |
&verifycontent($r);
|
<input type="submit" name="setversions" value="$lt{'sv'}" /> |
} elsif ($allowed && $env{'form.listsymbs'}) {
|
<table border="0"> |
&init_breadcrumbs('listsymbs','List Symbs');
|
ENDHEADERS |
&list_symbs($r);
|
foreach my $key (sort(keys(%changes))) { |
} elsif ($allowed && $env{'form.docslog'}) {
|
if ($changes{$key}>$starttime) { |
&init_breadcrumbs('docslog','Show Log');
|
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); |
&docs_change_log($r);
|
my $currentversion=&Apache::lonnet::getversion($key); |
} elsif ($allowed && $env{'form.versions'}) {
|
if ($currentversion<0) { |
&init_breadcrumbs('versions','Check/Set Resource Versions');
|
$currentversion=&mt('Could not be determined.'); |
&checkversions($r);
|
} |
} elsif ($allowed && $env{'form.dumpcourse'}) {
|
my $linkurl=&Apache::lonnet::clutter($key); |
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
|
$r->print( |
&dumpcourse($r);
|
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'. |
} elsif ($allowed && $env{'form.exportcourse'}) {
|
&Apache::lonnet::gettitle($linkurl). |
&init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
|
'</b></font></td></tr>'. |
&exportcourse($r);
|
'<tr><td> </td>'. |
} else {
|
'<td colspan="4">'. |
# is this a standard course?
|
'<a href="'.$linkurl.'" target="cat">'.$linkurl. |
|
'</a></td></tr>'. |
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
|
'<tr><td></td>'. |
my $forcestandard = 0;
|
'<td title="'.$lt{'md'}.'">'. |
my $forcesupplement;
|
&Apache::lonlocal::locallocaltime( |
my $script='';
|
&Apache::lonnet::metadata($root.'.'.$extension, |
my $showdoc=0;
|
'lastrevisiondate') |
my $containertag;
|
). |
my $uploadtag;
|
'</td>'. |
|
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '. |
|
'<font size="+1">'.$currentversion.'</font>'. |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
'</span></td>'. |
['folderpath','pagepath',
|
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$crstype.': '. |
'pagesymb']);
|
'<font size="+1">'); |
# No folderpath, no pagepath, see if we have something stored
|
# Used in course |
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
|
my $usedversion=$hash{'version_'.$linkurl}; |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
if (($usedversion) && ($usedversion ne 'mostrecent')) { |
{'folderpath' => 'scalar'});
|
$r->print($usedversion); |
}
|
} else { |
if (!$env{'form.folderpath'}) {
|
$r->print($currentversion); |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
} |
{'pagepath' => 'scalar'});
|
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'. |
}
|
'<span class="LC_nobreak">Use: '); |
if ($env{'form.pagepath'}) {
|
# Set version |
$env{'form.folderpath'}='';
|
$r->print(&Apache::loncommon::select_form($setversions{$linkurl}, |
}
|
'set_version_'.$linkurl, |
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
|
{'select_form_order' => |
$env{'form.folderpath'} = 'supplemental&'.
|
['',1..$currentversion,'mostrecent'], |
&escape(&mt('Supplemental '.$type.' Documents')).'&'.
|
'' => '', |
$env{'form.folderpath'};
|
'mostrecent' => &mt('most recent'), |
}
|
map {$_,$_} (1..$currentversion)})); |
&Apache::loncommon::store_course_settings('docs_folderpath',
|
$r->print('</span></td></tr><tr><td></td>'); |
{'pagepath' => 'scalar',
|
my $lastold=1; |
'folderpath' => 'scalar'});
|
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
if ($env{'form.folderpath'}) {
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
my (@folderpath)=split('&',$env{'form.folderpath'});
|
if (&Apache::lonnet::metadata($url,'lastrevisiondate')< |
$env{'form.foldername'}=&unescape(pop(@folderpath));
|
$starttime) { |
$env{'form.folder'}=pop(@folderpath);
|
$lastold=$prevvers; |
}
|
} |
if ($env{'form.pagepath'}) {
|
} |
my (@pagepath)=split('&',$env{'form.pagepath'});
|
# |
$env{'form.pagename'}=&unescape(pop(@pagepath));
|
# Code to figure out how many version entries should go in |
$env{'form.folder'}=pop(@pagepath);
|
# each of the four columns |
$containertag = '<input type="hidden" name="pagepath" value="" />'.
|
my $entries_per_col = 0; |
'<input type="hidden" name="pagesymb" value="" />';
|
my $num_entries = ($currentversion-$lastold); |
$uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
|
if ($num_entries % 4 == 0) { |
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
|
$entries_per_col = $num_entries/4; |
}
|
} else { |
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
|
$entries_per_col = $num_entries/4 + 1; |
$showdoc='/'.$1;
|
} |
}
|
my $entries_count = 0; |
unless ($showdoc) { # got called from remote
|
$r->print('<td valign="top"><font size="-2">'); |
if (($env{'form.folder'}=~/^(?:group|default)_/) ||
|
my $cols_output = 1; |
($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
|
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { |
$forcestandard = 1;
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
}
|
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url). |
$forcesupplement=($env{'form.folder'}=~/^supplemental_/);
|
'">'.&mt('Version').' '.$prevvers.'</a> ('. |
|
&Apache::lonlocal::locallocaltime( |
if ($allowed) {
|
&Apache::lonnet::metadata($url, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
|
'lastrevisiondate') |
$script=&Apache::lonratedt::editscript('simple');
|
). |
}
|
')'); |
} else { # got called in sequence from course
|
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { |
$allowed=0;
|
$r->print(' <a href="/adm/diff?filename='. |
}
|
&Apache::lonnet::clutter($root.'.'.$extension). |
|
'&versionone='.$prevvers. |
# get course data
|
'">'.&mt('Diffs').'</a>'); |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
|
} |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
$r->print('</span><br />'); |
|
if (++$entries_count % $entries_per_col == 0) { |
# get personal data
|
$r->print('</font></td>'); |
my $uname=$env{'user.name'};
|
if ($cols_output != 4) { |
my $udom=$env{'user.domain'};
|
$r->print('<td valign="top"><font size="-2">'); |
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
|
$cols_output++; |
|
} |
# graphics settings
|
} |
|
} |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
|
while($cols_output++ < 4) { |
|
$r->print('</font></td><td><font>') |
if ($allowed) {
|
} |
$script .= &editing_js($udom,$uname);
|
$r->print('</font></td></tr>'."\n"); |
}
|
} |
# -------------------------------------------------------------------- Body tag
|
} |
$script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
|
$r->print('</table></form>'); |
my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
|
$r->print('<p class="LC_success">'.&mt('Done').'</p>'); |
$r->print(&Apache::loncommon::start_page("$type Documents", $script,
|
|
{'force_register' => $showdoc,
|
&untiehash(); |
'bread_crumbs' => $brcrum}).
|
} |
&Apache::loncommon::help_open_menu('','',273,'RAT'));
|
|
|
sub mark_hash_old { |
my %allfiles = ();
|
my $retie_hash=0; |
my %codebase = ();
|
if ($hashtied) { |
my ($upload_result,$upload_output);
|
$retie_hash=1; |
if ($allowed) {
|
&untiehash(); |
if (($env{'form.uploaddoc.filename'}) &&
|
} |
($env{'form.cmd'}=~/^upload_(\w+)/)) {
|
&tiehash('write'); |
# Process file upload - phase one - upload and parse primary file.
|
$hash{'old'}=1; |
undef($hadchanges);
|
&untiehash(); |
$upload_result = &process_file_upload(\$upload_output,$coursenum,
|
if ($retie_hash) { &tiehash(); } |
$coursedom,\%allfiles,
|
} |
\%codebase,$1);
|
|
if ($hadchanges) {
|
sub is_hash_old { |
&mark_hash_old();
|
my $untie_hash=0; |
}
|
if (!$hashtied) { |
if ($upload_result eq 'phasetwo') {
|
$untie_hash=1; |
$r->print($upload_output);
|
&tiehash(); |
}
|
} |
} elsif ($env{'form.phasetwo'}) {
|
my $return=$hash{'old'}; |
my %newname = ();
|
if ($untie_hash) { &untiehash(); } |
my %origname = ();
|
return $return; |
my %attribs = ();
|
} |
my $updateflag = 0;
|
|
my $residx = $env{'form.newidx'};
|
sub changewarning { |
my $primary_url = &unescape($env{'form.primaryurl'});
|
my ($r,$postexec,$message,$url)=@_; |
# Process file upload - phase two - gather secondary files.
|
if (!&is_hash_old()) { return; } |
for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
|
my $pathvar='folderpath'; |
if ($env{'form.embedded_item_'.$i.'.filename'}) {
|
my $path=&escape($env{'form.folderpath'}); |
my $javacodebase;
|
if (!defined($url)) { |
$newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
|
if (defined($env{'form.pagepath'})) { |
$origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
|
$pathvar='pagepath'; |
if (exists($env{'form.embedded_codebase_'.$i})) {
|
$path=&escape($env{'form.pagepath'}); |
$javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
|
$path.='&pagesymb='.&escape($env{'form.pagesymb'}); |
$origname{$i} =~ s#^\Q$javacodebase\E/##;
|
} |
}
|
$url='/adm/coursedocs?'.$pathvar.'='.$path; |
my @attributes = ();
|
} |
if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
|
my $course_type = &Apache::loncommon::course_type(); |
@attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
|
if (!defined($message)) { |
} else {
|
$message='Changes will become active for your current session after [_1], or the next time you log in.'; |
@attributes = ($env{'form.embedded_attrib_'.$i});
|
} |
}
|
$r->print("\n\n". |
foreach my $attr (@attributes) {
|
'<script type="text/javascript">'."\n". |
push(@{$attribs{$i}},&unescape($attr));
|
'// <![CDATA['."\n". |
}
|
'function reinit(tf) { tf.submit();'.$postexec.' }'."\n". |
if ($javacodebase) {
|
'// ]]>'."\n". |
$codebase{$i} = $javacodebase;
|
'</script>'."\n". |
$codebase{$i} =~ s#/$##;
|
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'. |
$updateflag = 1;
|
'<input type="hidden" name="orgurl" value="'.$url. |
}
|
'" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'. |
}
|
&mt($message,' <input type="hidden" name="'. |
unless ($newname{$i} eq $origname{$i}) {
|
$env{'request.role'}.'" value="1" /><input type="button" value="'. |
$updateflag = 1;
|
&mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />'). |
}
|
$help{'Caching'}.'</p></form>'."\n\n"); |
}
|
} |
# Process file upload - phase three - modify primary file
|
|
if ($updateflag) {
|
|
my ($content,$rtncode);
|
sub init_breadcrumbs { |
my $updateflag = 0;
|
my ($form,$text)=@_; |
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
if ($getstatus eq 'ok') {
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs", |
foreach my $item (keys(%newname)) {
|
text=>&Apache::loncommon::course_type().' Editor', |
if ($newname{$item} ne $origname{$item}) {
|
faq=>273, |
my $attrib_regexp = '';
|
bug=>'Instructor Interface', |
if (@{$attribs{$item}} > 1) {
|
help => 'Docs_Adding_Course_Doc'}); |
$attrib_regexp = join('|',@{$attribs{$item}});
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1', |
} else {
|
text=>$text, |
$attrib_regexp = $attribs{$item}[0];
|
faq=>273, |
}
|
bug=>'Instructor Interface'}); |
if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
|
} |
}
|
|
$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
|
# subroutine to list form elements |
}
|
sub create_list_elements { |
if (exists($codebase{$item})) {
|
my @formarr = @_; |
$content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
|
my $list = ''; |
}
|
for my $button (@formarr){ |
}
|
for my $picture(keys %$button) { |
# Save edited file.
|
$list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); |
my $saveresult;
|
} |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
|
} |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
return $list; |
my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
|
} |
} else {
|
|
&Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
|
# subroutine to create ul from list elements |
}
|
sub create_form_ul { |
}
|
my $list = shift; |
}
|
my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'}); |
}
|
return $ul; |
|
} |
unless ($showdoc || $upload_result eq 'phasetwo') {
|
|
# -----------------------------------------------------------------------------
|
# |
my %lt=&Apache::lonlocal::texthash(
|
# Start tabs |
'uplm' => 'Upload a new main '.lc($type).' document',
|
# |
'upls' => 'Upload a new supplemental '.lc($type).' document',
|
|
'impp' => 'Import a document',
|
sub startContentScreen { |
'pubd' => 'Published Documents',
|
my ($r,$mode)=@_; |
'copm' => 'All documents out of a published map into this folder',
|
$r->print('<ul class="LC_TabContentBigger" id="mainnav">'); |
'upld' => 'Upload Document',
|
$r->print('<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'); |
'srch' => 'Search',
|
|
'impo' => 'Import',
|
my $active = ''; |
'book' => 'Import Bookmarks',
|
# does this user have privileges to modify docs? |
'selm' => 'Select Map',
|
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
'load' => 'Load Map',
|
|
'reco' => 'Recover Deleted Resources',
|
my $onclick; |
'newf' => 'New Folder',
|
my $href; |
'newp' => 'New Composite Page',
|
|
'extr' => 'External Resource',
|
if ($allowed) { |
'syll' => 'Syllabus',
|
$r->print('<li '.(($mode eq 'docs')?' class="active"':''). |
'navc' => 'Navigate Contents',
|
' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'); |
'sipa' => 'Simple Page',
|
} |
'sipr' => 'Simple Problem',
|
$r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'); |
'drbx' => 'Drop Box',
|
$r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'); |
'scuf' => 'Score Upload Form',
|
$r->print('<li '.(($mode eq 'supdocs')?' class="active"':''). |
'bull' => 'Bulletin Board',
|
'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Documents').'</b></a></li>'); |
'mypi' => 'My Personal Info',
|
$r->print('</ul>'); |
'grpo' => 'Group Files',
|
$r->print('<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">' |
'rost' => 'Course Roster',
|
.'<div id="maincoursedoc" style="margin:0 0;padding:0 0">'); |
'abou' => 'About User',
|
$r->print('<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">'); |
'imsf' => 'Import IMS package',
|
} |
'file' => 'File',
|
|
'title' => 'Title',
|
# |
'comment' => 'Comment',
|
# End tabs |
'parse' => 'Upload embedded images/multimedia files if HTML file!',
|
# |
'nd' => 'New Document',
|
|
'pm' => 'Published Map',
|
sub endContentScreen { |
'sd' => 'Special Document',
|
my ($r)=@_; |
'mo' => 'More Options',
|
$r->print('</div></div></div>'); |
'hao' => 'Hide all Options'
|
} |
);
|
|
# -----------------------------------------------------------------------------
|
sub supplemental_base { |
my $fileupload=(<<FIUP);
|
return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Documents')); |
$lt{'file'}:<br />
|
} |
<input type="file" name="uploaddoc" size="40" />
|
|
FIUP
|
sub handler { |
|
my $r = shift; |
my $checkbox=(<<CHBO);
|
&Apache::loncommon::content_type($r,'text/html'); |
<!-- <label>$lt{'parse'}?
|
$r->send_http_header; |
<input type="checkbox" name="parserflag" />
|
return OK if $r->header_only; |
</label> -->
|
my $crstype = &Apache::loncommon::course_type(); |
<label>
|
|
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
|
# |
</label>
|
# --------------------------------------------- Initialize help topics for this |
CHBO
|
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', |
|
'Adding_External_Resource','Navigate_Content', |
my $fileuploadform=(<<FUFORM);
|
'Adding_Folders','Docs_Overview', 'Load_Map', |
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
'Supplemental','Score_Upload_Form','Adding_Pages', |
$fileupload
|
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', |
<br />
|
'Check_Resource_Versions','Verify_Content') { |
$lt{'title'}:<br />
|
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
<input type="text" size="50" name="comment" />
|
} |
$uploadtag
|
# Composite help files |
<input type="hidden" name="cmd" value="upload_default" />
|
$help{'Syllabus'} = &Apache::loncommon::help_open_topic( |
<br />
|
'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); |
<span class="LC_nobreak">
|
$help{'Simple Page'} = &Apache::loncommon::help_open_topic( |
$checkbox
|
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); |
</span>
|
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic( |
<br />
|
'Option_Response_Simple'); |
<br />
|
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( |
<span class="LC_nobreak">
|
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); |
<input type="submit" value="$lt{'upld'}" />
|
$help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic( |
$help{'Uploading_From_Harddrive'}
|
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); |
</span>
|
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
</form>
|
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
FUFORM
|
|
|
# does this user have privileges to modify docs |
my $simpleeditdefaultform=(<<SEDFFORM);
|
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
|
if ($allowed && $env{'form.verify'}) { |
$lt{'pubd'}<br />
|
&init_breadcrumbs('verify','Verify Content'); |
$uploadtag
|
&verifycontent($r); |
<input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
|
} elsif ($allowed && $env{'form.listsymbs'}) { |
<br />
|
&init_breadcrumbs('listsymbs','List Symbs'); |
<span class="LC_nobreak">
|
&list_symbs($r); |
<input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
|
} elsif ($allowed && $env{'form.docslog'}) { |
$help{'Importing_LON-CAPA_Resource'}
|
&init_breadcrumbs('docslog','Show Log'); |
</span>
|
&docs_change_log($r); |
<br />
|
} elsif ($allowed && $env{'form.versions'}) { |
<input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
|
&init_breadcrumbs('versions','Check/Set Resource Versions'); |
<hr />
|
&checkversions($r); |
<p>
|
} elsif ($allowed && $env{'form.dumpcourse'}) { |
$lt{'copm'}<br />
|
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Documents to Construction Space'); |
<input type="text" size="40" name="importmap" /><br />
|
&dumpcourse($r); |
<span class="LC_nobreak"><input type="button"
|
} elsif ($allowed && $env{'form.exportcourse'}) { |
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
|
&init_breadcrumbs('exportcourse','IMS Export'); |
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
|
&exportcourse($r); |
$help{'Load_Map'}</span>
|
} else { |
</p>
|
# |
</form>
|
# Done catching special calls |
SEDFFORM
|
# The whole rest is for course and supplemental documents |
|
# Get the parameters that may be needed |
my $extresourcesform=(<<ERFORM);
|
# |
<form action="/adm/coursedocs" method="post" name="newext">
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
$uploadtag
|
['folderpath','pagepath', |
<input type="hidden" name="importdetail" value="" />
|
'pagesymb','forcesupplement','forcestandard']); |
<span class="LC_nobreak">
|
|
<input name="newext" type="button" onClick="javascript:makenewext('newext');"
|
# standard=1: this is a "new-style" course with an uploaded map as top level |
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
# standard=2: this is a "old-style" course, and there is nothing we can do |
</span>
|
|
</form>
|
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//); |
ERFORM
|
|
|
# Decide whether this should display supplemental or main content |
if ($allowed) {
|
# supplementalflag=1: show supplemental documents |
&update_paste_buffer($coursenum,$coursedom);
|
# supplementalflag=0: show standard documents |
my $dumpbut=&dumpbutton();
|
|
my $exportbut=&exportbutton();
|
|
my %lt=&Apache::lonlocal::texthash(
|
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
'vc' => 'Verify Content',
|
if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) { |
'cv' => 'Check/Set Resource Versions',
|
$supplementalflag=0; |
'ls' => 'List Symbs',
|
} |
'sl' => 'Show Log'
|
if ($env{'form.forcesupplement'}) { $supplementalflag=1; } |
);
|
if ($env{'form.forcestandard'}) { $supplementalflag=0; } |
|
unless ($allowed) { $supplementalflag=1; } |
my $folderpath=$env{'form.folderpath'};
|
unless ($standard) { $supplementalflag=1; } |
if (!$folderpath) {
|
|
if ($env{'form.folder'} eq '' ||
|
my $script=''; |
$env{'form.folder'} eq 'supplemental') {
|
my $showdoc=0; |
$folderpath='default&'.
|
my $addentries = {}; |
&escape(&mt('Main '.$type.' Documents'));
|
my $containertag; |
}
|
my $uploadtag; |
}
|
|
unless ($env{'form.pagepath'}) {
|
# Where do we store these for when we come back? |
$containertag = '<input type="hidden" name="folderpath" value="" />';
|
my $stored_folderpath='docs_folderpath'; |
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
|
if ($supplementalflag) { |
}
|
$stored_folderpath='docs_sup_folderpath'; |
$r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env));
|
} |
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
|
|
&mt('Editing the Table of Contents for your '.$type)));
|
# No folderpath, no pagepath, see if we have something stored |
}
|
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) { |
# --------------------------------------------------------- Standard documents
|
&Apache::loncommon::restore_course_settings($stored_folderpath, |
$r->print('<table class="LC_docs_documents">');
|
{'folderpath' => 'scalar'}); |
|
} |
if (($standard) && ($allowed) && (!$forcesupplement)) {
|
|
$r->print('<tr><td class="LC_docs_document">');
|
# If we are not allowed to make changes, all we can see are supplemental docs |
# '<h2>'.&mt('Main Course Documents').
|
if (!$allowed) { |
# ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
|
$env{'form.pagepath'}=''; |
my $folder=$env{'form.folder'};
|
unless ($env{'form.folderpath'} =~ /^supplemental/) { |
if ($folder eq '' || $folder eq 'supplemental') {
|
$env{'form.folderpath'} = &supplemental_base(); |
$folder='default';
|
} |
$env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
|
} |
$uploadtag = '<input type="hidden" name="folderpath" value="'.
|
# If we still not have a folderpath, see if we can resurrect at pagepath |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
|
if (!$env{'form.folderpath'} && $allowed) { |
}
|
&Apache::loncommon::restore_course_settings($stored_folderpath, |
my $postexec='';
|
{'pagepath' => 'scalar'}); |
if ($folder eq 'default') {
|
} |
$r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
|
# Make the zeroth entry in supplemental docs page paths, so we can get to top level |
} else {
|
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) { |
#$postexec='self.close();';
|
$env{'form.folderpath'} = &supplemental_base() |
}
|
.'&'. |
$hadchanges=0;
|
$env{'form.folderpath'}; |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
|
} |
$upload_output,$type);
|
# If after all of this, we still don't have any paths, make them |
if ($error) {
|
unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) { |
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
if ($supplementalflag) { |
}
|
$env{'form.folderpath'}=&supplemental_base(); |
if ($hadchanges) {
|
} else { |
&mark_hash_old();
|
$env{'form.folderpath'}='default'; |
}
|
} |
&changewarning($r,$postexec);
|
} |
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
|
'.sequence';
|
# Store this |
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
&Apache::loncommon::store_course_settings($stored_folderpath, |
'.page';
|
{'pagepath' => 'scalar', |
my $container='sequence';
|
'folderpath' => 'scalar'}); |
if ($env{'form.pagepath'}) {
|
|
$container='page';
|
if ($env{'form.folderpath'}) { |
}
|
my (@folderpath)=split('&',$env{'form.folderpath'}); |
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
|
$env{'form.foldername'}=&unescape(pop(@folderpath)); |
|
$env{'form.folder'}=pop(@folderpath); |
|
} |
|
if ($env{'form.pagepath'}) { |
my $recoverform=(<<RFORM);
|
my (@pagepath)=split('&',$env{'form.pagepath'}); |
<form action="/adm/groupsort" method="post" name="recover">
|
$env{'form.pagename'}=&unescape(pop(@pagepath)); |
<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
|
$env{'form.folder'}=pop(@pagepath); |
</form>
|
$containertag = '<input type="hidden" name="pagepath" value="" />'. |
RFORM
|
'<input type="hidden" name="pagesymb" value="" />'; |
|
$uploadtag = |
my $imspform=(<<IMSPFORM);
|
'<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'. |
<form action="/adm/imsimportdocs" method="post" name="ims">
|
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'. |
<input type="hidden" name="folder" value="$folder" />
|
'<input type="hidden" name="folderpath" value="" />'; |
<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
|
} else { |
</form>
|
my $folderpath=$env{'form.folderpath'}; |
IMSPFORM
|
if (!$folderpath) { |
|
if ($env{'form.folder'} eq '' || |
my $newnavform=(<<NNFORM);
|
$env{'form.folder'} eq 'supplemental') { |
<form action="/adm/coursedocs" method="post" name="newnav">
|
$folderpath='default&'. |
$uploadtag
|
&escape(&mt('Main '.$crstype.' Documents')); |
<input type="hidden" name="importdetail"
|
} |
value="$lt{'navc'}=/adm/navmaps" />
|
} |
<span class="LC_nobreak">
|
$containertag = '<input type="hidden" name="folderpath" value="" />'; |
<input name="newnav" type="submit" value="$lt{'navc'}" />
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; |
$help{'Navigate_Content'}
|
} |
</span>
|
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { |
</form>
|
$showdoc='/'.$1; |
NNFORM
|
} |
my $newsmppageform=(<<NSPFORM);
|
if ($showdoc) { # got called in sequence from course |
<form action="/adm/coursedocs" method="post" name="newsmppg">
|
$allowed=0; |
$uploadtag
|
} else { |
<input type="hidden" name="importdetail" value="" />
|
if ($allowed) { |
<span class="LC_nobreak">
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); |
<input name="newsmppg" type="button" value="$lt{'sipa'}"
|
$script=&Apache::lonratedt::editscript('simple'); |
onClick="javascript:makesmppage();" /> $help{'Simple Page'}
|
} |
</span>
|
} |
</form>
|
|
NSPFORM
|
# get course data |
|
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $newsmpproblemform=(<<NSPROBFORM);
|
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
<form action="/adm/coursedocs" method="post" name="newsmpproblem">
|
|
$uploadtag
|
# get personal data |
<input type="hidden" name="importdetail" value="" />
|
my $uname=$env{'user.name'}; |
<span class="LC_nobreak">
|
my $udom=$env{'user.domain'}; |
<input name="newsmpproblem" type="button" value="$lt{'sipr'}"
|
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom)); |
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
|
|
</span>
|
# graphics settings |
</form>
|
|
|
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); |
NSPROBFORM
|
|
|
if ($allowed) { |
my $newdropboxform=(<<NDBFORM);
|
my @tabids; |
<form action="/adm/coursedocs" method="post" name="newdropbox">
|
if ($supplementalflag) { |
$uploadtag
|
@tabids = ('002','ee2','ff2'); |
<input type="hidden" name="importdetail" value="" />
|
} else { |
<span class="LC_nobreak">
|
@tabids = ('aa1','bb1','cc1','ff1'); |
<input name="newdropbox" type="button" value="$lt{'drbx'}"
|
unless ($env{'form.pagepath'}) { |
onClick="javascript:makedropbox();" />
|
unshift(@tabids,'001'); |
</span>
|
push(@tabids,('dd1','ee1')); |
</form>
|
} |
NDBFORM
|
} |
|
my $tabidstr = join("','",@tabids); |
my $newexuploadform=(<<NEXUFORM);
|
$script .= &editing_js($udom,$uname). |
<form action="/adm/coursedocs" method="post" name="newexamupload">
|
&resize_contentdiv_js($tabidstr); |
$uploadtag
|
$addentries = { |
<input type="hidden" name="importdetail" value="" />
|
onload => "javascript:resize_contentdiv('contentscroll','1','1');", |
<span class="LC_nobreak">
|
}; |
<input name="newexamupload" type="button" value="$lt{'scuf'}"
|
} |
onClick="javascript:makeexamupload();" />
|
# -------------------------------------------------------------------- Body tag |
$help{'Score_Upload_Form'}
|
$script = '<script type="text/javascript">'."\n" |
</span>
|
.'// <![CDATA['."\n" |
</form>
|
.$script."\n" |
NEXUFORM
|
.'// ]]>'."\n" |
|
.'</script>'."\n"; |
my $newbulform=(<<NBFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newbul">
|
# Breadcrumbs |
$uploadtag
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
<input type="hidden" name="importdetail" value="" />
|
unless ($showdoc) { |
<span class="LC_nobreak">
|
&Apache::lonhtmlcommon::add_breadcrumb({ |
<input name="newbulletin" type="button" value="$lt{'bull'}"
|
href=>"/adm/coursedocs",text=>"$crstype Contents"}); |
onClick="javascript:makebulboard();" />
|
|
$help{'Bulletin Board'}
|
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script, |
</span>
|
{'force_register' => $showdoc, |
</form>
|
'add_entries' => $addentries, |
NBFORM
|
}) |
|
.&Apache::loncommon::help_open_menu('','',273,'RAT') |
my $newaboutmeform=(<<NAMFORM);
|
.&Apache::lonhtmlcommon::breadcrumbs( |
<form action="/adm/coursedocs" method="post" name="newaboutme">
|
'Editing the Table of Contents for your '.$crstype, |
$uploadtag
|
'Docs_Adding_Course_Doc') |
<input type="hidden" name="importdetail"
|
); |
value="$plainname=/adm/$udom/$uname/aboutme" />
|
} else { |
<span class="LC_nobreak">
|
$r->print(&Apache::loncommon::start_page("$crstype documents",undef, |
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
{'force_register' => $showdoc,})); |
$help{'My Personal Info'}
|
} |
</span>
|
|
</form>
|
my %allfiles = (); |
NAMFORM
|
my %codebase = (); |
|
my ($upload_result,$upload_output,$uploadphase); |
my $newaboutsomeoneform=(<<NASOFORM);
|
if ($allowed) { |
<form action="/adm/coursedocs" method="post" name="newaboutsomeone">
|
if (($env{'form.uploaddoc.filename'}) && |
$uploadtag
|
($env{'form.cmd'}=~/^upload_(\w+)/)) { |
<input type="hidden" name="importdetail" value="" />
|
my $context = $1; |
<span class="LC_nobreak">
|
# Process file upload - phase one - upload and parse primary file. |
<input name="newaboutsomeone" type="button" value="$lt{'abou'}"
|
undef($hadchanges); |
onClick="javascript:makeabout();" />
|
$uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom, |
</span>
|
\%allfiles,\%codebase,$context); |
</form>
|
if ($hadchanges) { |
NASOFORM
|
&mark_hash_old(); |
|
} |
|
$r->print($upload_output); |
my $newrosterform=(<<NROSTFORM);
|
} elsif ($env{'form.phase'} eq 'upload_embedded') { |
<form action="/adm/coursedocs" method="post" name="newroster">
|
# Process file upload - phase two - upload embedded objects |
$uploadtag
|
$uploadphase = 'check_embedded'; |
<input type="hidden" name="importdetail"
|
my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"'); |
value="$lt{'rost'}=/adm/viewclasslist" />
|
my $state = &embedded_form_elems($uploadphase,$primaryurl, |
<span class="LC_nobreak">
|
$env{'form.newidx'}); |
<input name="newroster" type="submit" value="$lt{'rost'}" />
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
$help{'Course Roster'}
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
</span>
|
my ($destination,$dir_root) = &embedded_destination(); |
</form>
|
my $url_root = '/uploaded/'.$docudom.'/'.$docuname; |
NROSTFORM
|
my $actionurl = '/adm/coursedocs'; |
|
my ($result,$flag) = |
$r->print(<<ENDFORM);
|
&Apache::loncommon::upload_embedded('coursedoc',$destination, |
|
$docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state, |
<ul class="LC_TabContent">
|
$actionurl); |
<li>$lt{'nd'}</li>
|
$r->print($result.&return_to_editor()); |
<li>$lt{'pm'}</li>
|
} elsif ($env{'form.phase'} eq 'check_embedded') { |
<li>$lt{'pubd'}</li>
|
# Process file upload - phase three - modify references in HTML file |
<li>$lt{'sd'}</li>
|
$uploadphase = 'modified_orightml'; |
<li>$lt{'mo'}</li>
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
<li>$lt{'hao'}</li>
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
</ul>
|
my ($destination,$dir_root) = &embedded_destination(); |
|
$r->print(&Apache::loncommon::modify_html_refs('coursedoc',$destination, |
<table class="LC_docs_adddocs">
|
$docuname,$docudom,undef, |
<!-- <tr>
|
$dir_root). |
<th>$lt{'uplm'}</th>
|
&return_to_editor()); |
<th>$lt{'impp'}</th>
|
} |
<th>$lt{'spec'}</th>
|
} |
</tr> -->
|
|
<tr>
|
unless ($showdoc || $uploadphase) { |
<td>
|
# ----------------------------------------------------------------------------- |
$fileuploadform
|
my %lt=&Apache::lonlocal::texthash( |
</td>
|
'uplm' => 'Upload a new main '.lc($crstype).' document', |
<td>
|
'upls' => 'Upload a new supplemental '.lc($crstype).' document', |
$simpleeditdefaultform
|
'impp' => 'Import a document', |
<hr />
|
'copm' => 'All documents out of a published map into this folder', |
$recoverform
|
'upld' => 'Import Document', |
ENDFORM
|
'srch' => 'Search', |
unless ($env{'form.pagepath'}) {
|
'impo' => 'Import', |
$r->print(<<ENDFORM);
|
'wish' => 'Import from Wishlist', |
<hr />
|
'selm' => 'Select Map', |
$extresourcesform
|
'load' => 'Load Map', |
<br />
|
'reco' => 'Recover Deleted Documents', |
$imspform
|
'newf' => 'New Folder', |
ENDFORM
|
'newp' => 'New Composite Page', |
}
|
'extr' => 'External Resource', |
$r->print('</td><td>');
|
'syll' => 'Syllabus', |
unless ($env{'form.pagepath'}) {
|
'navc' => 'Table of Contents', |
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
'sipa' => 'Simple Course Page', |
|
'sipr' => 'Simple Problem', |
|
'drbx' => 'Drop Box', |
|
'scuf' => 'External Scores (handgrade, upload, clicker)', |
my $newpageform=(<<NPFORM);
|
'bull' => 'Discussion Board', |
<form action="/adm/coursedocs" method="post" name="newpage">
|
'mypi' => 'My Personal Information Page', |
<input type="hidden" name="folderpath" value="$path" />
|
'grpo' => 'Group Portfolio', |
<input type="hidden" name="importdetail" value="" />
|
'rost' => 'Course Roster', |
<span class="LC_nobreak">
|
'abou' => 'Personal Information Page for a User', |
<input name="newpage" type="button"
|
'imsf' => 'IMS Import', |
onClick="javascript:makenewpage(this.form,'$pageseq');"
|
'imsl' => 'Import IMS package', |
value="$lt{'newp'}" />$help{'Adding_Pages'}
|
'file' => 'File', |
</span>
|
'title' => 'Title', |
</form>
|
'comment' => 'Comment', |
NPFORM
|
'parse' => 'Upload embedded images/multimedia files if HTML file', |
|
'nd' => 'Upload Document', |
my $newfolderform=(<<NFFORM);
|
'pm' => 'Published Map', |
<form action="/adm/coursedocs" method="post" name="newfolder">
|
'sd' => 'Special Document', |
<input type="hidden" name="folderpath" value="$path" />
|
'mo' => 'More Options', |
<input type="hidden" name="importdetail" value="" />
|
); |
<span class="LC_nobreak">
|
# ----------------------------------------------------------------------------- |
<input name="newfolder" type="button"
|
my $fileupload=(<<FIUP); |
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
$lt{'file'}:<br /> |
value="$lt{'newf'}" />$help{'Adding_Folders'}
|
<input type="file" name="uploaddoc" size="40" /> |
</span>
|
FIUP |
</form>
|
|
NFFORM
|
my $checkbox=(<<CHBO); |
|
<!-- <label>$lt{'parse'}? |
my $newsylform=(<<NSYLFORM);
|
<input type="checkbox" name="parserflag" /> |
<form action="/adm/coursedocs" method="post" name="newsyl">
|
</label> --> |
$uploadtag
|
<label> |
<input type="hidden" name="importdetail"
|
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'} |
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
|
</label> |
<span class="LC_nobreak">
|
CHBO |
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
|
$help{'Syllabus'}
|
my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}"; |
</span>
|
my $fileuploadform=(<<FUFORM); |
</form>
|
<div style="float:left"> |
NSYLFORM
|
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
|
<input type="hidden" name="active" value="aa" /> |
my $newgroupfileform=(<<NGFFORM);
|
$fileupload |
<form action="/adm/coursedocs" method="post" name="newgroupfiles">
|
<br /> |
$uploadtag
|
$lt{'title'}:<br /> |
<input type="hidden" name="importdetail"
|
<input type="text" size="60" name="comment" /> |
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
|
$uploadtag |
<span class="LC_nobreak">
|
<input type="hidden" name="cmd" value="upload_default" /> |
<input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
|
<br /> |
$help{'Group Files'}
|
<span class="LC_nobreak" style="float:left"> |
</span>
|
$checkbox |
</form>
|
</span> |
NGFFORM
|
FUFORM |
|
$fileuploadform .= $fileuploada.'</form></div>'; |
|
|
$r->print(<<ENDFORM);
|
my $simpleeditdefaultform=(<<SEDFFORM); |
<br />
|
<form action="/adm/coursedocs" method="post" name="simpleeditdefault"> |
$newfolderform
|
<input type="hidden" name="active" value="bb" /> |
<br />
|
SEDFFORM |
$newpageform
|
my @simpleeditdefaultforma = ( |
<br />
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/src.png" alt="'.$lt{srch}.'" onclick="javascript:groupsearch()" />' => "$uploadtag<a class='LC_menubuttons_link' href='javascript:groupsearch()'>$lt{'srch'}</a>" }, |
$newsylform
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" }, |
<br />
|
{ '<img class="LC_noBorder LC_middle" src="/res/adm/pages/wishlist.png" alt="'.$lt{wish}.'" onclick="javascript:open_Wishlist_Import();" />' => "<a class='LC_menubuttons_link' href='javascript:open_Wishlist_Import();'>$lt{'wish'}</a>" }, |
$newnavform
|
); |
<br />
|
$simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma)); |
$newsmppageform
|
$simpleeditdefaultform .=(<<SEDFFORM); |
<br />
|
<hr /> |
$newsmpproblemform
|
$lt{'copm'}<br /> |
<br />
|
<input type="text" size="40" name="importmap" /><br /> |
$newdropboxform
|
<span class="LC_nobreak" style="float:left"><input type="button" |
<br />
|
onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" |
$newexuploadform
|
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" /> |
<br />
|
$help{'Load_Map'}</span> |
$newbulform
|
</form> |
<br />
|
SEDFFORM |
$newaboutmeform
|
|
<br />
|
my $extresourcesform=(<<ERFORM); |
$newaboutsomeoneform
|
<form action="/adm/coursedocs" method="post" name="newext"> |
<br />
|
$uploadtag |
$newgroupfileform
|
<input type="hidden" name="importdetail" value="" /> |
<br />
|
<a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'} |
$newrosterform
|
</form> |
ENDFORM
|
ERFORM |
}
|
|
if ($env{'form.pagepath'}) {
|
|
$r->print(<<ENDBLOCK);
|
if ($allowed) { |
$newsmpproblemform
|
&update_paste_buffer($coursenum,$coursedom); |
<br />
|
my %lt=&Apache::lonlocal::texthash( |
$newexuploadform
|
'vc' => 'Verify Content', |
ENDBLOCK
|
'cv' => 'Check/Set Resource Versions', |
}
|
'ls' => 'List Symbs', |
$r->print('</td></tr>'."\n".
|
'sl' => 'Show Log' |
'</table>');
|
); |
$r->print('</td></tr>');
|
|
}
|
$r->print(<<HIDDENFORM); |
# ----------------------------------------------------- Supplemental documents
|
<form name="renameform" method="post" action="/adm/coursedocs"> |
if (!$forcestandard) {
|
<input type="hidden" name="title" /> |
$r->print('<tr><td class="LC_docs_document">');
|
<input type="hidden" name="cmd" /> |
# '<h2>'.&mt('Supplemental Course Documents').
|
<input type="hidden" name="markcopy" /> |
# ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
|
<input type="hidden" name="copyfolder" /> |
my $folder=$env{'form.folder'};
|
$containertag |
unless ($folder=~/^supplemental/) {
|
</form> |
$folder='supplemental';
|
<form name="simpleedit" method="post" action="/adm/coursedocs"> |
}
|
<input type="hidden" name="importdetail" value="" /> |
if ($folder =~ /^supplemental$/ &&
|
$uploadtag |
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
|
</form> |
$env{'form.folderpath'} = 'supplemental&'.
|
HIDDENFORM |
&escape(&mt('Supplemental '.$type.' Documents'));
|
} |
}
|
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
|
# Generate the tabs |
if ($error) {
|
&startContentScreen($r,($supplementalflag?'supdocs':'docs')); |
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
|
}
|
|
if ($allowed) {
|
# |
my $folderseq=
|
|
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
|
my $savefolderpath; |
'.sequence';
|
|
|
if ($allowed) { |
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
my $folder=$env{'form.folder'}; |
|
if ($folder eq '' || $supplementalflag) { |
my $supupdocform=(<<SUPDOCFORM);
|
$folder='default'; |
<form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
$savefolderpath = $env{'form.folderpath'}; |
$fileupload
|
$env{'form.folderpath'}='default&'.&escape(&mt('Content')); |
<br />
|
$uploadtag = '<input type="hidden" name="folderpath" value="'. |
<br />
|
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'; |
<span class="LC_nobreak">
|
} |
$checkbox
|
my $postexec=''; |
</span>
|
if ($folder eq 'default') { |
<br /><br />
|
$r->print('<script type="text/javascript">'."\n" |
$lt{'comment'}:<br />
|
.'// <![CDATA['."\n" |
<textarea cols=50 rows=4 name='comment'>
|
.'this.window.name="loncapaclient";'."\n" |
</textarea>
|
.'// ]]>'."\n" |
<br />
|
.'</script>'."\n" |
<input type="hidden" name="folderpath" value="$path" />
|
); |
<input type="hidden" name="cmd" value="upload_supplemental" />
|
} else { |
<span class="LC_nobreak">
|
#$postexec='self.close();'; |
<input type="submit" value="$lt{'upld'}" />
|
} |
$help{'Uploading_From_Harddrive'}
|
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
</span>
|
'.sequence'; |
</form>
|
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
SUPDOCFORM
|
'.page'; |
|
my $container='sequence'; |
my $supnewfolderform=(<<SNFFORM);
|
if ($env{'form.pagepath'}) { |
<form action="/adm/coursedocs" method="post" name="supnewfolder">
|
$container='page'; |
<input type="hidden" name="folderpath" value="$path" />
|
} |
<input type="hidden" name="importdetail" value="" />
|
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; |
<span class="LC_nobreak">
|
|
<input name="newfolder" type="button"
|
|
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
|
value="$lt{'newf'}" /> $help{'Adding_Folders'}
|
my $recoverform=(<<RFORM); |
</span>
|
<form action="/adm/groupsort" method="post" name="recover"> |
</form>
|
<a class="LC_menubuttons_link" href="javascript:groupopen('$readfile',1)">$lt{'reco'}</a> |
SNFFORM
|
</form> |
|
RFORM |
|
|
my $supnewextform=(<<SNEFORM);
|
my $imspform=(<<IMSPFORM); |
<form action="/adm/coursedocs" method="post" name="supnewext">
|
<form action="/adm/imsimportdocs" method="post" name="ims"> |
<input type="hidden" name="folderpath" value="$path" />
|
<input type="hidden" name="folder" value="$folder" /> |
<input type="hidden" name="importdetail" value="" />
|
<a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a> |
<span class="LC_nobreak">
|
</form> |
<input name="newext" type="button"
|
IMSPFORM |
onClick="javascript:makenewext('supnewext');"
|
|
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
my $newnavform=(<<NNFORM); |
</span>
|
<form action="/adm/coursedocs" method="post" name="newnav"> |
</form>
|
<input type="hidden" name="active" value="cc" /> |
SNEFORM
|
$uploadtag |
|
<input type="hidden" name="importdetail" |
my $supnewsylform=(<<SNSFORM);
|
value="$lt{'navc'}=/adm/navmaps" /> |
<form action="/adm/coursedocs" method="post" name="supnewsyl">
|
<a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a> |
<input type="hidden" name="folderpath" value="$path" />
|
$help{'Navigate_Content'} |
<input type="hidden" name="importdetail"
|
</form> |
value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
|
NNFORM |
<span class="LC_nobreak">
|
my $newsmppageform=(<<NSPFORM); |
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
<form action="/adm/coursedocs" method="post" name="newsmppg"> |
$help{'Syllabus'}
|
<input type="hidden" name="active" value="cc" /> |
</span>
|
$uploadtag |
</form>
|
<input type="hidden" name="importdetail" value="" /> |
SNSFORM
|
<a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a> |
|
$help{'Simple Page'} |
my $supnewaboutmeform=(<<SNAMFORM);
|
</form> |
<form action="/adm/coursedocs" method="post" name="subnewaboutme">
|
NSPFORM |
<input type="hidden" name="folderpath" value="$path" />
|
|
<input type="hidden" name="importdetail"
|
my $newsmpproblemform=(<<NSPROBFORM); |
value="$plainname=/adm/$udom/$uname/aboutme" />
|
<form action="/adm/coursedocs" method="post" name="newsmpproblem"> |
<span class="LC_nobreak">
|
<input type="hidden" name="active" value="cc" /> |
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
$uploadtag |
$help{'My Personal Info'}
|
<input type="hidden" name="importdetail" value="" /> |
</span>
|
<a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a> |
</form>
|
$help{'Simple Problem'} |
SNAMFORM
|
</form> |
|
|
$r->print(<<ENDSUPFORM);
|
NSPROBFORM |
<ul class="LC_TabContent">
|
|
<li>$lt{'nd'}</li>
|
my $newdropboxform=(<<NDBFORM); |
<li>$lt{'sd'}</li>
|
<form action="/adm/coursedocs" method="post" name="newdropbox"> |
<li>$lt{'hao'}</li>
|
<input type="hidden" name="active" value="cc" /> |
</ul>
|
$uploadtag |
<table class="LC_docs_adddocs">
|
<input type="hidden" name="importdetail" value="" /> |
<tr><td>
|
<a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a> |
$supupdocform
|
</form> |
</td>
|
NDBFORM |
<td>
|
|
$supnewfolderform
|
my $newexuploadform=(<<NEXUFORM); |
<br />
|
<form action="/adm/coursedocs" method="post" name="newexamupload"> |
$supnewextform
|
<input type="hidden" name="active" value="cc" /> |
<br />
|
$uploadtag |
$supnewsylform
|
<input type="hidden" name="importdetail" value="" /> |
<br />
|
<a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a> |
$supnewaboutmeform
|
$help{'Score_Upload_Form'} |
</td></tr>
|
</form> |
</table></td></tr>
|
NEXUFORM |
ENDSUPFORM
|
|
}
|
my $newbulform=(<<NBFORM); |
}
|
<form action="/adm/coursedocs" method="post" name="newbul"> |
$r->print('</table>');
|
<input type="hidden" name="active" value="cc" /> |
if ($allowed) {
|
$uploadtag |
$r->print('
|
<input type="hidden" name="importdetail" value="" /> |
<form method="post" name="extimport" action="/adm/coursedocs">
|
<a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a> |
<input type="hidden" name="title" />
|
$help{'Bulletin Board'} |
<input type="hidden" name="url" />
|
</form> |
<input type="hidden" name="useform" />
|
NBFORM |
<input type="hidden" name="residx" />
|
|
</form>');
|
my $newaboutmeform=(<<NAMFORM); |
}
|
<form action="/adm/coursedocs" method="post" name="newaboutme"> |
} else {
|
<input type="hidden" name="active" value="cc" /> |
unless ($upload_result eq 'phasetwo') {
|
$uploadtag |
# -------------------------------------------------------- This is showdoc mode
|
<input type="hidden" name="importdetail" |
$r->print("<h1>".&mt('Uploaded Document').' - '.
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
&Apache::lonnet::gettitle($r->uri).'</h1><p>'.
|
<a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a> |
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
|
$help{'My Personal Information Page'} |
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
|
</form> |
}
|
NAMFORM |
}
|
|
}
|
my $newaboutsomeoneform=(<<NASOFORM); |
$r->print(&Apache::loncommon::end_page());
|
<form action="/adm/coursedocs" method="post" name="newaboutsomeone"> |
return OK;
|
<input type="hidden" name="active" value="cc" /> |
}
|
$uploadtag |
|
<input type="hidden" name="importdetail" value="" /> |
sub generate_admin_options {
|
<a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a> |
my ($containertag,$uploadtag,$lt_ref,$help_ref,$env_ref) = @_;
|
</form> |
my %lt = %{$lt_ref};
|
NASOFORM |
my %help = %{$help_ref};
|
|
my %env = %{$env_ref};
|
|
my $dumpbut=&dumpbutton();
|
my $newrosterform=(<<NROSTFORM); |
my $exportbut=&exportbutton();
|
<form action="/adm/coursedocs" method="post" name="newroster"> |
return (<<ENDOPTIONFORM);
|
<input type="hidden" name="active" value="cc" /> |
<form name="renameform" method="post" action="/adm/coursedocs">
|
$uploadtag |
<input type="hidden" name="title" />
|
<input type="hidden" name="importdetail" |
<input type="hidden" name="cmd" />
|
value="$lt{'rost'}=/adm/viewclasslist" /> |
<input type="hidden" name="markcopy" />
|
<a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a> |
<input type="hidden" name="copyfolder" />
|
$help{'Course Roster'} |
$containertag
|
</form> |
</form>
|
NROSTFORM |
<form name="simpleedit" method="post" action="/adm/coursedocs">
|
|
<input type="hidden" name="importdetail" value="" />
|
my $specialdocumentsform; |
$uploadtag
|
my @specialdocumentsforma; |
</form>
|
my $gradingform; |
<form action="/adm/coursedocs" method="post" name="courseverify">
|
my @gradingforma; |
<ul style="list-style-type:none">
|
my $communityform; |
<li>
|
my @communityforma; |
<input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
|
my $newfolderform; |
</li>
|
my $newfolderb; |
<li>
|
|
<input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
</li>
|
|
<li>
|
my $newpageform=(<<NPFORM); |
$dumpbut
|
<form action="/adm/coursedocs" method="post" name="newpage"> |
</li>
|
<input type="hidden" name="folderpath" value="$path" /> |
<li>
|
<input type="hidden" name="importdetail" value="" /> |
$exportbut
|
<input type="hidden" name="active" value="cc" /> |
</li>
|
<a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a> |
<li>
|
$help{'Adding_Pages'} |
<input type="submit" name="listsymbs" value="$lt{'ls'}" />
|
</form> |
</li>
|
NPFORM |
<li>
|
|
<input type="hidden" name="folder" value="$env{'form.folder'}" />
|
|
<input type="submit" name="docslog" value="$lt{'sl'}" />
|
$newfolderform=(<<NFFORM); |
</li>
|
<form action="/adm/coursedocs" method="post" name="newfolder"> |
</ul>
|
<input type="hidden" name="folderpath" value="$path" /> |
</form>
|
<input type="hidden" name="importdetail" value="" /> |
<div style="clear: both; height: 0px;"> </div>
|
<input type="hidden" name="active" value="aa" /> |
ENDOPTIONFORM
|
<a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'} |
}
|
</form> |
|
NFFORM |
sub generate_edit_table {
|
|
my ($optionhash_ref,$namehash_ref,$orderhash_ref) = @_;
|
my $newsylform=(<<NSYLFORM); |
my %optionhash = %{$optionhash_ref}; #id verlinkt mit inhalt
|
<form action="/adm/coursedocs" method="post" name="newsyl"> |
my %namehash = %{$namehash_ref}; #name verlinkt mit id
|
<input type="hidden" name="active" value="cc" /> |
my %orderhash = %{$orderhash_ref}; #name mit kürzel verlinkt mit name
|
$uploadtag |
my $form;
|
<input type="hidden" name="importdetail" |
$form = '<div class="LC_ContentBoxSpecial"><h4 class="LC_hcell">'.&mt('Upload Course Documents').'<h4>';
|
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" /> |
$form .= '<ul class="LC_TabContent">';
|
<a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a> |
foreach my $name (sort(keys(%orderhash))){
|
$help{'Syllabus'} |
if($name eq 'zz_hide'){
|
|
$form .= '<li><a onclick="hideAllSection();" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
</form> |
}else{
|
NSYLFORM |
$form .= '<li><a onclick="popUpSection(\''.$namehash{$orderhash{$name}}.'\');" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
|
}
|
my $newgroupfileform=(<<NGFFORM); |
}
|
<form action="/adm/coursedocs" method="post" name="newgroupfiles"> |
foreach my $field (keys(%optionhash)){
|
<input type="hidden" name="active" value="cc" /> |
$form .= '<div id="'.$field.'" class="LC_ContentBox LC_hideThis">'.$optionhash{$field}.'</div>';
|
$uploadtag |
}
|
<input type="hidden" name="importdetail" |
$form .= '</div>';
|
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" /> |
return $form;
|
<a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a> |
}
|
$help{'Group Portfolio'} |
|
</form> |
sub editing_js {
|
NGFFORM |
my ($udom,$uname) = @_;
|
@specialdocumentsforma=( |
my $now = time();
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform}, |
my %lt = &Apache::lonlocal::texthash(
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform}, |
p_mnf => 'Name of New Folder',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform}, |
t_mnf => 'New Folder',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform}, |
p_mnp => 'Name of New Page',
|
); |
t_mnp => 'New Page',
|
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma)); |
p_mxu => 'Title for the Uploaded Score',
|
|
p_msp => 'Title for the Page',
|
|
p_msb => 'Title for the Problem',
|
my @importdoc = ( |
p_mdb => 'Title for the Drop Box',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform}, |
p_mbb => 'Title for the Bulletin Board',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},); |
p_mab => "Enter user:domain for User's 'About Me' Page",
|
$fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr/>' . $fileuploadform; |
p_mab2 => "About [_99]",
|
|
p_mab_alrt1 => 'Not a valid user:domain',
|
@gradingforma=( |
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
p_chn => 'New Title',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform}, |
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform}, |
p_rmr2a => 'Remove[_99]',
|
|
p_rmr2b => '?[_99]',
|
); |
p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
|
$gradingform = &create_form_ul(&create_list_elements(@gradingforma)); |
p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
|
|
p_ctr2a => 'Cut[_98]',
|
@communityforma=( |
p_ctr2b => '?[_98]'
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform}, |
);
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform}, |
return <<ENDNEWSCRIPT;
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform}, |
function makenewfolder(targetform,folderseq) {
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform}, |
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
|
); |
if (foldername) {
|
$communityform = &create_form_ul(&create_list_elements(@communityforma)); |
targetform.importdetail.value=escape(foldername)+"="+folderseq;
|
|
targetform.submit();
|
|
}
|
|
}
|
my @tools = ( |
|
# {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" />'=>$extresourcesform}, |
function makenewpage(targetform,folderseq) {
|
# {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" />'=>$imspform}, |
var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/recover.png" alt="'.$lt{reco}.'" onclick="javascript:groupopen(\''.$readfile.'\',1)" />'=>$recoverform}, |
if (pagename) {
|
); |
targetform.importdetail.value=escape(pagename)+"="+folderseq;
|
|
targetform.submit();
|
my %orderhash = ( |
}
|
'aa' => ['Import Documents',$fileuploadform], |
}
|
'bb' => ['Published Resources',$simpleeditdefaultform], |
|
'cc' => ['Grading Resources',$gradingform], |
function makenewext(targetname) {
|
'ff' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)], |
this.document.forms.extimport.useform.value=targetname;
|
); |
this.document.forms.extimport.title.value='';
|
unless ($env{'form.pagepath'}) { |
this.document.forms.extimport.url.value='';
|
$orderhash{'00'} = ['Newfolder',$newfolderform]; |
this.document.forms.extimport.residx.value='';
|
$orderhash{'dd'} = ['Community Resources',$communityform]; |
window.open('/adm/rat/extpickframe.html');
|
$orderhash{'ee'} = ['Special Documents',$specialdocumentsform]; |
}
|
} |
|
|
function edittext(targetname,residx,title,url) {
|
$hadchanges=0; |
this.document.forms.extimport.useform.value=targetname;
|
unless ($supplementalflag) { |
this.document.forms.extimport.residx.value=residx;
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
this.document.forms.extimport.url.value=url;
|
$supplementalflag,\%orderhash); |
this.document.forms.extimport.title.value=title;
|
if ($error) { |
window.open('/adm/rat/extpickframe.html');
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
}
|
} |
|
if ($hadchanges) { |
function makeexamupload() {
|
&mark_hash_old(); |
var title=prompt('$lt{"p_mxu"}');
|
} |
if (title) {
|
|
this.document.forms.newexamupload.importdetail.value=
|
&changewarning($r,''); |
escape(title)+'=/res/lib/templates/examupload.problem';
|
} |
this.document.forms.newexamupload.submit();
|
} |
}
|
|
}
|
# Supplemental documents start here |
|
|
function makesmppage() {
|
my $folder=$env{'form.folder'}; |
var title=prompt('$lt{"p_msp"}');
|
unless ($supplementalflag) { |
if (title) {
|
$folder='supplemental'; |
this.document.forms.newsmppg.importdetail.value=
|
} |
escape(title)+'=/adm/$udom/$uname/$now/smppg';
|
if ($folder =~ /^supplemental$/ && |
this.document.forms.newsmppg.submit();
|
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) { |
}
|
$env{'form.folderpath'} = &supplemental_base(); |
}
|
} elsif ($allowed) { |
|
$env{'form.folderpath'} = $savefolderpath; |
function makesmpproblem() {
|
} |
var title=prompt('$lt{"p_msb"}');
|
$env{'form.pagepath'} = ''; |
if (title) {
|
if ($allowed) { |
this.document.forms.newsmpproblem.importdetail.value=
|
my $folderseq= |
escape(title)+'=/res/lib/templates/simpleproblem.problem';
|
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. |
this.document.forms.newsmpproblem.submit();
|
'.sequence'; |
}
|
|
}
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
|
|
function makedropbox() {
|
my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}"; |
var title=prompt('$lt{"p_mdb"}');
|
my $supupdocform=(<<SUPDOCFORM); |
if (title) {
|
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> |
this.document.forms.newdropbox.importdetail.value=
|
<input type="hidden" name="active" value="ee" /> |
escape(title)+'=/res/lib/templates/DropBox.problem';
|
$fileupload |
this.document.forms.newdropbox.submit();
|
<br /> |
}
|
<br /> |
}
|
<span class="LC_nobreak"> |
|
$checkbox |
function makebulboard() {
|
</span> |
var title=prompt('$lt{"p_mbb"}');
|
<br /><br /> |
if (title) {
|
$lt{'comment'}:<br /> |
this.document.forms.newbul.importdetail.value=
|
<textarea cols="50" rows="4" name="comment"></textarea> |
escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
|
<br /> |
this.document.forms.newbul.submit();
|
<input type="hidden" name="folderpath" value="$path" /> |
}
|
<input type="hidden" name="cmd" value="upload_supplemental" /> |
}
|
SUPDOCFORM |
|
$supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>"; |
function makeabout() {
|
|
var user=prompt("$lt{'p_mab'}");
|
my $supnewfolderform=(<<SNFFORM); |
if (user) {
|
<form action="/adm/coursedocs" method="post" name="supnewfolder"> |
var comp=new Array();
|
<input type="hidden" name="active" value="ee" /> |
comp=user.split(':');
|
<input type="hidden" name="folderpath" value="$path" /> |
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
|
<input type="hidden" name="importdetail" value="" /> |
if ((comp[0]) && (comp[1])) {
|
<a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> |
this.document.forms.newaboutsomeone.importdetail.value=
|
$help{'Adding_Folders'} |
'$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
|
</form> |
this.document.forms.newaboutsomeone.submit();
|
SNFFORM |
} else {
|
|
alert("$lt{'p_mab_alrt1'}");
|
|
}
|
my $supnewextform=(<<SNEFORM); |
} else {
|
<form action="/adm/coursedocs" method="post" name="supnewext"> |
alert("$lt{'p_mab_alrt2'}");
|
<input type="hidden" name="active" value="ff" /> |
}
|
<input type="hidden" name="folderpath" value="$path" /> |
}
|
<input type="hidden" name="importdetail" value="" /> |
}
|
<a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'} |
|
</form> |
function makeims() {
|
SNEFORM |
var caller = document.forms.ims.folder.value;
|
|
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
|
my $supnewsylform=(<<SNSFORM); |
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
|
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
newWindow.location.href = newlocation;
|
<input type="hidden" name="active" value="ff" /> |
}
|
<input type="hidden" name="folderpath" value="$path" /> |
|
<input type="hidden" name="importdetail" |
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus" /> |
function finishpick() {
|
<a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a> |
var title=this.document.forms.extimport.title.value;
|
$help{'Syllabus'} |
var url=this.document.forms.extimport.url.value;
|
</form> |
var form=this.document.forms.extimport.useform.value;
|
SNSFORM |
var residx=this.document.forms.extimport.residx.value;
|
|
eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
|
my $supnewaboutmeform=(<<SNAMFORM); |
}
|
<form action="/adm/coursedocs" method="post" name="supnewaboutme"> |
|
<input type="hidden" name="active" value="ff" /> |
function changename(folderpath,index,oldtitle,container,pagesymb) {
|
<input type="hidden" name="folderpath" value="$path" /> |
var title=prompt('$lt{"p_chn"}',oldtitle);
|
<input type="hidden" name="importdetail" |
if (title) {
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
this.document.forms.renameform.markcopy.value=-1;
|
<a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a> |
this.document.forms.renameform.title.value=title;
|
$help{'My Personal Information Page'} |
this.document.forms.renameform.cmd.value='rename_'+index;
|
</form> |
if (container == 'sequence') {
|
SNAMFORM |
this.document.forms.renameform.folderpath.value=folderpath;
|
|
}
|
|
if (container == 'page') {
|
my @specialdocs = ( |
this.document.forms.renameform.pagepath.value=folderpath;
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />' |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
=>$supnewsylform}, |
}
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />' |
this.document.forms.renameform.submit();
|
=>$supnewaboutmeform}, |
}
|
); |
}
|
my @supimportdoc = ( |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />' |
function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
|
=>$supnewextform}, |
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
|
); |
this.document.forms.renameform.markcopy.value=-1;
|
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr/>' . $supupdocform; |
this.document.forms.renameform.cmd.value='del_'+index;
|
my %suporderhash = ( |
if (container == 'sequence') {
|
'00' => ['Supnewfolder', $supnewfolderform], |
this.document.forms.renameform.folderpath.value=folderpath;
|
'ee' => ['Import Documents',$supupdocform], |
}
|
'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))] |
if (container == 'page') {
|
); |
this.document.forms.renameform.pagepath.value=folderpath;
|
if ($supplementalflag) { |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
}
|
$supplementalflag,\%suporderhash); |
this.document.forms.renameform.submit();
|
if ($error) { |
}
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
}
|
} |
|
} |
function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
|
} elsif ($supplementalflag) { |
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
this.document.forms.renameform.cmd.value='cut_'+index;
|
$supplementalflag); |
this.document.forms.renameform.markcopy.value=index;
|
if ($error) { |
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
if (container == 'sequence') {
|
} |
this.document.forms.renameform.folderpath.value=folderpath;
|
} |
}
|
|
if (container == 'page') {
|
&endContentScreen($r); |
this.document.forms.renameform.pagepath.value=folderpath;
|
|
this.document.forms.renameform.pagesymb.value=pagesymb;
|
if ($allowed) { |
}
|
$r->print(' |
this.document.forms.renameform.submit();
|
<form method="post" name="extimport" action="/adm/coursedocs"> |
}
|
<input type="hidden" name="title" /> |
}
|
<input type="hidden" name="url" /> |
|
<input type="hidden" name="useform" /> |
function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
|
<input type="hidden" name="residx" /> |
this.document.forms.renameform.markcopy.value=index;
|
</form>'); |
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
} |
if (container == 'sequence') {
|
} else { |
this.document.forms.renameform.folderpath.value=folderpath;
|
unless ($uploadphase) { |
}
|
# -------------------------------------------------------- This is showdoc mode |
if (container == 'page') {
|
$r->print("<h1>".&mt('Uploaded Document').' - '. |
this.document.forms.renameform.pagepath.value=folderpath;
|
&Apache::lonnet::gettitle($r->uri).'</h1><p>'. |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
&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>'); |
this.document.forms.renameform.submit();
|
} |
}
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
ENDNEWSCRIPT
|
return OK; |
}
|
} |
1;
|
|
__END__
|
sub embedded_form_elems { |
|
my ($phase,$primaryurl,$newidx) = @_; |
|
my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
=head1 NAME
|
return <<STATE; |
|
<input type="hidden" name="folderpath" value="$folderpath" /> |
Apache::londocs.pm
|
<input type="hidden" name="cmd" value="upload_embedded" /> |
|
<input type="hidden" name="newidx" value="$newidx" /> |
=head1 SYNOPSIS
|
<input type="hidden" name="phase" value="$phase" /> |
|
<input type="hidden" name="primaryurl" value="$primaryurl" /> |
This is part of the LearningOnline Network with CAPA project
|
STATE |
described at http://www.lon-capa.org.
|
} |
|
|
=head1 SUBROUTINES
|
sub embedded_destination { |
|
my $folder=$env{'form.folder'}; |
=over
|
my $destination = 'docs/'; |
|
if ($folder =~ /^supplemental/) { |
=item %help=()
|
$destination = 'supplemental/'; |
|
} |
Available help topics
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
|
$destination .= 'default/'; |
=item mapread()
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
|
$destination .= $2.'/'; |
Mapread read maps into LONCAPA::map:: global arrays
|
} |
@order and @resources, determines status
|
$destination .= $env{'form.newidx'}; |
sets @order - pointer to resources in right order
|
my $dir_root = '/userfiles'; |
sets @resources - array with the resources with correct idx
|
return ($destination,$dir_root); |
|
} |
=item authorhosts()
|
|
|
sub return_to_editor { |
Return hash with valid author names
|
my $actionurl = '/adm/coursedocs'; |
|
return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n". |
=item dumpbutton()
|
'<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n". |
|
'<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor'). |
Generate "dump" button
|
'</a></p>'; |
|
} |
=item clean()
|
|
|
sub generate_admin_options { |
=item dumpcourse()
|
my ($help_ref,$env_ref) = @_; |
|
my %lt=&Apache::lonlocal::texthash( |
Actually dump course
|
'vc' => 'Verify Content', |
|
'cv' => 'Check/Set Resource Versions', |
|
'ls' => 'List Symbs', |
=item exportbutton()
|
'sl' => 'Show Log', |
|
'imse' => 'IMS Export', |
Generate "export" button
|
'dcd' => 'Dump Course Documents to Construction Space: available on other servers' |
|
); |
=item exportcourse()
|
my %help = %{$help_ref}; |
|
my %env = %{$env_ref}; |
=item create_ims_store()
|
my $dumpbut=&dumpbutton(); |
|
my $exportbut=&exportbutton(); |
=item build_package()
|
my @list = ( |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/verify.png" alt="'.$lt{vc}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "verify", "'.$lt{'vc'}.'")\' />' |
=item get_dependencies()
|
=> "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"verify\", \"$lt{'vc'}\")'>$lt{'vc'}</a>$help{'Verify_Content'}"}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/resversion.png" alt="'.$lt{cv}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "versions", "'.$lt{'cv'}.'")\' />' |
=item process_content()
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"versions\", \"$lt{'cv'}\")'>$lt{'cv'}</a>$help{'Check_Resource_Versions'}"}, |
|
); |
=item replicate_content()
|
if($dumpbut ne ''){ |
|
push @list, {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dump.png" alt="'.$lt{dcd}.'" />'=>$dumpbut}; |
=item extract_media()
|
} |
|
push @list, ({'<img class="LC_noBorder LC_middle" src="/res/adm/pages/imsexport.png" alt="'.$lt{imse}.'" onclick="javascript:injectData(document.courseverify, \'dummy\', \'exportcourse\', \''.&mt('IMS Export').'\');" />' |
=item store_template()
|
=>$exportbut}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/symbs.png" alt="'.$lt{ls}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "listsymbs", "'.$lt{'ls'}.'")\' />' |
=item group_import()
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"listsymbs\", \"$lt{'ls'}\")'>$lt{'ls'}</a><input type='hidden' name='folder' value='$env{'form.folder'}' />"}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/document-properties.png" alt="'.$lt{sl}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "docslog", "'.$lt{'sl'}.'")\' />' |
Imports the given (name, url) resources into the course
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"docslog\", \"$lt{'sl'}\")'>$lt{'sl'}</a>"}, |
coursenum, coursedom, and folder must precede the list
|
); |
|
return '<form action="/adm/coursedocs" method="post" name="courseverify"><input type="hidden" id="dummy" />'.&create_form_ul(&create_list_elements(@list)).'</form>'; |
=item breadcrumbs()
|
|
|
} |
=item log_docs()
|
|
|
|
=item docs_change_log()
|
sub generate_edit_table { |
|
my ($tid,$orderhash_ref,$to_show) = @_; |
=item update_paste_buffer()
|
return unless(ref($orderhash_ref) eq 'HASH'); |
|
my %orderhash = %{$orderhash_ref}; |
=item print_paste_buffer()
|
my $form; |
|
my $activetab; |
=item do_paste_from_buffer()
|
my $active; |
|
if($env{'form.active'} ne ''){ |
=item update_parameter()
|
$activetab = $env{'form.active'}; |
|
} |
=item handle_edit_cmd()
|
$form = '<div class="LC_Box" style="margin:0;">'. |
|
'<ul id="navigation'.$tid.'" class="LC_TabContent">'; |
=item editor()
|
foreach my $name (reverse(sort(keys(%orderhash)))) { |
|
if($name ne '00'){ |
=item process_file_upload()
|
if($activetab eq '' || $activetab ne $name){ |
|
$active = ''; |
=item process_secondary_uploads()
|
}elsif($activetab eq $name){ |
|
$active = 'class="active"'; |
=item is_supplemental_title()
|
} |
|
$form .= '<li style="float:right" '.$active |
=item parse_supplemental_title()
|
.' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"' |
|
.' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'; |
=item entryline()
|
} else { |
|
$form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'; |
=item tiehash()
|
|
|
} |
=item untiehash()
|
} |
|
$form .= '</ul>'; |
=item checkonthis()
|
$form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'; |
|
|
check on this
|
if ($to_show ne '') { |
|
$form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'; |
=item verifycontent()
|
} |
|
foreach my $field (keys(%orderhash)){ |
Verify Content
|
if($field ne '00'){ |
|
if($activetab eq '' || $activetab ne $field){ |
=item devalidateversioncache() & checkversions()
|
$active = 'style="display: none;float:left"'; |
|
}elsif($activetab eq $field){ |
Check Versions
|
$active = 'style="display:block;float:left"'; |
|
} |
=item mark_hash_old()
|
$form .= '<div id="'.$field.$tid.'"' |
|
.' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1] |
=item is_hash_old()
|
.'</div>'; |
|
} |
=item changewarning()
|
} |
|
$form .= '</div></div>'; |
=item init_breadcrumbs()
|
|
|
return $form; |
Breadcrumbs for special functions
|
} |
|
|
=back
|
sub editing_js { |
|
my ($udom,$uname) = @_; |
=cut
|
my $now = time(); |
|
my %lt = &Apache::lonlocal::texthash( |
|
p_mnf => 'Name of New Folder', |
|
t_mnf => 'New Folder', |
|
p_mnp => 'Name of New Page', |
|
t_mnp => 'New Page', |
|
p_mxu => 'Title for the External Score', |
|
p_msp => 'Name of Simple Course Page', |
|
p_msb => 'Title for the Problem', |
|
p_mdb => 'Title for the Drop Box', |
|
p_mbb => 'Title for the Discussion Board', |
|
p_mab => "Enter user:domain for User's Personal Information Page", |
|
p_mab2 => 'Personal Information Page of ', |
|
p_mab_alrt1 => 'Not a valid user:domain', |
|
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain', |
|
p_chn => 'New Title', |
|
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!', |
|
p_rmr2a => 'Remove[_99]', |
|
p_rmr2b => '?[_99]', |
|
p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!', |
|
p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.', |
|
p_ctr2a => 'Cut[_98]', |
|
p_ctr2b => '?[_98]' |
|
); |
|
|
|
my $crstype = &Apache::loncommon::course_type(); |
|
my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"'); |
|
my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"'); |
|
my $main_container_page; |
|
if ($docs_folderpath eq '') { |
|
if ($docs_pagepath ne '') { |
|
$main_container_page = 1; |
|
} |
|
} |
|
my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents'; |
|
my $toplevelsupp = &supplemental_base(); |
|
|
|
return <<ENDNEWSCRIPT; |
|
function makenewfolder(targetform,folderseq) { |
|
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}'); |
|
if (foldername) { |
|
targetform.importdetail.value=escape(foldername)+"="+folderseq; |
|
targetform.submit(); |
|
} |
|
} |
|
|
|
function makenewpage(targetform,folderseq) { |
|
var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}'); |
|
if (pagename) { |
|
targetform.importdetail.value=escape(pagename)+"="+folderseq; |
|
targetform.submit(); |
|
} |
|
} |
|
|
|
function makenewext(targetname) { |
|
this.document.forms.extimport.useform.value=targetname; |
|
this.document.forms.extimport.title.value=''; |
|
this.document.forms.extimport.url.value=''; |
|
this.document.forms.extimport.residx.value=''; |
|
window.open('/adm/rat/extpickframe.html'); |
|
} |
|
|
|
function edittext(targetname,residx,title,url) { |
|
this.document.forms.extimport.useform.value=targetname; |
|
this.document.forms.extimport.residx.value=residx; |
|
this.document.forms.extimport.url.value=url; |
|
this.document.forms.extimport.title.value=title; |
|
window.open('/adm/rat/extpickframe.html'); |
|
} |
|
|
|
function makeexamupload() { |
|
var title=prompt('$lt{"p_mxu"}'); |
|
if (title) { |
|
this.document.forms.newexamupload.importdetail.value= |
|
escape(title)+'=/res/lib/templates/examupload.problem'; |
|
this.document.forms.newexamupload.submit(); |
|
} |
|
} |
|
|
|
function makesmppage() { |
|
var title=prompt('$lt{"p_msp"}'); |
|
if (title) { |
|
this.document.forms.newsmppg.importdetail.value= |
|
escape(title)+'=/adm/$udom/$uname/$now/smppg'; |
|
this.document.forms.newsmppg.submit(); |
|
} |
|
} |
|
|
|
function makesmpproblem() { |
|
var title=prompt('$lt{"p_msb"}'); |
|
if (title) { |
|
this.document.forms.newsmpproblem.importdetail.value= |
|
escape(title)+'=/res/lib/templates/simpleproblem.problem'; |
|
this.document.forms.newsmpproblem.submit(); |
|
} |
|
} |
|
|
|
function makedropbox() { |
|
var title=prompt('$lt{"p_mdb"}'); |
|
if (title) { |
|
this.document.forms.newdropbox.importdetail.value= |
|
escape(title)+'=/res/lib/templates/DropBox.problem'; |
|
this.document.forms.newdropbox.submit(); |
|
} |
|
} |
|
|
|
function makebulboard() { |
|
var title=prompt('$lt{"p_mbb"}'); |
|
if (title) { |
|
this.document.forms.newbul.importdetail.value= |
|
escape(title)+'=/adm/$udom/$uname/$now/bulletinboard'; |
|
this.document.forms.newbul.submit(); |
|
} |
|
} |
|
|
|
function makeabout() { |
|
var user=prompt("$lt{'p_mab'}"); |
|
if (user) { |
|
var comp=new Array(); |
|
comp=user.split(':'); |
|
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { |
|
if ((comp[0]) && (comp[1])) { |
|
this.document.forms.newaboutsomeone.importdetail.value= |
|
'$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; |
|
this.document.forms.newaboutsomeone.submit(); |
|
} else { |
|
alert("$lt{'p_mab_alrt1'}"); |
|
} |
|
} else { |
|
alert("$lt{'p_mab_alrt2'}"); |
|
} |
|
} |
|
} |
|
|
|
function makeims() { |
|
var caller = document.forms.ims.folder.value; |
|
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"; |
|
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes"); |
|
newWindow.location.href = newlocation; |
|
} |
|
|
|
|
|
function finishpick() { |
|
var title=this.document.forms.extimport.title.value; |
|
var url=this.document.forms.extimport.url.value; |
|
var form=this.document.forms.extimport.useform.value; |
|
var residx=this.document.forms.extimport.residx.value; |
|
eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();'); |
|
} |
|
|
|
function changename(folderpath,index,oldtitle,container,pagesymb) { |
|
var title=prompt('$lt{"p_chn"}',oldtitle); |
|
if (title) { |
|
this.document.forms.renameform.markcopy.value=-1; |
|
this.document.forms.renameform.title.value=title; |
|
this.document.forms.renameform.cmd.value='rename_'+index; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) { |
|
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) { |
|
this.document.forms.renameform.markcopy.value=-1; |
|
this.document.forms.renameform.cmd.value='del_'+index; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) { |
|
if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) { |
|
this.document.forms.renameform.cmd.value='cut_'+index; |
|
this.document.forms.renameform.markcopy.value=index; |
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
} |
|
|
|
function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) { |
|
this.document.forms.renameform.markcopy.value=index; |
|
this.document.forms.renameform.copyfolder.value=folder+'.'+container; |
|
if (container == 'sequence') { |
|
this.document.forms.renameform.folderpath.value=folderpath; |
|
} |
|
if (container == 'page') { |
|
this.document.forms.renameform.pagepath.value=folderpath; |
|
this.document.forms.renameform.pagesymb.value=pagesymb; |
|
} |
|
this.document.forms.renameform.submit(); |
|
} |
|
|
|
function unselectInactive(nav) { |
|
currentNav = document.getElementById(nav); |
|
currentLis = currentNav.getElementsByTagName('LI'); |
|
for (i = 0; i < currentLis.length; i++) { |
|
if(currentLis[i].className == 'right active' || currentLis[i].className == 'right'){ |
|
currentLis[i].className = 'right'; |
|
}else{ |
|
currentLis[i].className = 'i'; |
|
} |
|
} |
|
} |
|
|
|
function hideAll(current, nav, data) { |
|
unselectInactive(nav); |
|
if(current.className == 'right'){ |
|
current.className = 'right active' |
|
}else{ |
|
current.className = 'active'; |
|
} |
|
currentData = document.getElementById(data); |
|
currentDivs = currentData.getElementsByTagName('DIV'); |
|
for (i = 0; i < currentDivs.length; i++) { |
|
if(currentDivs[i].className == 'LC_ContentBox'){ |
|
currentDivs[i].style.display = 'none'; |
|
} |
|
} |
|
} |
|
|
|
function openTabs(pageId) { |
|
tabnav = document.getElementById(pageId).getElementsByTagName('UL'); |
|
if(tabnav.length > 2 ){ |
|
currentNav = document.getElementById(tabnav[1].id); |
|
currentLis = currentNav.getElementsByTagName('LI'); |
|
for(i = 0; i< currentLis.length; i++){ |
|
if(currentLis[i].className == 'active') { |
|
funcString = currentLis[i].onclick.toString(); |
|
tab = funcString.split('"'); |
|
if(tab.length < 2) { |
|
tab = funcString.split("'"); |
|
} |
|
currentData = document.getElementById(tab[1]); |
|
currentData.style.display = 'block'; |
|
} |
|
} |
|
} |
|
} |
|
|
|
function showPage(current, pageId, nav, data) { |
|
hideAll(current, nav, data); |
|
openTabs(pageId); |
|
unselectInactive(nav); |
|
current.className = 'active'; |
|
currentData = document.getElementById(pageId); |
|
currentData.style.display = 'block'; |
|
activeTab = pageId; |
|
if (nav == 'mainnav') { |
|
var storedpath = "$docs_folderpath"; |
|
if (storedpath == '') { |
|
storedpath = "$docs_pagepath"; |
|
} |
|
var storedpage = "$main_container_page"; |
|
var reg = new RegExp("^supplemental"); |
|
if (pageId == 'mainCourseDocuments') { |
|
if (storedpage == 1) { |
|
document.simpleedit.folderpath.value = ''; |
|
document.uploaddocument.folderpath.value = ''; |
|
} else { |
|
if (reg.test(storedpath)) { |
|
document.simpleedit.folderpath.value = '$toplevelmain'; |
|
document.uploaddocument.folderpath.value = '$toplevelmain'; |
|
document.newext.folderpath.value = '$toplevelmain'; |
|
} else { |
|
document.simpleedit.folderpath.value = storedpath; |
|
document.uploaddocument.folderpath.value = storedpath; |
|
document.newext.folderpath.value = storedpath; |
|
} |
|
} |
|
} else { |
|
if (reg.test(storedpath)) { |
|
document.simpleedit.folderpath.value = storedpath; |
|
document.supuploaddocument.folderpath.value = storedpath; |
|
document.supnewext.folderpath.value = storedpath; |
|
} else { |
|
document.simpleedit.folderpath.value = '$toplevelsupp'; |
|
document.supuploaddocument.folderpath.value = '$toplevelsupp'; |
|
document.supnewext.folderpath.value = '$toplevelsupp'; |
|
} |
|
} |
|
} |
|
resize_contentdiv('contentscroll','1','0'); |
|
return false; |
|
} |
|
|
|
function injectData(current, hiddenField, name, value) { |
|
currentElement = document.getElementById(hiddenField); |
|
currentElement.name = name; |
|
currentElement.value = value; |
|
current.submit(); |
|
} |
|
|
|
ENDNEWSCRIPT |
|
} |
|
|
|
sub resize_contentdiv_js { |
|
my ($tabidstr) = @_; |
|
my $viewport_js = &Apache::loncommon::viewport_geometry_js(); |
|
return <<ENDRESIZESCRIPT; |
|
|
|
window.onresize=resizeContentEditor; |
|
|
|
var activeTab; |
|
|
|
$viewport_js |
|
|
|
function resize_contentdiv(scrollboxname,chkw,chkh) { |
|
var scrollboxid = 'div_'+scrollboxname; |
|
var scrolltableid = 'table_'+scrollboxname; |
|
var scrollbox; |
|
var scrolltable; |
|
|
|
if (document.getElementById("contenteditor") == null) { |
|
return; |
|
} |
|
|
|
if (document.getElementById(scrollboxid) == null) { |
|
return; |
|
} else { |
|
scrollbox = document.getElementById(scrollboxid); |
|
} |
|
|
|
if (document.getElementById(scrolltableid) == null) { |
|
return; |
|
} else { |
|
scrolltable = document.getElementById(scrolltableid); |
|
} |
|
|
|
init_geometry(); |
|
var vph = Geometry.getViewportHeight(); |
|
var vpw = Geometry.getViewportWidth(); |
|
|
|
var alltabs = ['$tabidstr']; |
|
var listwchange; |
|
if (chkw == 1) { |
|
var contenteditorw = document.getElementById("contenteditor").offsetWidth; |
|
var contentlistw; |
|
var contentlistid = document.getElementById("contentlist"); |
|
if (contentlistid != null) { |
|
contentlistw = document.getElementById("contentlist").offsetWidth; |
|
} |
|
var contentlistwstart = contentlistw; |
|
|
|
var scrollboxw = scrollbox.offsetWidth; |
|
var scrollboxscrollw = scrollbox.scrollWidth; |
|
|
|
var offsetw = parseInt(vpw * 0.015); |
|
var paddingw = parseInt(vpw * 0.09); |
|
|
|
var minscrollboxw = 250; |
|
|
|
var maxtabw = 0; |
|
for (var i=0; i<alltabs.length; i++) { |
|
if (activeTab == alltabs[i]) { |
|
var tabw = document.getElementById(alltabs[i]).offsetWidth; |
|
if (tabw > maxtabw) { |
|
maxtabw = tabw; |
|
} |
|
} else { |
|
if (document.getElementById(alltabs[i]) != null) { |
|
var thistab = document.getElementById(alltabs[i]); |
|
thistab.style.visibility = 'hidden'; |
|
thistab.style.display = 'block'; |
|
var tabw = document.getElementById(alltabs[i]).offsetWidth; |
|
thistab.style.display = 'none'; |
|
thistab.style.visibility = ''; |
|
if (tabw > maxtabw) { |
|
maxtabw = tabw; |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (maxtabw > 0) { |
|
var newscrollboxw; |
|
if (maxtabw+paddingw+scrollboxscrollw<contenteditorw) { |
|
newscrollboxw = contenteditorw-paddingw-maxtabw; |
|
if (newscrollboxw < minscrollboxw) { |
|
newscrollboxw = minscrollboxw; |
|
} |
|
scrollbox.style.width = newscrollboxw+"px"; |
|
if (newscrollboxw != scrollboxw) { |
|
var newcontentlistw = newscrollboxw-offsetw; |
|
contentlistid.style.width = newcontentlistw+"px"; |
|
} |
|
} else { |
|
newscrollboxw = contenteditorw-paddingw-maxtabw; |
|
if (newscrollboxw < minscrollboxw) { |
|
newscrollboxw = minscrollboxw; |
|
} |
|
scrollbox.style.width = newscrollboxw+"px"; |
|
if (newscrollboxw != scrollboxw) { |
|
var newcontentlistw = newscrollboxw-offsetw; |
|
contentlistid.style.width = newcontentlistw+"px"; |
|
} |
|
} |
|
|
|
if (newscrollboxw != scrollboxw) { |
|
var newscrolltablew = newscrollboxw+offsetw; |
|
scrolltable.style.width = newscrolltablew+"px"; |
|
} |
|
} |
|
|
|
if (contentlistid.offsetWidth != contentlistwstart) { |
|
listwchange = 1; |
|
} |
|
|
|
} |
|
if ((chkh == 1) || (listwchange)) { |
|
var primaryheight = document.getElementById("LC_nav_bar").offsetHeight; |
|
var secondaryheight = document.getElementById("LC_secondary_menu").offsetHeight; |
|
var crumbsheight = document.getElementById("LC_breadcrumbs").offsetHeight; |
|
var dccidheight = document.getElementById("dccid").offsetHeight; |
|
|
|
var uploadresultheight = 0; |
|
if (document.getElementById("uploadfileresult") != null) { |
|
uploadresultheight = document.getElementById("uploadfileresult").offsetHeight; |
|
} |
|
var tabbedheight = document.getElementById("tabbededitor").offsetHeight; |
|
var contenteditorheight = document.getElementById("contenteditor").offsetHeight; |
|
var scrollboxheight = scrollbox.offsetHeight; |
|
var scrollboxscrollheight = scrollbox.scrollHeight; |
|
var freevspace = vph-(primaryheight+secondaryheight+crumbsheight+dccidheight+uploadresultheight+tabbedheight+contenteditorheight); |
|
|
|
var minvscrollbox = 200; |
|
var offsetv = 20; |
|
var newscrollboxheight; |
|
if (freevspace < 0) { |
|
newscrollboxheight = scrollboxheight+freevspace-offsetv; |
|
if (newscrollboxheight < minvscrollbox) { |
|
newscrollboxheight = minvscrollbox; |
|
} |
|
scrollbox.style.height = newscrollboxheight + "px"; |
|
} else { |
|
if (scrollboxscrollheight > scrollboxheight) { |
|
if (freevspace > offsetv) { |
|
newscrollboxheight = scrollboxheight+freevspace-offsetv; |
|
if (newscrollboxheight < minvscrollbox) { |
|
newscrollboxheight = minvscrollbox; |
|
} |
|
scrollbox.style.height = newscrollboxheight+"px"; |
|
} |
|
} |
|
} |
|
scrollboxheight = scrollbox.offsetHeight; |
|
var contentlistheight = document.getElementById("contentlist").offsetHeight; |
|
|
|
if (scrollboxscrollheight <= scrollboxheight) { |
|
if ((contentlistheight+offsetv)<scrollboxheight) { |
|
newscrollheight = contentlistheight+offsetv; |
|
scrollbox.style.height = newscrollheight+"px"; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function resizeContentEditor() { |
|
var timer; |
|
clearTimeout(timer) |
|
timer=setTimeout('resize_contentdiv("contentscroll","1","1")',500); |
|
} |
|
|
|
ENDRESIZESCRIPT |
|
return; |
|
} |
|
|
|
1; |
|
__END__ |
|
|
|
|
|
=head1 NAME |
|
|
|
Apache::londocs.pm |
|
|
|
=head1 SYNOPSIS |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 SUBROUTINES |
|
|
|
=over |
|
|
|
=item %help=() |
|
|
|
Available help topics |
|
|
|
=item mapread() |
|
|
|
Mapread read maps into LONCAPA::map:: global arrays |
|
@order and @resources, determines status |
|
sets @order - pointer to resources in right order |
|
sets @resources - array with the resources with correct idx |
|
|
|
=item authorhosts() |
|
|
|
Return hash with valid author names |
|
|
|
=item dumpbutton() |
|
|
|
Generate "dump" button |
|
|
|
=item clean() |
|
|
|
=item dumpcourse() |
|
|
|
Actually dump course |
|
|
|
|
|
=item exportbutton() |
|
|
|
Generate "export" button |
|
|
|
=item exportcourse() |
|
|
|
=item create_ims_store() |
|
|
|
=item build_package() |
|
|
|
=item get_dependencies() |
|
|
|
=item process_content() |
|
|
|
=item replicate_content() |
|
|
|
=item extract_media() |
|
|
|
=item store_template() |
|
|
|
=item group_import() |
|
|
|
Imports the given (name, url) resources into the course |
|
coursenum, coursedom, and folder must precede the list |
|
|
|
=item breadcrumbs() |
|
|
|
=item log_docs() |
|
|
|
=item docs_change_log() |
|
|
|
=item update_paste_buffer() |
|
|
|
=item print_paste_buffer() |
|
|
|
=item do_paste_from_buffer() |
|
|
|
=item update_parameter() |
|
|
|
=item handle_edit_cmd() |
|
|
|
=item editor() |
|
|
|
=item process_file_upload() |
|
|
|
=item process_secondary_uploads() |
|
|
|
=item is_supplemental_title() |
|
|
|
=item parse_supplemental_title() |
|
|
|
=item entryline() |
|
|
|
=item tiehash() |
|
|
|
=item untiehash() |
|
|
|
=item checkonthis() |
|
|
|
check on this |
|
|
|
=item verifycontent() |
|
|
|
Verify Content |
|
|
|
=item devalidateversioncache() & checkversions() |
|
|
|
Check Versions |
|
|
|
=item mark_hash_old() |
|
|
|
=item is_hash_old() |
|
|
|
=item changewarning() |
|
|
|
=item init_breadcrumbs() |
|
|
|
Breadcrumbs for special functions |
|
|
|
=back |
|
|
|
=cut |