You are here

public function GetId3ConfigForm::buildForm in getID3() 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/GetId3ConfigForm.php, line 35
Contains \Drupal\getid3\Form\GetId3ConfigForm.

Class

GetId3ConfigForm

Namespace

Drupal\getid3\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $path = getid3_get_path();
  $form['getid3_path'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Path'),
    '#default_value' => $path,
    '#description' => $this
      ->t('The location where getID3() is installed. Relative paths are from the Drupal root directory.'),
  );
  $form['getid3_path']['#after_build'][] = array(
    get_class($this),
    'afterBuild',
  );
  if ($version = getid3_get_version()) {
    $form['getid3_version'] = array(
      '#type' => 'item',
      '#title' => $this
        ->t('Version'),
      '#markup' => '<pre>' . SafeMarkup::checkPlain($version) . '</pre>',
      '#description' => $this
        ->t("If you're seeing this it indicates that the getID3 library was found."),
    );

    // Check for existence of the 'demos' folder, contained in the getID3
    // library. The contents of this folder create a potential securtiy hole,
    // so we recommend that the user delete it.
    $getid3_demos_path = $path . '/../demos';
    if (file_exists($getid3_demos_path)) {
      drupal_set_message($this
        ->t("Your getID3 library is insecure! The demos distributed with getID3 contains code which creates a huge security hole. Remove the demos directory (%path) from beneath Drupal's directory.", array(
        '%path' => realpath($getid3_demos_path),
      )), 'error');
    }
  }
  $show_warnings = $this
    ->config('getid3.settings')
    ->get('getid3_show_warnings');
  if (empty($show_warnings)) {
    $show_warnings = FALSE;
  }
  $form['getid3_show_warnings'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t("Display Warnings"),
    '#default_value' => $show_warnings,
    '#description' => $this
      ->t("Check this to display the warning messages from the getID3 library when reading and writing ID3 tags. Generally it's a good idea to leave this unchecked, getID3 reports warnings for several trivial problems and the warnings can be confusing to users. This setting can be useful when debugging problems with the ID3 tags."),
  );
  return parent::buildForm($form, $form_state);
}