You are here

function lingotek_publish_form in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.7 lingotek.page.inc \lingotek_publish_form()
  2. 7.3 lingotek.page.inc \lingotek_publish_form()
  3. 7.4 lingotek.page.inc \lingotek_publish_form()
  4. 7.5 lingotek.page.inc \lingotek_publish_form()
  5. 7.6 lingotek.page.inc \lingotek_publish_form()

Form constructor for the Lingotek Publish form (functionality dependent on entity_translation module installed and enabled).

1 string reference to 'lingotek_publish_form'
lingotek_pm in ./lingotek.page.inc
Page callback for the Lingotek local task on node detail pages.

File

./lingotek.page.inc, line 57
Lingotek Tab for Nodes

Code

function lingotek_publish_form($form, $form_state, $node) {
  $form = array();
  if (module_exists('entity_translation')) {
    $handler = entity_translation_get_handler('node', $node);
    $languages = entity_translation_languages();
    $translations = $handler
      ->getTranslations();
    $form['publish'] = array(
      '#type' => 'fieldset',
      '#title' => t('Publish'),
      '#description' => t("Manage content visibility to your site's visitors for the selected languages."),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $options = array();
    $path = $handler
      ->getViewPath();
    if ($path) {
      $links = EntityTranslationDefaultHandler::languageSwitchLinks($path);
    }
    foreach ($languages as $language) {
      $language_name = $language->name;
      $langcode = $language->language;
      $is_original = $langcode == $node->language;
      $translation = isset($translations->data[$langcode]) ? $translations->data[$langcode] : array();
      $translation_status = isset($translation['status']) ? $translation['status'] : 1;

      // default to published
      $link_label = lingotek_language_native($langcode);
      $language_link = isset($links->links[$langcode]['href']) ? $links->links[$langcode] : array(
        'href' => $path,
        'language' => $language,
      );
      $subtext = $is_original ? '<i title="' . $langcode . '">source</i>' : '<span title="' . $langcode . '">' . lingotek_language_name($langcode) . '</span>';

      //$language_name;
      $row = array(
        l($link_label, $language_link['href'], $language_link) . ' (' . $subtext . ')',
        $translation_status ? t('Published') : t('Unpublished'),
      );
      $options[$langcode] = $row;
    }
    $form['publish']['languages'] = array(
      '#type' => 'tableselect',
      '#header' => array(
        t('Language'),
        t('Status'),
      ),
      '#options' => $options,
    );
    $form['publish']['submit_publish'] = array(
      '#type' => 'submit',
      '#id' => 'publish',
      '#value' => t('Publish'),
    );
    $form['publish']['submit_unpublish'] = array(
      '#type' => 'submit',
      '#id' => 'unpublish',
      '#value' => t('Unpublish'),
    );
    $form['node_id'] = array(
      '#type' => 'hidden',
      '#value' => $node->nid,
    );
  }
  return $form;
}