You are here

public static function EvaluationImplementation::upgradeCheckJsonForm in Drupal 8 upgrade evaluation 7

Same name and namespace in other branches
  1. 6 includes/EvaluationImplementation.php \Upgrade_check\EvaluationImplementation::upgradeCheckJsonForm()

Implements _upgrade_check_json_form().

1 call to EvaluationImplementation::upgradeCheckJsonForm()
_upgrade_check_json_form in ./upgrade_check.module
Function download json.

File

includes/EvaluationImplementation.php, line 94

Class

EvaluationImplementation

Namespace

Upgrade_check

Code

public static function upgradeCheckJsonForm() {
  $form = array();
  if (file_exists(variable_get(self::UPGRADE_CHECK_JSON_PATH, NULL))) {
    $method = variable_get(self::UPGRADE_CHECK_PREFIX . self::UPGRADE_CHECK_DATA_METHOD, 'manual');
    $url = UPGRADE_CHECK_URL . self::UPGRADE_CHECK_URL_ESTIMATE;
    $link = l($url, $url);
    $text = 'Do not disable the "Drupal 8 upgrade evaluation" module until ';
    $text .= 'you download json file to resource !l and do not get estimate ';
    $text .= 'result. Because the "Drupal 8 upgrade evaluation" module is ';
    $text .= 'needed to confirm verifying the ownership of your website.';
    drupal_set_message(t($text, array(
      '!l' => $link,
    )), 'warning');
    if (!empty($method) && $method !== 'automatic') {
      $form['download'] = array(
        '#type' => 'fieldset',
        '#title' => t('Download JSON file'),
      );
      $options = array(
        'absolute' => TRUE,
        'html' => TRUE,
        'attributes' => array(
          'target' => '_blank',
        ),
      );
      $link = l('Upload Json', $url, $options);
      $form['download']['description'] = array(
        '#type' => 'item',
        '#markup' => t('Please follow the steps to complete migration check process:'),
      );
      $form['download']['description_list_one'] = array(
        '#type' => 'item',
        '#markup' => t('I - Download JSON file from the given below link.'),
      );
      $form['download']['description_list_two'] = array(
        '#type' => 'item',
        '#markup' => t('II - Upload the JSON file here: !link', array(
          '!link' => $link,
        )),
      );
      $textButton = 'Download JSON';
    }
    else {
      $textButton = 'Transfer data';
      $form['download'] = array(
        '#type' => 'fieldset',
        '#title' => t('Transfer JSON data'),
      );
      $form['download']['description'] = array(
        '#type' => 'item',
        '#markup' => t('Please click to button "Transfer data" that complete migration check process. Data will be sent automatically.'),
      );
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t($textButton),
    );
  }
  else {
    $text = 'Their is no json file to download. ';
    $text .= 'Please create one by clicking the below link!';
    drupal_set_message(t($text));
    drupal_goto(UPGRADE_CHECK_EVALUATION);
  }
  return $form;
}