Révision 6331c987
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/i18n/i18n.module | ||
---|---|---|
498 | 498 |
* |
499 | 499 |
* @param $path |
500 | 500 |
* Path to get translations for or '<front>' for front page. |
501 |
* @param $check_access |
|
502 |
* Whether to check access to paths, defaults to TRUE |
|
501 | 503 |
*/ |
502 |
function i18n_get_path_translations($path) { |
|
504 |
function i18n_get_path_translations($path, $check_access = TRUE) {
|
|
503 | 505 |
$translations = &drupal_static(__FUNCTION__); |
506 |
|
|
504 | 507 |
if (!isset($translations[$path])) { |
505 | 508 |
$translations[$path] = array(); |
506 | 509 |
foreach (module_implements('i18n_translate_path') as $module) { |
... | ... | |
510 | 513 |
$translations[$path] += $translated; |
511 | 514 |
} |
512 | 515 |
} |
516 |
// Add access information if not there. |
|
517 |
foreach ($translations[$path] as $langcode => &$info) { |
|
518 |
if (!isset($info['access'])) { |
|
519 |
$item = menu_get_item($info['href']); |
|
520 |
// If no menu item, it may be an external URL, we allow access. |
|
521 |
$info['access'] = $item ? !empty($item['access']) : TRUE; |
|
522 |
} |
|
523 |
} |
|
513 | 524 |
// Chance for altering the results. |
514 | 525 |
drupal_alter('i18n_translate_path', $translations[$path], $path); |
515 | 526 |
} |
516 |
return $translations[$path]; |
|
527 |
|
|
528 |
if ($check_access) { |
|
529 |
return array_filter($translations[$path], '_i18n_get_path_translations_access'); |
|
530 |
} |
|
531 |
else { |
|
532 |
return $translations[$path]; |
|
533 |
} |
|
534 |
} |
|
535 |
|
|
536 |
/** |
|
537 |
* Helper function to check access to path translation. |
|
538 |
*/ |
|
539 |
function _i18n_get_path_translations_access($path) { |
|
540 |
return $path['access']; |
|
517 | 541 |
} |
518 | 542 |
|
519 | 543 |
/** |
Formats disponibles : Unified diff
Weekly update of contrib modules