|
|
@ -18,12 +18,25 @@ return function ($page, $site, $kirby) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
$kirby->impersonate('kirby'); |
|
|
|
$kirby->impersonate('kirby'); |
|
|
|
|
|
|
|
if ($site->find($tournament)->default()->toPage()){ |
|
|
|
|
|
|
|
$json["error"] = $site->find($tournament)->default()->toPage()->out(); |
|
|
|
|
|
|
|
$id = $site->find($tournament)->default()->toPage()->copy( |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'slug' => Str::slug($name), |
|
|
|
|
|
|
|
'parent' => $site->find($tournament), |
|
|
|
|
|
|
|
'children' => false, // copy children |
|
|
|
|
|
|
|
'files' => false, // don't copy files |
|
|
|
|
|
|
|
'isDraft' => false, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
$id = $site->find($tournament)->createChild([ |
|
|
|
$id = $site->find($tournament)->createChild([ |
|
|
|
'content' => $content, |
|
|
|
'content' => $content, |
|
|
|
'slug' => Str::slug($name), |
|
|
|
'slug' => Str::slug($name), |
|
|
|
'template' => 'xoi', |
|
|
|
'template' => 'xoi', |
|
|
|
'isDraft' => false |
|
|
|
'isDraft' => false |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
} |
|
|
|
$json["status"] = "ok"; |
|
|
|
$json["status"] = "ok"; |
|
|
|
$json["url"] = $id->url(); |
|
|
|
$json["url"] = $id->url(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
} catch (\Exception $e) { |
|
|
@ -38,3 +51,4 @@ return function ($page, $site, $kirby) { |
|
|
|
'error' => $error |
|
|
|
'error' => $error |
|
|
|
]; |
|
|
|
]; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|