<commit_before><?php

/**
 * @file
 * Displays the GovReady Dashboard.
 */

/**
 * GovreadyDashboard class.
 *
 * Namespace Govready\GovreadyDashboard.
 */
class GovreadyDashboard {

  /**
   * Construct function.
   */
  function __construct() {
    $this->path = drupal_get_path('module', 'govready');
    $this->config = govready_config();
  }

  /**
   * Display the GovReady dashboard.
   */
  public function dashboardPage() {
    $options = variable_get('govready_options', array());

    $path = $this->path . '/includes/js/';
    $settings = array(
      'api_endpoint' => url('govready/api'),
      'token_endpoint' => url('govready/refresh-token'),
      'trigger_endpoint' => url('govready/trigger'),
    );

    // First time using app, need to set everything up.
    if (empty($options['refresh_token'])) {

      // Call GovReady /initialize to set the allowed CORS endpoint.
      // @todo: error handling: redirect user to GovReady API dedicated login page
      global $base_url;
      if (empty($options['siteId'])) {
        $data = array(
          'url' => $base_url,
          'application' => 'drupal',
        );
        $response = govready_api('/initialize', 'POST', $data, TRUE);
        $options['siteId'] = $response['_id'];
        variable_set('govready_options', $options);
      }

      // Save some JS variables (available at govready.siteId, etc)
      drupal_add_js($path . 'govready-connect.js');<commit_msg>Add warning message if overlay is enabled https://github.com/GovReady/GovReady-Drupal-Agent/issues/5<commit_after><?php

/**
 * @file
 * Displays the GovReady Dashboard.
 */

/**
 * GovreadyDashboard class.
 *
 * Namespace Govready\GovreadyDashboard.
 */
class GovreadyDashboard {

  /**
   * Construct function.
   */
  function __construct() {
    $this->path = drupal_get_path('module', 'govready');
    $this->config = govready_config();
  }

  /**
   * Display the GovReady dashboard.
   */
  public function dashboardPage() {
    $options = variable_get('govready_options', array());

    $path = $this->path . '/includes/js/';
    $settings = array(
      'api_endpoint' => url('govready/api'),
      'token_endpoint' => url('govready/refresh-token'),
      'trigger_endpoint' => url('govready/trigger'),
    );

    // Add warning message if overlay is enabled.
    if (module_exists('overlay')) {
      $url = url('admin/reports/govready');
      drupal_set_message(
        t(
          'The GovReady Dashboard may not work properly with the Overlay module enabled. To use the Dashboard, please disable the Overlay module on the !modules, or view the dashboard from a !tab outside of the overlay.', array(
            '!modules' => l('modules page', 'admin/modules'), 
            '!tab' => l('new tab', $url, array('attributes' => array('onclick' => 'window.open("'.$url.'");return false;')))
          )
        ), 'warning');
    }

    // First time using app, need to set everything up.
    if (empty($options['refresh_token'])) {

      // Call GovReady /initialize to set the allowed CORS endpoint.
      // @todo: error handling: redirect user to GovReady API dedicated login page
      global $base_url;
      if (empty($options['siteId'])) {
        $data = array(
          'url' => $base_url,
          'application' => 'drupal',
        );
        $response = govready_api('/initialize', 'POST', $data, TRUE);
        $options['siteId'] = $response['_id'];
        variable_set('govready_options', $options);
      }

      // Save some JS variables (available at govready.siteId, etc)
      drupal_add_js($path . 'govready-connect.js');
{'fraction_non_alphanumeric': 0.15331300249514832, 'fraction_numerical': 0.0002772387025228722, 'mean_word_length': 2.862955032119914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7226822', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1076, 'n_words': 272}