You are here

class BlazyAdminExtended in Blazy 7

Provides re-usable admin functions, or form elements.

Hierarchy

Expanded class hierarchy of BlazyAdminExtended

File

src/Form/BlazyAdminExtended.php, line 8

Namespace

Drupal\blazy\Form
View source
class BlazyAdminExtended extends BlazyAdminFormatterBase implements BlazyAdminInterface {

  /**
   * Returns shared form elements across field formatter and Views.
   */
  public function openingForm(array &$form, &$definition = []) {
    $namespace = isset($definition['namespace']) ? $definition['namespace'] : 'blazy';
    if (!empty($definition['vanilla'])) {
      $form['vanilla'] = [
        '#type' => 'checkbox',
        '#title' => t('Vanilla @namespace', [
          '@namespace' => $namespace,
        ]),
        '#description' => t('<strong>Check</strong>:<ul><li>To render individual item as is as without extra logic.</li><li>To disable 99% @module features, and most of the mentioned options here, such as layouts, et al.</li><li>When the @module features can not satisfy the need.</li><li>Things may be broken! You are on your own.</li></ul><strong>Uncheck</strong>:<ul><li>To get consistent markups and its advanced features -- relevant for the provided options as @module needs to know what to style/work with.</li></ul>', [
          '@module' => $namespace,
        ]),
        '#weight' => -109,
        '#enforced' => TRUE,
        '#attributes' => [
          'class' => [
            'form-checkbox--vanilla',
          ],
          'data-blazy-tooltip' => 'wide',
          'data-blazy-tooltip-direction' => 'bottom',
        ],
      ];
    }
    if (!empty($definition['optionsets']) && $namespace != 'blazy') {
      $form['optionset'] = [
        '#type' => 'select',
        '#title' => t('Optionset'),
        '#options' => $definition['optionsets'],
        '#enforced' => TRUE,
        '#description' => t('Enable the optionset UI module to manage the optionsets.'),
        '#weight' => -108,
      ];
    }
    parent::openingForm($form, $definition);
  }

  /**
   * Returns re-usable fieldable formatter form elements.
   */
  public function fieldableForm(array &$form, $definition = []) {
    if (isset($definition['images'])) {
      $form['image'] = [
        '#type' => 'select',
        '#title' => t('Main stage'),
        '#options' => is_array($definition['images']) ? $definition['images'] : [],
        '#description' => t('Main background/stage image field. To have a mix of image and video with hires images, be sure to provide the same image field for both image and video. Leave empty to use default thumbnail if video, or just image.'),
        '#prefix' => '<h3 class="form__title form__title--fields">' . t('Fields') . '</h3>',
      ];
    }
    if (isset($definition['thumbnails'])) {
      $form['thumbnail'] = [
        '#type' => 'select',
        '#title' => t('Thumbnail image'),
        '#options' => is_array($definition['thumbnails']) ? $definition['thumbnails'] : [],
        '#description' => t('Leave empty to not use thumbnail pager.'),
      ];
    }
    if (isset($definition['overlays'])) {
      $form['overlay'] = [
        '#type' => 'select',
        '#title' => t('Overlay media'),
        '#options' => is_array($definition['overlays']) ? $definition['overlays'] : [],
        '#description' => t('Overlay is displayed over the main stage.'),
      ];
    }
    if (isset($definition['titles'])) {
      $form['title'] = [
        '#type' => 'select',
        '#title' => t('Title'),
        '#options' => is_array($definition['titles']) ? $definition['titles'] : [],
        '#description' => t('If provided, it will bre wrapped with H2.'),
      ];
    }
    if (isset($definition['links'])) {
      $form['link'] = [
        '#type' => 'select',
        '#title' => t('Link'),
        '#options' => is_array($definition['links']) ? $definition['links'] : [],
        '#description' => t('Link to content: Read more, View Case Study, etc.'),
      ];
    }
    if (isset($definition['classes'])) {
      $form['class'] = [
        '#type' => 'select',
        '#title' => t('Item class'),
        '#options' => is_array($definition['classes']) ? $definition['classes'] : [],
        '#description' => t('If provided, individual item will have this class, e.g.: to have different background with transparent images. Be sure its formatter is Key or Label. Accepted field types: list text, string (e.g.: node title), term/entity reference label.'),
        '#weight' => 6,
      ];
    }
    if (!empty($definition['id'])) {
      $form['id'] = [
        '#type' => 'textfield',
        '#title' => t('@namespace ID', [
          '@namespace' => $definition['namespace'],
        ]),
        '#size' => 40,
        '#maxlength' => 255,
        '#field_prefix' => '#',
        '#enforced' => TRUE,
        '#description' => t("Manually define the container ID. <em>This ID is used for the cache identifier, so be sure it is unique</em>. Leave empty to have a guaranteed unique ID managed by the module."),
        '#weight' => 94,
      ];
    }
    if (isset($form['caption'])) {
      $form['caption']['#description'] = t('Enable any of the following fields as captions. These fields are treated and wrapped as captions.');
    }
    if (empty($definition['id'])) {
      if (isset($form['caption'])) {
        $form['caption']['#description'] .= ' ' . t('Be sure to make them visible at their relevant Manage display.');
      }
    }
    else {
      if (isset($form['overlay'])) {
        $form['overlay']['#description'] .= ' ' . t('Be sure to CHECK "Use field template" under its formatter if using Slick field formatter.');
      }
    }
  }

  /**
   * Returns shared ending form elements across field formatter and Views.
   */
  public function closingForm(array &$form, $definition = []) {
    if (!empty($definition['caches'])) {
      $form['cache'] = [
        '#type' => 'select',
        '#title' => t('Cache'),
        '#options' => $this
          ->getCacheOptions(),
        '#weight' => 98,
        '#enforced' => TRUE,
        '#description' => t('Ditch all the logic to cached bare HTML. <ol><li><strong>Permanent</strong>: cached contents will persist (be displayed) till the next cron runs.</li><li><strong>Any number</strong>: expired by the selected expiration time, and fresh contents are fetched till the next cache rebuilt.</li></ol>A working cron job is required to clear stale cache. At any rate, cached contents will be refreshed regardless of the expiration time after the cron hits. <br />Leave it empty to disable caching.<br /><strong>Warning!</strong> Be sure no useless/ sensitive data such as Edit links as they are rendered as is regardless permissions. No permissions are changed, just ugly. Only enable it when all is done, otherwise cached options will be displayed while changing them.'),
      ];
      if (!empty($definition['_views'])) {
        $form['cache']['#description'] .= ' ' . t('Also disable Views cache (<strong>Advanced &gt; Caching</strong>) temporarily _only if trouble to see updated settings.');
      }
    }
    parent::closingForm($form, $definition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlazyAdminBase::$manager protected property The blazy manager service.
BlazyAdminBase::$viewModeOptions protected property The available view modes.
BlazyAdminBase::baseForm public function Returns simple form elements common for Views field, EB widget, formatters.
BlazyAdminBase::breakpointElements public function Defines re-usable breakpoints form.
BlazyAdminBase::breakpointsForm public function Defines re-usable breakpoints form.
BlazyAdminBase::finalizeForm public function Returns re-usable logic, styling and assets across fields and Views.
BlazyAdminBase::getBundlePath protected function Helper function for getting correct bundle for manage field/display path.
BlazyAdminBase::getCacheOptions public function Returns time in interval for select options.
BlazyAdminBase::getOptionsetOptions public function Returns available optionsets for select options.
BlazyAdminBase::getState protected function Get one of the pre-defined states used in this form.
BlazyAdminBase::getViewModeOptions public function Returns available view modes for select options.
BlazyAdminBase::gridForm public function Returns re-usable grid elements across field formatter and Views.
BlazyAdminBase::manager public function Returns the blazy manager.
BlazyAdminBase::mediaSwitchForm public function Returns re-usable media switch form elements.
BlazyAdminBase::showAltTitleFieldHint protected function If the image field doesn't have the Title field enabled, tell the user.
BlazyAdminBase::STATE_IFRAME_ENABLED constant A state that represents the media switch iframe is enabled.
BlazyAdminBase::STATE_IMAGE_RENDERED_ENABLED constant A state that represents the image rendered switch is enabled.
BlazyAdminBase::STATE_LIGHTBOX_CUSTOM constant A state that represents the custom lightbox caption is enabled.
BlazyAdminBase::STATE_LIGHTBOX_ENABLED constant A state that represents the media switch lightbox is enabled.
BlazyAdminBase::STATE_RESPONSIVE_IMAGE_STYLE_DISABLED constant A state that represents the responsive image style is disabled.
BlazyAdminBase::STATE_THUMBNAIL_STYLE_ENABLED constant A state that represents the thumbnail style is enabled.
BlazyAdminBase::__construct public function Constructs a BlazyAdmin instance.
BlazyAdminExtended::closingForm public function Returns shared ending form elements across field formatter and Views. Overrides BlazyAdminBase::closingForm
BlazyAdminExtended::fieldableForm public function Returns re-usable fieldable formatter form elements.
BlazyAdminExtended::openingForm public function Returns shared form elements across field formatter and Views. Overrides BlazyAdminBase::openingForm
BlazyAdminFormatterBase::getBundles private function Returns the expected bundles.
BlazyAdminFormatterBase::getExcludedFieldOptions public function Declutters options from less relevant options.
BlazyAdminFormatterBase::getExcludedSettingsSummary public function Exclude the field formatter settings summary as required.
BlazyAdminFormatterBase::getFieldOptions public function Returns available fields for select options.
BlazyAdminFormatterBase::getFieldOptionsInternal private function Helper function to get list of supported field base on field_types.
BlazyAdminFormatterBase::getResponsiveImageOptions public function Returns Picture for select options.
BlazyAdminFormatterBase::getSettingsSummary public function Return the field formatter settings summary.
BlazyAdminFormatterBase::imageStyleForm public function Returns re-usable image formatter form elements.