[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm /publisher lonpubdir.pm lonpublisher.pm lonretrieve.pm

raeburn raeburn at source.lon-capa.org
Mon Oct 31 13:27:16 EDT 2011


raeburn		Mon Oct 31 17:27:16 2011 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm lonpubdir.pm lonretrieve.pm 
    /loncom/interface	loncommon.pm 
  Log:
  - Fix Construction breadcrumb trails for /adm/publish /adm/retrieve
    - loncommon::CSTR_pageheader() takes optional argument 
      - name of file or directory used to construct breadcrumb trail 
        where $env{'request.filename'} is inappropriate.
  - use lonDocRoot perlvar in place of static string: '/home/httpd/html' 
  - coding style
     - eliminate leaning toothpicks
  
  
-------------- next part --------------
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.274 loncom/publisher/lonpublisher.pm:1.275
--- loncom/publisher/lonpublisher.pm:1.274	Sun Oct 30 20:49:33 2011
+++ loncom/publisher/lonpublisher.pm	Mon Oct 31 17:27:10 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.274 2011/10/30 20:49:33 raeburn Exp $
+# $Id: lonpublisher.pm,v 1.275 2011/10/31 17:27:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2157,7 +2157,7 @@
     $r->print(&Apache::loncommon::start_page('Resource Publication',$js)
              .&Apache::lonhtmlcommon::breadcrumbs()
              .&Apache::loncommon::head_subbox(
-                  &Apache::loncommon::CSTR_pageheader()) # FIXME crumbs broken?
+                  &Apache::loncommon::CSTR_pageheader($docroot.$fn))
     );
 
     my $thisdisfn=&HTML::Entities::encode($fn,'<>&"');
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.134 loncom/publisher/lonpubdir.pm:1.135
--- loncom/publisher/lonpubdir.pm:1.134	Sun Oct 30 20:28:02 2011
+++ loncom/publisher/lonpubdir.pm	Mon Oct 31 17:27:10 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.134 2011/10/30 20:28:02 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.135 2011/10/31 17:27:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -154,7 +154,7 @@
     $r->print(&Apache::loncommon::start_page('Construction Space',undef));
 
     $r->print(&Apache::loncommon::head_subbox(
-                &Apache::loncommon::CSTR_pageheader(1)));
+                &Apache::loncommon::CSTR_pageheader()));
 
     my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
     my $doctitle = 'LON-CAPA '.&mt('Construction Space');
Index: loncom/publisher/lonretrieve.pm
diff -u loncom/publisher/lonretrieve.pm:1.45 loncom/publisher/lonretrieve.pm:1.46
--- loncom/publisher/lonretrieve.pm:1.45	Mon Oct 31 01:30:38 2011
+++ loncom/publisher/lonretrieve.pm	Mon Oct 31 17:27:10 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to retrieve an old version of a file
 #
-# $Id: lonretrieve.pm,v 1.45 2011/10/31 01:30:38 raeburn Exp $
+# $Id: lonretrieve.pm,v 1.46 2011/10/31 17:27:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -108,14 +108,12 @@
 # ------------------------------------ Interface for selecting previous version
 sub phaseone {
     my ($r,$fn,$uname,$udom)=@_;
-    my $docroot=$r->dir_config('lonDocRoot');
 
-    my $urldir='/res/'.$udom.'/'.$uname.$fn;
-    $urldir=~s/\/[^\/]+$/\//;
+    my $urldir = "/res/$udom/$uname".$fn;
+    my $resfn = $r->dir_config('lonDocRoot').$urldir;
 
-    my $resfn=$docroot.'/res/'.$udom.'/'.$uname.$fn;
-    my $resdir=$resfn;
-    $resdir=~s/\/[^\/]+$/\//;
+    $urldir =~ s{[^/]+$}{};
+    my $resdir = $r->dir_config('lonDocRoot').$urldir;
 
     my ($main,$suffix,$is_meta) = &get_file_info($fn);
     
@@ -207,16 +205,19 @@
     my $dir =  &Apache::loncommon::authorspace()
               .&File::Basename::dirname($fn)
               .'/';
-    $r->print(&Apache::lonhtmlcommon::start_funclist()
-             .&Apache::lonhtmlcommon::add_item_funclist(
-                  '<a href="/priv/'.$udom.'/'.$uname.$fn.'">'
-                 .&mt('Back to Resource')
-                 .'</a>')
-             .&Apache::lonhtmlcommon::add_item_funclist(
-                  '<a href="'.$dir.'">'
-                 .&mt('Back to Directory')
-                 .'</a>')
-             .&Apache::lonhtmlcommon::end_funclist()
+    $r->print('<br />'
+             .&Apache::loncommon::head_subbox(
+                  &Apache::lonhtmlcommon::start_funclist()
+                 .&Apache::lonhtmlcommon::add_item_funclist(
+                     '<a href="/priv/'.$udom.'/'.$uname.$fn.'">'
+                    .&mt('Back to Resource')
+                    .'</a>')
+                 .&Apache::lonhtmlcommon::add_item_funclist(
+                     '<a href="'.$dir.'">'
+                    .&mt('Back to Directory')
+                    .'</a>')
+                 .&Apache::lonhtmlcommon::end_funclist()
+             )
     );
 }
 
@@ -233,13 +234,13 @@
 	my ($main,$suffix,$is_meta) = &get_file_info($fn);
 
         my $logfile;
-        my $ctarget=$r->dir_config('lonDocRoot').'/priv/'.$udom.'/'.$uname.$fn;
+        my $ctarget=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$fn;
         my $vfn=$fn;
         if ($version ne 'new') {
 	    $vfn=~s/\.(\Q$suffix\E)$/\.$version\.$1/;
         }
 
-        my $csource=$r->dir_config('lonDocRoot').'/res/'.$udom.'/'.$uname.$vfn;
+        my $csource=$r->dir_config('lonDocRoot')."/res/$udom/$uname".$vfn;
 
 	my $logname = $ctarget;
 	if ($is_meta) { $logname =~ s/\.meta$//; }
@@ -302,7 +303,7 @@
 
   if ($env{'form.filename'}) {
       $fn=$env{'form.filename'};
-      $fn=~s/^https?\:\/\/[^\/]+//;
+      $fn =~ s{^https?\://[^/]+}{};
   } else {
      $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
          ' unspecified filename for retrieval', $r->filename); 
@@ -328,8 +329,6 @@
      return HTTP_NOT_ACCEPTABLE;
   }
 
-  $fn=~s{/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{};
-
   &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;
 
@@ -344,12 +343,18 @@
         'href'  => '',
     });
 
+    my $londocroot = $r->dir_config('lonDocRoot');
+    my $trailfile = $fn;
+    $trailfile =~ s{^/(priv/)}{$londocroot/$1};
+
   $r->print(&Apache::loncommon::start_page('Retrieve Published Resources')
            .&Apache::lonhtmlcommon::breadcrumbs()
            .&Apache::loncommon::head_subbox(
-                &Apache::loncommon::CSTR_pageheader()) # FIXME crumbs broken?
+                &Apache::loncommon::CSTR_pageheader($trailfile))
     );
 
+  $fn=~s{/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{};
+
   $r->print('<p>'
            .&mt('Retrieve previous versions of [_1]'
                    ,'<span class="LC_filename">'.$fn.'</span>')
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1025 loncom/interface/loncommon.pm:1.1026
--- loncom/interface/loncommon.pm:1.1025	Mon Oct 31 01:14:24 2011
+++ loncom/interface/loncommon.pm	Mon Oct 31 17:27:15 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1025 2011/10/31 01:14:24 raeburn Exp $
+# $Id: loncommon.pm,v 1.1026 2011/10/31 17:27:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4446,7 +4446,7 @@
             close($fh);
         }
     }
-    if (-e '/home/httpd/html/adm/lonDomLogos/'.$udom.'.gif') {
+    if (-e $Apache::lonnet::perlvar{'lonDocRoot'}.'/adm/lonDomLogos/'.$udom.'.gif') {
         $legacyhash{$udom.'.login.domlogo'} = "/adm/lonDomLogos/$udom.gif";
     }
     return %legacyhash;
@@ -4582,7 +4582,9 @@
 
 =item * &CSTR_pageheader()
 
-Inputs: ./.
+Input: (optional) filename from which breadcrumb trail is built.
+       In most cases no input as needed, as $env{'request.filename'}
+       is appropriate for use in building the breadcrumb trail.
 
 Returns: HTML div with CSTR path and recent box
          To be included on Construction Space pages
@@ -4590,12 +4592,19 @@
 =cut
 
 sub CSTR_pageheader {
-    # this is for resources; directories have customtitle, and crumbs
-            # and select recent are created in lonpubdir.pm  
+    my ($trailfile) = @_;
+    if ($trailfile eq '') {
+        $trailfile = $env{'request.filename'};
+    }
+
+# this is for resources; directories have customtitle, and crumbs
+# and select recent are created in lonpubdir.pm
+
+    my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
     my ($udom,$uname,$thisdisfn)=
-        ($env{'request.filename'} =~ m|^/home/httpd/html/priv/([^/]+)/([^/]+)/(.*)$|);
-    my $formaction='/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
-    $formaction=~s/\/+/\//g;
+        ($trailfile =~ m{^\Q$londocroot\E/priv/([^/]+)/([^/]+)/(.*)$});
+    my $formaction = "/priv/$udom/$uname/$thisdisfn";
+    $formaction =~ s{/+}{/}g;
 
     my $parentpath = '';
     my $lastitem = '';
@@ -8451,7 +8460,7 @@
     } elsif (($actionurl eq '/adm/upload') || ($actionurl eq '/adm/testbank') ||
              ($actionurl eq '/adm/imsimport')) { 
         my ($udom,$uname,$rest) = ($args->{'current_path'} =~ m{/priv/($match_domain)/($match_username)/?(.*)$});
-        $url = '/home/httpd/html/priv/'.$udom.'/'.$uname.'/';
+        $url = $Apache::lonnet::perlvar{'lonDocRoot'}."/priv/$udom/$uname/";
         $toplevel = $url;
         if ($rest ne '') {
             $url .= $rest;


More information about the LON-CAPA-cvs mailing list