You've already forked phpmyadmin
mirror of
https://github.com/phpmyadmin/phpmyadmin.git
synced 2026-10-29 21:24:44 +03:00
Move /messages HTTP headers to the JavaScriptMessagesController
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
@@ -6,8 +6,11 @@ namespace PhpMyAdmin\Controllers;
|
||||
|
||||
use function __;
|
||||
use function _pgettext;
|
||||
use function gmdate;
|
||||
use function header;
|
||||
use function json_encode;
|
||||
use function json_last_error_msg;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* Exporting of translated messages from PHP to JavaScript.
|
||||
@@ -24,6 +27,7 @@ final class JavaScriptMessagesController
|
||||
|
||||
public function __invoke(): void
|
||||
{
|
||||
$this->setHTTPHeaders();
|
||||
$messages = json_encode($this->messages);
|
||||
if ($messages === false) {
|
||||
echo '// Error when encoding messages: ' . json_last_error_msg();
|
||||
@@ -34,6 +38,15 @@ final class JavaScriptMessagesController
|
||||
echo 'window.Messages = ' . $messages . ';';
|
||||
}
|
||||
|
||||
private function setHTTPHeaders(): void
|
||||
{
|
||||
// Send correct type.
|
||||
header('Content-Type: text/javascript; charset=UTF-8');
|
||||
// Cache output in client
|
||||
// the nocache query parameter makes sure that this file is reloaded when config changes.
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user