You are here

function _select2_set_exuled_for_settings in Select 2 7

Excluded settings.

2 calls to _select2_set_exuled_for_settings()
select2_get_settings_ajax in includes/ajax.inc
Ajax settings.
_select2_post_load_library_callback in ./select2.module
Sets the 'post-load callback' key.

File

./select2.module, line 1144
Main file for Select2 module.

Code

function _select2_set_exuled_for_settings() {
  $select2_settings = array(
    'select_2' => array(
      'excludes' => array(),
    ),
  );
  if (variable_get('select2_excluded_ids', '')) {
    $ids = explode("\r\n", variable_get('select2_excluded_ids', ''));
    $ids_values = array();
    $ids_reg_exs = array();
    foreach ($ids as $id) {
      if (preg_match('/^\\#(?<id_reg_ex>[0-9a-zA-Z-_]*)\\#$/', $id, $match)) {
        $ids_reg_exs[] = $match['id_reg_ex'];
      }
      else {
        $ids_values[] = $id;
      }
    }
    if ($ids_values) {
      $select2_settings['select_2']['excludes']['by_id']['values'] = $ids_values;
    }
    if ($ids_reg_exs) {
      $select2_settings['select_2']['excludes']['by_id']['reg_exs'] = $ids_reg_exs;
    }
  }
  if (variable_get('select2_excluded_cleasses', '')) {
    $classes = explode("\r\n", variable_get('select2_excluded_cleasses', ''));
    $select2_settings['select_2']['excludes']['by_class'] = $classes;
  }
  if (variable_get('select2_excluded_selectors', '')) {
    $selectors = explode("\r\n", variable_get('select2_excluded_selectors', ''));
    $select2_settings['select_2']['excludes']['by_selectors'] = $selectors;
  }

  //   if ($select2_settings['select_2']['excludes']) {
  //     $js = drupal_add_js($select2_settings, 'setting');
  //   }
  return $select2_settings;
}