mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
- fix errors if language files are broken
This commit is contained in:
parent
4e083c6327
commit
5483b9a9e6
2 changed files with 9 additions and 0 deletions
|
|
@ -54,6 +54,9 @@ class Lang
|
|||
{
|
||||
$this->code = $code;
|
||||
$json = json_decode($jsonString, true);
|
||||
if ($json === null) {
|
||||
$json = array();
|
||||
}
|
||||
|
||||
//load default language
|
||||
if ( $code != $this->default ) {
|
||||
|
|
@ -72,6 +75,9 @@ class Lang
|
|||
}
|
||||
$defStr = file_get_contents($this->langDir(). "{$this->default}.json");
|
||||
$this->strings = json_decode($defStr, true);
|
||||
if ($this->strings === null) {
|
||||
die("Invalid JSON in default language file (". htmlspecialchars($this->default). ".json)");
|
||||
}
|
||||
}
|
||||
|
||||
function get($key)
|
||||
|
|
|
|||
|
|
@ -153,6 +153,9 @@ function selectOptionsA($a, $key, $default=null)
|
|||
$s = '';
|
||||
if($default !== null && !isset($a[$key])) $key = $default;
|
||||
foreach($a as $k=>$v) {
|
||||
if (!is_array($v)) {
|
||||
$v = array('name' => $k);
|
||||
}
|
||||
$s .= '<option value="'.htmlspecialchars($k).'" '.($k===$key?'selected="selected"':'').
|
||||
(isset($v['title']) ? ' title="'.htmlspecialchars($v['title']).'"' : '').
|
||||
'>'.htmlspecialchars($v['name']).'</option>';
|
||||
|
|
|
|||
Loading…
Reference in a new issue