version 1.106, 2008/01/16 12:08:04
|
version 1.114.2.1, 2010/02/11 21:49:19
|
Line 62 sub handler {
|
Line 62 sub handler {
|
&Apache::loncacc::constructaccess( |
&Apache::loncacc::constructaccess( |
$fn,$r->dir_config('lonDefDomain')); |
$fn,$r->dir_config('lonDefDomain')); |
unless (($uname) && ($udom)) { |
unless (($uname) && ($udom)) { |
$r->log_reason($uname.' at '.$udom. |
$r->log_reason($uname.':'.$udom. |
' trying to list directory '.$env{'form.filename'}. |
' trying to list directory '.$env{'form.filename'}. |
' ('.$fn.') - not authorized', |
' ('.$fn.') - not authorized', |
$r->filename); |
$r->filename); |
Line 74 sub handler {
|
Line 74 sub handler {
|
$fn=~s/\/$//; |
$fn=~s/\/$//; |
|
|
unless ($fn) { |
unless ($fn) { |
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |
$r->log_reason($env{'user.name'}.':'.$env{'user.domain'}. |
' trying to list empty directory', $r->filename); |
' trying to list empty directory', $r->filename); |
return HTTP_NOT_FOUND; |
return HTTP_NOT_FOUND; |
} |
} |
Line 156 sub getEffectiveUrl {
|
Line 156 sub getEffectiveUrl {
|
# Replace the ~username of the URL with /home/username/public_html |
# Replace the ~username of the URL with /home/username/public_html |
# so that we don't have to worry about ~ expansion internally. |
# so that we don't have to worry about ~ expansion internally. |
# |
# |
$fn=~s/^http\:\/\/[^\/]+\///; |
$fn=~s/^https?\:\/\/[^\/]+\///; |
|
|
$fn=~s/^\///; |
$fn=~s/^\///; |
$fn=~s{~($LONCAPA::username_re)}{/home/$1/public_html}; |
$fn=~s{~($LONCAPA::username_re)}{/home/$1/public_html}; |
|
|
Line 207 sub startpage {
|
Line 208 sub startpage {
|
&Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction); |
&Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction); |
if ($env{'environment.remote'} eq 'off') { |
if ($env{'environment.remote'} eq 'off') { |
$env{'request.noversionuri'}=$currdir.'/'; |
$env{'request.noversionuri'}=$currdir.'/'; |
$r->print(&Apache::loncommon::start_page(&mt('Construction Space'),undef, |
$r->print(&Apache::loncommon::start_page('Construction Space',undef, |
{'body_title' => |
{'body_title' => |
$pagetitle,})); |
$pagetitle,})); |
} else { |
} else { |
$r->print(&Apache::loncommon::start_page(&mt('Construction Space'),undef, |
$r->print(&Apache::loncommon::start_page('Construction Space',undef, |
{ 'only_body' => 1,})); |
{ 'only_body' => 1,})); |
$r->print($pagetitle); |
$r->print($pagetitle); |
} |
} |
|
|
my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn); |
my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn); |
|
my $doctitle = 'LON-CAPA '.&mt('Construction Space'); |
|
my $newname = &mt('New Name'); |
my $pubdirscript=(<<ENDPUBDIRSCRIPT); |
my $pubdirscript=(<<ENDPUBDIRSCRIPT); |
<script type="text/javascript"> |
<script type="text/javascript"> |
top.document.title = '$esc_thisdisfn/ - '.&mt('LON-CAPA Construction Space'); |
top.document.title = '$esc_thisdisfn/ - $doctitle'; |
// Store directory location for menu bar to find |
// Store directory location for menu bar to find |
|
|
parent.lastknownpriv='/~$uname$esc_thisdisfn/'; |
parent.lastknownpriv='/~$uname$esc_thisdisfn/'; |
Line 231 parent.lastknownpriv='/~$uname$esc_thisd
|
Line 234 parent.lastknownpriv='/~$uname$esc_thisd
|
document.publishdir.filename.value = theform.filename.value; |
document.publishdir.filename.value = theform.filename.value; |
document.publishdir.submit(); |
document.publishdir.submit(); |
} |
} |
if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'editcat') { |
if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'editmeta') { |
top.location=theform.filename.value+'default.meta' |
top.location=theform.filename.value+'default.meta' |
} |
} |
if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'printdir' ) { |
if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'printdir' ) { |
Line 261 parent.lastknownpriv='/~$uname$esc_thisd
|
Line 264 parent.lastknownpriv='/~$uname$esc_thisd
|
if (theform.diraction.options[theform.diraction.selectedIndex].value == "publish") { |
if (theform.diraction.options[theform.diraction.selectedIndex].value == "publish") { |
theform.submit(); |
theform.submit(); |
} |
} |
if (theform.diraction.options[theform.diraction.selectedIndex].value == "editcat") { |
if (theform.diraction.options[theform.diraction.selectedIndex].value == "editmeta") { |
top.location=theform.filename.value+'default.meta' |
top.location=theform.filename.value+'default.meta' |
} |
} |
if (theform.diraction.options[theform.diraction.selectedIndex].value == "printdir") { |
if (theform.diraction.options[theform.diraction.selectedIndex].value == "printdir") { |
Line 313 parent.lastknownpriv='/~$uname$esc_thisd
|
Line 316 parent.lastknownpriv='/~$uname$esc_thisd
|
} |
} |
function changename(theform,activity) { |
function changename(theform,activity) { |
var oldname=theform.dispfilename.value; |
var oldname=theform.dispfilename.value; |
var newname=prompt('New Name',oldname); |
var newname=prompt('$newname',oldname); |
if (newname == "" || !newname || newname == oldname) { |
if (newname == "" || !newname || newname == oldname) { |
return |
return |
} |
} |
Line 328 ENDPUBDIRSCRIPT
|
Line 331 ENDPUBDIRSCRIPT
|
|
|
if ((($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) && |
if ((($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) && |
$env{'environment.remote'} ne 'off') { |
$env{'environment.remote'} ne 'off') { |
$r->print('<h3>'.&mt('Co-Author').': '.$uname.' at '.$udom. |
$r->print('<h3>'.&mt('Co-Author [_1]',$uname.':'.$udom).'</h3>'); |
'</h3>'); |
'</h3>'); |
} |
} |
} |
} |
Line 346 sub dircontrols {
|
Line 349 sub dircontrols {
|
list => 'List Directory', |
list => 'List Directory', |
uplo => 'Upload file', |
uplo => 'Upload file', |
dele => 'Delete', |
dele => 'Delete', |
edit => 'Edit Catalog Information', |
edit => 'Edit Metadata', |
sela => 'Select Action', |
sela => 'Select Action', |
nfil => 'New file', |
nfil => 'New file', |
nhtm => 'New HTML file', |
nhtm => 'New HTML file', |
Line 383 sub dircontrols {
|
Line 386 sub dircontrols {
|
<select name="dirtask" onchange="currdiract(this.form)"> |
<select name="dirtask" onchange="currdiract(this.form)"> |
<option>$lt{'sela'}</option> |
<option>$lt{'sela'}</option> |
<option value="publish">$lt{'pubd'}</option> |
<option value="publish">$lt{'pubd'}</option> |
<option value="editcat">$lt{'edit'}</option> |
<option value="editmeta">$lt{'edit'}</option> |
<option value="printdir">$lt{'prnt'}</option> |
<option value="printdir">$lt{'prnt'}</option> |
<option value="delete">$lt{'dedr'}</option> |
<option value="delete">$lt{'dedr'}</option> |
</select> |
</select> |
Line 447 sub pubbuttons {
|
Line 450 sub pubbuttons {
|
'<input type="submit" value="'.&mt('Publish Directory').'" /></td><td>'. |
'<input type="submit" value="'.&mt('Publish Directory').'" /></td><td>'. |
'<input type="button" onclick="window.location='."'/~". |
'<input type="button" onclick="window.location='."'/~". |
$uname.$thisdisfn."/default.meta'".'" value="'. |
$uname.$thisdisfn."/default.meta'".'" value="'. |
&mt('Edit Directory Catalog Information').'" /></td></tr></table></form>'); |
&mt('Edit Directory Metadata').'" /></td></tr></table></form>'); |
} |
} |
|
|
sub resourceactions { |
sub resourceactions { |
Line 539 sub putdirectory {
|
Line 542 sub putdirectory {
|
)); |
)); |
my $actionitem = ''; |
my $actionitem = ''; |
if ($dirname eq '..') { |
if ($dirname eq '..') { |
$actionitem = 'Go to ...'; |
$actionitem = &mt('Go to ...'); |
} else { |
} else { |
$actionitem = |
$actionitem = |
'<form name="dirselect_'.$$numdir. |
'<form name="dirselect_'.$$numdir. |
Line 548 sub putdirectory {
|
Line 551 sub putdirectory {
|
'<option selected="selected">'.&mt('Select action').'</option>'. |
'<option selected="selected">'.&mt('Select action').'</option>'. |
'<option value="open">'.&mt('Open').'</option>'. |
'<option value="open">'.&mt('Open').'</option>'. |
'<option value="publish">'.&mt('Publish').'</option>'. |
'<option value="publish">'.&mt('Publish').'</option>'. |
'<option value="editcat">'.&mt('Edit catalog information').'</option>'. |
'<option value="editmeta">'.&mt('Edit Metadata').'</option>'. |
'<option value="printdir">'.&mt('Print directory').'</option>'. |
'<option value="printdir">'.&mt('Print directory').'</option>'. |
'<option value="delete">'.&mt('Delete directory').'</option>'. |
'<option value="delete">'.&mt('Delete directory').'</option>'. |
'</select>'. |
'</select>'. |
Line 619 sub putresource {
|
Line 622 sub putresource {
|
$meta_same = 0; |
$meta_same = 0; |
} |
} |
$publish_button=&mt('Re-publish'); |
$publish_button=&mt('Re-publish'); |
my $rights_status = |
|
&mt(&getCopyRightString($targetdir.'/'.$filename)).' '. |
my $rights_status = |
&mt(&getSourceRightString($targetdir.'/'.$filename)); |
&mt(&getCopyRightString($targetdir.'/'.$filename)).', '; |
|
|
|
my %lt_SourceRight = &Apache::lonlocal::texthash( |
|
'open' => 'Source: open', |
|
'closed' => 'Source: closed', |
|
); |
|
$rights_status .= |
|
$lt_SourceRight{&getSourceRightString($targetdir.'/'.$filename)}; |
|
|
$title = '<a href="/res/'.$targetdir.'/'.$filename. |
$title = '<a href="/res/'.$targetdir.'/'.$filename. |
'.meta" target="cat">'. |
'.meta" target="cat">'. |
&getTitleString($targetdir.'/'.$filename).'</a>'; |
&getTitleString($targetdir.'/'.$filename).'</a>'; |
Line 654 sub putresource {
|
Line 665 sub putresource {
|
} |
} |
|
|
$title.="\n".'<br /><a href="/~'.$uname.$thisdisfn.'/'.$filename.'.meta">'. |
$title.="\n".'<br /><a href="/~'.$uname.$thisdisfn.'/'.$filename.'.meta">'. |
($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" border="0" alt="bomb" />':'Edit Metadata').'</a>'; |
($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" border="0" alt="'.&mt('bomb').'" />':&mt('Edit Metadata')).'</a>'; |
|
|
if (!$meta_same) { |
if (!$meta_same) { |
$title = &mt('Metadata Modified').'<br />'.$title. |
$title = &mt('Metadata Modified').'<br />'.$title. |
Line 783 sub CategorizeFiles {
|
Line 794 sub CategorizeFiles {
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|
=head1 NAME |
=head1 NAME |
|
|
Apache::lonpubdir - Construction space directory lister |
Apache::lonpubdir - Construction space directory lister |
Line 838 run through list of files and attempt to
|
Line 850 run through list of files and attempt to
|
|
|
=back |
=back |
|
|
|
=head1 SUBROUTINES: |
|
|
|
=over |
|
|
|
=item startpage($r, $uame, $udom, $thisdisfn) |
|
|
|
Output the header of the page. This includes: |
|
- The HTML header |
|
- The H1/H3 stuff which includes the directory. |
|
|
|
startpage($r, $uame, $udom, $thisdisfn); |
|
$r - The apache request object. |
|
$uname - User name. |
|
$udom - Domain name the user is logged in under. |
|
$thisdisfn - Displayable version of the filename. |
|
|
|
=item getTitleString($fullname) |
|
|
|
Get the title string or "[untitled]" if the file has no title metadata: |
|
Without the latter substitution, it's impossible to examine metadata for |
|
untitled resources. Resources may be legitimately untitled, to prevent |
|
searches from locating them. |
|
|
|
$str = getTitleString($fullname); |
|
$fullname - Fully qualified filename to check. |
|
|
|
=item putdirectory(r, base, here, dirname, modtime) |
|
|
|
Put out a directory table row: |
|
|
|
putdirectory($r, $base, $here, $dirname, $modtime) |
|
$r - Apache request object. |
|
$reqfile - File in request. |
|
$here - Where we are in directory tree. |
|
$dirname - Name of directory special file. |
|
$modtime - Encoded modification time. |
|
|
|
=item CategorizeFiles($location, $files) |
|
|
|
Categorize files in the directory. |
|
For each file in a list of files in a file directory, |
|
the file categorized as one of: |
|
- directory |
|
- sequence |
|
- problem |
|
- Other resource. |
|
|
|
For each file the modification date is determined as well. |
|
Returned is a list of sublists: |
|
(directories, sequences, problems, other) |
|
each of the sublists contains entries of the following form (sorted by filename): |
|
(filename, typecode, lastmodtime) |
|
|
|
$list = CategorizeFiles($location, $files) |
|
$location - Directory in which the files live (relative to our execution) |
|
$files - list of files. |
|
|
|
=back |
|
|
=cut |
=cut |
|
|