Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"cbschuld/browser.php": "^1.9.6",
"endroid/qr-code": "^4 || ^5.1",
"phpoffice/phpspreadsheet": "^2.2 || ^3.3",
"open-dxp/opendxp": "^1.1.2",
"open-dxp/opendxp": "^1.2.0",
"symfony/webpack-encore-bundle": "^2.1.1"
},
"require-dev": {
Expand Down
13 changes: 7 additions & 6 deletions src/Controller/Admin/DataObject/ClassController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use OpenDxp\Bundle\AdminBundle\Event\AdminEvents;
use OpenDxp\Controller\KernelControllerEventInterface;
use OpenDxp\Db;
use OpenDxp\Helper\FileSystemHelper;
use OpenDxp\Logger;
use OpenDxp\Model\Asset;
use OpenDxp\Model\DataObject;
Expand Down Expand Up @@ -1722,17 +1723,17 @@ public function getIconsAction(Request $request, EventDispatcherInterface $event
}

if ($type === null) {
$classIcons = rscandir($iconDir . '/object-icons/');
$colorIcons = rscandir($iconDir . '/flat-color-icons/');
$twemoji = rscandir($iconDir . '/twemoji/');
$classIcons = FileSystemHelper::scanDirectory($iconDir . '/object-icons/');
$colorIcons = FileSystemHelper::scanDirectory($iconDir . '/flat-color-icons/');
$twemoji = FileSystemHelper::scanDirectory($iconDir . '/twemoji/');
$icons = [...$classIcons, ...$colorIcons, ...$twemoji];
} else {
$icons = match($type) {
'color' => rscandir($iconDir . '/flat-color-icons/'),
'white' => rscandir($iconDir . '/flat-white-icons/'),
'color' => FileSystemHelper::scanDirectory($iconDir . '/flat-color-icons/'),
'white' => FileSystemHelper::scanDirectory($iconDir . '/flat-white-icons/'),
'twemoji-1', 'twemoji-2', 'twemoji-3',
'twemoji_variants-1', 'twemoji_variants-2', 'twemoji_variants-3'
=> rscandir($iconDir . '/twemoji/'),
=> FileSystemHelper::scanDirectory($iconDir . '/twemoji/'),
default => [],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OpenDxp\Bundle\AdminBundle\Controller\AdminAbstractController;
use OpenDxp\Controller\KernelControllerEventInterface;
use OpenDxp\Db;
use OpenDxp\Helper\ArrayHelper;
use OpenDxp\Model\DataObject;
use OpenDxp\Model\DataObject\ClassDefinition\Data\LayoutDefinitionEnrichmentInterface;
use OpenDxp\Model\DataObject\Classificationstore;
Expand Down Expand Up @@ -1391,7 +1392,7 @@ public function storetreeAction(Request $request): JsonResponse
public function getPageAction(Request $request): JsonResponse
{
$tableSuffix = $request->get('table');
if (!in_arrayi($tableSuffix, ['keys', 'groups'])) {
if (!ArrayHelper::inArrayCaseInsensitive($tableSuffix, ['keys', 'groups'])) {
$tableSuffix = 'keys';
}

Expand All @@ -1409,11 +1410,11 @@ public function getPageAction(Request $request): JsonResponse
$sortDir = 'ASC';
}

if (!in_arrayi($sortDir, ['DESC', 'ASC'])) {
if (!ArrayHelper::inArrayCaseInsensitive($sortDir, ['DESC', 'ASC'])) {
$sortDir = 'DESC';
}

if (!in_arrayi($sortKey, ['name', 'title', 'description', 'id', 'type', 'creationDate', 'modificationDate', 'enabled', 'parentId', 'storeId'])) {
if (!ArrayHelper::inArrayCaseInsensitive($sortKey, ['name', 'title', 'description', 'id', 'type', 'creationDate', 'modificationDate', 'enabled', 'parentId', 'storeId'])) {
$sortKey = 'name';
}

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ private function getInstanceId(): string
protected function addSystemVarSettings(array &$settings): static
{
// upload limit
$max_upload = filesize2bytes(ini_get('upload_max_filesize') . 'B');
$max_post = filesize2bytes(ini_get('post_max_size') . 'B');
$max_upload = OpenDxp\Helper\FileSystemHelper::filesizeToBytes(ini_get('upload_max_filesize') . 'B');
$max_post = OpenDxp\Helper\FileSystemHelper::filesizeToBytes(ini_get('post_max_size') . 'B');
$upload_mb = min($max_upload, $max_post) ?: $max_upload;

$settings['upload_max_filesize'] = (int) $upload_mb;
Expand Down
7 changes: 4 additions & 3 deletions src/Controller/Admin/MiscController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use OpenDxp\Bundle\AdminBundle\Tool as AdminTool;
use OpenDxp\Config;
use OpenDxp\Controller\Config\ControllerDataProvider;
use OpenDxp\Helper\FileSystemHelper;
use OpenDxp\Localization\LocaleServiceInterface;
use OpenDxp\Tool;
use OpenDxp\Tool\Storage;
Expand Down Expand Up @@ -272,9 +273,9 @@ public function iconListAction(Request $request, ?Profiler $profiler): Response
$extraInfo = null;

$icons = match ($type) {
'color' => rscandir($iconDir . '/flat-color-icons/'),
'white' => rscandir($iconDir . '/flat-white-icons/'),
'twemoji' => rscandir($iconDir . '/twemoji/'),
'color' => FileSystemHelper::scanDirectory($iconDir . '/flat-color-icons/'),
'white' => FileSystemHelper::scanDirectory($iconDir . '/flat-white-icons/'),
'twemoji' => FileSystemHelper::scanDirectory($iconDir . '/twemoji/'),
'flags' => $this->getFlags(),
default => []
};
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use OpenDxp\Cache\Symfony\CacheClearer;
use OpenDxp\Db;
use OpenDxp\Event\SystemEvents;
use OpenDxp\Helper\FileSystemHelper;
use OpenDxp\Helper\StopMessengerWorkersTrait;
use OpenDxp\Localization\LocaleServiceInterface;
use OpenDxp\Logger;
Expand Down Expand Up @@ -586,7 +587,7 @@ public function clearTemporaryFilesAction(EventDispatcherInterface $eventDispatc
Tool\Storage::get('asset_cache')->deleteDirectory('/');

// system files
recursiveDelete(OPENDXP_SYSTEM_TEMP_DIRECTORY, false);
FileSystemHelper::recursiveDelete(OPENDXP_SYSTEM_TEMP_DIRECTORY, false);

$eventDispatcher->dispatch(new GenericEvent(), SystemEvents::CACHE_CLEAR_TEMPORARY_FILES);

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private function addAdminSessionAttributeBags(ArrayNodeDefinition $adminNode): v
->useAttributeAsKey('name')
->beforeNormalization()
->ifArray()->then(function ($v) use ($normalizers) {
if (isAssocArray($v)) {
if (!array_is_list($v)) {
return $normalizers['assoc']($v);
}

Expand Down
5 changes: 3 additions & 2 deletions src/EventListener/UsageStatisticsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use OpenDxp\Bundle\CoreBundle\EventListener\Traits\OpenDxpContextAwareTrait;
use OpenDxp\Config;
use OpenDxp\Helper\StringHelper;
use OpenDxp\Http\Request\Resolver\OpenDxpContextResolver;
use OpenDxp\Security\User\TokenStorageUserResolver;
use Psr\Log\LoggerAwareTrait;
Expand Down Expand Up @@ -85,10 +86,10 @@ protected function getParams(Request $request): array
$requestParams = [...$request->query->all(), ...$request->request->all()];

foreach ($requestParams as $key => $value) {
if (is_json($value)) {
if (StringHelper::isValidJson($value)) {
$value = json_decode($value);
if (is_array($value)) {
array_walk_recursive($value, function (&$item, $key): void {
array_walk_recursive($value, static function (&$item, $key): void {
if (str_contains((string)$key, 'pass')) {
$item = '*************';
}
Expand Down
3 changes: 2 additions & 1 deletion src/Security/ContentSecurityPolicyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace OpenDxp\Bundle\AdminBundle\Security;

use OpenDxp\Config;
use OpenDxp\Helper\StringHelper;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -145,7 +146,7 @@ public function getNonceHtmlAttribute(): string
private function getNonce(): string
{
if (!$this->nonce) {
$this->nonce = generateRandomSymfonySecret();
$this->nonce = StringHelper::generateRandomSymfonySecret();
}

return $this->nonce;
Expand Down
5 changes: 3 additions & 2 deletions src/Security/CsrfProtectionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace OpenDxp\Bundle\AdminBundle\Security;

use OpenDxp\Helper\StringHelper;
use OpenDxp\Tool\Session;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
Expand Down Expand Up @@ -69,9 +70,9 @@ public function getCsrfToken(SessionInterface $session): ?string

public function regenerateCsrfToken(SessionInterface $session, bool $force = true): void
{
$this->csrfToken = Session::useBag($session, function (AttributeBagInterface $adminSession) use ($force) {
$this->csrfToken = Session::useBag($session, static function (AttributeBagInterface $adminSession) use ($force) {
if ($force || !$adminSession->get('csrfToken')) {
$adminSession->set('csrfToken', sha1(generateRandomSymfonySecret()));
$adminSession->set('csrfToken', sha1(StringHelper::generateRandomSymfonySecret()));
}

return $adminSession->get('csrfToken');
Expand Down
2 changes: 1 addition & 1 deletion src/Service/GridData/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function getData(Model\Asset $asset, ?array $fields = null, ?strin
$data[$field] = self::getPreviewThumbnail($asset, ['treepreview' => true, 'width' => 108, 'height' => 70, 'frame' => true]);
} elseif ($fieldDef[0] === 'size') {
$size = $asset->getFileSize();
$data[$field] = formatBytes($size);
$data[$field] = OpenDxp\Helper\FileSystemHelper::formatBytes($size);
}
} else {
if (isset($fieldDef[1])) {
Expand Down
Loading