setGadget($gadget); // Was a privacy policy header configured? if so set it if (Config::get('P3P') != '') { header("P3P: " . Config::get('P3P')); } $content = ''; // Set no doctype if quirks mode is requestet because of quirks or doctype attribute if ((isset($view['quirks']) && $view['quirks']) || $gadget->useQuirksMode()) { } else { // Override & insert DocType if Gadget is written for OpenSocial 2.0 or greater, // if quirksmode is not set $version20 = new OpenSocialVersion('2.0.0'); if ($gadget->getDoctype()) { $content .= "getDoctype() . "\n"; } else if ($gadget->getSpecificationVersion()->isEqualOrGreaterThan($version20)) { $content .= "\n"; } else { // prior to 2.0 the php version always set this doc type, when no quirks attribute was specified $content .= "\n"; } } // Rewriting the gadget's content using the libxml library does impose some restrictions to the validity of the input html, so // for the time being (until either gadgets are all fixed, or we find a more tolerant html parsing lib), we try to avoid it when we can $domRewrite = false; if (isset($gadget->gadgetSpec->rewrite) || Config::get('rewrite_by_default')) { $domRewrite = true; } elseif ((strpos($view['content'], 'text/os-data') !== false || strpos($view['content'], 'text/os-template') !== false) && ($gadget->gadgetSpec->templatesDisableAutoProcessing == false)) { $domRewrite = true; } if (!$domRewrite) { // Manually generate the html document using basic string concatinations instead of using our DOM based functions $content .= "\n\n\n"; $content .= '\n"; $scripts = $this->getJavaScripts(); foreach ($scripts as $script) { if ($script['type'] == 'inline') { $content .= "\n"; } else { $content .= "\n"; } } $content .= "\n\n"; $content .= $gadget->substitutions->substitute($view['content']); $content .= '\n"; $content .= "\n\n\n"; } else { // Use the (libxml2 based) DOM rewriter $content .= "\n"; // Append the content for the selected view $content .= $gadget->substitutions->substitute($view['content']); $content .= "\n\n"; $content = $this->parseTemplates($content); $content = $this->rewriteContent($content); $content = $this->addTemplates($content); } echo $content; } }