You are here

function lingotek_pm in Lingotek Translation 7.4

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

Page callback for the Lingotek local task on node detail pages.

Construct the table summarizing information a Product Manager would want to know about the progress of the translations.

Return value

array A Drupal render array of the page contents.

1 string reference to 'lingotek_pm'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

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

Code

function lingotek_pm($node) {

  // Display all of the appropriate node management sections (e.g., Upload, Download, Publish)
  $output = array(
    '#attached' => array(
      'css' => array(
        '//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css' => array(
          'type' => 'external',
        ),
      ),
    ),
  );
  $sync_status = $node->lingotek['node_sync_status'];

  // node translation support
  if ($node->tnid != 0 && $node->tnid != $node->nid) {
    $output[] = array(
      '#markup' => t('This is a translated node. Go to the @link to manage the translations.', array(
        '@link' => l('source node', 'node/' . $node->tnid . '/lingotek_pm'),
      )),
    );
    return $output;
  }

  // node disabled support
  if ($sync_status == LingotekSync::STATUS_DISABLED) {
    $output[] = array(
      '#markup' => 'Lingotek Translation is currently disabled for this node. You can enable translation by editing this node and selecting a Translation Profile (e.g. "Automatic").',
    );
    return $output;
  }
  if (lingotek_supported_node($node) && Lingotek::isSupportedLanguage($node->language)) {
    if ($node->lingotek['node_sync_status'] == LingotekSync::STATUS_EDITED) {
      $content_push_form = drupal_get_form('lingotek_push_form', $node);
      $output['content_push'] = array(
        '#markup' => drupal_render($content_push_form),
      );
    }
    if ($node->lingotek['document_id']) {
      $document = LingotekDocument::load($node->lingotek['document_id']);
      $progress = $document
        ->getProgress();
      if ($progress->results == 'success') {
        $download_form = drupal_get_form('lingotek_download_translations_form', $node, $document);
        $output[] = array(
          '#markup' => drupal_render($download_form),
        );
        if ($document
          ->hasPhasesToComplete()) {

          // Add the mark as complete table if there are complete-eligible phrases.
          $drupal_phase_complete_from = drupal_get_form('lingotek_mark_phases_complete', $node, $document);
          $output['mark_complete'] = array(
            '#markup' => drupal_render($drupal_phase_complete_from),
          );
        }
        $lingotek_advanced_parsing_form = drupal_get_form('lingotek_advanced_parsing_upgrade_form');
        $output['upgrade_form'] = array(
          '#markup' => drupal_render($lingotek_advanced_parsing_form),
        );
      }
      else {

        // Document not found (may still be importing)
        // Import Status (check and report on import status)
        $status = $document
          ->getImportStatus();
        $message = ' <i>' . check_plain($status) . '</i> ' . l('<i class="fa fa-refresh"></i> ' . t('Refresh'), '', array(
          'html' => TRUE,
          'attributes' => array(
            'class' => 'ltk-icon',
            'title' => t('Refresh'),
            'onclick' => array(
              'location.reload();return false;',
            ),
          ),
        ));
        drupal_set_message(t('Content Import Status:') . $message, 'status');
        $output['import_status'] = array(
          '#type' => 'fieldset',
          '#title' => t('Content Import Status'),
          '#description' => $message,
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
        );
      }

      /* REMOVE DISASSOCIATE_TRANSLTIONS FORM FROM THE TRANSLATE PAGE, FOR NOW
         $disassociate_translations_form = drupal_get_form('lingotek_node_disassociate_form', $node->nid);
         $output['disassociate_translations'] = array(
           '#markup' => drupal_render($disassociate_translations_form),
         );
         */
    }
  }
  else {
    $output[] = array(
      '#markup' => '<p class="help">' . t('This node is not compatible with Lingotek translation. Either it is not a Lingotek tranlsation-enabled content type or the node does not have a defined language.') . '</p>',
    );
  }

  // Publish form
  $output['publish_form'] = drupal_get_form('lingotek_publish_form', $node);
  return $output;
}