Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.2' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
robertSt7 committed Dec 6, 2023
2 parents a8b9492 + 6736cf0 commit d39a6ed
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 33 deletions.
12 changes: 12 additions & 0 deletions public/js/pimcore/asset/gridexport/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ pimcore.asset.gridexport.csv = Class.create(pimcore.element.gridexport.abstract,
labelWidth: 200,
value: ';',
allowBlank: false
}),
new Ext.form.ComboBox({
fieldLabel: t('header'),
name: 'header',
store: [
['name', t('system_key')],
['title', t('label')],
['no_header', t('no_header')]
],
labelWidth: 200,
value: 'title',
forceSelection: true,
})
]
});
Expand Down
20 changes: 20 additions & 0 deletions public/js/pimcore/asset/gridexport/xlsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ pimcore.asset.gridexport.xlsx = Class.create(pimcore.element.gridexport.abstract

getDownloadUrl: function(fileHandle) {
return Routing.generate('pimcore_admin_asset_assethelper_downloadxlsxfile', {fileHandle: fileHandle});
},

getExportSettingsContainer: function () {
return new Ext.form.FieldSet({
title: t('export_xlsx'),
items: [
new Ext.form.ComboBox({
fieldLabel: t('header'),
name: 'header',
store: [
['name', t('system_key')],
['title', t('label')],
['no_header', t('no_header')]
],
labelWidth: 200,
value: 'title',
forceSelection: true,
})
]
});
}
});

Expand Down
4 changes: 4 additions & 0 deletions public/js/pimcore/asset/metadata/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ pimcore.asset.metadata.grid = Class.create({
//enable different editors per row
editor.editors.each(function (e) {
try {
const fieldType = e.fieldInfo?.layout?.fieldtype;
if (fieldType === 'manyToManyRelation' || fieldType === 'multiselect') {
return;
}
// complete edit, so the value is stored when hopping around with TAB
e.completeEdit();
Ext.destroy(e);
Expand Down
12 changes: 6 additions & 6 deletions public/js/pimcore/element/helpers/gridCellEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ Ext.define('pimcore.element.helpers.gridCellEditor', {
this.callParent();
},

getValue: function() {
return Math.random();
},

startEdit: function(el, value, /* private: false means don't focus*/
doFocus) {

Expand Down Expand Up @@ -121,7 +117,11 @@ Ext.define('pimcore.element.helpers.gridCellEditor', {
text: t("save"),
iconCls: 'pimcore_icon_save',
handler: function() {
var newValue = tag.getCellEditValue();
if (typeof tag.isDirty === 'function' && tag.isDirty() === false) {
this.editWin.close();
return;
}
const newValue = tag.getCellEditValue();
this.setValue(newValue);
this.completeEdit(false);
this.editWin.close();
Expand Down Expand Up @@ -149,7 +149,7 @@ Ext.define('pimcore.element.helpers.gridCellEditor', {
startValue = me.startValue,
value;

if(fieldInfo.layout.noteditable) {
if (fieldInfo.layout.noteditable) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions public/js/pimcore/object/gridexport/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pimcore.object.gridexport.csv = Class.create(pimcore.element.gridexport.abstract
fieldLabel: t('header'),
name: 'header',
store: [
['name', t('name')],
['title', t('title')],
['name', t('system_key')],
['title', t('label')],
['no_header', t('no_header')]
],
labelWidth: 200,
Expand Down
4 changes: 2 additions & 2 deletions public/js/pimcore/object/gridexport/xlsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ pimcore.object.gridexport.xlsx = Class.create(pimcore.element.gridexport.abstrac
fieldLabel: t('header'),
name: 'header',
store: [
['name', t('name')],
['title', t('title')],
['name', t('system_key')],
['title', t('label')],
['no_header', t('no_header')]
],
labelWidth: 200,
Expand Down
2 changes: 2 additions & 0 deletions public/js/pimcore/settings/user/user/keyBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pimcore.settings.user.user.keyBindings = Class.create({
if (code.key) {
if (code.key >= 112 && code.key <= 123) {
parts.push("F" + (code.key - 111));
} else if(code.key === 32) {
parts.push(t("Space"));
} else {
parts.push(String.fromCharCode(code.key));
}
Expand Down
35 changes: 24 additions & 11 deletions src/Controller/Admin/Asset/AssetHelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ public function doExportAction(Request $request): JsonResponse
$settings = json_decode($request->get('settings'), true);
$delimiter = $settings['delimiter'] ?? ';';
$language = str_replace('default', '', $request->get('language'));
$header = $settings['header'] ?? 'title';

$list = new Asset\Listing();

Expand All @@ -742,11 +743,11 @@ public function doExportAction(Request $request): JsonResponse
$list->setCondition('id IN (' . implode(',', $quotedIds) . ')');
$list->setOrderKey(' FIELD(id, ' . implode(',', $quotedIds) . ')', false);

$fields = $request->get('fields');
$fields = json_decode($request->get('fields')[0], true);

$addTitles = (bool) $request->get('initial');

$csv = $this->getCsvData($request, $language, $list, $fields, $addTitles);
$csv = $this->getCsvData($language, $list, $fields, $header, $addTitles);

try {
$storage = Storage::get('temp');
Expand All @@ -758,6 +759,10 @@ public function doExportAction(Request $request): JsonResponse
stream_copy_to_stream($fileStream, $temp, null, 0);

$firstLine = true;
if ($request->get('initial') && $header === 'no_header') {
$firstLine = false;
}

foreach ($csv as $line) {
if ($addTitles && $firstLine) {
$firstLine = false;
Expand Down Expand Up @@ -790,18 +795,26 @@ public function encodeFunc(?string $value): string
return '"' . $value . '"';
}

protected function getCsvData(Request $request, string $language, Asset\Listing $list, array $fields, bool $addTitles = true): array
{
protected function getCsvData(
string $language,
Asset\Listing $list,
array $fields,
string $header,
bool $addTitles = true
): array {
//create csv
$csv = [];

$unsupportedFields = ['preview~system', 'size~system'];
$fields = array_diff($fields, $unsupportedFields);
$unsupportedFields = [0 => 'preview~system', 1 => 'size~system'];
$fields = array_filter($fields, function ($field) use ($unsupportedFields) {
return !in_array($field['key'], $unsupportedFields);
});

if ($addTitles) {
if ($addTitles && $header != 'no_header') {
$columns = $fields;
foreach ($columns as $columnIdx => $columnKey) {
$columns[$columnIdx] = '"' . $columnKey . '"';
$titleIdx = $header === 'name' ? 'key' : 'label';
foreach ($columns as $columnIdx => $columnKeys) {
$columns[$columnIdx] = '"' . $columnKeys[$titleIdx] . '"';
}
$csv[] = $columns;
}
Expand All @@ -810,7 +823,7 @@ protected function getCsvData(Request $request, string $language, Asset\Listing
if ($fields) {
$dataRows = [];
foreach ($fields as $field) {
$fieldDef = explode('~', $field);
$fieldDef = explode('~', $field['key']);
$getter = 'get' . ucfirst($fieldDef[0]);

if (isset($fieldDef[1])) {
Expand All @@ -821,7 +834,7 @@ protected function getCsvData(Request $request, string $language, Asset\Listing
$data = $asset->getMetadata($fieldDef[0], $fieldDef[1], true);
}
} else {
$data = $asset->getMetadata($field, $language, true);
$data = $asset->getMetadata($field['key'], $language, true);
}

if ($data instanceof Element\ElementInterface) {
Expand Down
29 changes: 22 additions & 7 deletions src/Controller/Admin/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Pimcore\Logger;
use Pimcore\Model\User;
use Pimcore\Security\SecurityHelper;
use Pimcore\SystemSettingsConfig;
use Pimcore\Tool;
use Pimcore\Tool\Authentication;
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
Expand All @@ -44,6 +45,7 @@
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\UserInterface;
Expand Down Expand Up @@ -194,8 +196,13 @@ public function loginCheckAction(Request $request): RedirectResponse
/**
* @Route("/login/lostpassword", name="pimcore_admin_login_lostpassword")
*/
public function lostpasswordAction(Request $request, CsrfProtectionHandler $csrfProtection, Config $config, RateLimiterFactory $resetPasswordLimiter): Response
{
public function lostpasswordAction(
Request $request,
CsrfProtectionHandler $csrfProtection,
Config $config,
RateLimiterFactory $resetPasswordLimiter,
RouterInterface $router
): Response {
$params = $this->buildLoginPageViewParams($config);
$error = null;

Expand Down Expand Up @@ -226,12 +233,20 @@ public function lostpasswordAction(Request $request, CsrfProtectionHandler $csrf
if (!$error) {
$token = Authentication::generateTokenByUser($user);

$loginUrl = $this->generateUrl('pimcore_admin_login_check', [
'token' => $token,
'reset' => 'true',
], UrlGeneratorInterface::ABSOLUTE_URL);

try {
$domain = SystemSettingsConfig::get()['general']['domain'];
if (!$domain) {
throw new \Exception('No main domain set in system settings, unable to generate reset password link');
}

$context = $router->getContext();
$context->setHost($domain);

$loginUrl = $this->generateUrl('pimcore_admin_login_check', [
'token' => $token,
'reset' => 'true',
], UrlGeneratorInterface::ABSOLUTE_URL);

$event = new LostPasswordEvent($user, $loginUrl);
$this->eventDispatcher->dispatch($event, AdminEvents::LOGIN_LOSTPASSWORD);

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/WorkflowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\WorkflowInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
Expand Down Expand Up @@ -347,7 +347,7 @@ private function customHtmlResponse(?CustomHtmlServiceInterface $customHtmlServi
/**
* @throws \Exception
*/
private function getWorkflowSvg(Workflow $workflow): string
private function getWorkflowSvg(WorkflowInterface $workflow): string
{
$marking = $workflow->getMarking($this->element);

Expand Down
6 changes: 3 additions & 3 deletions src/Service/Workflow/ActionsButtonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Pimcore\Model\Element\ElementInterface;
use Pimcore\Workflow\Manager;
use Pimcore\Workflow\Transition;
use Symfony\Component\Workflow\Workflow;
use Symfony\Component\Workflow\WorkflowInterface;

class ActionsButtonService
{
Expand All @@ -31,7 +31,7 @@ public function __construct(Manager $workflowManager)
$this->workflowManager = $workflowManager;
}

public function getAllowedTransitions(Workflow $workflow, ElementInterface $element): array
public function getAllowedTransitions(WorkflowInterface $workflow, ElementInterface $element): array
{
$allowedTransitions = [];

Expand All @@ -56,7 +56,7 @@ public function getAllowedTransitions(Workflow $workflow, ElementInterface $elem
return $allowedTransitions;
}

public function getGlobalActions(Workflow $workflow, ElementInterface $element): array
public function getGlobalActions(WorkflowInterface $workflow, ElementInterface $element): array
{
$globalActions = [];
foreach ($this->workflowManager->getGlobalActions($workflow->getName()) as $globalAction) {
Expand Down
1 change: 1 addition & 0 deletions translations/admin.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ cols: Columns
log_search_message: Message
batch_export_confirmation: You are about to export %s dataObjects. Do you want to continue ?
header: Header
system_key: System Key
no_header: No Header
delete_entire_folder_question: This operation will delete the entire parent/folder. You may not be able to fully undo this operation.
allow_to_clear_relation: Allow to clear all relations of this field
Expand Down

0 comments on commit d39a6ed

Please sign in to comment.