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