Exemple #1
0
 public function render($cache = false, $params = array())
 {
     MResponse::allowCache(false);
     MResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
     parent::render();
     return $this->getBuffer();
 }
Exemple #2
0
 public function render($cache = false, $params = array())
 {
     // If no error object is set return null
     if (!isset($this->_error)) {
         return;
     }
     // Set the status header
     MResponse::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']) ? MFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system';
     if (!file_exists($directory . '/' . $template . '/' . $file)) {
         $template = 'system';
     }
     // Set variables
     $this->baseurl = MURI::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;
 }
Exemple #3
0
 protected static function createDocument()
 {
     $lang = self::getLanguage();
     // @deprecated 12.1 This will be removed in the next version
     $raw = MRequest::getBool('no_html');
     $type = MRequest::getWord('format', $raw ? 'raw' : 'html');
     $attributes = array('charset' => 'utf-8', 'lineend' => 'unix', 'tab' => '  ', 'language' => $lang->getTag(), 'direction' => $lang->isRTL() ? 'rtl' : 'ltr');
     return MDocument::getInstance($type, $attributes);
 }
Exemple #4
0
 public function render($cache = false, $params = array())
 {
     parent::render();
     MResponse::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.xml"', true);
     return $this->getBuffer();
 }
Exemple #5
0
 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;
 }
Exemple #6
0
 public function setBuffer($content, $options = array())
 {
     self::$_buffer = $content;
     return $this;
 }
Exemple #7
0
 public function render($cache = false, $params = array())
 {
     parent::render();
     return $this->getBuffer();
 }
Exemple #8
0
 public static function customErrorPage(&$error)
 {
     // Deprecation warning.
     MLog::add('MError::customErrorPage() is deprecated.', MLog::WARNING, 'deprecated');
     // Initialise variables.
     $app = MFactory::getApplication();
     $document = MDocument::getInstance('error');
     if ($document) {
         $config = MFactory::getConfig();
         // Get the current template from the application
         $template = $app->getTemplate();
         // Push the error object into the document
         $document->setError($error);
         // 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' && MFactory::getConfig()->get('offline') == 1) {
             MFactory::getApplication()->redirect('index.php');
         }
         @ob_end_clean();
         $document->setTitle(MText::_('Error') . ': ' . $error->get('code'));
         $data = $document->render(false, array('template' => $template, 'directory' => MPATH_THEMES, 'debug' => $config->get('debug')));
         // Failsafe to get the error displayed.
         if (empty($data)) {
             self::handleEcho($error, array());
         } else {
             // Do not allow cache
             MResponse::allowCache(false);
             MResponse::setBody($data);
             echo MResponse::toString();
         }
     } else {
         // Must echo the error since there is no document
         // This is a common use case for Command Line Interface applications.
         self::handleEcho($error, array());
     }
     $app->close(0);
 }