--- loncom/interface/lonhtmlcommon.pm 2024/10/21 15:44:06 1.358.2.19.2.12
+++ loncom/interface/lonhtmlcommon.pm 2015/04/24 21:31:56 1.361
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.358.2.19.2.12 2024/10/21 15:44:06 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.361 2015/04/24 21:31:56 musolffc 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 '';
}
@@ -96,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 {
@@ -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;
}
@@ -415,7 +407,7 @@ sub textbox {
##############################################
##############################################
sub checkbox {
- my ($name,$checked,$value,$special) = @_;
+ my ($name,$checked,$value) = @_;
my $Str = '';
+ $Str .= ' />';
return $Str;
}
@@ -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.
@@ -490,50 +484,23 @@ 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
-Bugs
+=item Bugs
The method used to restrict user input will fail in the year 2400.
+=back
+
=cut
##############################################
##############################################
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;
@@ -542,8 +509,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;
@@ -679,7 +644,7 @@ ENDJS
my $minuteselector = qq{};
my $secondselector= qq{};
my $cal_link;
- unless (($nolink) || ($state eq 'disabled')) {
+ if (!$nolink) {
$cal_link = qq{};
}
#
@@ -688,24 +653,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;
@@ -749,7 +707,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 +723,8 @@ The unix time to use as the default in c
=back
+=back
+
Returns: Unix time represented in the form.
=cut
@@ -856,14 +818,13 @@ parameter setting wizard.
##############################################
sub pjump_javascript_definition {
my $Str = <&"');
&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 {
@@ -1277,9 +1255,9 @@ sub htmlareaheaders {
ENDEDITOR
}
$s.=(<
-
-
+
+
+
@@ -1687,29 +1665,13 @@ sub show_return_link {
unless ($env{'request.course.id'}) { return 0; }
if ($env{'request.noversionuri'}=~m{^/priv/} ||
$env{'request.uri'}=~m{^/priv/}) { return 1; }
- return if (($env{'request.noversionuri'} eq '/adm/supplemental') &&
- ($env{'form.folder'} ne 'supplemental'));
- return if (($env{'form.folderpath'} ne '') &&
- (($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) ||
- ($env{'request.noversionuri'} =~ m{^/public/$match_domain/$match_courseid/syllabus$})));
- if (($env{'request.noversionuri'} =~ m{^/adm/viewclasslist($|\?)})
+ return if ($env{'request.noversionuri'} eq '/adm/supplemental');
+
+ if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)})
|| ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) {
return if ($env{'form.register'});
}
- if ((($env{'request.symb'} ne '') || ($env{'form.folderpath'} ne '')) &&
- ($env{'request.noversionuri'} =~m{^/adm/coursedocs/showdoc/uploaded/($match_domain)/($match_courseid)/(docs|supplemental)/})) {
- my ($cdom,$cnum,$area) = ($1,$2,$3);
- if (($env{'course.'.$env{'request.course.id'}.'.domain'} eq $cdom) &&
- ($env{'course.'.$env{'request.course.id'}.'.num'} eq $cnum)) {
- if (($env{'request.symb'}) && ($area eq 'docs')) {
- my ($map,$resid,$url) = &Apache::lonnet::decode_symb($env{'request.symb'});
- return if ($env{'request.noversionuri'} eq '/adm/coursedocs/showdoc/'.$url);
- } elsif (($env{'form.folderpath'}) && ($area eq 'supplemental')) {
- return;
- }
- }
- }
return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
$env{'request.symb'} eq '')
||
@@ -1718,7 +1680,7 @@ sub show_return_link {
(($env{'request.noversionuri'}=~/^\/adm\//) &&
($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
($env{'request.noversionuri'}!~
- m{^/adm/.*/(smppg|bulletinboard|ext\.tool)($|\?)})
+ m{^/adm/.*/(smppg|bulletinboard)($|\?)})
));
}
@@ -1778,54 +1740,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
-}
-
############################################################
############################################################
@@ -1840,21 +1754,37 @@ 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)
- $crumbs_style (optional style attribute for div containing breadcrumbs
- unless called from docs_breadcrumbs)
- $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
+
+=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
+
+=back
+
+=back
Returns a string containing breadcrumbs for the current page.
@@ -1882,9 +1812,11 @@ returns: nothing
my %tools = ();
sub breadcrumbs {
- my ($component,$component_help,$menulink,$helplink,$crumbs_style,$no_mt,
- $CourseBreadcrumbs,$topic_help,$topic_help_text,$links_target) = @_;
+ my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt,
+ $CourseBreadcrumbs) = @_;
#
+ $css_class ||= 'LC_breadcrumbs';
+
# Make the faq and bug data cascade
my $faq = '';
my $bug = '';
@@ -1897,16 +1829,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'})) &&
@@ -1916,7 +1838,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';
@@ -1924,15 +1846,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) {
@@ -1950,8 +1866,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','',
$hashref);
@@ -2002,12 +1918,7 @@ returns: nothing
if ($faq ne '' || $component_help ne '' || $bug ne '') {
$icons .= &Apache::loncommon::help_open_menu($component,
$component_help,
- $faq,$bug,'','','','',
- $links_target);
- }
- if ($topic_help && $topic_help_text) {
- $icons .= ' '.&Apache::loncommon::help_open_topic($topic_help,&mt($topic_help_text),'',
- undef,600,'',$links_target);
+ $faq,$bug);
}
#
@@ -2021,7 +1932,7 @@ returns: nothing
}
- if (($component) || ($topic_help && $topic_help_text)) {
+ if ($component) {
$links = &htmltag('span',
( $no_mt ? $component : mt($component) ).
( $icons ? $icons : '' ),
@@ -2037,13 +1948,8 @@ returns: nothing
}
if (($links ne '') || ($nav_and_tools)) {
&render_tools(\$links);
- unless ($CourseBreadcrumbs) {
- my $args = { id => 'LC_breadcrumbs' };
- if ($crumbs_style ne '') {
- $args->{'style'} = $crumbs_style;
- }
- $links = &htmltag('div', $links, $args);
- }
+ $links = &htmltag('div', $links,
+ { id => "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ;
}
my $adv_tools = 0;
if (ref($tools{'advtools'}) eq 'ARRAY') {
@@ -2081,7 +1987,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
@@ -2095,7 +2003,9 @@ remaining items in right of breadcrumbs
advanced tools shown in a separate box below breadcrumbs line
=back
-
+
+=back
+
returns: nothing
=cut
@@ -2129,23 +2039,22 @@ returns: nothing
undef(%tools);
}
-=item ¤t_breadcrumb_tools()
+=item &render_tools(\$breadcrumbs)
-returns: a hash containing the current breadcrumb tools.
+Creates html for breadcrumb tools (categories navigation and tools) and inserts
+\$breadcrumbs at the correct position.
-=cut
+=over
- sub current_breadcrumb_tools {
- return %tools;
- }
+=item input:
-=item &render_tools(\$breadcrumbs)
+=over
-Creates html for breadcrumb tools (categories navigation and tools) and inserts
-\$breadcrumbs at the correct position.
+=item \$breadcrumbs - a reference to the string containing prepared breadcrumbs.
-input: \$breadcrumbs - a reference to the string containing prepared
-breadcrumbs.
+=back
+
+=back
returns: nothing
@@ -2171,8 +2080,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
@@ -2190,7 +2108,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/) {
@@ -2205,21 +2123,19 @@ 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);
# each of randompick number, hidden, encrypted, random order, is_page
# are appended with ":"s to the foldername
$name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)\:?(\d*)$//;
- if ($contenteditor) {
- if ($supplementalflag) {
- if ($2) { $ishidden=1; }
- } else {
+ unless ($supplementalflag) {
+ if ($contenteditor) {
if ($1 ne '') {
$randompick=$1;
} else {
@@ -2260,17 +2176,9 @@ sub docs_breadcrumbs {
$plain=~s/\>\;\s*$//;
}
my $menulink = 0;
- if (!$allowed && !$contenteditor && !$supplementalflag) {
+ 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,
@@ -2511,7 +2419,7 @@ sub course_selection {
if ($totcodes > 0) {
my $numtitles = @$codetitles;
if ($numtitles > 0) {
- $output .= ' ';
+ $output .= ' ';
$output .= '