ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLanguageDetectorFactory Class Reference

Class ilLanguageDetectorFactory. More...

+ Collaboration diagram for ilLanguageDetectorFactory:

Public Member Functions

 __construct ()
 
 getValidInstances ()
 
 createDetectorByType ($type)
 

Data Fields

const DEFAULT_DETECTOR = 1
 
const HTTP_REQUEST_DETECTOR = 2
 

Protected Attributes

 $client_ini
 
 $request_information = array()
 
 $settings
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLanguageDetectorFactory::__construct ( )

Definition at line 32 of file class.ilLanguageDetectorFactory.php.

References $_SERVER, $DIC, and settings().

33  {
34  global $DIC;
35 
36  $this->client_ini = $DIC->clientIni();
37  $this->request_information = $_SERVER;
38  $this->settings = $DIC->settings();
39  }
settings()
Definition: settings.php:2
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ createDetectorByType()

ilLanguageDetectorFactory::createDetectorByType (   $type)
Parameters
int$type
Exceptions
ilLanguageException
Returns
ilLanguageDetector

Definition at line 65 of file class.ilLanguageDetectorFactory.php.

References $type.

Referenced by getValidInstances().

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  }
$type
Class for language related exception handling in ILIAS.
Class ilDefaultLanguageDetector.
Class ilHttpRequestsLanguageDetector.
+ Here is the caller graph for this function:

◆ getValidInstances()

ilLanguageDetectorFactory::getValidInstances ( )
Returns
ilLanguageDetector[]

Definition at line 44 of file class.ilLanguageDetectorFactory.php.

References createDetectorByType(), settings(), and ilContext\usesHTTP().

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  }
settings()
Definition: settings.php:2
static usesHTTP()
Uses HTTP aka browser.
+ Here is the call graph for this function:

Field Documentation

◆ $client_ini

ilLanguageDetectorFactory::$client_ini
protected

Definition at line 17 of file class.ilLanguageDetectorFactory.php.

◆ $request_information

ilLanguageDetectorFactory::$request_information = array()
protected

Definition at line 22 of file class.ilLanguageDetectorFactory.php.

◆ $settings

ilLanguageDetectorFactory::$settings
protected

Definition at line 27 of file class.ilLanguageDetectorFactory.php.

◆ DEFAULT_DETECTOR

const ilLanguageDetectorFactory::DEFAULT_DETECTOR = 1

Definition at line 11 of file class.ilLanguageDetectorFactory.php.

◆ HTTP_REQUEST_DETECTOR

const ilLanguageDetectorFactory::HTTP_REQUEST_DETECTOR = 2

Definition at line 12 of file class.ilLanguageDetectorFactory.php.


The documentation for this class was generated from the following file: