--- loncom/interface/londocs.pm 2004/09/27 15:20:23 1.147
+++ loncom/interface/londocs.pm 2005/03/10 02:34:58 1.170
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.147 2004/09/27 15:20:23 matthew Exp $
+# $Id: londocs.pm,v 1.170 2005/03/10 02:34:58 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -30,6 +30,7 @@ package Apache::londocs;
use strict;
use Apache::Constants qw(:common :http);
+use Apache::imsexport;
use Apache::lonnet;
use Apache::loncommon;
use Apache::lonratedt;
@@ -131,11 +132,17 @@ sub dumpbutton {
}
}
+sub clean {
+ my ($title)=@_;
+ $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
+ return $title;
+}
# -------------------------------------------------------- Actually dump course
sub dumpcourse {
my $r=shift;
- $r->print('
Dump DOCS'.
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print($html.'Dump DOCS'.
&Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
'";
@@ -1208,33 +1452,24 @@ ENDPARMS
sub tiehash {
my ($mode)=@_;
$hashtied=0;
- &Apache::lonnet::logthis(" tiehash1 -- $hashtied ");
if ($ENV{'request.course.fn'}) {
- &Apache::lonnet::logthis(" tiehash2 -- $hashtied ");
if ($mode eq 'write') {
- &Apache::lonnet::logthis(" tiehash3 -- $hashtied ");
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
&GDBM_WRCREAT(),0640)) {
$hashtied=2;
- &Apache::lonnet::logthis(" tiehash4 -- $hashtied ");
}
} else {
- &Apache::lonnet::logthis(" tiehash5 -- $hashtied ");
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
&GDBM_READER(),0640)) {
$hashtied=1;
- &Apache::lonnet::logthis(" tiehash6 -- $hashtied ");
}
}
}
- &Apache::lonnet::logthis(" tiehash7 -- $hashtied ");
}
sub untiehash {
- &Apache::lonnet::logthis(" untiehash1 -- $hashtied ");
if ($hashtied) { untie %hash; }
$hashtied=0;
- &Apache::lonnet::logthis(" untiehash2 -- $hashtied ");
}
# --------------------------------------------------------------- check on this
@@ -1254,7 +1489,7 @@ sub checkonthis {
if ($url=~/^\/res\//) {
my $result=&Apache::lonnet::repcopy(
&Apache::lonnet::filelocation('',$url));
- if ($result==OK) {
+ if ($result eq 'OK') {
$r->print(''.&mt('ok').'');
$r->rflush();
&Apache::lonnet::countacc($url);
@@ -1266,23 +1501,19 @@ sub checkonthis {
$r->print(' ');
}
$r->print('- '.&mt('Rendering').': ');
- my $oldpath=$ENV{'request.filename'};
- $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
- &Apache::lonxml::xmlparse($r,'web',
- &Apache::lonnet::getfile(
- &Apache::lonnet::filelocation('',$url)));
- undef($Apache::lonhomework::parsing_a_problem);
- $ENV{'request.filename'}=$oldpath;
- if (($Apache::lonxml::errorcount) ||
- ($Apache::lonxml::warningcount)) {
- if ($Apache::lonxml::errorcount) {
+ my ($errorcount,$warningcount)=split(/:/,
+ &Apache::lonnet::ssi_body($url,
+ ('return_only_error_and_warning_counts' => 1)));
+ if (($errorcount) ||
+ ($warningcount)) {
+ if ($errorcount) {
$r->print(''.
- $Apache::lonxml::errorcount.' '.
+ $errorcount.' '.
&mt('error(s)').' ');
}
- if ($Apache::lonxml::warningcount) {
+ if ($warningcount) {
$r->print(''.
- $Apache::lonxml::warningcount.' '.
+ $warningcount.' '.
&mt('warning(s)').'');
}
} else {
@@ -1297,9 +1528,9 @@ sub checkonthis {
&checkonthis($r,$_,$level+1);
}
}
- } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
+ } elsif ($result eq 'HTTP_SERVICE_UNAVAILABLE') {
$r->print(''.&mt('connection down').'');
- } elsif ($result==HTTP_NOT_FOUND) {
+ } elsif ($result eq 'HTTP_NOT_FOUND') {
unless ($url=~/\$/) {
$r->print(''.&mt('not found').'');
} else {
@@ -1320,8 +1551,8 @@ sub verifycontent {
my $r=shift;
my $loaderror=&Apache::lonnet::overloaderror($r);
if ($loaderror) { return $loaderror; }
-
- $r->print('Verify Content'.
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print($html.'Verify Content'.
&Apache::loncommon::bodytag('Verify Course Documents'));
$hashtied=0;
undef %alreadyseen;
@@ -1349,7 +1580,8 @@ sub verifycontent {
sub checkversions {
my $r=shift;
- $r->print('Check Versions'.
+ my $html=&Apache::lonxml::xmlbegin();
+ $r->print($html.'Check Versions'.
&Apache::loncommon::bodytag('Check Course Document Versions'));
my $header='';
my $startsel='';
@@ -1590,21 +1822,14 @@ ENDHEADERS
sub mark_hash_old {
my $retie_hash=0;
- &Apache::lonnet::logthis(" markold1 -- $hashtied $retie_hash ");
if ($hashtied) {
$retie_hash=1;
- &Apache::lonnet::logthis(" markold2 -- $hashtied $retie_hash ");
&untiehash();
- &Apache::lonnet::logthis(" markold3 -- $hashtied $retie_hash ");
}
&tiehash('write');
- &Apache::lonnet::logthis(" markold4 -- $hashtied $retie_hash ");
$hash{'old'}=1;
- &Apache::lonnet::logthis(" markold5 -- $hashtied $retie_hash ");
&untiehash();
- &Apache::lonnet::logthis(" markold6 -- $hashtied $retie_hash ");
if ($retie_hash) { &tiehash(); }
- &Apache::lonnet::logthis(" markold7 -- $hashtied $retie_hash ");
}
sub is_hash_old {
@@ -1621,11 +1846,18 @@ sub is_hash_old {
sub changewarning {
my ($r,$postexec)=@_;
if (!&is_hash_old()) { return; }
+ my $pathvar='folderpath';
+ my $path=&Apache::lonnet::escape($ENV{'form.folderpath'});
+ if (defined($ENV{'form.pagepath'})) {
+ $pathvar='pagepath';
+ $path=&Apache::lonnet::escape($ENV{'form.pagepath'});
+ $path.='&symb='.&Apache::lonnet::escape($ENV{'form.pagesymb'});
+ }
$r->print(
''.
'
'.
-'
'.
&mt('Changes will become active for your current session after').
' ';
- $uploadtag = '';
+ $containertag = ''.
+ '';
+ $uploadtag = ''.
+ '';
}
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
}
unless ($showdoc) { # got called from remote
- $forcestandard=($ENV{'form.folder'}=~/^default_/);
+ if (($ENV{'form.folder'}=~/^default_/) ||
+ ($ENV{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {
+ $forcestandard = 1;
+ }
$forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
# does this user have privileges to post, etc?
@@ -1735,8 +1972,9 @@ sub handler {
my $now=time;
# print screen
+ my $html=&Apache::lonxml::xmlbegin();
$r->print(<
+$html
The LearningOnline Network with CAPA
ENDNEWSCRIPT
@@ -1877,7 +2133,9 @@ ENDNEWSCRIPT
my %lt=&Apache::lonlocal::texthash(
'uplm' => 'Upload a new main course document',
'upls' => 'Upload a new supplemental course document',
- 'impp' => 'Import a published document',
+ 'impp' => 'Import a document',
+ 'pubd' => 'Published documents',
+ 'copm' => 'All documents out of a published map',
'spec' => 'Special documents',
'upld' => 'Upload Document',
'srch' => 'Search',
@@ -1926,6 +2184,7 @@ ENDNEWSCRIPT