You are here

function i18n_menu_node_get_translations in Menu translation - Node 7

Return an array of node translation nids keyed by language.

2 calls to i18n_menu_node_get_translations()
i18n_menu_node_item_translations_refresh_set in ./i18n_menu_node.module
Refresh the translation cache for any menu item belonging to the translation sets identified by the given tnid.
i18n_menu_node_menu_link_alter in ./i18n_menu_node.module
Implementation of hook_menu_link_alter().

File

./i18n_menu_node.module, line 784
Menu translation (Node).

Code

function i18n_menu_node_get_translations($tnid, $field = 'nid') {
  static $translations = array();
  if (!isset($translations[$tnid])) {
    $translations[$tnid] = array();
    if ($tnid) {
      $result = db_query("SELECT n.language, n.nid, n.status, n.type FROM {node} n WHERE n.tnid = :tnid", array(
        ':tnid' => $tnid,
      ));
      foreach ($result as $row) {
        $translations[$tnid][$row->language] = $row;
      }
    }
  }
  if (!$field) {
    return $translations[$tnid];
  }
  else {
    $result = array();
    foreach ($translations[$tnid] as $langcode => $node) {
      $result[$langcode] = $node->{$field};
    }
    return $result;
  }
}