--- loncom/interface/lonhtmlcommon.pm 2015/05/11 17:18:36 1.358.2.1
+++ loncom/interface/lonhtmlcommon.pm 2016/09/15 17:31:00 1.358.2.7
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.358.2.1 2015/05/11 17:18:36 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.358.2.7 2016/09/15 17:31:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1158,7 +1158,7 @@ sub Close_PrgWin {
# ------------------------------------------------------- Puts directory header
sub crumbs {
- my ($uri,$target,$prefix,$form,$skiplast)=@_;
+ my ($uri,$target,$prefix,$form,$skiplast,$onclick)=@_;
# You cannot crumbnify uploaded or adm resources
if ($uri=~/^\/*(uploaded|adm)\//) { return &mt('(Internal Course/Group Content)'); }
if ($target) {
@@ -1184,9 +1184,9 @@ sub crumbs {
&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 {
@@ -1257,9 +1257,9 @@ sub htmlareaheaders {
ENDEDITOR
}
$s.=(<
-
-
+
+
+
@@ -1342,6 +1342,41 @@ 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
+ 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_m) {
+ if (!in_text) {
+ if (value.charAt(i) == ">") {
+ in_text = true;
+ it = i+1;
+ }
+ } else if (value.substr(i, 4) == "") {
+ in_m = false;
+ var text = value.substr(it, i-it);
+ var l1 = text.length;
+ text = text.replace(//g, ">");
+ var l2 = text.length;
+ value = value.substr(0, it) + text + "" + value.substr(i+4);
+ i = i + (l2-l1);
+ }
+ }
+ }
+ ta.value = value;
CKEDITOR.replace(id,
{
customConfig: "/ckeditor/loncapaconfig.js",
@@ -1353,6 +1388,68 @@ sub htmlareaselectactive {
function destroyRichEditor(id) {
CKEDITOR.instances[id].destroy();
+ // replace character entities < and > in and
+ // 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 it = -1; // position of the text inside
+ for (var i=0; i") {
+ in_text = true;
+ it = i+1;
+ }
+ } else if (value.substr(i, 3+tagname.length) == ""+tagname+">") {
+ in_element = 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);
+ i = i + (l2-l1);
+ }
+ }
+ }
+ // fix function names
+ value = value.replace(/&([a-zA-Z_]+)\(/g, "&$1(");
+ // fix quotes in functions
+ var pos_next_fct = value.search(/&[a-zA-Z_]+\(/);
+ var depth = 0;
+ for (var i=0; i 0) {
+ if (value.charAt(i) == ")")
+ depth--;
+ else if (value.substr(i, 6) == """)
+ value = value.substr(0, i) + "\"" + value.substr(i+6);
+ }
+ }
+ // replace the text value
+ ta.value = value;
}
function editorHandler(event) {
@@ -1660,12 +1757,19 @@ 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
+ $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.
+
Returns a string containing breadcrumbs for the current page.
=item &clear_breadcrumbs()
@@ -1693,7 +1797,7 @@ returns: nothing
sub breadcrumbs {
my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt,
- $CourseBreadcrumbs) = @_;
+ $CourseBreadcrumbs,$topic_help,$topic_help_text) = @_;
#
$css_class ||= 'LC_breadcrumbs';
@@ -1800,6 +1904,10 @@ 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);
+ }
#
@@ -1812,7 +1920,7 @@ returns: nothing
}
- if ($component) {
+ if (($component) || ($topic_help && $topic_help_text)) {
$links = &htmltag('span',
( $no_mt ? $component : mt($component) ).
( $icons ? $icons : '' ),
@@ -1915,6 +2023,16 @@ 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
@@ -2277,7 +2395,7 @@ sub course_selection {
if ($totcodes > 0) {
my $numtitles = @$codetitles;
if ($numtitles > 0) {
- $output .= ' ';
+ $output .= ' ';
$output .= '