[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm lonxml.pm

raeburn raeburn at source.lon-capa.org
Mon Apr 16 15:46:14 EDT 2012


raeburn		Mon Apr 16 19:46:14 2012 EDT

  Modified files:              
    /loncom/xml	londefdef.pm lonxml.pm 
  Log:
  - Part of change in lonxml.pm rev 1.529 moved to subroutine: 
    &get_courseupload_hierarchy() which returns symb, item title in course
    and path based on folder context for HTML page uploaded directly to course.
  - Bug 6448.  "Manage Dependencies" button to open pop-up window to upload,
    replace or delete files associated with an HTML page in a course.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.438 loncom/xml/londefdef.pm:1.439
--- loncom/xml/londefdef.pm:1.438	Thu Mar  1 21:13:36 2012
+++ loncom/xml/londefdef.pm	Mon Apr 16 19:46:14 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.438 2012/03/01 21:13:36 droeschl Exp $
+# $Id: londefdef.pm,v 1.439 2012/04/16 19:46:14 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -631,6 +631,16 @@
     $result .= '
 <div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" />';
     if (($env{'request.course.id'}) && ($env{'form.forceedit'})) {
+        my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
+        if ($url =~ /\.html?$/i) {
+            my ($symb,$itemtitle,$displayfile) = 
+                &Apache::lonxml::get_courseupload_hierarchy($url);
+            if ($symb ne '') {
+                  $result .= (' ' x 3).
+                             &Apache::lonhtmlcommon::dependencies_button()."\n".
+                             &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle)."\n";
+            }
+        }
         my $viewtext = &mt('Course View');
         if (&Apache::loncommon::course_type() eq 'Community') {
             $viewtext = &mt('Community View');
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.529 loncom/xml/lonxml.pm:1.530
--- loncom/xml/lonxml.pm:1.529	Wed Apr 11 15:58:07 2012
+++ loncom/xml/lonxml.pm	Mon Apr 16 19:46:14 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.529 2012/04/11 15:58:07 raeburn Exp $
+# $Id: lonxml.pm,v 1.530 2012/04/16 19:46:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1510,12 +1510,12 @@
 }
 
 sub inserteditinfo {
-      my ($filecontents, $filetype, $filename)=@_;
+      my ($filecontents,$filetype,$filename,$symb,$itemtitle) = @_;
       $filecontents = &HTML::Entities::encode($filecontents,'<>&"');
       my $xml_help = '';
       my $initialize='';
       my $textarea_id = 'filecont';
-      my $dragmath_button;
+      my ($dragmath_button,$deps_button);
       my ($add_to_onload, $add_to_onresize);
       $initialize=&Apache::lonhtmlcommon::spellheader();
       if (($filetype eq 'html') && (&Apache::lonhtmlcommon::htmlareabrowser())) {
@@ -1536,6 +1536,11 @@
 </script>
 FULLPAGE
       if ($filetype eq 'html') {
+          if ($symb) {
+              $deps_button = &Apache::lonhtmlcommon::dependencies_button()."\n";
+              $initialize .= 
+                  &Apache::lonhtmlcommon::dependencycheck_js($symb,$itemtitle)."\n";
+          }
           $dragmath_button = '<span id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';
           $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
       }
@@ -1580,7 +1585,7 @@
     <div class="LC_edit_problem_discards">
       <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />
       <input type="submit" name="Undo" accesskey="u" value="$lt{'un'}" />
-      $htmlerror $dragmath_button
+      $htmlerror $deps_button $dragmath_button
     </div>
     <div class="LC_edit_problem_saves">
       <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />
@@ -1789,26 +1794,17 @@
     unless ($env{'request.state'} eq 'published') {
 	if ($env{'form.editmode'} && (!($env{'form.viewmode'})) && (!($env{'form.discardview'})))
 	{
-	    my $displayfile=$request->uri;
-            if ($displayfile =~ m{^/uploaded/}) {
-                if ($env{'request.course.id'}) {
-                    my $symb = &Apache::lonnet::symbread();
-                    my ($map,$id,$res)=&Apache::lonnet::decode_symb($symb);
-                    my $navmap=Apache::lonnavmaps::navmap->new;
-                    if (ref($navmap)) {
-                        my $res = $navmap->getBySymb($symb);
-                        my @pathitems = 
-                            &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
-                        push(@pathitems,$res->compTitle());
-                        $displayfile = join(' » ', at pathitems);
-                    }
-                }
+            my ($displayfile,$url,$symb,$itemtitle);
+	    $displayfile=$request->uri;
+            if ($request->uri =~ m{^/uploaded/}) {
+                ($symb,$itemtitle,$displayfile) = 
+                    &get_courseupload_hierarchy($request->uri);
             } else {
 	        $displayfile=~s/^\/[^\/]*//;
             }
 
 	    my ($edit_info, $add_to_onload, $add_to_onresize)=
-		&inserteditinfo($filecontents,$filetype,$displayfile);
+		&inserteditinfo($filecontents,$filetype,$displayfile,$symb,$itemtitle);
 
 	    my %options = 
 		('add_entries' =>
@@ -1858,6 +1854,27 @@
     return $result;
 }
 
+sub get_courseupload_hierarchy {
+    my ($url) = @_;
+    my ($symb,$itemtitle,$displaypath);
+    if ($env{'request.course.id'}) {
+        $symb = &Apache::lonnet::symbread();
+        my ($map,$id,$res)=&Apache::lonnet::decode_symb($symb);
+        my $navmap=Apache::lonnavmaps::navmap->new;
+        if (ref($navmap)) {
+            my $res = $navmap->getBySymb($symb);
+            if (ref($res)) {
+                my @pathitems =
+                    &Apache::loncommon::get_folder_hierarchy($navmap,$map,1);
+                $itemtitle = $res->compTitle();
+                push(@pathitems,$itemtitle);
+                $displaypath = join(' » ', at pathitems);
+            }
+        }
+    }
+    return ($symb,$itemtitle,$displaypath);
+}
+
 sub debug {
     if ($Apache::lonxml::debug eq "1") {
 	$|=1;




More information about the LON-CAPA-cvs mailing list