Пример #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();
 }
Пример #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;
 }
Пример #3
0
 public function __toString()
 {
     $compress = $this->getCfg('gzip', false);
     return MResponse::toString($compress);
 }
Пример #4
0
 public function render($cache = false, $params = array())
 {
     parent::render();
     MResponse::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.xml"', true);
     return $this->getBuffer();
 }
Пример #5
0
 protected function _setEtag($etag)
 {
     MResponse::setHeader('ETag', $etag, true);
 }
Пример #6
0
 public static function setBody($content)
 {
     self::$body = array((string) $content);
 }
Пример #7
0
 public function render($cache = false, $params = array())
 {
     if ($mdate = $this->getModifiedDate()) {
         MResponse::setHeader('Last-Modified', $mdate);
     }
     MResponse::setHeader('Content-Type', $this->_mime . ($this->_charset ? '; charset=' . $this->_charset : ''));
 }
Пример #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);
 }