version 1.327, 2009/01/28 12:56:08
|
version 1.460, 2011/09/10 19:00:07
|
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',
|
if ($allowed) { |
'cp' => 'Copy');
|
$r->print(&generate_edit_table($tid,$orderhash,$to_show)); |
my $nocopy=0;
|
&print_paste_buffer($r,$container); |
my $nocut=0;
|
} else { |
if ($url=~/\.(page|sequence)$/) {
|
$r->print($to_show); |
if ($url =~ m{/res/}) {
|
} |
# no copy for published maps
|
return; |
$nocopy = 1;
|
} |
} else {
|
|
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
|
sub process_file_upload { |
my ($title,$url,$ext,$type)=split(/\:/,$item);
|
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_; |
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
|
# upload a file, if present |
$nocopy=1;
|
my ($parseaction,$showupload,$nextphase,$mimetype); |
last;
|
if ($env{'form.parserflag'}) { |
}
|
$parseaction = 'parse'; |
}
|
} |
}
|
my $folder=$env{'form.folder'}; |
}
|
if ($folder eq '') { |
if ($url=~/^\/res\/lib\/templates\//) {
|
$folder='default'; |
$nocopy=1;
|
} |
$nocut=1;
|
if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) { |
}
|
my $errtext=''; |
my $copylink=' ';
|
my $fatal=0; |
my $cutlink=' ';
|
my $container='sequence'; |
|
if ($env{'form.pagepath'}) { |
my $skip_confirm = 0;
|
$container='page'; |
if ( $folder =~ /^supplemental/
|
} |
|| ($url =~ m{( /smppg$
|
($errtext,$fatal)= |
|/syllabus$
|
&mapread($coursenum,$coursedom,$folder.'.'.$container); |
|/aboutme$
|
if ($#LONCAPA::map::order<1) { |
|/navmaps$
|
$LONCAPA::map::order[0]=1; |
|/bulletinboard$
|
$LONCAPA::map::resources[1]=''; |
|\.html$
|
} |
|^/adm/wrapper/ext)}x)) {
|
if ($fatal) { |
$skip_confirm = 1;
|
$$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>'; |
}
|
return; |
|
} |
if (!$nocopy) {
|
my $destination = 'docs/'; |
$copylink=(<<ENDCOPY);
|
if ($folder =~ /^supplemental/) { |
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
|
$destination = 'supplemental/'; |
ENDCOPY
|
} |
}
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
if (!$nocut) {
|
$destination .= 'default/'; |
$cutlink=(<<ENDCUT);
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
|
$destination .= $2.'/'; |
ENDCUT
|
} |
}
|
# this is for a course, not a user, so set context to coursedoc. |
$form_start = (<<END);
|
my $newidx=&LONCAPA::map::getresidx(); |
<form action="/adm/coursedocs" method="post">
|
$destination .= $newidx; |
<input type="hidden" name="${type}path" value="$path" />
|
my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination, |
<input type="hidden" name="${type}symb" value="$symb" />
|
$parseaction,$allfiles, |
<input type="hidden" name="setparms" value="$orderidx" />
|
$codebase,undef,undef,undef,undef, |
<input type="hidden" name="changeparms" value="0" />
|
undef,undef,\$mimetype); |
END
|
if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) { |
$form_end = '</form>';
|
my $stored = $1; |
$line.=(<<END);
|
$showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'. |
<td>
|
$stored.'</span>').'</p>'; |
<table class="LC_docs_entry_move">
|
} else { |
<tr>
|
my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$}); |
<td>
|
|
<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>
|
$$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>'; |
</td>
|
return; |
</tr>
|
} |
<tr>
|
my $ext='false'; |
<td>
|
if ($url=~m{^http://}) { $ext='true'; } |
<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>
|
$url = &LONCAPA::map::qtunescape($url); |
</td>
|
my $comment=$env{'form.comment'}; |
</tr>
|
$comment = &LONCAPA::map::qtunescape($comment); |
</table>
|
if ($folder=~/^supplemental/) { |
</td>
|
$comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'. |
<td>
|
$env{'user.domain'}.'___&&&___'.$comment; |
$form_start
|
} |
$selectbox
|
|
$form_end
|
$LONCAPA::map::resources[$newidx]= |
</td>
|
$comment.':'.$url.':'.$ext.':normal:res'; |
<td class="LC_docs_entry_commands">
|
$LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx; |
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
|
($errtext,$fatal)=&storemap($coursenum,$coursedom, |
$cutlink
|
$folder.'.'.$container); |
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
|
if ($fatal) { |
$copylink
|
$$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>'; |
</td>
|
return; |
END
|
} else { |
|
if ($parseaction eq 'parse' && $mimetype eq 'text/html') { |
}
|
$$upload_output = $showupload; |
# Figure out what kind of a resource this is
|
my $total_embedded = scalar(keys(%{$allfiles})); |
my ($extension)=($url=~/\.(\w+)$/);
|
if ($total_embedded > 0) { |
my $uploaded=($url=~/^\/*uploaded\//);
|
my $uploadphase = 'upload_embedded'; |
my $icon=&Apache::loncommon::icon($url);
|
my $primaryurl = &HTML::Entities::encode($url,'<>&"'); |
my $isfolder=0;
|
my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx); |
my $ispage=0;
|
my ($embedded,$num) = |
my $folderarg;
|
&Apache::loncommon::ask_for_embedded_content( |
my $pagearg;
|
'/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url}); |
my $pagefile;
|
if ($embedded) { |
if ($uploaded) {
|
if ($num) { |
if ($extension eq 'sequence') {
|
$$upload_output .= |
$icon=$iconpath.'/folder_closed.gif';
|
'<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded; |
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
|
$nextphase = $uploadphase; |
$url='/adm/coursedocs?';
|
} else { |
$folderarg=$1;
|
$$upload_output .= $embedded; |
$isfolder=1;
|
} |
} elsif ($extension eq 'page') {
|
} else { |
$icon=$iconpath.'/page.gif';
|
$$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />'; |
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
|
} |
$pagearg=$1;
|
} else { |
$url='/adm/coursedocs?';
|
$$upload_output .= &mt('No embedded items identified').'<br />'; |
$ispage=1;
|
} |
} else {
|
$$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>'; |
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
|
} |
}
|
} |
}
|
} |
|
return $nextphase; |
my $orig_url = $url;
|
} |
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
|
|
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
|
sub is_supplemental_title { |
my $symb=&Apache::lonnet::symbclean(
|
my ($title) = @_; |
&Apache::lonnet::declutter('uploaded/'.
|
return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/); |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
} |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
|
|
'.sequence').
|
sub parse_supplemental_title { |
'___'.$residx.'___'.
|
my ($title) = @_; |
&Apache::lonnet::declutter($url));
|
|
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
|
my ($foldertitle,$renametitle); |
$url=&Apache::lonnet::clutter($url);
|
if ($title =~ /&&&/) { |
if ($url=~/^\/*uploaded\//) {
|
$title = &HTML::Entites::decode($title); |
$url=~/\.(\w+)$/;
|
} |
my $embstyle=&Apache::loncommon::fileembstyle($1);
|
if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) { |
if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
|
$renametitle=$4; |
$url='/adm/wrapper'.$url;
|
my ($time,$uname,$udom) = ($1,$2,$3); |
} elsif ($embstyle eq 'ssi') {
|
$foldertitle=&Apache::lontexconvert::msgtexconverted($4); |
#do nothing with these
|
my $name = &Apache::loncommon::plainname($uname,$udom); |
} elsif ($url!~/\.(sequence|page)$/) {
|
$name = &HTML::Entities::encode($name,'"<>&\''); |
$url='/adm/coursedocs/showdoc'.$url;
|
$renametitle = &HTML::Entities::encode($renametitle,'"<>&\''); |
}
|
$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '. |
} elsif ($url=~m|^/ext/|) {
|
$name.': <br />'.$foldertitle; |
$url='/adm/wrapper'.$url;
|
} |
$external = 1;
|
if (wantarray) { |
}
|
return ($title,$foldertitle,$renametitle); |
if (&Apache::lonnet::symbverify($symb,$url)) {
|
} |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
return $title; |
} else {
|
} |
$url='';
|
|
}
|
# --------------------------------------------------------------- An entry line |
if ($container eq 'page') {
|
|
my $symb=$env{'form.pagesymb'};
|
sub entryline { |
|
my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_; |
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
|
my ($foldertitle,$pagetitle,$renametitle); |
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
|
if (&is_supplemental_title($title)) { |
}
|
($title,$foldertitle,$renametitle) = &parse_supplemental_title($title); |
}
|
$pagetitle = $foldertitle; |
my ($parameterset,$rand_order_text) = (' ', ' ');
|
} else { |
if ($isfolder || $extension eq 'sequence') {
|
$title=&HTML::Entities::encode($title,'"<>&\''); |
my $foldername=&escape($foldertitle);
|
$renametitle=$title; |
my $folderpath=$env{'form.folderpath'};
|
$foldertitle=$title; |
if ($folderpath) { $folderpath.='&' };
|
$pagetitle=$title; |
# Append randompick number, hidden, and encrypted with ":" to foldername,
|
} |
# so it gets transferred between levels
|
|
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
|
my $orderidx=$LONCAPA::map::order[$index]; |
'parameter_randompick'))[0]
|
|
.':'.((&LONCAPA::map::getparameter($orderidx,
|
|
'parameter_hiddenresource'))[0]=~/^yes$/i)
|
$renametitle=~s/\\/\\\\/g; |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
$renametitle=~s/\"\;/\\\"/g; |
'parameter_encrypturl'))[0]=~/^yes$/i)
|
$renametitle=~s/ /%20/g; |
.':'.((&LONCAPA::map::getparameter($orderidx,
|
my $line=&Apache::loncommon::start_data_table_row(); |
'parameter_randomorder'))[0]=~/^yes$/i);
|
my ($form_start,$form_end); |
$url.='folderpath='.&escape($folderpath).$cpinfo;
|
# Edit commands |
$parameterset='<label>'.&mt('Randomly Pick: ').
|
my ($container, $type, $esc_path, $path, $symb); |
'<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
|
if ($env{'form.folderpath'}) { |
(&LONCAPA::map::getparameter($orderidx,
|
$type = 'folder'; |
'parameter_randompick'))[0].
|
$container = 'sequence'; |
'" />'.
|
$esc_path=&escape($env{'form.folderpath'}); |
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
|
$path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
my $ro_set=
|
# $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"'); |
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
|
} |
$rand_order_text ='
|
if ($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>';
|
$type = $container = 'page'; |
}
|
$esc_path=&escape($env{'form.pagepath'}); |
if ($ispage) {
|
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"'); |
my $pagename=&escape($pagetitle);
|
$symb=&escape($env{'form.pagesymb'}); |
my $pagepath;
|
} |
my $folderpath=$env{'form.folderpath'};
|
my $cpinfo=''; |
if ($folderpath) { $pagepath = $folderpath.'&' };
|
if ($allowed) { |
$pagepath.=$pagearg.'&'.$pagename;
|
my $incindex=$index+1; |
my $symb=$env{'form.pagesymb'};
|
my $selectbox=''; |
if (!$symb) {
|
if (($folder!~/^supplemental/) && |
my $path='uploaded/'.
|
($#LONCAPA::map::order>0) && |
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
|
((split(/\:/, |
$env{'course.'.$env{'request.course.id'}.'.num'}.'/';
|
$LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1] |
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
|
ne '') && |
$residx,
|
((split(/\:/, |
$path.$pagearg.'.page');
|
$LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1] |
}
|
ne '')) { |
$url.='pagepath='.&escape($pagepath).
|
$selectbox= |
'&pagesymb='.&escape($symb).$cpinfo;
|
'<input type="hidden" name="currentpos" value="'.$incindex.'" />'. |
}
|
'<select name="newpos" onchange="this.form.submit()">'; |
if ($external) {
|
for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) { |
my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
|
if ($i==$incindex) { |
$external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
|
$selectbox.='<option value="" selected="selected">('.$i.')</option>'; |
} else {
|
} else { |
undef($external);
|
$selectbox.='<option value="'.$i.'">'.$i.'</option>'; |
}
|
} |
$line.='
|
} |
<td class="LC_docs_entry_icon">
|
$selectbox.='</select>'; |
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
|
} |
</td>
|
my %lt=&Apache::lonlocal::texthash( |
<td class="LC_docs_entry_title">
|
'up' => 'Move Up', |
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
|
'dw' => 'Move Down', |
</td>";
|
'rm' => 'Remove', |
if (($allowed) && ($folder!~/^supplemental/)) {
|
'ct' => 'Cut', |
my %lt=&Apache::lonlocal::texthash(
|
'rn' => 'Rename', |
'hd' => 'Hidden',
|
'cp' => 'Copy'); |
'ec' => 'URL hidden');
|
my $nocopy=0; |
my $enctext=
|
my $nocut=0; |
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
|
if ($url=~/\.(page|sequence)$/) { |
my $hidtext=
|
if ($url =~ m{/res/}) { |
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
|
# no copy for published maps |
$line.=(<<ENDPARMS);
|
$nocopy = 1; |
<td class="LC_docs_entry_parameter">
|
} else { |
$form_start
|
foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) { |
<label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
|
my ($title,$url,$ext,$type)=split(/\:/,$item); |
$form_end
|
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { |
</td>
|
$nocopy=1; |
<td class="LC_docs_entry_parameter">
|
last; |
$form_start
|
} |
<label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
|
} |
$form_end
|
} |
</td>
|
} |
<td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
|
if ($url=~/^\/res\/lib\/templates\//) { |
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
|
$nocopy=1; |
ENDPARMS
|
$nocut=1; |
}
|
} |
$line.="</tr>";
|
my $copylink=' '; |
return $line;
|
my $cutlink=' '; |
}
|
|
|
my $skip_confirm = 0; |
=pod
|
if ( $folder =~ /^supplemental/ |
|
|| ($url =~ m{( /smppg$ |
=item tiehash()
|
|/syllabus$ |
|
|/aboutme$ |
tie the hash
|
|/navmaps$ |
|
|/bulletinboard$ |
=cut
|
|\.html$ |
|
|^/adm/wrapper/ext)}x)) { |
sub tiehash {
|
$skip_confirm = 1; |
my ($mode)=@_;
|
} |
$hashtied=0;
|
|
if ($env{'request.course.fn'}) {
|
if (!$nocopy) { |
if ($mode eq 'write') {
|
$copylink=(<<ENDCOPY); |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
<a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a> |
&GDBM_WRCREAT(),0640)) {
|
ENDCOPY |
$hashtied=2;
|
} |
}
|
if (!$nocut) { |
} else {
|
$cutlink=(<<ENDCUT); |
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
|
<a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a> |
&GDBM_READER(),0640)) {
|
ENDCUT |
$hashtied=1;
|
} |
}
|
$form_start = (<<END); |
}
|
<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" /> |
sub untiehash {
|
<input type="hidden" name="changeparms" value="0" /> |
if ($hashtied) { untie %hash; }
|
END |
$hashtied=0;
|
$form_end = '</form>'; |
return OK;
|
$line.=(<<END); |
}
|
<td> |
|
<div class="LC_docs_entry_move"> |
|
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
|
<img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /> |
|
</a> |
sub checkonthis {
|
</div> |
my ($r,$url,$level,$title)=@_;
|
<div class="LC_docs_entry_move"> |
$url=&unescape($url);
|
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'> |
$alreadyseen{$url}=1;
|
<img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /> |
$r->rflush();
|
</a> |
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
|
</div> |
$r->print("\n<br />");
|
</td> |
if ($level==0) {
|
<td> |
$r->print("<br />");
|
$form_start |
}
|
$selectbox |
for (my $i=0;$i<=$level*5;$i++) {
|
$form_end |
$r->print(' ');
|
</td> |
}
|
<td class="LC_docs_entry_commands"> |
$r->print('<a href="'.$url.'" target="cat">'.
|
<a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a> |
($title?$title:$url).'</a> ');
|
$cutlink |
if ($url=~/^\/res\//) {
|
<a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a> |
my $result=&Apache::lonnet::repcopy(
|
$copylink |
&Apache::lonnet::filelocation('',$url));
|
</td> |
if ($result eq 'ok') {
|
END |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
|
$r->rflush();
|
} |
&Apache::lonnet::countacc($url);
|
# Figure out what kind of a resource this is |
$url=~/\.(\w+)$/;
|
my ($extension)=($url=~/\.(\w+)$/); |
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
|
my $uploaded=($url=~/^\/*uploaded\//); |
$r->print('<br />');
|
my $icon=&Apache::loncommon::icon($url); |
$r->rflush();
|
my $isfolder=0; |
for (my $i=0;$i<=$level*5;$i++) {
|
my $ispage=0; |
$r->print(' ');
|
my $folderarg; |
}
|
my $pagearg; |
$r->print('- '.&mt('Rendering:').' ');
|
my $pagefile; |
my ($errorcount,$warningcount)=split(/:/,
|
if ($uploaded) { |
&Apache::lonnet::ssi_body($url,
|
if ($extension eq 'sequence') { |
('grade_target'=>'web',
|
$icon=$iconpath.'/navmap.folder.closed.gif'; |
'return_only_error_and_warning_counts' => 1)));
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; |
if (($errorcount) ||
|
$url='/adm/coursedocs?'; |
($warningcount)) {
|
$folderarg=$1; |
if ($errorcount) {
|
$isfolder=1; |
$r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
|
} elsif ($extension eq 'page') { |
&mt('[quant,_1,error]',$errorcount).'</span>');
|
$icon=$iconpath.'/page.gif'; |
}
|
$url=~/\Q$coursenum\E\/([\/\w]+)\.page$/; |
if ($warningcount) {
|
$pagearg=$1; |
$r->print('<span class="LC_warning">'.
|
$url='/adm/coursedocs?'; |
&mt('[quant,_1,warning]',$warningcount).'</span>');
|
$ispage=1; |
}
|
} else { |
} else {
|
&Apache::lonnet::allowuploaded('/adm/coursedoc',$url); |
$r->print('<span class="LC_success">'.&mt('ok').'</span>');
|
} |
}
|
} |
$r->rflush();
|
|
}
|
my $orig_url = $url; |
my $dependencies=
|
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//}; |
&Apache::lonnet::metadata($url,'dependencies');
|
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/}); |
foreach my $dep (split(/\,/,$dependencies)) {
|
if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { |
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
|
my $symb=&Apache::lonnet::symbclean( |
&checkonthis($r,$dep,$level+1);
|
&Apache::lonnet::declutter('uploaded/'. |
}
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
}
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder. |
} elsif ($result eq 'unavailable') {
|
'.sequence'). |
$r->print('<span class="LC_error">'.&mt('connection down').'</span>');
|
'___'.$residx.'___'. |
} elsif ($result eq 'not_found') {
|
&Apache::lonnet::declutter($url)); |
unless ($url=~/\$/) {
|
(undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
|
$url=&Apache::lonnet::clutter($url); |
} else {
|
if ($url=~/^\/*uploaded\//) { |
$r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
|
$url=~/\.(\w+)$/; |
}
|
my $embstyle=&Apache::loncommon::fileembstyle($1); |
} else {
|
if (($embstyle eq 'img') || ($embstyle eq 'emb')) { |
$r->print('<span class="LC_error">'.&mt('access denied').'</span>');
|
$url='/adm/wrapper'.$url; |
}
|
} elsif ($embstyle eq 'ssi') { |
}
|
#do nothing with these |
}
|
} elsif ($url!~/\.(sequence|page)$/) { |
}
|
$url='/adm/coursedocs/showdoc'.$url; |
|
} |
|
} elsif ($url=~m|^/ext/|) { |
|
$url='/adm/wrapper'.$url; |
=pod
|
$external = 1; |
|
} |
=item list_symbs()
|
if (&Apache::lonnet::symbverify($symb,$url)) { |
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
List Symbs
|
} else { |
|
$url=''; |
=cut
|
} |
|
if ($container eq 'page') { |
sub list_symbs {
|
my $symb=$env{'form.pagesymb'}; |
my ($r) = @_;
|
|
|
$url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]); |
my $type = &Apache::loncommon::course_type();
|
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb); |
$r->print(&Apache::loncommon::start_page('Symb List'));
|
} |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
|
} |
my $navmap = Apache::lonnavmaps::navmap->new();
|
my ($parameterset,$rand_order_text) = (' ', ' '); |
if (!defined($navmap)) {
|
if ($isfolder || $extension eq 'sequence') { |
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
|
my $foldername=&escape($foldertitle); |
'<div class="LC_error">'.
|
my $folderpath=$env{'form.folderpath'}; |
&mt('Unable to retrieve information about course contents').
|
if ($folderpath) { $folderpath.='&' }; |
'</div>');
|
# Append randompick number, hidden, and encrypted with ":" to foldername, |
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
|
# so it gets transferred between levels |
} else {
|
$folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx, |
$r->print("<pre>\n");
|
'parameter_randompick'))[0] |
foreach my $res ($navmap->retrieveResources()) {
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
$r->print($res->compTitle()."\t".$res->symb()."\n");
|
'parameter_hiddenresource'))[0]=~/^yes$/i) |
}
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
$r->print("\n</pre>\n");
|
'parameter_encrypturl'))[0]=~/^yes$/i) |
}
|
.':'.((&LONCAPA::map::getparameter($orderidx, |
$r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
|
'parameter_randomorder'))[0]=~/^yes$/i); |
}
|
$url.='folderpath='.&escape($folderpath).$cpinfo; |
|
$parameterset='<label>'.&mt('Randomly Pick: '). |
|
'<input type="text" size="4" onchange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'. |
sub verifycontent {
|
(&LONCAPA::map::getparameter($orderidx, |
my ($r) = @_;
|
'parameter_randompick'))[0]. |
my $type = &Apache::loncommon::course_type();
|
'" />'. |
my $loaderror=&Apache::lonnet::overloaderror($r);
|
'<a href="javascript:void(0)">'.&mt('Save').'</a></label>'; |
if ($loaderror) { return $loaderror; }
|
my $ro_set= |
$r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
|
((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':''); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
|
$rand_order_text =' |
$hashtied=0;
|
<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>'; |
undef %alreadyseen;
|
} |
%alreadyseen=();
|
if ($ispage) { |
&tiehash();
|
my $pagename=&escape($pagetitle); |
foreach my $key (keys(%hash)) {
|
my $pagepath; |
if ($hash{$key}=~/\.(page|sequence)$/) {
|
my $folderpath=$env{'form.folderpath'}; |
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
|
if ($folderpath) { $pagepath = $folderpath.'&' }; |
$r->print('<hr /><span class="LC_error">'.
|
$pagepath.=$pagearg.'&'.$pagename; |
&mt('The following sequence or page is included more than once in your '.$type.': ').
|
my $symb=$env{'form.pagesymb'}; |
&unescape($hash{$key}).'</span><br />'.
|
if (!$symb) { |
&mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
|
my $path='uploaded/'. |
}
|
$env{'course.'.$env{'request.course.id'}.'.domain'}.'/'. |
}
|
$env{'course.'.$env{'request.course.id'}.'.num'}.'/'; |
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
|
$symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence', |
&checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
|
$residx, |
}
|
$path.$pagearg.'.page'); |
}
|
} |
&untiehash();
|
$url.='pagepath='.&escape($pagepath). |
$r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
|
'&pagesymb='.&escape($symb).$cpinfo; |
&mt('Return to DOCS').'</a>');
|
} |
}
|
if (($external) && ($allowed)) { |
|
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>'; |
sub devalidateversioncache {
|
} else { |
my $src=shift;
|
undef($external); |
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
|
} |
&Apache::lonnet::clutter($src));
|
my $reinit; |
}
|
if ($crstype eq 'Community') { |
|
$reinit = &mt('(re-initialize community to access)'); |
sub checkversions {
|
} else { |
my ($r) = @_;
|
$reinit = &mt('(re-initialize course to access)'); |
my $type = &Apache::loncommon::course_type();
|
} |
$r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
|
$line.=' |
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
|
<td> |
my $header='';
|
'.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').' |
my $startsel='';
|
</td> |
my $monthsel='';
|
<td> |
my $weeksel='';
|
'.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.$reinit.'</span>').$external." |
my $daysel='';
|
</td>"; |
my $allsel='';
|
if (($allowed) && ($folder!~/^supplemental/)) { |
my %changes=();
|
my %lt=&Apache::lonlocal::texthash( |
my $starttime=0;
|
'hd' => 'Hidden', |
my $haschanged=0;
|
'ec' => 'URL hidden'); |
my %setversions=&Apache::lonnet::dump('resourceversions',
|
my $enctext= |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':''); |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
my $hidtext= |
|
((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':''); |
$hashtied=0;
|
$line.=(<<ENDPARMS); |
&tiehash();
|
<td class="LC_docs_entry_parameter"> |
my %newsetversions=();
|
$form_start |
if ($env{'form.setmostrecent'}) {
|
<label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label> |
$haschanged=1;
|
$form_end |
foreach my $key (keys(%hash)) {
|
<br /> |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
$form_start |
$newsetversions{$1}='mostrecent';
|
<label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label> |
&devalidateversioncache($1);
|
$form_end |
}
|
</td> |
}
|
<td class="LC_docs_entry_parameter">$form_start $parameterset $form_end<br /> |
} elsif ($env{'form.setcurrent'}) {
|
$form_start $rand_order_text $form_end</td> |
$haschanged=1;
|
ENDPARMS |
foreach my $key (keys(%hash)) {
|
} |
if ($key=~/^ids\_(\/res\/.+)$/) {
|
$line.=&Apache::loncommon::end_data_table_row(); |
my $getvers=&Apache::lonnet::getversion($1);
|
return $line; |
if ($getvers>0) {
|
} |
$newsetversions{$1}=$getvers;
|
|
&devalidateversioncache($1);
|
=pod |
}
|
|
}
|
=item tiehash() |
}
|
|
} elsif ($env{'form.setversions'}) {
|
tie the hash |
$haschanged=1;
|
|
foreach my $key (keys(%env)) {
|
=cut |
if ($key=~/^form\.set_version_(.+)$/) {
|
|
my $src=$1;
|
sub tiehash { |
if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
|
my ($mode)=@_; |
$newsetversions{$src}=$env{$key};
|
$hashtied=0; |
&devalidateversioncache($src);
|
if ($env{'request.course.fn'}) { |
}
|
if ($mode eq 'write') { |
}
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
}
|
&GDBM_WRCREAT(),0640)) { |
}
|
$hashtied=2; |
if ($haschanged) {
|
} |
if (&Apache::lonnet::put('resourceversions',\%newsetversions,
|
} else { |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db", |
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
|
&GDBM_READER(),0640)) { |
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>');
|
$hashtied=1; |
} else {
|
} |
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>');
|
} |
}
|
} |
&mark_hash_old();
|
} |
}
|
|
&changewarning($r,'');
|
sub untiehash { |
if ($env{'form.timerange'} eq 'all') {
|
if ($hashtied) { untie %hash; } |
# show all documents
|
$hashtied=0; |
$header=&mt('All Documents in '.$type);
|
return OK; |
$allsel=1;
|
} |
foreach my $key (keys(%hash)) {
|
|
if ($key=~/^ids\_(\/res\/.+)$/) {
|
|
my $src=$1;
|
|
$changes{$src}=1;
|
|
}
|
sub checkonthis { |
}
|
my ($r,$url,$level,$title)=@_; |
} else {
|
$url=&unescape($url); |
# show documents which changed
|
$alreadyseen{$url}=1; |
%changes=&Apache::lonnet::dump
|
$r->rflush(); |
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
|
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) { |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
$r->print("\n<br />"); |
my $firstkey=(keys(%changes))[0];
|
if ($level==0) { |
unless ($firstkey=~/^error\:/) {
|
$r->print("<br />"); |
unless ($env{'form.timerange'}) {
|
} |
$env{'form.timerange'}=604800;
|
for (my $i=0;$i<=$level*5;$i++) { |
}
|
$r->print(' '); |
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
|
} |
.&mt('seconds');
|
$r->print('<a href="'.$url.'" target="cat">'. |
if ($env{'form.timerange'}==-1) {
|
($title?$title:$url).'</a> '); |
$seltext='since start of course';
|
if ($url=~/^\/res\//) { |
$startsel='selected';
|
my $result=&Apache::lonnet::repcopy( |
$env{'form.timerange'}=time;
|
&Apache::lonnet::filelocation('',$url)); |
}
|
if ($result eq 'ok') { |
$starttime=time-$env{'form.timerange'};
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
if ($env{'form.timerange'}==2592000) {
|
$r->rflush(); |
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
&Apache::lonnet::countacc($url); |
$monthsel='selected';
|
$url=~/\.(\w+)$/; |
} elsif ($env{'form.timerange'}==604800) {
|
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { |
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
$r->print('<br />'); |
$weeksel='selected';
|
$r->rflush(); |
} elsif ($env{'form.timerange'}==86400) {
|
for (my $i=0;$i<=$level*5;$i++) { |
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
|
$r->print(' '); |
$daysel='selected';
|
} |
}
|
$r->print('- '.&mt('Rendering:').' '); |
$header=&mt('Content changed').' '.$seltext;
|
my ($errorcount,$warningcount)=split(/:/, |
} else {
|
&Apache::lonnet::ssi_body($url, |
$header=&mt('No content modifications yet.');
|
('grade_target'=>'web', |
}
|
'return_only_error_and_warning_counts' => 1))); |
}
|
if (($errorcount) || |
%setversions=&Apache::lonnet::dump('resourceversions',
|
($warningcount)) { |
$env{'course.'.$env{'request.course.id'}.'.domain'},
|
if ($errorcount) { |
$env{'course.'.$env{'request.course.id'}.'.num'});
|
$r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'. |
my %lt=&Apache::lonlocal::texthash
|
&mt('[quant,_1,error]',$errorcount).'</span>'); |
('st' => 'Version changes since start of '.$type,
|
} |
'lm' => 'Version changes since last Month',
|
if ($warningcount) { |
'lw' => 'Version changes since last Week',
|
$r->print('<span class="LC_warning">'. |
'sy' => 'Version changes since Yesterday',
|
&mt('[quant,_1,warning]',$warningcount).'</span>'); |
'al' => 'All Resources (possibly large output)',
|
} |
'sd' => 'Display',
|
} else { |
'fi' => 'File',
|
$r->print('<span class="LC_success">'.&mt('ok').'</span>'); |
'md' => 'Modification Date',
|
} |
'mr' => 'Most recently published Version',
|
$r->rflush(); |
've' => 'Version used in '.$type,
|
} |
'vu' => 'Set Version to be used in '.$type,
|
my $dependencies= |
'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
|
&Apache::lonnet::metadata($url,'dependencies'); |
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
|
foreach my $dep (split(/\,/,$dependencies)) { |
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
|
if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) { |
'di' => 'Differences');
|
&checkonthis($r,$dep,$level+1); |
$r->print(<<ENDHEADERS);
|
} |
<form action="/adm/coursedocs" method="post">
|
} |
<input type="hidden" name="versions" value="1" />
|
} elsif ($result eq 'unavailable') { |
<input type="submit" name="setmostrecent" value="$lt{'sm'}" />
|
$r->print('<span class="LC_error">'.&mt('connection down').'</span>'); |
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
|
} elsif ($result eq 'not_found') { |
<select name="timerange">
|
unless ($url=~/\$/) { |
<option value='all' $allsel>$lt{'al'}</option>
|
$r->print('<span class="LC_error">'.&mt('not found').'</b></span>'); |
<option value="-1" $startsel>$lt{'st'}</option>
|
} else { |
<option value="2592000" $monthsel>$lt{'lm'}</option>
|
$r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>'); |
<option value="604800" $weeksel>$lt{'lw'}</option>
|
} |
<option value="86400" $daysel>$lt{'sy'}</option>
|
} else { |
</select>
|
$r->print('<span class="LC_error">'.&mt('access denied').'</span>'); |
<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))) {
|
|
if ($changes{$key}>$starttime) {
|
|
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
|
=pod |
my $currentversion=&Apache::lonnet::getversion($key);
|
|
if ($currentversion<0) {
|
=item list_symbs() |
$currentversion=&mt('Could not be determined.');
|
|
}
|
List Symbs |
my $linkurl=&Apache::lonnet::clutter($key);
|
|
$r->print(
|
=cut |
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
|
|
&Apache::lonnet::gettitle($linkurl).
|
sub list_symbs { |
'</b></font></td></tr>'.
|
my ($r) = @_; |
'<tr><td> </td>'.
|
|
'<td colspan="4">'.
|
my $crstype = &Apache::loncommon::course_type(); |
'<a href="'.$linkurl.'" target="cat">'.$linkurl.
|
$r->print(&Apache::loncommon::start_page('Symb List')); |
'</a></td></tr>'.
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List')); |
'<tr><td></td>'.
|
&startContentScreen($r,'tools'); |
'<td title="'.$lt{'md'}.'">'.
|
my $navmap = Apache::lonnavmaps::navmap->new(); |
&Apache::lonlocal::locallocaltime(
|
if (!defined($navmap)) { |
&Apache::lonnet::metadata($root.'.'.$extension,
|
$r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'. |
'lastrevisiondate')
|
'<div class="LC_error">'. |
).
|
&mt('Unable to retrieve information about course contents'). |
'</td>'.
|
'</div>'); |
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
|
&Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'}); |
'<font size="+1">'.$currentversion.'</font>'.
|
} else { |
'</span></td>'.
|
$r->print("<pre>\n"); |
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
|
foreach my $res ($navmap->retrieveResources()) { |
'<font size="+1">');
|
$r->print($res->compTitle()."\t".$res->symb()."\n"); |
# Used in course
|
} |
my $usedversion=$hash{'version_'.$linkurl};
|
$r->print("\n</pre>\n"); |
if (($usedversion) && ($usedversion ne 'mostrecent')) {
|
} |
$r->print($usedversion);
|
} |
} else {
|
|
$r->print($currentversion);
|
|
}
|
sub verifycontent { |
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'.
|
my ($r) = @_; |
'<span class="LC_nobreak">Use: ');
|
my $crstype = &Apache::loncommon::course_type(); |
# Set version
|
$r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents')); |
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents')); |
'set_version_'.$linkurl,
|
&startContentScreen($r,'tools'); |
('select_form_order' =>
|
$hashtied=0; |
['',1..$currentversion,'mostrecent'],
|
undef %alreadyseen; |
'' => '',
|
%alreadyseen=(); |
'mostrecent' => 'most recent',
|
&tiehash(); |
map {$_,$_} (1..$currentversion))));
|
foreach my $key (keys(%hash)) { |
$r->print('</span></td></tr><tr><td></td>');
|
if ($hash{$key}=~/\.(page|sequence)$/) { |
my $lastold=1;
|
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) { |
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
|
$r->print('<hr /><span class="LC_error">'. |
my $url=$root.'.'.$prevvers.'.'.$extension;
|
&mt('The following sequence or page is included more than once in your '.$crstype.':').' '. |
if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
|
&unescape($hash{$key}).'</span><br />'. |
$starttime) {
|
&mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />'); |
$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
|
} |
# each of the four columns
|
} |
my $entries_per_col = 0;
|
&untiehash(); |
my $num_entries = ($currentversion-$lastold);
|
$r->print('<p class="LC_success">'.&mt('Done').'</p>'); |
if ($num_entries % 4 == 0) {
|
} |
$entries_per_col = $num_entries/4;
|
|
} else {
|
|
$entries_per_col = $num_entries/4 + 1;
|
sub devalidateversioncache { |
}
|
my $src=shift; |
my $entries_count = 0;
|
&Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'. |
$r->print('<td valign="top"><font size="-2">');
|
&Apache::lonnet::clutter($src)); |
my $cols_output = 1;
|
} |
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
|
|
my $url=$root.'.'.$prevvers.'.'.$extension;
|
sub checkversions { |
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
|
my ($r) = @_; |
'">'.&mt('Version').' '.$prevvers.'</a> ('.
|
my $crstype = &Apache::loncommon::course_type(); |
&Apache::lonlocal::locallocaltime(
|
$r->print(&Apache::loncommon::start_page("Check $crstype Document Versions")); |
&Apache::lonnet::metadata($url,
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions")); |
'lastrevisiondate')
|
&startContentScreen($r,'tools'); |
).
|
|
')');
|
my $header=''; |
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
|
my $startsel=''; |
$r->print(' <a href="/adm/diff?filename='.
|
my $monthsel=''; |
&Apache::lonnet::clutter($root.'.'.$extension).
|
my $weeksel=''; |
'&versionone='.$prevvers.
|
my $daysel=''; |
'">'.&mt('Diffs').'</a>');
|
my $allsel=''; |
}
|
my %changes=(); |
$r->print('</span><br />');
|
my $starttime=0; |
if (++$entries_count % $entries_per_col == 0) {
|
my $haschanged=0; |
$r->print('</font></td>');
|
my %setversions=&Apache::lonnet::dump('resourceversions', |
if ($cols_output != 4) {
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$r->print('<td valign="top"><font size="-2">');
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$cols_output++;
|
|
}
|
$hashtied=0; |
}
|
&tiehash(); |
}
|
my %newsetversions=(); |
while($cols_output++ < 4) {
|
if ($env{'form.setmostrecent'}) { |
$r->print('</font></td><td><font>')
|
$haschanged=1; |
}
|
foreach my $key (keys(%hash)) { |
$r->print('</font></td></tr>'."\n");
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
}
|
$newsetversions{$1}='mostrecent'; |
}
|
&devalidateversioncache($1); |
$r->print('</table></form>');
|
} |
$r->print('<h1>'.&mt('Done').'.</h1>');
|
} |
|
} elsif ($env{'form.setcurrent'}) { |
&untiehash();
|
$haschanged=1; |
}
|
foreach my $key (keys(%hash)) { |
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
sub mark_hash_old {
|
my $getvers=&Apache::lonnet::getversion($1); |
my $retie_hash=0;
|
if ($getvers>0) { |
if ($hashtied) {
|
$newsetversions{$1}=$getvers; |
$retie_hash=1;
|
&devalidateversioncache($1); |
&untiehash();
|
} |
}
|
} |
&tiehash('write');
|
} |
$hash{'old'}=1;
|
} elsif ($env{'form.setversions'}) { |
&untiehash();
|
$haschanged=1; |
if ($retie_hash) { &tiehash(); }
|
foreach my $key (keys(%env)) { |
}
|
if ($key=~/^form\.set_version_(.+)$/) { |
|
my $src=$1; |
sub is_hash_old {
|
if (($env{$key}) && ($env{$key} ne $setversions{$src})) { |
my $untie_hash=0;
|
$newsetversions{$src}=$env{$key}; |
if (!$hashtied) {
|
&devalidateversioncache($src); |
$untie_hash=1;
|
} |
&tiehash();
|
} |
}
|
} |
my $return=$hash{'old'};
|
} |
if ($untie_hash) { &untiehash(); }
|
if ($haschanged) { |
return $return;
|
if (&Apache::lonnet::put('resourceversions',\%newsetversions, |
}
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { |
sub changewarning {
|
$r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>'); |
my ($r,$postexec,$message,$url)=@_;
|
} else { |
if (!&is_hash_old()) { return; }
|
$r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>'); |
my $pathvar='folderpath';
|
} |
my $path=&escape($env{'form.folderpath'});
|
&mark_hash_old(); |
if (!defined($url)) {
|
} |
if (defined($env{'form.pagepath'})) {
|
&changewarning($r,''); |
$pathvar='pagepath';
|
if ($env{'form.timerange'} eq 'all') { |
$path=&escape($env{'form.pagepath'});
|
# show all documents |
$path.='&pagesymb='.&escape($env{'form.pagesymb'});
|
$header=&mt('All Documents in '.$crstype); |
}
|
$allsel=1; |
$url='/adm/coursedocs?'.$pathvar.'='.$path;
|
foreach my $key (keys(%hash)) { |
}
|
if ($key=~/^ids\_(\/res\/.+)$/) { |
my $course_type = &Apache::loncommon::course_type();
|
my $src=$1; |
if (!defined($message)) {
|
$changes{$src}=1; |
$message='Changes will become active for your current session after [_1], or the next time you log in.';
|
} |
}
|
} |
$r->print("\n\n".
|
} else { |
'<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
|
# show documents which changed |
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
|
%changes=&Apache::lonnet::dump |
'<input type="hidden" name="orgurl" value="'.$url.
|
('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'}, |
'" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
&mt($message,' <input type="hidden" name="'.
|
my $firstkey=(keys(%changes))[0]; |
$env{'request.role'}.'" value="1" /><input type="button" value="'.
|
unless ($firstkey=~/^error\:/) { |
&mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
|
unless ($env{'form.timerange'}) { |
$help{'Caching'}.'</span></h3></form>'."\n\n");
|
$env{'form.timerange'}=604800; |
}
|
} |
|
my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' ' |
|
.&mt('seconds'); |
sub init_breadcrumbs {
|
if ($env{'form.timerange'}==-1) { |
my ($form,$text)=@_;
|
$seltext='since start of course'; |
&Apache::lonhtmlcommon::clear_breadcrumbs();
|
$startsel='selected'; |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
|
$env{'form.timerange'}=time; |
text=>"Edit ".&Apache::loncommon::course_type(),
|
} |
faq=>273,
|
$starttime=time-$env{'form.timerange'}; |
bug=>'Instructor Interface',
|
if ($env{'form.timerange'}==2592000) { |
help => 'Docs_Adding_Course_Doc'});
|
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
|
$monthsel='selected'; |
text=>$text,
|
} elsif ($env{'form.timerange'}==604800) { |
faq=>273,
|
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
bug=>'Instructor Interface'});
|
$weeksel='selected'; |
}
|
} elsif ($env{'form.timerange'}==86400) { |
|
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')'; |
|
$daysel='selected'; |
|
} |
|
$header=&mt('Content changed').' '.$seltext; |
sub handler {
|
} else { |
my $r = shift;
|
$header=&mt('No content modifications yet.'); |
&Apache::loncommon::content_type($r,'text/html');
|
} |
$r->send_http_header;
|
} |
return OK if $r->header_only;
|
%setversions=&Apache::lonnet::dump('resourceversions', |
my $type = &Apache::loncommon::course_type();
|
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
|
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
my %lt=&Apache::lonlocal::texthash |
# --------------------------------------------- Initialize help topics for this
|
('st' => 'Version changes since start of '.$crstype, |
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
|
'lm' => 'Version changes since last Month', |
'Adding_External_Resource','Navigate_Content',
|
'lw' => 'Version changes since last Week', |
'Adding_Folders','Docs_Overview', 'Load_Map',
|
'sy' => 'Version changes since Yesterday', |
'Supplemental','Score_Upload_Form','Adding_Pages',
|
'al' => 'All Resources (possibly large output)', |
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
|
'sd' => 'Display', |
'Check_Resource_Versions','Verify_Content') {
|
'fi' => 'File', |
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
|
'md' => 'Modification Date', |
}
|
'mr' => 'Most recently published Version', |
# Composite help files
|
've' => 'Version used in '.$crstype, |
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
|
'vu' => 'Set Version to be used in '.$crstype, |
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
|
'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below', |
$help{'Simple Page'} = &Apache::loncommon::help_open_topic(
|
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', |
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
|
'sc' => 'Set all Resource Versions to current Version (Fix Versions)', |
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
|
'di' => 'Differences'); |
'Option_Response_Simple');
|
$r->print(<<ENDHEADERS); |
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
|
<form action="/adm/coursedocs" method="post"> |
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
|
<input type="hidden" name="versions" value="1" /> |
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
|
<input type="submit" name="setmostrecent" value="$lt{'sm'}" /> |
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
|
<input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr /> |
$help{'Group Files'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
|
<select name="timerange"> |
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
|
<option value='all' $allsel>$lt{'al'}</option> |
|
<option value="-1" $startsel>$lt{'st'}</option> |
# does this user have privileges to modify docs
|
<option value="2592000" $monthsel>$lt{'lm'}</option> |
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
|
<option value="604800" $weeksel>$lt{'lw'}</option> |
if ($allowed && $env{'form.verify'}) {
|
<option value="86400" $daysel>$lt{'sy'}</option> |
&init_breadcrumbs('verify','Verify Content');
|
</select> |
&verifycontent($r);
|
<input type="submit" name="display" value="$lt{'sd'}" /> |
} elsif ($allowed && $env{'form.listsymbs'}) {
|
<h3>$header</h3> |
&init_breadcrumbs('listsymbs','List Symbs');
|
<input type="submit" name="setversions" value="$lt{'sv'}" /> |
&list_symbs($r);
|
<table border="0"> |
} elsif ($allowed && $env{'form.docslog'}) {
|
ENDHEADERS |
&init_breadcrumbs('docslog','Show Log');
|
foreach my $key (sort(keys(%changes))) { |
&docs_change_log($r);
|
if ($changes{$key}>$starttime) { |
} elsif ($allowed && $env{'form.versions'}) {
|
my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); |
&init_breadcrumbs('versions','Check/Set Resource Versions');
|
my $currentversion=&Apache::lonnet::getversion($key); |
&checkversions($r);
|
if ($currentversion<0) { |
} elsif ($allowed && $env{'form.dumpcourse'}) {
|
$currentversion=&mt('Could not be determined.'); |
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
|
} |
&dumpcourse($r);
|
my $linkurl=&Apache::lonnet::clutter($key); |
} elsif ($allowed && $env{'form.exportcourse'}) {
|
$r->print( |
&init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
|
'<tr><td colspan="5"><br /><br /><font size="+1"><b>'. |
&exportcourse($r);
|
&Apache::lonnet::gettitle($linkurl). |
} else {
|
'</b></font></td></tr>'. |
# is this a standard course?
|
'<tr><td> </td>'. |
|
'<td colspan="4">'. |
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
|
'<a href="'.$linkurl.'" target="cat">'.$linkurl. |
my $forcestandard = 0;
|
'</a></td></tr>'. |
my $forcesupplement;
|
'<tr><td></td>'. |
my $script='';
|
'<td title="'.$lt{'md'}.'">'. |
my $showdoc=0;
|
&Apache::lonlocal::locallocaltime( |
my $containertag;
|
&Apache::lonnet::metadata($root.'.'.$extension, |
my $uploadtag;
|
'lastrevisiondate') |
|
). |
|
'</td>'. |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
|
'<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '. |
['folderpath','pagepath',
|
'<font size="+1">'.$currentversion.'</font>'. |
'pagesymb']);
|
'</span></td>'. |
# No folderpath, no pagepath, see if we have something stored
|
'<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$crstype.': '. |
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
|
'<font size="+1">'); |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
# Used in course |
{'folderpath' => 'scalar'});
|
my $usedversion=$hash{'version_'.$linkurl}; |
}
|
if (($usedversion) && ($usedversion ne 'mostrecent')) { |
if (!$env{'form.folderpath'}) {
|
$r->print($usedversion); |
&Apache::loncommon::restore_course_settings('docs_folderpath',
|
} else { |
{'pagepath' => 'scalar'});
|
$r->print($currentversion); |
}
|
} |
if ($env{'form.pagepath'}) {
|
$r->print('</font></span></td><td title="'.$lt{'vu'}.'">'. |
$env{'form.folderpath'}='';
|
'<span class="LC_nobreak">Use: '); |
}
|
# Set version |
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
|
$r->print(&Apache::loncommon::select_form($setversions{$linkurl}, |
$env{'form.folderpath'} = 'supplemental&'.
|
'set_version_'.$linkurl, |
&escape(&mt('Supplemental '.$type.' Documents')).'&'.
|
{'select_form_order' => |
$env{'form.folderpath'};
|
['',1..$currentversion,'mostrecent'], |
}
|
'' => '', |
&Apache::loncommon::store_course_settings('docs_folderpath',
|
'mostrecent' => &mt('most recent'), |
{'pagepath' => 'scalar',
|
map {$_,$_} (1..$currentversion)})); |
'folderpath' => 'scalar'});
|
$r->print('</span></td></tr><tr><td></td>'); |
if ($env{'form.folderpath'}) {
|
my $lastold=1; |
my (@folderpath)=split('&',$env{'form.folderpath'});
|
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { |
$env{'form.foldername'}=&unescape(pop(@folderpath));
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
$env{'form.folder'}=pop(@folderpath);
|
if (&Apache::lonnet::metadata($url,'lastrevisiondate')< |
}
|
$starttime) { |
if ($env{'form.pagepath'}) {
|
$lastold=$prevvers; |
my (@pagepath)=split('&',$env{'form.pagepath'});
|
} |
$env{'form.pagename'}=&unescape(pop(@pagepath));
|
} |
$env{'form.folder'}=pop(@pagepath);
|
# |
$containertag = '<input type="hidden" name="pagepath" value="" />'.
|
# Code to figure out how many version entries should go in |
'<input type="hidden" name="pagesymb" value="" />';
|
# each of the four columns |
$uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
|
my $entries_per_col = 0; |
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
|
my $num_entries = ($currentversion-$lastold); |
}
|
if ($num_entries % 4 == 0) { |
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
|
$entries_per_col = $num_entries/4; |
$showdoc='/'.$1;
|
} else { |
}
|
$entries_per_col = $num_entries/4 + 1; |
unless ($showdoc) { # got called from remote
|
} |
if (($env{'form.folder'}=~/^(?:group|default)_/) ||
|
my $entries_count = 0; |
($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
|
$r->print('<td valign="top"><font size="-2">'); |
$forcestandard = 1;
|
my $cols_output = 1; |
}
|
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { |
$forcesupplement=($env{'form.folder'}=~/^supplemental_/);
|
my $url=$root.'.'.$prevvers.'.'.$extension; |
|
$r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url). |
if ($allowed) {
|
'">'.&mt('Version').' '.$prevvers.'</a> ('. |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
|
&Apache::lonlocal::locallocaltime( |
$script=&Apache::lonratedt::editscript('simple');
|
&Apache::lonnet::metadata($url, |
}
|
'lastrevisiondate') |
} else { # got called in sequence from course
|
). |
$allowed=0;
|
')'); |
}
|
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { |
|
$r->print(' <a href="/adm/diff?filename='. |
# get course data
|
&Apache::lonnet::clutter($root.'.'.$extension). |
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
|
'&versionone='.$prevvers. |
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
'">'.&mt('Diffs').'</a>'); |
|
} |
# get personal data
|
$r->print('</span><br />'); |
my $uname=$env{'user.name'};
|
if (++$entries_count % $entries_per_col == 0) { |
my $udom=$env{'user.domain'};
|
$r->print('</font></td>'); |
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
|
if ($cols_output != 4) { |
|
$r->print('<td valign="top"><font size="-2">'); |
# graphics settings
|
$cols_output++; |
|
} |
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
|
} |
|
} |
if ($allowed) {
|
while($cols_output++ < 4) { |
$script .= &editing_js($udom,$uname);
|
$r->print('</font></td><td><font>') |
}
|
} |
# -------------------------------------------------------------------- Body tag
|
$r->print('</font></td></tr>'."\n"); |
$script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
|
} |
my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
|
} |
$r->print(&Apache::loncommon::start_page("$type Documents", $script,
|
$r->print('</table></form>'); |
{'force_register' => $showdoc,
|
$r->print('<p class="LC_success">'.&mt('Done').'</p>'); |
'bread_crumbs' => $brcrum}).
|
|
&Apache::loncommon::help_open_menu('','',273,'RAT'));
|
&untiehash(); |
|
} |
my %allfiles = ();
|
|
my %codebase = ();
|
sub mark_hash_old { |
my ($upload_result,$upload_output);
|
my $retie_hash=0; |
if ($allowed) {
|
if ($hashtied) { |
if (($env{'form.uploaddoc.filename'}) &&
|
$retie_hash=1; |
($env{'form.cmd'}=~/^upload_(\w+)/)) {
|
&untiehash(); |
# Process file upload - phase one - upload and parse primary file.
|
} |
undef($hadchanges);
|
&tiehash('write'); |
$upload_result = &process_file_upload(\$upload_output,$coursenum,
|
$hash{'old'}=1; |
$coursedom,\%allfiles,
|
&untiehash(); |
\%codebase,$1);
|
if ($retie_hash) { &tiehash(); } |
if ($hadchanges) {
|
} |
&mark_hash_old();
|
|
}
|
sub is_hash_old { |
if ($upload_result eq 'phasetwo') {
|
my $untie_hash=0; |
$r->print($upload_output);
|
if (!$hashtied) { |
}
|
$untie_hash=1; |
} elsif ($env{'form.phasetwo'}) {
|
&tiehash(); |
my %newname = ();
|
} |
my %origname = ();
|
my $return=$hash{'old'}; |
my %attribs = ();
|
if ($untie_hash) { &untiehash(); } |
my $updateflag = 0;
|
return $return; |
my $residx = $env{'form.newidx'};
|
} |
my $primary_url = &unescape($env{'form.primaryurl'});
|
|
# Process file upload - phase two - gather secondary files.
|
sub changewarning { |
for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
|
my ($r,$postexec,$message,$url)=@_; |
if ($env{'form.embedded_item_'.$i.'.filename'}) {
|
if (!&is_hash_old()) { return; } |
my $javacodebase;
|
my $pathvar='folderpath'; |
$newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
|
my $path=&escape($env{'form.folderpath'}); |
$origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
|
if (!defined($url)) { |
if (exists($env{'form.embedded_codebase_'.$i})) {
|
if (defined($env{'form.pagepath'})) { |
$javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
|
$pathvar='pagepath'; |
$origname{$i} =~ s#^\Q$javacodebase\E/##;
|
$path=&escape($env{'form.pagepath'}); |
}
|
$path.='&pagesymb='.&escape($env{'form.pagesymb'}); |
my @attributes = ();
|
} |
if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
|
$url='/adm/coursedocs?'.$pathvar.'='.$path; |
@attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
|
} |
} else {
|
my $course_type = &Apache::loncommon::course_type(); |
@attributes = ($env{'form.embedded_attrib_'.$i});
|
if (!defined($message)) { |
}
|
$message='Changes will become active for your current session after [_1], or the next time you log in.'; |
foreach my $attr (@attributes) {
|
} |
push(@{$attribs{$i}},&unescape($attr));
|
$r->print("\n\n". |
}
|
'<script type="text/javascript">'."\n". |
if ($javacodebase) {
|
'// <![CDATA['."\n". |
$codebase{$i} = $javacodebase;
|
'function reinit(tf) { tf.submit();'.$postexec.' }'."\n". |
$codebase{$i} =~ s#/$##;
|
'// ]]>'."\n". |
$updateflag = 1;
|
'</script>'."\n". |
}
|
'<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'. |
}
|
'<input type="hidden" name="orgurl" value="'.$url. |
unless ($newname{$i} eq $origname{$i}) {
|
'" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'. |
$updateflag = 1;
|
&mt($message,' <input type="hidden" name="'. |
}
|
$env{'request.role'}.'" value="1" /><input type="button" value="'. |
}
|
&mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />'). |
# Process file upload - phase three - modify primary file
|
$help{'Caching'}.'</p></form>'."\n\n"); |
if ($updateflag) {
|
} |
my ($content,$rtncode);
|
|
my $updateflag = 0;
|
|
my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
|
sub init_breadcrumbs { |
if ($getstatus eq 'ok') {
|
my ($form,$text)=@_; |
foreach my $item (keys(%newname)) {
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
if ($newname{$item} ne $origname{$item}) {
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs", |
my $attrib_regexp = '';
|
text=>&Apache::loncommon::course_type().' Editor', |
if (@{$attribs{$item}} > 1) {
|
faq=>273, |
$attrib_regexp = join('|',@{$attribs{$item}});
|
bug=>'Instructor Interface', |
} else {
|
help => 'Docs_Adding_Course_Doc'}); |
$attrib_regexp = $attribs{$item}[0];
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1', |
}
|
text=>$text, |
if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
|
faq=>273, |
}
|
bug=>'Instructor Interface'}); |
$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
|
} |
}
|
|
if (exists($codebase{$item})) {
|
# subroutine to list form elements |
$content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
|
sub create_list_elements { |
}
|
my @formarr = @_; |
}
|
my $list = ''; |
# Save edited file.
|
for my $button (@formarr){ |
my $saveresult;
|
for my $picture(keys %$button) { |
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
|
$list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); |
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
|
} |
my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
|
} |
} else {
|
return $list; |
&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'}); |
unless ($showdoc || $upload_result eq 'phasetwo') {
|
return $ul; |
# -----------------------------------------------------------------------------
|
} |
my %lt=&Apache::lonlocal::texthash(
|
|
'uplm' => 'Upload a new main '.lc($type).' document',
|
# |
'upls' => 'Upload a new supplemental '.lc($type).' document',
|
# Start tabs |
'impp' => 'Import a document',
|
# |
'pubd' => 'Published Documents',
|
|
'copm' => 'All documents out of a published map into this folder',
|
sub startContentScreen { |
'upld' => 'Upload Document',
|
my ($r,$mode)=@_; |
'srch' => 'Search',
|
$r->print('<ul class="LC_TabContentBigger" id="mainnav">'); |
'impo' => 'Import',
|
$r->print('<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'); |
'book' => 'Import Bookmarks',
|
|
'selm' => 'Select Map',
|
my $active = ''; |
'load' => 'Load Map',
|
# does this user have privileges to modify docs? |
'reco' => 'Recover Deleted Resources',
|
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
'newf' => 'New Folder',
|
|
'newp' => 'New Composite Page',
|
my $onclick; |
'extr' => 'External Resource',
|
my $href; |
'syll' => 'Syllabus',
|
|
'navc' => 'Navigate Contents',
|
if ($allowed) { |
'sipa' => 'Simple Page',
|
$r->print('<li '.(($mode eq 'docs')?' class="active"':''). |
'sipr' => 'Simple Problem',
|
' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'); |
'drbx' => 'Drop Box',
|
} |
'scuf' => 'Score Upload Form',
|
$r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'); |
'bull' => 'Bulletin Board',
|
$r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'); |
'mypi' => 'My Personal Info',
|
$r->print('<li '.(($mode eq 'supdocs')?' class="active"':''). |
'grpo' => 'Group Files',
|
'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Documents').'</b></a></li>'); |
'rost' => 'Course Roster',
|
$r->print('</ul>'); |
'abou' => 'About User',
|
$r->print('<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">' |
'imsf' => 'Import IMS package',
|
.'<div id="maincoursedoc" style="margin:0 0;padding:0 0">'); |
'file' => 'File',
|
$r->print('<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">'); |
'title' => 'Title',
|
} |
'comment' => 'Comment',
|
|
'parse' => 'Upload embedded images/multimedia files if HTML file!',
|
# |
'nd' => 'New Document',
|
# End tabs |
'pm' => 'Published Map',
|
# |
'sd' => 'Special Document',
|
|
'mo' => 'More Options',
|
sub endContentScreen { |
'hao' => 'Hide all Options'
|
my ($r)=@_; |
);
|
$r->print('</div></div></div>'); |
# -----------------------------------------------------------------------------
|
} |
my $fileupload=(<<FIUP);
|
|
$lt{'file'}:<br />
|
sub supplemental_base { |
<input type="file" name="uploaddoc" size="40" />
|
return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Documents')); |
FIUP
|
} |
|
|
my $checkbox=(<<CHBO);
|
sub handler { |
<!-- <label>$lt{'parse'}?
|
my $r = shift; |
<input type="checkbox" name="parserflag" />
|
&Apache::loncommon::content_type($r,'text/html'); |
</label> -->
|
$r->send_http_header; |
<label>
|
return OK if $r->header_only; |
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
|
my $crstype = &Apache::loncommon::course_type(); |
</label>
|
|
CHBO
|
# |
|
# --------------------------------------------- Initialize help topics for this |
my $fileuploadform=(<<FUFORM);
|
foreach my $topic ('Adding_Course_Doc','Main_Course_Documents', |
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
'Adding_External_Resource','Navigate_Content', |
$fileupload
|
'Adding_Folders','Docs_Overview', 'Load_Map', |
<br />
|
'Supplemental','Score_Upload_Form','Adding_Pages', |
$lt{'title'}:<br />
|
'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', |
<input type="text" size="50" name="comment" />
|
'Check_Resource_Versions','Verify_Content') { |
$uploadtag
|
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic); |
<input type="hidden" name="cmd" value="upload_default" />
|
} |
<br />
|
# Composite help files |
<span class="LC_nobreak">
|
$help{'Syllabus'} = &Apache::loncommon::help_open_topic( |
$checkbox
|
'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); |
</span>
|
$help{'Simple Page'} = &Apache::loncommon::help_open_topic( |
<br />
|
'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); |
<br />
|
$help{'Simple Problem'} = &Apache::loncommon::help_open_topic( |
<span class="LC_nobreak">
|
'Option_Response_Simple'); |
<input type="submit" value="$lt{'upld'}" />
|
$help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( |
$help{'Uploading_From_Harddrive'}
|
'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); |
</span>
|
$help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic( |
</form>
|
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); |
FUFORM
|
$help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files'); |
|
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); |
my $simpleeditdefaultform=(<<SEDFFORM);
|
|
<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
|
# does this user have privileges to modify docs |
$lt{'pubd'}<br />
|
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); |
$uploadtag
|
if ($allowed && $env{'form.verify'}) { |
<input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
|
&init_breadcrumbs('verify','Verify Content'); |
<br />
|
&verifycontent($r); |
<span class="LC_nobreak">
|
} elsif ($allowed && $env{'form.listsymbs'}) { |
<input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
|
&init_breadcrumbs('listsymbs','List Symbs'); |
$help{'Importing_LON-CAPA_Resource'}
|
&list_symbs($r); |
</span>
|
} elsif ($allowed && $env{'form.docslog'}) { |
<br />
|
&init_breadcrumbs('docslog','Show Log'); |
<input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
|
&docs_change_log($r); |
<hr />
|
} elsif ($allowed && $env{'form.versions'}) { |
<p>
|
&init_breadcrumbs('versions','Check/Set Resource Versions'); |
$lt{'copm'}<br />
|
&checkversions($r); |
<input type="text" size="40" name="importmap" /><br />
|
} elsif ($allowed && $env{'form.dumpcourse'}) { |
<span class="LC_nobreak"><input type="button"
|
&init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Documents to Construction Space'); |
onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
|
&dumpcourse($r); |
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
|
} elsif ($allowed && $env{'form.exportcourse'}) { |
$help{'Load_Map'}</span>
|
&init_breadcrumbs('exportcourse','IMS Export'); |
</p>
|
&exportcourse($r); |
</form>
|
} else { |
SEDFFORM
|
# |
|
# Done catching special calls |
my $extresourcesform=(<<ERFORM);
|
# The whole rest is for course and supplemental documents |
<form action="/adm/coursedocs" method="post" name="newext">
|
# Get the parameters that may be needed |
$uploadtag
|
# |
<input type="hidden" name="importdetail" value="" />
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
<span class="LC_nobreak">
|
['folderpath','pagepath', |
<input name="newext" type="button" onClick="javascript:makenewext('newext');"
|
'pagesymb','forcesupplement','forcestandard']); |
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
|
</span>
|
# standard=1: this is a "new-style" course with an uploaded map as top level |
</form>
|
# standard=2: this is a "old-style" course, and there is nothing we can do |
ERFORM
|
|
|
my $standard=($env{'request.course.uri'}=~/^\/uploaded\//); |
if ($allowed) {
|
|
&update_paste_buffer($coursenum,$coursedom);
|
# Decide whether this should display supplemental or main content |
my $dumpbut=&dumpbutton();
|
# supplementalflag=1: show supplemental documents |
my $exportbut=&exportbutton();
|
# supplementalflag=0: show standard documents |
my %lt=&Apache::lonlocal::texthash(
|
|
'vc' => 'Verify Content',
|
|
'cv' => 'Check/Set Resource Versions',
|
my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/); |
'ls' => 'List Symbs',
|
if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) { |
'sl' => 'Show Log'
|
$supplementalflag=0; |
);
|
} |
|
if ($env{'form.forcesupplement'}) { $supplementalflag=1; } |
my $folderpath=$env{'form.folderpath'};
|
if ($env{'form.forcestandard'}) { $supplementalflag=0; } |
if (!$folderpath) {
|
unless ($allowed) { $supplementalflag=1; } |
if ($env{'form.folder'} eq '' ||
|
unless ($standard) { $supplementalflag=1; } |
$env{'form.folder'} eq 'supplemental') {
|
|
$folderpath='default&'.
|
my $script=''; |
&escape(&mt('Main '.$type.' Documents'));
|
my $showdoc=0; |
}
|
my $addentries = {}; |
}
|
my $containertag; |
unless ($env{'form.pagepath'}) {
|
my $uploadtag; |
$containertag = '<input type="hidden" name="folderpath" value="" />';
|
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
|
# Where do we store these for when we come back? |
}
|
my $stored_folderpath='docs_folderpath'; |
$r->print(&generate_admin_options($containertag,$uploadtag,\%lt,\%help,\%env));
|
if ($supplementalflag) { |
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
|
$stored_folderpath='docs_sup_folderpath'; |
&mt('Editing the Table of Contents for your '.$type)));
|
} |
}
|
|
# --------------------------------------------------------- Standard documents
|
# No folderpath, no pagepath, see if we have something stored |
$r->print('<table class="LC_docs_documents">');
|
if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) { |
|
&Apache::loncommon::restore_course_settings($stored_folderpath, |
if (($standard) && ($allowed) && (!$forcesupplement)) {
|
{'folderpath' => 'scalar'}); |
$r->print('<tr><td class="LC_docs_document">');
|
} |
# '<h2>'.&mt('Main Course Documents').
|
|
# ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
|
# If we are not allowed to make changes, all we can see are supplemental docs |
my $folder=$env{'form.folder'};
|
if (!$allowed) { |
if ($folder eq '' || $folder eq 'supplemental') {
|
$env{'form.pagepath'}=''; |
$folder='default';
|
unless ($env{'form.folderpath'} =~ /^supplemental/) { |
$env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
|
$env{'form.folderpath'} = &supplemental_base(); |
$uploadtag = '<input type="hidden" name="folderpath" value="'.
|
} |
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
|
} |
}
|
# If we still not have a folderpath, see if we can resurrect at pagepath |
my $postexec='';
|
if (!$env{'form.folderpath'} && $allowed) { |
if ($folder eq 'default') {
|
&Apache::loncommon::restore_course_settings($stored_folderpath, |
$r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
|
{'pagepath' => 'scalar'}); |
} else {
|
} |
#$postexec='self.close();';
|
# Make the zeroth entry in supplemental docs page paths, so we can get to top level |
}
|
if ($env{'form.folderpath'} =~ /^supplemental_\d+/) { |
$hadchanges=0;
|
$env{'form.folderpath'} = &supplemental_base() |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
|
.'&'. |
$upload_output,$type);
|
$env{'form.folderpath'}; |
if ($error) {
|
} |
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
# If after all of this, we still don't have any paths, make them |
}
|
unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) { |
if ($hadchanges) {
|
if ($supplementalflag) { |
&mark_hash_old();
|
$env{'form.folderpath'}=&supplemental_base(); |
}
|
} else { |
&changewarning($r,$postexec);
|
$env{'form.folderpath'}='default'; |
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
} |
'.sequence';
|
} |
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
|
|
'.page';
|
# Store this |
my $container='sequence';
|
&Apache::loncommon::store_course_settings($stored_folderpath, |
if ($env{'form.pagepath'}) {
|
{'pagepath' => 'scalar', |
$container='page';
|
'folderpath' => 'scalar'}); |
}
|
|
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
|
if ($env{'form.folderpath'}) { |
|
my (@folderpath)=split('&',$env{'form.folderpath'}); |
|
$env{'form.foldername'}=&unescape(pop(@folderpath)); |
|
$env{'form.folder'}=pop(@folderpath); |
my $recoverform=(<<RFORM);
|
} |
<form action="/adm/groupsort" method="post" name="recover">
|
if ($env{'form.pagepath'}) { |
<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
|
my (@pagepath)=split('&',$env{'form.pagepath'}); |
</form>
|
$env{'form.pagename'}=&unescape(pop(@pagepath)); |
RFORM
|
$env{'form.folder'}=pop(@pagepath); |
|
$containertag = '<input type="hidden" name="pagepath" value="" />'. |
my $imspform=(<<IMSPFORM);
|
'<input type="hidden" name="pagesymb" value="" />'; |
<form action="/adm/imsimportdocs" method="post" name="ims">
|
$uploadtag = |
<input type="hidden" name="folder" value="$folder" />
|
'<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'. |
<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
|
'<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'. |
</form>
|
'<input type="hidden" name="folderpath" value="" />'; |
IMSPFORM
|
} else { |
|
my $folderpath=$env{'form.folderpath'}; |
my $newnavform=(<<NNFORM);
|
if (!$folderpath) { |
<form action="/adm/coursedocs" method="post" name="newnav">
|
if ($env{'form.folder'} eq '' || |
$uploadtag
|
$env{'form.folder'} eq 'supplemental') { |
<input type="hidden" name="importdetail"
|
$folderpath='default&'. |
value="$lt{'navc'}=/adm/navmaps" />
|
&escape(&mt('Main '.$crstype.' Documents')); |
<span class="LC_nobreak">
|
} |
<input name="newnav" type="submit" value="$lt{'navc'}" />
|
} |
$help{'Navigate_Content'}
|
$containertag = '<input type="hidden" name="folderpath" value="" />'; |
</span>
|
$uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />'; |
</form>
|
} |
NNFORM
|
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) { |
my $newsmppageform=(<<NSPFORM);
|
$showdoc='/'.$1; |
<form action="/adm/coursedocs" method="post" name="newsmppg">
|
} |
$uploadtag
|
if ($showdoc) { # got called in sequence from course |
<input type="hidden" name="importdetail" value="" />
|
$allowed=0; |
<span class="LC_nobreak">
|
} else { |
<input name="newsmppg" type="button" value="$lt{'sipa'}"
|
if ($allowed) { |
onClick="javascript:makesmppage();" /> $help{'Simple Page'}
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); |
</span>
|
$script=&Apache::lonratedt::editscript('simple'); |
</form>
|
} |
NSPFORM
|
} |
|
|
my $newsmpproblemform=(<<NSPROBFORM);
|
# get course data |
<form action="/adm/coursedocs" method="post" name="newsmpproblem">
|
my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'}; |
$uploadtag
|
my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
<input type="hidden" name="importdetail" value="" />
|
|
<span class="LC_nobreak">
|
# get personal data |
<input name="newsmpproblem" type="button" value="$lt{'sipr'}"
|
my $uname=$env{'user.name'}; |
onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
|
my $udom=$env{'user.domain'}; |
</span>
|
my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom)); |
</form>
|
|
|
# graphics settings |
NSPROBFORM
|
|
|
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/"); |
my $newdropboxform=(<<NDBFORM);
|
|
<form action="/adm/coursedocs" method="post" name="newdropbox">
|
if ($allowed) { |
$uploadtag
|
my @tabids; |
<input type="hidden" name="importdetail" value="" />
|
if ($supplementalflag) { |
<span class="LC_nobreak">
|
@tabids = ('002','ee2','ff2'); |
<input name="newdropbox" type="button" value="$lt{'drbx'}"
|
} else { |
onClick="javascript:makedropbox();" />
|
@tabids = ('aa1','bb1','cc1','ff1'); |
</span>
|
unless ($env{'form.pagepath'}) { |
</form>
|
unshift(@tabids,'001'); |
NDBFORM
|
push(@tabids,('dd1','ee1')); |
|
} |
my $newexuploadform=(<<NEXUFORM);
|
} |
<form action="/adm/coursedocs" method="post" name="newexamupload">
|
my $tabidstr = join("','",@tabids); |
$uploadtag
|
$script .= &editing_js($udom,$uname). |
<input type="hidden" name="importdetail" value="" />
|
&resize_contentdiv_js($tabidstr); |
<span class="LC_nobreak">
|
$addentries = { |
<input name="newexamupload" type="button" value="$lt{'scuf'}"
|
onload => "javascript:resize_contentdiv('contentscroll','1','1');", |
onClick="javascript:makeexamupload();" />
|
}; |
$help{'Score_Upload_Form'}
|
} |
</span>
|
# -------------------------------------------------------------------- Body tag |
</form>
|
$script = '<script type="text/javascript">'."\n" |
NEXUFORM
|
.'// <![CDATA['."\n" |
|
.$script."\n" |
my $newbulform=(<<NBFORM);
|
.'// ]]>'."\n" |
<form action="/adm/coursedocs" method="post" name="newbul">
|
.'</script>'."\n"; |
$uploadtag
|
|
<input type="hidden" name="importdetail" value="" />
|
# Breadcrumbs |
<span class="LC_nobreak">
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
<input name="newbulletin" type="button" value="$lt{'bull'}"
|
unless ($showdoc) { |
onClick="javascript:makebulboard();" />
|
&Apache::lonhtmlcommon::add_breadcrumb({ |
$help{'Bulletin Board'}
|
href=>"/adm/coursedocs",text=>"$crstype Contents"}); |
</span>
|
|
</form>
|
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script, |
NBFORM
|
{'force_register' => $showdoc, |
|
'add_entries' => $addentries, |
my $newaboutmeform=(<<NAMFORM);
|
}) |
<form action="/adm/coursedocs" method="post" name="newaboutme">
|
.&Apache::loncommon::help_open_menu('','',273,'RAT') |
$uploadtag
|
.&Apache::lonhtmlcommon::breadcrumbs( |
<input type="hidden" name="importdetail"
|
'Editing the Table of Contents for your '.$crstype, |
value="$plainname=/adm/$udom/$uname/aboutme" />
|
'Docs_Adding_Course_Doc') |
<span class="LC_nobreak">
|
); |
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
} else { |
$help{'My Personal Info'}
|
$r->print(&Apache::loncommon::start_page("$crstype documents",undef, |
</span>
|
{'force_register' => $showdoc,})); |
</form>
|
} |
NAMFORM
|
|
|
my %allfiles = (); |
my $newaboutsomeoneform=(<<NASOFORM);
|
my %codebase = (); |
<form action="/adm/coursedocs" method="post" name="newaboutsomeone">
|
my ($upload_result,$upload_output,$uploadphase); |
$uploadtag
|
if ($allowed) { |
<input type="hidden" name="importdetail" value="" />
|
if (($env{'form.uploaddoc.filename'}) && |
<span class="LC_nobreak">
|
($env{'form.cmd'}=~/^upload_(\w+)/)) { |
<input name="newaboutsomeone" type="button" value="$lt{'abou'}"
|
my $context = $1; |
onClick="javascript:makeabout();" />
|
# Process file upload - phase one - upload and parse primary file. |
</span>
|
undef($hadchanges); |
</form>
|
$uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom, |
NASOFORM
|
\%allfiles,\%codebase,$context); |
|
if ($hadchanges) { |
|
&mark_hash_old(); |
my $newrosterform=(<<NROSTFORM);
|
} |
<form action="/adm/coursedocs" method="post" name="newroster">
|
$r->print($upload_output); |
$uploadtag
|
} elsif ($env{'form.phase'} eq 'upload_embedded') { |
<input type="hidden" name="importdetail"
|
# Process file upload - phase two - upload embedded objects |
value="$lt{'rost'}=/adm/viewclasslist" />
|
$uploadphase = 'check_embedded'; |
<span class="LC_nobreak">
|
my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"'); |
<input name="newroster" type="submit" value="$lt{'rost'}" />
|
my $state = &embedded_form_elems($uploadphase,$primaryurl, |
$help{'Course Roster'}
|
$env{'form.newidx'}); |
</span>
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
</form>
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
NROSTFORM
|
my ($destination,$dir_root) = &embedded_destination(); |
|
my $url_root = '/uploaded/'.$docudom.'/'.$docuname; |
$r->print(<<ENDFORM);
|
my $actionurl = '/adm/coursedocs'; |
|
my ($result,$flag) = |
<ul class="LC_TabContent">
|
&Apache::loncommon::upload_embedded('coursedoc',$destination, |
<li>$lt{'nd'}</li>
|
$docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state, |
<li>$lt{'pm'}</li>
|
$actionurl); |
<li>$lt{'pubd'}</li>
|
$r->print($result.&return_to_editor()); |
<li>$lt{'sd'}</li>
|
} elsif ($env{'form.phase'} eq 'check_embedded') { |
<li>$lt{'mo'}</li>
|
# Process file upload - phase three - modify references in HTML file |
<li>$lt{'hao'}</li>
|
$uploadphase = 'modified_orightml'; |
</ul>
|
my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
<table class="LC_docs_adddocs">
|
my ($destination,$dir_root) = &embedded_destination(); |
<!-- <tr>
|
$r->print(&Apache::loncommon::modify_html_refs('coursedoc',$destination, |
<th>$lt{'uplm'}</th>
|
$docuname,$docudom,undef, |
<th>$lt{'impp'}</th>
|
$dir_root). |
<th>$lt{'spec'}</th>
|
&return_to_editor()); |
</tr> -->
|
} |
<tr>
|
} |
<td>
|
|
$fileuploadform
|
unless ($showdoc || $uploadphase) { |
</td>
|
# ----------------------------------------------------------------------------- |
<td>
|
my %lt=&Apache::lonlocal::texthash( |
$simpleeditdefaultform
|
'uplm' => 'Upload a new main '.lc($crstype).' document', |
<hr />
|
'upls' => 'Upload a new supplemental '.lc($crstype).' document', |
$recoverform
|
'impp' => 'Import a document', |
ENDFORM
|
'copm' => 'All documents out of a published map into this folder', |
unless ($env{'form.pagepath'}) {
|
'upld' => 'Import Document', |
$r->print(<<ENDFORM);
|
'srch' => 'Search', |
<hr />
|
'impo' => 'Import', |
$extresourcesform
|
'wish' => 'Import from Wishlist', |
<br />
|
'selm' => 'Select Map', |
$imspform
|
'load' => 'Load Map', |
ENDFORM
|
'reco' => 'Recover Deleted Documents', |
}
|
'newf' => 'New Folder', |
$r->print('</td><td>');
|
'newp' => 'New Composite Page', |
unless ($env{'form.pagepath'}) {
|
'extr' => 'External Resource', |
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
'syll' => 'Syllabus', |
|
'navc' => 'Table of Contents', |
|
'sipa' => 'Simple Course Page', |
|
'sipr' => 'Simple Problem', |
my $newpageform=(<<NPFORM);
|
'drbx' => 'Drop Box', |
<form action="/adm/coursedocs" method="post" name="newpage">
|
'scuf' => 'External Scores (handgrade, upload, clicker)', |
<input type="hidden" name="folderpath" value="$path" />
|
'bull' => 'Discussion Board', |
<input type="hidden" name="importdetail" value="" />
|
'mypi' => 'My Personal Information Page', |
<span class="LC_nobreak">
|
'grpo' => 'Group Portfolio', |
<input name="newpage" type="button"
|
'rost' => 'Course Roster', |
onClick="javascript:makenewpage(this.form,'$pageseq');"
|
'abou' => 'Personal Information Page for a User', |
value="$lt{'newp'}" />$help{'Adding_Pages'}
|
'imsf' => 'IMS Import', |
</span>
|
'imsl' => 'Import IMS package', |
</form>
|
'file' => 'File', |
NPFORM
|
'title' => 'Title', |
|
'comment' => 'Comment', |
my $newfolderform=(<<NFFORM);
|
'parse' => 'Upload embedded images/multimedia files if HTML file', |
<form action="/adm/coursedocs" method="post" name="newfolder">
|
'nd' => 'Upload Document', |
<input type="hidden" name="folderpath" value="$path" />
|
'pm' => 'Published Map', |
<input type="hidden" name="importdetail" value="" />
|
'sd' => 'Special Document', |
<span class="LC_nobreak">
|
'mo' => 'More Options', |
<input name="newfolder" type="button"
|
); |
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
# ----------------------------------------------------------------------------- |
value="$lt{'newf'}" />$help{'Adding_Folders'}
|
my $fileupload=(<<FIUP); |
</span>
|
$lt{'file'}:<br /> |
</form>
|
<input type="file" name="uploaddoc" size="40" /> |
NFFORM
|
FIUP |
|
|
my $newsylform=(<<NSYLFORM);
|
my $checkbox=(<<CHBO); |
<form action="/adm/coursedocs" method="post" name="newsyl">
|
<!-- <label>$lt{'parse'}? |
$uploadtag
|
<input type="checkbox" name="parserflag" /> |
<input type="hidden" name="importdetail"
|
</label> --> |
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
|
<label> |
<span class="LC_nobreak">
|
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'} |
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
</label> |
$help{'Syllabus'}
|
CHBO |
</span>
|
|
</form>
|
my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}"; |
NSYLFORM
|
my $fileuploadform=(<<FUFORM); |
|
<form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data"> |
my $newgroupfileform=(<<NGFFORM);
|
<input type="hidden" name="active" value="aa" /> |
<form action="/adm/coursedocs" method="post" name="newgroupfiles">
|
$fileupload |
$uploadtag
|
<br /> |
<input type="hidden" name="importdetail"
|
$lt{'title'}:<br /> |
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
|
<input type="text" size="60" name="comment" /> |
<span class="LC_nobreak">
|
$uploadtag |
<input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
|
<input type="hidden" name="cmd" value="upload_default" /> |
$help{'Group Files'}
|
<br /> |
</span>
|
<span class="LC_nobreak" style="float:left"> |
</form>
|
$checkbox |
NGFFORM
|
</span> |
|
FUFORM |
|
$fileuploadform .= $fileuploada.'</form>'; |
$r->print(<<ENDFORM);
|
|
<br />
|
my $simpleeditdefaultform=(<<SEDFFORM); |
$newfolderform
|
<form action="/adm/coursedocs" method="post" name="simpleeditdefault"> |
<br />
|
<input type="hidden" name="active" value="bb" /> |
$newpageform
|
SEDFFORM |
<br />
|
my @simpleeditdefaultforma = ( |
$newsylform
|
{ '<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>" }, |
<br />
|
{ '<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'}" }, |
$newnavform
|
{ '<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>" }, |
<br />
|
); |
$newsmppageform
|
$simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma)); |
<br />
|
$simpleeditdefaultform .=(<<SEDFFORM); |
$newsmpproblemform
|
<hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" /> |
<br />
|
$lt{'copm'}<br /> |
$newdropboxform
|
<input type="text" size="40" name="importmap" /><br /> |
<br />
|
<span class="LC_nobreak" style="float:left"><input type="button" |
$newexuploadform
|
onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')" |
<br />
|
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" /> |
$newbulform
|
$help{'Load_Map'}</span> |
<br />
|
</form> |
$newaboutmeform
|
SEDFFORM |
<br />
|
|
$newaboutsomeoneform
|
my $extresourcesform=(<<ERFORM); |
<br />
|
<form action="/adm/coursedocs" method="post" name="newext"> |
$newgroupfileform
|
$uploadtag |
<br />
|
<input type="hidden" name="importdetail" value="" /> |
$newrosterform
|
<a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'} |
ENDFORM
|
</form> |
}
|
ERFORM |
if ($env{'form.pagepath'}) {
|
|
$r->print(<<ENDBLOCK);
|
|
$newsmpproblemform
|
if ($allowed) { |
<br />
|
&update_paste_buffer($coursenum,$coursedom); |
$newexuploadform
|
my %lt=&Apache::lonlocal::texthash( |
ENDBLOCK
|
'vc' => 'Verify Content', |
}
|
'cv' => 'Check/Set Resource Versions', |
$r->print('</td></tr>'."\n".
|
'ls' => 'List Symbs', |
'</table>');
|
'sl' => 'Show Log' |
$r->print('</td></tr>');
|
); |
}
|
|
# ----------------------------------------------------- Supplemental documents
|
$r->print(<<HIDDENFORM); |
if (!$forcestandard) {
|
<form name="renameform" method="post" action="/adm/coursedocs"> |
$r->print('<tr><td class="LC_docs_document">');
|
<input type="hidden" name="title" /> |
# '<h2>'.&mt('Supplemental Course Documents').
|
<input type="hidden" name="cmd" /> |
# ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
|
<input type="hidden" name="markcopy" /> |
my $folder=$env{'form.folder'};
|
<input type="hidden" name="copyfolder" /> |
unless ($folder=~/^supplemental/) {
|
$containertag |
$folder='supplemental';
|
</form> |
}
|
<form name="simpleedit" method="post" action="/adm/coursedocs"> |
if ($folder =~ /^supplemental$/ &&
|
<input type="hidden" name="importdetail" value="" /> |
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
|
$uploadtag |
$env{'form.folderpath'} = 'supplemental&'.
|
</form> |
&escape(&mt('Supplemental '.$type.' Documents'));
|
HIDDENFORM |
}
|
} |
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
|
|
if ($error) {
|
# Generate the tabs |
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
|
&startContentScreen($r,($supplementalflag?'supdocs':'docs')); |
}
|
|
if ($allowed) {
|
|
my $folderseq=
|
# |
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
|
|
'.sequence';
|
my $savefolderpath; |
|
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
|
if ($allowed) { |
|
my $folder=$env{'form.folder'}; |
my $supupdocform=(<<SUPDOCFORM);
|
if ($folder eq '' || $supplementalflag) { |
<form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
|
$folder='default'; |
$fileupload
|
$savefolderpath = $env{'form.folderpath'}; |
<br />
|
$env{'form.folderpath'}='default&'.&escape(&mt('Content')); |
<br />
|
$uploadtag = '<input type="hidden" name="folderpath" value="'. |
<span class="LC_nobreak">
|
&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'; |
$checkbox
|
} |
</span>
|
my $postexec=''; |
<br /><br />
|
if ($folder eq 'default') { |
$lt{'comment'}:<br />
|
$r->print('<script type="text/javascript">'."\n" |
<textarea cols=50 rows=4 name='comment'>
|
.'// <![CDATA['."\n" |
</textarea>
|
.'this.window.name="loncapaclient";'."\n" |
<br />
|
.'// ]]>'."\n" |
<input type="hidden" name="folderpath" value="$path" />
|
.'</script>'."\n" |
<input type="hidden" name="cmd" value="upload_supplemental" />
|
); |
<span class="LC_nobreak">
|
} else { |
<input type="submit" value="$lt{'upld'}" />
|
#$postexec='self.close();'; |
$help{'Uploading_From_Harddrive'}
|
} |
</span>
|
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
</form>
|
'.sequence'; |
SUPDOCFORM
|
my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. |
|
'.page'; |
my $supnewfolderform=(<<SNFFORM);
|
my $container='sequence'; |
<form action="/adm/coursedocs" method="post" name="supnewfolder">
|
if ($env{'form.pagepath'}) { |
<input type="hidden" name="folderpath" value="$path" />
|
$container='page'; |
<input type="hidden" name="importdetail" value="" />
|
} |
<span class="LC_nobreak">
|
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container; |
<input name="newfolder" type="button"
|
|
onClick="javascript:makenewfolder(this.form,'$folderseq');"
|
|
value="$lt{'newf'}" /> $help{'Adding_Folders'}
|
|
</span>
|
my $recoverform=(<<RFORM); |
</form>
|
<form action="/adm/groupsort" method="post" name="recover"> |
SNFFORM
|
<a class="LC_menubuttons_link" href="javascript:groupopen('$readfile',1)">$lt{'reco'}</a> |
|
</form> |
|
RFORM |
my $supnewextform=(<<SNEFORM);
|
|
<form action="/adm/coursedocs" method="post" name="supnewext">
|
my $imspform=(<<IMSPFORM); |
<input type="hidden" name="folderpath" value="$path" />
|
<form action="/adm/imsimportdocs" method="post" name="ims"> |
<input type="hidden" name="importdetail" value="" />
|
<input type="hidden" name="folder" value="$folder" /> |
<span class="LC_nobreak">
|
<a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a> |
<input name="newext" type="button"
|
</form> |
onClick="javascript:makenewext('supnewext');"
|
IMSPFORM |
value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
|
|
</span>
|
my $newnavform=(<<NNFORM); |
</form>
|
<form action="/adm/coursedocs" method="post" name="newnav"> |
SNEFORM
|
<input type="hidden" name="active" value="cc" /> |
|
$uploadtag |
my $supnewsylform=(<<SNSFORM);
|
<input type="hidden" name="importdetail" |
<form action="/adm/coursedocs" method="post" name="supnewsyl">
|
value="$lt{'navc'}=/adm/navmaps" /> |
<input type="hidden" name="folderpath" value="$path" />
|
<a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a> |
<input type="hidden" name="importdetail"
|
$help{'Navigate_Content'} |
value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
|
</form> |
<span class="LC_nobreak">
|
NNFORM |
<input name="newsyl" type="submit" value="$lt{'syll'}" />
|
my $newsmppageform=(<<NSPFORM); |
$help{'Syllabus'}
|
<form action="/adm/coursedocs" method="post" name="newsmppg"> |
</span>
|
<input type="hidden" name="active" value="cc" /> |
</form>
|
$uploadtag |
SNSFORM
|
<input type="hidden" name="importdetail" value="" /> |
|
<a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a> |
my $supnewaboutmeform=(<<SNAMFORM);
|
$help{'Simple Page'} |
<form action="/adm/coursedocs" method="post" name="subnewaboutme">
|
</form> |
<input type="hidden" name="folderpath" value="$path" />
|
NSPFORM |
<input type="hidden" name="importdetail"
|
|
value="$plainname=/adm/$udom/$uname/aboutme" />
|
my $newsmpproblemform=(<<NSPROBFORM); |
<span class="LC_nobreak">
|
<form action="/adm/coursedocs" method="post" name="newsmpproblem"> |
<input name="newaboutme" type="submit" value="$lt{'mypi'}" />
|
<input type="hidden" name="active" value="cc" /> |
$help{'My Personal Info'}
|
$uploadtag |
</span>
|
<input type="hidden" name="importdetail" value="" /> |
</form>
|
<a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a> |
SNAMFORM
|
$help{'Simple Problem'} |
|
</form> |
$r->print(<<ENDSUPFORM);
|
|
<ul class="LC_TabContent">
|
NSPROBFORM |
<li>$lt{'nd'}</li>
|
|
<li>$lt{'sd'}</li>
|
my $newdropboxform=(<<NDBFORM); |
<li>$lt{'hao'}</li>
|
<form action="/adm/coursedocs" method="post" name="newdropbox"> |
</ul>
|
<input type="hidden" name="active" value="cc" /> |
<table class="LC_docs_adddocs">
|
$uploadtag |
<tr><td>
|
<input type="hidden" name="importdetail" value="" /> |
$supupdocform
|
<a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a> |
</td>
|
</form> |
<td>
|
NDBFORM |
$supnewfolderform
|
|
<br />
|
my $newexuploadform=(<<NEXUFORM); |
$supnewextform
|
<form action="/adm/coursedocs" method="post" name="newexamupload"> |
<br />
|
<input type="hidden" name="active" value="cc" /> |
$supnewsylform
|
$uploadtag |
<br />
|
<input type="hidden" name="importdetail" value="" /> |
$supnewaboutmeform
|
<a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a> |
</td></tr>
|
$help{'Score_Upload_Form'} |
</table></td></tr>
|
</form> |
ENDSUPFORM
|
NEXUFORM |
}
|
|
}
|
my $newbulform=(<<NBFORM); |
$r->print('</table>');
|
<form action="/adm/coursedocs" method="post" name="newbul"> |
if ($allowed) {
|
<input type="hidden" name="active" value="cc" /> |
$r->print('
|
$uploadtag |
<form method="post" name="extimport" action="/adm/coursedocs">
|
<input type="hidden" name="importdetail" value="" /> |
<input type="hidden" name="title" />
|
<a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a> |
<input type="hidden" name="url" />
|
$help{'Bulletin Board'} |
<input type="hidden" name="useform" />
|
</form> |
<input type="hidden" name="residx" />
|
NBFORM |
</form>');
|
|
}
|
my $newaboutmeform=(<<NAMFORM); |
} else {
|
<form action="/adm/coursedocs" method="post" name="newaboutme"> |
unless ($upload_result eq 'phasetwo') {
|
<input type="hidden" name="active" value="cc" /> |
# -------------------------------------------------------- This is showdoc mode
|
$uploadtag |
$r->print("<h1>".&mt('Uploaded Document').' - '.
|
<input type="hidden" name="importdetail" |
&Apache::lonnet::gettitle($r->uri).'</h1><p>'.
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
|
<a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a> |
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
|
$help{'My Personal Information Page'} |
}
|
</form> |
}
|
NAMFORM |
}
|
|
$r->print(&Apache::loncommon::end_page());
|
my $newaboutsomeoneform=(<<NASOFORM); |
return OK;
|
<form action="/adm/coursedocs" method="post" name="newaboutsomeone"> |
}
|
<input type="hidden" name="active" value="cc" /> |
|
$uploadtag |
sub generate_admin_options {
|
<input type="hidden" name="importdetail" value="" /> |
my ($containertag,$uploadtag,$lt_ref,$help_ref,$env_ref) = @_;
|
<a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a> |
my %lt = %{$lt_ref};
|
</form> |
my %help = %{$help_ref};
|
NASOFORM |
my %env = %{$env_ref};
|
|
my $dumpbut=&dumpbutton();
|
|
my $exportbut=&exportbutton();
|
my $newrosterform=(<<NROSTFORM); |
return (<<ENDOPTIONFORM);
|
<form action="/adm/coursedocs" method="post" name="newroster"> |
<form name="renameform" method="post" action="/adm/coursedocs">
|
<input type="hidden" name="active" value="cc" /> |
<input type="hidden" name="title" />
|
$uploadtag |
<input type="hidden" name="cmd" />
|
<input type="hidden" name="importdetail" |
<input type="hidden" name="markcopy" />
|
value="$lt{'rost'}=/adm/viewclasslist" /> |
<input type="hidden" name="copyfolder" />
|
<a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a> |
$containertag
|
$help{'Course Roster'} |
</form>
|
</form> |
<form name="simpleedit" method="post" action="/adm/coursedocs">
|
NROSTFORM |
<input type="hidden" name="importdetail" value="" />
|
|
$uploadtag
|
my $specialdocumentsform; |
</form>
|
my @specialdocumentsforma; |
<form action="/adm/coursedocs" method="post" name="courseverify">
|
my $gradingform; |
<ul style="list-style-type:none">
|
my @gradingforma; |
<li>
|
my $communityform; |
<input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
|
my @communityforma; |
</li>
|
my $newfolderform; |
<li>
|
my $newfolderb; |
<input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
|
|
</li>
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
<li>
|
|
$dumpbut
|
my $newpageform=(<<NPFORM); |
</li>
|
<form action="/adm/coursedocs" method="post" name="newpage"> |
<li>
|
<input type="hidden" name="folderpath" value="$path" /> |
$exportbut
|
<input type="hidden" name="importdetail" value="" /> |
</li>
|
<input type="hidden" name="active" value="cc" /> |
<li>
|
<a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a> |
<input type="submit" name="listsymbs" value="$lt{'ls'}" />
|
$help{'Adding_Pages'} |
</li>
|
</form> |
<li>
|
NPFORM |
<input type="hidden" name="folder" value="$env{'form.folder'}" />
|
|
<input type="submit" name="docslog" value="$lt{'sl'}" />
|
|
</li>
|
$newfolderform=(<<NFFORM); |
</ul>
|
<form action="/adm/coursedocs" method="post" name="newfolder"> |
</form>
|
<input type="hidden" name="folderpath" value="$path" /> |
<div style="clear: both; height: 0px;"> </div>
|
<input type="hidden" name="importdetail" value="" /> |
ENDOPTIONFORM
|
<input type="hidden" name="active" value="aa" /> |
}
|
<a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'} |
|
</form> |
sub generate_edit_table {
|
NFFORM |
my ($optionhash_ref,$namehash_ref,$orderhash_ref) = @_;
|
|
my %optionhash = %{$optionhash_ref}; #id verlinkt mit inhalt
|
my $newsylform=(<<NSYLFORM); |
my %namehash = %{$namehash_ref}; #name verlinkt mit id
|
<form action="/adm/coursedocs" method="post" name="newsyl"> |
my %orderhash = %{$orderhash_ref}; #name mit kürzel verlinkt mit name
|
<input type="hidden" name="active" value="cc" /> |
my $form;
|
$uploadtag |
$form = '<div class="LC_ContentBoxSpecial"><h4 class="LC_hcell">'.&mt('Upload Course Documents').'<h4>';
|
<input type="hidden" name="importdetail" |
$form .= '<ul class="LC_TabContent">';
|
value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" /> |
foreach my $name (sort(keys(%orderhash))){
|
<a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a> |
if($name eq 'zz_hide'){
|
$help{'Syllabus'} |
$form .= '<li><a onclick="hideAllSection();" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
|
}else{
|
</form> |
$form .= '<li><a onclick="popUpSection(\''.$namehash{$orderhash{$name}}.'\');" href="#">'.&mt($orderhash{$name}).'</a></li>';
|
NSYLFORM |
}
|
|
}
|
my $newgroupfileform=(<<NGFFORM); |
foreach my $field (keys(%optionhash)){
|
<form action="/adm/coursedocs" method="post" name="newgroupfiles"> |
$form .= '<div id="'.$field.'" class="LC_ContentBox LC_hideThis">'.$optionhash{$field}.'</div>';
|
<input type="hidden" name="active" value="cc" /> |
}
|
$uploadtag |
$form .= '</div>';
|
<input type="hidden" name="importdetail" |
return $form;
|
value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" /> |
}
|
<a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a> |
|
$help{'Group Portfolio'} |
sub editing_js {
|
</form> |
my ($udom,$uname) = @_;
|
NGFFORM |
my $now = time();
|
@specialdocumentsforma=( |
my %lt = &Apache::lonlocal::texthash(
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/page.png" alt="'.$lt{newp}.'" onclick="javascript:makenewpage(document.newpage,\''.$pageseq.'\');" />'=>$newpageform}, |
p_mnf => 'Name of New Folder',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform}, |
t_mnf => 'New Folder',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform}, |
p_mnp => 'Name of New Page',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform}, |
t_mnp => 'New Page',
|
); |
p_mxu => 'Title for the Uploaded Score',
|
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma)); |
p_msp => 'Title for the Page',
|
|
p_msb => 'Title for the Problem',
|
|
p_mdb => 'Title for the Drop Box',
|
my @importdoc = ( |
p_mbb => 'Title for the Bulletin Board',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform}, |
p_mab => "Enter user:domain for User's 'About Me' Page",
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},); |
p_mab2 => "About [_99]",
|
$fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform; |
p_mab_alrt1 => 'Not a valid user:domain',
|
|
p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
|
@gradingforma=( |
p_chn => 'New Title',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform}, |
p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform}, |
p_rmr2a => 'Remove[_99]',
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform}, |
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.',
|
$gradingform = &create_form_ul(&create_list_elements(@gradingforma)); |
p_ctr2a => 'Cut[_98]',
|
|
p_ctr2b => '?[_98]'
|
@communityforma=( |
);
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform}, |
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform}, |
return <<ENDNEWSCRIPT;
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform}, |
function makenewfolder(targetform,folderseq) {
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform}, |
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform}, |
if (foldername) {
|
); |
targetform.importdetail.value=escape(foldername)+"="+folderseq;
|
$communityform = &create_form_ul(&create_list_elements(@communityforma)); |
targetform.submit();
|
|
}
|
|
}
|
|
|
my @tools = ( |
function makenewpage(targetform,folderseq) {
|
# {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" />'=>$extresourcesform}, |
var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
|
# {'<img class="LC_noBorder LC_middle" align="left" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" />'=>$imspform}, |
if (pagename) {
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/recover.png" alt="'.$lt{reco}.'" onclick="javascript:groupopen(\''.$readfile.'\',1)" />'=>$recoverform}, |
targetform.importdetail.value=escape(pagename)+"="+folderseq;
|
); |
targetform.submit();
|
|
}
|
my %orderhash = ( |
}
|
'aa' => ['Import Documents',$fileuploadform], |
|
'bb' => ['Published Resources',$simpleeditdefaultform], |
function makenewext(targetname) {
|
'cc' => ['Grading Resources',$gradingform], |
this.document.forms.extimport.useform.value=targetname;
|
'ff' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)], |
this.document.forms.extimport.title.value='';
|
); |
this.document.forms.extimport.url.value='';
|
unless ($env{'form.pagepath'}) { |
this.document.forms.extimport.residx.value='';
|
$orderhash{'00'} = ['Newfolder',$newfolderform]; |
window.open('/adm/rat/extpickframe.html');
|
$orderhash{'dd'} = ['Community Resources',$communityform]; |
}
|
$orderhash{'ee'} = ['Special Documents',$specialdocumentsform]; |
|
} |
function edittext(targetname,residx,title,url) {
|
|
this.document.forms.extimport.useform.value=targetname;
|
$hadchanges=0; |
this.document.forms.extimport.residx.value=residx;
|
unless ($supplementalflag) { |
this.document.forms.extimport.url.value=url;
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
this.document.forms.extimport.title.value=title;
|
$supplementalflag,\%orderhash); |
window.open('/adm/rat/extpickframe.html');
|
if ($error) { |
}
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
|
} |
function makeexamupload() {
|
if ($hadchanges) { |
var title=prompt('$lt{"p_mxu"}');
|
&mark_hash_old(); |
if (title) {
|
} |
this.document.forms.newexamupload.importdetail.value=
|
|
escape(title)+'=/res/lib/templates/examupload.problem';
|
&changewarning($r,''); |
this.document.forms.newexamupload.submit();
|
} |
}
|
} |
}
|
|
|
# Supplemental documents start here |
function makesmppage() {
|
|
var title=prompt('$lt{"p_msp"}');
|
my $folder=$env{'form.folder'}; |
if (title) {
|
unless ($supplementalflag) { |
this.document.forms.newsmppg.importdetail.value=
|
$folder='supplemental'; |
escape(title)+'=/adm/$udom/$uname/$now/smppg';
|
} |
this.document.forms.newsmppg.submit();
|
if ($folder =~ /^supplemental$/ && |
}
|
(($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) { |
}
|
$env{'form.folderpath'} = &supplemental_base(); |
|
} elsif ($allowed) { |
function makesmpproblem() {
|
$env{'form.folderpath'} = $savefolderpath; |
var title=prompt('$lt{"p_msb"}');
|
} |
if (title) {
|
$env{'form.pagepath'} = ''; |
this.document.forms.newsmpproblem.importdetail.value=
|
if ($allowed) { |
escape(title)+'=/res/lib/templates/simpleproblem.problem';
|
my $folderseq= |
this.document.forms.newsmpproblem.submit();
|
'/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time. |
}
|
'.sequence'; |
}
|
|
|
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
function makedropbox() {
|
|
var title=prompt('$lt{"p_mdb"}');
|
my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}"; |
if (title) {
|
my $supupdocform=(<<SUPDOCFORM); |
this.document.forms.newdropbox.importdetail.value=
|
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data"> |
escape(title)+'=/res/lib/templates/DropBox.problem';
|
<input type="hidden" name="active" value="ee" /> |
this.document.forms.newdropbox.submit();
|
$fileupload |
}
|
<br /> |
}
|
<br /> |
|
<span class="LC_nobreak"> |
function makebulboard() {
|
$checkbox |
var title=prompt('$lt{"p_mbb"}');
|
</span> |
if (title) {
|
<br /><br /> |
this.document.forms.newbul.importdetail.value=
|
$lt{'comment'}:<br /> |
escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
|
<textarea cols="50" rows="4" name="comment"></textarea> |
this.document.forms.newbul.submit();
|
<br /> |
}
|
<input type="hidden" name="folderpath" value="$path" /> |
}
|
<input type="hidden" name="cmd" value="upload_supplemental" /> |
|
SUPDOCFORM |
function makeabout() {
|
$supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>"; |
var user=prompt("$lt{'p_mab'}");
|
|
if (user) {
|
my $supnewfolderform=(<<SNFFORM); |
var comp=new Array();
|
<form action="/adm/coursedocs" method="post" name="supnewfolder"> |
comp=user.split(':');
|
<input type="hidden" name="active" value="ee" /> |
if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
|
<input type="hidden" name="folderpath" value="$path" /> |
if ((comp[0]) && (comp[1])) {
|
<input type="hidden" name="importdetail" value="" /> |
this.document.forms.newaboutsomeone.importdetail.value=
|
<a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> |
'$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
|
$help{'Adding_Folders'} |
this.document.forms.newaboutsomeone.submit();
|
</form> |
} else {
|
SNFFORM |
alert("$lt{'p_mab_alrt1'}");
|
|
}
|
|
} else {
|
my $supnewextform=(<<SNEFORM); |
alert("$lt{'p_mab_alrt2'}");
|
<form action="/adm/coursedocs" method="post" name="supnewext"> |
}
|
<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'} |
function makeims() {
|
</form> |
var caller = document.forms.ims.folder.value;
|
SNEFORM |
var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
|
|
newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
|
my $supnewsylform=(<<SNSFORM); |
newWindow.location.href = newlocation;
|
<form action="/adm/coursedocs" method="post" name="supnewsyl"> |
}
|
<input type="hidden" name="active" value="ff" /> |
|
<input type="hidden" name="folderpath" value="$path" /> |
|
<input type="hidden" name="importdetail" |
function finishpick() {
|
value="Syllabus=/public/$coursedom/$coursenum/syllabus" /> |
var title=this.document.forms.extimport.title.value;
|
<a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a> |
var url=this.document.forms.extimport.url.value;
|
$help{'Syllabus'} |
var form=this.document.forms.extimport.useform.value;
|
</form> |
var residx=this.document.forms.extimport.residx.value;
|
SNSFORM |
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"> |
function changename(folderpath,index,oldtitle,container,pagesymb) {
|
<input type="hidden" name="active" value="ff" /> |
var title=prompt('$lt{"p_chn"}',oldtitle);
|
<input type="hidden" name="folderpath" value="$path" /> |
if (title) {
|
<input type="hidden" name="importdetail" |
this.document.forms.renameform.markcopy.value=-1;
|
value="$plainname=/adm/$udom/$uname/aboutme" /> |
this.document.forms.renameform.title.value=title;
|
<a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a> |
this.document.forms.renameform.cmd.value='rename_'+index;
|
$help{'My Personal Information Page'} |
if (container == 'sequence') {
|
</form> |
this.document.forms.renameform.folderpath.value=folderpath;
|
SNAMFORM |
}
|
|
if (container == 'page') {
|
|
this.document.forms.renameform.pagepath.value=folderpath;
|
my @specialdocs = ( |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />' |
}
|
=>$supnewsylform}, |
this.document.forms.renameform.submit();
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />' |
}
|
=>$supnewaboutmeform}, |
}
|
); |
|
my @supimportdoc = ( |
function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />' |
if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
|
=>$supnewextform}, |
this.document.forms.renameform.markcopy.value=-1;
|
); |
this.document.forms.renameform.cmd.value='del_'+index;
|
$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform; |
if (container == 'sequence') {
|
my %suporderhash = ( |
this.document.forms.renameform.folderpath.value=folderpath;
|
'00' => ['Supnewfolder', $supnewfolderform], |
}
|
'ee' => ['Import Documents',$supupdocform], |
if (container == 'page') {
|
'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))] |
this.document.forms.renameform.pagepath.value=folderpath;
|
); |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
if ($supplementalflag) { |
}
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
this.document.forms.renameform.submit();
|
$supplementalflag,\%suporderhash); |
}
|
if ($error) { |
}
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
|
} |
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"}')) {
|
} elsif ($supplementalflag) { |
this.document.forms.renameform.cmd.value='cut_'+index;
|
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, |
this.document.forms.renameform.markcopy.value=index;
|
$supplementalflag); |
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
if ($error) { |
if (container == 'sequence') {
|
$r->print('<p><span class="LC_error">'.$error.'</span></p>'); |
this.document.forms.renameform.folderpath.value=folderpath;
|
} |
}
|
} |
if (container == 'page') {
|
|
this.document.forms.renameform.pagepath.value=folderpath;
|
&endContentScreen($r); |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
|
}
|
if ($allowed) { |
this.document.forms.renameform.submit();
|
$r->print(' |
}
|
<form method="post" name="extimport" action="/adm/coursedocs"> |
}
|
<input type="hidden" name="title" /> |
|
<input type="hidden" name="url" /> |
function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
|
<input type="hidden" name="useform" /> |
this.document.forms.renameform.markcopy.value=index;
|
<input type="hidden" name="residx" /> |
this.document.forms.renameform.copyfolder.value=folder+'.'+container;
|
</form>'); |
if (container == 'sequence') {
|
} |
this.document.forms.renameform.folderpath.value=folderpath;
|
} else { |
}
|
unless ($uploadphase) { |
if (container == 'page') {
|
# -------------------------------------------------------- This is showdoc mode |
this.document.forms.renameform.pagepath.value=folderpath;
|
$r->print("<h1>".&mt('Uploaded Document').' - '. |
this.document.forms.renameform.pagesymb.value=pagesymb;
|
&Apache::lonnet::gettitle($r->uri).'</h1><p>'. |
}
|
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>". |
this.document.forms.renameform.submit();
|
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>'); |
}
|
} |
|
} |
|
} |
ENDNEWSCRIPT
|
$r->print(&Apache::loncommon::end_page()); |
}
|
return OK; |
1;
|
} |
__END__
|
|
|
sub embedded_form_elems { |
|
my ($phase,$primaryurl,$newidx) = @_; |
=head1 NAME
|
my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"'); |
|
return <<STATE; |
Apache::londocs.pm
|
<input type="hidden" name="folderpath" value="$folderpath" /> |
|
<input type="hidden" name="cmd" value="upload_embedded" /> |
=head1 SYNOPSIS
|
<input type="hidden" name="newidx" value="$newidx" /> |
|
<input type="hidden" name="phase" value="$phase" /> |
This is part of the LearningOnline Network with CAPA project
|
<input type="hidden" name="primaryurl" value="$primaryurl" /> |
described at http://www.lon-capa.org.
|
STATE |
|
} |
=head1 SUBROUTINES
|
|
|
sub embedded_destination { |
=over
|
my $folder=$env{'form.folder'}; |
|
my $destination = 'docs/'; |
=item %help=()
|
if ($folder =~ /^supplemental/) { |
|
$destination = 'supplemental/'; |
Available help topics
|
} |
|
if (($folder eq 'default') || ($folder eq 'supplemental')) { |
=item mapread()
|
$destination .= 'default/'; |
|
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { |
Mapread read maps into LONCAPA::map:: global arrays
|
$destination .= $2.'/'; |
@order and @resources, determines status
|
} |
sets @order - pointer to resources in right order
|
$destination .= $env{'form.newidx'}; |
sets @resources - array with the resources with correct idx
|
my $dir_root = '/userfiles'; |
|
return ($destination,$dir_root); |
=item authorhosts()
|
} |
|
|
Return hash with valid author names
|
sub return_to_editor { |
|
my $actionurl = '/adm/coursedocs'; |
=item dumpbutton()
|
return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n". |
|
'<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n". |
Generate "dump" button
|
'<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor'). |
|
'</a></p>'; |
=item clean()
|
} |
|
|
=item dumpcourse()
|
sub generate_admin_options { |
|
my ($help_ref,$env_ref) = @_; |
Actually dump course
|
my %lt=&Apache::lonlocal::texthash( |
|
'vc' => 'Verify Content', |
|
'cv' => 'Check/Set Resource Versions', |
=item exportbutton()
|
'ls' => 'List Symbs', |
|
'sl' => 'Show Log', |
Generate "export" button
|
'imse' => 'IMS Export', |
|
'dcd' => 'Dump Course Documents to Construction Space: available on other servers' |
=item exportcourse()
|
); |
|
my %help = %{$help_ref}; |
=item create_ims_store()
|
my %env = %{$env_ref}; |
|
my $dumpbut=&dumpbutton(); |
=item build_package()
|
my $exportbut=&exportbutton(); |
|
my @list = ( |
=item get_dependencies()
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/verify.png" alt="'.$lt{vc}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "verify", "'.$lt{'vc'}.'")\' />' |
|
=> "<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"verify\", \"$lt{'vc'}\")'>$lt{'vc'}</a>$help{'Verify_Content'}"}, |
=item process_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'}.'")\' />' |
|
=>"<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 ''){ |
=item extract_media()
|
push @list, {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dump.png" alt="'.$lt{dcd}.'" />'=>$dumpbut}; |
|
} |
=item store_template()
|
push @list, ({'<img class="LC_noBorder LC_middle" src="/res/adm/pages/imsexport.png" alt="'.$lt{imse}.'" onclick="javascript:injectData(document.courseverify, \'dummy\', \'exportcourse\', \''.&mt('IMS Export').'\');" />' |
|
=>$exportbut}, |
=item group_import()
|
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/symbs.png" alt="'.$lt{ls}.'" onclick=\'javascript:injectData(document.courseverify, "dummy", "listsymbs", "'.$lt{'ls'}.'")\' />' |
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"listsymbs\", \"$lt{'ls'}\")'>$lt{'ls'}</a><input type='hidden' name='folder' value='$env{'form.folder'}' />"}, |
Imports the given (name, url) resources into the course
|
{'<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'}.'")\' />' |
coursenum, coursedom, and folder must precede the list
|
=>"<a class='LC_menubuttons_link' href='javascript:injectData(document.courseverify, \"dummy\", \"docslog\", \"$lt{'sl'}\")'>$lt{'sl'}</a>"}, |
|
); |
=item breadcrumbs()
|
return '<form action="/adm/coursedocs" method="post" name="courseverify"><input type="hidden" id="dummy" />'.&create_form_ul(&create_list_elements(@list)).'</form>'; |
|
|
=item log_docs()
|
} |
|
|
=item docs_change_log()
|
|
|
sub generate_edit_table { |
=item update_paste_buffer()
|
my ($tid,$orderhash_ref,$to_show) = @_; |
|
return unless(ref($orderhash_ref) eq 'HASH'); |
=item print_paste_buffer()
|
my %orderhash = %{$orderhash_ref}; |
|
my $form; |
=item do_paste_from_buffer()
|
my $activetab; |
|
my $active; |
=item update_parameter()
|
if($env{'form.active'} ne ''){ |
|
$activetab = $env{'form.active'}; |
=item handle_edit_cmd()
|
} |
|
$form = '<div class="LC_Box" style="margin:0;">'. |
=item editor()
|
'<ul id="navigation'.$tid.'" class="LC_TabContent">'; |
|
foreach my $name (reverse(sort(keys(%orderhash)))) { |
=item process_file_upload()
|
if($name ne '00'){ |
|
if($activetab eq '' || $activetab ne $name){ |
=item process_secondary_uploads()
|
$active = ''; |
|
}elsif($activetab eq $name){ |
=item is_supplemental_title()
|
$active = 'class="active"'; |
|
} |
=item parse_supplemental_title()
|
$form .= '<li style="float:right" '.$active |
|
.' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"' |
=item entryline()
|
.' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'; |
|
} else { |
=item tiehash()
|
$form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'; |
|
|
=item untiehash()
|
} |
|
} |
=item checkonthis()
|
$form .= '</ul>'; |
|
$form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'; |
check on this
|
|
|
if ($to_show ne '') { |
=item verifycontent()
|
$form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'; |
|
} |
Verify Content
|
foreach my $field (keys(%orderhash)){ |
|
if($field ne '00'){ |
=item devalidateversioncache() & checkversions()
|
if($activetab eq '' || $activetab ne $field){ |
|
$active = 'style="display: none;float:left"'; |
Check Versions
|
}elsif($activetab eq $field){ |
|
$active = 'style="display:block;float:left"'; |
=item mark_hash_old()
|
} |
|
$form .= '<div id="'.$field.$tid.'"' |
=item is_hash_old()
|
.' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1] |
|
.'</div>'; |
=item changewarning()
|
} |
|
} |
=item init_breadcrumbs()
|
$form .= '</div></div>'; |
|
|
Breadcrumbs for special functions
|
return $form; |
|
} |
=back
|
|
|
sub editing_js { |
=cut
|
my ($udom,$uname) = @_; |
|
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; |
|
var actabw = 0; |
|
for (var i=0; i<alltabs.length; i++) { |
|
if (activeTab == alltabs[i]) { |
|
actabw = document.getElementById(alltabs[i]).offsetWidth; |
|
if (actabw > maxtabw) { |
|
maxtabw = actabw; |
|
} |
|
} 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 (activeTab == 'cc1') { |
|
if (document.getElementById('cc_hrule') != null) { |
|
document.getElementById('cc_hrule').style.width=actabw+"px"; |
|
} |
|
} else { |
|
if (activeTab == 'bb1') { |
|
if (document.getElementById('bb_hrule') != null) { |
|
document.getElementById('bb_hrule').style.width=actabw+"px"; |
|
} |
|
} else { |
|
if (activeTab == 'ee2') { |
|
if (document.getElementById('ee_hrule') != null) { |
|
document.getElementById('ee_hrule').style.width=actabw+"px"; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
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 |