Make list of locales working
This commit is contained in:
parent
604e42d323
commit
b8295bb66f
|
@ -108,6 +108,8 @@ if(isset($controller->splitted_url[1])) {
|
|||
|
||||
// If we are editing the profile
|
||||
if(isset($controller->splitted_url[3]) && $controller->splitted_url[3]=="edit" && ($user->rankIsHigher("moderator") || $user->id == $userProfile->id)) {
|
||||
$locales = new Locales;
|
||||
$locales->getAll();
|
||||
$head['js'] = "d.avatar.js";
|
||||
if (isset($_POST['submit'])) {
|
||||
$receivedUser = new User();
|
||||
|
|
|
@ -46,6 +46,9 @@ class Locale
|
|||
** Populate the object using raw data from SQL
|
||||
*****/
|
||||
private function populate($row) {
|
||||
$this->forcePopulate($row);
|
||||
}
|
||||
public function forcePopulate($row) {
|
||||
$this->name = $row['name'];
|
||||
$this->display_name = $row['display_name'];
|
||||
$this->flag_name = $row['flag_name'];
|
||||
|
@ -54,8 +57,49 @@ class Locale
|
|||
/*****
|
||||
** Simple return only functions
|
||||
*****/
|
||||
public function get_id() {
|
||||
return $this->id;
|
||||
public function get_name() {
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
***********************************************************
|
||||
**
|
||||
** This class is to manage Locales list object
|
||||
**
|
||||
***********************************************************
|
||||
**********************************************************/
|
||||
|
||||
class Locales
|
||||
{
|
||||
public $number = 0;
|
||||
public $objs = array();
|
||||
|
||||
/*****
|
||||
** Get all locales
|
||||
*****/
|
||||
public function getAll() {
|
||||
global $config;
|
||||
|
||||
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
|
||||
or die ("Could not connect to server\n");
|
||||
|
||||
$query = "SELECT * FROM locales";
|
||||
|
||||
pg_prepare($con, "prepare1", $query)
|
||||
or die ("Cannot prepare statement\n");
|
||||
$result = pg_execute($con, "prepare1", array())
|
||||
or die ("Cannot execute statement\n");
|
||||
|
||||
pg_close($con);
|
||||
|
||||
$this->number = pg_num_rows($result);
|
||||
|
||||
for($i = 0; $i < $this->number; $i++) {
|
||||
$locale = pg_fetch_assoc($result, $i);
|
||||
$this->objs[$i] = new Locale;
|
||||
$this->objs[$i]->forcePopulate($locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
<li><label for="password">Mot de passe :</label><input name="password" id="password" type="password" placeholder="Nouveau mot de passe"></li>
|
||||
<li><label for="locale">Langue :</label>
|
||||
<select name="locale" id="locale">
|
||||
<? foreach($config['locales'] as $locale) { ?>
|
||||
<option <?=$userProfile->locale==$locale[0]?'selected':''?> value="<?=$locale[0]?>"><?=$locale[5]?></option>
|
||||
<? foreach($locales->objs as $locale) { ?>
|
||||
<option <?=$userProfile->get_locale()==$locale->display_name?'selected':''?> value="<?=$locale->get_name()?>"><?=$locale->display_name?></option>
|
||||
<? } ?>
|
||||
</select></li>
|
||||
<? if($user->rankIsHigher("administrator")) { ?>
|
||||
|
|
Loading…
Reference in New Issue