--- loncom/interface/lonhtmlcommon.pm 2019/07/27 00:38:33 1.358.2.15 +++ loncom/interface/lonhtmlcommon.pm 2017/02/20 18:29:22 1.381 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.358.2.15 2019/07/27 00:38:33 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.381 2017/02/20 18:29:22 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,7 +92,7 @@ sub raw_href_to_link { sub entity_encode { my ($text)=@_; - return &HTML::Entities::encode($text, '\'<>&"'); + return &HTML::Entities::encode($text, '<>&"'); } sub direct_parm_link { @@ -451,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. @@ -515,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 ############################################## @@ -685,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, @@ -741,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 @@ -755,6 +763,8 @@ The unix time to use as the default in c =back +=back + Returns: Unix time represented in the form. =cut @@ -926,7 +936,9 @@ sub javascript_docopen { Returns html for a selection box which allows the user to choose the enrollment status of students. The selection box name is 'Status'. -Inputs: +=over + +=item Inputs: $status: the currently selected status. If undefined the value of $env{'form.Status'} is taken. If that is undefined, a value of 'Active' @@ -940,6 +952,8 @@ $size: the size (number of lines) of the $onchange: javascript to use when the value is changed. Enclosed in double quotes, ""s, not single quotes. +=back + Returns: a perl string as described. =cut @@ -987,7 +1001,7 @@ sub StatusOptions { =pod -=item Progess Window Handling Routines +=item Progress Window Handling Routines These routines handle the creation, update, increment, and closure of progress windows. The progress window reports to the user the number @@ -1001,28 +1015,30 @@ of items completed and an estimate of th Writes javascript to the client to open a progress window and returns a data structure used for bookkeeping. -Inputs +=over -=over 4 +=item Inputs + +=over =item $r Apache request =item $number_to_do The total number of items being processed. -=item $preamble Optional HTML to display before the progress bar. +=back =back Returns a hash containing the progress state data structure. -If $number_to_do is zero or null, an indeterminate progress bar will -be used. =item &Update_PrgWin() Updates the text in the progress indicator. Does not increment the count. See &Increment_PrgWin. -Inputs: +=over + +=item Inputs: =over 4 @@ -1034,25 +1050,38 @@ Inputs: =back +=back + Returns: none -=item Increment_PrgWin() +=item &Increment_PrgWin() Increment the count of items completed for the progress window by $step or 1 if no step is provided. -Inputs: +=over + +=item Inputs: =over 4 -=item $r Apache request +=item $r -=item $prog_state Pointer to the data structure returned by Create_PrgWin +Apache request + +=item $prog_state + +Pointer to the data structure returned by Create_PrgWin -=item $extraInfo A description of the items being iterated over. Typically -'student'. +=item $extraInfo -=item $step (optional) counter step. Will be set to default 1 if ommited. step must be greater than 0 or empty. +A description of the items being iterated over. Typically 'student'. + +=item $step + +(optional) counter step. Will be set to default 1 if ommited. step must be greater than 0 or empty. + +=back =back @@ -1063,7 +1092,9 @@ Returns: none Closes the progress window. -Inputs: +=over + +=item Inputs: =over 4 @@ -1073,6 +1104,8 @@ Inputs: =back +=back + Returns: none =back @@ -1085,20 +1118,20 @@ Returns: none # Create progress sub Create_PrgWin { - my ($r,$number_to_do,$preamble)=@_; + my ($r,$number_to_do)=@_; my %prog_state; $prog_state{'done'}=0; $prog_state{'firststart'}=&Time::HiRes::time(); $prog_state{'laststart'}=&Time::HiRes::time(); $prog_state{'max'}=$number_to_do; - &Apache::loncommon::LCprogressbar($r,$prog_state{'max'},$preamble); + &Apache::loncommon::LCprogressbar($r); return %prog_state; } # update progress sub Update_PrgWin { my ($r,$prog_state,$displayString)=@_; - &Apache::loncommon::LCprogressbarUpdate($r,undef,$displayString,$$prog_state{'max'}); + &Apache::loncommon::LCprogressbarUpdate($r,undef,$displayString); $$prog_state{'laststart'}=&Time::HiRes::time(); } @@ -1148,7 +1181,7 @@ sub Increment_PrgWin { if ($$prog_state{'max'}) { $percent=int(100.*$current/$$prog_state{'max'}); } - &Apache::loncommon::LCprogressbarUpdate($r,$percent,$timeinfo,$$prog_state{'max'}); + &Apache::loncommon::LCprogressbarUpdate($r,$percent,$timeinfo); $$prog_state{'laststart'}=&Time::HiRes::time(); } @@ -1268,9 +1301,9 @@ sub htmlareaheaders { ENDEDITOR } $s.=(< - - + + + @@ -1679,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($|\?)})) { @@ -1693,7 +1727,7 @@ sub show_return_link { (($env{'request.noversionuri'}=~/^\/adm\//) && ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && ($env{'request.noversionuri'}!~ - m{^/adm/.*/(smppg|bulletinboard)($|\?)}) + m{^/adm/.*/(smppg|bulletinboard|exttools?)($|\?)}) )); } @@ -1767,19 +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. +=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. @@ -1808,7 +1877,7 @@ returns: nothing sub breadcrumbs { my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, - $CourseBreadcrumbs,$topic_help,$topic_help_text) = @_; + $CourseBreadcrumbs,$topic_help,$topic_help_text,$crstype) = @_; # $css_class ||= 'LC_breadcrumbs'; @@ -1833,7 +1902,7 @@ returns: nothing $env{'course.'.$env{'request.course.id'}.'.description'}; $no_mt_descr = 1; if ($env{'request.noversionuri'} =~ - m{^/?public/($match_domain)/($match_courseid)/syllabus$}) { + m{^/public/($match_domain)/($match_courseid)/syllabus$}) { unless (($env{'course.'.$env{'request.course.id'}.'.domain'} eq $1) && ($env{'course.'.$env{'request.course.id'}.'.num'} eq $2)) { $description = 'Menu'; @@ -1986,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 @@ -2000,7 +2071,9 @@ remaining items in right of breadcrumbs advanced tools shown in a separate box below breadcrumbs line =back - + +=back + returns: nothing =cut @@ -2049,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 @@ -2076,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 @@ -3386,17 +3477,7 @@ function go(url) { if (url!='' && url!= null) { currentURL = null; currentSymb= null; - var lcHostname = setLCHost(); - if (lcHostname!='' && lcHostname!= null) { - var RegExp = /^https?\:/; - if (RegExp.test(url)) { - window.location.href=url; - } else { - window.location.href=lcHostname+url; - } - } else { - window.location.href=url; - } + window.location.href=url; } } @@ -3415,8 +3496,8 @@ ENDUTILITY sub jump_to_editres { my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb,$folderpath, - $title,$idx,$suppurl,$todocs,$suppanchor) = @_; - my ($jscall,$anchor,$usehttp,$usehttps,$is_ext); + $title,$hostname,$idx,$suppurl,$todocs,$suppanchor) = @_; + my ($jscall,$anchor,$usehttp,$usehttps); if ($switchserver) { if ($home) { $cfile = '/adm/switchserver?otherserver='.$home.'&role='. @@ -3436,30 +3517,17 @@ sub jump_to_editres { } } 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()) { - $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}) { + $anchor = $2; + } elsif ($cfile =~ m{^/public/($match_domain)/($match_courseid)/syllabus}) { if ($ENV{'SERVER_PORT'} == 443) { my ($cdom,$cnum) = ($1,$2); if (($env{'request.course.id'}) && ($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()) { - $usehttp = 1; - } + $usehttp = 1; } } } elsif ($env{'request.use_absolute'}) { @@ -3492,16 +3560,14 @@ sub jump_to_editres { } if ($forceedit) { $cfile .= (($cfile=~/\?/)?'&':'?').'forceedit=1'; - if ($usehttps) { - $cfile = $env{'request.use_absolute'}.(($cfile =~ /^\//)? '':'/').$cfile; + if (($usehttps) && ($hostname ne '')) { + $cfile = 'https://'.$hostname.$cfile; } } elsif ($usehttp) { if ($hostname ne '') { - $cfile = 'http://'.$hostname.(($cfile =~ /^\//)? '':'/').$cfile; + $cfile = 'http://'.$hostname.$cfile; } $cfile .= (($cfile=~/\?/)?'&':'?').'usehttp=1'; - } elsif ($usehttps) { - $cfile = $env{'request.use_absolute'}.(($cfile =~ /^\//)? '':'/').$cfile; } if ($forcereg) { $cfile .= (($cfile=~/\?/)?'&':'?').'register=1'; @@ -3646,7 +3712,9 @@ sub scripttag { Constructs a XHTML list from \@array. -input: +=over + +=item input: =over @@ -3660,7 +3728,9 @@ Attributes for