function i18n_book_navigation_token_values in Book translation 6.2
Same name and namespace in other branches
- 6 i18n_book_navigation.module \i18n_book_navigation_token_values()
Implementation of hook_token_values()
Port of book_token_values() from the token module. Will translate all the tokens.
See also
File
- ./
i18n_book_navigation.module, line 677 - Defines the i18n book navigation module. Contains all necessary data and hooks
Code
function i18n_book_navigation_token_values($type, $object = NULL, $options = array()) {
$tokens = array();
if ($type == 'node') {
$tokens['i18n-bookpath'] = '';
$tokens['i18n-bookpath-raw'] = '';
// Get the translation
$node = i18n_book_navigation_get_original_node($object);
if (!empty($node->book['menu_name'])) {
// Set the i18n node selection mode in the correct language
i18n_selection_mode('node', $node->language);
$trail_raw = i18n_book_navigation_menu_titles($node->book, $node->nid, $object->language);
// Revert the i18n node selection mode
i18n_selection_mode('node', i18n_get_lang());
$book_raw = $trail_raw[0];
$book = check_plain($book_raw);
// For book paths, we don't include the current node's title in the trail
array_pop($trail_raw);
$trail = array();
foreach ($trail_raw as $title) {
$trail[] = check_plain($title);
}
$tokens['i18n-book'] = $book;
$tokens['i18n-book-raw'] = $book_raw;
$tokens['i18n-bookpath'] = !empty($options['pathauto']) ? $trail : implode('/', $trail);
$tokens['i18n-bookpath-raw'] = !empty($options['pathauto']) ? $trail_raw : implode('/', $trail_raw);
}
}
return $tokens;
}