You are here

public function FloatingSocialIconsBlock::blockForm in Floating Social Icons 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/FloatingSocialIconsBlock.php, line 89

Class

FloatingSocialIconsBlock
Provides a 'Floating Social Icon' Block.

Namespace

Drupal\floating_social_icons\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);

  // Facebook details.
  $form['floating_facebook'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Facebook settings'),
    '#collapsible' => TRUE,
    '#open' => TRUE,
    '#description' => '',
  ];
  $form['floating_facebook']['facebook_link'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Facebook Link'),
    '#size' => 60,
    '#default_value' => isset($this->configuration['facebook']) ? $this->configuration['facebook'] : '',
  ];
  $form['floating_facebook']['facebook_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Facebook title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['facebook_title']) ? $this->configuration['facebook_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // Twitter details.
  $form['floating_twitter'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Twitter settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '',
  ];
  $form['floating_twitter']['twitter_link'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Twitter Link'),
    '#size' => 60,
    '#default_value' => isset($this->configuration['twitter']) ? $this->configuration['twitter'] : '',
  ];
  $form['floating_twitter']['twitter_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Twitter title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['twitter_title']) ? $this->configuration['twitter_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // Google Plus details.
  $form['floating_google_plus'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Google Plus settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => '',
  ];
  $form['floating_google_plus']['google_plus_link'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Google Link'),
    '#size' => 60,
    '#default_value' => isset($this->configuration['google_plus']) ? $this->configuration['google_plus'] : '',
  ];
  $form['floating_google_plus']['google_plus_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('GooglePlus title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['google_plus_title']) ? $this->configuration['google_plus_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // LinkedIn details.
  $form['floating_linkedIn'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('LinkedIn settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => '',
  ];
  $form['floating_linkedIn']['linkedIn_link'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('LinkedIn Link'),
    '#size' => 60,
    '#default_value' => isset($this->configuration['linkedIn']) ? $this->configuration['linkedIn'] : '',
  ];
  $form['floating_linkedIn']['linkedIn_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('LinkedIn title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['linkedIn_title']) ? $this->configuration['linkedIn_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // Pinterest details.
  $form['floating_pinterest'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Pinterest settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '',
  ];
  $form['floating_pinterest']['pinterest_link'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Pinterest Link'),
    '#size' => 60,
    '#default_value' => isset($this->configuration['pinterest']) ? $this->configuration['pinterest'] : '',
  ];
  $form['floating_pinterest']['pinterest_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Pinterest title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['pinterest_title']) ? $this->configuration['pinterest_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // Instagram details.
  $form['floating_instagram'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Instagram settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '',
  ];
  $form['floating_instagram']['instagram_link'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Instagram Link'),
    '#size' => 60,
    '#default_value' => isset($this->configuration['instagram']) ? $this->configuration['instagram'] : '',
  ];
  $form['floating_instagram']['instagram_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Instagram title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['instagram_title']) ? $this->configuration['instagram_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // YouTube details.
  $form['floating_youtube'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Youtube settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '',
  ];
  $form['floating_youtube']['youtube_link'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Youtube Link'),
    '#size' => 60,
    '#default_value' => isset($this->configuration['youtube']) ? $this->configuration['youtube'] : '',
  ];
  $form['floating_youtube']['youtube_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Youtube title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['youtube_title']) ? $this->configuration['youtube_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // Mail details.
  $form['floating_mail'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('mail settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '',
  ];
  $form['floating_mail']['mail_link'] = [
    '#type' => 'email',
    '#title' => $this
      ->t('Mail Link'),
    '#size' => 60,
    '#description' => $this
      ->t('Please type only the e-mail id'),
    '#default_value' => isset($this->configuration['mail']) ? $this->configuration['mail'] : '',
  ];
  $form['floating_mail']['mail_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Mail title'),
    '#description' => $this
      ->t('Text to display when in active or hover state'),
    '#default_value' => isset($this->configuration['mail_title']) ? $this->configuration['mail_title'] : '',
    '#size' => 60,
    '#maxlength' => 128,
  ];

  // Block details.
  $form['floating_icons'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Display Icons'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '',
  ];
  $form['floating_icons']['hover'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Select the Hover Effects'),
    '#required' => TRUE,
    '#attributes' => array(
      'class' => array(
        'floating-block',
      ),
    ),
    '#default_value' => isset($this->configuration['hover']) ? $this->configuration['hover'] : 'grow',
    '#options' => [
      'grow' => $this
        ->t('Grow'),
      'shrink' => $this
        ->t('Shrink'),
      'black-white' => $this
        ->t('Black and white'),
      'white-black' => $this
        ->t('White and black'),
      'rotate' => $this
        ->t('Rotate 360'),
    ],
  ];
  $form['floating_icons']['place'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Where do you want to display the icons?'),
    '#required' => TRUE,
    '#default_value' => isset($this->configuration['place']) ? $this->configuration['place'] : 4,
    '#options' => [
      1 => $this
        ->t('Top'),
      2 => $this
        ->t('Right'),
      3 => $this
        ->t('Bottom'),
      4 => $this
        ->t('Left'),
    ],
  ];
  $form['floating_icons']['target'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Target Attribute'),
    '#default_value' => isset($this->configuration['target']) ? $this->configuration['target'] : '_self',
    '#options' => [
      '_self' => $this
        ->t('_Self'),
      '_blank' => $this
        ->t('_Blank'),
    ],
  ];
  $form['floating_icons']['count'] = [
    '#title' => $this
      ->t('Count'),
    '#value' => isset($this->configuration['count']) ? $this->configuration['count'] : 0,
    '#type' => 'hidden',
  ];
  return $form;
}