--- loncom/interface/lonhtmlcommon.pm 2023/09/11 14:13:31 1.358.2.20 +++ loncom/interface/lonhtmlcommon.pm 2015/03/31 13:46:01 1.359 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.358.2.20 2023/09/11 14:13:31 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.359 2015/03/31 13:46:01 damieng 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 { @@ -407,7 +407,7 @@ sub textbox { ############################################## ############################################## sub checkbox { - my ($name,$checked,$value,$special) = @_; + my ($name,$checked,$value) = @_; my $Str = ''; + $Str .= ' />'; return $Str; } @@ -482,36 +482,7 @@ the date/time fields are left empty. =item $state Specifies the initial state of the form elements. Either 'disabled' or empty. -Defaults to empty, which indicates the form elements are not disabled. - -=item $no_hh_mm_ss - -If true, text boxes for hours, minutes and seconds are omitted. - -=item $defhour - -Default value for hours (a default of 0 is used otherwise). - -=item $defmin - -Default value for minutes (a default of 0 is used otherwise). - -=item defsec - -Default value for seconds (a default of 0 is used otherwise). - -=item $nolink - -If true, a "Select calendar" link (to pop-up a calendar) is not displayed -to the right of the items. - -=item $no_mm_ss - -If true, text boxes for minutes and seconds are omitted. - -=item $no_ss - -If true, text boxes for seconds are omitted. +Defaults to empty, which indiciates the form elements are not disabled. =back @@ -525,7 +496,7 @@ The method used to restrict user input w ############################################## sub date_setter { my ($formname,$dname,$currentvalue,$special,$includeempty,$state, - $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink,$no_mm_ss,$no_ss) = @_; + $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_; my $now = time; my $tzname; @@ -534,8 +505,6 @@ sub date_setter { if (! defined($state) || $state ne 'disabled') { $state = ''; - } else { - $state = 'disabled="disabled"'; } if (! defined($no_hh_mm_ss)) { $no_hh_mm_ss = 0; @@ -671,7 +640,7 @@ ENDJS my $minuteselector = qq{}; my $secondselector= qq{}; my $cal_link; - unless (($nolink) || ($state eq 'disabled')) { + if (!$nolink) { $cal_link = qq{}; } # @@ -680,24 +649,17 @@ ENDJS $result .= &mt('[_1] [_2] [_3] ', $monthselector,$dayselector,$yearselector). $tzone; - } elsif ($no_mm_ss) { - $result .= &mt('[_1] [_2] [_3] [_4]', - $monthselector,$dayselector,$yearselector, - $hourselector). - $tzone; - } elsif ($no_ss) { - $result .= &mt('[_1] [_2] [_3] [_4] [_5]m', - $monthselector,$dayselector,$yearselector, - $hourselector,$minuteselector). - $tzone; + if (!$nolink) { + $result .= &mt('[_1]Select Date[_2]',$cal_link,''); + } } else { $result .= &mt('[_1] [_2] [_3] [_4] [_5]m [_6]s ', $monthselector,$dayselector,$yearselector, $hourselector,$minuteselector,$secondselector). $tzone; - } - unless (($nolink) || ($state eq 'disabled')) { - $result .= &mt('[_1]Select Date[_2]',$cal_link,''); + if (!$nolink) { + $result .= &mt('[_1]Select Date[_2]',$cal_link,''); + } } $result .= "\n\n"; return $result; @@ -1009,13 +971,10 @@ Inputs =item $number_to_do The total number of items being processed. -=item $preamble Optional HTML to display before the progress bar. - =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() @@ -1085,20 +1044,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 +1107,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(); } @@ -1163,9 +1122,9 @@ sub Close_PrgWin { # ------------------------------------------------------- Puts directory header sub crumbs { - my ($uri,$target,$prefix,$form,$skiplast,$onclick)=@_; + my ($uri,$target,$prefix,$form,$skiplast)=@_; # You cannot crumbnify uploaded or adm resources - if ($uri=~/^\/*(uploaded|adm)\//) { return &mt('(Internal Course/Community Content)'); } + if ($uri=~/^\/*(uploaded|adm)\//) { return &mt('(Internal Course/Group Content)'); } if ($target) { $target = ' target="'. &Apache::loncommon::escape_single($target).'"'; @@ -1185,19 +1144,13 @@ sub crumbs { } else { $path.='/'; } - if ($path eq '/res/') { - unless (&Apache::lonnet::allowed('bre',$path)) { - $output.="$dir/"; - next; - } - } my $href_path = &HTML::Entities::encode($path,'<>&"'); &Apache::loncommon::inhibit_menu_check(\$href_path); if ($form) { my $href = 'javascript:'.$form.".action='".$href_path."';".$form.'.submit();'; - $output.=qq{$dir/}; + $output.=qq{$dir/}; } else { - $output.=qq{$dir/}; + $output.=qq{$dir/}; } } } else { @@ -1268,9 +1221,9 @@ sub htmlareaheaders { ENDEDITOR } $s.=(< - - + + + @@ -1355,7 +1308,6 @@ sub htmlareaselectactive { function startRichEditor(id) { // fix character entities inside // NOTE: this is not fixing characters inside - // NOTE: < and > inside should fix automatically because there should not be a letter after <. var ta = document.getElementById(id); var value = ta.value; var in_m = false; // in the m element @@ -1399,41 +1351,36 @@ sub htmlareaselectactive { function destroyRichEditor(id) { CKEDITOR.instances[id].destroy(); - // replace character entities < and > in and + // replace character entities < and > in // and "&fctname(" by "&fctname(" // and the quotes inside functions: "&fct(1, "a")" -> "&fct(1, "a")" var ta = document.getElementById(id); var value = ta.value; - var in_element = false; // in the m or chem element - var tagname = ""; // m or chem - var in_text = false; // in the text inside the element - var im = -1; // position of start tag + var in_m = false; // in the m element + var in_text = false; // in the text inside the m element + var im = -1; // position of var it = -1; // position of the text inside for (var i=0; i if found twice + in_m = true; in_text = false; im = i; it = -1; - } else if (in_element) { + } else if (in_m) { if (!in_text) { if (value.charAt(i) == ">") { in_text = true; it = i+1; } - } else if (value.substr(i, 3+tagname.length) == "") { - in_element = false; + } else if (value.substr(i, 4) == "") { + in_m = false; var text = value.substr(it, i-it); var l1 = text.length; text = text.replace(/</g, "<"); text = text.replace(/>/g, ">"); var l2 = text.length; - value = value.substr(0, it) + text + value.substr(i); + value = value.substr(0, it) + text + "" + value.substr(i+4); i = i + (l2-l1); } } @@ -1753,48 +1700,6 @@ clientTime = (new Date()).getTime(); END } -## -# Client-side javascript to convert any dashes in text pasted -# into textbox(es) for numericalresponse item(s) to a standard -# minus, i.e., - . Calls to dash_to_minus_js() in end_problem() -# and in loncommon::endbodytag() for a .page (arg: dashjs => 1) -# -# Will apply to any input tag with class: LC_numresponse_text. -# Currently set in start_textline for numericalresponse items. -# - -sub dash_to_minus_js { - return <<'ENDJS'; - - - -ENDJS -} - ############################################################ ############################################################ @@ -1810,19 +1715,12 @@ 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). + $component_help $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. - Returns a string containing breadcrumbs for the current page. =item &clear_breadcrumbs() @@ -1850,7 +1748,7 @@ returns: nothing sub breadcrumbs { my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, - $CourseBreadcrumbs,$topic_help,$topic_help_text) = @_; + $CourseBreadcrumbs) = @_; # $css_class ||= 'LC_breadcrumbs'; @@ -1875,7 +1773,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'; @@ -1957,10 +1855,6 @@ returns: nothing $component_help, $faq,$bug); } - if ($topic_help && $topic_help_text) { - $icons .= ' '.&Apache::loncommon::help_open_topic($topic_help,&mt($topic_help_text),'', - undef,600); - } # @@ -1973,7 +1867,7 @@ returns: nothing } - if (($component) || ($topic_help && $topic_help_text)) { + if ($component) { $links = &htmltag('span', ( $no_mt ? $component : mt($component) ). ( $icons ? $icons : '' ), @@ -2076,16 +1970,6 @@ returns: nothing undef(%tools); } -=item ¤t_breadcrumb_tools() - -returns: a hash containing the current breadcrumb tools. - -=cut - - sub current_breadcrumb_tools { - return %tools; - } - =item &render_tools(\$breadcrumbs) Creates html for breadcrumb tools (categories navigation and tools) and inserts @@ -2152,11 +2036,11 @@ sub docs_breadcrumbs { my $foldername=shift(@folders); if ($folderpath) {$folderpath.='&';} $folderpath.=$folder.'&'.$foldername; - my $url = $env{'request.use_absolute'}; + my $url; if ($allowed) { - $url .= '/adm/coursedocs?folderpath='; + $url = '/adm/coursedocs?folderpath='; } else { - $url .= '/adm/supplemental?folderpath='; + $url = '/adm/supplemental?folderpath='; } $url .= &escape($folderpath); my $name=&unescape($foldername); @@ -2448,7 +2332,7 @@ sub course_selection { if ($totcodes > 0) { my $numtitles = @$codetitles; if ($numtitles > 0) { - $output .= '
'; + $output .= '
'; $output .= '
'.$$codetitles[0].'
'."\n". '