summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Mateescu2012-05-18 10:45:03 (GMT)
committer Andrei Mateescu2012-05-18 10:45:03 (GMT)
commitee9b55e9c523db9262078538d617148850dd532a (patch)
tree8c2574732c2c5347acae12c60cffebf8745e70b4
parentf32017fd3a5c40776eb4b1cb217eb2ee6ce216b8 (diff)
Issue #1095278 by pillarsdotnet, sun, amateescu: Added support for a transliteration text format filter.
-rw-r--r--transliteration.module49
1 files changed, 49 insertions, 0 deletions
diff --git a/transliteration.module b/transliteration.module
index 7722f6d..5fc889c 100644
--- a/transliteration.module
+++ b/transliteration.module
@@ -180,3 +180,52 @@ function transliteration_search_preprocess($text) {
}
return $text;
}
+
+/**
+ * Implements hook_filter_info().
+ */
+function transliteration_filter_info() {
+ return array(
+ 'transliteration' => array(
+ 'title' => t('Convert all characters to US-ASCII'),
+ 'process callback' => '_transliteration_filter_process',
+ 'settings callback' => '_transliteration_filter_settings',
+ 'default settings' => array(
+ 'no_known_transliteration' => '?'
+ ),
+ 'tips callback' => '_transliteration_filter_tips',
+ ),
+ );
+}
+
+/**
+ * Process callback for the transliteration filter.
+ */
+function _transliteration_filter_process($text, $filter, $format, $langcode, $cache, $cache_id) {
+ return transliteration_get($text, $filter->settings['no_known_transliteration'], $langcode);
+}
+
+/**
+ * Settings callback for the transliteration filter.
+ */
+function _transliteration_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
+ $filter->settings += $defaults;
+
+ return array(
+ 'no_known_transliteration' => 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' => $filter->settings['no_known_transliteration'],
+ )
+ );
+}
+
+/**
+ * Filter tips callback for the transliteration filter.
+ */
+function _transliteration_filter_tips($filter, $format, $long) {
+ return t('Non-latin text (e.g., å, ö, 漢) will be converted to US-ASCII equivalents (a, o, ?).');
+}