1.20.x block.admin.inc block_custom_block_translate_list($form, &$form_state, $delta)

Form constructor for the block translation list form.

Parameters

array $form: An associative array containing the structure of a portion of the form.

array $form_state: A keyed array containing the current state of the form.

$delta: Unique ID of the block within the context of $module.

Related topics

File

modules/block/block.admin.inc, line 300
Admin page callbacks for the Block module.

Code

function block_custom_block_translate_list($form, &$form_state, $delta) {
  $custom_block = block_custom_block_load($delta);

  $language_list = language_list();

  $header = array(
    t('Language'),
    t('Title'),
    t('Status'),
    t('Operations'),
  );

  $rows = array();

  foreach ($language_list as $langcode => $item) {
    $row = array();
    $links = array();

    // Check if this is the source language.
    if (isset($custom_block['default_langcode']) && ($langcode == $custom_block['default_langcode'])) {
      $row[] = t($item->name) . ' ' . t('(source)');
      $row[] = isset($custom_block['title']) ? check_plain($custom_block['title']) : t('N/A');
      $row[] = t('Source');
      $links['edit'] = array(
        'title' => t('EDIT'),
        'href' => 'admin/structure/block/manage/' . $delta . '/translate/' . $langcode,
      );
    }
    else {
      $row[] = t($item->name);
      $row[] = isset($custom_block['translations'][$langcode]['title']) ? check_plain($custom_block['translations'][$langcode]['title']) : t('N/A');
      $row[] = isset($custom_block['translations'][$langcode]) ? t('Translated') : t('Not Translated');
      $links['edit'] = array(
        'title' => isset($custom_block['translations'][$langcode]) ? t('EDIT') : t('ADD TRANSLATION'),
        'href' => 'admin/structure/block/manage/' . $delta . '/translate/' . $langcode,
      );
    }

    $operations = array(
      '#type' => 'operations',
      '#links' => $links,
    );
    $row[] = array('data' => $operations);
    $rows[] = $row;
  }

  if ($custom_block['info']) {
    backdrop_set_title(t("Translate '%name' block", array('%name' => $custom_block['info'])), PASS_THROUGH);
  }

  return array(
    '#theme' => 'table__block_admin_list',
    '#rows' => $rows,
    '#header' => $header,
    '#empty' => t('No languages found to translate to.'),
  );
}