Skip to content

Commit 104fb55

Browse files
committed
feat. add history method into lang component
1 parent 9147cd9 commit 104fb55

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

app/Controller/Component/LangComponent.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,10 @@ function email_reset($email, $pseudo, $key)
457457

458458
if (file_get_contents(ROOT . '/lang/' . $language . '.json')) {
459459
$language_file = file_get_contents(ROOT . '/lang/' . $language . '.json');
460-
$language_file = json_decode($language_file, true);
461460
} else {
462461
$language_file = file_get_contents(ROOT . '/lang/fr.json');
463-
$language_file = json_decode($language_file, true);
464462
}
463+
$language_file = json_decode($language_file, true);
465464

466465
if (isset($language_file[$msg])) { // et si le msg existe
467466
$msg = str_replace('{EMAIL}', $email, $language_file[$msg]);
@@ -473,6 +472,11 @@ function email_reset($email, $pseudo, $key)
473472
}
474473
}
475474

475+
function history($action)
476+
{
477+
$message = $this->lang['messages']["HISTORY__ACTION_" . $action];
478+
return !$message ? $action : $message;
479+
}
480+
476481
}
477482

478-
?>

app/Controller/HistoryController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function admin_getAll()
3030
$this->DataTable->mDataProp = true;
3131
$response = $this->DataTable->getResponse();
3232
$response["aaData"] = array_map(function($data) {
33-
$data["History"]["action"] = $this->Lang->get('HISTORY__ACTION_' . $data["History"]["action"]);
33+
$data["History"]["action"] = $this->Lang->history($data["History"]["action"]);
3434
return $data;
3535
}, $response["aaData"]);
3636
$this->response->body(json_encode($response));

app/View/Admin/admin_index.ctp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
</tr>
249249
<?php foreach ($History->get(false, 5) as $k => $v) { ?>
250250
<tr>
251-
<td><?= $v['History']['action'] ?></td>
251+
<td><?= $Lang->history($v['History']['action']) ?></td>
252252
<td><?= $v['History']['category'] ?></td>
253253
<td><?= $Lang->date($v['History']['created']) ?></td>
254254
<td><?= $v['History']['author'] ?></td>

0 commit comments

Comments
 (0)