MDL-25501 reverting PULL-95
[moodle.git] / mod / wiki / db / migration / lib.php
CommitLineData
00710f4c
DC
1<?php
2function wiki_ewiki_2_html($oldentry, $oldpage, $oldwiki) {
3 global $CFG, $wiki_entry, $moodle_disable_camel_case, $ewiki_plugins, $ewiki_config, $moodle_format;
4
5 $wiki_entry = $oldentry;
6
7 $moodle_disable_camel_case = ($oldwiki->disablecamelcase == 1);
8
90c42e0f 9 // Block of dinamic ewiki defines
00710f4c
DC
10 wiki_set_define("EWIKI_NAME", $wiki_entry->pagename);
11 wiki_set_define("EWIKI_DEFAULT_LANG", current_language());
12 if ($moodle_disable_camel_case) {
13 wiki_set_define("EWIKI_CHARS_L", "");
14 wiki_set_define("EWIKI_CHARS_U", "");
15 } else {
16 wiki_set_define("EWIKI_CHARS_L", "a-z_ยตยค$\337-\377");
17 wiki_set_define("EWIKI_CHARS_U", "A-Z0-9\300-\336");
18 }
19
20 wiki_set_define("EWIKI_CHARS", wiki_get_define('EWIKI_CHARS_L') . wiki_get_define('EWIKI_CHARS_U'));
21
22 require_once($CFG->dirroot . '/mod/wiki/db/migration/wiki/ewikimoodlelib.php');
23 require_once($CFG->dirroot . '/mod/wiki/db/migration/wiki/ewiki/ewiki.php');
24
25 if ($oldwiki->htmlmode == 0) {
26 # No HTML
27 $ewiki_config["htmlentities"] = array(); // HTML is managed by moodle
28 $moodle_format = FORMAT_TEXT;
29 }
30 if ($oldwiki->htmlmode == 1) {
31 # Safe HTML
32 include_once($CFG->dirroot . "/mod/wiki/db/migration/wiki/ewiki/plugins/moodle/moodle_rescue_html.php");
33 $moodle_format = FORMAT_HTML;
34 }
35 if ($oldwiki->htmlmode == 2) {
36 # HTML Only
37 $moodle_format = FORMAT_HTML;
38 $ewiki_use_editor = 1;
39 $ewiki_config["htmlentities"] = array(); // HTML is allowed
40 $ewiki_config["wiki_link_regex"] = "\007 [!~]?(
41 \#?\[[^<>\[\]\n]+\] |
42 \^[-" .
43 wiki_get_define('EWIKI_CHARS_U') . wiki_get_define('EWIKI_CHARS_L') . "]{3,} |
44 \b([\w]{3,}:)*([" .
45 wiki_get_define('EWIKI_CHARS_U') . "]+[" . wiki_get_define('EWIKI_CHARS_L') . "]+){2,}\#?[\w\d]* |
46 \w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x";
47 }
48
49 $content = ewiki_format($oldpage->content);
50
90c42e0f
PS
51 return format_text($content, $moodle_format);
52
00710f4c
DC
53}
54
55function wiki_set_define($key, $value) {
56 global $ewikidefines;
57
58 $ewikidefines[$key] = $value;
59}
60
61function wiki_get_define($key) {
62 global $ewikidefines;
63
64 return $ewikidefines[$key];
65}
66