You are here

function i18nblocks_save in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18nblocks/i18nblocks.module \i18nblocks_save()
  2. 5 i18nblocks/i18nblocks.module \i18nblocks_save()
  3. 5.2 i18nblocks/i18nblocks.module \i18nblocks_save()

Set block language data.

Parameters

array $block: Array of block parameters: module, delata, ibid (internal i18nblocks delta).

2 calls to i18nblocks_save()
i18nblocks_form_submit in i18nblocks/i18nblocks.module
Forms api callback. Submit function.
i18nblocks_update_1 in i18nblocks/i18nblocks.install
Update: move old variable to new tables.

File

i18nblocks/i18nblocks.module, line 189
Internationalization (i18n) submodule: Multilingual meta-blocks

Code

function i18nblocks_save($block) {
  if (!empty($block['language'])) {
    if ($block['language'] == I18N_BLOCK_LOCALIZE) {
      $block['language'] = '';
    }

    // Update strings for localizable blocks.
    if ($block['ibid']) {
      drupal_write_record('i18n_blocks', $block, 'ibid');
    }
    else {
      drupal_write_record('i18n_blocks', $block);
    }
  }
  else {

    // No language, delete all i18n information.
    db_query("DELETE FROM {i18n_blocks} WHERE module = '%s' AND delta = '%s'", $block['module'], $block['delta']);
  }

  // If localize block or block without language
  if (!$block['language']) {

    // We use ibid property instead of block's delta as block id for strings
    $module = $block['module'];
    $delta = $block['delta'];
    if (!empty($block['title']) && $block['title'] != '<none>') {
      i18nstrings_update("blocks:{$module}:{$delta}:title", $block['title']);
    }
    if (isset($block['body'])) {
      i18nstrings_update("blocks:{$module}:{$delta}:body", $block['body'], $block['format']);
    }
  }
}