ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
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 $detectors[] = $this->createDetectorByType(self::HTTP_REQUEST_DETECTOR);
59 }
60
61 return $detectors;
62 }
63
69 public function createDetectorByType($type)
70 {
71 switch ($type) {
73 require_once 'Services/Language/classes/class.ilHttpRequestsLanguageDetector.php';
74 return new ilHttpRequestsLanguageDetector($this->request_information['HTTP_ACCEPT_LANGUAGE']);
75
77 require_once 'Services/Language/classes/class.ilDefaultLanguageDetector.php';
78 return new ilDefaultLanguageDetector($this->client_ini);
79 }
80
81 require_once 'Services/Language/exceptions/class.ilLanguageException.php';
82 throw new ilLanguageException(__METHOD__ . sprintf('Cannot create language detector instance for type %s!', $type));
83 }
84}
sprintf('%.4f', $callTime)
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.
global $ilSetting
Definition: privfeed.php:17
$type
settings()
Definition: settings.php:2
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']