You are here

function lingotek_get_dashboard_code in Lingotek Translation 7.2

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

Generates the code for the embedded Javascript dashboard.

1 call to lingotek_get_dashboard_code()
lingotek_dashboard in ./lingotek.dashboard.inc
Tab: Dashboard - The main Lingotek dashboard page.

File

./lingotek.dashboard.inc, line 66
Lingotek Dashboard.

Code

function lingotek_get_dashboard_code() {
  global $base_url;
  $output = '';
  $totals = array();
  $guid = lingotek_get_guid();

  // 16 char string

  //$active_languages = lingotek_get_active_languages();  // array of enabled Drupal language codes (from locale module)
  $target_languages = LingotekAccount::instance()
    ->getManagedTargets(TRUE);
  $totals = lingotek_get_target_status();
  $script = '
      <script src="' . LINGOTEK_GMC_SERVER . '/js/lingotek.min.js"></script>
      <script>
        require(["lingotek"],function(lingotek){
        var containerId = "dashboard";
        var config = {
          // lingotek
          "community": "%s",
          "oauth_key": "%s",
          "oauth_secret": "%s",
          "external_id": "%s",
          "tm_vault_id": "%s",
          "workflow_id": "%s",
          "project_id": "%s",
          "first_name": "%s",
          "last_name": "%s",
          "email": "%s",
          // cms
          "cms_site_id": "%s",
          "cms_site_key": "%s",
          "cms_site_name": "%s",
          "cms_type": "%s",
          "cms_version": "%s",
          "cms_tag": "%s",
          "module_version": %s,
          "endpoint_url": "%s",
          "upload_url": "%s",
          "download_url": "%s",
          "sync_url": "%s",
          // data
          "source_language":%s ,
          "localization_languages": %s,
          "target_languages": %s
        };
         lingotek.dashboard(containerId,config);
        });
      </script>
    ';
  $endpoint = $base_url . '/lingotek/target';
  $upload_url = $base_url . '/lingotek/upload';
  $download_url = $base_url . '/lingotek/download';
  $sync_url = $base_url . '/lingotek/sync';
  $output .= sprintf($script, variable_get('lingotek_community_identifier', ''), variable_get('lingotek_oauth_consumer_id', ''), variable_get('lingotek_oauth_consumer_secret', ''), variable_get('lingotek_login_id', ''), variable_get('lingotek_vault', ''), variable_get('lingotek_workflow', ''), variable_get('lingotek_project', ''), variable_get('lingotek_activation_first_name', ''), variable_get('lingotek_activation_last_name', ''), variable_get('lingotek_activation_email', ''), $guid, url('<front>', array(
    'absolute' => TRUE,
  )), variable_get('site_name', 'Unidentified Drupal Site'), 'Drupal', VERSION, variable_get('install_profile', ''), json_encode(lingotek_get_module_info('version')), $endpoint, $upload_url, $download_url, $sync_url, lingotek_get_source_language_json(), lingotek_get_localization_languages_json(), json_encode($totals));
  return $output;
}