From 0a8e8b6fd87947dbf2fb766f845e0f8cb3b5e730 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Wed, 9 Sep 2009 06:16:09 +0000 Subject: [PATCH] navigation MDL-14632 Added title tags for navigation items that are trimmed but do not have an action --- lib/navigationlib.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 3d4686248f..24ed7c7ec7 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -371,26 +371,34 @@ class navigation_node { return ''; } if ($shorttext && $this->shorttext!==null) { - $content = s($this->shorttext); + $content = clean_text($this->shorttext); } else { - $content = s($this->text); + $content = clean_text($this->text); } + $title = ''; + if ($this->forcetitle || ($this->shorttext!==null && $this->title !== $this->shorttext) || $this->title !== $this->text) { + $title = $this->title; + } + if ($content != '' && ((is_object($this->action) && $this->action instanceof moodle_url) || is_string($this->action))) { $link = new html_link(); - if ($this->forcetitle || ($this->shorttext!==null && $this->title !== $this->shorttext) || $this->title !== $this->text) { - $link->title = $this->title; + if ($title !== '') { + $link->title = $title; } if ($this->hidden) { $link->add_class('dimmed'); } $link->url = $this->action; - $link->text = $content; + $link->text = clean_text($content); $content = $OUTPUT->link($link); } else { + if ($title !== '') { + $title = ' title="'.s($title).'"'; + } if ($this->hidden) { - $content = sprintf('%s', $content); + $content = sprintf('%s', $title, clean_text($content)); } else { - $content = sprintf('%s', $content); + $content = sprintf('%s', $title, clean_text($content)); } } if ($this->icon!==null) { @@ -947,7 +955,7 @@ class global_navigation extends navigation_node { $this->add_to_path($keys, $module->id, $module->name, $module->name, $type, $url, $icon); $child = $this->find_child($module->id, $type); if ($child != false) { - $child->title(get_string($module->modname, $module->modname)); + $child->title(get_string('modulename', $module->modname)); if ($type==navigation_node::TYPE_ACTIVITY && $this->module_extends_navigation($module->modname)) { $child->nodetype = self::NODETYPE_BRANCH; } @@ -1011,7 +1019,7 @@ class global_navigation extends navigation_node { $this->add_to_path($path, $module->id, $module->name, $module->name, $type, $url, $icon); $child = $this->find_child($module->id, $type); if ($child != false) { - $child->title(get_string($module->modname, $module->modname)); + $child->title(get_string('modulename', $module->modname)); if (!$module->visible) { $child->hidden = true; } @@ -1721,7 +1729,7 @@ class limited_global_navigation extends global_navigation { $this->add_to_path($keys, $module->id, $module->name, $module->name, $type, $url, $icon); $child = $this->find_child($module->id, $type); if ($child != false) { - $child->title(get_string($module->modname, $module->modname)); + $child->title(get_string('modulename', $module->modname)); if (!$module->visible) { $child->hidden = true; } -- 2.39.5