Contributions API

lightbox2_filter

Definition

lightbox2_filter($op, $delta = 0, $format = -1, $text = '')
contributions/lightbox2/lightbox2.module, line 395

Description

Implementation of hook_filter().

Code

<?php
function lightbox2_filter($op, $delta = 0, $format = -1, $text = '') {
  switch ($op) {
    case 'list':
      return array(
        0 => t('Lightbox filter'),
        1 => t('Lightbox G2 filter'),
        2 => t('Lightbox slideshow filter'),
        3 => t('Lightbox iframe filter'),
        4 => t('Lightbox video filter'),
        5 => t('Lightbox modal filter'),
        6 => t('Disable Lightbox iframe filter'),
      );

    case 'description':
      if ($delta == 0) {
        return t('Image links with \'rel="lightbox"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      }
      else if ($delta == 1) {
        return t('Turns g2_filter links into Lightbox2 appropriate links');
      }
      else if ($delta == 2) {
        return t('Image links with \'rel="lightshow"\' in the &lt;a&gt; tag will appear in a Lightbox slideshow when clicked on.');
      }
      else if ($delta == 3) {
        return t('Links to HTML content with \'rel="lightframe"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      }
      else if ($delta == 4) {
        return t('Links to video content with \'rel="lightvideo"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      }
      else if ($delta == 5) {
        return t('Links to inline or modal content with \'rel="lightmodal"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      }
      else if ($delta == 6) {
        return t('It\'s possible to show webpage content in the lightbox, using iframes.  In this case the "rel" attribute should be set to "lightframe".  However, users can do this without any filters to be enabled.  To prevent users from adding iframes to the site in this manner, then please enable this option.') .'</p>';
      }

    case 'process':
      if ($delta == 1) {
        $text = ' '. $text .' ';
        $text = preg_replace('/ShowItem/', 'DownloadItem', $text);
        $text = preg_replace('/src="/', 'rel="lightbox" src="', $text);
        $text = drupal_substr($text, 1, -1);
      }
      else if ($delta == 6) {
        $text = preg_replace('/<a([^>]*?)(rel=[\'"]*lightframe[\'"]*)([^>]*?)>/i', '<a\1\3>', $text);
      }
      return $text;

    default:
      return $text;
  }
}
?>