- Patch #344661 by Dave Reid: API doc improvements for hook_translation_link_alter.
parent
c0cb68abcc
commit
8ad5cba994
|
|
@ -24,6 +24,29 @@ function hook_locale($op = 'groups') {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform alterations on translation links.
|
||||
*
|
||||
* A translation link may need to point to a different path or use a translated
|
||||
* link text before going through l(), which will just handle the path aliases.
|
||||
*
|
||||
* @param $links
|
||||
* Nested array of links keyed by language code.
|
||||
* @param $path
|
||||
* The current path.
|
||||
* @return
|
||||
* None.
|
||||
*/
|
||||
function hook_translation_link_alter(array &$links, $path) {
|
||||
global $language;
|
||||
|
||||
if (isset($links[$language])) {
|
||||
foreach ($links[$language] as $link) {
|
||||
$link['attributes']['class'] .= ' active-language';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -597,9 +597,6 @@ function locale_block($op = 'list', $delta = '') {
|
|||
}
|
||||
|
||||
// Allow modules to provide translations for specific links.
|
||||
// A translation link may need to point to a different path or use
|
||||
// a translated link text before going through l(), which will just
|
||||
// handle the path aliases.
|
||||
drupal_alter('translation_link', $links, $path);
|
||||
|
||||
$block['subject'] = t('Languages');
|
||||
|
|
|
|||
|
|
@ -397,21 +397,22 @@ function hook_link($type, $object, $teaser = FALSE) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Perform alterations before links on a node are rendered. One popular use of
|
||||
* this hook is to add/delete links from other modules.
|
||||
* Perform alterations before links on a node are rendered.
|
||||
*
|
||||
* One popular use of this hook is to add/delete links from other modules.
|
||||
*
|
||||
* @param $links
|
||||
* Nested array of links for the node
|
||||
* Nested array of links for the node keyed by providing module.
|
||||
* @param $node
|
||||
* A node object for editing links on
|
||||
* A node object that contains the links.
|
||||
* @return
|
||||
* None.
|
||||
*/
|
||||
function hook_link_alter(&$links, $node) {
|
||||
foreach ($links AS $module => $link) {
|
||||
function hook_link_alter(array &$links, $node) {
|
||||
foreach ($links as $module => $link) {
|
||||
if (strstr($module, 'taxonomy_term')) {
|
||||
// Link back to the forum and not the taxonomy term page
|
||||
$links[$module]['#href'] = str_replace('taxonomy/term', 'forum', $link['#href']);
|
||||
$links[$module]['href'] = str_replace('taxonomy/term', 'forum', $link['href']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,11 +335,11 @@ function translation_path_get_translations($path) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_alter_translation_link().
|
||||
* Implementation of hook_translation_link_alter().
|
||||
*
|
||||
* Replaces links with pointers to translated versions of the content.
|
||||
*/
|
||||
function translation_translation_link_alter(&$links, $path) {
|
||||
function translation_translation_link_alter(array &$links, $path) {
|
||||
if ($paths = translation_path_get_translations($path)) {
|
||||
foreach ($links as $langcode => $link) {
|
||||
if (isset($paths[$langcode])) {
|
||||
|
|
@ -353,4 +353,3 @@ function translation_translation_link_alter(&$links, $path) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue