mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1774 from open-sausages/pulls/4.0/6258-update-archive-warning-msg
ENHANCEMENT Update archive warning message
This commit is contained in:
commit
3c00c437f4
7
client/dist/js/bundle.js
vendored
7
client/dist/js/bundle.js
vendored
@ -67,10 +67,9 @@ return"http://"!=a.substr(0,7)&&(a=t("base").attr("href")+a),window.open(a,"prin
|
||||
|
||||
|
||||
return i=a?r.default.sprintf(r.default._t("CMSMain.RollbackToVersion"),a):r.default._t("CMSMain.ConfirmRestoreFromLive"),!!confirm(i)&&this._super(e)}}),t(".cms-edit-form .btn-toolbar #Form_EditForm_action_archive").entwine({
|
||||
onclick:function t(e){var n=this.parents("form:first"),a=n.find(":input[name=Version]").val(),i=""
|
||||
return i=r.default.sprintf(r.default._t("CMSMain.Archive"),a),!!confirm(i)&&this._super(e)}}),t(".cms-edit-form .btn-toolbar #Form_EditForm_action_restore").entwine({onclick:function t(e){var n=this.parents("form:first"),a=n.find(":input[name=Version]").val(),i="",s=this.data("toRoot")
|
||||
|
||||
|
||||
onclick:function t(e){var n=this.parents("form:first"),a=""
|
||||
return a=n.find("input[name=ArchiveWarningMessage]").val().replace(/\\n/g,"\n"),!!confirm(a)&&this._super(e)}}),t(".cms-edit-form .btn-toolbar #Form_EditForm_action_restore").entwine({onclick:function t(e){
|
||||
var n=this.parents("form:first"),a=n.find(":input[name=Version]").val(),i="",s=this.data("toRoot")
|
||||
return i=r.default.sprintf(r.default._t(s?"CMSMain.RestoreToRoot":"CMSMain.Restore"),a),!!confirm(i)&&this._super(e)}}),t(".cms-edit-form .btn-toolbar #Form_EditForm_action_unpublish").entwine({onclick:function t(e){
|
||||
var n=this.parents("form:first"),a=n.find(":input[name=Version]").val(),i=""
|
||||
return i=r.default.sprintf(r.default._t("CMSMain.Unpublish"),a),!!confirm(i)&&this._super(e)}}),t(".cms-edit-form.changed").entwine({onmatch:function t(e){var n=this.find("button[name=action_save]")
|
||||
|
@ -30,7 +30,6 @@ if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') {
|
||||
"CMSMAIN.SELECTONEPAGE": "Please select at least 1 page.",
|
||||
"CMSMAIN.URLSEGMENTVALIDATION": "URLs can only be made up of letters, digits and hyphens.",
|
||||
"CMSMAIN.WARNINGSAVEPAGESBEFOREADDING": "You have to save a page before adding children underneath it",
|
||||
"CMSMain.Archive": "Are you sure you want to archive this page and all of its children pages?\n\nThis page and all of its children will be unpublished and sent to the archive.",
|
||||
"CMSMain.ConfirmRestoreFromLive": "Are you sure you want to revert draft to when the page was last published?",
|
||||
"CMSMain.DeleteFromDraft": "Are you sure you want to remove your page from the draft site?\n\nThis page will remain on the published site.",
|
||||
"CMSMain.Restore": "Are you sure you want to restore this page from archive?",
|
||||
|
@ -23,7 +23,6 @@
|
||||
"CMSMAIN.SELECTONEPAGE": "Please select at least 1 page.",
|
||||
"CMSMAIN.URLSEGMENTVALIDATION": "URLs can only be made up of letters, digits and hyphens.",
|
||||
"CMSMAIN.WARNINGSAVEPAGESBEFOREADDING": "You have to save a page before adding children underneath it",
|
||||
"CMSMain.Archive": "Are you sure you want to archive this page and all of its children pages?\n\nThis page and all of its children will be unpublished and sent to the archive.",
|
||||
"CMSMain.ConfirmRestoreFromLive": "Are you sure you want to revert draft to when the page was last published?",
|
||||
"CMSMain.DeleteFromDraft": "Are you sure you want to remove your page from the draft site?\n\nThis page will remain on the published site.",
|
||||
"CMSMain.Restore": "Are you sure you want to restore this page from archive?",
|
||||
|
@ -306,11 +306,11 @@ $.entwine('ss', function($){
|
||||
* (Event) e
|
||||
*/
|
||||
onclick: function(e) {
|
||||
var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = '';
|
||||
message = i18n.sprintf(
|
||||
i18n._t('CMSMain.Archive'),
|
||||
version
|
||||
);
|
||||
var form = this.parents('form:first'), message = '';
|
||||
message = form.find('input[name=ArchiveWarningMessage]')
|
||||
.val()
|
||||
.replace(/\\n/g, '\n');
|
||||
|
||||
if(confirm(message)) {
|
||||
return this._super(e);
|
||||
} else {
|
||||
|
@ -60,6 +60,8 @@ use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\Requirements;
|
||||
use Translatable;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Versioned\ChangeSet;
|
||||
use SilverStripe\Versioned\ChangeSetItem;
|
||||
|
||||
/**
|
||||
* The main "content" area of the CMS.
|
||||
@ -742,8 +744,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$fields->push($liveLinkField = new HiddenField("AbsoluteLink", false, $record->AbsoluteLink()));
|
||||
$fields->push($liveLinkField = new HiddenField("LiveLink"));
|
||||
$fields->push($stageLinkField = new HiddenField("StageLink"));
|
||||
$fields->push($archiveWarningMsgField = new HiddenField("ArchiveWarningMessage"));
|
||||
$fields->push(new HiddenField("TreeTitle", false, $record->TreeTitle));
|
||||
|
||||
$archiveWarningMsgField->setValue($this->getArchiveWarningMessage($record));
|
||||
|
||||
if ($record->ID && is_numeric($record->ID)) {
|
||||
$liveLink = $record->getAbsoluteLiveLink();
|
||||
if ($liveLink) {
|
||||
@ -828,6 +833,43 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
}
|
||||
}
|
||||
|
||||
protected function getArchiveWarningMessage($record)
|
||||
{
|
||||
// Get all page's descendants
|
||||
$record->collateDescendants(true, $descendants);
|
||||
if (!$descendants) {
|
||||
$descendants = [];
|
||||
}
|
||||
|
||||
// Get all campaigns that the page and its descendants belong to
|
||||
$inChangeSetIDs = ChangeSetItem::get_for_object($record)->column('ChangeSetID');
|
||||
|
||||
foreach ($descendants as $page) {
|
||||
$inChangeSetIDs = array_merge($inChangeSetIDs, ChangeSetItem::get_for_object($page)->column('ChangeSetID'));
|
||||
}
|
||||
|
||||
if (count($inChangeSetIDs) > 0) {
|
||||
$inChangeSets = ChangeSet::get()->filter(['ID' => $inChangeSetIDs, 'State' => ChangeSet::STATE_OPEN]);
|
||||
} else {
|
||||
$inChangeSets = new ArrayList();
|
||||
}
|
||||
|
||||
$numCampaigns = ChangeSet::singleton()->i18n_pluralise($inChangeSets->count());
|
||||
$numCampaigns = mb_strtolower($numCampaigns);
|
||||
|
||||
if (count($descendants) > 0 && $inChangeSets->count() > 0) {
|
||||
$archiveWarningMsg = _t('CMSMain.ArchiveWarningWithChildrenAndCampaigns', 'Warning: This page and all of its child pages will be unpublished and automatically removed from their associated {NumCampaigns} before being sent to the archive.\n\nAre you sure you want to proceed?', [ 'NumCampaigns' => $numCampaigns ]);
|
||||
} elseif (count($descendants) > 0) {
|
||||
$archiveWarningMsg = _t('CMSMain.ArchiveWarningWithChildren', 'Warning: This page and all of its child pages will be unpublished before being sent to the archive.\n\nAre you sure you want to proceed?');
|
||||
} elseif ($inChangeSets->count() > 0) {
|
||||
$archiveWarningMsg = _t('CMSMain.ArchiveWarningWithCampaigns', 'Warning: This page will be unpublished and automatically removed from their associated {NumCampaigns} before being sent to the archive.\n\nAre you sure you want to proceed?', [ 'NumCampaigns' => $numCampaigns ]);
|
||||
} else {
|
||||
$archiveWarningMsg = _t('CMSMain.ArchiveWarning', 'Warning: This page will be unpublished before being sent to the archive.\n\nAre you sure you want to proceed?');
|
||||
}
|
||||
|
||||
return $archiveWarningMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param HTTPRequest $request
|
||||
* @return string HTML
|
||||
|
@ -84,6 +84,10 @@ en:
|
||||
TreeFiltered: 'Showing search results.'
|
||||
TreeFilteredClear: Clear
|
||||
UNPUBLISH_AND_ARCHIVE: 'Unpublish and archive'
|
||||
ArchiveWarning: 'Warning: This page will be unpublished before being sent to the archive.\n\nAre you sure you want to proceed?'
|
||||
ArchiveWarningWithChildren: 'Warning: This page and all of its child pages will be unpublished before being sent to the archive.\n\nAre you sure you want to proceed?'
|
||||
ArchiveWarningWithCampaigns: 'Warning: This page will be unpublished and automatically removed from their associated {NumCampaigns} before being sent to the archive.\n\nAre you sure you want to proceed?'
|
||||
ArchiveWarningWithChildrenAndCampaigns: 'Warning: This page and all of its child pages will be unpublished and automatically removed from their associated {NumCampaigns} before being sent to the archive.\n\nAre you sure you want to proceed?'
|
||||
CMSMain_left_ss:
|
||||
APPLY_FILTER: Search
|
||||
CLEAR_FILTER: Clear
|
||||
|
Loading…
Reference in New Issue
Block a user