--- loncom/publisher/lonpublisher.pm 2012/10/29 17:38:55 1.280
+++ loncom/publisher/lonpublisher.pm 2023/03/28 23:17:16 1.301
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.280 2012/10/29 17:38:55 raeburn Exp $
+# $Id: lonpublisher.pm,v 1.301 2023/03/28 23:17:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -102,8 +102,6 @@ to publication space.
Many of the undocumented subroutines implement various magical
parsing shortcuts.
-=over 4
-
=cut
######################################################################
@@ -130,13 +128,9 @@ use Apache::lonlocal;
use Apache::loncfile;
use LONCAPA::lonmetadata;
use Apache::lonmsg;
-use vars qw(%metadatafields %metadatakeys);
+use vars qw(%metadatafields %metadatakeys %addid $readit);
use LONCAPA qw(:DEFAULT :match);
-
-my %addid;
-my %nokey;
-
my $docroot;
my $cuname;
@@ -149,6 +143,8 @@ my $lock;
=pod
+=over 4
+
=item B
Evaluates a string that contains metadata. This subroutine
@@ -200,12 +196,12 @@ sub metaeval {
if (defined($token->[2]->{'name'})) {
$unikey.="\0".$token->[2]->{'name'};
}
- foreach (@{$token->[3]}) {
- $metadatafields{$unikey.'.'.$_}=$token->[2]->{$_};
+ foreach my $item (@{$token->[3]}) {
+ $metadatafields{$unikey.'.'.$item}=$token->[2]->{$item};
if ($metadatakeys{$unikey}) {
- $metadatakeys{$unikey}.=','.$_;
+ $metadatakeys{$unikey}.=','.$item;
} else {
- $metadatakeys{$unikey}=$_;
+ $metadatakeys{$unikey}=$item;
}
}
my $newentry=$parser->get_text('/'.$entry);
@@ -293,8 +289,8 @@ sub coursedependencies {
my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain,
$aauthor,$regexp);
my %courses=();
- foreach (keys %evaldata) {
- if ($_=~/^([a-zA-Z0-9]+_[a-zA-Z0-9]+)___.+___course$/) {
+ foreach my $item (keys(%evaldata)) {
+ if ($item=~/^([a-zA-Z0-9]+_[a-zA-Z0-9]+)___.+___course$/) {
$courses{$1}=1;
}
}
@@ -318,8 +314,12 @@ string which presents the form field (fo
=item B
+=item B
+
=item B
+=item B
+
=item B
=back
@@ -329,7 +329,7 @@ string which presents the form field (fo
#########################################
#########################################
sub textfield {
- my ($title,$name,$value,$noline)=@_;
+ my ($title,$name,$value,$noline,$readonly)=@_;
$value=~s/^\s+//gs;
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
@@ -341,22 +341,31 @@ sub textfield {
}
sub text_with_browse_field {
- my ($title,$name,$value,$restriction,$noline)=@_;
+ my ($title,$name,$value,$restriction,$noline,$readonly)=@_;
$value=~s/^\s+//gs;
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
$title=&mt($title);
$env{'form.'.$name}=$value;
- return "\n".&Apache::lonhtmlcommon::row_title($title)
- .''
- .'
'
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ my $output =
+ "\n".&Apache::lonhtmlcommon::row_title($title)
+ .'';
+ unless ($readonly) {
+ $output .=
+ '
'
.''
.&mt('Select')
.' '
.''
.&mt('Search')
- .''
- .&Apache::lonhtmlcommon::row_closure($noline);
+ .'';
+ }
+ $output .= &Apache::lonhtmlcommon::row_closure($noline);
+ return $output;
}
sub hiddenfield {
@@ -367,12 +376,12 @@ sub hiddenfield {
sub checkbox {
my ($name,$text)=@_;
- return "\n
');$r->rflush;
}
# ------------------------------------------------------------------- Link back
- $r->print("".&mt('Back to Metadata').'');
+ $r->print("".&mt('Back to Metadata').'');
$r->print(&Apache::loncommon::end_page());
return OK;
}
@@ -2117,29 +2594,7 @@ sub handler {
return HTTP_NOT_FOUND;
}
-# -------------------------------- File is there and owned, init lookup tables.
-
- %addid=();
-
- {
- my $fh=Apache::File->new($r->dir_config('lonTabDir').'/addid.tab');
- while (<$fh>=~/(\w+)\s+(\w+)/) {
- $addid{$1}=$2;
- }
- }
-
- %nokey=();
-
- {
- my $fh=Apache::File->new($r->dir_config('lonIncludes').'/un_keyword.tab');
- while (<$fh>) {
- my $word=$_;
- chomp($word);
- $nokey{$word}=1;
- }
- }
-
-# ---------------------------------------------------------- Start page output.
+# --------------------------------- File is there and owned, start page output
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -2147,7 +2602,7 @@ sub handler {
# Breadcrumbs
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({
- 'text' => 'Construction Space',
+ 'text' => 'Authoring Space',
'href' => &Apache::loncommon::authorspace($fn),
});
&Apache::lonhtmlcommon::add_breadcrumb({
@@ -2158,7 +2613,53 @@ sub handler {
my $js='';
- $r->print(&Apache::loncommon::start_page('Resource Publication',$js)
+ my $startargs = {};
+ if ($fn=~/\/$/) {
+ unless ($env{'form.phase'} eq 'two') {
+ $startargs->{'add_entries'} = { onload => 'javascript:setDefaultAccess();' };
+ $js .= <<"END";
+
+
+END
+ }
+ }
+ $r->print(&Apache::loncommon::start_page('Resource Publication',$js,$startargs)
.&Apache::lonhtmlcommon::breadcrumbs()
.&Apache::loncommon::head_subbox(
&Apache::loncommon::CSTR_pageheader($docroot.$fn))
@@ -2168,11 +2669,15 @@ sub handler {
my $thistarget=$fn;
$thistarget=~s/^\/priv\//\/res\//;
my $thisdistarget=&HTML::Entities::encode($thistarget,'<>&"');
+ my $nokeyref = &getnokey($r->dir_config('lonIncludes'));
if ($fn=~/\/$/) {
# -------------------------------------------------------- This is a directory
- &publishdirectory($r,$docroot.$fn,$thisdisfn);
- $r->print('
'.&mt('Return to Directory').'');
+ &publishdirectory($r,$docroot.$fn,$thisdisfn,$nokeyref);
+ $r->print(
+ '
'.
+ &Apache::lonhtmlcommon::actionbox([
+ ''.&mt('Return to Directory').'']));
} else {
# ---------------------- Evaluate individual file, and then output information.
$fn=~/\.(\w+)$/;
@@ -2222,7 +2727,7 @@ ENDCAPTION
$r->print(&Apache::lonhtmlcommon::row_closure()
.&Apache::lonhtmlcommon::row_title(&mt('Diffs')));
$r->print(<
+
ENDDIFF
$r->print(&mt('Diffs with Current Version').'');
}
@@ -2241,7 +2746,7 @@ ENDDIFF
}
unless ($errorcount) {
my ($outstring,$error)=
- &publish($docroot.$fn,$docroot.$thistarget,$thisembstyle);
+ &publish($docroot.$fn,$docroot.$thistarget,$thisembstyle,undef,$nokeyref);
$r->print($outstring);
} else {
$r->print(''.
@@ -2249,7 +2754,9 @@ ENDDIFF
'
');
}
} else {
- &phasetwo($r,$docroot.$fn,$docroot.$thistarget,$thisembstyle,$thisdistarget);
+ my ($output,$error) = &phasetwo($r,$docroot.$fn,$docroot.$thistarget,
+ $thisembstyle,$thisdistarget);
+ $r->print($output);
}
}
$r->print(&Apache::loncommon::end_page());
@@ -2257,6 +2764,24 @@ ENDDIFF
return OK;
}
+BEGIN {
+
+# ----------------------------------- Read addid.tab
+ unless ($readit) {
+ %addid=();
+
+ {
+ my $tabdir = $Apache::lonnet::perlvar{'lonTabDir'};
+ my $fh=Apache::File->new($tabdir.'/addid.tab');
+ while (<$fh>=~/(\w+)\s+(\w+)/) {
+ $addid{$1}=$2;
+ }
+ }
+ }
+ $readit=1;
+}
+
+
1;
__END__
@@ -2264,7 +2789,5 @@ __END__
=back
-=back
-
=cut