diff --git a/src/Http/Controllers/CmsEditor/CmsEditorTableController.php b/src/Http/Controllers/CmsEditor/CmsEditorTableController.php index 2df3ad75..a5501262 100644 --- a/src/Http/Controllers/CmsEditor/CmsEditorTableController.php +++ b/src/Http/Controllers/CmsEditor/CmsEditorTableController.php @@ -3,7 +3,6 @@ namespace NotFound\Framework\Http\Controllers\CmsEditor; use Illuminate\Http\Request as HttpRequest; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use NotFound\Framework\Http\Requests\FormDataRequest; use NotFound\Framework\Models\Table; @@ -323,7 +322,9 @@ private function checkColumn(string $table, object $field): string $fieldClass = new $className(new stdClass()); if (Schema::hasColumn($table, $field->internal)) { - return $fieldClass->checkColumnType(DB::getDoctrineColumn($this->setDatabasePrefix($table), $field->internal)->getType()); + return $fieldClass->checkColumnType( + Schema::getColumnType($table, $field->internal) + ); } else { return $fieldClass->checkColumnType(null); } diff --git a/src/Services/Assets/Components/ComponentText.php b/src/Services/Assets/Components/ComponentText.php index 9aa634ad..ef265c6c 100644 --- a/src/Services/Assets/Components/ComponentText.php +++ b/src/Services/Assets/Components/ComponentText.php @@ -73,13 +73,6 @@ protected function customProperties(): object $customProperties['editorSettings'] = json_decode($setting->settings); } } - if ( - $this->assetItem->properties->type == 'richtext' && - isset($this->assetItem->server_properties->editModal) && - $this->assetItem->server_properties->editModal === true - ) { - $customProperties['editModal'] = true; - } return (object) $customProperties; } diff --git a/src/Services/Editor/Fields/Button.php b/src/Services/Editor/Fields/Button.php index 6b215c92..f29dab83 100644 --- a/src/Services/Editor/Fields/Button.php +++ b/src/Services/Editor/Fields/Button.php @@ -23,7 +23,7 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { return ''; } diff --git a/src/Services/Editor/Fields/Checkbox.php b/src/Services/Editor/Fields/Checkbox.php index 35c792a5..85de8fd5 100644 --- a/src/Services/Editor/Fields/Checkbox.php +++ b/src/Services/Editor/Fields/Checkbox.php @@ -21,14 +21,14 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if (! in_array($type->getName(), ['tinyint', 'boolean'])) { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field'; + if (! in_array($type, ['tinyint', 'int', 'boolean'])) { + return 'TYPE ERROR: '.$type.' is not a valid type for a text field'; } return ''; diff --git a/src/Services/Editor/Fields/ChildTable.php b/src/Services/Editor/Fields/ChildTable.php index 457ed075..76a94dfd 100644 --- a/src/Services/Editor/Fields/ChildTable.php +++ b/src/Services/Editor/Fields/ChildTable.php @@ -34,7 +34,7 @@ protected function rename(): array ]; } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type !== null) { return 'COLUMN NOT NEEDED'; diff --git a/src/Services/Editor/Fields/ContentBlocks.php b/src/Services/Editor/Fields/ContentBlocks.php index 68f5aca7..696598af 100644 --- a/src/Services/Editor/Fields/ContentBlocks.php +++ b/src/Services/Editor/Fields/ContentBlocks.php @@ -28,7 +28,7 @@ public function serverProperties(): void } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type !== null) { return 'COLUMN NOT NEEDED'; diff --git a/src/Services/Editor/Fields/DatePicker.php b/src/Services/Editor/Fields/DatePicker.php index 033d64ca..1f1361ba 100644 --- a/src/Services/Editor/Fields/DatePicker.php +++ b/src/Services/Editor/Fields/DatePicker.php @@ -33,17 +33,17 @@ protected function rename(): array ]; } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if ($type->getName() === 'int') { - return 'TYPE WARNING: '.$type->getName().' should be converted to datetime'; + if ($type === 'int') { + return 'TYPE WARNING: '.$type.' should be converted to datetime'; } - if ($type->getName() !== 'datetime') { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a date field'; + if ($type !== 'datetime') { + return 'TYPE ERROR: '.$type.' is not a valid type for a date field'; } return ''; diff --git a/src/Services/Editor/Fields/DateTimePicker.php b/src/Services/Editor/Fields/DateTimePicker.php index bba24fa2..5ca27dcc 100644 --- a/src/Services/Editor/Fields/DateTimePicker.php +++ b/src/Services/Editor/Fields/DateTimePicker.php @@ -22,13 +22,13 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if (! in_array($type->getName(), ['datetime'])) { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a date field'; + if (! in_array($type, ['datetime'])) { + return 'TYPE ERROR: '.$type.' is not a valid type for a date field'; } return ''; diff --git a/src/Services/Editor/Fields/Description.php b/src/Services/Editor/Fields/Description.php index 23c0afb5..4efa733b 100644 --- a/src/Services/Editor/Fields/Description.php +++ b/src/Services/Editor/Fields/Description.php @@ -20,7 +20,7 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { return ''; diff --git a/src/Services/Editor/Fields/DropDown.php b/src/Services/Editor/Fields/DropDown.php index c38eb66b..66810caa 100644 --- a/src/Services/Editor/Fields/DropDown.php +++ b/src/Services/Editor/Fields/DropDown.php @@ -2,7 +2,6 @@ namespace NotFound\Framework\Services\Editor\Fields; -use Doctrine\DBAL\Types\Type; use NotFound\Framework\Services\Editor\Properties; use NotFound\Framework\Services\Editor\Repeatable; use stdClass; @@ -30,7 +29,7 @@ public function serverProperties(): void { } - public function checkColumnType(?Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; diff --git a/src/Services/Editor/Fields/File.php b/src/Services/Editor/Fields/File.php index 1b20138c..528d9731 100644 --- a/src/Services/Editor/Fields/File.php +++ b/src/Services/Editor/Fields/File.php @@ -22,14 +22,14 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if (! in_array($type->getName(), ['string'])) { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field'; + if (! in_array($type, ['varchar'])) { + return 'TYPE ERROR: '.$type.' is not a valid type for a text field'; } return ''; diff --git a/src/Services/Editor/Fields/Filter.php b/src/Services/Editor/Fields/Filter.php index feaccdc0..d32b423f 100644 --- a/src/Services/Editor/Fields/Filter.php +++ b/src/Services/Editor/Fields/Filter.php @@ -19,7 +19,7 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { return ''; } diff --git a/src/Services/Editor/Fields/Header.php b/src/Services/Editor/Fields/Header.php index 431bb9be..4251cce8 100644 --- a/src/Services/Editor/Fields/Header.php +++ b/src/Services/Editor/Fields/Header.php @@ -20,7 +20,7 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { return ''; } diff --git a/src/Services/Editor/Fields/Image.php b/src/Services/Editor/Fields/Image.php index bb79878f..04d23795 100644 --- a/src/Services/Editor/Fields/Image.php +++ b/src/Services/Editor/Fields/Image.php @@ -2,7 +2,6 @@ namespace NotFound\Framework\Services\Editor\Fields; -use Doctrine\DBAL\Types\Type; use NotFound\Framework\Services\Editor\Properties; use NotFound\Framework\Services\Editor\Repeatable; use stdClass; @@ -36,7 +35,7 @@ public function serverProperties(): void $this->addCheckbox('createPNG', 'Create PNG'); } - public function checkColumnType(?Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; diff --git a/src/Services/Editor/Fields/Link.php b/src/Services/Editor/Fields/Link.php index 6f8b6c43..89b4d8cc 100644 --- a/src/Services/Editor/Fields/Link.php +++ b/src/Services/Editor/Fields/Link.php @@ -20,7 +20,7 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; diff --git a/src/Services/Editor/Fields/ModelSelect.php b/src/Services/Editor/Fields/ModelSelect.php index 3ce93b7f..e4a9e577 100644 --- a/src/Services/Editor/Fields/ModelSelect.php +++ b/src/Services/Editor/Fields/ModelSelect.php @@ -23,13 +23,13 @@ public function serverProperties(): void $this->addText('methodName', 'Method', true); } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if (! in_array($type->getName(), ['string', 'integer'])) { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a table select field'; + if (! in_array($type, ['varchar', 'int'])) { + return 'TYPE ERROR: '.$type.' is not a valid type for a table select field'; } return ''; diff --git a/src/Services/Editor/Fields/Number.php b/src/Services/Editor/Fields/Number.php index ff488580..249f7f12 100644 --- a/src/Services/Editor/Fields/Number.php +++ b/src/Services/Editor/Fields/Number.php @@ -23,7 +23,7 @@ public function serverProperties(): void { } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; diff --git a/src/Services/Editor/Fields/Slug.php b/src/Services/Editor/Fields/Slug.php index ee2e62b2..f8f9952b 100644 --- a/src/Services/Editor/Fields/Slug.php +++ b/src/Services/Editor/Fields/Slug.php @@ -23,13 +23,13 @@ public function serverProperties(): void $this->addText('source', 'Source field internal name', false); } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if (! in_array($type->getName(), ['string'])) { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a slug field'; + if (! in_array($type, ['varchar'])) { + return 'TYPE ERROR: '.$type.' is not a valid type for a slug field'; } return ''; diff --git a/src/Services/Editor/Fields/TableSelect.php b/src/Services/Editor/Fields/TableSelect.php index c753bbf9..5d9b8ee8 100644 --- a/src/Services/Editor/Fields/TableSelect.php +++ b/src/Services/Editor/Fields/TableSelect.php @@ -40,13 +40,13 @@ protected function rename(): array ]; } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if (! in_array($type->getName(), ['string', 'integer'])) { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a table select field'; + if (! in_array($type, ['int', 'tinyint', 'varchar'])) { + return 'TYPE ERROR: '.$type.' is not a valid type for a table select field'; } return ''; diff --git a/src/Services/Editor/Fields/Tags.php b/src/Services/Editor/Fields/Tags.php index 041e3b06..4f8aa5b8 100644 --- a/src/Services/Editor/Fields/Tags.php +++ b/src/Services/Editor/Fields/Tags.php @@ -42,7 +42,7 @@ protected function rename(): array ]; } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type !== null) { return 'COLUMN NOT NEEDED'; diff --git a/src/Services/Editor/Fields/Text.php b/src/Services/Editor/Fields/Text.php index eabd0169..67c83dd4 100644 --- a/src/Services/Editor/Fields/Text.php +++ b/src/Services/Editor/Fields/Text.php @@ -24,6 +24,7 @@ public function properties(): void (object) ['value' => 'richtext', 'label' => 'Rich Text'], ]); $this->addNumber('maxlength', 'Maximum length'); + $this->addCheckbox('editModal', 'Edit texts in popup (required for ContentBlock/Childtable)'); } public function serverProperties(): void @@ -36,7 +37,6 @@ public function serverProperties(): void $this->addDropDown('editorSettings', 'Editor settings (for rich text editor)', $options); // BUG: TODO: editModal should just be a property, // not a server property - $this->addCheckbox('editModal', 'Edit texts in popup (required for ContentBlock/Childtable)'); $this->addTitle('Validation'); $this->addDropDown('regExTemplate', 'Built in validations', [ @@ -54,13 +54,13 @@ public function rename(): array return ['texttype' => 'type']; } - public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string + public function checkColumnType(?string $type): string { if ($type === null) { return 'COLUMN MISSING'; } - if (! in_array($type->getName(), ['string', 'text'])) { - return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field'; + if (! in_array($type, ['varchar', 'text'])) { + return 'TYPE ERROR: '.$type.' is not a valid type for a text field'; } return ''; diff --git a/src/Services/Editor/Properties.php b/src/Services/Editor/Properties.php index b8476fcd..85fa8090 100644 --- a/src/Services/Editor/Properties.php +++ b/src/Services/Editor/Properties.php @@ -39,7 +39,7 @@ abstract public function serverProperties(): void; abstract public function description(): string; - abstract public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string; + abstract public function checkColumnType(?string $type): string; protected function addText($property_name, $display_name, $required = false, $default = null) { diff --git a/src/Services/Editor/Repeatable.php b/src/Services/Editor/Repeatable.php index a9b0c2db..8b2e2e98 100644 --- a/src/Services/Editor/Repeatable.php +++ b/src/Services/Editor/Repeatable.php @@ -2,8 +2,6 @@ namespace NotFound\Framework\Services\Editor; -use Doctrine\DBAL\Types\Type; - class Repeatable extends Properties { public function description(): string @@ -19,7 +17,7 @@ public function serverProperties(): void { } - public function checkColumnType(?Type $type): string + public function checkColumnType(?string $type): string { trigger_error('This should never be called', E_USER_ERROR);