Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/wiki/editors/wiki_editor.php
Go to the documentation of this file.
00001 <?php
00025 function wiki_print_editor_wiki($pageid, $content, $editor, $version = -1, $section = null, $upload = false, $deleteuploads = array(), $comesfrom = 'editorview', $commentid = 0) {
00026     global $CFG, $OUTPUT, $PAGE;
00027 
00028     if ($comesfrom == 'editcomments') {
00029         $action = $CFG->wwwroot . '/mod/wiki/instancecomments.php?pageid=' . $pageid . '&id=' . $commentid . '&action=edit';
00030     } else if ($comesfrom == 'addcomments') {
00031         $action = $CFG->wwwroot . '/mod/wiki/instancecomments.php?pageid=' . $pageid . '&id=' . $commentid . '&action=add';
00032     } else {
00033         $action = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $pageid;
00034     }
00035 
00036     if (!empty($section)) {
00037         $action .= "&amp;section=" . urlencode($section);
00038     }
00039 
00041     $tag = getTokens($editor, 'bold');
00042     $wiki_editor['bold'] = array('ed_bold.gif', get_string('wikiboldtext', 'wiki'), $tag[0], $tag[1], get_string('wikiboldtext', 'wiki'));
00043     $tag = getTokens($editor, 'italic');
00044     $wiki_editor['italic'] = array('ed_italic.gif', get_string('wikiitalictext', 'wiki'), $tag[0], $tag[1], get_string('wikiitalictext', 'wiki'));
00045     $tag = getTokens($editor, 'link');
00046     $wiki_editor['internal'] = array('ed_internal.gif', get_string('wikiinternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiinternalurl', 'wiki'));
00047     $tag = getTokens($editor, 'url');
00048     $wiki_editor['external'] = array('ed_external.gif', get_string('wikiexternalurl', 'wiki'), $tag[0], $tag[1], get_string('wikiexternalurl', 'wiki'));
00049     $tag = getTokens($editor, 'list');
00050     $wiki_editor['u_list'] = array('ed_ul.gif', get_string('wikiunorderedlist', 'wiki'), '\\n' . $tag[0], '', '');
00051     $wiki_editor['o_list'] = array('ed_ol.gif', get_string('wikiorderedlist', 'wiki'), '\\n' . $tag[1], '', '');
00052     $tag = getTokens($editor, 'image');
00053     $wiki_editor['image'] = array('ed_img.gif', get_string('wikiimage', 'wiki'), $tag[0], $tag[1], get_string('wikiimage', 'wiki'));
00054     $tag = getTokens($editor, 'header');
00055     $wiki_editor['h1'] = array('ed_h1.gif', get_string('wikiheader', 'wiki', 1), '\\n' . $tag . ' ', ' ' . $tag . '\\n', get_string('wikiheader', 'wiki', 1));
00056     $wiki_editor['h2'] = array('ed_h2.gif', get_string('wikiheader', 'wiki', 2), '\\n' . $tag . $tag . ' ', ' ' . $tag . $tag . '\\n', get_string('wikiheader', 'wiki', 2));
00057     $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));
00058     $tag = getTokens($editor, 'line_break');
00059     $wiki_editor['hr'] = array('ed_hr.gif', get_string('wikihr', 'wiki'), '\\n' . $tag . '\\n', '', '');
00060     $tag = getTokens($editor, 'nowiki');
00061     $wiki_editor['nowiki'] = array('ed_nowiki.gif', get_string('wikinowikitext', 'wiki'), $tag[0], $tag[1], get_string('wikinowikitext', 'wiki'));
00062 
00063     $OUTPUT->heading(strtoupper(get_string('format' . $editor, 'wiki')));
00064 
00065     $PAGE->requires->js('/mod/wiki/editors/wiki/buttons.js');
00066 
00067     echo $OUTPUT->container_start('mdl-align');
00068     foreach ($wiki_editor as $button) {
00069         echo "<a href=\"javascript:insertTags";
00070         echo "('" . $button[2] . "','" . $button[3] . "','" . $button[4] . "');\">";
00071         echo "<img width=\"23\" height=\"22\" src=\"$CFG->wwwroot/mod/wiki/editors/wiki/images/$button[0]\" alt=\"" . $button[1] . "\" title=\"" . $button[1] . "\" />";
00072         echo "</a>";
00073     }
00074     echo $OUTPUT->container_end();
00075 
00076     echo $OUTPUT->container_start('mdl-align');
00077     echo '<form method="post" id="mform1" action="' . $action . '">';
00078     echo $OUTPUT->container(print_textarea(false, 20, 60, 0, 0, "newcontent", $content, 0, true), false, 'wiki_editor');
00079     echo $OUTPUT->container_start();
00080     wiki_print_edit_form_default_fields($editor, $pageid, $version, $upload, $deleteuploads);
00081     echo $OUTPUT->container_end();
00082     echo '</form>';
00083     echo $OUTPUT->container_end();
00084 }
00085 
00093 function getTokens($format, $token) {
00094     $tokens = wiki_parser_get_token($format, $token);
00095 
00096     if (is_array($tokens)) {
00097         foreach ($tokens as $key => $value) {
00098             $tokens[$key] = urlencode(str_replace("'", "\'", $value));
00099         }
00100     } else {
00101         urlencode(str_replace("'", "\'", $token));
00102     }
00103 
00104     return $tokens;
00105 }
 All Data Structures Namespaces Files Functions Variables Enumerations