security update core+modules
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* Produces a menu translation form.
|
||||
*/
|
||||
function i18n_menu_translation_form($form, $form_state, $translation_set = NULL, $item = NULL) {
|
||||
$translation_set = $translation_set ? $translation_set : i18n_translation_set_create('menu_link');
|
||||
$translation_set = $translation_set ? $translation_set : i18n_translation_set_build('menu_link');
|
||||
$form['translation_set'] = array('#type' => 'value', '#value' => $translation_set);
|
||||
$translations = $translation_set->get_translations();
|
||||
// What to do with title? Let's make it a hidden field for now, some tests relay on it
|
||||
@@ -55,7 +55,7 @@ function i18n_menu_translation_form($form, $form_state, $translation_set = NULL,
|
||||
}
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['update'] = array('#type' => 'submit', '#value' => t('Save'));
|
||||
if ($translation_set) {
|
||||
if (!empty($translation_set->tsid)) {
|
||||
$form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
|
||||
}
|
||||
return $form;
|
||||
@@ -244,12 +244,16 @@ function i18n_menu_translation_item_overview($item, $translation_set = NULL) {
|
||||
$title = t('n/a');
|
||||
$options[] = l(t('add translation'), 'admin/structure/menu/manage/' . $item['menu_name'] . '/add', array('query' => array('translation' => $item['mlid'], 'target' => $langcode) + drupal_get_destination()));
|
||||
}
|
||||
$rows[] = array($language_name, $title, implode(" | ", $options));
|
||||
$rows[$langcode] = array(
|
||||
'language' => $language_name,
|
||||
'title' => $title,
|
||||
'operations' => implode(" | ", $options)
|
||||
);
|
||||
}
|
||||
|
||||
drupal_set_title(t('Translations of menu item %title', array('%title' => $item['link_title'])), PASS_THROUGH);
|
||||
|
||||
$build['translation_item_overview'] = array(
|
||||
$build['translation_overview'] = array(
|
||||
'#theme' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
|
@@ -123,8 +123,8 @@ function i18n_menu_item_translation_page($type, $item) {
|
||||
module_load_include('admin.inc', 'i18n_menu');
|
||||
// If the item has a language code, we can only support translation sets.
|
||||
$translation_set = !empty($item['i18n_tsid']) ? i18n_translation_set_load($item['i18n_tsid']) : NULL;
|
||||
$build['overview'] = i18n_menu_translation_item_overview($item, $translation_set);
|
||||
$build['translation_form'] = drupal_get_form('i18n_menu_translation_form', $translation_set, $item);
|
||||
return $build;
|
||||
$overview = i18n_menu_translation_item_overview($item, $translation_set);
|
||||
$translation_form = drupal_get_form('i18n_menu_translation_form', $translation_set, $item);
|
||||
return $overview + $translation_form;
|
||||
}
|
||||
|
||||
|
@@ -69,6 +69,7 @@ class i18n_menu_link extends i18n_string_object_wrapper {
|
||||
return I18N_MODE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to object translation. This should check object properties and permissions
|
||||
*/
|
||||
|
@@ -10,9 +10,9 @@ core = 7.x
|
||||
files[] = i18n_menu.inc
|
||||
files[] = i18n_menu.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-01-13
|
||||
version = "7.x-1.8"
|
||||
; Information added by Drupal.org packaging script on 2015-01-26
|
||||
version = "7.x-1.12"
|
||||
core = "7.x"
|
||||
project = "i18n"
|
||||
datestamp = "1358075001"
|
||||
datestamp = "1422286982"
|
||||
|
||||
|
@@ -343,6 +343,8 @@ function i18n_menu_variable_info_alter(&$variables, $options) {
|
||||
// Make menu variables translatable
|
||||
$variables['menu_main_links_source']['localize'] = TRUE;
|
||||
$variables['menu_secondary_links_source']['localize'] = TRUE;
|
||||
$variables['menu_parent_[node_type]']['localize'] = TRUE;
|
||||
$variables['menu_options_[node_type]']['localize'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -468,7 +470,8 @@ function i18n_menu_navigation_links($menu_name, $level = 0) {
|
||||
* Get localized menu title
|
||||
*/
|
||||
function _i18n_menu_link_title($link, $langcode = NULL) {
|
||||
return i18n_string_translate(array('menu', 'item', $link['mlid'], 'title'), $link['link_title'], array('langcode' => $langcode, 'sanitize' => FALSE));
|
||||
$key = i18n_object_info('menu_link', 'key');
|
||||
return i18n_string_translate(array('menu', 'item', $link[$key], 'title'), $link['link_title'], array('langcode' => $langcode, 'sanitize' => FALSE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -500,7 +503,8 @@ function _i18n_menu_link_localize(&$link, $langcode = NULL) {
|
||||
*/
|
||||
function _i18n_menu_link_description($link, $langcode = NULL) {
|
||||
if (!empty($link['options']['attributes']['title'])) {
|
||||
return i18n_string_translate(array('menu', 'item', $link['mlid'], 'description'), $link['options']['attributes']['title'], array('langcode' => $langcode));
|
||||
$key = i18n_object_info('menu_link', 'key');
|
||||
return i18n_string_translate(array('menu', 'item', $link[$key], 'description'), $link['options']['attributes']['title'], array('langcode' => $langcode));
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
@@ -525,6 +529,10 @@ function _i18n_menu_link_process(&$link) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// Skip if administering this menu item through the node edit form.
|
||||
elseif (arg(0) == 'node' && arg(2) == 'edit' && $link['link_path'] == arg(0) . '/' . arg(1)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
@@ -709,6 +717,26 @@ function i18n_menu_form_menu_edit_item_alter(&$form, &$form_state) {
|
||||
array_unshift($form['#validate'], 'i18n_menu_menu_item_prepare_normal_path');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
* FORM_ID = menu-overview-form.
|
||||
* Add a "translate" link in operations column for each menu item.
|
||||
*/
|
||||
function i18n_menu_form_menu_overview_form_alter(&$form, &$form_state) {
|
||||
foreach (element_children($form) as $element) {
|
||||
if (substr($element, 0, 5) == 'mlid:') {
|
||||
$mlid = $form[$element]['#item']['mlid'];
|
||||
if (i18n_get_object('menu', $mlid)->get_translate_access()) {
|
||||
$form[$element]['operations']['translate'] = array(
|
||||
'#type' => 'link',
|
||||
'#title' => t('translate'),
|
||||
'#href' => "admin/structure/menu/item/{$mlid}/translate",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normal path should be checked with menu item's language to avoid
|
||||
* troubles when a node and it's translation has the same url alias.
|
||||
@@ -727,6 +755,9 @@ function i18n_menu_item_get_language($item) {
|
||||
}
|
||||
else {
|
||||
$menu = menu_load($item['menu_name']);
|
||||
if (!isset($menu['i18n_mode'])) {
|
||||
return LANGUAGE_NONE;
|
||||
}
|
||||
switch ($menu['i18n_mode']) {
|
||||
case I18N_MODE_LANGUAGE:
|
||||
return $menu['language'];
|
||||
@@ -858,6 +889,14 @@ function i18n_menu_link_load($path, $langcode) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_query_TAG_alter() for features_menu_links.
|
||||
* Add needed fields to properly serialize localization information.
|
||||
*/
|
||||
function i18n_menu_query_features_menu_link_alter($query) {
|
||||
$query->fields('menu_links', array('language', 'customized'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_init().
|
||||
*/
|
||||
|
@@ -130,6 +130,8 @@ class i18nMenuTestCase extends Drupali18nTestCase {
|
||||
$this->drupalGet('admin/structure/menu/item/' . $node->menu['mlid'] . '/edit');
|
||||
$this->assertText(t('This menu item belongs to a node, so it will have the same language as the node and cannot be localized.'));
|
||||
$this->assertNoField('language', 'We cannot edit language for menu items that belong to nodes.');
|
||||
// Edit the node and submit it to see if the menu link stays enabled.
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', array(), t('Save'));
|
||||
}
|
||||
// Check menu items show up for the right language.
|
||||
$this->drupalGet('<front>');
|
||||
|
Reference in New Issue
Block a user