. */ require_once 'Compiler.php'; /** * UWA compilation utilities. */ class Compiler_Uwa extends Compiler { /** * Main rendering function. * * @return string */ public function render() { $style = $this->_widget->getStyle(); $script = $this->_widget->getCompressedScript(); $preferences = $this->_widget->getPreferences(); $l = array(); $l[] = ''; $l[] = ''; $l[] = ''; $l[] = ''; $l[] = '' . $this->_widget->getTitle() . ''; $l[] = ''; foreach ($this->_widget->getMetadata() as $key => $value) { $l[] = ''; } $l[] = ''; $coreLibrary = $this->_widget->getCoreLibrary(); $externalScripts = $this->_widget->getExternalScripts(); if (empty($externalScripts) ) { $library = 'http://' . NV_HOST . '/js/UWA/load.js.php?env=Standalone'; } else if ($coreLibrary == 'uwa') { $library = 'http://' . NV_HOST . '/js/c/UWA_Standalone.js'; } else if ($coreLibrary == 'uwa-mootools') { $library = 'http://' . NV_HOST . '/js/c/UWA_Standalone_Mootools.js'; } $l[] = ''; foreach ($externalScripts as $javascript) { $l[] = ''; } if (isset($preferences) && count($preferences) > 0) { $l[] = ''; foreach ($preferences as $pref) { $l[] = $this->_getPreferenceXml($pref); } $l[] = ''; } if (isset($style) && strlen($style) > 0) { $l[] = ''; } if (isset($script) && strlen($script) > 0) { $l[] = ''; } $l[] = ''; $l[] = ''; $l[] = $this->_widget->getBody(); $l[] = ''; $l[] = ''; return implode("\n", $l); } public function _getPreferenceXml($preference) { $preference = $preference->toArray(); $xml = " $value) { if ($key != "options") { $k = htmlspecialchars($key); $v = htmlspecialchars($value); $xml .= " $k=\"$v\""; } } switch ($preference['type']) { case 'list': $xml .= ">\n"; if (isset($preference['options']) && count($preference['options']) > 0) { foreach ($preference['options'] as $opt) { $xml .= sprintf("