You are here

function i18n_selection_mode in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_selection_mode()
  2. 5 i18n.module \i18n_selection_mode()
  3. 5.2 i18n.module \i18n_selection_mode()

Selection mode for content.

Warning: when used with params they need to be escaped, as some values are thrown directly in queries.

Allows several modes for query rewriting and to change them programatically. off = No language conditions inserted. simple = Only current language and no language. mixed = Only current and default languages. strict = Only current language. default = Only default language. user = User defined, in the module's settings page. params = Gets the stored params. reset = Returns to previous. custom = add custom where clause, like "%alias.language = 'en'".

7 calls to i18n_selection_mode()
i18nmenu_locale_refresh in i18nmenu/i18nmenu.module
Refresh locale strings.
i18nsync_nodeapi in i18nsync/i18nsync.module
Implementation of hook_nodeapi().
i18ntaxonomy_db_rewrite_sql in i18ntaxonomy/i18ntaxonomy.module
Implementation of hook_db_rewrite_sql().
i18n_db_rewrite_sql in ./i18n.module
Implementation of hook_db_rewrite_sql().
i18n_db_rewrite_where in ./i18n.module
Rewrites queries depending on rewriting mode.

... See full list

3 string references to 'i18n_selection_mode'
i18n_admin_settings in ./i18n.admin.inc
Form builder function.
i18n_API_Tests::testBasicAPI in tests/i18n_api.test
i18n_uninstall in ./i18n.install

File

./i18n.module, line 404
Internationalization (i18n) module.

Code

function i18n_selection_mode($mode = NULL, $params = NULL) {
  static $current_mode;
  static $current_value = '';
  static $store = array();

  // Initialization, first time this runs
  if (!isset($current_mode)) {
    $current_mode = variable_get('i18n_selection_mode', 'simple');
  }
  if (!$mode) {
    return $current_mode;
  }
  elseif ($mode == 'params') {
    return $current_value;
  }
  elseif ($mode == 'reset') {
    list($current_mode, $current_value) = array_pop($store);
  }
  else {
    array_push($store, array(
      $current_mode,
      $current_value,
    ));
    $current_mode = $mode;
    $current_value = $params;
  }
}