--- loncom/publisher/lonpubdir.pm 2006/09/13 21:43:26 1.95 +++ loncom/publisher/lonpubdir.pm 2008/12/21 04:36:58 1.110.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Construction Space Directory Lister # -# $Id: lonpubdir.pm,v 1.95 2006/09/13 21:43:26 albertel Exp $ +# $Id: lonpubdir.pm,v 1.110.2.1 2008/12/21 04:36:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonlocal; use Apache::lonmsg; use Apache::lonmenu; use Apache::lonnet; +use LONCAPA; sub handler { @@ -104,7 +105,7 @@ sub handler { my $numres = 0; # Start off the directory table. - $r->print('

Directory Contents:

'); + $r->print('

'.&mt('Directory Contents:').'

'); $r->print(''. ''. ''. @@ -155,9 +156,9 @@ sub getEffectiveUrl { # Replace the ~username of the URL with /home/username/public_html # so that we don't have to worry about ~ expansion internally. # - $fn=~s/^http\:\/\/[^\/]+\///; + $fn=~s/^https?\:\/\/[^\/]+\///; $fn=~s/^\///; - $fn=~s/\~(\w+)/\/home\/$1\/public_html/; + $fn=~s{~($LONCAPA::username_re)}{/home/$1/public_html}; # Remove trailing / strings (?) @@ -170,7 +171,7 @@ sub getEffectiveUrl { #internal authentication, needs fixup. $fn = $r->uri(); # non users do not get the full path request # through SCRIPT_FILENAME - $fn=~s|^/~(\w+)|/home/$1/public_html|; + $fn=~s{^/~($LONCAPA::username_re)}{/home/$1/public_html}; } } $fn=~s/\/+/\//g; @@ -196,7 +197,7 @@ sub startpage { my $formaction='/priv/'.$uname.$thisdisfn.'/'; $formaction=~s|/+|/|g; my $pagetitle .= &Apache::loncommon::help_open_menu('','',3,'Authoring'). - 'Construction Space: '. + ''.&mt('Construction Space').': '. ''. &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/','_top','/priv','','+1',1)."
". @@ -210,16 +211,20 @@ sub startpage { {'body_title' => $pagetitle,})); } else { - $r->print(&Apache::loncommon::start_page('Construction Space',undef)); + $r->print(&Apache::loncommon::start_page('Construction Space',undef, + { 'only_body' => 1,})); $r->print($pagetitle); } + my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn); + my $doctitle = 'LON-CAPA '.&mt('Construction Space'); + my $newname = &mt('New Name'); my $pubdirscript=(< -top.document.title = '$thisdisfn/ - LON-CAPA Construction Space'; +top.document.title = '$esc_thisdisfn/ - $doctitle'; // Store directory location for menu bar to find -parent.lastknownpriv='/~$uname$thisdisfn/'; +parent.lastknownpriv='/~$uname$esc_thisdisfn/'; // Confirmation dialogues @@ -309,8 +314,9 @@ parent.lastknownpriv='/~$uname$thisdisfn return } function changename(theform,activity) { - var newname=prompt('New Name'); - if (newname == "" || !newname) { + var oldname=theform.dispfilename.value; + var newname=prompt('$newname',oldname); + if (newname == "" || !newname || newname == oldname) { return } document.moveresource.newfilename.value = newname @@ -352,17 +358,20 @@ sub dircontrols { ncrf => 'New custom rights file', nsty => 'New style file', nlib => 'New library file', + nbt => 'New bridgetask file', nsub => 'New subdirectory', renm => 'Rename current file to', move => 'Move current file to', copy => 'Copy current file to', type => 'Type Name Here', - go => 'Go', + go => 'Go', prnt => 'Print contents of directory', crea => 'Create a new directory or LON-CAPA document', acti => 'Actions for current directory', - updc => 'Upload a new document' + updc => 'Upload a new document', + pick => 'Please select an action to perform using the new filename', ); + my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript $r->print(< @@ -401,18 +410,29 @@ sub dircontrols { -    + +    @@ -513,15 +533,15 @@ sub putdirectory { %Apache::lonpublisher::metadatafields=(); %Apache::lonpublisher::metadatakeys=(); my $construct=$here; - $construct=~s:^/priv/(\w+)$:/home/$1/public_html:; + $construct=~s{^/priv/($LONCAPA::username_re)$}{/home/$1/public_html}; my $dirpath = $here; - $dirpath=~s:^/priv/:/~:; + $dirpath=~s{^/priv/}{/~}; &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile( $construct.'/'.$dirname.'/default.meta' )); my $actionitem = ''; if ($dirname eq '..') { - $actionitem = 'Go to ...'; + $actionitem = &mt('Go to ...'); } else { $actionitem = ''. &getTitleString($targetdir.'/'.$filename).''; - &Apache::lonnet::logthis("same $same meta $meta_same"); if ($same) { if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) { $pubstatus = 'obsolete'; @@ -637,7 +656,7 @@ sub putresource { } $title.="\n".'
'. - ($$bombs{$targetdir.'/'.$filename}?'bomb':'Edit Metadata').''; + ($$bombs{$targetdir.'/'.$filename}?''.&mt('bomb').'':&mt('Edit Metadata')).''; if (!$meta_same) { $title = &mt('Metadata Modified').'
'.$title. @@ -673,7 +692,7 @@ sub putresource { ''. ''. - ''. @@ -712,7 +731,9 @@ sub create_pubselect { ''. ''; + &HTML::Entities::encode($uname.$thisdisfn.'/'.$filename,'<>&"').'" /> + '; $$numres ++; }
'.&mt('Type').''.&mt('Actions').'
'.($filename=~/[\#\~]$/?' ': '').''.$pub_select.' '. + ''. ''. $filename.''.$editlink2.$editlink. '