function lingotek_json_output_cors in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lingotek.util.inc \lingotek_json_output_cors()
- 7.2 lingotek.util.inc \lingotek_json_output_cors()
- 7.3 lingotek.util.inc \lingotek_json_output_cors()
- 7.5 lingotek.util.inc \lingotek_json_output_cors()
- 7.6 lingotek.util.inc \lingotek_json_output_cors()
Drupal JSON Output - CORS - allows cross domain requests (adapted from: drupal_json_output)
Parameters
type $var:
3 calls to lingotek_json_output_cors()
- lingotek_dashboard_command_ajax in ./
lingotek.dashboard.inc - Ajax Command Processing for the Lingotek dashboard.
- lingotek_sync in ./
lingotek.sync.inc - The main function responsible for syncing node/document translation.
- lingotek_sync_endpoint in ./
lingotek.sync.inc - The API endpoint for bulk translation management
File
- ./
lingotek.util.inc, line 13 - Utility functions.
Code
function lingotek_json_output_cors($var = NULL, $status = "200", $params = array()) {
// We are returning JSON, so tell the browser.
$methods_allowed = isset($params['methods_allowed']) ? $params['methods_allowed'] : 'GET,PUT,POST,DELETE';
drupal_add_http_header('Status', $status);
drupal_add_http_header('Content-Type', 'application/json');
drupal_add_http_header('Access-Control-Allow-Origin', "*");
drupal_add_http_header('Access-Control-Allow-Methods', $methods_allowed);
drupal_add_http_header('Access-Control-Allow-Headers', 'Content-Type');
drupal_add_http_header('X-Powered-By', 'Lingotek');
if (isset($var)) {
echo drupal_json_encode($var);
}
}