Change API format
This commit is contained in:
+14
-7
@@ -13,9 +13,9 @@ abstract class Main extends PhpObject
|
||||
//Constants
|
||||
const SUCCESS = 'success';
|
||||
const ERROR = 'error';
|
||||
const UNAUTHORIZED = 'unauthorized';
|
||||
const NOT_FOUND = 'unknown action';
|
||||
const NO_DATA = 'No Data';
|
||||
const UNAUTHORIZED = 'error.no_auth';
|
||||
const NOT_FOUND = 'error.not_found';
|
||||
const NO_DATA = 'error.no_data';
|
||||
|
||||
const ACTIVE = 1;
|
||||
const INACTIVE = 0;
|
||||
@@ -147,16 +147,23 @@ abstract class Main extends PhpObject
|
||||
|
||||
protected abstract function getSqlOptions();
|
||||
|
||||
public static function getJsonResult($bSuccess, $sDesc, $asVars=array())
|
||||
public static function getJsonResult($bSuccess, $sLangId='', $asVars=array(), $asLangParams=array())
|
||||
{
|
||||
header('Content-type: application/json');
|
||||
$asResult = self::getResult($bSuccess, $sDesc, $asVars);
|
||||
|
||||
$asResult = self::getResult($bSuccess, $sLangId, $asVars, $asLangParams);
|
||||
$asResult['result'] = $asResult['result']?self::SUCCESS:self::ERROR;
|
||||
|
||||
return json_encode($asResult);
|
||||
}
|
||||
|
||||
public static function getResult($bSuccess, $sDesc, $asVars=array()) {
|
||||
return array('result'=>$bSuccess, 'desc'=>$sDesc, 'data'=>$asVars);
|
||||
public static function getResult($bSuccess, $sLangId='', $asVars=array(), $asLangParams=array()) {
|
||||
return array(
|
||||
'result' => $bSuccess,
|
||||
'data' => $asVars,
|
||||
'desc_lang_id' => $sLangId,
|
||||
'desc_lang_params' => $asLangParams
|
||||
);
|
||||
}
|
||||
|
||||
public static function goTo403() {
|
||||
|
||||
Reference in New Issue
Block a user