[LON-CAPA-cvs] cvs: loncom /interface londependencies.pm londocs.pm lonhtmlcommon.pm /lonnet/perl lonnet.pm /xml londefdef.pm

raeburn raeburn at source.lon-capa.org
Thu Nov 29 15:37:20 EST 2012


raeburn		Thu Nov 29 20:37:20 2012 EDT

  Modified files:              
    /loncom/interface	londependencies.pm londocs.pm lonhtmlcommon.pm 
    /loncom/xml	londefdef.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Consistent interface.
  - HTML files uploaded to course's Supplemental content area can be edited,
    and any dependencies can be replaced (or uploaded if missing).
  - "Course View" button provided when "editing" HTML files uploaded
    directly to a course removed; use "Exit Editing" item in Functions instead.  
  
  
-------------- next part --------------
Index: loncom/interface/londependencies.pm
diff -u loncom/interface/londependencies.pm:1.2 loncom/interface/londependencies.pm:1.3
--- loncom/interface/londependencies.pm:1.2	Fri Jul  6 22:46:06 2012
+++ loncom/interface/londependencies.pm	Thu Nov 29 20:37:07 2012
@@ -2,7 +2,7 @@
 # Handler to manage dependencies for HTML files uploaded directly
 # to a course. 
 #
-# $Id: londependencies.pm,v 1.2 2012/07/06 22:46:06 raeburn Exp $
+# $Id: londependencies.pm,v 1.3 2012/11/29 20:37:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -94,11 +94,12 @@
     $r->send_http_header;
 
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-                                            ['action','symb','title','url']);
+                                     ['action','symb','title','url','folderpath']);
     my $action = $env{'form.action'};
     my $symb = $env{'form.symb'};
     my $docs_title = $env{'form.title'};
     my $docs_url = $env{'form.url'};
+    my $folderpath = &unescape($env{'form.folderpath'});
     my ($mimetype,$numpathchgs,$numrefchanges,%allfiles,%codebase,$url);
     if ($symb) {
         (undef,undef,$url) = &Apache::lonnet::decode_symb($symb);
@@ -108,6 +109,7 @@
     }
     my $title = &mt('Manage Dependencies');
     my $state = '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
+                '<input type="hidden" name="folderpath" value="'.$env{'form.folderpath'}.'" />'."\n".
                 '<input type="hidden" name="title" value="'.$docs_title.'" />'."\n".
                 '<input type="hidden" name="url" value="'.$docs_url.'" />'."\n";
     my $dir_root = '/userfiles';
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.510 loncom/interface/londocs.pm:1.511
--- loncom/interface/londocs.pm:1.510	Tue Nov 27 23:34:41 2012
+++ loncom/interface/londocs.pm	Thu Nov 29 20:37:07 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.510 2012/11/27 23:34:41 raeburn Exp $
+# $Id: londocs.pm,v 1.511 2012/11/29 20:37:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2434,7 +2434,7 @@
         if ($title) {
             $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
         }
-        if ($orderidx) {
+        if ($isexternal && $orderidx) {
             $url .= '&idx='.$orderidx;
         }
     }
@@ -2451,25 +2451,19 @@
         my $fileloc = 
             &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
         if ($isexternal) {
-            $editlink =
+            $editlink = ' '.
                 &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
-        } else {
+        } elsif (!$isfolder && !$ispage) {
             my ($cfile,$home,$switchserver,$forceedit,$forceview) = 
                 &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
-            my $geteditlink;
-            if ($supplementalflag) {
-                if ($orig_url eq "/adm/$env{'user.domain'}/$env{'user.name'}/aboutme") {
-                    $geteditlink = 1;
-                }
-            } elsif (($cfile ne '') && ($symb ne '')) {
-                $geteditlink = 1;
-            }
-            if ($geteditlink) {
+            if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
                 my $jscall = 
                     &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
                                                             $switchserver,
                                                             $forceedit,
-                                                            undef,$symb);
+                                                            undef,$symb,
+                                                            &escape($env{'form.folderpath'}),
+                                                            $renametitle);
                 if ($jscall) {
                     $editlink = ' <a class="LC_docs_ext_edit" href="javascript:'.
                                 $jscall.'" >'.&mt('Edit').'</a>';
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.333 loncom/interface/lonhtmlcommon.pm:1.334
--- loncom/interface/lonhtmlcommon.pm:1.333	Thu Nov 29 20:13:43 2012
+++ loncom/interface/lonhtmlcommon.pm	Thu Nov 29 20:37:07 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.333 2012/11/29 20:13:43 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.334 2012/11/29 20:37:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -209,10 +209,19 @@
 =cut
 
 sub dependencycheck_js {
-    my ($symb,$title,$url) = @_;
-    my $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"').
-               '&title='.&HTML::Entities::encode($title,'<>&"').
-               '&url='.&HTML::Entities::encode($url,'<>&"');
+    my ($symb,$title,$url,$folderpath,$uri) = @_;
+    my $link;
+    if ($symb) {
+        $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"');
+    } elsif ($folderpath) {
+        $link = '/adm/dependencies?folderpath='.&HTML::Entities::encode($folderpath,'<>&"');
+         $url = $uri;
+    }
+    $link .= (($link=~/\?/)?'&':'?').'title='.
+             &HTML::Entities::encode($title,'<>&"');
+    if ($url) {
+        $link .= '&url='.&HTML::Entities::encode($url,'<>&"');
+    }
     return <<ENDJS;
                 <script type="text/javascript">
                 // <![CDATA[
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.440 loncom/xml/londefdef.pm:1.441
--- loncom/xml/londefdef.pm:1.440	Fri Jul  6 22:46:12 2012
+++ loncom/xml/londefdef.pm	Thu Nov 29 20:37:13 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.440 2012/07/06 22:46:12 raeburn Exp $
+# $Id: londefdef.pm,v 1.441 2012/11/29 20:37:13 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -599,7 +599,7 @@
             $header=&Apache::lonmenu::constspaceform();
         }
         if ($env{'request.state'} ne 'published') {
-            $header.=&Apache::londefdef::edit_controls();
+            $header.=&edit_controls();
         }
         if ($env{'request.state'} eq 'construct') {
             $currentstring.=&Apache::loncommon::head_subbox(
@@ -633,20 +633,27 @@
     if (($env{'request.course.id'}) && ($env{'form.forceedit'})) {
         my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
         if ($url =~ /\.html?$/i) {
+            if ($env{'request.course.id'}) {
+                if ($env{'request.filename'} =~ m{/userfiles/supplemental/default|\d+/}) {
+                    if (&Apache::lonnet::is_course_upload($env{'request.filename'},
+                        $env{'course.'.$env{'request.course.id'}.'.num'},
+                        $env{'course.'.$env{'request.course.id'}.'.domain'})) {
+                        &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+                                                                ['folderpath','title']);
+                    }
+                }
+            }
             my ($symb,$itemtitle,$displayfile) = 
-                &Apache::lonxml::get_courseupload_hierarchy($url);
+                &Apache::lonxml::get_courseupload_hierarchy($url,
+                                                            $env{'form.folderpath'},
+                                                            $env{'form.title'});
             if (($symb ne '') || ($env{'httpref.'.$url} ne '')) {
                   $result .= (' ' x 3).
                              &Apache::lonhtmlcommon::dependencies_button()."\n".
-                             &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle,$url)."\n";
+                             &Apache::lonhtmlcommon::dependencycheck_js($symb,
+                                 $itemtitle,$url,$env{'form.folderpath'},$url)."\n";
             }
         }
-        my $viewtext = &mt('Course View');
-        if (&Apache::loncommon::course_type() eq 'Community') {
-            $viewtext = &mt('Community View');
-        }
-        $result .= (' ' x 3).'<input type="button" value="'.
-                   $viewtext.'" onclick="javascript:location.href=currentURL" />';
     }
     $result .= '</div>
 </div>
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1200 loncom/lonnet/perl/lonnet.pm:1.1201
--- loncom/lonnet/perl/lonnet.pm:1.1200	Thu Nov 29 03:23:52 2012
+++ loncom/lonnet/perl/lonnet.pm	Thu Nov 29 20:37:19 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1200 2012/11/29 03:23:52 raeburn Exp $
+# $Id: lonnet.pm,v 1.1201 2012/11/29 20:37:19 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2732,7 +2732,11 @@
                 $incourse = 1;
                 if ($file =~/\.(htm|html|css|js|txt)$/) {
                     $cfile = &hreflocation('',$file);
-                    $forceedit = 1;
+                    if ($env{'form.forceedit'}) {
+                        $forceview = 1;
+                    } else {
+                        $forceedit = 1;
+                    }
                 }
             } elsif ($resurl =~ m{^/public/$cdom/$cnum/syllabus}) {
                 $incourse = 1;
@@ -2820,8 +2824,8 @@
     my ($file,$cnum,$cdom) = @_;
     my $uploadpath = &LONCAPA::propath($cdom,$cnum);
     $uploadpath =~ s{^\/}{};
-    if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
-        ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
+    if (($file =~ m{^\Q$uploadpath\E/userfiles/(docs|supplemental)/}) ||
+        ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/(docs|supplemental)/})) {
         return 1;
     }
     return;


More information about the LON-CAPA-cvs mailing list