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