function iframe_iframe in Iframe 7
Same name and namespace in other branches
- 6 iframe.module \iframe_iframe()
2 calls to iframe_iframe()
- iframe_formatter_default_helper in ./
iframe.module - Formatter function for 'default' text field formatter.
- iframe_formatter_only_helper in ./
iframe.module - Formatter function for 'iframeonly' text field formatter.
File
- ./
iframe.module, line 459 - Defines an iframe field with all attributes.
Code
function iframe_iframe($text, $path, $options = FALSE) {
global $user, $language, $node;
iframe_debug(1, 'iframe_iframe item', $options);
if (!$options) {
$options = array();
}
// Merge in defaults.
$options += array(
'html' => FALSE,
'style' => '',
);
$allow = array();
if (!isset($options['width'])) {
$options['width'] = '100%';
}
if (!isset($options['height'])) {
$options['height'] = '701';
}
if (isset($options['frameborder'])) {
if ($options['frameborder'] > 0) {
$options['style'] .= 'border-width:2px;';
}
else {
$options['style'] .= 'border-width:0;';
}
unset($options['frameborder']);
}
if (isset($options['scrolling'])) {
if ($options['scrolling'] == 'yes') {
$options['style'] .= 'overflow:scroll;';
}
elseif ($options['scrolling'] == 'no') {
$options['style'] .= 'overflow:hidden;';
}
else {
# auto
$options['style'] .= 'overflow:auto;';
}
unset($options['scrolling']);
}
if (isset($options['transparency'])) {
if ($options['transparency'] > 0) {
$options['style'] .= 'background-color:transparent;';
}
unset($options['transparency']);
}
if (!isset($options['tokensupport']) || $options['tokensupport'] < 0) {
$options['tokensupport'] = 0;
}
if (isset($options['allowfullscreen']) && $options['allowfullscreen'] == 1) {
$allow[] = 'fullscreen';
}
unset($options['allowfullscreen']);
$allow[] = 'autoplay';
$allow[] = 'camera';
$allow[] = 'microphone';
$allow[] = 'payment';
$allow[] = 'accelerometer';
$allow[] = 'geolocation';
$allow[] = 'encrypted-media';
$allow[] = 'gyroscope';
$options['allow'] = implode(';', $allow);
// Append active class.
if ($path == $_GET['q'] || $path == '<front>' && drupal_is_front_page()) {
if (isset($options['class'])) {
$options['class'] .= ' active';
}
else {
$options['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['title']) && strpos($options['title'], '<') !== FALSE) {
$options['title'] = strip_tags($options['title']);
}
$options_link = array();
$options_link['attributes'] = array();
$options_link['attributes']['title'] = $options['title'];
if (module_exists('token')) {
// Token Support for field "url" and "title"
if (!isset($node)) {
$node = menu_get_object();
}
$tokensupport = !empty($options['tokensupport']) ? (int) $options['tokensupport'] : 0;
if ($tokensupport > 0) {
$text = token_replace($text, array(
'user' => $user,
'node' => $node,
), array(
'language' => $language,
));
// node:, user: are default token targets
}
if ($tokensupport > 1) {
$path = token_replace($path, array(
'user' => $user,
'node' => $node,
), array(
'language' => $language,
));
}
}
if (!isset($options['name']) && !empty($options['id'])) {
$options['name'] = $options['id'];
}
$iframearguments_allowed = array(
'title',
'width',
'height',
'class',
'style',
'id',
'name',
'allow',
);
$iframearguments = array();
foreach ($iframearguments_allowed as $argkey) {
if (isset($options[$argkey])) {
$iframearguments[$argkey] = $options[$argkey];
}
}
$options['external'] = TRUE;
return '<div class="' . (isset($options['class']) ? check_plain($options['class']) : '') . '">' . (empty($text) ? '' : '<h3 class="iframe_title">' . ($options['html'] ? $text : check_plain($text)) . '</h3>') . '<iframe src="' . check_url(url($path, $options)) . '"' . drupal_attributes($iframearguments) . '>' . t('Your browser does not support iframes, but you can use the following link.') . ' ' . l('Link', url($path, $options), $options_link) . '</iframe>' . '</div>';
}