3
* Copyright Netvibes 2006-2009.
4
* This file is part of Exposition PHP Lib.
6
* Exposition PHP Lib is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Exposition PHP Lib is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with Exposition PHP Lib. If not, see <http://www.gnu.org/licenses/>.
21
require_once 'Compiler.php';
24
* Frame Compiler to render a UWA widget within an iframe.
26
class Compiler_Frame extends Compiler
29
* Javascript UWA environment.
33
protected $_environment = 'Frame';
40
protected $_stylesheet = 'uwa-iframe.css';
43
* Main rendering function.
47
public function render()
51
$l[] = '<?xml version="1.0" encoding="utf-8"?>';
52
$l[] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' .
53
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
54
$l[] = '<html xmlns="http://www.w3.org/1999/xhtml">';
56
$l[] = '<title>' . $this->_widget->getTitle() . '</title>';
57
$l[] = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
58
foreach ($this->getStylesheets() as $stylesheet) {
59
$l[] = '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '"/>';
63
$className = 'moduleIframe';
64
if (isset($this->options['chromeColor'])) {
65
$className .= ' ' . $this->options['chromeColor'] . '-module';
67
$l[] = '<body class="' . $className . '">';
69
$l[] = $this->getHtmlBody();
74
return implode("\n", $l);
77
public function getHtmlBody()
81
if (isset($this->options['displayHeader']) && $this->options['displayHeader'] == '1') {
82
$l[] = $this->_getHtmlHeader();
85
$l[] = '<div class="moduleContent" id="moduleContent">';
86
$l[] = $this->_widget->getBody();
89
if (isset($this->options['displayStatus']) && $this->options['displayStatus'] == '1') {
90
$l[] = $this->_getHtmlStatus();
93
$l[] = $this->_getJavascriptConstants();
95
foreach ($this->_getJavascripts() as $script) {
96
$l[] = '<script type="text/javascript" src="' . $script . '"></script>';
99
$l[] = '<script type="text/javascript">';
100
$l[] = $this->_getFrameScript();
103
return implode("\n", $l);
106
public function getStylesheets()
108
return $this->_getStylesheets();
111
private function _getFrameScript()
116
'ajax' => Zend_Registry::get('proxyEndpoint') . '/ajax',
117
'feed' => Zend_Registry::get('proxyEndpoint') . '/feed'
120
$l[] = sprintf('UWA.proxies = %s;', Zend_Json::encode($proxies));
122
if (isset($this->options['properties'])) {
123
foreach ($this->options['properties'] as $key => $value) {
125
$l[] = sprintf("widget.%s = %s;", $key, Zend_Json::encode($value));
130
if (isset($this->options['data']) && count($this->options['data'])) {
131
$l[] = sprintf("UWA.extend(widget.data, %s);", Zend_Json::encode($this->options['data']));
134
$script = $this->_widget->getScript();
135
if (!empty($script)) {
136
if (isset($this->options['uwaId'])) {
137
$l[] = sprintf("UWA.Scripts['%s'](widget);", $this->options['uwaId']);
139
$l[] = "UWA.script(widget);";
143
if (isset($this->options['ifproxyUrl'])) {
144
$l[] = sprintf("Environment.ifproxyUrl = %s;", Zend_Json::encode($this->options['ifproxyUrl']));
147
$l[] = "Environment.launchModule();";
149
return implode("\n", $l);