You are here

function i18n_node_block_view_system_help_alter in Internationalization 7

Implements hook_block_view_MODULE_DELTA_alter().

Set translated help text for node/add pages, replace node_help() text.

File

i18n_node/i18n_node.module, line 53
Internationalization (i18n) module - Node type handling

Code

function i18n_node_block_view_system_help_alter(&$block) {
  $arg = drupal_help_arg(arg(NULL));
  if ($arg[0] == 'node' && $arg[1] == 'add' && $arg[2]) {
    if (($type = node_type_get_type(str_replace('-', '_', $arg[2]))) && !empty($type->help)) {
      $help = i18n_node_translate_type($type, 'help', NULL, array(
        'sanitize' => FALSE,
      ));
      if ($help !== $type->help) {
        $block['content'] = str_replace(filter_xss_admin($type->help), filter_xss_admin($help), $block['content']);
      }
    }
  }
  elseif ($arg[0] == 'node' && $arg[2] == 'edit') {
    $node = menu_get_object();
    if ($node && isset($node->type)) {
      $type = node_type_get_type($node->type);
      $help = i18n_node_translate_type($type, 'help', NULL, array(
        'sanitize' => FALSE,
      ));
      if ($help !== $type->help) {
        $block['content'] = str_replace(filter_xss_admin($type->help), filter_xss_admin($help), $block['content']);
      }
    }
  }
}