Skip to content

Commit 461f588

Browse files
committed
L10N patch.
1 parent 561e6b7 commit 461f588

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/Web.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Upload handler (last modified: 2023.04.02).
11+
* This file: Upload handler (last modified: 2023.04.03).
1212
*/
1313

1414
namespace phpMussel\Web;
@@ -156,20 +156,20 @@ public function scan()
156156
}
157157

158158
if (is_array($fileData['name'])) {
159-
array_walk_recursive($fileData['name'], function ($item, $key) use (&$FilesData) {
160-
$FilesData['name'][] = $item;
159+
array_walk_recursive($fileData['name'], function ($Item, $Key) use (&$FilesData) {
160+
$FilesData['name'][] = $Item;
161161
});
162-
array_walk_recursive($fileData['type'], function ($item, $key) use (&$FilesData) {
163-
$FilesData['type'][] = $item;
162+
array_walk_recursive($fileData['type'], function ($Item, $Key) use (&$FilesData) {
163+
$FilesData['type'][] = $Item;
164164
});
165-
array_walk_recursive($fileData['tmp_name'], function ($item, $key) use (&$FilesData) {
166-
$FilesData['tmp_name'][] = $item;
165+
array_walk_recursive($fileData['tmp_name'], function ($Item, $Key) use (&$FilesData) {
166+
$FilesData['tmp_name'][] = $Item;
167167
});
168-
array_walk_recursive($fileData['error'], function ($item, $key) use (&$FilesData) {
169-
$FilesData['error'][] = $item;
168+
array_walk_recursive($fileData['error'], function ($Item, $Key) use (&$FilesData) {
169+
$FilesData['error'][] = $Item;
170170
});
171-
array_walk_recursive($fileData['size'], function ($item, $key) use (&$FilesData) {
172-
$FilesData['size'][] = $item;
171+
array_walk_recursive($fileData['size'], function ($Item, $Key) use (&$FilesData) {
172+
$FilesData['size'][] = $Item;
173173
});
174174
} else {
175175
$FilesData['name'][] = $fileData['name'];
@@ -306,11 +306,11 @@ public function scan()
306306
/** Pull relevant client-specified L10N data. */
307307
if (!empty($this->Attache)) {
308308
foreach (['denied', 'denied_reason'] as $Pull) {
309-
if (isset($this->ClientL10N->Data[$Pull])) {
310-
$TemplateData[$Pull] = $this->ClientL10N->Data[$Pull];
309+
if (($Try = $this->ClientL10N->getString($Pull)) !== '') {
310+
$TemplateData[$Pull] = $Try;
311311
}
312312
}
313-
unset($Pull);
313+
unset($Try, $Pull);
314314
}
315315

316316
/** Determine which template file to use. */
@@ -385,10 +385,15 @@ public function scan()
385385
) ? '' : '<br /><a href="' . $this->Loader->Configuration['legal']['privacy_policy'] . '">' . $this->ClientL10N->L10N->getString('PrivacyPolicy') . '</a>';
386386

387387
/** Generate HTML output. */
388-
$Output = $this->Loader->parse(
389-
$this->Loader->ClientL10N->Data,
390-
$this->Loader->parse($TemplateData, $this->Loader->readFile($TemplateFile))
391-
);
388+
$Output = $this->Loader->parse($TemplateData, $this->Loader->readFile($TemplateFile));
389+
if (preg_match_all('~\{([A-Za-z\d_ -]+)\}~', $Output, $Matches)) {
390+
foreach ($Matches[1] as $Key) {
391+
if (($Value = $this->Loader->ClientL10N->getString($Key)) !== '') {
392+
$Output = str_replace('{' . $Key . '}', $Value, $Output);
393+
}
394+
}
395+
}
396+
unset($Value, $Key, $Matches);
392397

393398
/** Send email notifications about blocked uploads (if enabled). */
394399
if (strlen($this->Loader->InstanceCache['enable_notifications'])) {

0 commit comments

Comments
 (0)