Diff for /loncom/interface/lonextresedit.pm between versions 1.8.2.4.2.1 and 1.17

version 1.8.2.4.2.1, 2020/01/13 19:03:37 version 1.17, 2017/05/06 15:47:48
Line 60  sub handler { Line 60  sub handler {
         $symb,$type);          $symb,$type);
     if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) {      if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) {
         $supplementalflag = 1;          $supplementalflag = 1;
         if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {          if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) {
             $type = 'tool';              $type = 'tool';
         }          }
     }      }
Line 79  sub handler { Line 79  sub handler {
             if ($symb ne $env{'form.symb'}) {              if ($symb ne $env{'form.symb'}) {
                 $env{'form.symb'} = $symb;                  $env{'form.symb'} = $symb;
             }              }
             if ($url =~ m{/adm/$cdom/$cnum/\d+/ext\.tool$}) {              if ($url =~ m{/adm/$cdom/$cnum/\d+/exttools?$}) {
                 $type = 'tool';                  $type = 'tool';
             }              }
         }          }
Line 146  sub process_changes { Line 146  sub process_changes {
         $oldtitle = &unescape($env{'form.title'});          $oldtitle = &unescape($env{'form.title'});
         $container = 'sequence';          $container = 'sequence';
         $supplementalflag = 1;          $supplementalflag = 1;
         if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {          if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) {
             $type = 'tool';              $type = 'tool';
         } else {          } else {
             $type = 'ext';              $type = 'ext';
Line 157  sub process_changes { Line 157  sub process_changes {
     if ($env{'form.importdetail'}) {      if ($env{'form.importdetail'}) {
         ($newtitle,$newurl,$newidx) =          ($newtitle,$newurl,$newidx) =
             map {&unescape($_)} split(/\=/,$env{'form.importdetail'});              map {&unescape($_)} split(/\=/,$env{'form.importdetail'});
         if ($newurl =~ m{^(/adm/$cdom/$cnum/(\d+)/ext\.tool)\:?(.*)$}) {          if ($newurl =~ m{^(/adm/$cdom/$cnum/(\d+)/exttools?)\:?(.*)$}) {
             $newurl = $1;              $newurl = $1;
             $marker = $2;              $marker = $2;
             $args = $3;              $args = $3;
Line 272  sub update_exttool { Line 272  sub update_exttool {
         if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {          if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
             if ($newhash{'target'} eq 'iframe') {              if ($newhash{'target'} eq 'iframe') {
                 $newhash{$item} = '';                  $newhash{$item} = '';
             } elsif ($newhash{'target'} eq 'tab') {  
                 if (($item eq 'width') || ($item eq 'height')) {  
                     $newhash{$item} = '';  
                 }  
             }              }
         }          }
         if ($toolhash{$item} ne $newhash{$item}) {          if ($toolhash{$item} ne $newhash{$item}) {
             if ($newhash{$item} eq '') {              if ($newhash{$item} eq '') {
                 unless (($item eq 'target') ||                  unless (($item eq 'target') ||
                         ((($item eq 'width') || ($item eq 'height')) &&                          ((($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) &&
                          (($newhash{'target'} eq 'window') ||                            (($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});                      delete($toolhash{$item});
                     push(@deleted,$item);                      push(@deleted,$item);
                     $changed = 1;                      $changed = 1;
Line 425  sub extedit_form { Line 418  sub extedit_form {
         } else {          } else {
             $orig_title = $lt{'et'};              $orig_title = $lt{'et'};
             $save = $lt{'at'};              $save = $lt{'at'};
             $orig_url = "/adm/$cdom/$cnum/new/ext\.tool";               $orig_url = "/adm/$cdom/$cnum/new/exttool"; 
         }          }
         $pathitem .= '<br />';          $pathitem .= '<br />';
     }      }
Line 436  sub extedit_form { Line 429  sub extedit_form {
         my $class = 'LC_nobreak';          my $class = 'LC_nobreak';
         if ($residx) {          if ($residx) {
             $class = 'LC_docs_ext_edit LC_nobreak';               $class = 'LC_docs_ext_edit LC_nobreak'; 
             if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {              if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/exttools?$}) {
                 my $marker = $1;                  my $marker = $1;
                 my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);                  my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
                 if ($toolhash{'id'}) {                  if ($toolhash{'id'}) {
Line 454  sub extedit_form { Line 447  sub extedit_form {
                                     $dimendivstyle = 'display:block';                                      $dimendivstyle = 'display:block';
                                     $windivstyle = 'display:block';                                      $windivstyle = 'display:block';
                                     $chkstate{'window'} = 'checked="checked" ';                                      $chkstate{'window'} = 'checked="checked" ';
                                 } elsif ($tooltarget eq 'tab') {  
                                     $windivstyle = 'display:block';  
                                     $chkstate{'tab'} = 'checked="checked" ';  
                                 } else {                                  } else {
                                     $chkstate{'iframe'} = 'checked="checked" ';                                      $chkstate{'iframe'} = 'checked="checked" ';
                                 }                                  }
Line 521  sub extedit_form { Line 511  sub extedit_form {
                     '<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'.                      '<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'.
                     "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',                      "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
                     '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('iframe').'</label>'.('&nbsp;'x2).                      '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('iframe').'</label>'.('&nbsp;'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>'.('&nbsp;'x2).  
                     '<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'.                      '<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'.
                     "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',                      "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
                     '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('window').'</label></span>'.                      '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('window').'</label></span>'.
Line 674  sub extedit_javascript { Line 661  sub extedit_javascript {
     my %js_lt = &Apache::lonlocal::texthash(      my %js_lt = &Apache::lonlocal::texthash(
         invurl  => 'Invalid URL',          invurl  => 'Invalid URL',
         titbl   => 'Title is blank',          titbl   => 'Title is blank',
         mixfra  => 'Show preview in pop-up? (http in https page + no framing)',  
         mixonly => 'Show preview in pop-up? (http in https page)',  
         fraonly => 'Show preview in pop-up? (framing disallowed)',  
         nopopup => 'Pop-up blocked',  
         nopriv  => 'Insufficient privileges to use preview',  
         badurl  => 'URL is not: http://hostname/path or https://hostname/path',  
         invtool => 'Please select an external tool',          invtool => 'Please select an external tool',
     );      );
     &js_escape(\%js_lt);      &js_escape(\%js_lt);
Line 748  function setExternal(extform,residx,type Line 729  function setExternal(extform,residx,type
                                 var height = extform.exttoolheight.value;                                  var height = extform.exttoolheight.value;
                                 height.trim();                                  height.trim();
                                 info += ':window:'+width+':'+height;                                  info += ':window:'+width+':'+height;
                             } else if (extform.exttooltarget[i].value == 'tab') {  
                                 info += ':tab::';  
                             } else {                              } else {
                                 info += ':iframe::';                                  info += ':iframe::';
                             }                              }
Line 838  function extUrlPreview(caller,protocol) Line 817  function extUrlPreview(caller,protocol)
         var url = document.getElementById(caller).value;          var url = document.getElementById(caller).value;
         if (regexp.test(url)) {          if (regexp.test(url)) {
             var http_regex = /^http\:\/\//gi;              var http_regex = /^http\:\/\//gi;
             var mixed = 0;  
             var noiframe = 0;  
             var nopriv = 0;  
             var badurl = 0;  
             var name = "externalpreview";  
             if ((protocol == 'https') && (http_regex.test(url))) {              if ((protocol == 'https') && (http_regex.test(url))) {
                 mixed = 1;                  window.open(url,"externalpreview","height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1");
             }  
             var http = new XMLHttpRequest();  
             var lcurl = "/adm/exturlcheck";  
             var params = "exturl="+url;  
             http.open("POST",lcurl, true);  
             http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
             http.onreadystatechange = function() {  
                 if (http.readyState == 4) {  
                     if (http.status == 200) {  
                         if (http.responseText.length > 0) {  
                             if (http.responseText == 1) {  
                                 noiframe = 1;  
                             } else if (http.responseText == -1) {  
                                 nopriv = 1;  
                             } else if (http.responseText == 0) {  
                                 badurl = 1;  
                             }  
                         }  
                         openPreviewWindow(url,name,noiframe,mixed,nopriv,badurl);  
                     }  
                 }  
             }  
             http.send(params);  
         } else {  
             alert("$js_lt{'invurl'}");  
         }  
     }  
 }  
   
 var previewLCWindow = null;  
 function openPreviewWindow(url,name,noiframe,mixed,nopriv,badurl) {  
     if (previewLCWindow !=null) {  
         previewLCWindow.close();  
     }  
     if (badurl) {  
         alert("$js_lt{'badurl'}");  
     } else if (nopriv) {  
         alert("$js_lt{'nopriv'}");  
     } else if ((noiframe == 1) || (mixed == 1)) {  
         var encurl = encodeURI(url);  
         var msg;  
         if (mixed == 1) {  
             if (noiframe == 1) {  
                 msg = "$js_lt{'mixfra'}";  
             } else {              } else {
                 msg = "$js_lt{'mixonly'}";                  openMyModal(url,500,400,'yes');
             }              }
         } else {          } else {
             msg = "$js_lt{'fraonly'}";              alert("$js_lt{'invurl'}");
         }  
         if (confirm(msg)) {  
             previewLCWindow = window.open(url,name,"height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1");  
             if (previewLCWindow != null) {  
                 previewLCWindow.focus();  
             } else {  
                 alert("$js_lt{'nopopup'}");  
             }  
         }          }
     } else {  
         openMyModal(url,500,400,'yes');  
     }      }
 }  }
   
Line 986  function updateExttool(caller,form,suppl Line 906  function updateExttool(caller,form,suppl
                             }                              }
                         }                          }
                         if (document.getElementById(windiv)) {                          if (document.getElementById(windiv)) {
                             if ((ltitoolsTarget[j] == 'window') || (ltitoolsTarget[j] == 'tab')) {                              if (ltitoolsTarget[j] == 'window') {
                                 document.getElementById(windiv).style.display = 'block';                                  document.getElementById(windiv).style.display = 'block';
                             } else {                              } else {
                                 document.getElementById(windiv).style.display = 'none';                                  document.getElementById(windiv).style.display = 'none';
Line 1052  function updateTooldim(form,dimendiv,win Line 972  function updateTooldim(form,dimendiv,win
                     dimen = 'block';                      dimen = 'block';
                     linkconf = 'block';                      linkconf = 'block';
                 } else {                  } else {
                     if (form.exttooltarget[i].value == 'tab') {                      if (document.getElementById(widthinput)) {
                         linkconf = 'block';                          document.getElementById(widthinput).value = '';
                     } else {                      }
                         if (document.getElementById(widthinput)) {                      if (document.getElementById(heightinput)) {
                             document.getElementById(widthinput).value = '';                          document.getElementById(heightinput).value = '';
                         }                      }
                         if (document.getElementById(heightinput)) {                      if (document.getElementById(linkinput)) {
                             document.getElementById(heightinput).value = '';                          document.getElementById(linkinput).value = '';
                         }                      }
                         if (document.getElementById(linkinput)) {                      if (document.getElementById(explaininput)) {
                             document.getElementById(linkinput).value = '';                          document.getElementById(explaininput).value = '';
                         }  
                         if (document.getElementById(explaininput)) {  
                             document.getElementById(explaininput).value = '';  
                         }  
                     }                      }
                 }                  }
                 if (document.getElementById(dimendiv)) {                  if (document.getElementById(dimendiv)) {

Removed from v.1.8.2.4.2.1  
changed lines
  Added in v.1.17


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