--- loncom/publisher/lonpublisher.pm 2008/06/30 18:10:24 1.239
+++ loncom/publisher/lonpublisher.pm 2016/03/22 16:41:10 1.295
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.239 2008/06/30 18:10:24 bisitz Exp $
+# $Id: lonpublisher.pm,v 1.295 2016/03/22 16:41:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,10 +66,10 @@ invocation by F:
=head1 OVERVIEW
-Authors can only write-access the C~authorname/> space. They can
-copy resources into the resource area through the publication step,
-and move them back through a recover step. Authors do not have direct
-write-access to their resource space.
+Authors can only write-access the C space.
+They can copy resources into the resource area through the
+publication step, and move them back through a recover step.
+Authors do not have direct write-access to their resource space.
During the publication step, several events will be
triggered. Metadata is gathered, where a wizard manages default
@@ -102,8 +102,6 @@ to publication space.
Many of the undocumented subroutines implement various magical
parsing shortcuts.
-=over 4
-
=cut
######################################################################
@@ -118,11 +116,13 @@ use Apache::File;
use File::Copy;
use Apache::Constants qw(:common :http :methods);
use HTML::LCParser;
+use HTML::Entities;
+use Encode::Encoder;
use Apache::lonxml;
-use Apache::loncacc;
use DBI;
use Apache::lonnet;
use Apache::loncommon();
+use Apache::lonhtmlcommon;
use Apache::lonmysql;
use Apache::lonlocal;
use Apache::loncfile;
@@ -147,6 +147,8 @@ my $lock;
=pod
+=over 4
+
=item B
Evaluates a string that contains metadata. This subroutine
@@ -198,12 +200,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);
@@ -263,8 +265,9 @@ sub metaread {
my ($logfile,$fn,$prefix)=@_;
unless (-e $fn) {
print($logfile 'No file '.$fn."\n");
- return ' '.&mt('No file').':'.
- &Apache::loncfile::display($fn).'';
+ return '
';
}
#########################################
@@ -289,8 +293,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;
}
}
@@ -314,8 +318,12 @@ string which presents the form field (fo
=item B
+=item B
+
=item B
+=item B
+
=item B
=back
@@ -325,7 +333,7 @@ string which presents the form field (fo
#########################################
#########################################
sub textfield {
- my ($title,$name,$value)=@_;
+ my ($title,$name,$value,$noline)=@_;
$value=~s/^\s+//gs;
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
@@ -333,11 +341,11 @@ sub textfield {
$env{'form.'.$name}=$value;
return "\n".&Apache::lonhtmlcommon::row_title($title)
.''
- .&Apache::lonhtmlcommon::row_closure();
+ .&Apache::lonhtmlcommon::row_closure($noline);
}
sub text_with_browse_field {
- my ($title,$name,$value,$restriction)=@_;
+ my ($title,$name,$value,$restriction,$noline)=@_;
$value=~s/^\s+//gs;
$value=~s/\s+$//gs;
$value=~s/\s+/ /gs;
@@ -352,7 +360,7 @@ sub text_with_browse_field {
.''
.&mt('Search')
.''
- .&Apache::lonhtmlcommon::row_closure();
+ .&Apache::lonhtmlcommon::row_closure($noline);
}
sub hiddenfield {
@@ -378,12 +386,12 @@ sub selectbox {
}
my $selout="\n".&Apache::lonhtmlcommon::row_title($title)
.''.&Apache::lonhtmlcommon::row_closure();
return $selout;
@@ -395,6 +403,59 @@ sub select_level_form {
if (!defined($value)) { $env{'form.'.$name}=0; }
return &Apache::loncommon::select_level_form($value,$name);
}
+
+sub common_access {
+ my ($name,$text,$options)=@_;
+ return unless (ref($options) eq 'ARRAY');
+ my $formname = 'pubdirpref';
+ my $chkname = 'common'.$name;
+ my $chkid = 'LC_'.$chkname;
+ my $divid = $chkid.'div';
+ my $customdivid = 'LC_customfile';
+ my $selname = $chkname.'select';
+ my $selid = $chkid.'select';
+ my $selonchange;
+ if ($name eq 'dist') {
+ $selonchange = ' onchange="showHideCustom(this,'."'$customdivid'".');"';
+ }
+ my %lt = &Apache::lonlocal::texthash(
+ 'default' => 'System wide - can be used for any courses system wide',
+ 'domain' => 'Domain only - use limited to courses in the domai',
+ 'custom' => 'Customized right of use ...',
+ 'public' => 'Public - no authentication or authorization required for use',
+ 'closed' => 'Closed - XML source is closed to everyone',
+ 'open' => 'Open - XML source is open to people who want to use it',
+ 'sel' => 'Select',
+ );
+ my $output = <<"END";
+
+
+
+
'.
- &mt('Copyright/distribution option "Private" is no longer supported. Select another option from below. Consider "Custom Rights" for maximum control over the usage of your resource.').'
';
+ $scrout.='
'.&mt('Warning!').' '
+ .&mt('Copyright/distribution option "Private" is no longer supported. Select another option from below. Consider "Custom Rights" for maximum control over the usage of your resource.')
+ .'
';
}
# ------------------------------------------------------- Now have all metadata
@@ -1167,17 +1338,22 @@ sub publish {
$textonly=~s/\';
- $r->print(&Apache::loncommon::start_page('Resource Publication',$js));
-
-
- my $thisfn=$fn;
-
- my $thistarget=$thisfn;
-
- $thistarget=~s/^\/home/$targetdir/;
- $thistarget=~s/\/public\_html//;
+ my $startargs = {};
+ if ($fn=~/\/$/) {
+ unless ($env{'form.phase'} eq 'two') {
+ $startargs->{'add_entries'} = { onload => 'javascript:setDefaultAccess();' };
+ $js .= <<"END";
+
- my $thisdisfn=$thisfn;
- $thisdisfn=~s/^\/home\/\Q$cuname\E\/public_html\///;
+END
+ }
+ }
+ $r->print(&Apache::loncommon::start_page('Resource Publication',$js,$startargs)
+ .&Apache::lonhtmlcommon::breadcrumbs()
+ .&Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader($docroot.$fn))
+ );
+
+ my $thisdisfn=&HTML::Entities::encode($fn,'<>&"');
+ my $thistarget=$fn;
+ $thistarget=~s/^\/priv\//\/res\//;
+ my $thisdistarget=&HTML::Entities::encode($thistarget,'<>&"');
if ($fn=~/\/$/) {
# -------------------------------------------------------- This is a directory
- &publishdirectory($r,$fn,$thisdisfn);
- $r->print(''.&mt('Return to Directory').'');
-
-
+ &publishdirectory($r,$docroot.$fn,$thisdisfn);
+ $r->print(
+ '
'.
+ &Apache::lonhtmlcommon::actionbox([
+ ''.&mt('Return to Directory').'']));
} else {
# ---------------------- Evaluate individual file, and then output information.
- $thisfn=~/\.(\w+)$/;
+ $fn=~/\.(\w+)$/;
my $thistype=$1;
my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);
if ($thistype eq 'page') { $thisembstyle = 'rat'; }
- $r->print('