--- loncom/interface/londocs.pm 2007/07/12 23:56:29 1.289
+++ loncom/interface/londocs.pm 2009/10/04 09:41:12 1.387
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.289 2007/07/12 23:56:29 albertel Exp $
+# $Id: londocs.pm,v 1.387 2009/10/04 09:41:12 tempelho Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,6 +26,8 @@
# http://www.lon-capa.org/
#
+
+
package Apache::londocs;
use strict;
@@ -33,6 +35,7 @@ use Apache::Constants qw(:common :http);
use Apache::imsexport;
use Apache::lonnet;
use Apache::loncommon;
+use Apache::lonhtmlcommon;
use LONCAPA::map();
use Apache::lonratedt();
use Apache::lonxml;
@@ -53,15 +56,9 @@ my %alreadyseen=();
my $hadchanges;
-# Available help topics
my %help=();
-# 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
-#
sub mapread {
my ($coursenum,$coursedom,$map)=@_;
@@ -76,25 +73,25 @@ sub storemap {
&LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
$map,1);
if ($errtext) { return ($errtext,2); }
-
+
$hadchanges=1;
return ($errtext,0);
}
-# ----------------------------------------- Return hash with valid author names
+
sub authorhosts {
my %outhash=();
my $home=0;
my $other=0;
- foreach (keys %env) {
- if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
+ foreach my $key (keys(%env)) {
+ if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
my $role=$1;
my $realm=$2;
- my ($start,$end)=split(/\./,$env{$_});
+ my ($start,$end)=split(/\./,$env{$key});
if (($start) && ($start>time)) { next; }
if (($end) && (time>$end)) { next; }
- my $ca; my $cd;
+ my ($ca,$cd);
if ($1 eq 'au') {
$ca=$env{'user.name'};
$cd=$env{'user.domain'};
@@ -116,18 +113,16 @@ sub authorhosts {
}
return ($home,$other,%outhash);
}
-# ------------------------------------------------------ Generate "dump" button
+
sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
my $type = &Apache::loncommon::course_type();
if ($home+$other==0) { return ''; }
if ($home) {
- return '
';
+ return "".&mt('IMS Export')."".
+ &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').' ';
}
+
+
sub exportcourse {
my $r=shift;
my $type = &Apache::loncommon::course_type();
my %discussiontime = &Apache::lonnet::dump('discussiontimes',
$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
- my $numdisc = keys %discussiontime;
+ my $numdisc = keys(%discussiontime);
my $navmap = Apache::lonnavmaps::navmap->new();
+ if (!defined($navmap)) {
+ $r->print(&Apache::loncommon::start_page('Export '.$type.' to IMS Package').
+ '
'.&mt('IMS Export Failed').'
'.
+ '
'.
+ &mt('Unable to retrieve information about course contents').
+ '
'.&mt('Return to Course Editor').'');
+ &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
+ return;
+ }
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
my $curRes;
my $outcome;
@@ -284,7 +298,17 @@ sub exportcourse {
my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
if (@exportitems == 0 && @discussions == 0) {
- $outcome = ' As you did not select any content items or discussions for export, an IMS package has not been created. Please go back to select either content items or discussions for export';
+ $outcome =
+ '
'
+ .&mt('As you did not select any content items or discussions'
+ .' for export, an IMS package has not been created.')
+ .'
'
+ .'
'
+ .&mt('Please [_1]go back[_2] to select either content items'
+ .' or discussions for export.'
+ ,''
+ ,'')
+ .'
';
} else {
my $now = time;
my %symbs;
@@ -307,35 +331,51 @@ sub exportcourse {
open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
close(OUTPUT);
chdir $cwd;
- $outcome .= &mt('Download the zip file from IMS '.lc($type).' archive ',$imszipfile,);
if ($copyresult) {
- $outcome .= 'The following errors occurred during export - '.$copyresult;
+ $outcome .= '
'
+ .&mt('The following errors occurred during export - [_1]'
+ ,$copyresult)
+ .'
';
}
+ $outcome .= '
'
+ .&mt('[_1]Your IMS package[_2] is ready for download.'
+ ,'','')
+ .'
';
} else {
- $outcome = ' 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. ';
+ $outcome = '
'
+ .&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.')
+ .'
';
}
}
- $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
+ $r->print(&Apache::loncommon::start_page('Export '.$type.' to IMS Package'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export'));
$r->print($outcome);
$r->print(&Apache::loncommon::end_page());
} else {
my $display;
- $display = '
';
my $curRes;
my $depth = 0;
my $count = 0;
@@ -344,13 +384,17 @@ sub exportcourse {
my %parent = ();
my %children = ();
my $lastcontainer = $startcount;
- my @bgcolors = ('#F6F6F6','#FFFFFF');
- $display .= '