diff -Naur moodle-base/admin/settings/plugins.php moodle-export/admin/settings/plugins.php
--- moodle-base/admin/settings/plugins.php 2009-05-28 16:40:39.000000000 -0700
+++ moodle-export/admin/settings/plugins.php 2009-06-03 09:10:49.000000000 -0700
@@ -99,6 +99,9 @@
'2' => get_string('htmlfilesonly')));
$items[] = new admin_setting_configcheckbox('filtermatchoneperpage', get_string('filtermatchoneperpage', 'admin'), get_string('configfiltermatchoneperpage', 'admin'), 0);
$items[] = new admin_setting_configcheckbox('filtermatchonepertext', get_string('filtermatchonepertext', 'admin'), get_string('configfiltermatchonepertext', 'admin'), 0);
+ // MOD -- Adding config settings for wiki-style autolinking
+ $items[] = new admin_setting_configcheckbox('filterdelimiterautolinking', get_string('filterdelimiterautolinking', 'admin'), get_string('configfilterdelimiterautolinking', 'admin'), 0);
+ // End MOD
$items[] = new admin_setting_configcheckbox('filterall', get_string('filterall', 'admin'), get_string('configfilterall', 'admin'), 0);
foreach ($items as $item) {
$item->set_updatedcallback('reset_text_filters_cache');
diff -Naur moodle-base/lang/en_utf8/admin.php moodle-export/lang/en_utf8/admin.php
--- moodle-base/lang/en_utf8/admin.php 2009-05-28 16:40:39.000000000 -0700
+++ moodle-export/lang/en_utf8/admin.php 2009-06-03 09:10:49.000000000 -0700
@@ -128,6 +128,9 @@
$string['configfilterall'] = 'Filter all strings, including headings, titles, navigation bar and so on. This is mostly useful when using the multilang filter, otherwise it will just create extra load on your site for little gain.';
$string['configfiltermatchoneperpage'] = 'Automatic linking filters will only generate a single link for the first matching text instance found on the complete page. All others are ignored.';
$string['configfiltermatchonepertext'] = 'Automatic linking filters will only generate a single link for the first matching text instance found in each item of text (e.g., resource, block) on the page. All others are ignored. This setting is ignored if the one per page setting is yes.';
+// MOD -- Added feature to have wiki-style autolinking
+$string['configfilterdelimiterautolinking'] = 'Automatic linking filters will only generate links when the matching text is surrounded by double square brackets. E.g., the text Announcements will only link to the Announcements forum when it’s typed as [[Announcements]].';
+// End MOD
$string['configfilteruploadedfiles'] = 'Process all uploaded HTML and text files with the filters before displaying them, only uploaded HTML files or none at all.';
$string['configforcelogin'] = 'Normally, the front page of the site and the course listings (but not courses) can be read by people without logging in to the site. If you want to force people to log in before they do ANYTHING on the site, then you should enable this setting.';
$string['configforceloginforprofiles'] = 'This setting forces people to login as a real (non-guest) account before viewing any user\'s profile. If you disabled this setting, you may find that some users post advertising (spam) or other inappropriate content in their profiles, which is then visible to the whole world.';
@@ -385,6 +388,9 @@
$string['filterall'] = 'Filter all strings';
$string['filtermatchoneperpage'] = 'Filter match once per page';
$string['filtermatchonepertext'] = 'Filter match once per text';
+// MOD -- Added feature for wiki-style autolinking
+$string['filterdelimiterautolinking'] = 'Links require delimiters';
+// End MOD
$string['filtersettings'] = 'Manage filters';
$string['filtersettingsgeneral'] = 'General filter settings';
$string['filteruploadedfiles'] = 'Filter uploaded files';
diff -Naur moodle-base/lib/filterlib.php moodle-export/lib/filterlib.php
--- moodle-base/lib/filterlib.php 2009-05-28 16:40:39.000000000 -0700
+++ moodle-export/lib/filterlib.php 2009-06-03 09:10:49.000000000 -0700
@@ -26,6 +26,12 @@
var $work_fullmatch;
var $work_replacementphrase;
var $work_calculated;
+ // MOD -- Add feature to allow wiki-styl autolinking
+ var $prefixdelimiter;
+ var $suffixdelimiter;
+ var $work_prefixdelimiter;
+ var $work_suffixdelimiter;
+ // End MOD
/// a constructor just because I like constructing
function filterobject($phrase, $hreftagbegin='',
@@ -41,7 +47,16 @@
$this->fullmatch = $fullmatch;
$this->replacementphrase= $replacementphrase;
$this->work_calculated = false;
-
+
+ global $CFG;
+
+ if(!empty($CFG->filterdelimiterautolinking)) {
+ $this->prefixdelimiter = '[[';
+ $this->suffixdelimiter = ']]';
+ } else {
+ $this->prefixdelimiter = '';
+ $this->suffixdelimiter = '';
+ }
}
}
@@ -156,6 +171,10 @@
/// Quote any regular expression characters and the delimiter in the work phrase to be searched
$linkobject->work_phrase = preg_quote($linkobject->work_phrase, '/');
+ // MOD -- Add feature for wiki-style autolinking
+ $linkobject->work_prefixdelimiter = preg_quote($linkobject->prefixdelimiter, '/');
+ $linkobject->work_suffixdelimiter = preg_quote($linkobject->suffixdelimiter, '/');
+ // End MOD
/// Work calculated
$linkobject->work_calculated = true;
@@ -176,7 +195,10 @@
/// If yes then go through and remove any non full matching entries
if ($linkobject->work_fullmatch) {
$notfullmatches = array();
- $regexp = '/'.$filterinvalidprefixes.'('.$linkobject->work_phrase.')|('.$linkobject->work_phrase.')'.$filterinvalidsuffixes.'/'.$modifiers;
+ // MOD -- Add feature for wiki-style autolinking
+ /*$regexp = '/'.$filterinvalidprefixes.'('.$linkobject->work_phrase.')|('.$linkobject->work_phrase.')'.$filterinvalidsuffixes.'/'.$modifiers;*/
+ $regexp = '/'.$filterinvalidprefixes.$linkobject->work_prefixdelimiter.'('.$linkobject->work_phrase.')'.$linkobject->work_suffixdelimiter.'|'.$linkobject->work_prefixdelimiter.'('.$linkobject->work_phrase.')'.$linkobject->work_prefixdelimiter.$filterinvalidsuffixes.'/'.$modifiers;
+ // End MOD
preg_match_all($regexp,$text,$list_of_notfullmatches);
@@ -192,12 +214,18 @@
/// Finally we do our highlighting
if (!empty($CFG->filtermatchonepertext) || !empty($CFG->filtermatchoneperpage)) {
- $resulttext = preg_replace('/('.$linkobject->work_phrase.')/'.$modifiers,
+ // MOD -- Added feature for wiki-style autolinking
+ //$resulttext = preg_replace('/('.$linkobject->work_phrase.')/'.$modifiers,
+ $resulttext = preg_replace('/'.$linkobject->work_prefixdelimiter.'('.$linkobject->work_phrase.')'.$linkobject->work_suffixdelimiter.'/'.$modifiers,
+ // End MOD
$linkobject->work_hreftagbegin.
$linkobject->work_replacementphrase.
$linkobject->work_hreftagend, $text, 1);
} else {
- $resulttext = preg_replace('/('.$linkobject->work_phrase.')/'.$modifiers,
+ // MOD -- Added feature for wiki-style autolinking
+ //$resulttext = preg_replace('/('.$linkobject->work_phrase.')/'.$modifiers,
+ $resulttext = preg_replace('/'.$linkobject->work_prefixdelimiter.'('.$linkobject->work_phrase.')'.$linkobject->work_suffixdelimiter.'/'.$modifiers,
+ // End MOD
$linkobject->work_hreftagbegin.
$linkobject->work_replacementphrase.
$linkobject->work_hreftagend, $text);