+ protected function updateTemplateStatusAndContentFromInput(Page $page, array $input)
+ {
+ if (isset($input['template']) && userCan('templates-manage')) {
+ $page->template = ($input['template'] === 'true');
+ }
+
+ $pageContent = new PageContent($page);
+ $currentEditor = $page->editor ?: PageEditorData::getSystemDefaultEditor();
+ $newEditor = $currentEditor;
+
+ $haveInput = isset($input['markdown']) || isset($input['html']);
+ $inputEmpty = empty($input['markdown']) && empty($input['html']);
+
+ if ($haveInput && $inputEmpty) {
+ $pageContent->setNewHTML('');
+ } elseif (!empty($input['markdown']) && is_string($input['markdown'])) {
+ $newEditor = 'markdown';
+ $pageContent->setNewMarkdown($input['markdown']);
+ } elseif (isset($input['html'])) {
+ $newEditor = 'wysiwyg';
+ $pageContent->setNewHTML($input['html']);
+ }
+
+ if ($newEditor !== $currentEditor && userCan('editor-change')) {
+ $page->editor = $newEditor;
+ }
+ }
+