From: mchurch Date: Thu, 24 Jun 2004 15:56:01 +0000 (+0000) Subject: Added a per-wiki option to allow disabling of automatic camel case linking. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e8f993326c6a74cf81c6add91cc2c11cc9851285;p=moodle.git Added a per-wiki option to allow disabling of automatic camel case linking. If pages have been created using camel case, and this option is activated, those pages remain, but may not be linkable. If the option is disabled, they will be linked again. --- diff --git a/lang/en/help/wiki/studentadminoptions.html b/lang/en/help/wiki/studentadminoptions.html index 59d7535cb1..19a9b07789 100644 --- a/lang/en/help/wiki/studentadminoptions.html +++ b/lang/en/help/wiki/studentadminoptions.html @@ -1,4 +1,4 @@ -

Allow Binary Files

+

Student Administration Options

Certain administration options can be turned 'on' or 'off' for students. When 'on', these options only take affect for wikis that can be edited by the student. When 'off', they will not appear in the administrator diff --git a/lang/en/help/wiki/wikilinkoptions.html b/lang/en/help/wiki/wikilinkoptions.html new file mode 100644 index 0000000000..65e53851a3 --- /dev/null +++ b/lang/en/help/wiki/wikilinkoptions.html @@ -0,0 +1,10 @@ +

Wiki Auto-linking Options

+ +

In certain situations, you may not want automatic linking based on CamelCase words. +If this is so, check this box to disable CamelCase linking. +

+

+WARNING -- CamelCase is a standard wiki feature, and disabling it may cause other +imported wikis to work incorrectly. Use this feature only if you are absolutely certain +you do not want CamelCase linking. +

diff --git a/lang/en/wiki.php b/lang/en/wiki.php index 7342983414..566824f197 100644 --- a/lang/en/wiki.php +++ b/lang/en/wiki.php @@ -10,6 +10,7 @@ $string['wikitype'] = 'Type'; $string['ewikiprinttitle'] = 'Print the wiki name on every page.'; $string['htmlmode'] = 'HTML Mode'; $string['ewikiacceptbinary'] = 'Allow binary files'; +$string['wikilinkoptions'] = 'Wiki auto-linking options'; $string['studentadminoptions'] = 'Student admin options'; $string['initialcontent'] = 'Choose an Initial Page'; $string['chooseafile'] = 'Choose/upload initial page'; diff --git a/mod/wiki/db/mysql.php b/mod/wiki/db/mysql.php index e6421f7c30..1fbb95e76b 100644 --- a/mod/wiki/db/mysql.php +++ b/mod/wiki/db/mysql.php @@ -46,6 +46,11 @@ function wiki_upgrade($oldversion) { .' ADD `revertchanges` TINYINT DEFAULT \'1\' NOT NULL AFTER `removepages`'); } + if ($oldversion < 2004062400) { + execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki`' + .' ADD `disablecamelcase` TINYINT DEFAULT \'0\' NOT NULL AFTER `ewikiacceptbinary`'); + } + return true; } diff --git a/mod/wiki/db/mysql.sql b/mod/wiki/db/mysql.sql index d52f88120a..7bef549eb1 100644 --- a/mod/wiki/db/mysql.sql +++ b/mod/wiki/db/mysql.sql @@ -15,6 +15,7 @@ CREATE TABLE `prefix_wiki` ( `ewikiprinttitle` tinyint(4) NOT NULL default '1', `htmlmode` tinyint(4) NOT NULL default '0', `ewikiacceptbinary` tinyint(4) NOT NULL default '0', + `disablecamelcase` tinyint(4) NOT NULL default '0', `setpageflags` tinyint(4) NOT NULL default '1', `strippages` tinyint(4) NOT NULL default '1', `removepages` tinyint(4) NOT NULL default '1', diff --git a/mod/wiki/ewiki/ewiki.php b/mod/wiki/ewiki/ewiki.php index 17c79c8edf..e06defcc89 100644 --- a/mod/wiki/ewiki/ewiki.php +++ b/mod/wiki/ewiki/ewiki.php @@ -83,8 +83,23 @@ define("EWIKI_AUTO_LOGIN", 1); # [auth_query] on startup #-- allowed WikiPageNameCharacters - define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377"); - define("EWIKI_CHARS_U", "A-Z0-9\300-\336"); + +#### BEGIN MOODLE CHANGES - to remove auto-camelcase linking. + global $moodle_disable_camel_case; + if ($moodle_disable_camel_case) { + define("EWIKI_CHARS_L", ""); + define("EWIKI_CHARS_U", ""); + } + else { +#### END MOODLE CHANGES + + define("EWIKI_CHARS_L", "a-z_µ¤$\337-\377"); + define("EWIKI_CHARS_U", "A-Z0-9\300-\336"); + +#### BEGIN MOODLE CHANGES + } +#### END MOODLE CHANGES + define("EWIKI_CHARS", EWIKI_CHARS_L.EWIKI_CHARS_U); #-- database @@ -195,18 +210,21 @@ "script_url" => (defined("EWIKI_SCRIPT_URL")?EWIKI_SCRIPT_URL:NULL), "script_binary" => EWIKI_SCRIPT_BINARY, #-- heart of the wiki -- don't try to read this! ;) + "wiki_pre_scan_regex" => '/ (? "\007 [!~]?( \#?\[[^<>\[\]\n]+\] | \^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} | \b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* | ([a-z]{2,9}://|mailto:)[^\s\[\]\'\"\)\,<]+ | \w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x", + #-- rendering ruleset "wm_indent" => '
', "wm_table_defaults" => 'cellpadding="2" border="1" cellspacing="0"', diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php index 9b37a12c24..079629bd58 100644 --- a/mod/wiki/lib.php +++ b/mod/wiki/lib.php @@ -25,6 +25,7 @@ function wiki_add_instance($wiki) { $wiki->pagename = wiki_page_name($wiki); /// Check 'check boxes'. The variables won't be set at all of they were deselected. + $wiki->disablecamelcase = (isset($wiki->disablecamelcase)) ? 1 : 0; $wiki->setpageflags = (isset($wiki->setpageflags)) ? 1 : 0; $wiki->removepages = (isset($wiki->removepages)) ? 1 : 0; $wiki->strippages = (isset($wiki->strippages)) ? 1 : 0; @@ -43,6 +44,7 @@ function wiki_update_instance($wiki) { $wiki->pagename = wiki_page_name($wiki); /// Check 'check boxes'. The variables won't be set at all of they were deselected. + $wiki->disablecamelcase = (isset($wiki->disablecamelcase)) ? 1 : 0; $wiki->setpageflags = (isset($wiki->setpageflags)) ? 1 : 0; $wiki->removepages = (isset($wiki->removepages)) ? 1 : 0; $wiki->strippages = (isset($wiki->strippages)) ? 1 : 0; diff --git a/mod/wiki/mod.html b/mod/wiki/mod.html index 406309aec1..21d925c405 100644 --- a/mod/wiki/mod.html +++ b/mod/wiki/mod.html @@ -125,6 +125,16 @@ + + + + : + + disablecamelcase?"CHECKED":""; ?> /> + Disable CamelCase linking.
+ + + diff --git a/mod/wiki/version.php b/mod/wiki/version.php index 9d446606a4..b46f4f9007 100644 --- a/mod/wiki/version.php +++ b/mod/wiki/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2004061300; // The current module version (Date: YYYYMMDDXX) +$module->version = 2004062400; // The current module version (Date: YYYYMMDDXX) $module->cron = 0; // Period for cron to check this module (secs) ?> diff --git a/mod/wiki/view.php b/mod/wiki/view.php index 09cd3debc7..ba95ea78a2 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -60,6 +60,9 @@ ### SAVE ID from Moodle $moodleID=@$_REQUEST["id"]; +/// Globally disable CamelCase, if the option is selected for this wiki. + $moodle_disable_camel_case = ($wiki->disablecamelcase == 1); + if (($wiki_entry = wiki_get_default_entry($wiki, $course, $userid, $groupid))) { /// ################# EWIKI Part ###########################