[LON-CAPA-cvs] cvs: loncom /publisher lonpubdir.pm

www www at source.lon-capa.org
Fri Oct 21 18:33:14 EDT 2011


www		Fri Oct 21 22:33:14 2011 EDT

  Modified files:              
    /loncom/publisher	lonpubdir.pm 
  Log:
  Bug #1320
  
  
-------------- next part --------------
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.128 loncom/publisher/lonpubdir.pm:1.129
--- loncom/publisher/lonpubdir.pm:1.128	Fri Oct 21 18:04:51 2011
+++ loncom/publisher/lonpubdir.pm	Fri Oct 21 22:33:14 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.128 2011/10/21 18:04:51 www Exp $
+# $Id: lonpubdir.pm,v 1.129 2011/10/21 22:33:14 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,9 +106,9 @@
      my $extension='';
      if ($filename=~/\.(\w+)$/) { $extension=$1; }
      if ($cmode&$dirptr) {
-	 putdirectory($r, $thisdisfn, $linkdir, $filename, $cmtime,$targetdir,\%bombs,\$numdir);
+	 &putdirectory($r, $thisdisfn, $linkdir, $filename, $cmtime,$targetdir,\%bombs,\$numdir);
      } elsif (&Apache::loncommon::fileembstyle($extension) ne 'hdn') {
-	 putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir, 
+	 &putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir, 
 		     $targetdir, $linkdir, $cmtime,\%bombs,\$numres);
      } else {
 	# "hidden" extension and not a directory, so hide it away.
@@ -135,7 +135,6 @@
 
 sub startpage {
     my ($r, $uname, $udom, $thisdisfn) = @_;
-    my $currdir = '/priv/'.$uname.$thisdisfn;
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 
@@ -151,7 +150,7 @@
     # breadcrumbs (and tools) will be created 
     # in start_page->bodytag->innerregister
 
-    $env{'request.noversionuri'}=$currdir.'/';
+    $env{'request.noversionuri'}='/priv/'.$udom.'/'.$uname.$thisdisfn.'/';
     $r->print(&Apache::loncommon::start_page('Construction Space',undef));
 
     $r->print(&Apache::loncommon::head_subbox(
@@ -165,7 +164,7 @@
 top.document.title = '$esc_thisdisfn/ - $doctitle';
 // Store directory location for menu bar to find
 
-parent.lastknownpriv='/~$uname$esc_thisdisfn/';
+parent.lastknownpriv='/priv/$udom/$uname$esc_thisdisfn/';
 
 // Confirmation dialogues
 
@@ -320,7 +319,7 @@
             <option value="printdir">$lt{'prnt'}</option>
             <option value="delete">$lt{'dedr'}</option>
         </select>
-        <input type="hidden" name="filename" value="/~$uname$thisdisfn/" />
+        <input type="hidden" name="filename" value="/priv/$udom/$uname$thisdisfn/" />
       </fieldset>
     </form>
     <form name="publishdir" method="post" action="/adm/publish" target="_parent">
@@ -336,7 +335,7 @@
     <form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload" target="_parent">
       <fieldset>
         <legend>$lt{'updc'}</legend>
-        <input type="hidden" name="filename" value="/~$uname$thisdisfn/" />
+        <input type="hidden" name="filename" value="/priv/$udom/$uname$thisdisfn/" />
         <input type="file" name="upfile" size="20" />
         <input type="button" value="$lt{'uplo'}"  onclick="checkUpload(this.form)" />
       </fieldset>
@@ -348,7 +347,7 @@
       <fieldset>
               <legend>$lt{'crea'}</legend>
 	      <span class="LC_nobreak">
-		<input type="hidden" name="filename" value="/~$uname$thisdisfn/" />
+		<input type="hidden" name="filename" value="/priv/$udom/$uname$thisdisfn/" />
                   <script type="text/javascript">
                     function validate_go() {
                         var selected = document.fileaction.action.selectedIndex;
@@ -447,7 +446,11 @@
 # 
 sub putdirectory {
     my ($r, $reqfile, $here, $dirname, $modtime, $resdir, $bombs, $numdir) = @_;
-    # construct the display filename: the directory name unless ..:
+
+#&Apache::lonnet::logthis("reqfile $reqfile here $here dirname $dirname resdir $resdir");
+
+
+# construct the display filename: the directory name unless ..:
     
     my $disfilename = $dirname;
     if ($dirname eq '..') {
@@ -458,17 +461,17 @@
 	foreach (keys %{$bombs}) {
 	    if ($_=~m:^\Q$resdir\E/\Q$disfilename\E/:) { $kaputt=1; last; }
 	}
+#
+# Get the metadata from that directory's default.meta to display titles
+#
 	%Apache::lonpublisher::metadatafields=();
 	%Apache::lonpublisher::metadatakeys=();
-	my $construct=$here;
-	$construct=~s{^/priv/($LONCAPA::username_re)$}{/home/$1/public_html};
-        my $dirpath = $here;
-        $dirpath=~s{^/priv/}{/~};
-	&Apache::lonpublisher::metaeval(&Apache::lonnet::getfile(
-       				 $construct.'/'.$dirname.'/default.meta'
-								 ));
+	&Apache::lonpublisher::metaeval(
+                 &Apache::lonnet::getfile($r->dir_config('lonDocRoot').$here.'/'.$dirname.'/default.meta')
+                                       );
+#
         my $actionitem = '';
-        if ($dirname eq '..') {
+        if ($here eq '..') {
             $actionitem = &mt('Go to ...');
         } else {
             $actionitem = 
@@ -482,7 +485,7 @@
                       '<option value="printdir">'.&mt('Print directory').'</option>'.
                       '<option value="delete">'.&mt('Delete directory').'</option>'.
                     '</select>'.
-                     '<input type="hidden" name="filename" value="'.&HTML::Entities::encode($dirpath.'/'.$dirname,'<>&"').'/" />'.
+                     '<input type="hidden" name="filename" value="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" />'.
                      '<input type="hidden" name="openname" value="'.$here.'/'.$dirname.'/" />'.
                      '<input type="hidden" name="postdata" value="" />'.
                    '</form>';
@@ -519,11 +522,9 @@
     my $css_class='LC_browser_file';
     my $title=' ';
     my $publish_button=&mt('Publish');
-    my $cstr_dir = '/home/'.$uname.'/public_html/'.$thisdisfn.'/';
-#    my $action_buttons=
-#        '<br /><a target="_parent" href="/adm/cfile?action=delete&filename=/~'.
-#	$uname.'/'.$thisdisfn.'/'.$filename.'">'.
-#	&mt('Delete').'</a>';
+    my $cstr_dir = $r->dir_config('lonDocRoot').'/priv/'.$udom.'/'.$uname.'/'.$thisdisfn.'/';
+    my $linkfilename='/priv'.$thisdisfn.'/'.$filename;
+
     if (-e $resdir.'/'.$filename) {
         my $same=0;
 	my ($rdev,$rino,$rmode,$rnlink,
@@ -576,34 +577,26 @@
 		$status=&mt('Published').
 		    '<br />'. $rights_status;
 	    }
-#	    } else {
-#		$action_buttons='';
-#	    }
 	} else {
             $pubstatus = 'modified';
 	    $status=&mt('Modified').
 		'<br />'. $rights_status;
-#	    $action_buttons='';
 	    if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
-		$status.='<br /><a href="/adm/diff?filename=/~'.$uname.
-		    $thisdisfn.'/'.$filename.
+		$status.='<br /><a href="/adm/diff?filename='.$linkfilename.
 		    '&versiontwo=priv" target="cat">'.&mt('Diffs').'</a>';
 	    }
 	} 
 
-	$title.="\n".'<br /><a href="/~'.$uname.$thisdisfn.'/'.$filename.'.meta">'. 
+	$title.="\n".'<br /><a href="'.$linkfilename.'.meta">'. 
 	    ($$bombs{$targetdir.'/'.$filename}?'<img src="/adm/lonMisc/bomb.gif" border="0" alt="'.&mt('bomb').'" />':&mt('Edit Metadata')).'</a>';
 
 	if (!$meta_same) {
 	    $title = &mt('Metadata Modified').'<br />'.$title.
-		'<br /><a href="/adm/diff?filename=/~'.$uname.
-		$thisdisfn.'/'.$filename.'.meta'.
+		'<br /><a href="/adm/diff?filename=/priv/'.$linkfilename.'.meta'.
 		'&versiontwo=priv" target="cat">'.&mt('Metadata Diffs').'</a>';
-	    $title.="\n".'<br /><a href="/adm/retrieve?filename=/~'.$uname.
-		$thisdisfn.'/'.$filename.'.meta" target="_parent">'.&mt('Retrieve Metadata').'</a>';
+	    $title.="\n".'<br /><a href="/adm/retrieve?filename='.$linkfilename.'.meta" target="_parent">'.&mt('Retrieve Metadata').'</a>';
 	}
-	$status.="\n".'<br /><a href="/adm/retrieve?filename=/~'.$uname.
-	    $thisdisfn.'/'.$filename.'" target="_parent">'.&mt('Retrieve').'</a>';
+	$status.="\n".'<br /><a href="/adm/retrieve?filename='.$linkfilename.'" target="_parent">'.&mt('Retrieve').'</a>';
     }
     my $editlink='';
     my $editlink2='';
@@ -615,12 +608,10 @@
 	$editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?forceColoredit=1" target="_parent">'.&mt('Edit').'</a>)';
     }
     if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
-	$editlink.=' (<a href="/adm/cleanup?filename=/~'.$uname.
-	    $thisdisfn.'/'.$filename.'" target="_parent">'.&mt('Clean Up').')</a>';
+	$editlink.=' (<a href="/adm/cleanup?filename='.$linkfilename.'" target="_parent">'.&mt('Clean Up').')</a>';
     }
     if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
-	$editlink=' (<a target="_parent" href="/adm/cfile?decompress=/~'.
-	      $uname.$thisdisfn.'/'.$filename.'">'.&mt('Decompress').'</a>)';
+	$editlink=' (<a target="_parent" href="/adm/cfile?decompress='.$linkfilename.'">'.&mt('Decompress').'</a>)';
     }
     my $pub_select = '';
     &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
@@ -694,32 +685,6 @@
     return $versions;
 }
 
-#
-#   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.
-#
-sub CategorizeFiles {
-    my $location = shift;
-    my $files    = shift;
-}
-
 1;
 __END__
 
@@ -816,26 +781,6 @@
         $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


More information about the LON-CAPA-cvs mailing list