ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilLanguageDetectorFactory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
10 {
11  const DEFAULT_DETECTOR = 1;
13 
17  protected $client_ini;
18 
22  protected $request_information = array();
23 
27  protected $settings;
28 
32  public function __construct()
33  {
38  global $ilClientIniFile, $ilSetting;
39 
40  $this->client_ini = $ilClientIniFile;
41  $this->request_information = $_SERVER;
42  $this->settings = $ilSetting;
43  }
44 
48  public function getValidInstances()
49  {
50  $detectors = array(
51  $this->createDetectorByType(self::DEFAULT_DETECTOR)
52  );
53 
54  if(
55  $this->settings->get('lang_detection') &&
57  )
58  {
59  $detectors[] = $this->createDetectorByType(self::HTTP_REQUEST_DETECTOR);
60  }
61 
62  return $detectors;
63  }
64 
70  public function createDetectorByType($type)
71  {
72  switch($type)
73  {
74  case self::HTTP_REQUEST_DETECTOR:
75  require_once 'Services/Language/classes/class.ilHttpRequestsLanguageDetector.php';
76  return new ilHttpRequestsLanguageDetector($this->request_information['HTTP_ACCEPT_LANGUAGE']);
77 
78  case self::DEFAULT_DETECTOR:
79  require_once 'Services/Language/classes/class.ilDefaultLanguageDetector.php';
80  return new ilDefaultLanguageDetector($this->client_ini);
81  }
82 
83  require_once 'Services/Language/exceptions/class.ilLanguageException.php';
84  throw new ilLanguageException(__METHOD__ . sprintf('Cannot create language detector instance for type %s!', $type));
85  }
86 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static usesHTTP()
Uses HTTP aka browser.
Class ilLanguageDetectorFactory.
Class for language related exception handling in ILIAS.
Class ilDefaultLanguageDetector.
Class ilHttpRequestsLanguageDetector.
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
global $ilSetting
Definition: privfeed.php:17