Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.358.2.16 and 1.358.2.19.2.5

version 1.358.2.16, 2019/07/27 13:57:31 version 1.358.2.19.2.5, 2023/01/21 21:20:54
Line 78  sub java_not_enabled { Line 78  sub java_not_enabled {
 sub coursepreflink {  sub coursepreflink {
    my ($text,$category)=@_;     my ($text,$category)=@_;
    if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {     if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
       return '<a target="_top" href="'.&HTML::Entities::encode("/adm/courseprefs?phase=display&actions=$category",'<>&"').'"><span class="LC_setting">'.$text.'</span></a>';        my $target =' target="_top"';
         if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) {
             $target = '';
         }
         return '<a'.$target.' href="'.&HTML::Entities::encode("/adm/courseprefs?phase=display&actions=$category",'<>&"').'"><span class="LC_setting">'.$text.'</span></a>';
    } else {     } else {
       return '';        return '';
    }     }
Line 101  sub direct_parm_link { Line 105  sub direct_parm_link {
     $filter=&entity_encode($filter);      $filter=&entity_encode($filter);
     $part=&entity_encode($part);      $part=&entity_encode($part);
     if (($symb) && (&Apache::lonnet::allowed('opa')) && ($target ne 'tex')) {      if (($symb) && (&Apache::lonnet::allowed('opa')) && ($target ne 'tex')) {
        return "<a target='_top' href='/adm/parmset?symb=$symb&amp;filter=$filter&amp;part=$part'><span class='LC_setting'>$linktext</span></a>";          my $target=' target="_top"';
           if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) {
               $target = '';
           }
          return "<a".$target." href='/adm/parmset?symb=$symb&amp;filter=$filter&amp;part=$part'><span class='LC_setting'>$linktext</span></a>";
     } else {      } else {
        return $linktext;         return $linktext;
     }      }
Line 848  parameter setting wizard. Line 856  parameter setting wizard.
 ##############################################  ##############################################
 sub pjump_javascript_definition {  sub pjump_javascript_definition {
     my $Str = <<END;      my $Str = <<END;
     function pjump(type,dis,value,marker,ret,call,hour,min,sec) {      function pjump(type,dis,value,marker,ret,call,hour,min,sec,extra) {
         openMyModal("/adm/rat/parameter.html?type="+escape(type)          openMyModal("/adm/rat/parameter.html?type="+escape(type)
                  +"&value="+escape(value)+"&marker="+escape(marker)                   +"&value="+escape(value)+"&marker="+escape(marker)
                  +"&return="+escape(ret)                   +"&return="+escape(ret)
                  +"&call="+escape(call)+"&name="+escape(dis)                   +"&call="+escape(call)+"&name="+escape(dis)
                  +"&defhour="+escape(hour)+"&defmin="+escape(min)                   +"&defhour="+escape(hour)+"&defmin="+escape(min)
                  +"&defsec="+escape(sec)+"&modal=1",350,350,'no');                   +"&defsec="+escape(sec)+"&extra="+escape(extra)
                    +"&modal=1",350,350,'no');
     }      }
 END  END
     return $Str;      return $Str;
Line 1693  sub show_return_link { Line 1702  sub show_return_link {
             (($env{'request.noversionuri'}=~/^\/adm\//) &&              (($env{'request.noversionuri'}=~/^\/adm\//) &&
              ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&               ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
              ($env{'request.noversionuri'}!~               ($env{'request.noversionuri'}!~
               m{^/adm/.*/(smppg|bulletinboard)($|\?)})                m{^/adm/.*/(smppg|bulletinboard|ext\.tool)($|\?)})
            ));             ));
 }  }
   
Line 1780  Inputs: $component (the text on the righ Line 1789  Inputs: $component (the text on the righ
            row, using loncommon::help_open_topic() to generate the link.             row, using loncommon::help_open_topic() to generate the link.
         $topic_help_text (text to include in the link in the optional help item           $topic_help_text (text to include in the link in the optional help item 
            on the right side of the breadcrumbs row.             on the right side of the breadcrumbs row.
           $links_target optionally includes the target (_top, _parent or _self)
   
 Returns a string containing breadcrumbs for the current page.  Returns a string containing breadcrumbs for the current page.
   
Line 1808  returns: nothing Line 1818  returns: nothing
           
     sub breadcrumbs {      sub breadcrumbs {
         my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt,           my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, 
             $CourseBreadcrumbs,$topic_help,$topic_help_text) = @_;              $CourseBreadcrumbs,$topic_help,$topic_help_text,$links_target) = @_;
         #          #
         $css_class ||= 'LC_breadcrumbs';          $css_class ||= 'LC_breadcrumbs';
   
Line 1824  returns: nothing Line 1834  returns: nothing
         # The first one should be the course or a menu link          # The first one should be the course or a menu link
         if (!defined($menulink)) { $menulink=1; }          if (!defined($menulink)) { $menulink=1; }
         if ($menulink) {          if ($menulink) {
               if ($env{'request.course.id'}) {
                   my ($menucoll,$deeplinkmenu,$menuref) = &Apache::loncommon::menucoll_in_effect();
                   if (($menucoll) && (ref($menuref) eq 'HASH')) {
                       if ($menuref->{'main'} eq 'n') {
                          undef($menulink);
                       }
                   }
               }
           }
           if ($menulink) {
             my $description = 'Menu';              my $description = 'Menu';
             my $no_mt_descr = 0;              my $no_mt_descr = 0;
             if ((exists($env{'request.course.id'})) &&               if ((exists($env{'request.course.id'})) && 
Line 1841  returns: nothing Line 1861  returns: nothing
                     }                      }
                 }                  }
             }              }
               my $target = '_top';
               if ($links_target) {
                   $target = $links_target;
               } elsif (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) {
                   $target = '';
               }
             $menulink =  {  href   =>'/adm/menu',              $menulink =  {  href   =>'/adm/menu',
                             title  =>'Go to main menu',                              title  =>'Go to main menu',
                             target =>'_top',                              target =>$target,
                             text   =>$description,                              text   =>$description,
                             no_mt  =>$no_mt_descr, };                              no_mt  =>$no_mt_descr, };
             if($last) {              if($last) {
Line 1861  returns: nothing Line 1887  returns: nothing
                             title => &mt('Back to most recent content resource'),                              title => &mt('Back to most recent content resource'),
                             class => 'LC_menubuttons_link',                              class => 'LC_menubuttons_link',
                           };                            };
             if ($env{'request.noversionuri'} eq '/adm/searchcat') {              if ($links_target) {
                 $hashref->{'target'} = '_top';                   $hashref->{'target'} = $links_target;
             }              }
             $links=&htmltag( 'a','<img src="/res/adm/pages/tolastloc.png" alt="'.$alttext.'" class="LC_icon" />',              $links=&htmltag( 'a','<img src="/res/adm/pages/tolastloc.png" alt="'.$alttext.'" class="LC_icon" />',
                              $hashref);                               $hashref);
Line 1913  returns: nothing Line 1939  returns: nothing
         if ($faq ne '' || $component_help ne '' || $bug ne '') {          if ($faq ne '' || $component_help ne '' || $bug ne '') {
             $icons .= &Apache::loncommon::help_open_menu($component,              $icons .= &Apache::loncommon::help_open_menu($component,
                                                          $component_help,                                                           $component_help,
                                                          $faq,$bug);                                                           $faq,$bug,'','','','',
                                                            $links_target);
         }          }
         if ($topic_help && $topic_help_text) {          if ($topic_help && $topic_help_text) {
            $icons .= ' '.&Apache::loncommon::help_open_topic($topic_help,&mt($topic_help_text),'',             $icons .= ' '.&Apache::loncommon::help_open_topic($topic_help,&mt($topic_help_text),'',
                                                              undef,600);                                                               undef,600,'',$links_target);
         }          }
         #          #
   
Line 2095  returns: nothing Line 2122  returns: nothing
 } # End of scope for @Crumbs  } # End of scope for @Crumbs
   
 sub docs_breadcrumbs {  sub docs_breadcrumbs {
     my ($allowed,$crstype,$contenteditor,$title,$precleared)=@_;      my ($allowed,$crstype,$contenteditor,$title,$precleared,$checklinkprot)=@_;
     my ($folderpath,@folders,$supplementalflag);      my ($folderpath,@folders,$supplementalflag);
     @folders = split('&',$env{'form.folderpath'});      @folders = split('&',$env{'form.folderpath'});
     if ($env{'form.folderpath'} =~ /^supplemental/) {      if ($env{'form.folderpath'} =~ /^supplemental/) {
Line 2121  sub docs_breadcrumbs { Line 2148  sub docs_breadcrumbs {
 # each of randompick number, hidden, encrypted, random order, is_page   # each of randompick number, hidden, encrypted, random order, is_page 
 # are appended with ":"s to the foldername  # are appended with ":"s to the foldername
         $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//;          $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//;
         unless ($supplementalflag) {          if ($contenteditor) {
             if ($contenteditor) {               if ($supplementalflag) {
                   if ($2) { $ishidden=1; }
               } else {
                 if ($1 ne '') {                  if ($1 ne '') {
                     $randompick=$1;                      $randompick=$1;
                 } else {                  } else {
Line 2166  sub docs_breadcrumbs { Line 2195  sub docs_breadcrumbs {
         if (!$allowed && !$contenteditor) {          if (!$allowed && !$contenteditor) {
             $menulink = 1;              $menulink = 1;
         }          }
           if ($checklinkprot) {
               if ($env{'request.deeplink.login'}) {
                   my $linkprotout = &Apache::lonmenu::linkprot_exit();
                   if ($linkprotout) {
                       &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$linkprotout);
                   }
               }
           }
         return (&breadcrumbs(undef,undef,$menulink,'nohelp',undef,undef,          return (&breadcrumbs(undef,undef,$menulink,'nohelp',undef,undef,
                              $contenteditor),                               $contenteditor),
                              $randompick,$ishidden,$isencrypted,$plain,                               $randompick,$ishidden,$isencrypted,$plain,
Line 2539  sub course_custom_roles { Line 2576  sub course_custom_roles {
   
   
 sub resource_info_box {  sub resource_info_box {
    my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp)=@_;     my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp,$divforres)=@_;
    my $return='';     my $return='';
    if ($stuvcurrent ne '') {     if (($stuvcurrent ne '') || ($divforres)) {
        $return = '<div class="LC_left_float">';         $return = '<div class="LC_left_float">';
    }     }
    if ($symb) {     if ($symb) {
Line 2570  sub resource_info_box { Line 2607  sub resource_info_box {
     } else {      } else {
        $return='<p><span class="LC_error">'.&mt('No context provided.').'</span></p>';         $return='<p><span class="LC_error">'.&mt('No context provided.').'</span></p>';
     }      }
     if ($stuvcurrent ne '') {      if (($stuvcurrent ne '') || ($divforres)) {
         $return .= '</div>';          $return .= '</div>';
     }      }
     return $return;      return $return;
Line 3301  PARAMSONE Line 3338  PARAMSONE
         if (itemid != null) {          if (itemid != null) {
             itemh = itemid.offsetHeight;              itemh = itemid.offsetHeight;
         }          }
         var primaryheight = document.getElementById('LC_nav_bar').offsetHeight;          var primaryheight = 0;
         var secondaryheight;          if (document.getElementById('LC_nav_bar') != null) {
               primaryheight = document.getElementById('LC_nav_bar').offsetHeight;
           }
           var secondaryheight = 0;
         if (document.getElementById('LC_secondary_menu') != null) {           if (document.getElementById('LC_secondary_menu') != null) { 
             secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight;              secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight;
         }          }
         var crumbsheight = document.getElementById('LC_breadcrumbs').offsetHeight;          var crumbsheight = 0;
           if (document.getElementById('LC_breadcrumbs') != null) {
               crumbsheight = document.getElementById('LC_breadcrumbs').offsetHeight;
           }
         var dccidheight = 0;          var dccidheight = 0;
         if (document.getElementById('dccid') != null) {          if (document.getElementById('dccid') != null) {
             dccidheight = document.getElementById('dccid').offsetHeight;              dccidheight = document.getElementById('dccid').offsetHeight;
Line 3379  THIRD Line 3422  THIRD
 sub javascript_jumpto_resource {  sub javascript_jumpto_resource {
     my $confirm_switch = &mt("Editing requires switching to the resource's home server.")."\n".      my $confirm_switch = &mt("Editing requires switching to the resource's home server.")."\n".
                          &mt('Switch server?');                           &mt('Switch server?');
       my $confirm_new_tab = &mt("Editing requires using the resource's home server.")."\n".
                             &mt('Open a new browser tab?');
     &js_escape(\$confirm_switch);      &js_escape(\$confirm_switch);
       &js_escape(\$confirm_new_tab);
     return (<<ENDUTILITY)      return (<<ENDUTILITY)
   
 function go(url) {  function go(url) {
Line 3400  function go(url) { Line 3446  function go(url) {
    }     }
 }  }
   
 function need_switchserver(url) {  function need_switchserver(url,target) {
     if (url!='' && url!= null) {      if (url!='' && url!= null) {
         if (confirm("$confirm_switch")) {          if (target == '_blank') {
               if (confirm("$confirm_new_tab")) {
                   window.open(url,target);
               }
           } else if (confirm("$confirm_switch")) {
             go(url);              go(url);
         }          }
     }      }
Line 3414  ENDUTILITY Line 3464  ENDUTILITY
 }  }
   
 sub jump_to_editres {  sub jump_to_editres {
     my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath,      my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$shownsymb,
         $title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_;          $folderpath,$title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_;
     my ($jscall,$anchor,$usehttp,$usehttps,$is_ext);      my ($jscall,$anchor,$usehttp,$usehttps,$is_ext,$target);
     if ($switchserver) {      if ($switchserver) {
         if ($home) {          if ($home) {
               my $resedit;
               if ($cfile =~ m{^/priv/($match_domain)/($match_username)/}) {
                   my ($audom,$auname) = ($1,$2);
                   unless (&Apache::lonnet::is_course($audom,$auname)) {
                       unless ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$audom)) &&
                               (&Apache::lonnet::will_trust('coaurem',$audom,$env{'user.domain'}))) {
                          return;
                       }
                       if (($symb ne '') && ($env{'request.course.id'}) &&
                           (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
                           unless (&Apache::lonnet::can_switchserver($env{'user.domain'},$home)) {
                               $target = '_blank';
                               $resedit = 1;
                           }
                       }
                   }
               }
             $cfile = '/adm/switchserver?otherserver='.$home.'&amp;role='.              $cfile = '/adm/switchserver?otherserver='.$home.'&amp;role='.
                      &HTML::Entities::encode($env{'request.role'},'"<>&');                       &HTML::Entities::encode($env{'request.role'},'"<>&');
             if ($symb) {              if ($shownsymb) {
                 $cfile .= '&amp;symb='.&HTML::Entities::encode($symb,'"<>&');                  $cfile .= '&amp;symb='.&HTML::Entities::encode($shownsymb,'"<>&');
                   if ($resedit) {
                       $cfile .= '&amp;edit=1';
                   }
             } elsif ($folderpath) {              } elsif ($folderpath) {
                 $cfile .= '&amp;folderpath='.&HTML::Entities::encode($folderpath,'"<>&');                  $cfile .= '&amp;folderpath='.&HTML::Entities::encode($folderpath,'"<>&');
             }              }
Line 3432  sub jump_to_editres { Line 3502  sub jump_to_editres {
             if ($forcereg) {              if ($forcereg) {
                 $cfile .= '&amp;register=1';                  $cfile .= '&amp;register=1';
             }              }
             $jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."');";              $jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."','$target')";
         }          }
     } else {      } else {
         unless ($cfile =~ m{^/priv/}) {          unless ($cfile =~ m{^/priv/}) {
Line 3442  sub jump_to_editres { Line 3512  sub jump_to_editres {
                 $anchor = $3;                  $anchor = $3;
                 $is_ext = 1;                  $is_ext = 1;
                 if (($extlink !~ /^https:/) && ($ENV{'SERVER_PORT'} == 443)) {                  if (($extlink !~ /^https:/) && ($ENV{'SERVER_PORT'} == 443)) {
                     unless (&Apache::lonnet::uses_sts()) {                      unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
                         $usehttp = 1;                          $usehttp = 1;
                     }                      }
                 } elsif ($env{'request.use_absolute'}) {                  } elsif ($env{'request.use_absolute'}) {
Line 3457  sub jump_to_editres { Line 3527  sub jump_to_editres {
                         ($env{'course.'.$env{'request.course.id'}.'.num'} eq $cnum) &&                          ($env{'course.'.$env{'request.course.id'}.'.num'} eq $cnum) &&
                         ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $cdom)) {                          ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $cdom)) {
                         if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {                          if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) {
                             unless (&Apache::lonnet::uses_sts()) {                              unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) {
                                 $usehttp = 1;                                  $usehttp = 1;
                             }                              }
                         }                          }
Line 3528  sub jump_to_editres { Line 3598  sub jump_to_editres {
 # javascript_valid_email  # javascript_valid_email
 #  #
 # Generates javascript to validate an e-mail address.  # Generates javascript to validate an e-mail address.
 # Returns a javascript function which accetps a form field as argumnent, and  # Returns a javascript function which accepts a form field as argument, and
 # returns false if field.value does not satisfy two regular expression matches  # returns false if field.value does not satisfy two regular expression matches
 # for a valid e-mail address.  Backwards compatible with old browsers without  # for a valid e-mail address.  Backwards compatible with old browsers without
 # support for javascript RegExp (just checks for @ in field.value in this case).   # support for javascript RegExp (just checks for @ in field.value in this case). 
   
 sub javascript_valid_email {  sub javascript_valid_email {
     my $scripttag .= <<'END';      my $scripttag .= <<'END';
 function validmail(field) {  function validmail(field,suffix) {
     var str = field.value;      var str = field.value;
       if (suffix != '' && suffix != undefined) {
           str += suffix;
       }
     if (window.RegExp) {      if (window.RegExp) {
         var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";          var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
         var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"          var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //"

Removed from v.1.358.2.16  
changed lines
  Added in v.1.358.2.19.2.5


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