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