本文整理汇总了PHP中JDocument::render方法的典型用法代码示例。如果您正苦于以下问题:PHP JDocument::render方法的具体用法?PHP JDocument::render怎么用?PHP JDocument::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JDocument
的用法示例。
在下文中一共展示了JDocument::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* 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 = JFactory::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();
}
示例2: render
/**
* Render the document.
*
* @access public
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
* @return The rendered data
*/
function render($cache = false, $params = array())
{
// Instantiate feed renderer and set the mime encoding
require_once dirname(__FILE__) . DS . 'renderer' . DS . 'xml.php';
$renderer =& $this->loadRenderer('xml');
if (!is_a($renderer, 'JDocumentRenderer')) {
JError::raiseError(404, JText::_('Resource Not Found'));
}
$url = 'http://demo.fabrikar.com/index.php?option=com_fabrik&view=table&tableid=' . $this->tableid . '&format=raw&type=xml';
$url = htmlspecialchars($url, ENT_COMPAT, 'UTF-8');
$data = '<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>' . htmlspecialchars($this->author, ENT_COMPAT, 'UTF-8') . '</author>
<documentationURL>None</documentationURL>
<description>' . htmlspecialchars($this->description, ENT_COMPAT, 'UTF-8') . '</description>
<sampleQuery>SELECT * FROM {table} WHERE jos_fabrik_calendar_events___visualization_id_raw="0"</sampleQuery>
</meta>
<bindings>
<select itemPath="root.row" produces="XML">
<urls>
<url>' . $url . '</url>
</urls>
</select>
</bindings>
</table>';
// Render the feed
//$data .= $renderer->render();
parent::render();
return $data;
}
示例3: render
/**
* Render the document
*
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
*/
public function render($cache = false, $params = array())
{
// If no error object is set return null
if (!isset($this->_error)) {
return;
}
//Set the status header
JResponse::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']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system';
if (!file_exists($directory . DS . $template . DS . $file)) {
$template = 'system';
}
//set variables
$this->baseurl = JURI::base(true);
$this->template = $template;
$this->debug = isset($params['debug']) ? $params['debug'] : false;
$this->error = $this->_error;
// load
$data = $this->_loadTemplate($directory . DS . $template, $file);
parent::render();
return $data;
}
示例4: testRender
/**
* @todo Implement testRender().
*/
public function testRender()
{
$this->object = new JDocument();
$this->object->render();
$headers = JResponse::getHeaders();
$lastMod = false;
$contentType = false;
foreach ($headers as $header) {
if ($header['name'] == 'Last-Modified') {
$lastMod = $header;
}
if ($header['name'] == 'Content-Type') {
$contentType = $header;
}
}
$this->assertThat($lastMod, $this->equalTo(false));
$this->assertThat($contentType['value'], $this->equalTo('; charset=utf-8'));
$this->object->setModifiedDate('My date');
$this->object->setMimeEncoding('MyMimeType');
$this->object->setCharset('MyCharset');
$this->object->render();
$headers = JResponse::getHeaders();
$lastMod = false;
$contentType = false;
foreach ($headers as $header) {
if ($header['name'] == 'Last-Modified') {
$lastMod = $header;
}
if ($header['name'] == 'Content-Type') {
$contentType = $header;
}
}
$this->assertThat($lastMod['value'], $this->equalTo('My date'));
$this->assertThat($contentType['value'], $this->equalTo('mymimetype; charset=MyCharset'));
}
示例5: render
/**
* Render the document.
*
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
*
* @return The rendered data
*
* @since 3.1
*/
public function render($cache = false, $params = array())
{
JResponse::allowCache($cache);
JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
// Unfortunately, the exact syntax of the Content-Type header
// is not defined, so we have to try to be a bit clever here.
$contentType = $this->_mime;
if (stripos($contentType, 'json') === false) {
$contentType .= '+' . $this->_type;
}
$this->_mime = $contentType;
parent::render();
// Get the HAL object from the buffer.
$hal = $this->getBuffer();
// If required, change relative links to absolute.
if ($this->absoluteHrefs && is_object($hal) && isset($hal->_links)) {
// Adjust hrefs in the _links object.
$this->relToAbs($hal->_links);
// Adjust hrefs in the _embedded object (if there is one).
if (isset($hal->_embedded)) {
foreach ($hal->_embedded as $rel => $resources) {
foreach ($resources as $id => $resource) {
if (isset($resource->_links)) {
$this->relToAbs($resource->_links);
}
}
}
}
}
// Return it as a JSON string.
return json_encode($hal);
}
示例6: render
/**
* 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())
{
JResponse::allowCache(false);
JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
parent::render();
return $this->getBuffer();
}
示例7: render
/**
* 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();
JResponse::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.xml"', true);
return $this->getBuffer();
}
示例8: render
/**
* 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())
{
$app = JFactory::getApplication();
$app->allowCache(false);
$app->setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
parent::render();
return $this->getBuffer();
}
示例9: render
/**
* 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())
{
$app = JFactory::getApplication();
$app->allowCache(false);
if ($this->_mime == 'application/json') {
// Browser other than Internet Explorer < 10
$app->setHeader('Content-Disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
}
parent::render();
return $this->getBuffer();
}
示例10: render
/**
* Render the document.
*
* @access public
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
* @return The rendered data
*/
function render($cache = false, $params = array())
{
// Instantiate feed renderer and set the mime encoding
require_once dirname(__FILE__) . DS . 'renderer' . DS . 'xml.php';
$renderer =& $this->loadRenderer('xml');
if (!is_a($renderer, 'JDocumentRenderer')) {
JError::raiseError(404, JText::_('Resource Not Found'));
}
$data = '';
// Render the feed
$data .= $renderer->render();
parent::render();
return $data;
}
示例11: render
/**
* Render the document
*
* @access public
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
* @return The rendered data
*/
function render($cache = false, $params = array())
{
$app = JFactory::getApplication();
$input = $app->input;
$option = $input->get('option');
// Get the feed type
$type = $input->get('type', 'rss');
/*
* Cache TODO In later release
*/
$cache = 0;
$cache_time = 3600;
$cache_path = JPATH_BASE . '/cache';
// Set filename for rss feeds
$file = strtolower(str_replace('.', '', $type));
$file = $cache_path . '/' . $file . '_' . $option . '.xml';
// Instantiate feed renderer and set the mime encoding
$renderer =& $this->loadRenderer($type ? $type : 'rss');
if (!is_a($renderer, 'JDocumentRenderer')) {
throw new RuntimeException('Resource Not Found', 404);
}
$this->setMimeEncoding($renderer->getContentType());
// 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;
}
示例12: render
/**
* Render the document.
*
* @access public
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
* @return The rendered data
*/
function render($cache = false, $params = array())
{
$pdf =& $this->_engine;
// Set PDF Metadata
$pdf->SetCreator($this->getGenerator());
$pdf->SetTitle($this->getTitle());
$pdf->SetSubject($this->getDescription());
$pdf->SetKeywords($this->getMetaData('keywords'));
// Set PDF Header data
$pdf->setHeaderData('', 0, $this->getTitle(), $this->getHeader());
// Set PDF Header and Footer fonts
$lang =& JFactory::getLanguage();
$font = $lang->getPdfFontName();
$font = $font ? $font : 'freesans';
$pdf->setRTL($lang->isRTL());
$pdf->setHeaderFont(array($font, '', 10));
$pdf->setFooterFont(array($font, '', 8));
// Initialize PDF Document
$pdf->AliasNbPages();
$pdf->AddPage();
// Build the PDF Document string from the document buffer
$this->fixLinks();
$pdf->WriteHTML($this->getBuffer(), true);
$data = $pdf->Output('', 'S');
// Set document type headers
parent::render();
//JResponse::setHeader('Content-Length', strlen($data), true);
JResponse::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.pdf"', true);
//Close and output PDF document
return $data;
}
示例13: render
/**
* Render the document
*
* @access public
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
* @return The rendered data
*/
function render($cache = false, $params = array())
{
global $option;
// Get the feed type
$type = JRequest::getCmd('type', 'rss');
/*
* Cache TODO In later release
*/
$cache = 0;
$cache_time = 3600;
$cache_path = JPATH_BASE . DS . 'cache';
// set filename for rss feeds
$file = strtolower(str_replace('.', '', $type));
$file = $cache_path . DS . $file . '_' . $option . '.xml';
// Instantiate feed renderer and set the mime encoding
$renderer =& $this->loadRenderer($type ? $type : 'rss');
if (!is_a($renderer, 'JDocumentRenderer')) {
JError::raiseError(404, JText::_('Resource Not Found'));
}
$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;
}
示例14: render
/**
* Outputs the template to the browser.
*
* @access public
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
* @return The rendered data
*/
function render($caching = false, $params = array())
{
// check
$directory = isset($params['directory']) ? $params['directory'] : 'templates';
$template = JFilterInput::clean($params['template'], 'cmd');
$file = JFilterInput::clean($params['file'], 'cmd');
if (!file_exists($directory . DS . $template . DS . $file)) {
$template = 'system';
}
// Parse the template INI file if it exists for parameters and insert
// them into the template.
if (is_readable($directory . DS . $template . DS . 'params.ini')) {
$content = file_get_contents($directory . DS . $template . DS . 'params.ini');
$params = new JParameter($content);
}
// Load the language file for the template
$lang =& JFactory::getLanguage();
$lang->load('tpl_' . $template);
// Assign the variables
$this->template = $template;
$this->baseurl = JURI::base(true);
$this->params = $params;
// load
$data = $this->_loadTemplate($directory . DS . $template, $file);
// parse
$data = $this->_parseTemplate($data);
//output
parent::render();
return $data;
}
示例15: render
/**
* 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;
}