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/Desktop.php';
24
* Apple Dashboard Widgets Compiler.
26
abstract class Compiler_Desktop_W3c extends Compiler_Desktop
34
protected $_extension = 'zip';
41
protected $_mimeType = 'application/zip';
43
public function getHtml()
47
$l[] = '<?xml version="1.0" encoding="utf-8"?>';
48
$l[] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' .
49
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
50
$l[] = '<html xmlns="http://www.w3.org/1999/xhtml">';
52
$l[] = '<title>' . $this->_widget->getTitle() . '</title>';
53
$l[] = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
55
foreach ($this->_getStylesheets() as $stylesheet) {
56
$l[] = '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($stylesheet) . '"/>';
62
$l[] = $this->_getHtmlBody();
64
$l[] = $this->_getJavascriptConstants();
66
$javascripts = $this->_getJavascripts( array('platform' => $this->_platform) );
68
foreach ($javascripts as $script) {
69
$l[] = "<script type='text/javascript' src='" . htmlspecialchars($script) . "' charset='utf-8'/>";
72
$l[] = '<script type="text/javascript">';
73
$l[] = $this->_getScript();
76
if (isset($this->options['appendBody'])) {
77
$l[] = $this->options['appendBody'];
83
return implode("\n", $l);
86
private function _getHtmlBody()
90
$l[] = '<div class="module" id="wrapper">';
91
$l[] = $this->_getHtmlHeader();
92
$l[] = '<div id="contentWrapper">';
93
$l[] = '<div class="moduleContent" id="moduleContent">';
94
$l[] = $this->_widget->getBody();
96
$l[] = $this->_getHtmlStatus();
98
$l[] = '<div class="moduleFooter" id="moduleFooter"></div>';
101
return implode("\n", $l);
104
private function _getScript()
109
'ajax' => Zend_Registry::get('proxyEndpoint') . '/ajax',
110
'feed' => Zend_Registry::get('proxyEndpoint') . '/feed'
113
$l[] = sprintf('UWA.proxies = %s;', Zend_Json::encode($proxies));
115
$l[] = "var id = window.widget ? widget.identifier : Math.round(Math.random() * 1000);";
116
$l[] = "Environments[id] = new UWA.Environment();";
117
$l[] = "Widgets[id] = Environments[id].getModule();";
118
$l[] = "UWA.script(Widgets[id]);";
119
$l[] = "Environments[id].launchModule();";
121
return implode("\n", $l);
124
public function getFileName()
126
$filename = $this->getNormalizedTitle();
127
if (!empty($filename)) {
128
return $filename . '.' . $this->_extension;
130
return 'Widget' . '.' . $this->_extension;
134
public function getNormalizedTitle()
136
return $this->_widget->getTitle();
139
public function getFileMimeType()
141
return $this->_mimeType;
144
/*** ABSTRACT FUNCTIONS ***/
146
abstract protected function _getXmlManifest();