Skip to content

Commit

Permalink
Merge branch 'wip-mdl-28101-m22' of git://github.com/rajeshtaneja/moo…
Browse files Browse the repository at this point in the history
…dle into MOODLE_22_STABLE
  • Loading branch information
Aparup Banerjee committed Feb 14, 2012
2 parents 0c8c296 + b71bd1e commit 7fda50c
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions mod/wiki/editors/wiki_editor.php
Expand Up @@ -38,26 +38,26 @@ function wiki_print_editor_wiki($pageid, $content, $editor, $version = -1, $sect
} }


///Get tags for every element we are displaying ///Get tags for every element we are displaying
$tag = wiki_parser_get_token($editor, 'bold'); $tag = getTokens($editor, 'bold');
$wiki_editor['bold'] = array('ed_bold.gif', get_string('wikiboldtext', 'wiki'), $tag[0], $tag[1], get_string('wikiboldtext', 'wiki')); $wiki_editor['bold'] = array('ed_bold.gif', get_string('wikiboldtext', 'wiki'), $tag[0], $tag[1], get_string('wikiboldtext', 'wiki'));
$tag = wiki_parser_get_token($editor, 'italic'); $tag = getTokens($editor, 'italic');
$wiki_editor['italic'] = array('ed_italic.gif', get_string('wikiitalictext', 'wiki'), $tag[0], $tag[1], get_string('wikiitalictext', 'wiki')); $wiki_editor['italic'] = array('ed_italic.gif', get_string('wikiitalictext', 'wiki'), $tag[0], $tag[1], get_string('wikiitalictext', 'wiki'));
$tag = wiki_parser_get_token($editor, 'link'); $tag = getTokens($editor, 'link');
$wiki_editor['internal'] = array('ed_internal.gif', get_string('wikiinternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiinternalurl', 'wiki')); $wiki_editor['internal'] = array('ed_internal.gif', get_string('wikiinternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiinternalurl', 'wiki'));
$tag = wiki_parser_get_token($editor, 'url'); $tag = getTokens($editor, 'url');
$wiki_editor['external'] = array('ed_external.gif', get_string('wikiexternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiexternalurl', 'wiki')); $wiki_editor['external'] = array('ed_external.gif', get_string('wikiexternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiexternalurl', 'wiki'));
$tag = wiki_parser_get_token($editor, 'list'); $tag = getTokens($editor, 'list');
$wiki_editor['u_list'] = array('ed_ul.gif', get_string('wikiunorderedlist', 'wiki'), '\\n' . $tag[0], '', ''); $wiki_editor['u_list'] = array('ed_ul.gif', get_string('wikiunorderedlist', 'wiki'), '\\n' . $tag[0], '', '');
$wiki_editor['o_list'] = array('ed_ol.gif', get_string('wikiorderedlist', 'wiki'), '\\n' . $tag[1], '', ''); $wiki_editor['o_list'] = array('ed_ol.gif', get_string('wikiorderedlist', 'wiki'), '\\n' . $tag[1], '', '');
$tag = wiki_parser_get_token($editor, 'image'); $tag = getTokens($editor, 'image');
$wiki_editor['image'] = array('ed_img.gif', get_string('wikiimage', 'wiki'), $tag[0], $tag[1], get_string('wikiimage', 'wiki')); $wiki_editor['image'] = array('ed_img.gif', get_string('wikiimage', 'wiki'), $tag[0], $tag[1], get_string('wikiimage', 'wiki'));
$tag = wiki_parser_get_token($editor, 'header'); $tag = getTokens($editor, 'header');
$wiki_editor['h1'] = array('ed_h1.gif', get_string('wikiheader', 'wiki', 1), '\\n' . $tag . ' ', ' ' . $tag . '\\n', get_string('wikiheader', 'wiki', 1)); $wiki_editor['h1'] = array('ed_h1.gif', get_string('wikiheader', 'wiki', 1), '\\n' . $tag . ' ', ' ' . $tag . '\\n', get_string('wikiheader', 'wiki', 1));
$wiki_editor['h2'] = array('ed_h2.gif', get_string('wikiheader', 'wiki', 2), '\\n' . $tag . $tag . ' ', ' ' . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 2)); $wiki_editor['h2'] = array('ed_h2.gif', get_string('wikiheader', 'wiki', 2), '\\n' . $tag . $tag . ' ', ' ' . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 2));
$wiki_editor['h3'] = array('ed_h3.gif', get_string('wikiheader', 'wiki', 3), '\\n' . $tag . $tag . $tag . ' ', ' ' . $tag . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 3)); $wiki_editor['h3'] = array('ed_h3.gif', get_string('wikiheader', 'wiki', 3), '\\n' . $tag . $tag . $tag . ' ', ' ' . $tag . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 3));
$tag = wiki_parser_get_token($editor, 'line_break'); $tag = getTokens($editor, 'line_break');
$wiki_editor['hr'] = array('ed_hr.gif', get_string('wikihr', 'wiki'), '\\n' . $tag . '\\n', '', ''); $wiki_editor['hr'] = array('ed_hr.gif', get_string('wikihr', 'wiki'), '\\n' . $tag . '\\n', '', '');
$tag = wiki_parser_get_token($editor, 'nowiki'); $tag = getTokens($editor, 'nowiki');
$wiki_editor['nowiki'] = array('ed_nowiki.gif', get_string('wikinowikitext', 'wiki'), $tag[0], $tag[1], get_string('wikinowikitext', 'wiki')); $wiki_editor['nowiki'] = array('ed_nowiki.gif', get_string('wikinowikitext', 'wiki'), $tag[0], $tag[1], get_string('wikinowikitext', 'wiki'));


$OUTPUT->heading(strtoupper(get_string('format' . $editor, 'wiki'))); $OUTPUT->heading(strtoupper(get_string('format' . $editor, 'wiki')));
Expand All @@ -82,3 +82,24 @@ function wiki_print_editor_wiki($pageid, $content, $editor, $version = -1, $sect
echo '</form>'; echo '</form>';
echo $OUTPUT->container_end(); echo $OUTPUT->container_end();
} }

/**
* Returns escaped token used by a wiki language to represent a given tag or "object" (bold -> **)
*
* @param string $format format of page
* @param array|string $token format tokens which needs to be escaped
* @return array|string
*/
function getTokens($format, $token) {
$tokens = wiki_parser_get_token($format, $token);

if (is_array($tokens)) {
foreach ($tokens as $key => $value) {
$tokens[$key] = urlencode(str_replace("'", "\'", $value));
}
} else {
urlencode(str_replace("'", "\'", $token));
}

return $tokens;
}

0 comments on commit 7fda50c

Please sign in to comment.