--- loncom/publisher/lonpublisher.pm 2005/06/23 22:46:00 1.198 +++ loncom/publisher/lonpublisher.pm 2006/09/27 21:04:13 1.214 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.198 2005/06/23 22:46:00 www Exp $ +# $Id: lonpublisher.pm,v 1.214 2006/09/27 21:04:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -129,6 +129,9 @@ use Apache::loncfile; use LONCAPA::lonmetadata; use Apache::lonmsg; use vars qw(%metadatafields %metadatakeys); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; + my %addid; my %nokey; @@ -355,7 +358,8 @@ sub hiddenfield { sub checkbox { my ($name,$text)=@_; - return "\n
".&mt($text); + return "\n
"; } sub selectbox { @@ -507,7 +511,6 @@ sub get_subscribed_hosts { if ( $sh=Apache::File->new("$target.subscription") ) { &Apache::lonnet::logthis("opened $target.subscription"); while (my $subline=<$sh>) { - &Apache::lonnet::logthis("Trying $subline"); if ($subline =~ /(^\w+):/) { if ($1 ne $Apache::lonnet::perlvar{'lonHostID'}) { push(@subscribed,$1); @@ -547,6 +550,7 @@ sub get_max_ids_indices { my %duplicatedids; my $parser=HTML::LCParser->new($content); + $parser->xml_mode(1); my $token; while ($token=$parser->get_token) { if ($token->[0] eq 'S') { @@ -676,6 +680,7 @@ sub fix_ids_and_indices { $allow{$token->[2]->{'src'}}=1; next; } + if ($lctag eq 'base') { next; } my %parms=%{$token->[2]}; $counter=$addid{$tag}; if (!$counter) { $counter=$addid{$lctag}; } @@ -685,7 +690,9 @@ sub fix_ids_and_indices { $parms{'id'}!~/^\s*$/) { $maxid++; $parms{'id'}=$maxid; - print $logfile 'ID: '.$tag.':'.$maxid."\n"; + print $logfile 'ID(new) : '.$tag.':'.$maxid."\n"; + } else { + print $logfile 'ID(kept): '.$tag.':'.$parms{'id'}."\n"; } } elsif ($counter eq 'index') { unless (defined($parms{'index'}) && @@ -696,12 +703,14 @@ sub fix_ids_and_indices { } } } - foreach my $type ('src','href','background','bgimg') { - foreach my $key (keys(%parms)) { - if ($key =~ /^$type$/i) { - $parms{$key}=&set_allow(\%allow,$logfile, - $target,$tag, - $parms{$key}); + unless ($parms{'type'} eq 'zombie') { + foreach my $type ('src','href','background','bgimg') { + foreach my $key (keys(%parms)) { + if ($key =~ /^$type$/i) { + $parms{$key}=&set_allow(\%allow,$logfile, + $target,$tag, + $parms{$key}); + } } } } @@ -837,7 +846,7 @@ sub store_metadata { $status=&LONCAPA::lonmetadata::delete_metadata($dbh,undef, $metadata{'url'}); } else { - $status = &LONCAPA::lonmetadata::update_metadata($dbh,undef, + $status = &LONCAPA::lonmetadata::update_metadata($dbh,undef,undef, \%metadata); } if (defined($status) && $status ne '') { @@ -847,7 +856,7 @@ sub store_metadata { &Apache::lonnet::logthis($status); return ($error,undef); } - return (undef,$status); + return (undef,'success'); } @@ -933,7 +942,7 @@ sub publish { return (''.&mt('No write permission to user directory, FAIL').'',1); } print $logfile -"\n\n================= Publish ".localtime()." Phase One ================\n".$env{'user.name'}.'@'.$env{'user.domain'}."\n"; +"\n\n================= Publish ".localtime()." Phase One ================\n".$env{'user.name'}.':'.$env{'user.domain'}."\n"; if (($style eq 'ssi') || ($style eq 'rat') || ($style eq 'prv')) { # ------------------------------------------------------- This needs processing @@ -1027,7 +1036,7 @@ sub publish { $env{'environment.generation'}; $metadatafields{'author'}=~s/\s+/ /g; $metadatafields{'author'}=~s/\s+$//; - $metadatafields{'owner'}=$cuname.'@'.$cudom; + $metadatafields{'owner'}=$cuname.':'.$cudom; # ------------------------------------------------ Check out directory hierachy @@ -1162,7 +1171,7 @@ sub publish { '

'.($env{'form.makeobsolete'}?'':'').'

'. &hiddenfield('phase','two'). &hiddenfield('filename',$env{'form.filename'}). - &hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)). + &hiddenfield('allmeta',&escape($allmeta)). &hiddenfield('dependencies',join(',',keys %allow)); unless ($env{'form.makeobsolete'}) { $intr_scrout.= @@ -1312,12 +1321,12 @@ END # $intr_scrout.=&text_with_browse_field('Source Custom Distribution File','sourcerights',$metadatafields{'sourcerights'},'rights'); my $uctitle=&mt('Obsolete'); $intr_scrout.= - "\n

$uctitle:". + "\n

'.&mt('Publishing').' '. &Apache::loncommon::filedescription($thistype).' '); @@ -2106,7 +2123,7 @@ ENDDIFF $r->print('
'); } } - $r->print(''); + $r->print(&Apache::loncommon::end_page()); return OK; }