/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->get('page_heading', $this->params->get('page_title', $menu->title)); } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } $this->document->setTitle($title); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } }
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = NULL; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } $title = $this->params->get('page_title', ''); $title .= " - " . JText::_('COM_EVENTGALLERY_ORDERS_PATH'); // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } if ($this->document) { $this->document->setTitle($title); } }
/** * 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 fetchScripts($document) { // Trigger the onBeforeCompileHead event $app = JFactory::getApplication(); // Get line endings $lnEnd = $document->_getLineEnd(); $tab = $document->_getTab(); $tagEnd = ' />'; $buffer = ''; if ($disabled_scripts_list = $document->params->get('disabled_scripts_list', '')) { $disable_scripts = preg_split("#\n" . '|' . "\r\n#", $disabled_scripts_list); } // Generate script file links foreach ($document->_scripts as $strSrc => $strAttr) { if (!in_array($strSrc, $disable_scripts)) { $buffer .= $tab . '<script src="' . $strSrc . '"'; $defaultMimes = array('text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript'); if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultMimes))) { $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(JText::script())) { $buffer .= $tab . '<script type="text/javascript">' . $lnEnd; $buffer .= $tab . $tab . '(function() {' . $lnEnd; $buffer .= $tab . $tab . $tab . 'var strings = ' . json_encode(JText::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; } return $buffer; }
/** * Adds the map javascript to the document */ protected function mapJS(JDocument $document) { // Add map interface Javascript JHtml::_('behavior.framework', true); $document->addScript('/libraries/openlayers/OpenLayers.debug.js'); $document->addScript('/swg/js/maps.js'); $document->addScript('/swg/js/events.js'); }
/** * Generates the javascript HTML and return the results as a string * * @param JDocument $document The document for which the javascript will be created * * @return string The javascript hTML * * @since 11.1 */ public function fetchJs($document) { // Get line endings $lnEnd = $document->_getLineEnd(); $tab = $document->_getTab(); $buffer = ''; // Generate script file links foreach ($document->_scripts as $strSrc => $strAttr) { $buffer .= $tab . '<script src="' . $strSrc . '"'; $defaultMimes = array('text/javascript', 'application/javascript', 'text/x-javascript', 'application/x-javascript'); if (!is_null($strAttr['mime']) && (!$document->isHtml5() || !in_array($strAttr['mime'], $defaultMimes))) { $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(JText::script())) { $buffer .= $tab . '<script type="text/javascript">' . $lnEnd; $buffer .= $tab . $tab . '(function() {' . $lnEnd; $buffer .= $tab . $tab . $tab . 'var strings = ' . json_encode(JText::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 error page based on an exception. * * @param Exception $error The exception for which to render the error page. * * @return void * * @since 3.0 */ public static function render(Exception $error) { try { $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); if (!$document) { // We're probably in an CLI environment jexit($error->getMessage()); } // Get the current template from the application $template = $app->getTemplate(); // Push the error object into the document $document->setError($error); if (ob_get_contents()) { ob_end_clean(); } $document->setTitle(JText::_('Error') . ': ' . $error->getCode()); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => JDEBUG)); // Do not allow cache $app->allowCache(false); // If nothing was rendered, just use the message from the Exception if (empty($data)) { $data = $error->getMessage(); } $app->setBody($data); echo $app->toString(); } catch (Exception $e) { // Try to set a 500 header if they haven't already been sent if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); } jexit('Error displaying the error page: ' . $e->getMessage() . ': ' . $error->getMessage()); } }
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = NULL; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } $title = $this->params->get('page_title', ''); if ($this->folder->getDisplayName()) { $title = $this->folder->getDisplayName(); } // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } if (empty($title)) { $title = $this->folder->getDisplayName(); } $this->document->setTitle($title); if ($this->folder->getText()) { $this->document->setDescription($this->folder->getText()); } elseif (!$this->folder->getText() && $this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } }
/** * Resets the document type to format=raw * * @return void * @since 0.1 * @todo Figure out if there is a better way to do this */ private function resetDocumentType() { $document =& JFactory::getDocument(); $raw =& JDocument::getInstance('raw'); $document = $raw; JResponse::clearHeaders(); }
function display() { $doDisplay = true; // Set a default view if none exists if (!JRequest::getCmd('view')) { JRequest::setVar('view', 'tickets'); } // Handle displaying an attachment if (JRequest::getCmd('view') == 'attachment') { $model = $this->getModel('attachment'); $result = $model->download(JRequest::getVar('ArticleID', '', '', 'integer'), JRequest::getVar('AtmID', '', '', 'integer')); if (array_key_exists('data', $result)) { $document =& JFactory::getDocument(); $doc =& JDocument::getInstance('raw'); $document = $doc; JResponse::clearHeaders(); $document->setMimeEncoding($result['data']->ContentType); JResponse::setHeader('Content-length', $result['data']->FilesizeRaw, true); $fn = preg_replace('/"/', '\\"', $result['data']->Filename); JResponse::setHeader('Content-disposition', sprintf('attachment;filename="%s"', $fn), true); $document->render(); echo $result['data']->Content; $doDisplay = false; } } if ($doDisplay) { parent::display(); } }
public function populate() { if (!empty($this->script_files)) { ksort($this->script_files); foreach ($this->script_files as $order => $order_entries) { foreach ($order_entries as $entry_key => $entry) { $this->document->addScript($entry); } } } if (!empty($this->inline_scripts)) { ksort($this->inline_scripts); foreach ($this->inline_scripts as $order => $order_entries) { foreach ($order_entries as $entry_key => $entry) { $this->document->addScriptDeclaration($entry); } } } if (!empty($this->style_files)) { ksort($this->style_files); foreach ($this->style_files as $order => $order_entries) { foreach ($order_entries as $entry_key => $entry) { $this->document->addStyleSheet($entry); } } } if (!empty($this->inline_styles)) { ksort($this->inline_styles); foreach ($this->inline_styles as $order => $order_entries) { foreach ($order_entries as $entry_key => $entry) { $this->document->addStyleDeclaration($entry); } } } // Generate domready script if (!empty($this->domready_scripts)) { ksort($this->domready_scripts); $strHtml = 'window.addEvent(\'domready\', function() {'; foreach ($this->domready_scripts as $order => $order_entries) { foreach ($order_entries as $entry_key => $entry) { $strHtml .= chr(13) . $entry; } } $strHtml .= chr(13) . '});' . chr(13); $this->document->addScriptDeclaration($strHtml); } if (!empty($this->loadevent_scripts)) { ksort($this->loadevent_scripts); $strHtml = 'window.addEvent(\'load\', function() {'; foreach ($this->loadevent_scripts as $order => $order_entries) { foreach ($order_entries as $entry_key => $entry) { $strHtml .= chr(13) . $entry; } } $strHtml .= chr(13) . '});' . chr(13); $this->document->addScriptDeclaration($strHtml); } $this->populated = true; $this->reset(); }
/** * 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); }
/** * Tests JHtml::calendar() method with and without 'readonly' attribute. */ public function testCalendar() { // Create a world for the test jimport('joomla.session.session'); jimport('joomla.application.application'); jimport('joomla.document.document'); $cfg = new JObject(); JFactory::$session = $this->getMock('JSession', array('_start')); JFactory::$application = $this->getMock('ApplicationMock'); JFactory::$config = $cfg; JFactory::$application->expects($this->any())->method('getTemplate')->will($this->returnValue('atomic')); $cfg->live_site = 'http://example.com'; $cfg->offset = 'Europe/Kiev'; $_SERVER['HTTP_USER_AGENT'] = 'Test Browser'; // two sets of test data $test_data = array('date' => '2010-05-28 00:00:00', 'friendly_date' => 'Friday, 28 May 2010', 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d', 'attribs' => array()); $test_data_ro = array_merge($test_data, array('attribs' => array('readonly' => 'readonly'))); foreach (array($test_data, $test_data_ro) as $data) { // Reset the document JFactory::$document = JDocument::getInstance('html', array('unique_key' => serialize($data))); $input = JHtml::calendar($data['date'], $data['name'], $data['id'], $data['format'], $data['attribs']); $this->assertEquals((string) $xml->input['title'], $data['friendly_date'], 'Line:' . __LINE__ . ' The calendar input should have `title == "' . $data['friendly_date'] . '"`'); $this->assertEquals((string) $xml->input['name'], $data['name'], 'Line:' . __LINE__ . ' The calendar input should have `name == "' . $data['name'] . '"`'); $this->assertEquals((string) $xml->input['id'], $data['id'], 'Line:' . __LINE__ . ' The calendar input should have `id == "' . $data['id'] . '"`'); $head_data = JFactory::getDocument()->getHeadData(); if (!isset($data['attribs']['readonly']) || !$data['attribs']['readonly'] === 'readonly') { $this->assertArrayHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" should be loaded'); $this->assertArrayHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" should be loaded'); } } }
/** * 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(); }
/** * 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; }
/** * Sets direction 'ltr' or 'rtl' for global document * * @param string $textDirection 'ltr' for left-to-right or 'rtl' for right-to-left texts globally on the page */ public function setDirection($textDirection = 'ltr') { if ($this->_cmsDoc) { $this->_cmsDoc->setDirection($textDirection); } $this->_direction = $textDirection; }
/** * 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(); }
/** * Submits a bug report to Dioscouri. * Thanks so much! They really help improve the product! */ function sendBug() { $mainframe = JFactory::getApplication(); $body = JRequest::getVar('body'); $name = JRequest::getVar('title'); $body .= "\n\n Project: tienda"; $body .= "\n Tracker: Bug"; $body .= "\n Affected Version: " . Tienda::getVersion(); $doc = JDocument::getInstance('raw'); ob_start(); $option = JRequest::getCmd('option'); $db = JFactory::getDBO(); $path = JPATH_ADMINISTRATOR . '/components/com_admin/'; require_once $path . 'admin.admin.html.php'; $path .= 'tmpl/'; require_once $path . 'sysinfo_system.php'; require_once $path . 'sysinfo_directory.php'; require_once $path . 'sysinfo_phpinfo.php'; require_once $path . 'sysinfo_phpsettings.php'; require_once $path . 'sysinfo_config.php'; jimport('joomla.filesystem.file'); $contents = ob_get_contents(); ob_end_clean(); $doc->setBuffer($contents); $contents = $doc->render(); $sitename = $config->get('sitename', $mainframe->getCfg('sitename')); // write file with info $config = JFactory::getConfig(); $filename = 'system_info_' . $sitename . '.html'; $file = JPATH_SITE . '/tmp/' . $filename; JFile::write($file, $contents); $mailer = JFactory::getMailer(); $success = false; // For now, bug submission goes to info@dioscouri.com, // but in the future, it will go to projects@dioscouri.com // (once we get the Redmine auto-create working properly // and format the subject/body of the email properly) $mailer->addRecipient('*****@*****.**'); $mailer->setSubject($name); $mailfrom = $config->get('emails_defaultemail', $mainframe->getCfg('mailfrom')); $fromname = $config->get('emails_defaultname', $mainframe->getCfg('fromname')); // check user mail format type, default html $mailer->setBody($body); $mailer->addAttachment($file); $sender = array($mailfrom, $fromname); $mailer->setSender($sender); $sent = $mailer->send(); if ($sent == '1') { $success = true; } JFile::delete($file); if ($success) { $msg = JText::_('COM_TIENDA_BUG_SUBMIT_OK'); $msgtype = 'message'; } else { $msg = JText::_('COM_TIENDA_BUG_SUBMIT_FAIL'); $msgtype = 'notice'; } $mainframe->redirect(JRoute::_('index.php?option=com_tienda&view=dashboard'), $msg, $msgtype); }
/** * 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(); }
/** * @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')); }
/** * Render the error page based on an exception. * * @param Exception $error The exception for which to render the error page. * * @return void * * @since 3.0 */ public static function render(Exception $error) { try { $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); if (!$document) { // We're probably in an CLI environment exit($error->getMessage()); $app->close(0); } $config = JFactory::getConfig(); // Get the current template from the application $template = $app->getTemplate(); // Push the error object into the document $document->setError($error); if (ob_get_contents()) { ob_end_clean(); } $document->setTitle(JText::_('Error') . ': ' . $error->getCode()); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug'))); // Failsafe to get the error displayed. if (empty($data)) { exit($error->getMessage()); } else { // Do not allow cache $app->allowCache(false); $app->setBody($data); echo $app->toString(); } } catch (Exception $e) { exit('Error displaying the error page: ' . $e->getMessage() . ': ' . $error->getMessage()); } }
/** * Register the API server. * * @throws \Exception * @return boolean */ public function register() { $uri = \JURI::getInstance(); if (!$this->isApi()) { return false; } $app = \JFactory::getApplication(); $input = $app->input; // Restore Joomla handler and using our Json handler. JsonResponse::registerErrorHandler(); // Authentication if (!$this->isUserOperation($uri) && $this->option['authorise']) { if (!Authentication::authenticate($input->get('session_key'))) { throw new \Exception(\JText::_('JERROR_ALERTNOAUTHOR'), 403); } } // Set Format to JSON $input->set('format', 'json'); // Store JDocumentJson to Factory \JFactory::$document = \JDocument::getInstance('json'); $router = $app::getRouter(); // Attach a hook to Router $router->attachParseRule(array($this, 'parseRule')); return true; }
/** * 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; }
/** * 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(); }
/** * Render the error page based on an exception. * * @param Exception|Throwable $error An Exception or Throwable (PHP 7+) object for which to render the error page. * * @return void * * @since 3.0 */ public static function render($error) { $expectedClass = PHP_MAJOR_VERSION >= 7 ? 'Throwable' : 'Exception'; $isException = $error instanceof $expectedClass; // In PHP 5, the $error object should be an instance of Exception; PHP 7 should be a Throwable implementation if ($isException) { try { // If site is offline and it's a 404 error, just go to index (to see offline message, instead of 404) if ($error->getCode() == '404' && JFactory::getConfig()->get('offline') == 1) { JFactory::getApplication()->redirect('index.php'); } $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); if (!$document) { // We're probably in an CLI environment jexit($error->getMessage()); } // Get the current template from the application $template = $app->getTemplate(); // Push the error object into the document $document->setError($error); if (ob_get_contents()) { ob_end_clean(); } $document->setTitle(JText::_('Error') . ': ' . $error->getCode()); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => JDEBUG)); // Do not allow cache $app->allowCache(false); // If nothing was rendered, just use the message from the Exception if (empty($data)) { $data = $error->getMessage(); } $app->setBody($data); echo $app->toString(); $app->close(0); // This return is needed to ensure the test suite does not trigger the non-Exception handling below return; } catch (Throwable $e) { // Pass the error down } catch (Exception $e) { // Pass the error down } } // This isn't an Exception, we can't handle it. if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); } $message = 'Error displaying the error page'; if ($isException) { $message .= ': '; if (isset($e)) { $message .= $e->getMessage() . ': '; } $message .= $error->getMessage(); } echo $message; jexit(1); }
/** * Render the error page based on an exception. * * @param object $error An Exception or Throwable (PHP 7+) object for which to render the error page. * * @return void * * @since 3.0 */ public static function render($error) { $expectedClass = PHP_MAJOR_VERSION >= 7 ? 'Throwable' : 'Exception'; $isException = $error instanceof $expectedClass; // In PHP 5, the $error object should be an instance of Exception; PHP 7 should be a Throwable implementation if ($isException) { try { $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); $code = $error->getCode(); if (!isset(JHttpResponse::$status_messages[$code])) { $code = '500'; } if (ini_get('display_errors')) { $message = $error->getMessage(); } else { $message = JHttpResponse::$status_messages[$code]; } if (!$document || PHP_SAPI == 'cli') { // We're probably in an CLI environment jexit($message); } // Get the current template from the application $template = $app->getTemplate(); // Push the error object into the document $document->setError($error); if (ob_get_contents()) { ob_end_clean(); } $document->setTitle(JText::_('Error') . ': ' . $code); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => JFactory::getConfig()->get('debug'))); // Do not allow cache $app->allowCache(false); // If nothing was rendered, just use the message from the Exception if (empty($data)) { $data = $message; } $app->setBody($data); echo $app->toString(); return; } catch (Exception $e) { // Pass the error down } } // This isn't an Exception, we can't handle it. if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); } $message = 'Error displaying the error page'; if ($isException) { $message .= ': ' . $e->getMessage() . ': ' . $message; } echo $message; jexit(1); }
function ezStream() { $options = array('margin-header' => 5, 'margin-footer' => 10, 'margin-top' => 20, 'margin-bottom' => 20, 'margin-left' => 15, 'margin-right' => 15); $pdfDoc =& JDocument::getInstance('pdf', $options); $pdfDoc->setTitle($this->_title); $pdfDoc->setHeader($this->_header); $pdfDoc->setBuffer($this->_text); header('Content-Type: application/pdf'); header('Content-disposition: inline; filename="file.pdf"', true); echo $pdfDoc->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(); }
/** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->get('page_heading', $this->params->get('page_title', $menu->title)); } $title = $this->params->get('page_title', ''); // checks for empty title or sets the category title if // the current menu item has a different catid than the current catid is if (empty($title) || isset($menu->query['catid']) && $this->catid != $menu->query['catid']) { $title = $this->category->title; } if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } $this->document->setTitle($title); if (!empty($this->category->metadesc)) { $this->document->setDescription($this->category->metadesc); } else { if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } } if (!empty($this->category->metadesc)) { $this->document->setMetadata('keywords', $this->category->metakey); } else { if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } } $robots = $this->category->getMetadata()->get('robots'); if (!empty($robots)) { $this->document->setMetadata('robots', $robots); } else { if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } /** * @var JPathway $pathway */ $pathway = $app->getPathway(); }
/** * Sets the document title according to Global Configuration options * * @param string $title The page title * * @return void * * @since 3.6 */ public function setDocumentTitle($title) { $app = JFactory::getApplication(); // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->get('sitename'); } elseif ($app->get('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); } $this->document->setTitle($title); }
/** * 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; }