--- loncom/interface/londocs.pm 2007/07/03 00:17:42 1.283
+++ loncom/interface/londocs.pm 2008/12/15 06:32:01 1.323
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.283 2007/07/03 00:17:42 albertel Exp $
+# $Id: londocs.pm,v 1.323 2008/12/15 06:32:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,6 +26,8 @@
# http://www.lon-capa.org/
#
+
+
package Apache::londocs;
use strict;
@@ -53,15 +55,10 @@ 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)=@_;
@@ -81,20 +78,20 @@ sub storemap {
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,7 +113,7 @@ sub authorhosts {
}
return ($home,$other,%outhash);
}
-# ------------------------------------------------------ Generate "dump" button
+
sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
@@ -141,7 +138,8 @@ sub clean {
$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
return $title;
}
-# -------------------------------------------------------- Actually dump course
+
+
sub dumpcourse {
my ($r) = @_;
@@ -161,15 +159,15 @@ sub dumpcourse {
my $title=$env{'form.authorfolder'};
$title=&clean($title);
my %replacehash=();
- foreach (keys %env) {
- if ($_=~/^form\.namefor\_(.+)/) {
- $replacehash{$1}=$env{$_};
+ foreach my $key (keys(%env)) {
+ if ($key=~/^form\.namefor\_(.+)/) {
+ $replacehash{$1}=$env{$key};
}
}
my $crs='/uploaded/'.$env{'request.course.id'}.'/';
$crs=~s/\_/\//g;
- foreach (keys %replacehash) {
- my $newfilename=$title.'/'.$replacehash{$_};
+ foreach my $item (keys(%replacehash)) {
+ my $newfilename=$title.'/'.$replacehash{$item};
$newfilename=~s/\.(\w+)$//;
my $ext=$1;
$newfilename=&clean($newfilename);
@@ -184,16 +182,16 @@ sub dumpcourse {
unless(mkdir($makepath,0777)) { $fail=1; }
}
}
- $r->print('
'.$_.' => '.$newfilename.': ');
+ $r->print('
'.$item.' => '.$newfilename.': ');
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
- if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
+ if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
print $fh &Apache::lonclonecourse::rewritefile(
- &Apache::lonclonecourse::readfile($env{'request.course.id'},$_),
+ &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
(%replacehash,$crs => '')
);
} else {
print $fh
- &Apache::lonclonecourse::readfile($env{'request.course.id'},$_);
+ &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
}
$fh->close();
} else {
@@ -211,8 +209,8 @@ sub dumpcourse {
$r->print(
'
'.&mt('Select the Construction Space').'