blob: 9eb5cc8e079511bfa5fe804828bf1edff878f091 [file] [log] [blame]
atoulme425b6c82008-11-24 14:00:27 +00001<?php
2/*******************************************************************************
3 * Copyright (c) 2007-2008 Eclipse Foundation and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Antoine Toulme, Intalio Inc. bug 248845: Refactoring generate1.php into different files with a functional approach
kitlo86651192009-01-22 04:28:19 +000011 * Kit Lo (IBM) - patch, bug 261739, Inconsistent use of language names
kitlof237f0e2009-03-14 02:12:56 +000012 * Kit Lo (IBM) - Beautify Babel Supported Languages table
atoulme425b6c82008-11-24 14:00:27 +000013*******************************************************************************/
14
15class Language {
16
17 public $name = '';
18 public $iso = '';
19 public $locale = '';
20 public $id = '';
21
22 /**
23 * Default constructor
24 */
25 function Language($name = '', $iso= '', $locale = '', $id = '') {
26 $this->name = $name;
27 $this->iso = $iso;
28 $this->locale = $locale;
29 $this->id = $id;
30
31 if (strcmp($iso, "en") == 0) {
32 $this->iso = "en_AA";
33 $this->name = "Pseudo Translations";
34 }
35
36 if ($locale != null) {
kitlo86651192009-01-22 04:28:19 +000037 $this->name = $this->name . " (" . $this->locale . ")";
atoulme425b6c82008-11-24 14:00:27 +000038 }
39 }
40
41 /**
42 * A constructor expecting an associative array as its unique parameter
43 */
atoulme589b1ec2008-11-24 15:23:01 +000044 static function fromRow($row) {
atoulmef84e8752008-11-24 15:24:59 +000045 return new Language($row['name'], $row['iso_code'], $row['locale'], $row['language_id']);
atoulme425b6c82008-11-24 14:00:27 +000046 }
47
48 static function all() {
49 $langs = array();
Denis Roy7f62f6f2019-11-13 15:35:26 -050050 global $dbh;
kitlo1d027092018-04-19 17:44:07 -040051 $language_result = mysqli_query($dbh, "SELECT * FROM languages WHERE languages.is_active ORDER BY name, locale");
52 while (($language_row = mysqli_fetch_assoc($language_result)) != null) {
atoulmef84e8752008-11-24 15:24:59 +000053 $langs[] = Language::fromRow($language_row);
atoulme425b6c82008-11-24 14:00:27 +000054 }
55 return $langs;
56 }
57}