mirror of
https://github.com/processwire/processwire.git
synced 2025-08-25 23:56:41 +02:00
Add an update to accommodate request in processwire/processwire-issues#648 for wording of warning message when a 3rd party hook has changed a page's name behind the scenes after it was saved
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
* @method InputfieldForm buildForm()
|
||||
* @method bool processInput(InputfieldForm $form)
|
||||
* @method array getAllowedTemplates($parent = null)
|
||||
* @method string nameChangedWarning(Page $page, $namePrevious)
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1064,6 +1065,21 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook called when the page's name changed during save
|
||||
*
|
||||
* @param Page $page
|
||||
* @param $namePrevious
|
||||
* @return string Warning message
|
||||
*
|
||||
*/
|
||||
protected function ___nameChangedWarning(Page $page, $namePrevious) {
|
||||
return sprintf(
|
||||
$this->_('Warning, the name you selected "%1$s" has been changed to "%2$s".'),
|
||||
$namePrevious, $page->name
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the submitted page add form
|
||||
*
|
||||
@@ -1155,10 +1171,8 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
|
||||
$this->createdPageMessage($this->page);
|
||||
|
||||
if($pageName != $this->page->name) {
|
||||
$this->error(sprintf(
|
||||
$this->_('Warning, the name you selected "%1$s" was already in use and has been changed to "%2$s".'),
|
||||
$pageName, $this->page->name
|
||||
));
|
||||
$warning = $this->nameChangedWarning($this->page, $pageName);
|
||||
if($warning) $this->warning($warning);
|
||||
}
|
||||
|
||||
if($publishNow && $publishAdd) {
|
||||
|
Reference in New Issue
Block a user