1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-14 02:34:24 +02:00

Add PR #273 Make error messages translatable in ProcessPageAdd

Co-authored-by: jmartsch <jmartsch@gmail.com>
This commit is contained in:
Ryan Cramer
2023-06-16 11:59:11 -04:00
parent 3fd4073f34
commit 9353a8ea43

View File

@@ -737,26 +737,45 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
protected function isAllowedParent(Page $parent, $showError = false, Template $template = null) {
if($parent->template->noChildren) {
if($showError) $this->error("The parent template has specified that no children may be added here");
if($showError) {
$this->error($this->_('The parent template has specified that no children may be added here'));
}
return false;
}
if($template && count($template->parentTemplates)) {
if(!in_array($parent->template->id, $template->parentTemplates)) {
if($showError) $this->error("The template '$template' does not allow parents of type '$parent->template'");
if($showError) {
$this->error(sprintf(
$this->_('The template "%1$s" does not allow parents of type "%2$s"'),
$template->name,
$parent->template->name
));
}
return false;
}
}
if($template && count($parent->template->childTemplates)) {
if(!in_array($template->id, $parent->template->childTemplates)) {
if($showError) $this->error("The parent of type '$parent->template' does not allow children of type '$template'");
if($showError) {
$this->error(sprintf(
$this->_('The parent of type "%1$s" does not allow children of type "%2$s"'),
$parent->template->name,
$template->name
));
}
return false;
}
}
if(!$parent->addable()) {
if($showError) $this->error("You don't have access to add pages to parent $parent->path");
if($showError) {
$this->error(sprintf(
$this->_('You dont have access to add pages to parent %s'),
$parent->path
));
}
return false;
}
@@ -768,7 +787,12 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
}
}
if(!$allowed) {
if($showError) $this->error("Specified parent is not allowed ($parent->path)");
if($showError) {
$this->error(sprintf(
$this->_('Specified parent is not allowed (%s)'),
$parent->path
));
}
return false;
}
}
@@ -1480,4 +1504,3 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
return $form;
}
}