ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LanguageAdaptor.php
Go to the documentation of this file.
1 <?php
2 
10 
11  private $langattr = 'preferredLanguage';
12 
13 
20  public function __construct($config, $reserved) {
21  parent::__construct($config, $reserved);
22  assert(is_array($config));
23 
24  if (array_key_exists('attributename', $config)) {
25  $this->langattr = $config['attributename'];
26  }
27  }
28 
29 
37  public function process(&$request) {
38  assert(is_array($request));
39  assert(array_key_exists('Attributes', $request));
40 
41  $attributes =& $request['Attributes'];
42 
43  $attrlang = NULL;
44  if (array_key_exists($this->langattr, $attributes))
45  $attrlang = $attributes[$this->langattr][0];
46 
48 
49 
50  if (isset($attrlang))
51  SimpleSAML\Logger::debug('LanguageAdaptor: Language in attribute was set [' . $attrlang . ']');
52  if (isset($lang))
53  SimpleSAML\Logger::debug('LanguageAdaptor: Language in session was set [' . $lang . ']');
54 
55 
56  if (isset($attrlang) && !isset($lang)) {
57  // Language set in attribute but not in cookie - update cookie
59  } elseif (!isset($attrlang) && isset($lang)) {
60  // Language set in cookie, but not in attribute. Update attribute
61  $request['Attributes'][$this->langattr] = array($lang);
62  }
63 
64  }
65 
66 }
__construct($config, $reserved)
Initialize this filter.
static getLanguageCookie()
Retrieve the user-selected language from a cookie.
Definition: Language.php:378
$config
Definition: bootstrap.php:15
foreach($paths as $path) $request
Definition: asyncclient.php:32
static debug($string)
Definition: Logger.php:211
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
static setLanguageCookie($language)
This method will attempt to set the user-selected language in a cookie.
Definition: Language.php:401
process(&$request)
Apply filter to add or replace attributes.