--- loncom/publisher/lonpubdir.pm 2005/06/23 22:24:54 1.84 +++ loncom/publisher/lonpubdir.pm 2006/05/17 13:41:45 1.91 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Construction Space Directory Lister # -# $Id: lonpubdir.pm,v 1.84 2005/06/23 22:24:54 www Exp $ +# $Id: lonpubdir.pm,v 1.91 2006/05/17 13:41:45 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,7 @@ use Apache::Constants qw(:common :http : use Apache::loncacc; use Apache::loncommon(); use Apache::lonhtmlcommon(); +use Apache::londiff(); use Apache::lonlocal; use Apache::lonmsg; use Apache::lonmenu; @@ -111,7 +112,7 @@ sub handler { ''.&mt('Title').''. ''.&mt('Status').''. ''.&mt('Last Modified'). - ''); + ''."\n"); my $filename; my $dirptr=16384; # Mask indicating a directory in stat.cmode. @@ -137,7 +138,7 @@ sub handler { } closedir(DIR); - $r->print(''); + $r->print(''.&Apache::loncommon::end_page()); return OK; } # @@ -191,13 +192,10 @@ sub startpage { my $currdir = '/priv/'.$uname.$thisdisfn; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.'LON-CAPA Construction Space'); - my $pagetitle; my $formaction='/priv/'.$uname.$thisdisfn.'/'; - $formaction=~s/\/+/\//g; - $pagetitle .= &Apache::loncommon::help_open_menu('','','','',3,'Authoring'). + $formaction=~s|/+|/|g; + my $pagetitle .= &Apache::loncommon::help_open_menu('','','','',3,'Authoring'). 'Construction Space: '. '
'. @@ -208,10 +206,14 @@ sub startpage { &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction); if ($env{'environment.remote'} eq 'off') { $env{'request.noversionuri'}=$currdir.'/'; - $r->print(&Apache::loncommon::bodytag('Construction Space',undef,undef,undef,undef,undef,$pagetitle)); + $r->print(&Apache::loncommon::start_page('Construction Space',undef, + {'body_title' => + $pagetitle,})); } else { + $r->print(&Apache::loncommon::start_page('Construction Space',undef)); $r->print($pagetitle); } + my $pubdirscript=(< top.document.title = '$thisdisfn/ - LON-CAPA Construction Space'; @@ -233,6 +235,11 @@ parent.lastknownpriv='/~$uname$thisdisfn document.printdir.postdata.value=theform.filename.value document.printdir.submit(); } + if (theform.dirtask.options[theform.dirtask.selectedIndex].value == "delete") { + var delform = document.delresource + delform.filename.value = theform.filename.value + delform.submit() + } } function checkUpload(theform) { @@ -259,6 +266,11 @@ parent.lastknownpriv='/~$uname$thisdisfn theform.postdata.value = theform.filename.value theform.submit() } + if (theform.diraction.options[theform.diraction.selectedIndex].value == "delete") { + var delform = document.delresource + delform.filename.value = theform.filename.value + delform.submit() + } return } function SetResChoice(theform) { @@ -325,8 +337,8 @@ sub dircontrols { mcdi => 'Must create new subdirectory inside a directory', pubr => 'Publish this Resource', pubd => 'Publish this Directory', + dedr => 'Delete Directory', rtrv => 'Retrieve Old Version', - pubs => 'Publish with Subdirectories', list => 'List Directory', uplo => 'Upload file', dele => 'Delete', @@ -354,18 +366,19 @@ sub dircontrols { $r->print(< - $lt{'acti'} - $lt{'updc'} - $lt{'crea'} + $lt{'acti'} + $lt{'updc'} + $lt{'crea'} - + @@ -414,7 +427,7 @@ sub pubbuttons { '
'. ''. -'
'); } @@ -513,15 +526,15 @@ sub putdirectory { $actionitem = '
'. - ''. ''. ''. ''. - ''. ''. ''. + ''. ''. - ''. + ''. ''. ''. '
'; @@ -529,9 +542,9 @@ sub putdirectory { } $r->print(''. ''. + $Apache::lonnet::perlvar{'lonIconsURL'}.'/folder_closed.gif" alt="folder" />'. ''.$actionitem.''. - ''. + ''. $disfilename.''. ''.($kaputt?&Apache::lonhtmlcommon::authorbombs($resdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'}.' '. $Apache::lonpublisher::metadatafields{'subject'}.' '. @@ -559,12 +572,23 @@ sub putresource { # $uname.'/'.$thisdisfn.'/'.$filename.'">'. # &mt('Delete').''; if (-e $resdir.'/'.$filename) { + my $same=0; my ($rdev,$rino,$rmode,$rnlink, $ruid,$rgid,$rrdev,$rsize, $ratime,$rmtime,$rctime, $rblksize,$rblocks)=stat($resdir.'/'.$filename); + if ($rmtime>=$cmtime) { + $same=1; + } else { + if (&Apache::londiff::are_different_files($resdir.'/'.$filename, + '/home/'.$uname.'/public_html/'.$thisdisfn.'/'.$filename)) { + $same=0; + } else { + $same=1; + } + } $publish_button=&mt('Re-publish'); - if ($rmtime>=$cmtime) { + if ($same) { $pubstatus = 'published'; $status=&mt('Published').'
'. &mt(&getCopyRightString($targetdir.'/'.$filename)).' '. @@ -597,7 +621,7 @@ sub putresource { } } $title.="\n".'
'. - ($$bombs{$targetdir.'/'.$filename}?'':'Edit Metadata').''; + ($$bombs{$targetdir.'/'.$filename}?'bomb':'Edit Metadata').''; $status.="\n".'
'.&mt('Retrieve').''; } @@ -622,7 +646,7 @@ sub putresource { &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres); $r->print(''. ''.($filename=~/[\#\~]$/?' ': - ''). + '').''. ''.$pub_select.''. ''. ''. @@ -639,7 +663,7 @@ sub create_pubselect { my ($r,$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres) = @_; $$pub_select = '
- '. ''; if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') { @@ -663,7 +687,7 @@ sub create_pubselect { ''. '
'; + &HTML::Entities::encode($uname.$thisdisfn.'/'.$filename,'<>&"').'" />'; $$numres ++; }