You are here

function lingotek_admin_utilities_form in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.3 lingotek.admin.inc \lingotek_admin_utilities_form()
  2. 7.4 lingotek.admin.inc \lingotek_admin_utilities_form()
  3. 7.5 lingotek.admin.inc \lingotek_admin_utilities_form()
  4. 7.6 lingotek.admin.inc \lingotek_admin_utilities_form()

Utilities Form

1 string reference to 'lingotek_admin_utilities_form'
lingotek_admin_configuration_view in ./lingotek.admin.inc

File

./lingotek.admin.inc, line 2386

Code

function lingotek_admin_utilities_form($form, &$form_state, $show_fieldset = FALSE) {
  $form['utilities'] = array(
    '#type' => $show_fieldset ? 'fieldset' : 'item',
    '#title' => t('Lingotek Utilities'),
    '#description' => '',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'additional_settings',
  );
  drupal_add_js(array(
    'lingotek-disassociate-style' => array(
      'modalSize' => array(
        'type' => 'fixed',
        'width' => 450,
        'height' => 250,
      ),
      'closeImage' => theme('image', array(
        'path' => drupal_get_path('module', 'lingotek') . '/images/close.png',
        'alt' => t('Close window'),
        'title' => t('Close window'),
      )),
      'closeText' => '',
      'animation' => 'fadeIn',
    ),
  ), 'setting');
  $form['url'] = array(
    '#type' => 'hidden',
    // The name of the class is the #id of $btn_disassociate_translations with "-url" suffix.
    '#attributes' => array(
      'class' => array(
        'ctools-lingotek-disassociate-button-url',
      ),
    ),
    '#value' => url(LINGOTEK_MENU_MAIN_BASE_URL . '/disassociate/'),
  );
  $btn_disassociate_translations = array(
    '#type' => 'button',
    '#value' => t('Disassociate'),
    '#attributes' => array(
      'class' => array(
        'ctools-use-modal',
        'ctools-modal-lingotek-disassociate-style',
      ),
    ),
    '#id' => 'ctools-lingotek-disassociate-button',
  );
  $btn_callback_url_update = array(
    '#type' => 'submit',
    '#value' => t('Update URL'),
    '#submit' => array(
      'lingotek_notify_url_update',
    ),
  );
  $btn_callback_refresh_api_cache = array(
    '#type' => 'submit',
    '#value' => t('Refresh'),
    '#submit' => array(
      'lingotek_refresh_api_cache',
    ),
  );

  // Start: Not sure why, but without these below, the table buttons do not work properly
  $form['utilities'][] = array_merge($btn_callback_refresh_api_cache, array(
    '#attributes' => array(
      'style' => 'display: none;',
    ),
  ));
  $form['utilities'][] = array_merge($btn_callback_url_update, array(
    '#attributes' => array(
      'style' => 'display: none;',
    ),
  ));

  //$form['utilities'][] = array_merge($btn_disassociate_translations, array('#attributes' => array('style' => 'display: none;')));

  // End: Not sure why
  $rows = array(
    array(
      array(
        'data' => array(
          '#type' => 'markup',
          '#prefix' => t('Refresh Project, Workflow, and Vault Information') . '<div class="description">',
          '#markup' => t("This module locally caches the available projects, workflows, and vaults.  Use this utility whenever you need to pull down names for any newly created projects, workflows, or vaults from the Lingotek Translation Management System."),
          '#suffix' => '</div>',
        ),
      ),
      array(
        'data' => $btn_callback_refresh_api_cache,
      ),
    ),
    array(
      array(
        'data' => array(
          '#type' => 'markup',
          '#prefix' => t('Update Notification Callback URL') . '<div class="description">',
          '#markup' => t("Update the notification callback URL.  This can be run whenever your site is moved (e.g., domain name change or sub-directory re-location) or whenever you would like your security token re-generated.<br/>") . '<br/>' . t("Current notification callback URL:") . ' <i>' . variable_get('lingotek_notify_url', 'None') . '</i>',
          '#suffix' => '</div>',
        ),
      ),
      array(
        'data' => $btn_callback_url_update,
      ),
    ),
  );
  $rows[] = array(
    array(
      'data' => array(
        '#type' => 'markup',
        '#prefix' => t('Disassociate All Translations') . ' <i>' . t('(use with caution)') . '</i>' . '<div class="description">',
        '#markup' => t("Should only be used to change the Lingotek project or TM vault associated with the node’s translation. Option to disassociate node translations on Lingotek’s servers from the copies downloaded to Drupal. Additional translation using Lingotek will require re-uploading the node’s content to restart the translation process."),
        '#suffix' => '</div>',
      ),
    ),
    array(
      'data' => $btn_disassociate_translations,
    ),
  );
  $header = array();
  $form['utilities']['utility_table'] = array(
    '#markup' => theme('table', array(
      'header' => $header,
      'rows' => $rows,
    )),
  );
  $form['#action'] = url('admin/settings/lingotek/settings', array(
    'fragment' => 'ltk-utils',
  ));
  return $form;
}