public function YoutubeSettingsForm::buildForm in YouTube Field 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/ YoutubeSettingsForm.php, line 30
Class
- YoutubeSettingsForm
- Configure Youtube settings for this site.
Namespace
Drupal\youtube\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->configFactory
->get('youtube.settings');
$form['text'] = [
'#type' => 'markup',
'#markup' => '<p>' . $this
->t('The following settings will be used as default values on all YouTube video fields. Many of these settings can be overridden on a per-field basis.') . '</p>',
];
$form['youtube_global'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Video parameters'),
];
$form['youtube_global']['youtube_suggest'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show suggested videos from any channel - as opposed to only the same channel - when playback ends (rel).'),
'#default_value' => $config
->get('youtube_suggest'),
];
$form['youtube_global']['youtube_modestbranding'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Do not show YouTube logo on video player control bar (modestbranding).'),
'#default_value' => $config
->get('youtube_modestbranding'),
];
$form['youtube_global']['youtube_theme'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use a light colored control bar for video player controls (theme).'),
'#default_value' => $config
->get('youtube_theme'),
];
$form['youtube_global']['youtube_color'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use a white colored video progress bar (color).'),
'#default_value' => $config
->get('youtube_color'),
'#description' => $this
->t('Note: the modestbranding parameter will be ignored when this is in use.'),
];
$form['youtube_global']['youtube_enablejsapi'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable use of the IFrame API (enablejsapi, origin).'),
'#default_value' => $config
->get('youtube_enablejsapi'),
'#description' => $this
->t('For more information on the IFrame API and how to use it, see the <a href="@api_reference">IFrame API documentation</a>.', [
'@api_reference' => 'https://developers.google.com/youtube/iframe_api_reference',
]),
];
$form['youtube_global']['youtube_wmode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Fix overlay problem on IE8 and lower'),
'#default_value' => $config
->get('youtube_wmode'),
'#description' => $this
->t("Checking this will fix the issue of a YouTube video showing above a modal window (including Drupal's Overlay). This is needed if you have Overlay users in IE or have modal windows throughout your site."),
];
$form['youtube_global']['youtube_override'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Allow users to override parameters.'),
'#default_value' => $config
->get('youtube_override', FALSE),
'#description' => $this
->t('This will allow users to pass parameter values into the YouTube URL provided in the field input. For example, adding "&start=30" to the end of the URL would start the embedded video at the 30 second mark. This may have unintended side effects if parameter values are ever passed by accident.'),
];
$form['youtube_thumbs'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Thumbnails'),
];
$form['youtube_thumbs']['youtube_thumb_dir'] = [
'#type' => 'textfield',
'#title' => $this
->t('YouTube thumbnail directory'),
'#field_prefix' => 'public://',
'#field_suffix' => '/thumbnail.jpg',
'#description' => $this
->t('Location, within the files directory, where you would like the YouTube thumbnails stored.'),
'#default_value' => $config
->get('youtube_thumb_dir'),
];
$form['youtube_thumbs']['youtube_thumb_hires'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Save higher resolution thumbnail images'),
'#description' => $this
->t('This will save thumbnails larger than the default size, 480x360, to the thumbnails directory specified above.'),
'#default_value' => $config
->get('youtube_thumb_hires'),
];
$form['youtube_thumbs']['youtube_thumb_token_image_style'] = [
'#type' => 'select',
'#options' => image_style_options(TRUE),
'#title' => $this
->t('Default token image style'),
'#description' => $this
->t('Default image style for the output of a youtube_image_url token.'),
'#default_value' => $config
->get('youtube_thumb_token_image_style'),
];
$form['youtube_thumbs']['youtube_thumb_delete_all'] = [
'#type' => 'submit',
'#value' => $this
->t('Refresh existing thumbnail image files'),
'#submit' => [
'youtube_thumb_delete_all',
],
];
$form['youtube_privacy'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable privacy-enhanced mode'),
'#default_value' => $config
->get('youtube_privacy'),
'#description' => $this
->t('Checking this box will prevent YouTube from setting cookies in your site visitors browser.'),
];
$form['youtube_player_class'] = [
'#type' => 'textfield',
'#title' => $this
->t('YouTube player class'),
'#default_value' => $config
->get('youtube_player_class'),
'#description' => $this
->t('The iframe of every player will be given this class. They will also be given IDs based off of this value.'),
];
return parent::buildForm($form, $form_state);
}