SHINDIG-1056 by lipeng, BasicRemoteContentTest doesn't depend on static private key...
[shindig.git] / php / src / gadgets / render / GadgetHtmlRenderer.php
blob4a47103cfd67aa55ee1f028a9cb5159d50e6354b
1 <?php
2 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
21 require 'GadgetBaseRenderer.php';
23 /**
24 * Renders a Gadget's Content type="html" view, inlining the content, feature javascript and javascript initialization
25 * into the gadget's content. Most of the logic is performed with in the shared GadgetBaseRender class
28 class GadgetHtmlRenderer extends GadgetBaseRenderer {
30 public function renderGadget(Gadget $gadget, $view) {
31 $this->setGadget($gadget);
32 // Was a privacy policy header configured? if so set it
33 if (Config::get('P3P') != '') {
34 header("P3P: " . Config::get('P3P'));
36 $content = '';
37 // Set doctype if quirks = false or empty in the view
38 if (! empty($view['quirks']) || ! $view['quirks']) {
39 $content .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n";
41 $content .= "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>\n";
42 // Append the content for the selected view
43 $content .= $gadget->substitutions->substitute($view['content']);
44 $content .= "\n</body>\n</html>";
45 $content = $this->parseTemplates($content);
46 $content = $this->rewriteContent($content);
47 $content = $this->addTemplates($content);
48 echo $content;