Skip to content

Commit

Permalink
Merge branch '4.x' of https://github.com/craftcms/cms into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 27, 2024
2 parents 8f5e664 + 5755af3 commit 5052a30
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 124 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Fixed a bug where custom fields were getting included in rendered field layout forms, even if their `getInputHtml()` method returned an empty string.
- Fixed a bug where the password input on the Set Password page wasn’t including the “Show” button.
- Fixed a SQL error that could occur if an element was saved with a title longer than 255 characters.
- Fixed a bug where some UI messages began with a lowercase letter in some languages. ([#16354](https://github.com/craftcms/cms/issues/16354))
- Fixed errors that could occur when working with field layouts for element types that are no longer installed. ([#16352](https://github.com/craftcms/cms/issues/16352))
- Fixed an error that could occur when creating nested entries within Matrix fields. ([#16331](https://github.com/craftcms/cms/issues/16331))
- Fixed a bug where element index View menus could include a “Use defaults” button when no view customizations had been made.
Expand Down
28 changes: 14 additions & 14 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -1054,19 +1054,19 @@ public static function actions(string $source): array
if (!$hasActionType(Edit::class)) {
$actions->prepend([
'type' => Edit::class,
'label' => Craft::t('app', 'Edit {type}', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'Edit {type}', [
'type' => static::lowerDisplayName(),
]),
])),
]);
}

// Prepend View?
if (static::hasUris() && !$hasActionType(ViewAction::class)) {
$actions->prepend([
'type' => ViewAction::class,
'label' => Craft::t('app', 'View {type}', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'View {type}', [
'type' => static::lowerDisplayName(),
]),
])),
]);
}

Expand Down Expand Up @@ -3795,9 +3795,9 @@ protected function safeActionMenuItems(): array
$items[] = [
'id' => $editId,
'icon' => 'edit',
'label' => Craft::t('app', 'Edit {type}', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'Edit {type}', [
'type' => static::lowerDisplayName(),
]),
])),
];

$view = Craft::$app->getView();
Expand Down Expand Up @@ -3882,9 +3882,9 @@ protected function destructiveActionMenuItems(): array
if ($canDeleteForSite) {
$items[] = [
'icon' => 'remove',
'label' => Craft::t('app', 'Delete {type} for this site', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type} for this site', [
'type' => $isUnpublishedDraft ? Craft::t('app', 'draft') : static::lowerDisplayName(),
]),
])),
'action' => 'elements/delete-for-site',
'params' => [
'elementId' => $this->getCanonicalId(),
Expand All @@ -3902,9 +3902,9 @@ protected function destructiveActionMenuItems(): array
if ($canDeleteCanonical) {
$items[] = [
'icon' => 'trash',
'label' => Craft::t('app', 'Delete {type}', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type}', [
'type' => $isUnpublishedDraft ? Craft::t('app', 'draft') : static::lowerDisplayName(),
]),
])),
'action' => $isUnpublishedDraft ? 'elements/delete-draft' : 'elements/delete',
'params' => [
'elementId' => $this->getCanonicalId(),
Expand All @@ -3922,9 +3922,9 @@ protected function destructiveActionMenuItems(): array
if ($canDeleteForSite) {
$items[] = [
'icon' => 'remove',
'label' => Craft::t('app', 'Delete {type} for this site', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type} for this site', [
'type' => Craft::t('app', 'draft'),
]),
])),
'action' => 'elements/delete-for-site',
'params' => [
'elementId' => $this->getCanonicalId(),
Expand All @@ -3942,9 +3942,9 @@ protected function destructiveActionMenuItems(): array
// Delete draft
$items[] = [
'icon' => 'trash',
'label' => Craft::t('app', 'Delete {type}', [
'label' => StringHelper::upperCaseFirst(Craft::t('app', 'Delete {type}', [
'type' => Craft::t('app', 'draft'),
]),
])),
'action' => 'elements/delete-draft',
'params' => [
'elementId' => $this->getCanonicalId(),
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public function actionSaveAsset(): ?Response
if (!Craft::$app->getElements()->saveElement($asset)) {
return $this->asModelFailure(
$asset,
Craft::t('app', 'Couldn’t save {type}.', [
StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => Asset::lowerDisplayName(),
]),
])),
$assetVariable
);
}
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use craft\errors\InvalidElementException;
use craft\helpers\Cp;
use craft\helpers\ElementHelper;
use craft\helpers\StringHelper;
use craft\helpers\UrlHelper;
use craft\models\CategoryGroup;
use craft\models\CategoryGroup_SiteSettings;
Expand Down Expand Up @@ -279,9 +280,9 @@ public function actionCreate(string $groupHandle): ?Response
// Save it
$category->setScenario(Element::SCENARIO_ESSENTIALS);
if (!Craft::$app->getDrafts()->saveElementAsDraft($category, Craft::$app->getUser()->getId(), null, null, false)) {
return $this->asModelFailure($category, Craft::t('app', 'Couldn’t create {type}.', [
return $this->asModelFailure($category, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => Category::lowerDisplayName(),
]), 'category');
])), 'category');
}

// Set its position in the structure if a before/after param was passed
Expand Down Expand Up @@ -370,9 +371,9 @@ public function actionSaveCategory(): ?Response
if (!Craft::$app->getElements()->saveElement($category)) {
return $this->asModelFailure(
$category,
Craft::t('app', 'Couldn’t save {type}.', [
StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => Category::lowerDisplayName(),
]),
])),
$categoryVariable
);
}
Expand Down
36 changes: 18 additions & 18 deletions src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ public function actionCreate(): Response
// Save it
$element->setScenario(Element::SCENARIO_ESSENTIALS);
if (!Craft::$app->getDrafts()->saveElementAsDraft($element, $user->id, null, null, false)) {
return $this->_asFailure($element, Craft::t('app', 'Couldn’t create {type}.', [
return $this->_asFailure($element, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => $element::lowerDisplayName(),
]));
])));
}

// Redirect to its edit page
Expand Down Expand Up @@ -454,9 +454,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
if ($isUnpublishedDraft) {
if ($canSaveCanonical) {
$response
->submitButtonLabel(Craft::t('app', 'Create {type}', [
->submitButtonLabel(StringHelper::upperCaseFirst(Craft::t('app', 'Create {type}', [
'type' => $element::lowerDisplayName(),
]))
])))
->action('elements/apply-draft')
->redirectUrl("$redirectUrl#");
} else {
Expand All @@ -470,9 +470,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
->redirectUrl("$redirectUrl#");
} elseif ($isDraft) {
$response
->submitButtonLabel(Craft::t('app', 'Save {type}', [
->submitButtonLabel(StringHelper::upperCaseFirst(Craft::t('app', 'Save {type}', [
'type' => Craft::t('app', 'draft'),
]))
])))
->action('elements/save-draft')
->redirectUrl("{cpEditUrl}");
} else {
Expand Down Expand Up @@ -512,9 +512,9 @@ public function actionEdit(?ElementInterface $element, ?int $elementId = null):
}

if ($canSaveCanonical && $isUnpublishedDraft) {
$response->addAltAction(Craft::t('app', 'Save {type}', [
$response->addAltAction(StringHelper::upperCaseFirst(Craft::t('app', 'Save {type}', [
'type' => Craft::t('app', 'draft'),
]), [
])), [
'action' => 'elements/save-draft',
'redirect' => "$redirectUrl#",
'eventData' => ['autosave' => false],
Expand Down Expand Up @@ -1271,9 +1271,9 @@ public function actionSave(): ?Response
}

if (!$success) {
return $this->_asFailure($element, Craft::t('app', 'Couldn’t save {type}.', [
return $this->_asFailure($element, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => $element::lowerDisplayName(),
]));
])));
}

$elementsService->trackActivity($element, ElementActivity::TYPE_SAVE);
Expand Down Expand Up @@ -1410,9 +1410,9 @@ public function actionSaveNestedElementForDerivative(): ?Response

if (!$success) {
$transaction->rollBack();
return $this->_asFailure($element, Craft::t('app', 'Couldn’t save {type}.', [
return $this->_asFailure($element, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => $element::lowerDisplayName(),
]));
])));
}

if ($element->getIsDraft()) {
Expand Down Expand Up @@ -1675,9 +1675,9 @@ public function actionSaveDraft(): ?Response

if (!$elementsService->saveElement($element)) {
$transaction->rollBack();
return $this->_asFailure($element, Craft::t('app', 'Couldn’t save {type}.', [
return $this->_asFailure($element, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => Craft::t('app', 'draft'),
]));
])));
}

$transaction->commit();
Expand Down Expand Up @@ -1895,13 +1895,13 @@ public function actionApplyDraft(): ?Response
private function _asAppyDraftFailure(ElementInterface $element): ?Response
{
if ($element->getIsUnpublishedDraft()) {
$message = Craft::t('app', 'Couldn’t create {type}.', [
$message = StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => $element::lowerDisplayName(),
]);
]));
} elseif ($element->isProvisionalDraft) {
$message = Craft::t('app', 'Couldn’t save {type}.', [
$message = StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => $element::lowerDisplayName(),
]);
]));
} else {
$message = Craft::t('app', 'Couldn’t apply draft.');
}
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use craft\helpers\DateTimeHelper;
use craft\helpers\ElementHelper;
use craft\helpers\Html;
use craft\helpers\StringHelper;
use craft\helpers\UrlHelper;
use craft\models\Section;
use craft\models\Section_SiteSettings;
Expand Down Expand Up @@ -187,9 +188,9 @@ public function actionCreate(?string $section = null): ?Response
DateTimeHelper::resume();

if (!$success) {
return $this->asModelFailure($entry, Craft::t('app', 'Couldn’t create {type}.', [
return $this->asModelFailure($entry, StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => Entry::lowerDisplayName(),
]), 'entry');
])), 'entry');
}

// Set its position in the structure if a before/after param was passed
Expand Down
9 changes: 5 additions & 4 deletions src/controllers/GlobalsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use craft\elements\GlobalSet;
use craft\helpers\Cp;
use craft\helpers\Json;
use craft\helpers\StringHelper;
use craft\web\Controller;
use yii\web\BadRequestHttpException;
use yii\web\ForbiddenHttpException;
Expand Down Expand Up @@ -79,9 +80,9 @@ public function actionSaveSet(): ?Response

// Save it
if (!Craft::$app->getGlobals()->saveSet($globalSet)) {
$this->setFailFlash(Craft::t('app', 'Couldn’t save {type}.', [
$this->setFailFlash(StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => GlobalSet::lowerDisplayName(),
]));
])));

// Send the global set back to the template
Craft::$app->getUrlManager()->setRouteParams([
Expand Down Expand Up @@ -221,9 +222,9 @@ public function actionSaveContent(): ?Response
$globalSet->setScenario(Element::SCENARIO_LIVE);

if (!Craft::$app->getElements()->saveElement($globalSet)) {
$this->setFailFlash(Craft::t('app', 'Couldn’t save {type}.', [
$this->setFailFlash(StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t save {type}.', [
'type' => GlobalSet::lowerDisplayName(),
]));
])));

// Send the global set back to the template
Craft::$app->getUrlManager()->setRouteParams([
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/MatrixController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public function actionCreateEntry(): Response

$entry->setScenario(Element::SCENARIO_ESSENTIALS);
if (!Craft::$app->getDrafts()->saveElementAsDraft($entry, $user->id, markAsSaved: false)) {
return $this->asFailure(Craft::t('app', 'Couldn’t create {type}.', [
return $this->asFailure(StringHelper::upperCaseFirst(Craft::t('app', 'Couldn’t create {type}.', [
'type' => Entry::lowerDisplayName(),
]));
])));
}

/** @var EntryQuery|ElementCollection $value */
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/SystemSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use craft\helpers\Component;
use craft\helpers\Html;
use craft\helpers\MailerHelper;
use craft\helpers\StringHelper;
use craft\helpers\UrlHelper;
use craft\mail\Mailer;
use craft\mail\transportadapters\BaseTransportAdapter;
Expand Down Expand Up @@ -260,9 +261,9 @@ public function actionGlobalSetIndex(): Response
],
],
'globalSets' => Craft::$app->getGlobals()->getAllSets(),
'buttonLabel' => Craft::t('app', 'New {type}', [
'buttonLabel' => StringHelper::upperCaseFirst(Craft::t('app', 'New {type}', [
'type' => GlobalSet::lowerDisplayName(),
]),
])),
]);
}

Expand Down
Loading

0 comments on commit 5052a30

Please sign in to comment.