diff --git a/mod/wiki/parser/markups/html.php b/mod/wiki/parser/markups/html.php
index 26961b882c8..544b6bafa25 100644
--- a/mod/wiki/parser/markups/html.php
+++ b/mod/wiki/parser/markups/html.php
@@ -110,18 +110,20 @@ class html_parser extends nwiki_parser {
* @return string
*/
protected function generate_header($text, $level) {
- $text = trim($text);
+ $toctext = $text = trim($text);
$normlevel = $level - $this->minheaderlevel + 1;
if (!$this->pretty_print && $normlevel == 1) {
- $text .= ' ' . parser_utils::h('a', '['.get_string('editsection', 'wiki').']',
- array('href' => "edit.php?pageid={$this->wiki_page_id}§ion=" . urlencode($text),
- 'class' => 'wiki_edit_section'));
+ $editlink = '[' . get_string('editsection', 'wiki') . ']';
+ $url = array('href' => "edit.php?pageid={$this->wiki_page_id}§ion=" . urlencode($text),
+ 'class' => 'wiki_edit_section');
+ $text .= ' ' . parser_utils::h('a', $this->protect($editlink), $url);
+ $toctext .= ' ' . parser_utils::h('a', $editlink, $url);
}
if ($normlevel <= $this->maxheaderdepth) {
- $this->toc[] = array($normlevel, $text);
+ $this->toc[] = array($normlevel, $toctext);
$num = count($this->toc);
$text = parser_utils::h('a', "", array('name' => "toc-$num")) . $text;
}
diff --git a/mod/wiki/parser/markups/wikimarkup.php b/mod/wiki/parser/markups/wikimarkup.php
index a8984ccd35d..f24147d08b2 100644
--- a/mod/wiki/parser/markups/wikimarkup.php
+++ b/mod/wiki/parser/markups/wikimarkup.php
@@ -178,16 +178,18 @@ abstract class wiki_markup_parser extends generic_parser {
*/
protected function generate_header($text, $level) {
- $text = trim($text);
+ $toctext = $text = trim($text);
if (!$this->pretty_print && $level == 1) {
- $text .= ' ' . parser_utils::h('a', '['.get_string('editsection', 'wiki').']',
- array('href' => "edit.php?pageid={$this->wiki_page_id}§ion=" . urlencode($text),
- 'class' => 'wiki_edit_section'));
+ $editlink = '[' . get_string('editsection', 'wiki') . ']';
+ $url = array('href' => "edit.php?pageid={$this->wiki_page_id}§ion=" . urlencode($text),
+ 'class' => 'wiki_edit_section');
+ $text .= ' ' . parser_utils::h('a', $this->protect($editlink), $url);
+ $toctext .= ' ' . parser_utils::h('a', $editlink, $url);
}
if ($level <= $this->maxheaderdepth) {
- $this->toc[] = array($level, $text);
+ $this->toc[] = array($level, $toctext);
$num = count($this->toc);
$text = parser_utils::h('a', "", array('name' => "toc-$num")) . $text;
}