.
*/
require_once 'Compiler.php';
/**
* Frame Compiler to render a UWA widget within an iframe.
*/
class Compiler_Frame extends Compiler
{
/**
* Javascript UWA environment.
*
* @var string
*/
protected $_environment = 'Frame';
/**
* Stylesheet.
*
* @var string
*/
protected $_stylesheet = 'uwa-iframe.css';
/**
* Main rendering function.
*
* @return string
*/
public function render()
{
$l = array();
$l[] = '';
$l[] = '';
$l[] = '';
$l[] = '
';
$l[] = '' . $this->_widget->getTitle() . '';
$l[] = '';
foreach ($this->getStylesheets() as $stylesheet) {
$l[] = '';
}
$l[] = '';
$className = 'moduleIframe';
if (isset($this->options['chromeColor'])) {
$className .= ' ' . $this->options['chromeColor'] . '-module';
}
$l[] = '';
$l[] = $this->getHtmlBody();
$l[] = '';
$l[] = '';
return implode("\n", $l);
}
public function getHtmlBody()
{
$l = array();
if (isset($this->options['displayHeader']) && $this->options['displayHeader'] == '1') {
$l[] = $this->_getHtmlHeader();
}
$l[] = '';
$l[] = $this->_widget->getBody();
$l[] = '
';
if (isset($this->options['displayStatus']) && $this->options['displayStatus'] == '1') {
$l[] = $this->_getHtmlStatus();
}
$l[] = $this->_getJavascriptConstants();
foreach ($this->_getJavascripts() as $script) {
$l[] = '';
}
$l[] = '';
return implode("\n", $l);
}
public function getStylesheets()
{
return $this->_getStylesheets();
}
private function _getFrameScript()
{
$l = array();
$proxies = array(
'ajax' => Zend_Registry::get('proxyEndpoint') . '/ajax',
'feed' => Zend_Registry::get('proxyEndpoint') . '/feed'
);
$l[] = sprintf('UWA.proxies = %s;', Zend_Json::encode($proxies));
if (isset($this->options['properties'])) {
foreach ($this->options['properties'] as $key => $value) {
if (isset($value)) {
$l[] = sprintf("widget.%s = %s;", $key, Zend_Json::encode($value));
}
}
}
if (isset($this->options['data']) && count($this->options['data'])) {
$l[] = sprintf("UWA.extend(widget.data, %s);", Zend_Json::encode($this->options['data']));
}
$script = $this->_widget->getScript();
if (!empty($script)) {
if (isset($this->options['uwaId'])) {
$l[] = sprintf("UWA.Scripts['%s'](widget);", $this->options['uwaId']);
} else {
$l[] = "UWA.script(widget);";
}
}
if (isset($this->options['ifproxyUrl'])) {
$l[] = sprintf("Environment.ifproxyUrl = %s;", Zend_Json::encode($this->options['ifproxyUrl']));
}
$l[] = "Environment.launchModule();";
return implode("\n", $l);
}
}