diff --git a/lib/javascript-navigation.js b/lib/javascript-navigation.js index 59c591d5a68..451dc61dff7 100644 --- a/lib/javascript-navigation.js +++ b/lib/javascript-navigation.js @@ -771,26 +771,33 @@ navigation_tree_branch.prototype.inject_into_dom = function (element, gntinstanc if (this.myid != null) { branchp.setAttribute('id',this.myid); } + var branchicon = false; if (this.myicon != null) { - var branchicon = document.createElement('img'); + branchicon = document.createElement('img'); branchicon.setAttribute('src',this.myicon); branchicon.setAttribute('alt',''); - branchp.appendChild(branchicon); this.myname = ' '+this.myname; } if (this.mylink === null) { - branchp.innerHTML = this.myname.replace(/\n/g, '
'); + if (branchicon !== false) { + branchp.appendChild(branchicon); + } + branchp.appendChild(document.createTextNode(this.myname.replace(/\n/g, '
'))); } else { var branchlink = document.createElement('a'); branchlink.setAttribute('title', this.mytitle); branchlink.setAttribute('href', this.mylink); - branchlink.innerHTML = this.myname.replace(/\n/g, '
'); + if (branchicon !== false) { + branchlink.appendChild(branchicon); + } + branchlink.appendChild(document.createTextNode(this.myname.replace(/\n/g, '
'))); if (this.myhidden) { YAHOO.util.Dom.addClass(branchlink, 'dimmed'); } branchp.appendChild(branchlink); } branchli.appendChild(branchp); + alert(branchli.innerHTML); element.appendChild(branchli); return branchli; } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index a128204f43c..f29e2b0d662 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -402,6 +402,15 @@ class navigation_node { $title = $this->title; } + if ($this->icon!==null) { + $icon = new html_image(); + $icon->src = $this->icon; + $icon->alt = ''; + $content = $OUTPUT->image($icon).' '.$content; + } else if ($this->helpbutton!==null) { + $content = sprintf('%s%s',trim($this->helpbutton),$content); + } + if ($content != '' && ((is_object($this->action) && ($this->action instanceof moodle_url || $this->action instanceof html_link)) || is_string($this->action))) { if (!($this->action instanceof html_link)) { $link = new html_link(); @@ -424,19 +433,15 @@ class navigation_node { $content = $OUTPUT->link($link); } else { + $span = new html_span(); + $span->contents = $content; if ($title !== '') { - $title = ' title="'.s($title).'"'; + $span->title = $title; } if ($this->hidden) { - $content = sprintf('%s', $title, clean_text($content)); - } else { - $content = sprintf('%s', $title, clean_text($content)); + $span->add_class('dimmed_text'); } - } - if ($this->icon!==null) { - $content = sprintf(' %s',$this->icon,$content); - } else if ($this->helpbutton!==null) { - $content = sprintf('%s%s',trim($this->helpbutton),$content); + $content = $OUTPUT->span($span); } return $content; }