class Lightbox2AutoImageHandlingSettingsForm in Lightbox2 8
Same name in this branch
- 8 src/Lightbox2AutoImageHandlingSettingsForm.php \Drupal\lightbox2\Lightbox2AutoImageHandlingSettingsForm
- 8 src/Form/Lightbox2AutoImageHandlingSettingsForm.php \Drupal\lightbox2\Form\Lightbox2AutoImageHandlingSettingsForm
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\lightbox2\Form\Lightbox2AutoImageHandlingSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of Lightbox2AutoImageHandlingSettingsForm
1 string reference to 'Lightbox2AutoImageHandlingSettingsForm'
File
- src/
Form/ Lightbox2AutoImageHandlingSettingsForm.php, line 14 - Contains \Drupal\lightbox2\Form\Lightbox2AutoImageHandlingSettingsForm.
Namespace
Drupal\lightbox2\FormView source
class Lightbox2AutoImageHandlingSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'lightbox2_auto_image_handling_settings_form';
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('lightbox2.settings');
foreach (Element::children($form) as $variable) {
$config
->set($variable, $form_state
->getValue($form[$variable]['#parents']));
}
$config
->save();
if (method_exists($this, '_submitForm')) {
$this
->_submitForm($form, $form_state);
}
parent::submitForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'lightbox2.settings',
];
}
public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
// Add the javascript which disables / enables form elements.
drupal_add_js(drupal_get_path('module', 'lightbox2') . '/js/lightbox2.js', 'module');
// Set up a hidden variable.
$form['lightbox2_lite'] = [
'#type' => 'hidden',
'#value' => variable_get('lightbox2_lite', FALSE),
];
$automatic_options = [
0 => t('Disabled'),
1 => t('Lightbox'),
2 => t('Lightbox grouped'),
3 => t('Slideshow'),
4 => t('HTML content'),
5 => t('HTML content grouped'),
];
// Set image node options help text.
$form['image_node_options'] = [
'#value' => t('These options allow automatic URL re-formatting of images. This removes the need for you to add \'rel="lightbox"\' to each image link throughout your site. You can select which image sizes will trigger the lightbox and configure a list of image CSS classes which should also have their URLs automatically re-formatted. This feature is not available when using Lightbox2 Lite.'),
];
// Define handler settings fieldset.
/* --------------------------------- */
$form['handler_options'] = [
'#type' => 'fieldset',
'#title' => t('Automatic handlers'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
];
// Define image nodes settings fieldset.
/* ------------------------------------- */
$form['handler_options']['image_node_options'] = [
'#type' => 'fieldset',
'#title' => t('Image node settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
// Add checkbox for image nodes.
$form['handler_options']['image_node_options']['lightbox2_image_node'] = [
'#type' => 'select',
'#title' => t('Automatic handler for image nodes'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for image nodes will be automatically handled.'),
'#default_value' => variable_get('lightbox2_image_node', 0),
];
/*
// Add drop-down for list of available image sizes.
if (module_exists('image')) {
$sizes = image_get_sizes();
foreach ($sizes as $size_key => $size) {
if ($size_key == 'original' or $size_key == '_original') {
$size_key = 'original';
}
$size_options[$size_key] = $size['label'];
}
$form['handler_options']['image_node_options']['lightbox2_display_image_size'] = array(
'#type' => 'select',
'#title' => t('Lightbox image display size'),
'#options' => $size_options,
'#default_value' => variable_get('lightbox2_display_image_size', 'original'),
'#description' => t('Select which image size will be loaded in the lightbox. This only applies to images uploaded with the Image module.'),
);
$form['handler_options']['image_node_options']['lightbox2_trigger_image_size'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Image trigger size'),
'#options' => $size_options,
'#default_value' => variable_get('lightbox2_trigger_image_size', array('thumbnail')),
'#description' => t('Select which image size, when clicked on, will automatically trigger the lightbox. This only applies to images uploaded with the Image module.'),
);
}
*/
// Add checkbox for disabling lightbox for gallery lists.
$form['handler_options']['image_node_options']['lightbox2_disable_nested_galleries'] = [
'#type' => 'checkbox',
'#title' => t('Disable lightbox for gallery lists'),
'#description' => t('Checking this box will disable the lightbox for images in gallery lists. This means it is possible to open a gallery by clicking on the teaser image, but the lightbox will still appear when viewing images within the gallery. This only applies to image galleries created with the "image gallery" module.'),
'#default_value' => variable_get('lightbox2_disable_nested_galleries', TRUE),
];
// Define flickr fieldset.
/* ----------------------- */
$form['handler_options']['flickr_options'] = [
'#type' => 'fieldset',
'#title' => t('Flickr images'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
// Add checkbox for flickr image support.
$form['handler_options']['flickr_options']['lightbox2_flickr'] = [
'#type' => 'select',
'#title' => t('Automatic handler for Flickr images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for Flickr images will be automatically handled.'),
'#default_value' => variable_get('lightbox2_flickr', 0),
];
// Define gallery2 fieldset.
/* ------------------------- */
$form['handler_options']['gallery2_options'] = [
'#type' => 'fieldset',
'#title' => t('Gallery2 images'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
// Add checkbox for gallery2 block image support.
$form['handler_options']['gallery2_options']['lightbox2_gallery2_blocks'] = [
'#type' => 'select',
'#title' => t('Automatic handler for Gallery2 block images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for images, contained within Gallery2 image blocks, will be automatically handled.'),
'#default_value' => variable_get('lightbox2_gallery2_blocks', 0),
];
// Define inline fieldset.
/* ----------------------- */
$form['handler_options']['inline_options'] = [
'#type' => 'fieldset',
'#title' => t('Inline module images'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
// Add checkbox for inline image support.
$form['handler_options']['inline_options']['lightbox2_inline'] = [
'#type' => 'select',
'#title' => t('Automatic handler for Inline module images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for Inline module images will be automatically handled.'),
'#default_value' => variable_get('lightbox2_inline', 0),
];
// Define image assist fieldset.
/* ----------------------------- */
$form['handler_options']['img_assist_options'] = [
'#type' => 'fieldset',
'#title' => t('Image Assist images'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
// Add checkbox for image assist custom size images.
$form['handler_options']['img_assist_options']['lightbox2_image_assist_custom'] = [
'#type' => 'select',
'#title' => t('Automatic handler for Image Assist custom size images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for custom size images, displayed by the Image Assist module, will be automatically handled.'),
'#default_value' => variable_get('lightbox2_image_assist_custom', 0),
];
// Define custom fieldset.
/* ----------------------- */
$form['handler_options']['custom_options'] = [
'#type' => 'fieldset',
'#title' => t('Custom class images'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
// Add checkbox for custom class image support.
$form['handler_options']['custom_options']['lightbox2_custom_class_handler'] = [
'#type' => 'select',
'#title' => t('Automatic handler for custom class images'),
'#options' => $automatic_options,
'#description' => t('Choose how URLs for custom class images will be automatically handled.'),
'#default_value' => variable_get('lightbox2_custom_class_handler', 0),
];
// Add text box for custom trigger classes.
$form['handler_options']['custom_options']['lightbox2_custom_trigger_classes'] = [
'#type' => 'textarea',
'#title' => t('Custom image trigger classes'),
'#description' => t('List the image classes which should trigger the lightbox when clicked on. Put each class on a separate line.'),
'#default_value' => variable_get('lightbox2_custom_trigger_classes', ''),
];
// Add checkbox for disabling lightbox for acidfree gallery lists.
if (module_exists("acidfree")) {
// Define acidfree settings fieldset.
/* ---------------------------------- */
$form['handler_options']['lightbox2_acidfree_options'] = [
'#type' => 'fieldset',
'#title' => t('Acidfree settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
];
$form['handler_options']['lightbox2_acidfree_options']['lightbox2_disable_nested_acidfree_galleries'] = [
'#type' => 'checkbox',
'#title' => t('Disable lightbox for Acidfree gallery lists'),
'#description' => t('Checking this box will disable the lightbox for images in gallery lists. This means it is possible to open a gallery by clicking on the teaser image, but the lightbox will still appear when viewing images within the gallery. This only applies to image galleries created with the "acidfree" module.'),
'#default_value' => variable_get('lightbox2_disable_nested_acidfree_galleries', TRUE),
];
// Add checkbox for enabling lightbox for acidfree videos.
if (module_exists("video")) {
$form['handler_options']['lightbox2_acidfree_options']['lightbox2_enable_acidfree_videos'] = [
'#type' => 'checkbox',
'#title' => t('Enable lightbox for Acidfree videos'),
'#description' => t('Checking this box will enable the display of acidfree videos in a lightbox. This only applies to videos created by the "video" module and which appear in an acidfree gallery.'),
'#default_value' => variable_get('lightbox2_enable_acidfree_videos', FALSE),
];
}
}
return parent::buildForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
Lightbox2AutoImageHandlingSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
Lightbox2AutoImageHandlingSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
Lightbox2AutoImageHandlingSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
Lightbox2AutoImageHandlingSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |