ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
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 {
75 require_once 'Services/Language/classes/class.ilHttpRequestsLanguageDetector.php';
76 return new ilHttpRequestsLanguageDetector($this->request_information['HTTP_ACCEPT_LANGUAGE']);
77
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}
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:40
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']