[LON-CAPA-cvs] cvs: rat / lonwrapper.pm loncom/interface domainprefs.pm londocs.pm lonextresedit.pm

raeburn raeburn at source.lon-capa.org
Wed May 10 09:49:24 EDT 2017


raeburn		Wed May 10 13:49:24 2017 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm londocs.pm lonextresedit.pm 
    /rat	lonwrapper.pm 
  Log:
  - Bug 6754. Make LON-CAPA an LTI Tool Consumer (LTI 1.1).
    - Display options are now: iframe, tab and window. 
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.297 loncom/interface/domainprefs.pm:1.298
--- loncom/interface/domainprefs.pm:1.297	Tue May  9 03:04:26 2017
+++ loncom/interface/domainprefs.pm	Wed May 10 13:49:14 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.297 2017/05/09 03:04:26 raeburn Exp $
+# $Id: domainprefs.pm,v 1.298 2017/05/10 13:49:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3758,6 +3758,8 @@
             if (ref($settings->{$item}->{'display'}) eq 'HASH') {
                 if ($settings->{$item}->{'display'}->{'target'} eq 'window') {
                     $currdisp{'window'} = ' checked="checked"';
+                } elsif ($settings->{$item}->{'display'}->{'target'} eq 'tab') {
+                    $currdisp{'tab'} = ' checked="checked"';
                 } else {
                     $currdisp{'iframe'} = ' checked="checked"';
                 }
@@ -3772,7 +3774,7 @@
             } else {
                 $currdisp{'iframe'} = ' checked="checked"';
             }
-            foreach my $disp ('iframe','window') {
+            foreach my $disp ('iframe','tab','window') {
                 $datatable .= '<label><input type="radio" name="ltitools_target_'.$i.'" value="'.$disp.'"'.$currdisp{$disp}.' />'.
                               $lt{$disp}.'</label>'.(' 'x2);
             }
@@ -3937,7 +3939,7 @@
                   '<span class="LC_nobreak">'.&mt('Display target:');
     my %defaultdisp;
     $defaultdisp{'iframe'} = ' checked="checked"';
-    foreach my $disp ('iframe','window') {
+    foreach my $disp ('iframe','tab','window') {
         $datatable .= '<label><input type="radio" name="ltitools_add_target" value="'.$disp.'"'.$defaultdisp{$disp}.' />'.
                       $lt{$disp}.'</label>'.(' 'x2);
     }
@@ -4024,7 +4026,8 @@
                                           'lastname'       => 'Last Name',
                                           'email'          => 'E-mail',
                                           'roles'          => 'Role',
-                                          'window'         => 'Window/Tab',
+                                          'window'         => 'Window',
+                                          'tab'            => 'Tab',
                                           'iframe'         => 'iFrame',
                                           'height'         => 'Height',
                                           'width'          => 'Width',
@@ -9532,6 +9535,8 @@
             }
             if ($env{'form.ltitools_add_target'} eq 'window') {
                 $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
+            } elsif ($env{'form.ltitools_add_target'} eq 'tab') {
+                $confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'};
             } else {
                 $confhash{$newid}{'display'}{'target'} = 'iframe';
             }
@@ -9671,6 +9676,8 @@
                     }
                     if ($env{'form.ltitools_target_'.$i} eq 'window') {
                         $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
+                    } elsif ($env{'form.ltitools_target_'.$i} eq 'tab') {
+                        $confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i};
                     } else {
                         $confhash{$itemid}{'display'}{'target'} = 'iframe';
                     }
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.627 loncom/interface/londocs.pm:1.628
--- loncom/interface/londocs.pm:1.627	Wed May 10 00:03:08 2017
+++ loncom/interface/londocs.pm	Wed May 10 13:49:14 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.627 2017/05/10 00:03:08 raeburn Exp $
+# $Id: londocs.pm,v 1.628 2017/05/10 13:49:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -678,7 +678,8 @@
                     my @deleted;
                     if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
                         $toolhash{'id'} = $toolid;
-                        if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'window')) {
+                        if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
+                            ($toolhash{'target'} eq 'window')) {
                             if ($toolhash{'target'} eq 'window') {
                                 foreach my $item ('width','height') {
                                     $toolhash{$item} =~ s/^\s+//;
@@ -716,6 +717,15 @@
                                     }
                                 }
                             }
+                        } elsif ($toolhash{'target'} eq 'tab') {
+                            foreach my $item ('width','height') {
+                                delete($toolhash{$item});
+                                if ($residx) {
+                                    if ($toolsettings{$item}) {
+                                        push(@deleted,$item);
+                                    }
+                                }
+                            }
                         }
                         if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
                             foreach my $item ('label','title','linktext','explanation') {
Index: loncom/interface/lonextresedit.pm
diff -u loncom/interface/lonextresedit.pm:1.18 loncom/interface/lonextresedit.pm:1.19
--- loncom/interface/lonextresedit.pm:1.18	Mon May  8 14:20:20 2017
+++ loncom/interface/lonextresedit.pm	Wed May 10 13:49:14 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: lonextresedit.pm,v 1.18 2017/05/08 14:20:20 raeburn Exp $
+# $Id: lonextresedit.pm,v 1.19 2017/05/10 13:49:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -272,14 +272,21 @@
         if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
             if ($newhash{'target'} eq 'iframe') {
                 $newhash{$item} = '';
+            } elsif ($newhash{'target'} eq 'tab') {
+                if (($item eq 'width') || ($item eq 'height')) {
+                    $newhash{$item} = '';
+                }
             }
         }
         if ($toolhash{$item} ne $newhash{$item}) {
             if ($newhash{$item} eq '') {
                 unless (($item eq 'target') ||
-                        ((($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) &&
+                        ((($item eq 'width') || ($item eq 'height')) &&
                          (($newhash{'target'} eq 'window') || 
-                          (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window'))))) {
+                          (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window')))) ||
+                        ((($item eq 'linktext') || ($item eq 'explanation')) &&
+                         ((($newhash{'target'} =~ /^(window|tab)$/)) ||
+                         (($newhash{'target'} eq '') && ($toolhash{'target'} =~ /^(window|tab)$/))))) {
                     delete($toolhash{$item});
                     push(@deleted,$item);
                     $changed = 1;
@@ -447,6 +454,9 @@
                                     $dimendivstyle = 'display:block';
                                     $windivstyle = 'display:block';
                                     $chkstate{'window'} = 'checked="checked" ';
+                                } elsif ($tooltarget eq 'tab') {
+                                    $windivstyle = 'display:block';
+                                    $chkstate{'tab'} = 'checked="checked" ';
                                 } else {
                                     $chkstate{'iframe'} = 'checked="checked" ';
                                 }
@@ -511,6 +521,9 @@
                     '<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'.
                     "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
                     '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('iframe').'</label>'.(' 'x2).
+                    '<label><input type="radio" name="exttooltarget" value="tab" '.$chkstate{'tab'}.'onclick="updateTooldim(this.form,'.
+                    "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
+                    '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('tab').'</label>'.(' 'x2).
                     '<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'.
                     "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
                     '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('window').'</label></span>'.
@@ -729,6 +742,8 @@
                                 var height = extform.exttoolheight.value;
                                 height.trim();
                                 info += ':window:'+width+':'+height;
+                            } else if (extform.exttooltarget[i].value == 'tab') {
+                                info += ':tab::';
                             } else {
                                 info += ':iframe::';
                             }
@@ -906,7 +921,7 @@
                             }
                         }
                         if (document.getElementById(windiv)) {
-                            if (ltitoolsTarget[j] == 'window') {
+                            if ((ltitoolsTarget[j] == 'window') || (ltitoolsTarget[j] == 'tab')) {
                                 document.getElementById(windiv).style.display = 'block';
                             } else {
                                 document.getElementById(windiv).style.display = 'none';
@@ -972,17 +987,21 @@
                     dimen = 'block';
                     linkconf = 'block';
                 } else {
-                    if (document.getElementById(widthinput)) {
-                        document.getElementById(widthinput).value = '';
-                    }
-                    if (document.getElementById(heightinput)) {
-                        document.getElementById(heightinput).value = '';
-                    }
-                    if (document.getElementById(linkinput)) {
-                        document.getElementById(linkinput).value = '';
-                    }
-                    if (document.getElementById(explaininput)) {
-                        document.getElementById(explaininput).value = '';
+                    if (form.exttooltarget[i].value == 'tab') {
+                        linkconf = 'block';
+                    } else {
+                        if (document.getElementById(widthinput)) {
+                            document.getElementById(widthinput).value = '';
+                        }
+                        if (document.getElementById(heightinput)) {
+                            document.getElementById(heightinput).value = '';
+                        }
+                        if (document.getElementById(linkinput)) {
+                            document.getElementById(linkinput).value = '';
+                        }
+                        if (document.getElementById(explaininput)) {
+                            document.getElementById(explaininput).value = '';
+                        }
                     }
                 }
                 if (document.getElementById(dimendiv)) {
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.62 rat/lonwrapper.pm:1.63
--- rat/lonwrapper.pm:1.62	Mon May  8 14:20:32 2017
+++ rat/lonwrapper.pm	Wed May 10 13:49:21 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Wrapper for external and binary files as standalone resources
 #
-# $Id: lonwrapper.pm,v 1.62 2017/05/08 14:20:32 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.63 2017/05/10 13:49:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,7 +42,8 @@
 
 # ================================================================ Main Handler
 sub wrapper {
-    my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,$title) = @_;
+    my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation,
+        $title,$width,$height) = @_;
 
     my $forcereg;
     unless ($env{'form.folderpath'}) {
@@ -83,7 +84,7 @@
     my $startpage = &Apache::loncommon::start_page('Menu',undef,$args);
     my $endpage = &Apache::loncommon::end_page();
     
-    if (($env{'browser.mobile'}) || ($exttool eq 'window')) {
+    if (($env{'browser.mobile'}) || ($exttool eq 'window') || ($exttool eq 'tab')) {
         my $output = $startpage;
         if ($is_pdf) {
             if ($title eq '') {
@@ -99,14 +100,41 @@
                 $output .= $title.'<br />';
             }
             $output .= '<a href="'.$url.'">'.&mt('Link to PDF (for mobile devices)').'</a>';
-        } elsif ($exttool eq 'window') {
+        } elsif (($exttool eq 'window') || ($exttool eq 'tab')) {
             if ($linktext eq '') {
                 $linktext = &mt('Launch External Tool');
             }
-            $output .= '<div>'.
-                       '<a href="'.$url.'" target="LC_LTI" style="padding:0;clear:both;margin:0;border:0">'.
-                       $linktext.'</a>'.
-                       '</div>';
+            if ($exttool eq 'tab') {
+                $output .= '<div>'.
+                           '<a href="'.$url.'" target="LCExternalToolTab" style="padding:0;clear:both;margin:0;border:0">'.
+                           $linktext.'</a>'.
+                           '</div>';
+            } else {
+                $output .= <<"ENDLINK";
+<script type="text/javascript">
+var windowObjectReference = null; 
+var PreviousUrl; 
+                           
+function openSinglePopup(strUrl) {
+    if (windowObjectReference == null || windowObjectReference.closed) {
+        windowObjectReference = window.open(strUrl, "LCExternalToolPopUp",
+                                            "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
+    } else if(PreviousUrl != strUrl) {
+        windowObjectReference = window.open(strUrl, "LCExternalToolPopUp",
+                                            "height=$height,width=$width,scrollbars=yes,resizable=yes,status=yes,menubar=no,location=no'");
+        windowObjectReference.focus();
+    } else {
+        windowObjectReference.focus();
+    };
+    PreviousUrl = strUrl;
+}
+</script>
+<div>
+<a href="$url" target="LCExternalToolPopUp" onclick="openSinglePopup(this.href); return false;">
+$linktext</a>
+</div>
+ENDLINK
+            }
             if ($explanation ne '') {
                 $output .= '<div>'.$explanation.'</div>';
             }
@@ -171,7 +199,7 @@
 
     my $url = $r->uri;
     my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname,
-        $linktext,$explanation);
+        $linktext,$explanation,$width,$height);
 
     for ($url){
         s|^/adm/wrapper||;
@@ -189,7 +217,7 @@
         my $marker = $3;
         $exttool = 'iframe';
         my $exttoolremote;
-        my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id'],
+        my %toolhash = &Apache::lonnet::get('exttool_'.$marker,['target','linktext','explanation','id','width','height'],
                                             $cdom,$cnum);
         if ($toolhash{'id'}) {
             my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
@@ -198,11 +226,17 @@
             }
         }
         if ($toolhash{'target'} eq 'window') {
-            $exttool = 'window'; 
+            $exttool = 'window';
+            $width = $toolhash{'width'};
+            $height = $toolhash{'height'};
+        } elsif ($toolhash{'target'} eq 'tab') {
+            $exttool = 'tab'; 
+        }
+        if (($exttool eq 'window') || ($exttool eq 'tab')) {
             $linktext = $toolhash{'linktext'}; 
             $explanation = $toolhash{'explanation'};
         } elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {
-            $exttool = 'window';
+            $exttool = 'tab';
         }
     }
     if (($is_ext) || ($exttool)) {
@@ -277,7 +311,8 @@
             &Apache::lonenc::check_encrypt(\$url);
         }
 
-        $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,$linktext,$explanation) );
+        $r->print( wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$exttool,
+                           $linktext,$explanation,undef,$width,$height) );
 
     } # not just the menu
     


More information about the LON-CAPA-cvs mailing list