BMLT Root Server
GetLangs.php
Go to the documentation of this file.
1 <?php
2 /****************************************************************************************//**
3 * \file client_interface/json/GetLangs.php *
4 * \brief Returns a JSON response, containing all the Language enumss and names. *
5 
6  This file is part of the Basic Meeting List Toolbox (BMLT).
7 
8  Find out more at: https://bmlt.app
9 
10  BMLT is free software: you can redistribute it and/or modify
11  it under the terms of the MIT License.
12 
13  BMLT is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  MIT License for more details.
17 
18  You should have received a copy of the MIT License along with this code.
19  If not, see <https://opensource.org/licenses/MIT>.
20 ********************************************************************************************/
21 
22 defined('BMLT_EXEC') or define('BMLT_EXEC', true); // This is a security verifier. Keeps files from being executed outside of the context
23 $file_dir = str_replace('/client_interface/json', '', dirname(__FILE__)).'/server/c_comdef_server.class.php';
24 require_once($file_dir);
25 $server = c_comdef_server::MakeServer();
26 $ret = null;
27 
28 if ($server instanceof c_comdef_server) {
29  $langs = $server->GetServerLangs();
30 
31  if ($langs) {
32  // The caller can request compression. Not all clients can deal with compressed replies.
33  if (isset($_GET['compress_json']) || isset($_POST['compress_json'])) {
34  ob_start('ob_gzhandler');
35  } else {
36  header('Content-Type:application/json; charset=UTF-8');
37  ob_start();
38  }
39 
40  echo '{"languages":[';
41 
42  $first = true;
43 
44  foreach ($langs as $key_string => $name_string) {
45  if (!$first) {
46  echo ",";
47  } else {
48  $first = false;
49  }
50 
51  echo '{"key":'.json_encode($key_string);
52  echo ',"name":'.json_encode($name_string);
53  if (!strcmp($key_string, $server->GetLocalLang())) {
54  echo ',"default":true';
55  }
56  echo '}';
57  }
58 
59  echo "]}";
60  ob_end_flush();
61  } else {
62  echo ( 'No Languages' );
63  }
64 } else {
65  echo ( 'No Server' );
66 }
if($handler instanceof c_comdef_admin_ajax_handler)
const BMLT_EXEC
Definition: index.php:21
defined('BMLT_EXEC') or define('BMLT_EXEC' true
Definition: GetLangs.php:22
$file_dir
Definition: GetLangs.php:23
$server
Definition: GetLangs.php:25
$ret
Definition: GetLangs.php:26
This class is the main server class. It instantiates a PDO database object, and is the starting point...
defined('BMLT_EXEC') or define('BMLT_EXEC'
Definition: index.php:3
$_GET['switcher']