File: Iframe.php

package info (click to toggle)
php-horde 5.2.13%2Bdebian0-1%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,652 kB
  • sloc: php: 11,153; xml: 6,751; javascript: 5,560; sh: 92; makefile: 33; sql: 1
file content (83 lines) | stat: -rw-r--r-- 2,269 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
 * @package Horde
 */
class Horde_Block_Iframe extends Horde_Core_Block
{
    /**
     */
    public function __construct($app, $params = array())
    {
        parent::__construct($app, $params);

        $this->_name = _("View an external web page");
    }

    /**
     */
    protected function _params()
    {
        return array(
            'iframe' => array(
                'type' => 'text',
                'name' => _("URL"),
                'default' => ''
            ),
            'title' => array(
                'type' => 'text',
                'name' => _("Title")
            ),
            'height' => array(
                'type' => 'enum',
                'name' => _("Height"),
                'default' => '600',
                'values' => array(
                    '480' => _("Small"),
                    '600' => _("Medium"),
                    '768' => _("Large"),
                    '1024' => _("Extra Large")
                )
            )
        );
    }

    /**
     */
    protected function _title()
    {
        $title = !empty($this->_params['title'])
            ? $this->_params['title']
            : $this->_params['iframe'];
        $url = new Horde_Url(Horde::externalUrl($this->_params['iframe']));

        return htmlspecialchars($title) .
            $url->link(array('target' => '_blank')) .
            Horde_Themes_Image::tag('external.png', array(
                'attr' => array(
                    'style' => 'vertical-align:middle;padding-left:.3em'
                )
            )) . '</a>';
    }

    /**
     */
    protected function _content()
    {
        global $browser;

        if (!$browser->hasFeature('iframes')) {
            return _("Your browser does not support this feature.");
        }

        if (empty($this->_params['height'])) {
            $height = ($browser->isBrowser('msie') || $browser->isBrowser('webkit'))
                ? ''
                : ' height="100%"';
        } else {
            $height = ' height="' . htmlspecialchars($this->_params['height']) . '"';
        }

        return '<iframe src="' . htmlspecialchars($this->_params['iframe']) . '" width="100%"' . $height . ' marginheight="0" scrolling="auto" frameborder="0"></iframe>';
    }

}