- <?php
-
- * @file
- * Mock module for locale layer tests.
- */
-
- * Implements hook_boot().
- *
- * For testing domain language negotiation, we fake it by setting
- * the HTTP_HOST here
- */
- function locale_test_boot() {
- if (state_get('locale_test_domain')) {
- $_SERVER['HTTP_HOST'] = state_get('locale_test_domain');
- }
- }
-
- * Implements hook_init().
- */
- function locale_test_init() {
- locale_test_store_language_negotiation();
- if (isset($GLOBALS['language']) && isset($GLOBALS['language']->provider)) {
- backdrop_set_message(t('Language negotiation provider: @name', array('@name' => $GLOBALS['language']->provider)));
- }
- }
-
- * Implements hook_language_types_info().
- */
- function locale_test_language_types_info() {
- if (state_get('locale_test_language_types', FALSE)) {
- return array(
- 'test_language_type' => array(
- 'name' => t('Test'),
- 'description' => t('A test language type.'),
- ),
- 'fixed_test_language_type' => array(
- 'fixed' => array('test_language_provider'),
- ),
- );
- }
- }
-
- * Implements hook_language_types_info_alter().
- */
- function locale_test_language_types_info_alter(array &$language_types) {
- if (state_get('locale_test_content_language_type', FALSE)) {
- unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
- }
- }
-
- * Implements hook_language_negotiation_info().
- */
- function locale_test_language_negotiation_info() {
- if (state_get('locale_test_language_negotiation_info', FALSE)) {
- $info = array(
- 'callbacks' => array(
- 'language' => 'locale_test_language_provider',
- ),
- 'file' => backdrop_get_path('module', 'locale_test') .'/locale_test.module',
- 'weight' => -10,
- 'description' => t('This is a test language provider.'),
- );
-
- return array(
- 'test_language_provider' => array(
- 'name' => t('Test'),
- 'types' => array(LANGUAGE_TYPE_CONTENT, 'test_language_type', 'fixed_test_language_type'),
- ) + $info,
- 'test_language_provider_ts' => array(
- 'name' => t('Type-specific test'),
- 'types' => array('test_language_type'),
- ) + $info,
- );
- }
- }
-
- * Implements hook_language_negotiation_info_alter().
- */
- function locale_test_language_negotiation_info_alter(array &$language_providers) {
- if (state_get('locale_test_language_negotiation_info_alter', FALSE)) {
- unset($language_providers[LANGUAGE_NEGOTIATION_INTERFACE]);
- }
- }
-
- * Store the last negotiated languages.
- */
- function locale_test_store_language_negotiation() {
- $last = array();
- require_once BACKDROP_ROOT . '/core/includes/language.inc';
- foreach (language_types_info() as $type_name => $type_info) {
- $last[$type_name] = $GLOBALS[$type_name]->langcode;
- }
- state_set('locale_test_language_negotiation_last', $last);
- }
-
- * Test language provider.
- */
- function locale_test_language_provider($languages) {
- return 'it';
- }