mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 03:09:58 +03:00
Merge 86ad01f208
into ee0d29a0e9
This commit is contained in:
commit
3fccfc39a3
3 changed files with 45 additions and 2 deletions
|
@ -58,6 +58,10 @@ if (!is_null($responseFormat))
|
|||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php');
|
||||
$encoder = new PwgJsonEncoder();
|
||||
break;
|
||||
case 'jsonalt':
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/jsonalt_encoder.php');
|
||||
$encoder = new PwgJsonAlternativeEncoder();
|
||||
break;
|
||||
case 'xmlrpc':
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php');
|
||||
$encoder = new PwgXmlRpcEncoder();
|
||||
|
@ -66,4 +70,4 @@ if (!is_null($responseFormat))
|
|||
$service->setEncoder($responseFormat, $encoder);
|
||||
}
|
||||
|
||||
set_make_full_url();
|
||||
set_make_full_url();
|
||||
|
|
38
include/ws_protocols/jsonalt_encoder.php
Normal file
38
include/ws_protocols/jsonalt_encoder.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This file is part of Piwigo. |
|
||||
// | |
|
||||
// | For copyright and license information, please view the COPYING.txt |
|
||||
// | file that was distributed with this source code. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
class PwgJsonAlternativeEncoder extends PwgResponseEncoder
|
||||
{
|
||||
function encodeResponse($response)
|
||||
{
|
||||
if ($response instanceof PwgError)
|
||||
{
|
||||
return json_encode(
|
||||
array(
|
||||
'stat' => 'fail',
|
||||
'err' => $response->code(),
|
||||
'message' => $response->message(),
|
||||
)
|
||||
);
|
||||
}
|
||||
parent::flattenResponse($response);
|
||||
return json_encode(
|
||||
array(
|
||||
'stat' => 'ok',
|
||||
'result' => $response,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function getContentType()
|
||||
{
|
||||
return 'application/json';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -133,7 +133,8 @@
|
|||
<label for='responseFormat'>Response format</label>
|
||||
<div class="select">
|
||||
<select id="responseFormat">
|
||||
<option value="json" selected>JSON</option>
|
||||
<option value="json" selected>JSON (test/plain)</option>
|
||||
<option value="jsonalt" selected>JSON (application/json)</option>
|
||||
<option value="rest" selected>REST (xml)</option>
|
||||
<option value="php">PHP serial</option>
|
||||
<option value="xmlrpc">XML RPC</option>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue