/** * Render the document. * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { Response::allowCache(false); Response::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true); parent::render(); return $this->getBuffer(); }
/** * Render the document. * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 12.1 */ public function render($cache = false, $params = array()) { // Get the image type $type = Factory::getApplication()->input->get('type', 'png'); switch ($type) { case 'jpg': case 'jpeg': $this->_mime = 'image/jpeg'; break; case 'gif': $this->_mime = 'image/gif'; break; case 'png': default: $this->_mime = 'image/png'; break; } $this->_charset = null; parent::render(); return $this->getBuffer(); }
/** * Render the document. * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { parent::render(); Response::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.xml"', true); return $this->getBuffer(); }
/** * Render the document * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return string The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { // If no error object is set return null if (!isset($this->_error)) { return; } // Set the status header Response::setHeader('status', $this->_error->getCode() . ' ' . str_replace("\n", ' ', $this->_error->getMessage())); $file = 'error.php'; // Check template $directory = isset($params['directory']) ? $params['directory'] : 'templates'; $template = isset($params['template']) ? FilterInput::getInstance()->clean($params['template'], 'cmd') : 'system'; if (!file_exists($directory . '/' . $template . '/' . $file)) { $template = 'system'; } // Set variables $this->baseurl = Uri::base(true); $this->template = $template; $this->debug = isset($params['debug']) ? $params['debug'] : false; $this->error = $this->_error; // Load $data = $this->_loadTemplate($directory . '/' . $template, $file); parent::render(); return $data; }
/** * Outputs the template to the browser. * * @param boolean $caching If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 11.1 */ public function render($caching = false, $params = array()) { $this->_caching = $caching; if (!empty($this->_template)) { $data = $this->_renderTemplate(); } else { $this->parse($params); $data = $this->_renderTemplate(); } parent::render(); return $data; }
/** * Render the document * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 11.1 * @throws Exception * @todo Make this cacheable */ public function render($cache = false, $params = array()) { // Get the feed type $type = Factory::getApplication()->input->get('type', 'rss'); // Instantiate feed renderer and set the mime encoding $renderer = $this->loadRenderer($type ? $type : 'rss'); if (!is_a($renderer, '\\Joomla\\Document\\Renderer')) { throw new Exception(Text::_('JGLOBAL_RESOURCE_NOT_FOUND'), 404); } $this->setMimeEncoding($renderer->getContentType()); // Output // Generate prolog $data = "<?xml version=\"1.0\" encoding=\"" . $this->_charset . "\"?>\n"; $data .= "<!-- generator=\"" . $this->getGenerator() . "\" -->\n"; // Generate stylesheet links foreach ($this->_styleSheets as $src => $attr) { $data .= "<?xml-stylesheet href=\"{$src}\" type=\"" . $attr['mime'] . "\"?>\n"; } // Render the feed $data .= $renderer->render(); parent::render(); return $data; }
/** * Create a document object * * @return Document object * * @see Document * @since 11.1 */ protected static function createDocument() { $lang = self::getLanguage(); $input = self::getApplication()->input; $type = $input->get('format', 'html', 'word'); $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => ' ', 'language' => $lang->getTag(), 'direction' => $lang->isRTL() ? 'rtl' : 'ltr'); return Document::getInstance($type, $attributes); }
/** * Generates the head HTML and return the results as a string * * @param JDocument $document The document for which the head will be created * * @return string The head hTML * * @since 11.1 */ public function fetchHead(Document $document) { // Trigger the onBeforeCompileHead event (skip for installation, since it causes an error) $app = Factory::getApplication(); $app->triggerEvent('onBeforeCompileHead'); // Get line endings $lnEnd = $document->_getLineEnd(); $tab = $document->_getTab(); $tagEnd = ' />'; $buffer = ''; // Generate charset when using HTML5 (should happen first) if ($document->isHtml5()) { $buffer .= $tab . '<meta charset="' . $document->getCharset() . '" />' . $lnEnd; } // Generate base tag (need to happen early) $base = $document->getBase(); if (!empty($base)) { $buffer .= $tab . '<base href="' . $document->getBase() . '" />' . $lnEnd; } // Generate META tags (needs to happen as early as possible in the head) foreach ($document->_metaTags as $type => $tag) { foreach ($tag as $name => $content) { if ($type == 'http-equiv' && !($document->isHtml5() && $name == 'content-type')) { $buffer .= $tab . '<meta http-equiv="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd; } elseif ($type == 'standard' && !empty($content)) { $buffer .= $tab . '<meta name="' . $name . '" content="' . htmlspecialchars($content) . '" />' . $lnEnd; } } } // Don't add empty descriptions $documentDescription = $document->getDescription(); if ($documentDescription) { $buffer .= $tab . '<meta name="description" content="' . htmlspecialchars($documentDescription) . '" />' . $lnEnd; } // Don't add empty generators $generator = $document->getGenerator(); if ($generator) { $buffer .= $tab . '<meta name="generator" content="' . htmlspecialchars($generator) . '" />' . $lnEnd; } $buffer .= $tab . '<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>' . $lnEnd; // Generate link declarations foreach ($document->_links as $link => $linkAtrr) { $buffer .= $tab . '<link href="' . $link . '" ' . $linkAtrr['relType'] . '="' . $linkAtrr['relation'] . '"'; if ($temp = ArrayHelper::toString($linkAtrr['attribs'])) { $buffer .= ' ' . $temp; } $buffer .= ' />' . $lnEnd; } // Generate stylesheet links foreach ($document->_styleSheets as $strSrc => $strAttr) { $buffer .= $tab . '<link rel="stylesheet" href="' . $strSrc . '" type="' . $strAttr['mime'] . '"'; if (!is_null($strAttr['media'])) { $buffer .= ' media="' . $strAttr['media'] . '" '; } if ($temp = ArrayHelper::toString($strAttr['attribs'])) { $buffer .= ' ' . $temp; } $buffer .= $tagEnd . $lnEnd; } // Generate stylesheet declarations foreach ($document->_style as $type => $content) { $buffer .= $tab . '<style type="' . $type . '">' . $lnEnd; // This is for full XHTML support. if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . '<![CDATA[' . $lnEnd; } $buffer .= $content . $lnEnd; // See above note if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . ']]>' . $lnEnd; } $buffer .= $tab . '</style>' . $lnEnd; } // Generate script file links foreach ($document->_scripts as $strSrc => $strAttr) { $buffer .= $tab . '<script src="' . $strSrc . '"'; if (!is_null($strAttr['mime'])) { $buffer .= ' type="' . $strAttr['mime'] . '"'; } if ($strAttr['defer']) { $buffer .= ' defer="defer"'; } if ($strAttr['async']) { $buffer .= ' async="async"'; } $buffer .= '></script>' . $lnEnd; } // Generate script declarations foreach ($document->_script as $type => $content) { $buffer .= $tab . '<script type="' . $type . '">' . $lnEnd; // This is for full XHTML support. if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . '<![CDATA[' . $lnEnd; } $buffer .= $content . $lnEnd; // See above note if ($document->_mime != 'text/html') { $buffer .= $tab . $tab . ']]>' . $lnEnd; } $buffer .= $tab . '</script>' . $lnEnd; } // Generate script language declarations. if (count(Text::script())) { $buffer .= $tab . '<script type="text/javascript">' . $lnEnd; $buffer .= $tab . $tab . '(function() {' . $lnEnd; $buffer .= $tab . $tab . $tab . 'var strings = ' . json_encode(Text::script()) . ';' . $lnEnd; $buffer .= $tab . $tab . $tab . 'if (typeof Joomla == \'undefined\') {' . $lnEnd; $buffer .= $tab . $tab . $tab . $tab . 'Joomla = {};' . $lnEnd; $buffer .= $tab . $tab . $tab . $tab . 'Joomla.JText = strings;' . $lnEnd; $buffer .= $tab . $tab . $tab . '}' . $lnEnd; $buffer .= $tab . $tab . $tab . 'else {' . $lnEnd; $buffer .= $tab . $tab . $tab . $tab . 'Joomla.JText.load(strings);' . $lnEnd; $buffer .= $tab . $tab . $tab . '}' . $lnEnd; $buffer .= $tab . $tab . '})();' . $lnEnd; $buffer .= $tab . '</script>' . $lnEnd; } foreach ($document->_custom as $custom) { $buffer .= $tab . $custom . $lnEnd; } return $buffer; }
/** * Render the document * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { $xml = new DOMDocument('1.0', 'utf-8'); if (defined('JDEBUG') && JDEBUG) { $xml->formatOutput = true; } // The OpenSearch Namespace $osns = 'http://a9.com/-/spec/opensearch/1.1/'; // Create the root element $elOs = $xml->createElementNS($osns, 'OpenSearchDescription'); $elShortName = $xml->createElementNS($osns, 'ShortName'); $elShortName->appendChild($xml->createTextNode(htmlspecialchars($this->_shortName))); $elOs->appendChild($elShortName); $elDescription = $xml->createElementNS($osns, 'Description'); $elDescription->appendChild($xml->createTextNode(htmlspecialchars($this->description))); $elOs->appendChild($elDescription); // Always set the accepted input encoding to UTF-8 $elInputEncoding = $xml->createElementNS($osns, 'InputEncoding'); $elInputEncoding->appendChild($xml->createTextNode('UTF-8')); $elOs->appendChild($elInputEncoding); foreach ($this->_images as $image) { $elImage = $xml->createElementNS($osns, 'Image'); $elImage->setAttribute('type', $image->type); $elImage->setAttribute('width', $image->width); $elImage->setAttribute('height', $image->height); $elImage->appendChild($xml->createTextNode(htmlspecialchars($image->data))); $elOs->appendChild($elImage); } foreach ($this->_urls as $url) { $elUrl = $xml->createElementNS($osns, 'Url'); $elUrl->setAttribute('type', $url->type); // Results is the default value so we don't need to add it if ($url->rel != 'results') { $elUrl->setAttribute('rel', $url->rel); } $elUrl->setAttribute('template', $url->template); $elOs->appendChild($elUrl); } $xml->appendChild($elOs); parent::render(); return $xml->saveXML(); }