ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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{
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) {
69 require_once 'Services/Language/classes/class.ilHttpRequestsLanguageDetector.php';
70 return new ilHttpRequestsLanguageDetector($this->request_information['HTTP_ACCEPT_LANGUAGE']);
71
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}
An exception for terminatinating execution or to throw for unit testing.
static usesHTTP()
Uses HTTP aka browser.
Class ilDefaultLanguageDetector.
Class ilHttpRequestsLanguageDetector.
Class ilLanguageDetectorFactory.
Class for language related exception handling in ILIAS.
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46