You are here

function _suggestion_admin_stopword_init in Autocomplete Search Suggestions 7

Implements hook_enable().

1 call to _suggestion_admin_stopword_init()
suggestion_admin_settings_form in ./suggestion.admin.inc
Menu callback to configure suggestion settings.

File

./suggestion.admin.inc, line 480
Administration form for suggestion module.

Code

function _suggestion_admin_stopword_init() {
  $tgt = variable_get('suggestion_stopword_uri', file_default_scheme() . '://suggestion/suggestion_stopword.txt');
  if (file_exists($tgt)) {
    return;
  }
  $dir = preg_replace('/\\/[^\\/]+$/', '', $tgt);
  if (!file_exists($dir)) {
    drupal_mkdir($dir);
  }
  module_load_include('inc', 'suggestion', 'suggestion.stopword');
  $stopwords = implode("\n", _suggestion_stopword_list());
  variable_set('suggestion_stopword_hash', drupal_hash_base64($stopwords));
  file_unmanaged_save_data($stopwords, $tgt, FILE_EXISTS_REPLACE);
}