Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.6' into 11.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	bundles/AdminBundle/Resources/public/js/pimcore/object/tags/advancedManyToManyObjectRelation.js
#	bundles/AdminBundle/Security/Guard/AdminAuthenticator.php
#	bundles/AdminBundle/public/js/pimcore/object/helpers/gridTabAbstract.js
#	bundles/EcommerceFrameworkBundle/src/IndexService/ProductList/ElasticSearch/DefaultElasticSearch8.php
#	bundles/EcommerceFrameworkBundle/src/IndexService/Worker/ElasticSearch/DefaultElasticSearch8.php
#	composer.json
#	lib/Image/Adapter/Imagick.php
#	phpstan-baseline.neon
#	tests/Support/Helper/Pimcore.php
  • Loading branch information
brusch committed Dec 14, 2022
2 parents fba610b + 520f220 commit 1b283ca
Show file tree
Hide file tree
Showing 41 changed files with 824 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,17 @@ pimcore.document.editables.image = Class.create(pimcore.document.editable, {
} catch (e) {
console.log(e);
}
}.bind(this));
}.bind(this),
function (res) {
const response = Ext.decode(res.response.responseText);
if (response && response.success === false) {
pimcore.helpers.showNotification(t("error"), response.message, "error",
res.response.responseText);
} else {
pimcore.helpers.showNotification(t("error"), res, "error",
res.response.responseText);
}
}.bind(this), [] ,this.getType());
},

onNodeOver: function(target, dd, e, data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ pimcore.element.helpers.gridColumnConfig = {
settings = Ext.encode(settings);
params["settings"] = settings;
Ext.Ajax.request({
method: 'POST',
url: this.exportPrepareUrl,
params: params,
success: function (response) {
Expand Down
6 changes: 5 additions & 1 deletion bundles/AdminBundle/public/js/pimcore/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ pimcore.helpers.openMemorizedTabs = function () {
}
};

pimcore.helpers.assetSingleUploadDialog = function (parent, parentType, success, failure, context) {
pimcore.helpers.assetSingleUploadDialog = function (parent, parentType, success, failure, context, type) {

var params = {};
params['parent' + ucfirst(parentType)] = parent;
Expand All @@ -959,6 +959,10 @@ pimcore.helpers.assetSingleUploadDialog = function (parent, parentType, success,
url += "&context=" + Ext.encode(context);
}

if(type) {
url += "&type=" + type;
}

pimcore.helpers.uploadDialog(url, 'Filedata', success, failure);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pimcore.object.helpers.classTree = Class.create({

newNode = fn();

if (con.children) {
if (con.children && newNode) {
for (var i = 0; i < con.children.length; i++) {
this.recursiveAddNode(con.children[i], newNode, brickDescriptor, config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ pimcore.object.tags.advancedManyToManyRelation = Class.create(pimcore.object.tag
var renderer = null;
var listeners = null;

if (this.fieldConfig.columns[i].type == "number" && !readOnly) {
cellEditor = function () {
return new Ext.form.NumberField({});
};
if (this.fieldConfig.columns[i].type == "number") {
if(!readOnly) {
cellEditor = function () {
return new Ext.form.NumberField({});
};
}

renderer = Ext.util.Format.numberRenderer();
} else if (this.fieldConfig.columns[i].type == "text" && !readOnly) {
cellEditor = function () {
return new Ext.form.TextField({});
Expand Down Expand Up @@ -820,7 +824,7 @@ pimcore.object.tags.advancedManyToManyRelation = Class.create(pimcore.object.tag

uploadDialog: function () {
if (!this.fieldConfig.allowMultipleAssignments || (this.fieldConfig["maxItems"] && this.fieldConfig["maxItems"] >= 1)) {
if ((this.store.getData().getSource() || this.store.getData()).count() >= this.fieldConfig.maxItems) {
if (this.fieldConfig.maxItems && (this.store.getData().getSource() || this.store.getData()).count() >= this.fieldConfig.maxItems) {
Ext.Msg.alert(t("error"), t("limit_reached"));
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/AdminBundle/public/js/pimcore/object/tags/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pimcore.object.tags.image = Class.create(pimcore.object.tags.abstract, {
pimcore.helpers.showNotification(t("error"), res, "error",
res.response.responseText);
}
}.bind(this), this.context);
}.bind(this), this.context, this.type);
},

addDataFromSelector: function (item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ pimcore.object.tags.manyToManyRelation = Class.create(pimcore.object.tags.abstra

uploadDialog: function () {
if (!this.fieldConfig.allowMultipleAssignments || (this.fieldConfig["maxItems"] && this.fieldConfig["maxItems"] >= 1)) {
if ((this.store.getData().getSource() || this.store.getData()).count() >= this.fieldConfig.maxItems) {
if (this.fieldConfig.maxItems && (this.store.getData().getSource() || this.store.getData()).count() >= this.fieldConfig.maxItems) {
Ext.Msg.alert(t("error"), t("limit_reached"));
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pimcore.object.tags.objectbricks = Class.create(pimcore.object.tags.abstract, {
dirty: false,
addedTypes: {},
preventDelete: {},
inheritedCount: 0,

initialize: function (data, fieldConfig) {

Expand Down Expand Up @@ -236,7 +237,12 @@ pimcore.object.tags.objectbricks = Class.create(pimcore.object.tags.abstract, {
if (!this.layoutDefinitions[type]) {
return;
}
if (this.fieldConfig.maxItems && this.getCurrentElementsCount() >= this.fieldConfig.maxItems) {

if(blockData && blockData.inherited) {
this.inheritedCount++;
}

if (this.fieldConfig.maxItems && this.getCurrentElementsCount() >= this.fieldConfig.maxItems + this.inheritedCount) {
Ext.Msg.alert(t("error"), t("limit_reached"));
return;
}
Expand Down
6 changes: 3 additions & 3 deletions bundles/AdminBundle/public/js/pimcore/settings/docTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ pimcore.settings.document.doctypes = Class.create({
handler: function (grid, rowIndex) {
var rec = grid.getStore().getAt(rowIndex);
try {
pimcore.globalmanager.get("translationadminmanager").activate(rec.data.name);
pimcore.globalmanager.get("translationdomainmanager").activate(rec.data.name);
}
catch (e) {
pimcore.globalmanager.add("translationadminmanager",
new pimcore.settings.translation.admin(rec.data.name));
pimcore.globalmanager.add("translationdomainmanager",
new pimcore.settings.translation.domain("admin",rec.data.name));
}
}.bind(this)
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ pimcore.settings.properties.predefined = Class.create({
handler: function(grid, rowIndex){
var rec = grid.getStore().getAt(rowIndex);
try {
pimcore.globalmanager.get("translationadminmanager").activate(rec.data.name);
}
catch (e) {
pimcore.globalmanager.add("translationadminmanager",
new pimcore.settings.translation.admin(rec.data.name));
pimcore.globalmanager.get("translationdomainmanager").activate(rec.data.name);
} catch (e) {
pimcore.globalmanager.add("translationdomainmanager",
new pimcore.settings.translation.domain("admin", rec.data.name));
}
}.bind(this)
}]
Expand Down
11 changes: 11 additions & 0 deletions bundles/AdminBundle/src/Controller/Admin/Asset/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,17 @@ protected function addAsset(Request $request, Config $config): array
throw new \Exception('Something went wrong, please check upload_max_filesize and post_max_size in your php.ini as well as the write permissions of your temporary directories.');
}

// check if there is a requested type and if matches the asset type of the uploaded file
$type = $request->get('type');
if ($type) {
$mimetype = MimeTypes::getDefault()->guessMimeType($sourcePath);
$assetType = Asset::getTypeFromMimeMapping($mimetype, $filename);

if ($type !== $assetType) {
throw new \Exception("Mime type does not match with asset type: $type");
}
}

if ($request->get('allowOverwrite') && Asset\Service::pathExists($parentAsset->getRealFullPath().'/'.$filename)) {
$asset = Asset::getByPath($parentAsset->getRealFullPath().'/'.$filename);
$asset->setStream(fopen($sourcePath, 'rb', false, File::getContext()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ protected function updateGridConfigFavourites(?GridConfig $gridConfig, array $me
}

/**
* @Route("/get-export-jobs", name="pimcore_admin_asset_assethelper_getexportjobs", methods={"GET"})
* @Route("/get-export-jobs", name="pimcore_admin_asset_assethelper_getexportjobs", methods={"POST"})
*
* @param Request $request
* @param GridHelperService $gridHelperService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,13 @@ private function prepareObjectData(
LocaleServiceInterface $localeService
): array {
$user = Tool\Admin::getCurrentUser();
$allLanguagesAllowed = false;
$languagePermissions = [];
if (!$user->isAdmin()) {
$languagePermissions = $object->getPermissions('lEdit', $user);

//sets allowed all languages modification when the lEdit column is empty
$allLanguagesAllowed = $languagePermissions['lEdit'] == '';
$languagePermissions = explode(',', $languagePermissions['lEdit']);
if ($languagePermissions['lEdit']) {
$languagePermissions = explode(',', $languagePermissions['lEdit']);
}
}

$class = $object->getClass();
Expand Down Expand Up @@ -258,7 +257,7 @@ private function prepareObjectData(
$brick->$valueSetter($value);
}
} else {
if (!$user->isAdmin() && $languagePermissions) {
if ($languagePermissions) {
$fd = $class->getFieldDefinition($key);
if (!$fd) {
// try to get via localized fields
Expand All @@ -267,7 +266,7 @@ private function prepareObjectData(
$field = $localized->getFieldDefinition($key);
if ($field) {
$currentLocale = $localeService->findLocale();
if (!$allLanguagesAllowed && !in_array($currentLocale, $languagePermissions)) {
if (!in_array($currentLocale, $languagePermissions)) {
continue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ protected function getCsvFile(string $fileHandle): string
}

/**
* @Route("/get-export-jobs", name="getexportjobs", methods={"GET"})
* @Route("/get-export-jobs", name="getexportjobs", methods={"POST"})
*
* @param Request $request
* @param GridHelperService $gridHelperService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,14 @@ public function saveAction(Request $request): JsonResponse
'treeData' => $treeData,
]);
} else {
$draftData = [
'id' => $version->getId(),
'modificationDate' => $version->getDate(),
'isAutoSave' => $version->isAutoSave(),
];
$draftData = [];
if ($version) {
$draftData = [
'id' => $version->getId(),
'modificationDate' => $version->getDate(),
'isAutoSave' => $version->isAutoSave(),
];
}

return $this->adminJson(['success' => true, 'draft' => $draftData]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Pimcore\Document\StaticPageGenerator;
use Pimcore\Http\Request\Resolver\DocumentResolver;
use Pimcore\Http\Request\Resolver\EditmodeResolver;
use Pimcore\Localization\LocaleService;
use Pimcore\Messenger\GeneratePagePreviewMessage;
use Pimcore\Model\Document;
use Pimcore\Model\Document\Targeting\TargetingDocumentInterface;
Expand Down Expand Up @@ -392,6 +393,7 @@ public function qrCodeAction(Request $request): BinaryFileResponse
* @param Environment $twig
* @param EditableRenderer $editableRenderer
* @param DocumentResolver $documentResolver
* @param LocaleService $localeService
*
* @return JsonResponse
*
Expand All @@ -404,7 +406,8 @@ public function areabrickRenderIndexEditmode(
EditmodeEditableDefinitionCollector $definitionCollector,
Environment $twig,
EditableRenderer $editableRenderer,
DocumentResolver $documentResolver
DocumentResolver $documentResolver,
LocaleService $localeService
): JsonResponse {
$blockStateStackData = json_decode($request->get('blockStateStack'), true);
$blockStateStack->loadArray($blockStateStackData);
Expand All @@ -425,6 +428,9 @@ public function areabrickRenderIndexEditmode(
// so we use the attribute as a workaround
$request->attributes->set(EditmodeResolver::ATTRIBUTE_EDITMODE, true);

// setting locale manually here before rendering, to make sure editables use the right locale from document
$localeService->setLocale($document->getProperty('language'));

$areaBlockConfig = json_decode($request->get('areablockConfig'), true);
/** @var Document\Editable\Areablock $areablock */
$areablock = $editableRenderer->getEditable($document, 'areablock', $request->get('realName'), $areaBlockConfig, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,14 @@ public function saveAction(Request $request): JsonResponse
} else {
$this->saveToSession($snippet);

$draftData = [
'id' => $version->getId(),
'modificationDate' => $version->getDate(),
'isAutoSave' => $version->isAutoSave(),
];
$draftData = [];
if ($version) {
$draftData = [
'id' => $version->getId(),
'modificationDate' => $version->getDate(),
'isAutoSave' => $version->isAutoSave(),
];
}

return $this->adminJson(['success' => true, 'draft' => $draftData]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function deeplinkAction(Request $request, EventDispatcherInterface $event

if (preg_match('/(document|asset|object)_([0-9]+)_([a-z]+)/', $queryString, $deeplink)) {
$deeplink = $deeplink[0];
$perspective = strip_tags($request->get('perspective'));
$perspective = strip_tags($request->get('perspective', ''));

if (strpos($queryString, 'token')) {
$event = new LoginRedirectEvent('pimcore_admin_login', [
Expand Down
16 changes: 8 additions & 8 deletions bundles/AdminBundle/src/Controller/Admin/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function addAction(Request $request): JsonResponse
{
try {
$tag = new Tag();
$tag->setName(strip_tags($request->get('text')));
$tag->setName(strip_tags($request->get('text', '')));
$tag->setParentId((int)$request->get('parentId'));
$tag->save();

Expand Down Expand Up @@ -92,7 +92,7 @@ public function updateAction(Request $request): JsonResponse
$tag->setParentId((int)$parentId);
}
if ($request->get('text')) {
$tag->setName(strip_tags($request->get('text')));
$tag->setName(strip_tags($request->get('text', '')));
}

$tag->save();
Expand All @@ -114,7 +114,7 @@ public function treeGetChildrenByIdAction(Request $request): JsonResponse
{
$showSelection = $request->get('showSelection') == 'true';
$assignmentCId = (int)$request->get('assignmentCId');
$assignmentCType = strip_tags($request->get('assignmentCType'));
$assignmentCType = strip_tags($request->get('assignmentCType', ''));

$recursiveChildren = false;
$assignedTagIds = [];
Expand Down Expand Up @@ -201,7 +201,7 @@ protected function convertTagToArray(Tag $tag, bool $showSelection, array $assig
public function loadTagsForElementAction(Request $request): JsonResponse
{
$assginmentCId = (int)$request->get('assignmentCId');
$assginmentCType = strip_tags($request->get('assignmentCType'));
$assginmentCType = strip_tags($request->get('assignmentCType', ''));

$assignedTagArray = [];
if ($assginmentCId && $assginmentCType) {
Expand All @@ -225,7 +225,7 @@ public function loadTagsForElementAction(Request $request): JsonResponse
public function addTagToElementAction(Request $request): JsonResponse
{
$assginmentCId = (int)$request->get('assignmentElementId');
$assginmentCType = strip_tags($request->get('assignmentElementType'));
$assginmentCType = strip_tags($request->get('assignmentElementType', ''));
$tagId = (int)$request->get('tagId');

$tag = Tag::getById($tagId);
Expand All @@ -248,7 +248,7 @@ public function addTagToElementAction(Request $request): JsonResponse
public function removeTagFromElementAction(Request $request): JsonResponse
{
$assginmentCId = (int)$request->get('assignmentElementId');
$assginmentCType = strip_tags($request->get('assignmentElementType'));
$assginmentCType = strip_tags($request->get('assignmentElementType', ''));
$tagId = (int)$request->get('tagId');

$tag = Tag::getById($tagId);
Expand All @@ -272,7 +272,7 @@ public function removeTagFromElementAction(Request $request): JsonResponse
public function getBatchAssignmentJobsAction(Request $request, EventDispatcherInterface $eventDispatcher): JsonResponse
{
$elementId = (int)$request->get('elementId');
$elementType = strip_tags($request->get('elementType'));
$elementType = strip_tags($request->get('elementType', ''));

$idList = [];
switch ($elementType) {
Expand Down Expand Up @@ -409,7 +409,7 @@ private function getSubDocumentIds(\Pimcore\Model\Document $document, EventDispa
*/
public function doBatchAssignmentAction(Request $request): JsonResponse
{
$cType = strip_tags($request->get('elementType'));
$cType = strip_tags($request->get('elementType', ''));
$assignedTags = json_decode($request->get('assignedTags'));
$elementIds = json_decode($request->get('childrenIds'));
$doCleanupTags = $request->get('removeAndApply') == 'true';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
} else {
$url = $this->router->generate('pimcore_admin_index', [
'_dc' => time(),
'perspective' => strip_tags($request->get('perspective')),
'perspective' => strip_tags($request->get('perspective', '')),
]);
}

Expand Down
Loading

0 comments on commit 1b283ca

Please sign in to comment.