diff --git a/handlers/views_handler_field.inc b/handlers/views_handler_field.inc index 65210d9..1f1df12 100644 --- a/handlers/views_handler_field.inc +++ b/handlers/views_handler_field.inc @@ -315,6 +315,12 @@ class views_handler_field extends views_handler { // the first row. if (isset($row_index) && isset($this->view->style_plugin->render_tokens[$row_index])) { $tokens = $this->view->style_plugin->render_tokens[$row_index]; + + // Make sure at least one module implements our hook. + if (sizeof(module_implements('views_field_token_alter')) > 0) { + // Call modules that implement the hook, and let them change $variables. + $tokens = module_invoke_all('views_field_token_alter', $tokens); + } } else { // Get tokens from the last field. @@ -796,6 +802,13 @@ class views_handler_field extends views_handler { break; } } + + // Make sure at least one module implements our hook. + if (sizeof(module_implements('views_field_token_alter_info')) > 0) { + // Call modules that implement the hook, and let them change $variables. + $options[t('Fields')] = module_invoke_all('views_field_token_alter_info', $options[t('Fields')]); + } + $count = 0; // This lets us prepare the key as we want it printed. foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); @@ -1422,6 +1435,12 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $this->view->style_plugin->render_tokens[$this->view->row_index] = $tokens; $this->last_tokens = $tokens; + // Make sure at least one module implements our hook. + if (sizeof(module_implements('views_field_token_alter')) > 0) { + // Call modules that implement the hook, and let them change $variables. + $tokens = module_invoke_all('views_field_token_alter', $tokens); + } + return $tokens; } diff --git a/views.module b/views.module index fc427f4..ec3b0d6 100644 --- a/views.module +++ b/views.module @@ -2532,3 +2532,36 @@ if (!function_exists('user_views_api')) { if (!function_exists('contact_views_api')) { function contact_views_api() { return views_views_api(); } } + +/** + * Implementation of hook_views_field_token_alter_info(). + */ +function views_views_field_token_alter_info($options) { + if (module_exists('transliteration')) { + $newoptions = array(); + foreach ($options as $token => $name) { + if($token[0] == '[' && $token[strlen($token) - 1] == ']') { + $newtoken = '[' . substr($token, 1, -1) . '-transliterated]'; + $newoptions[$token] = $name; + $newoptions[$newtoken] = $name . ' (' . t('transliterated') . ')'; + } + } + } + return $newoptions; +} + +/** + * Implementation of hook_views_field_token_alter(). + */ +function views_views_field_token_alter($tokens) { + if (module_exists('transliteration')) { + foreach ($tokens as $token => $value) { + if($token[0] == '[' && $token[strlen($token) - 1] == ']') { + $newtoken = '[' . substr($token, 1, -1) . '-transliterated]'; + $tokens[$newtoken] = transliteration_get(drupal_html_class(views_clean_css_identifier($value)));; + } + } + } + + return $tokens; +}