You are here

function lingotek_sync_endpoint in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.7 lingotek.sync.inc \lingotek_sync_endpoint()
  2. 7.3 lingotek.sync.inc \lingotek_sync_endpoint()
  3. 7.4 lingotek.sync.inc \lingotek_sync_endpoint()
  4. 7.5 lingotek.sync.inc \lingotek_sync_endpoint()
  5. 7.6 lingotek.sync.inc \lingotek_sync_endpoint()

The API endpoint for bulk translation management

1 string reference to 'lingotek_sync_endpoint'
lingotek_menu in ./lingotek.module
Implements hook_menu().

File

./lingotek.sync.inc, line 290
Content translation management and sync functions.

Code

function lingotek_sync_endpoint() {
  $parameters = array();
  $method = $_SERVER['REQUEST_METHOD'];
  $status = "200";
  $request = array(
    'method' => $method,
  );
  $response = array();
  switch ($method) {
    case 'GET':
      $request['parameters'] = $parameters = $_GET;
      $project_id = variable_get('lingotek_project', NULL);
      $request['doc_ids'] = $document_ids = isset($parameters['doc_ids']) ? array_map(function ($val) {
        return trim($val);
      }, explode(',', $parameters['doc_ids'])) : array();
      $api = LingotekApi::instance();
      $report = $api
        ->getProgressReport($project_id, $document_ids, TRUE);
      break;
    case 'POST':
    case 'PUT':
    case 'DELETE':
    default:
      parse_str(file_get_contents("php://input"), $parameters);
      $status = "405 Method Not Allowed";
      break;
  }
  return lingotek_json_output_cors($response, $status, array(
    'methods_allowed' => 'GET',
  ));
}