version 1.106, 2008/01/16 12:08:04
|
version 1.116, 2008/12/05 09:41:59
|
Line 105 sub handler {
|
Line 105 sub handler {
|
my $numres = 0; |
my $numres = 0; |
|
|
# Start off the directory table. |
# Start off the directory table. |
$r->print('<h3>'.&mt('Directory Contents:').'</h3>'); |
$r->print(&Apache::loncommon::start_data_table() |
$r->print('<table id="LC_browser"><tr>'. |
.&Apache::loncommon::start_data_table_header_row() |
'<th>'.&mt('Type').'</th>'. |
.'<th>'.&mt('Type').'</th>' |
'<th>'.&mt('Actions').'</th>'. |
.'<th>'.&mt('Actions').'</th>' |
'<th>'.&mt('Name').'</th>'. |
.'<th>'.&mt('Name').'</th>' |
'<th>'.&mt('Title').'</th>'. |
.'<th>'.&mt('Title').'</th>' |
'<th>'.&mt('Status').'</th>'. |
.'<th colspan="2">'.&mt('Status').'</th>' |
'<th>'.&mt('Last Modified'). |
.'<th>'.&mt('Last Modified').'</th>' |
'</th></tr>'."\n"); |
.&Apache::loncommon::end_data_table_header_row() |
|
); |
|
|
my $filename; |
my $filename; |
my $dirptr=16384; # Mask indicating a directory in stat.cmode. |
my $dirptr=16384; # Mask indicating a directory in stat.cmode. |
Line 139 sub handler {
|
Line 140 sub handler {
|
} |
} |
closedir(DIR); |
closedir(DIR); |
|
|
$r->print('</table>'.&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_data_table() |
|
.&Apache::loncommon::end_page() |
|
); |
return OK; |
return OK; |
} |
} |
# |
# |
Line 207 sub startpage {
|
Line 210 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 236 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 266 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 318 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 346 sub dircontrols {
|
Line 351 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 371 sub dircontrols {
|
Line 376 sub dircontrols {
|
); |
); |
my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript |
my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript |
$r->print(<<END); |
$r->print(<<END); |
<table id="LC_cstr_controls"> |
<div class="columnSection"> |
<tr> |
<div> |
<th>$lt{'acti'}</th> |
<form name="curractions" method="post" action=""> |
<th>$lt{'updc'}</th> |
<fieldset> |
<th>$lt{'crea'}</th> |
<legend>$lt{'acti'}</legend> |
</tr> |
<select name="dirtask" onchange="currdiract(this.form)"> |
<tr> |
|
<td> |
|
<form name="curractions" method="post" action=""> |
|
<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> |
<input type="hidden" name="filename" value="/~$uname$thisdisfn/" /> |
<input type="hidden" name="filename" value="/~$uname$thisdisfn/" /> |
</form> |
</fieldset> |
<form name="publishdir" method="post" action="/adm/publish" target="_parent"> |
</form> |
<input type="hidden" name="pubrec" value="" /> |
<form name="publishdir" method="post" action="/adm/publish" target="_parent"> |
<input type="hidden" name="filename" value="" /> |
<input type="hidden" name="pubrec" value="" /> |
</form> |
<input type="hidden" name="filename" value="" /> |
<form name="printdir" method="post" action="/adm/printout" target="_parent"> |
</form> |
<input type="hidden" name="postdata" value="" /> |
<form name="printdir" method="post" action="/adm/printout" target="_parent"> |
</form> |
<input type="hidden" name="postdata" value="" /> |
</td> |
</form> |
<td> |
</div> |
<form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload" target="_parent"> |
|
<input type="hidden" name="filename" value="/~$uname$thisdisfn/" /> |
<div> |
<input type="file" name="upfile" size="20" /> |
<form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload" target="_parent"> |
<input type="button" value="$lt{'uplo'}" onclick="checkUpload(this.form)" /> |
<fieldset> |
</form> |
<legend>$lt{'updc'}</legend> |
</td> |
<input type="hidden" name="filename" value="/~$uname$thisdisfn/" /> |
<td> |
<input type="file" name="upfile" size="20" /> |
<form name="fileaction" method="post" action="/adm/cfile" target="_parent"> |
<input type="button" value="$lt{'uplo'}" onclick="checkUpload(this.form)" /> |
<span style="white-space: nowrap"> |
</fieldset> |
|
</form> |
|
</div> |
|
|
|
<div> |
|
<form name="fileaction" method="post" action="/adm/cfile" target="_parent"> |
|
<fieldset> |
|
<legend>$lt{'crea'}</legend> |
|
<span class="LC_nobreak"> |
<input type="hidden" name="filename" value="/~$uname$thisdisfn/" /> |
<input type="hidden" name="filename" value="/~$uname$thisdisfn/" /> |
<script type="text/javascript"> |
<script type="text/javascript"> |
function validate_go() { |
function validate_go() { |
Line 432 sub dircontrols {
|
Line 441 sub dircontrols {
|
<option value="newdir">$lt{'nsub'}:</option> |
<option value="newdir">$lt{'nsub'}:</option> |
</select> <input type="text" name="newfilename" value="$lt{'type'}" onfocus="if (this.value == '$mytype') this.value=''" /> <input type="button" value="Go" onclick="validate_go();" /> |
</select> <input type="text" name="newfilename" value="$lt{'type'}" onfocus="if (this.value == '$mytype') this.value=''" /> <input type="button" value="Go" onclick="validate_go();" /> |
</span> |
</span> |
</form> |
</fieldset> |
</td> |
</form> |
</tr> |
</div> |
</table> |
</div> |
END |
END |
} |
} |
|
|
Line 539 sub putdirectory {
|
Line 548 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 557 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 564 sub putdirectory {
|
Line 573 sub putdirectory {
|
'<td>'.$actionitem.'</td>'. |
'<td>'.$actionitem.'</td>'. |
'<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" target="_parent">'. |
'<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" target="_parent">'. |
$disfilename.'</a></span></td>'. |
$disfilename.'</a></span></td>'. |
'<td colspan="2">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($resdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'}); |
'<td colspan="3">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($resdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'}); |
if ($Apache::lonpublisher::metadatafields{'subject'} ne '') { |
if ($Apache::lonpublisher::metadatafields{'subject'} ne '') { |
$r->print(' <i>'. |
$r->print(' <i>'. |
$Apache::lonpublisher::metadatafields{'subject'}. |
$Apache::lonpublisher::metadatafields{'subject'}. |
Line 654 sub putresource {
|
Line 663 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 686 sub putresource {
|
Line 695 sub putresource {
|
} |
} |
my $pub_select = ''; |
my $pub_select = ''; |
&create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres); |
&create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres); |
$r->print('<tr class="LC_browser_file_'.$pubstatus.'">'. |
$r->print(&Apache::loncommon::start_data_table_row(). |
'<td>'.($filename=~/[\#\~]$/?' ': |
'<td>'.($filename=~/[\#\~]$/?' ': |
'<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'. |
'<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'. |
'<td>'.$pub_select.'</td>'. |
'<td>'.$pub_select.'</td>'. |
Line 695 sub putresource {
|
Line 704 sub putresource {
|
$filename.'</a></span>'.$editlink2.$editlink. |
$filename.'</a></span>'.$editlink2.$editlink. |
'</td>'. |
'</td>'. |
'<td>'.$title.'</td>'. |
'<td>'.$title.'</td>'. |
'<td>'.$status.'</td>'. |
'<td class="LC_browser_file_'.$pubstatus.'"> </td>'. # Display publication status |
|
'<td>'.$status.'</td>'. |
'<td>'.&Apache::lonlocal::locallocaltime($cmtime).'</td>'. |
'<td>'.&Apache::lonlocal::locallocaltime($cmtime).'</td>'. |
"</tr>\n"); |
&Apache::loncommon::end_data_table_row() |
|
); |
return OK; |
return OK; |
} |
} |
|
|
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 |
|
|