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