You are here

function iframe_iframe in Iframe 6

Same name and namespace in other branches
  1. 7 iframe.module \iframe_iframe()
2 calls to iframe_iframe()
theme_iframe_formatter_default in ./iframe.module
Theme function for 'default' text field formatter.
theme_iframe_formatter_iframeonly in ./iframe.module
Theme function for 'iframeonly' text field formatter.

File

./iframe.module, line 816
Defines simple iframe field types. based on the cck-module "link" by quicksketch MODULE-Funtions

Code

function iframe_iframe($text, $path, $options = FALSE) {
  dmsg(3, 'func iframe_iframe');
  if (!$options) {
    $options = array();
  }

  // Merge in defaults.

  //dmsg(4, 'IFIF options=' . implode(" ++ ", explode("\n", print_r($options, TRUE))));
  $options += array(
    'attributes' => array(),
    'html' => FALSE,
  );
  if (!isset($options['attributes']['width'])) {
    $options['attributes']['width'] = '100%';
  }
  if (!isset($options['attributes']['height'])) {
    $options['attributes']['height'] = '701';
  }
  if (!isset($options['attributes']['frameborder']) || empty($options['attributes']['frameborder'])) {
    $options['attributes']['frameborder'] = '0';
  }
  if (!isset($options['attributes']['scrolling']) || empty($options['attributes']['scrolling'])) {
    $options['attributes']['scrolling'] = 'auto';
  }
  if (!isset($options['attributes']['transparency']) || empty($options['attributes']['transparency'])) {
    $options['attributes']['transparency'] = '0';
  }
  $htmlid = '';
  if (isset($options['html-id']) && !empty($options['html-id'])) {
    $htmlid = ' id="' . $options['html-id'] . '" name="' . $options['html-id'] . '"';
  }

  // Append active class.
  if ($path == $_GET['q'] || $path == '<front>' && drupal_is_front_page()) {
    if (isset($options['attributes']['class'])) {
      $options['attributes']['class'] .= ' active';
    }
    else {
      $options['attributes']['class'] = 'active';
    }
  }

  // Remove all HTML and PHP tags from a tooltip. For best performance, we act only
  // if a quick strpos() pre-check gave a suspicion (because strip_tags() is expensive).
  if (isset($options['attributes']['title']) && strpos($options['attributes']['title'], '<') !== FALSE) {
    $options['attributes']['title'] = strip_tags($options['attributes']['title']);
  }
  $options_link = array();
  $options_link['attributes'] = array();
  $options_link['attributes']['title'] = $options['attributes']['title'];
  include_once drupal_get_path('module', 'content') . '/includes/content.crud.inc';
  return (empty($text) ? '' : '<div class="iframe_title">' . ($options['html'] ? $text : check_plain($text)) . '</div>') . '<iframe src="' . check_url(url($path, $options)) . '"' . drupal_attributes($options['attributes']) . $htmlid . '>' . t('Your browser does not support iframes. But You can use the following link.') . ' ' . l('Link', url($path, $options), $options_link) . '</iframe>';
}