You are here

function lightbox2_filter in Lightbox2 6

Same name and namespace in other branches
  1. 5.2 lightbox2.module \lightbox2_filter()

Implementation of hook_filter().

File

./lightbox2.module, line 368
Enables the use of lightbox2 which places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths.

Code

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 <a> tag will appear in a Lightbox when clicked on.');
      }
      elseif ($delta == 1) {
        return t('Turns g2_filter links into Lightbox2 appropriate links');
      }
      elseif ($delta == 2) {
        return t('Image links with \'rel="lightshow"\' in the <a> tag will appear in a Lightbox slideshow when clicked on.');
      }
      elseif ($delta == 3) {
        return t('Links to HTML content with \'rel="lightframe"\' in the <a> tag will appear in a Lightbox when clicked on.');
      }
      elseif ($delta == 4) {
        return t('Links to video content with \'rel="lightvideo"\' in the <a> tag will appear in a Lightbox when clicked on.');
      }
      elseif ($delta == 5) {
        return t('Links to inline or modal content with \'rel="lightmodal"\' in the <a> tag will appear in a Lightbox when clicked on.');
      }
      elseif ($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.');
      }
    case 'process':
      if ($delta == 1) {
        $text = ' ' . $text . ' ';
        $text = preg_replace('/ShowItem/', 'DownloadItem', $text);
        $text = preg_replace('/<img\\s+([^>]*?)src="/', '<img \\1rel="lightbox" src="', $text);
        $text = drupal_substr($text, 1, -1);
      }
      elseif ($delta == 6) {
        $text = preg_replace('/<a([^>]*?)(rel=[\'"]*lightframe[\'"]*)([^>]*?)>/i', '<a\\1\\3>', $text);
      }
      return $text;
    default:
      return $text;
  }
}