Révision 6331c987
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/i18n/i18n_node/i18n_node.module | ||
---|---|---|
54 | 54 |
$arg = drupal_help_arg(arg(NULL)); |
55 | 55 |
if ($arg[0] == 'node' && $arg[1] == 'add' && $arg[2]) { |
56 | 56 |
if (($type = node_type_get_type(str_replace('-', '_', $arg[2]))) && !empty($type->help)) { |
57 |
$help = i18n_node_translate_type($type, 'help'); |
|
57 |
$help = i18n_node_translate_type($type, 'help', NULL, array('sanitize' => FALSE));
|
|
58 | 58 |
if ($help !== $type->help) { |
59 | 59 |
$block['content'] = str_replace(filter_xss_admin($type->help), filter_xss_admin($help), $block['content']); |
60 | 60 |
} |
... | ... | |
64 | 64 |
$node = menu_get_object(); |
65 | 65 |
if ($node && isset($node->type)) { |
66 | 66 |
$type = node_type_get_type($node->type); |
67 |
$help = i18n_node_translate_type($type, 'help'); |
|
67 |
$help = i18n_node_translate_type($type, 'help', NULL, array('sanitize' => FALSE));
|
|
68 | 68 |
if ($help !== $type->help) { |
69 | 69 |
$block['content'] = str_replace(filter_xss_admin($type->help), filter_xss_admin($help), $block['content']); |
70 | 70 |
} |
... | ... | |
121 | 121 |
'href' => 'node/' . $node_translation->nid . $matches[2], |
122 | 122 |
'title' => $node_translation->title, |
123 | 123 |
'object' => $node_translation, |
124 |
// Performance: for node view add access information right away. |
|
125 |
'access' => !$matches[2] ? $node_translation->status : NULL, |
|
124 | 126 |
); |
125 | 127 |
} |
126 | 128 |
return $result; |
... | ... | |
347 | 349 |
static $sent = FALSE; |
348 | 350 |
|
349 | 351 |
// Ensure we send the Javascript only once. |
350 |
if (!$sent && isset($element['#autocomplete_path']) && !empty($element['#autocomplete_path']) && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE) {
|
|
352 |
if (!$sent && isset($element['#autocomplete_path']) && !empty($element['#autocomplete_path']) && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_DEFAULT) != LANGUAGE_NEGOTIATION_DEFAULT) {
|
|
351 | 353 |
// Add a JS file for node forms. |
352 | 354 |
// Determine if we are either editing or translating an existing node. |
353 | 355 |
// We can't act on regular node creation because we don't have a specified |
... | ... | |
442 | 444 |
* |
443 | 445 |
* @see http://drupal.org/node/765860 |
444 | 446 |
*/ |
445 |
|
|
447 |
|
|
446 | 448 |
// Replace core's node submit callback with our own, |
447 | 449 |
// in order to translate the node type name. |
448 | 450 |
$key = array_search('node_form_submit', $form['actions']['submit']['#submit']); |
... | ... | |
464 | 466 |
$insert = empty($node->nid); |
465 | 467 |
node_save($node); |
466 | 468 |
$node_link = l(t('view'), 'node/' . $node->nid); |
467 |
$type = node_type_get_type($node->type); |
|
468 |
$type_name = i18n_node_translate_type($type); |
|
469 |
$type_name = i18n_node_type_name($node->type); |
|
469 | 470 |
|
470 | 471 |
$watchdog_args = array('@type' => $node->type, '%title' => $node->title); |
471 | 472 |
$t_args = array('@type' => $type_name, '%title' => $node->title); |
... | ... | |
481 | 482 |
if ($node->nid) { |
482 | 483 |
$form_state['values']['nid'] = $node->nid; |
483 | 484 |
$form_state['nid'] = $node->nid; |
484 |
$form_state['redirect'] = 'node/' . $node->nid;
|
|
485 |
$form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->nid : '<front>';
|
|
485 | 486 |
} |
486 | 487 |
else { |
487 | 488 |
// In the unlikely case something went wrong on save, the node will be |
... | ... | |
516 | 517 |
$form['body_field']['body']['#title'] = i18n_node_translate_type($node->type, 'body', $form['body_field']['body']['#title']); |
517 | 518 |
} |
518 | 519 |
// Translate page title for node/add/% and node/%/edit pages. |
519 |
$types = node_type_get_types(); |
|
520 | 520 |
if (empty($node->nid) && strpos($_GET['q'], 'node/add/' . str_replace('_', '-', $node->type)) === 0) { |
521 |
drupal_set_title(t('Create @name', array('@name' => i18n_node_translate_type($types[$node->type], 'name'))), PASS_THROUGH);
|
|
521 |
drupal_set_title(t('Create @name', array('@name' => i18n_node_type_name($node->type))), PASS_THROUGH);
|
|
522 | 522 |
} |
523 | 523 |
elseif (!empty($node->nid) && $_GET['q'] == 'node/' . $node->nid . '/edit') { |
524 |
drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => i18n_node_translate_type($types[$node->type], 'name'), '@title' => $node->title)), PASS_THROUGH);
|
|
524 |
drupal_set_title(t('<em>Edit @type</em> @title', array('@type' => i18n_node_type_name($node->type), '@title' => $node->title)), PASS_THROUGH);
|
|
525 | 525 |
} |
526 | 526 |
return $form; |
527 | 527 |
} |
... | ... | |
553 | 553 |
} |
554 | 554 |
|
555 | 555 |
/** |
556 |
* Translate node type name (unfiltered) |
|
556 |
* Get translated node type name (unfiltered) |
|
557 |
* |
|
558 |
* @param string $type |
|
559 |
* Node type. |
|
560 |
* @param string $name |
|
561 |
* Optional node type name. |
|
557 | 562 |
*/ |
558 |
function i18n_node_type_name($type, $name) { |
|
559 |
return i18n_string_translate(array('node', 'type', $type, 'name'), $name); |
|
563 |
function i18n_node_type_name($type, $name = NULL) { |
|
564 |
$name = isset($name) ? $name : node_type_get_name($type); |
|
565 |
return i18n_string_translate(array('node', 'type', $type, 'name'), $name, array('sanitize' => FALSE)); |
|
560 | 566 |
} |
561 | 567 |
|
562 | 568 |
/** |
Formats disponibles : Unified diff
Weekly update of contrib modules