Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / blazy / src / Form / BlazyAdminFormatter.php
1 <?php
2
3 namespace Drupal\blazy\Form;
4
5 use Drupal\Core\Url;
6
7 /**
8  * Provides admin form specific to Blazy admin formatter.
9  */
10 class BlazyAdminFormatter extends BlazyAdminFormatterBase {
11
12   /**
13    * Defines re-usable form elements.
14    */
15   public function buildSettingsForm(array &$form, $definition = []) {
16     $definition['namespace'] = 'blazy';
17     $definition['responsive_image'] = isset($definition['responsive_image']) ? $definition['responsive_image'] : TRUE;
18
19     $this->openingForm($form, $definition);
20     $this->imageStyleForm($form, $definition);
21
22     if (!empty($definition['media_switch_form']) && !isset($form['media_switch'])) {
23       $this->mediaSwitchForm($form, $definition);
24     }
25
26     if (!empty($definition['grid_form']) && !isset($form['grid'])) {
27       $this->gridForm($form, $definition);
28
29       // Blazy doesn't need complex grid with multiple groups.
30       unset($form['preserve_keys'], $form['visible_items']);
31
32       if (isset($form['grid'])) {
33         $form['grid']['#description'] = $this->t('The amount of block grid columns for large monitors 64.063em+. <br /><strong>Requires</strong>:<ol><li>Display style.</li><li>A reasonable amount of contents.</li></ol>Leave empty to DIY, or to not build grids.');
34       }
35     }
36
37     if (!empty($definition['breakpoints'])) {
38       $this->breakpointsForm($form, $definition);
39     }
40
41     if (isset($form['responsive_image_style'])) {
42       $form['responsive_image_style']['#description'] = $this->t('Not compatible with below breakpoints, aspect ratio, yet. However it can still lazyload by checking <strong>Responsive image</strong> option via Blazy UI. Leave empty to disable.');
43
44       if ($this->blazyManager()->getModuleHandler()->moduleExists('blazy_ui')) {
45         $form['responsive_image_style']['#description'] .= ' ' . $this->t('<a href=":url" target="_blank">Enable lazyloading Responsive image</a>.', [':url' => Url::fromRoute('blazy.settings')->toString()]);
46       }
47     }
48
49     $this->closingForm($form, $definition);
50   }
51
52 }