. */ require_once 'Compiler/Desktop.php'; /** * Apple Dashboard Widgets Compiler. */ abstract class Compiler_Desktop_W3c extends Compiler_Desktop { /** * Extension. * * @var string */ protected $_extension = 'zip'; /** * Mime Type. * * @var string */ protected $_mimeType = 'application/zip'; public function getHtml() { $l = array(); $l[] = ''; $l[] = ''; $l[] = ''; $l[] = ''; $l[] = '' . $this->_widget->getTitle() . ''; $l[] = ''; foreach ($this->_getStylesheets() as $stylesheet) { $l[] = ''; } $l[] = ''; $l[] = ''; $l[] = $this->_getHtmlBody(); $l[] = $this->_getJavascriptConstants(); $javascripts = $this->_getJavascripts( array('platform' => $this->_platform) ); foreach ($javascripts as $script) { $l[] = "'; if (isset($this->options['appendBody'])) { $l[] = $this->options['appendBody']; } $l[] = ''; $l[] = ''; return implode("\n", $l); } private function _getHtmlBody() { $l = array(); $l[] = '
'; $l[] = $this->_getHtmlHeader(); $l[] = '
'; $l[] = '
'; $l[] = $this->_widget->getBody(); $l[] = '
'; $l[] = $this->_getHtmlStatus(); $l[] = '
'; $l[] = '
'; $l[] = '
'; return implode("\n", $l); } private function _getScript() { $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)); $l[] = "var id = window.widget ? widget.identifier : Math.round(Math.random() * 1000);"; $l[] = "Environments[id] = new UWA.Environment();"; $l[] = "Widgets[id] = Environments[id].getModule();"; $l[] = "UWA.script(Widgets[id]);"; $l[] = "Environments[id].launchModule();"; return implode("\n", $l); } public function getFileName() { $filename = $this->getNormalizedTitle(); if (!empty($filename)) { return $filename . '.' . $this->_extension; } else { return 'Widget' . '.' . $this->_extension; } } public function getNormalizedTitle() { return $this->_widget->getTitle(); } public function getFileMimeType() { return $this->_mimeType; } /*** ABSTRACT FUNCTIONS ***/ abstract protected function _getXmlManifest(); }