summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Mateescu2012-05-18 12:16:36 (GMT)
committer Andrei Mateescu2012-05-18 12:16:36 (GMT)
commit6a53653bcf6129090666f1fa379a6829b343033c (patch)
tree0cd1280c8357e8d9478107b716923f1c3981d4d4
parent4307b0bde5d2fa8f0a81960344dc31a6855221a8 (diff)
Issue #1095278 by pillarsdotnet, sun, amateescu: Added support for a transliteration text format filter.
-rw-r--r--transliteration.install6
-rw-r--r--transliteration.module43
2 files changed, 48 insertions, 1 deletions
diff --git a/transliteration.install b/transliteration.install
index b7bc19d..27538e9 100644
--- a/transliteration.install
+++ b/transliteration.install
@@ -30,5 +30,9 @@ function transliteration_uninstall() {
variable_del('transliteration_file_uploads');
variable_del('transliteration_file_lowercase');
variable_del('transliteration_search');
-}
+ // Delete all the transliteration_filter_no_known_transliteration_* variables
+ // and then clear the variable cache.
+ db_query("DELETE FROM {variable} WHERE name LIKE 'transliteration_filter_no_known_transliteration_%'");
+ cache_clear_all('variables', 'cache');
+}
diff --git a/transliteration.module b/transliteration.module
index 1474110..bb1b7ac 100644
--- a/transliteration.module
+++ b/transliteration.module
@@ -183,3 +183,46 @@ function transliteration_search_preprocess($text) {
}
return $text;
}
+
+/**
+ * Implements hook_filter().
+ */
+function transliteration_filter($op, $delta = 0, $format = -1, $text = '', $cache_id = 0) {
+ switch ($op) {
+ case 'list':
+ return array(t('Convert all characters to US-ASCII'));
+ case 'no cache':
+ return FALSE;
+ case 'process':
+ return transliteration_get(
+ $text,
+ variable_get("transliteration_filter_no_known_transliteration_$format", '?')
+ );
+ case 'settings':
+ return array(
+ 'filter_transliteration' => array(
+ '#type' => 'fieldset',
+ '#title' => 'Transliteration',
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ "transliteration_filter_no_known_transliteration_$format" => array(
+ '#type' => 'textfield',
+ '#title' => t('Placeholder for characters with no known US-ASCII equivalent'),
+ '#size' => 2,
+ // The maximum length is 5 in order to accommodate unicode multibyte input.
+ '#maxlength' => 5,
+ '#default_value' => variable_get("transliteration_filter_no_known_transliteration_$format", '?'),
+ ),
+ ),
+ );
+ default:
+ return $text;
+ }
+}
+
+/**
+ * Implements hook_filter_tips().
+ */
+function transliteration_filter_tips($delta, $format, $long) {
+ return t('Non-latin text (e.g., å, ö, 漢) will be converted to US-ASCII equivalents (a, o, ?).');
+}