You are here

public function TranscoderAbstractionFactoryZencoder::adminSettings in Video 7.2

Admin settings form for the transcoder

Overrides TranscoderFactoryInterface::adminSettings

File

transcoders/TranscoderAbstractionFactoryZencoder.inc, line 296
File containing class TranscoderAbstractionFactoryZencoder

Class

TranscoderAbstractionFactoryZencoder
Class that handles Zencoder transcoding.

Code

public function adminSettings() {
  $t = get_t();
  $form = array();
  $zencoder_api = variable_get('video_zencoder_api_key', NULL);
  if (empty($zencoder_api)) {
    $form['zencoder_user'] = array(
      '#type' => 'fieldset',
      '#title' => $t('Zencoder setup'),
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
      '#description' => $t('Add your email address, password and <em>save configurations</em> to create your Zencoder account. It will help you to transcode and manage your videos using Zencode website. Once you save your configurations then this will automatically create an account on the Zencoder.com and password and all ther other relevent details will be emailed to you.', array(
        '!link' => l($t('Zencoder.com'), 'http://zencoder.com'),
      )),
      '#states' => array(
        'visible' => array(
          ':input[name=video_convertor]' => array(
            'value' => 'TranscoderAbstractionFactoryZencoder',
          ),
        ),
      ),
    );
    $form['zencoder_user']['zencoder_username'] = array(
      '#type' => 'textfield',
      '#title' => $t('Your email address'),
      '#default_value' => variable_get('site_mail', 'me@localhost'),
      '#size' => 50,
      '#description' => $t('Make sure the email is accurate, since we will send all the password details to manage transcoding online and API key details to this.'),
    );
    $form['zencoder_user']['agree_terms_zencoder'] = array(
      '#type' => 'checkbox',
      '#title' => $t('Agree Zencoder !link.', array(
        '!link' => l($t('Terms and Conditions'), 'http://zencoder.com/terms', array(
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
      )),
      '#default_value' => variable_get('agree_terms_zencoder', TRUE),
    );
  }
  else {

    // Zencoder API is exists
    $form['zencoder_info'] = array(
      '#type' => 'fieldset',
      '#title' => t('Zencoder'),
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
      '#states' => array(
        'visible' => array(
          ':input[name=video_convertor]' => array(
            'value' => 'TranscoderAbstractionFactoryZencoder',
          ),
        ),
      ),
    );
    $form['zencoder_info']['api_status'] = array(
      '#type' => 'item',
      '#title' => t('Zencoder API status'),
      '#markup' => $this
        ->getCurrentStatus(),
    );
    $form['zencoder_info']['video_zencoder_api_key'] = array(
      '#type' => 'textfield',
      '#title' => t('Zencoder API key'),
      '#default_value' => variable_get('video_zencoder_api_key', NULL),
      '#description' => t('Leave empty and submit the form to start creating a new Zencoder account.'),
    );
    $form['zencoder_info']['video_zencoder_grouping'] = array(
      '#type' => 'textfield',
      '#title' => t('Zencoder grouping'),
      '#default_value' => variable_get('video_zencoder_grouping', NULL),
      '#description' => t('Create a grouping for reporting purposes. Can be used with the Zencoder reporting API.'),
    );
    $form['zencoder_info']['video_zencoder_http_username'] = array(
      '#type' => 'textfield',
      '#title' => t('Zencoder HTTP username'),
      '#default_value' => variable_get('video_zencoder_http_username'),
      '#description' => t('Enter a username and a password below to enable HTTP Basic Auth protected transfer of the original video file.') . '<br />' . t('This is useful if video files are stored in the private files directory and public access is not allowed.'),
    );
    $form['zencoder_info']['video_zencoder_http_password'] = array(
      '#type' => 'password',
      '#title' => t('Zencoder HTTP password'),
    );
    $form['zencoder_info']['video_thumbnail_count_zc'] = array(
      '#type' => 'textfield',
      '#title' => t('Number of thumbnails'),
      '#description' => t('Number of thumbnails to display from video.'),
      '#default_value' => variable_get('video_thumbnail_count', 5),
      '#size' => 5,
    );
    $form['zencoder_info']['video_thumbnail_size'] = array(
      '#type' => 'select',
      '#title' => t('Dimension of thumbnails'),
      '#default_value' => variable_get('video_thumbnail_size', '320x240'),
      '#options' => video_utility::getDimensions(),
    );
    $form['zencoder_info']['video_zencoder_postback'] = array(
      '#type' => 'textfield',
      '#title' => t('Postback URL for Zencoder'),
      '#description' => t('Important: Don\'t change this if you don\'t know what you\'re doing. The Postback URL is used by Zencoder to send transcoding status notifications to Drupal.') . '<br/>' . t('Default: %value', array(
        '%value' => url('postback/jobs', array(
          'absolute' => TRUE,
        )),
      )),
      '#default_value' => $this->postbackurl,
    );
    $form['zencoder_info']['video_zencoder_postback_donotvalidate'] = array(
      '#type' => 'checkbox',
      '#title' => t('Do not validate the Postback URL'),
      '#description' => t('The Postback URL is validated by retrieving the URL from the local server. In some cases this fails while it works fine for the Zencoder notification sender. Use this checkbox to disable Postback URL validation.'),
      '#default_value' => variable_get('video_zencoder_postback_donotvalidate', FALSE),
    );

    // testing
    $form['zencoder_info']['testing'] = array(
      '#type' => 'fieldset',
      '#title' => t('Testing mode'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['zencoder_info']['testing']['video_zencoder_testing_mode'] = array(
      '#type' => 'checkbox',
      '#title' => t('Test mode'),
      '#default_value' => variable_get('video_zencoder_testing_mode', FALSE),
      '#description' => t('Enable test mode to test upload/playback locally (if you have no public IP to test)'),
    );
    $form['zencoder_info']['testing']['video_zencoder_test_file_path'] = array(
      '#type' => 'textfield',
      '#title' => t('Path to test video file'),
      '#description' => t('Add the path to a video file for Zencoder to transcode.
          You must use this file for testing when using a local machine with no public IP
          address from which Zencoder can download video.'),
      '#default_value' => variable_get('video_zencoder_test_file_path', 'http://example.com/video.mp4'),
    );

    // advanced
    $form['zencoder_info']['advanced'] = array(
      '#type' => 'fieldset',
      '#title' => t('Advanced'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $tempdestinations = array(
      '' => t('Zencoder temporary storage') . ' (' . t('default') . ')',
    );
    if (module_exists('amazons3') && variable_get('amazons3_bucket', FALSE)) {
      $tempdestinations['s3'] = t('Amazon S3 bucket %bucket', array(
        '%bucket' => variable_get('amazons3_bucket'),
      ));
    }
    if (module_exists('cloud_files') && variable_get('rackspace_cloud_container', FALSE)) {
      $tempdestinations['rcf'] = t('Rackspace Cloud Files container %container', array(
        '%container' => variable_get('rackspace_cloud_container'),
      ));
    }
    if (count($tempdestinations) > 1) {
      $form['zencoder_info']['advanced']['video_zencoder_output_destination'] = array(
        '#type' => 'radios',
        '#title' => t('Location for Zencoder output'),
        '#default_value' => $this->outputdestination === NULL ? '' : $this->outputdestination,
        '#options' => $tempdestinations,
        '#description' => t('Normally, Zencoder uploads its transcoded files to its own Amazon S3 bucket from which the Video module will copy the file to the final destination. Use this setting to use a different location. If the selected location is identical to the final destination, this saves resource intensive copy operations during handling of the postback. The final destination is set per video field and defaults to the public files folder.'),
      );
      if (isset($tempdestinations['s3'])) {
        $form['zencoder_info']['advanced']['video_zencoder_output_destination']['#description'] .= '<br/>' . t('To enable Zencoder to upload directly to your Amazon S3 bucket, read the <a href="@zencoder-s3-url">Zencoder manual</a>.', array(
          '@zencoder-s3-url' => url('https://app.zencoder.com/docs/guides/getting-started/working-with-s3'),
        ));
      }
    }
    if (module_exists('amazons3')) {
      $form['zencoder_info']['advanced']['video_zencoder_private'] = array(
        '#type' => 'checkbox',
        '#title' => t('Store files on Amazon S3 privately'),
        '#default_value' => variable_get('video_zencoder_private', FALSE),
        '#description' => t('Files stored privately are only accessible by visitors when <a href="@amazons3-settings">Presigned URLs</a> are enabled. These URLs expire, allow you to control access to the video files. For this setting to work, you must set %destination-setting-name to Amazon S3.', array(
          '@amazons3-settings' => url('admin/config/media/amazons3'),
          '%destination-setting-name' => t('Location for Zencoder output'),
        )),
      );
    }
  }
  return $form;
}