--- loncom/interface/lonhtmlcommon.pm 2022/09/19 19:38:49 1.358.2.19.2.4 +++ loncom/interface/lonhtmlcommon.pm 2017/07/13 21:25:28 1.387 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.358.2.19.2.4 2022/09/19 19:38:49 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.387 2017/07/13 21:25:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -78,11 +78,7 @@ sub java_not_enabled { sub coursepreflink { my ($text,$category)=@_; if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { - my $target =' target="_top"'; - if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) { - $target = ''; - } - return '&"').'">'.$text.''; + return '&"').'">'.$text.''; } else { return ''; } @@ -105,11 +101,7 @@ sub direct_parm_link { $filter=&entity_encode($filter); $part=&entity_encode($part); if (($symb) && (&Apache::lonnet::allowed('opa')) && ($target ne 'tex')) { - my $target=' target="_top"'; - if (($env{'request.deeplink.login'}) && ($env{'request.deeplink.target'} eq '_self')) { - $target = ''; - } - return "$linktext"; + return "$linktext"; } else { return $linktext; } @@ -459,10 +451,12 @@ sub radio { &date_setter returns html and javascript for a compact date-setting form. To retrieve values from it, use &get_date_from_form. -Inputs - =over 4 +=item Inputs + +=over + =item $dname The name to prepend to the form elements. @@ -523,10 +517,12 @@ If true, text boxes for seconds are omit =back -Bugs +=item Bugs The method used to restrict user input will fail in the year 2400. +=back + =cut ############################################## @@ -693,11 +689,13 @@ ENDJS $monthselector,$dayselector,$yearselector, $hourselector). $tzone; + } elsif ($no_ss) { $result .= &mt('[_1] [_2] [_3] [_4] [_5]m', $monthselector,$dayselector,$yearselector, $hourselector,$minuteselector). $tzone; + } else { $result .= &mt('[_1] [_2] [_3] [_4] [_5]m [_6]s ', $monthselector,$dayselector,$yearselector, @@ -749,7 +747,9 @@ sub build_url { get_date_from_form retrieves the date specified in an &date_setter form. -Inputs: +=over + +=item Inputs: =over 4 @@ -763,6 +763,8 @@ The unix time to use as the default in c =back +=back + Returns: Unix time represented in the form. =cut @@ -856,14 +858,13 @@ parameter setting wizard. ############################################## sub pjump_javascript_definition { my $Str = < - - + + + @@ -1688,7 +1712,8 @@ sub show_return_link { if ($env{'request.noversionuri'}=~m{^/priv/} || $env{'request.uri'}=~m{^/priv/}) { return 1; } return if ($env{'request.noversionuri'} eq '/adm/supplemental'); - + return if (($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Placement') && + (!$env{'request.role.adv'})); if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)}) || ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) { @@ -1776,20 +1801,54 @@ A link to help for the component will be All inputs can be undef without problems. -Inputs: $component (the text on the right side of the breadcrumbs trail), - $component_help (the help item filename (without .tex extension). - $menulink (boolean, controls whether to include a link to /adm/menu) - $helplink (if 'nohelp' don't include the orange help link) - $css_class (optional name for the class to apply to the table for CSS) - $no_mt (optional flag, 1 if &mt() is _not_ to be applied to $component - when including the text on the right. - $CourseBreadcrumbs (optional flag, 1 if &breadcrumbs called from &docs_breadcrumbs, - because breadcrumbs are being) - $topic_help (optional help item to be displayed on right side of the breadcrumbs - row, using loncommon::help_open_topic() to generate the link. - $topic_help_text (text to include in the link in the optional help item - on the right side of the breadcrumbs row. - $links_target optionally includes the target (_top, _parent or _self) +=over + +=item Inputs: + +=over + +=item $component + +the text on the right side of the breadcrumbs trail + +=item $component_help + +the help item filename (without .tex extension). + +=item $menulink + +boolean, controls whether to include a link to /adm/menu + +=item $helplink + +if 'nohelp' don't include the orange help link + +=item $css_class + +optional name for the class to apply to the table for CSS + +=item $no_mt + +optional flag, 1 if &mt() is _not_ to be applied to $component when including the text on the right + +=item $CourseBreadcrumbs + +optional flag, 1 if &breadcrumbs called from &docs_breadcrumbs, because breadcrumbs are being +used to display hierarchy for current folder shown in the Course Editor. + +=item $topic_help + +optional help item to be displayed on right side of the breadcrumbs row, using +loncommon::help_open_topic() to generate the link. + +=item $topic_help_text + +text to include in the link in the optional help item ($topic_help) on the right +side of the breadcrumbs row. + +=back + +=back Returns a string containing breadcrumbs for the current page. @@ -1818,7 +1877,7 @@ returns: nothing sub breadcrumbs { my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, - $CourseBreadcrumbs,$topic_help,$topic_help_text,$links_target) = @_; + $CourseBreadcrumbs,$topic_help,$topic_help_text,$crstype) = @_; # $css_class ||= 'LC_breadcrumbs'; @@ -1834,16 +1893,6 @@ returns: nothing # The first one should be the course or a menu link if (!defined($menulink)) { $menulink=1; } 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 $no_mt_descr = 0; if ((exists($env{'request.course.id'})) && @@ -1861,15 +1910,9 @@ 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', title =>'Go to main menu', - target =>$target, + target =>'_top', text =>$description, no_mt =>$no_mt_descr, }; if($last) { @@ -1887,8 +1930,8 @@ returns: nothing title => &mt('Back to most recent content resource'), class => 'LC_menubuttons_link', }; - if ($links_target) { - $hashref->{'target'} = $links_target; + if ($env{'request.noversionuri'} eq '/adm/searchcat') { + $hashref->{'target'} = '_top'; } $links=&htmltag( 'a',''.$alttext.'', $hashref); @@ -1939,12 +1982,11 @@ returns: nothing if ($faq ne '' || $component_help ne '' || $bug ne '') { $icons .= &Apache::loncommon::help_open_menu($component, $component_help, - $faq,$bug,'','','','', - $links_target); + $faq,$bug); } if ($topic_help && $topic_help_text) { $icons .= ' '.&Apache::loncommon::help_open_topic($topic_help,&mt($topic_help_text),'', - undef,600,'',$links_target); + undef,600); } # @@ -2013,7 +2055,9 @@ Adds $html to $category of the breadcrum $html is usually a link to a page that invokes a function on the currently displayed data (e.g. print when viewing a problem) -Currently there are 3 possible values for $category: +=over + +=item Currently there are 3 possible values for $category: =over @@ -2027,7 +2071,9 @@ remaining items in right of breadcrumbs advanced tools shown in a separate box below breadcrumbs line =back - + +=back + returns: nothing =cut @@ -2076,8 +2122,17 @@ returns: a hash containing the current b Creates html for breadcrumb tools (categories navigation and tools) and inserts \$breadcrumbs at the correct position. -input: \$breadcrumbs - a reference to the string containing prepared -breadcrumbs. +=over + +=item input: + +=over + +=item \$breadcrumbs - a reference to the string containing prepared breadcrumbs. + +=back + +=back returns: nothing @@ -2103,8 +2158,17 @@ returns: nothing Creates html for advanced tools (category advtools) and inserts \$breadcrumbs at the correct position. -input: \$breadcrumbs - a reference to the string containing prepared -breadcrumbs (after render_tools call). +=over + +=item input: + +=over + +=item \$breadcrumbs - a reference to the string containing prepared breadcrumbs (after render_tools call). + +=back + +=back returns: nothing @@ -2122,7 +2186,7 @@ returns: nothing } # End of scope for @Crumbs sub docs_breadcrumbs { - my ($allowed,$crstype,$contenteditor,$title,$precleared,$checklinkprot)=@_; + my ($allowed,$crstype,$contenteditor,$title,$precleared)=@_; my ($folderpath,@folders,$supplementalflag); @folders = split('&',$env{'form.folderpath'}); if ($env{'form.folderpath'} =~ /^supplemental/) { @@ -2193,14 +2257,6 @@ sub docs_breadcrumbs { if (!$allowed && !$contenteditor) { $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, $contenteditor), $randompick,$ishidden,$isencrypted,$plain, @@ -2574,9 +2630,9 @@ sub course_custom_roles { sub resource_info_box { - my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp,$divforres)=@_; + my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp)=@_; my $return=''; - if (($stuvcurrent ne '') || ($divforres)) { + if ($stuvcurrent ne '') { $return = '
'; } if ($symb) { @@ -2605,7 +2661,7 @@ sub resource_info_box { } else { $return='

'.&mt('No context provided.').'

'; } - if (($stuvcurrent ne '') || ($divforres)) { + if ($stuvcurrent ne '') { $return .= '
'; } return $return; @@ -3336,18 +3392,12 @@ PARAMSONE if (itemid != null) { itemh = itemid.offsetHeight; } - var primaryheight = 0; - if (document.getElementById('LC_nav_bar') != null) { - primaryheight = document.getElementById('LC_nav_bar').offsetHeight; - } - var secondaryheight = 0; + var primaryheight = document.getElementById('LC_nav_bar').offsetHeight; + var secondaryheight; if (document.getElementById('LC_secondary_menu') != null) { secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight; } - var crumbsheight = 0; - if (document.getElementById('LC_breadcrumbs') != null) { - crumbsheight = document.getElementById('LC_breadcrumbs').offsetHeight; - } + var crumbsheight = document.getElementById('LC_breadcrumbs').offsetHeight; var dccidheight = 0; if (document.getElementById('dccid') != null) { dccidheight = document.getElementById('dccid').offsetHeight; @@ -3420,10 +3470,7 @@ THIRD sub javascript_jumpto_resource { my $confirm_switch = &mt("Editing requires switching to the resource's home server.")."\n". &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_new_tab); return (<&'); - if ($shownsymb) { - $cfile .= '&symb='.&HTML::Entities::encode($shownsymb,'"<>&'); - if ($resedit) { - $cfile .= '&edit=1'; - } + if ($symb) { + $cfile .= '&symb='.&HTML::Entities::encode($symb,'"<>&'); } elsif ($folderpath) { $cfile .= '&folderpath='.&HTML::Entities::encode($folderpath,'"<>&'); } @@ -3500,24 +3514,22 @@ sub jump_to_editres { if ($forcereg) { $cfile .= '&register=1'; } - $jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."','$target')"; + $jscall = "need_switchserver('".&Apache::loncommon::escape_single($cfile)."');"; } } else { unless ($cfile =~ m{^/priv/}) { - if ($cfile =~ m{^(/adm/wrapper/ext/([^#]+))(?:|#([^#]+))$}) { + if ($cfile =~ m{^(/adm/wrapper/ext/([^#]+))#([^#]+)$}) { $cfile = $1; my $extlink = $2; $anchor = $3; $is_ext = 1; if (($extlink !~ /^https:/) && ($ENV{'SERVER_PORT'} == 443)) { - unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) { - $usehttp = 1; - } + $usehttp = 1; } elsif ($env{'request.use_absolute'}) { if ($env{'request.use_absolute'} =~ m{^https://}) { $usehttps = 1; } - } + } } elsif ($cfile =~ m{^/?public/($match_domain)/($match_courseid)/syllabus}) { if ($ENV{'SERVER_PORT'} == 443) { my ($cdom,$cnum) = ($1,$2); @@ -3525,9 +3537,7 @@ sub jump_to_editres { ($env{'course.'.$env{'request.course.id'}.'.num'} eq $cnum) && ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $cdom)) { if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) { - unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl($hostname))) { - $usehttp = 1; - } + $usehttp = 1; } } } elsif ($env{'request.use_absolute'}) { @@ -3567,7 +3577,9 @@ sub jump_to_editres { if ($hostname ne '') { $cfile = 'http://'.$hostname.(($cfile =~ /^\//)? '':'/').$cfile; } - $cfile .= (($cfile=~/\?/)?'&':'?').'usehttp=1'; + unless ($is_ext) { + $cfile .= (($cfile=~/\?/)?'&':'?').'usehttp=1'; + } } elsif ($usehttps) { $cfile = $env{'request.use_absolute'}.(($cfile =~ /^\//)? '':'/').$cfile; } @@ -3596,18 +3608,15 @@ sub jump_to_editres { # javascript_valid_email # # Generates javascript to validate an e-mail address. -# Returns a javascript function which accepts a form field as argument, and +# Returns a javascript function which accetps a form field as argumnent, and # returns false if field.value does not satisfy two regular expression matches # 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). sub javascript_valid_email { my $scripttag .= <<'END'; -function validmail(field,suffix) { +function validmail(field) { var str = field.value; - if (suffix != '' && suffix != undefined) { - str += suffix; - } if (window.RegExp) { var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)"; var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //" @@ -3717,7 +3726,9 @@ sub scripttag { Constructs a XHTML list from \@array. -input: +=over + +=item input: =over @@ -3731,7 +3742,9 @@ Attributes for
    and
  • passed in a See htmltag() for more details. =back - + +=back + returns: XHTML list as String. =cut @@ -3850,13 +3863,19 @@ should be included in this list. If the optional headline text is not provided, a default text will be used. +=over + +=item Related routines: -Related routines: =over 4 -add_item_funclist -end_funclist + +=item add_item_funclist + +=item end_funclist + =back +=back Inputs: (optional) headline text @@ -3883,10 +3902,18 @@ sub start_funclist { Adds an item to the list of available functions -Related routines: +=over + +=item Related routines: + =over 4 -start_funclist -end_funclist + +=item start_funclist + +=item end_funclist + +=back + =back Inputs: content item with text and link to function @@ -3909,10 +3936,13 @@ sub add_item_funclist { End list of available functions -Related routines: -=over 4 -start_funclist -add_item_funclist +=over + +=item Related routines: + + start_funclist + add_item_funclist + =back Inputs: ./. @@ -3945,7 +3975,7 @@ A string that's used as visually highlig it's value evaluates to false. =back - + returns: XHTML list as string. =back @@ -3958,7 +3988,7 @@ sub funclist_from_array { $args->{legend} ||= mt('Functions'); return list_from_array( [$args->{legend}, @$items], { listattr => {class => 'LC_funclist'} }); -} +} =pod @@ -3980,8 +4010,8 @@ e.g. a file operation in Authoring Space A reference to the array containing text. Details: sub funclist_from_array =back - -Returns: XHTML div as string. + +Returns: XHTML div as string. =back