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