Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/10.5' into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Corepex committed Dec 7, 2022
2 parents 0f1b80d + a067c31 commit a2ea7bd
Show file tree
Hide file tree
Showing 28 changed files with 113 additions and 58 deletions.
11 changes: 11 additions & 0 deletions bundles/AdminBundle/Controller/Admin/Asset/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,17 @@ protected function addAsset(Request $request, Config $config)
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 @@ -115,11 +115,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 @@ -22,6 +22,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 @@ -390,6 +391,7 @@ public function qrCodeAction(Request $request): BinaryFileResponse
* @param Environment $twig
* @param EditableRenderer $editableRenderer
* @param DocumentResolver $documentResolver
* @param LocaleService $localeService
*
* @return JsonResponse
*
Expand All @@ -402,7 +404,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 @@ -423,6 +426,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 @@ -129,11 +129,14 @@ public function saveAction(Request $request)
} 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
2 changes: 1 addition & 1 deletion bundles/AdminBundle/Controller/Admin/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,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/Controller/Admin/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function addAction(Request $request)
{
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 @@ -91,7 +91,7 @@ public function updateAction(Request $request)
$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 @@ -113,7 +113,7 @@ public function treeGetChildrenByIdAction(Request $request)
{
$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 @@ -209,7 +209,7 @@ protected function convertTagToArray(Tag $tag, $showSelection, $assignedTagIds,
public function loadTagsForElementAction(Request $request)
{
$assginmentCId = (int)$request->get('assignmentCId');
$assginmentCType = strip_tags($request->get('assignmentCType'));
$assginmentCType = strip_tags($request->get('assignmentCType', ''));

$assignedTagArray = [];
if ($assginmentCId && $assginmentCType) {
Expand All @@ -233,7 +233,7 @@ public function loadTagsForElementAction(Request $request)
public function addTagToElementAction(Request $request)
{
$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 @@ -256,7 +256,7 @@ public function addTagToElementAction(Request $request)
public function removeTagFromElementAction(Request $request)
{
$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 @@ -280,7 +280,7 @@ public function removeTagFromElementAction(Request $request)
public function getBatchAssignmentJobsAction(Request $request, EventDispatcherInterface $eventDispatcher)
{
$elementId = (int)$request->get('elementId');
$elementType = strip_tags($request->get('elementType'));
$elementType = strip_tags($request->get('elementType', ''));

$idList = [];
switch ($elementType) {
Expand Down Expand Up @@ -423,7 +423,7 @@ private function getSubDocumentIds(\Pimcore\Model\Document $document, EventDispa
*/
public function doBatchAssignmentAction(Request $request)
{
$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 @@ -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
6 changes: 5 additions & 1 deletion bundles/AdminBundle/Resources/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 @@ -178,6 +178,7 @@ pimcore.object.helpers.gridTabAbstract = Class.create({
}.bind(this),
"keydown": function (field, key) {
if (key.getKey() == key.ENTER) {
this.sqlFilter = field.getValue();
this.updateSqlFilter();
}
}.bind(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,14 @@ pimcore.object.tags.advancedManyToManyObjectRelation = Class.create(pimcore.obje
var renderer = null;
var listeners = null;

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

renderer = Ext.util.Format.numberRenderer();
} else if (this.fieldConfig.columns[i].type == "text" && !readOnly) {
cellEditor = function() {
return new Ext.form.TextField({});
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 @@ -789,7 +793,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
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 @@ -452,7 +452,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
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function start(Request $request, AuthenticationException $authException =
return $response;
}

$event = new LoginRedirectEvent(self::PIMCORE_ADMIN_LOGIN, ['perspective' => strip_tags($request->get('perspective'))]);
$event = new LoginRedirectEvent(self::PIMCORE_ADMIN_LOGIN, ['perspective' => strip_tags($request->get('perspective', ''))]);
$this->dispatcher->dispatch($event, AdminEvents::LOGIN_REDIRECT);

$url = $this->router->generate($event->getRouteName(), $event->getRouteParams());
Expand Down
2 changes: 1 addition & 1 deletion bundles/AdminBundle/Security/Guard/AdminAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,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
2 changes: 0 additions & 2 deletions bundles/CoreBundle/Resources/config/pimcore/test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
framework:
test: ~
session:
storage_factory_id: session.storage.factory.mock_file
profiler: false
mailer:
transports:
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@
"symfony/symfony": "*",
"symfony/monolog-bundle": "3.6.0",
"doctrine/doctrine-migrations-bundle": "3.1.0",
"sabre/dav": "4.2.2"
"sabre/dav": "4.2.2",
"thecodingmachine/safe": "<2.0"
},
"require-dev": {
"codeception/codeception": "^4.1.12",
"codeception/module-symfony": "^1.6.0",
"codeception/phpunit-wrapper": "^9",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-symfony": "^1.2.14",
Expand Down
Loading

0 comments on commit a2ea7bd

Please sign in to comment.