You are here

public function PhotosFilter::tips in Album Photos 8.5

Same name and namespace in other branches
  1. 8.4 src/Plugin/Filter/PhotosFilter.php \Drupal\photos\Plugin\Filter\PhotosFilter::tips()
  2. 6.0.x src/Plugin/Filter/PhotosFilter.php \Drupal\photos\Plugin\Filter\PhotosFilter::tips()

Generates a filter's tip.

A filter's tips should be informative and to the point. Short tips are preferably one-liners.

@todo Split into getSummaryItem() and buildGuidelines().

Parameters

bool $long: Whether this callback should return a short tip to display in a form (FALSE), or whether a more elaborate filter tips should be returned for template_preprocess_filter_tips() (TRUE).

Return value

string|null Translated text to display as a tip, or NULL if this filter has no tip.

Overrides FilterBase::tips

File

src/Plugin/Filter/PhotosFilter.php, line 35

Class

PhotosFilter
Provides a filter to embed image and albums from the photos module.

Namespace

Drupal\photos\Plugin\Filter

Code

public function tips($long = FALSE) {
  switch ($long) {
    case 0:
      return $this
        ->t('Insert an image: [photos=image]id=55[/photos], insert multiple images: [photos=image]id=55,56,57,58[/photos], insert album: [photos=album]id=10[/photos].');
    case 1:

      // @todo id is the fid and will have to remain fid in 8.x-5.x to
      //   preserver backwards compatibility.
      $tip = '<h3>Insert images and albums</h3>';
      $item[] = $this
        ->t('Insert an image: [photos=image]id=55[/photos].');
      $item[] = $this
        ->t('Insert multiple images: [photos=image]id=55,56,57,58,59[/photos].');
      $item[] = $this
        ->t('Optional attributes: align, e.g: [photos=image]id=55|align=left[/photos] or [photos=image]id=55,56,57|align=right[/photos].');
      $t1 = [
        '#theme' => 'item_list',
        '#items' => $item,
        '#title' => $this
          ->t('Images'),
      ];
      $tip .= \Drupal::service('renderer')
        ->render($t1);
      $item = [];
      $item[] = $this
        ->t('Insert album: [photos=album]id=10[/photos]. The default will display the album cover. You can display additional images with the "limit" property.');
      $item[] = $this
        ->t('Optional attributes: align or limit, e.g: [photos=album]id=10|align=left[/photos] or [photos=album]id=10|align=right|limit=5[/photos].');
      $t2 = [
        '#theme' => 'item_list',
        '#items' => $item,
        '#title' => $this
          ->t('Albums'),
      ];
      $tip .= \Drupal::service('renderer')
        ->render($t2);
      $tip .= $this
        ->t('This is similar to bbcode.');
      return $tip;
  }
  return '';
}