Skip to content

Commit

Permalink
set language in admin form
Browse files Browse the repository at this point in the history
  • Loading branch information
rachyandco committed Oct 12, 2012
1 parent e5ba555 commit 7085ae1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
5 changes: 3 additions & 2 deletions SQL.Structure
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: 46.20.241.57
-- Generation Time: Oct 05, 2012 at 10:18 PM
-- Generation Time: Oct 12, 2012 at 10:29 AM
-- Server version: 5.0.91
-- PHP Version: 5.2.15

Expand Down Expand Up @@ -33,7 +33,7 @@ CREATE TABLE IF NOT EXISTS `comments` (
PRIMARY KEY (`com_id`),
KEY `com_id` (`com_id`),
KEY `timestamp` (`timestamp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=71 ;

-- --------------------------------------------------------

Expand All @@ -49,6 +49,7 @@ CREATE TABLE IF NOT EXISTS `configuration` (
`titlehead` text NOT NULL,
`lastrefresh` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`cron` tinyint(4) NOT NULL,
`lang` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Expand Down
17 changes: 16 additions & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,22 @@
<option value=0 ".$cronselectON.">".$lang['ADMIN_PARAM_ACTIVATED']."</option>
<option value=1 ".$cronselectOFF.">".$lang['ADMIN_PARAM_DEACTIVATED']."</option>
</select>
<br>
";

// Admin Form - Get available languages
echo "<label>".$lang['ADMIN_PARAM_SITELANGUAGE']." :</label>";
echo "<select name=lang>";
foreach($langarray as $langavail){
if ($param['LANG'] == $langavail)
{$langselect = "selected=\"selected\"";
} else {
$langselect = "";
}
echo "<option value=\"".$langavail."\" ".$langselect.">".$langavail."</option>";
}
echo "</select>";

echo "<br>
<button class=\"btn btn-primary\" type=submit value=Save>".$lang['ADMIN_PARAM_SAVE']."</button>
<button class=\"btn\" data-dismiss=\"modal\" aria-hidden=\"true\">".$lang['ADMIN_PARAM_CANCEL']."</button>
</form>
Expand Down
15 changes: 14 additions & 1 deletion db.connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

//retrieve Site Parameters

$QueryConfig ="select title,subtitle,titlehead,numrows,lastrefresh,cron from configuration where id = 0";
$QueryConfig ="select title,subtitle,titlehead,numrows,lastrefresh,cron,lang from configuration where id = 0";
$ResultConfig = mysql_query($QueryConfig);
$ArrayConfig = mysql_fetch_row($ResultConfig);

Expand All @@ -28,4 +28,17 @@
$param['NUMROWS'] = $ArrayConfig[3];
$param['LASTREFRESH'] = $ArrayConfig[4];
$param['CRON'] = $ArrayConfig[5];
$param['LANG'] = $ArrayConfig[6];

// Parse language file in array
$langarray = array();
if ($langdir = opendir('lang')){
while (false !== ($langdirentry = readdir($langdir))) {
if ($langdirentry != "." && $langdirentry != "..") {
array_push($langarray,$langdirentry);
}

}
closedir($langdir);
}
?>
1 change: 1 addition & 0 deletions lang/lang.fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
$lang['ADMIN_PARAM_AUTOUPDATE'] = 'Mise à jour automatique (désactiver si un cronjob est installé sur le serveur)';
$lang['ADMIN_PARAM_ACTIVATED'] = 'Activée';
$lang['ADMIN_PARAM_DEACTIVATED'] = 'Desactivée';
$lang['ADMIN_PARAM_SITELANGUAGE'] = 'Langue du Site';
$lang['ADMIN_PARAM_SAVE'] = 'Sauvegarder';
$lang['ADMIN_PARAM_CANCEL'] = 'Annuler';

Expand Down

0 comments on commit 7085ae1

Please sign in to comment.