Diff for /rat/lonwrapper.pm between versions 1.62 and 1.63

version 1.62, 2017/05/08 14:20:32 version 1.63, 2017/05/10 13:49:21
Line 42  use LONCAPA qw(:DEFAULT :match);; Line 42  use LONCAPA qw(:DEFAULT :match);;
   
 # ================================================================ Main Handler  # ================================================================ Main Handler
 sub wrapper {  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;      my $forcereg;
     unless ($env{'form.folderpath'}) {      unless ($env{'form.folderpath'}) {
Line 83  sub wrapper { Line 84  sub wrapper {
     my $startpage = &Apache::loncommon::start_page('Menu',undef,$args);      my $startpage = &Apache::loncommon::start_page('Menu',undef,$args);
     my $endpage = &Apache::loncommon::end_page();      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;          my $output = $startpage;
         if ($is_pdf) {          if ($is_pdf) {
             if ($title eq '') {              if ($title eq '') {
Line 99  sub wrapper { Line 100  sub wrapper {
                 $output .= $title.'<br />';                  $output .= $title.'<br />';
             }              }
             $output .= '<a href="'.$url.'">'.&mt('Link to PDF (for mobile devices)').'</a>';              $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 '') {              if ($linktext eq '') {
                 $linktext = &mt('Launch External Tool');                  $linktext = &mt('Launch External Tool');
             }              }
             $output .= '<div>'.              if ($exttool eq 'tab') {
                        '<a href="'.$url.'" target="LC_LTI" style="padding:0;clear:both;margin:0;border:0">'.                  $output .= '<div>'.
                        $linktext.'</a>'.                             '<a href="'.$url.'" target="LCExternalToolTab" style="padding:0;clear:both;margin:0;border:0">'.
                        '</div>';                             $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 '') {              if ($explanation ne '') {
                 $output .= '<div>'.$explanation.'</div>';                  $output .= '<div>'.$explanation.'</div>';
             }              }
Line 171  sub handler { Line 199  sub handler {
   
     my $url = $r->uri;      my $url = $r->uri;
     my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname,      my ($is_ext,$brcrum,$absolute,$is_pdf,$exttool,$cdom,$cnum,$hostname,
         $linktext,$explanation);          $linktext,$explanation,$width,$height);
   
     for ($url){      for ($url){
         s|^/adm/wrapper||;          s|^/adm/wrapper||;
Line 189  sub handler { Line 217  sub handler {
         my $marker = $3;          my $marker = $3;
         $exttool = 'iframe';          $exttool = 'iframe';
         my $exttoolremote;          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);                                              $cdom,$cnum);
         if ($toolhash{'id'}) {          if ($toolhash{'id'}) {
             my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);              my %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
Line 198  sub handler { Line 226  sub handler {
             }              }
         }          }
         if ($toolhash{'target'} eq 'window') {          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'};               $linktext = $toolhash{'linktext'}; 
             $explanation = $toolhash{'explanation'};              $explanation = $toolhash{'explanation'};
         } elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {          } elsif (($exttoolremote =~ /^http:/) && ($ENV{'SERVER_PORT'} == 443)) {
             $exttool = 'window';              $exttool = 'tab';
         }          }
     }      }
     if (($is_ext) || ($exttool)) {      if (($is_ext) || ($exttool)) {
Line 277  sub handler { Line 311  sub handler {
             &Apache::lonenc::check_encrypt(\$url);              &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      } # not just the menu
           

Removed from v.1.62  
changed lines
  Added in v.1.63


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>