Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a per-wiki option to allow disabling of automatic camel case li…

…nking.

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.
  • Loading branch information...
commit e8f993326c6a74cf81c6add91cc2c11cc9851285 1 parent 5388302
mchurch authored
2  lang/en/help/wiki/studentadminoptions.html
View
@@ -1,4 +1,4 @@
-<P ALIGN=CENTER><B>Allow Binary Files</B></P>
+<P ALIGN=CENTER><B>Student Administration Options</B></P>
<P>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
10 lang/en/help/wiki/wikilinkoptions.html
View
@@ -0,0 +1,10 @@
+<P ALIGN=CENTER><B>Wiki Auto-linking Options</B></P>
+
+<P>In certain situations, you may not want automatic linking based on CamelCase words.
+If this is so, check this box to disable CamelCase linking.
+</p>
+<p>
+<b>WARNING</b> -- CamelCase is a standard wiki feature, and disabling it may cause other
+imported wikis to work incorrectly. Use this feature <i>only</i> if you are absolutely certain
+you do not want CamelCase linking.
+</P>
1  lang/en/wiki.php
View
@@ -10,6 +10,7 @@
$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';
5 mod/wiki/db/mysql.php
View
@@ -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;
}
1  mod/wiki/db/mysql.sql
View
@@ -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',
22 mod/wiki/ewiki/ewiki.php
View
@@ -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" => '/
(?<![~!])
((?:(?:\w+:)*['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+){2,}[\w\d]*)
|\^([-'.EWIKI_CHARS_L.EWIKI_CHARS_U.']{3,})
|\[ (?:"[^\]\"]+" | \s+ | [^:\]#]+\|)* ([^\|\"\[\]\#]+) (?:\s+ | "[^\]\"]+")* [\]\#]
|(\w{3,9}:\/\/[^?#\s\[\]\'\"\)\,<]+) /x',
+
"wiki_link_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" => '<div style="margin-left:15px;" class="indent">',
"wm_table_defaults" => 'cellpadding="2" border="1" cellspacing="0"',
2  mod/wiki/lib.php
View
@@ -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;
10 mod/wiki/mod.html
View
@@ -127,6 +127,16 @@
<tr valign="top">
<td align="right">
+ <?php helpbutton('wikilinkoptions', get_string('wikilinkoptions', 'wiki'), 'wiki') ?>
+ <b> <?php print_string('wikilinkoptions', 'wiki') ?>:</b></td>
+ <td>
+ <input type="checkbox" name="disablecamelcase" value="1" <?php echo $form->disablecamelcase?"CHECKED":""; ?> />
+ Disable CamelCase linking.<br />
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">
<?php helpbutton('studentadminoptions', get_string('studentadminoptions', 'wiki'), 'wiki') ?>
<b> <?php print_string('studentadminoptions', 'wiki') ?>:</b></td>
<td>
2  mod/wiki/version.php
View
@@ -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)
?>
3  mod/wiki/view.php
View
@@ -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 ###########################
Please sign in to comment.
Something went wrong with that request. Please try again.