ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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  {
34  global $DIC;
35 
36  $this->client_ini = $DIC->clientIni();
37  $this->request_information = $_SERVER;
38  $this->settings = $DIC->settings();
39  }
40 
44  public function getValidInstances()
45  {
46  $detectors = array(
47  $this->createDetectorByType(self::DEFAULT_DETECTOR)
48  );
49 
50  if (
51  $this->settings->get('lang_detection') &&
53  ) {
54  $detectors[] = $this->createDetectorByType(self::HTTP_REQUEST_DETECTOR);
55  }
56 
57  return $detectors;
58  }
59 
65  public function createDetectorByType($type)
66  {
67  switch ($type) {
68  case self::HTTP_REQUEST_DETECTOR:
69  require_once 'Services/Language/classes/class.ilHttpRequestsLanguageDetector.php';
70  return new ilHttpRequestsLanguageDetector($this->request_information['HTTP_ACCEPT_LANGUAGE']);
71 
72  case self::DEFAULT_DETECTOR:
73  require_once 'Services/Language/classes/class.ilDefaultLanguageDetector.php';
74  return new ilDefaultLanguageDetector($this->client_ini);
75  }
76 
77  require_once 'Services/Language/exceptions/class.ilLanguageException.php';
78  throw new ilLanguageException(__METHOD__ . sprintf('Cannot create language detector instance for type %s!', $type));
79  }
80 }
settings()
Definition: settings.php:2
$type
static usesHTTP()
Uses HTTP aka browser.
Class ilLanguageDetectorFactory.
Class for language related exception handling in ILIAS.
Class ilDefaultLanguageDetector.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
Class ilHttpRequestsLanguageDetector.
$DIC
Definition: xapitoken.php:46