We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 0791d003 authored by Evan Prodromou's avatar Evan Prodromou

return Ajax-y XML on exceptions

parent 29a4bb4d
...@@ -83,6 +83,11 @@ class Action extends HTMLOutputter // lawsuit ...@@ -83,6 +83,11 @@ class Action extends HTMLOutputter // lawsuit
function prepare($argarray) function prepare($argarray)
{ {
$this->args =& common_copy_args($argarray); $this->args =& common_copy_args($argarray);
if ($this->boolean('ajax')) {
StatusNet::setAjax(true);
}
return true; return true;
} }
......
...@@ -68,7 +68,11 @@ class ErrorAction extends InfoAction ...@@ -68,7 +68,11 @@ class ErrorAction extends InfoAction
function showPage() function showPage()
{ {
if ($this->minimal) { if (StatusNet::isAjax()) {
$this->extraHeaders();
$this->ajaxErrorMsg();
exit();
} if ($this->minimal) {
// Even more minimal -- we're in a machine API // Even more minimal -- we're in a machine API
// and don't want to flood the output. // and don't want to flood the output.
$this->extraHeaders(); $this->extraHeaders();
...@@ -94,4 +98,27 @@ class ErrorAction extends InfoAction ...@@ -94,4 +98,27 @@ class ErrorAction extends InfoAction
function showNoticeForm() function showNoticeForm()
{ {
} }
/**
* Show an Ajax-y error message
*
* Goes back to the browser, where it's shown in a popup.
*
* @param string $msg Message to show
*
* @return void
*/
function ajaxErrorMsg()
{
$this->startHTML('text/xml;charset=utf-8', true);
$this->elementStart('head');
// TRANS: Page title after an AJAX error occurs on the send notice page.
$this->element('title', null, _('Ajax Error'));
$this->elementEnd('head');
$this->elementStart('body');
$this->element('p', array('id' => 'error'), $this->message);
$this->elementEnd('body');
$this->elementEnd('html');
}
} }
...@@ -31,6 +31,7 @@ class StatusNet ...@@ -31,6 +31,7 @@ class StatusNet
{ {
protected static $have_config; protected static $have_config;
protected static $is_api; protected static $is_api;
protected static $is_ajax;
protected static $plugins = array(); protected static $plugins = array();
/** /**
...@@ -230,6 +231,16 @@ class StatusNet ...@@ -230,6 +231,16 @@ class StatusNet
self::$is_api = $mode; self::$is_api = $mode;
} }
public function isAjax()
{
return self::$is_ajax;
}
public function setAjax($mode)
{
self::$is_ajax = $mode;
}
/** /**
* Build default configuration array * Build default configuration array
* @return array * @return array
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment