1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-17 12:10:45 +02:00
This commit is contained in:
Ryan Cramer
2023-08-17 08:56:54 -04:00
parent a0200795a5
commit 0efd5eec99

View File

@@ -364,6 +364,7 @@ abstract class Process extends WireData implements Module {
$config = $this->wire()->config; $config = $this->wire()->config;
$modules = $this->wire()->modules; $modules = $this->wire()->modules;
$sanitizer = $this->wire()->sanitizer; $sanitizer = $this->wire()->sanitizer;
$languages = $this->wire()->languages;
$info = $modules->getModuleInfoVerbose($this); $info = $modules->getModuleInfoVerbose($this);
$name = $sanitizer->pageName($name); $name = $sanitizer->pageName($name);
@@ -384,12 +385,14 @@ abstract class Process extends WireData implements Module {
if(!$parent || !$parent->id) $parent = $adminPage; // default if(!$parent || !$parent->id) $parent = $adminPage; // default
$page = $parent->child("include=all, name=$name"); // does it already exist? $page = $parent->child("include=all, name=$name"); // does it already exist?
if($page->id && "$page->process" == "$this") return $page; // return existing copy if($page->id && "$page->process" == "$this") return $page; // return existing copy
if($languages) $languages->setDefault();
$page = $pages->newPage($template ? $template : 'admin'); $page = $pages->newPage($template ? $template : 'admin');
$page->name = $name; $page->name = $name;
$page->parent = $parent; $page->parent = $parent;
$page->process = $this; $page->process = $this;
$page->title = $title ? $title : $info['title']; $page->title = $title ? $title : $info['title'];
foreach($extras as $key => $value) $page->set($key, $value); foreach($extras as $key => $value) $page->set($key, $value);
if($languages) $languages->unsetDefault();
$pages->save($page, array('adjustName' => true)); $pages->save($page, array('adjustName' => true));
if(!$page->id) throw new WireException("Unable to create page: $parent->path$name"); if(!$page->id) throw new WireException("Unable to create page: $parent->path$name");
$this->message(sprintf($this->_('Created Page: %s'), $page->path)); $this->message(sprintf($this->_('Created Page: %s'), $page->path));