Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w committed Jul 16, 2024
2 parents 900f1d0 + 0421982 commit 3bbef07
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 5 deletions.
9 changes: 9 additions & 0 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace FriendsOfRedaxo\Neues;

use rex;
use rex_addon;
use rex_config;
use rex_file;
Expand All @@ -14,6 +15,14 @@
/* Tablesets aktualisieren */
if (rex_addon::get('yform') && rex_addon::get('yform')->isAvailable()) {
rex_yform_manager_table_api::importTablesets(rex_file::get(__DIR__ . '/install/tableset.json'));

// Vorhandene leere UUID-Felder aktualisieren
$sql = rex_sql::factory();
$sql->setQuery('UPDATE ' . rex::getTable('neues_author') . ' SET uuid = uuid() WHERE uuid IS NULL OR uuid = ""');
$sql->setQuery('UPDATE ' . rex::getTable('neues_category') . ' SET uuid = uuid() WHERE uuid IS NULL OR uuid = ""');
$sql->setQuery('UPDATE ' . rex::getTable('neues_entry') . ' SET uuid = uuid() WHERE uuid IS NULL OR uuid = ""');

Neues::ensureDbScheme();
}

if (!rex_media::get('neues_entry_fallback_image.png')) {
Expand Down
10 changes: 5 additions & 5 deletions install/tableset.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
"prio": 2,
"type_id": "value",
"type_name": "choice_status",
"db_type": "text",
"db_type": "int",
"list_hidden": 1,
"search": 0,
"name": "status",
Expand Down Expand Up @@ -454,7 +454,7 @@
"prio": 8,
"type_id": "value",
"type_name": "be_manager_relation",
"db_type": "text",
"db_type": "int(10) unsigned",
"list_hidden": 1,
"search": 0,
"name": "lang_id",
Expand Down Expand Up @@ -733,7 +733,7 @@
"table": {
"status": 1,
"table_name": "rex_neues_entry_category_rel",
"name": "\ud83d\udcf0 translate:neues_entry_category_rel",
"name": "translate:neues_entry_category_rel",
"description": "",
"list_amount": 50,
"list_sortfield": "id",
Expand All @@ -757,7 +757,7 @@
"prio": 1,
"type_id": "value",
"type_name": "be_manager_relation",
"db_type": "text",
"db_type": "int(10) unsigned",
"list_hidden": 0,
"search": 0,
"name": "entry_id",
Expand All @@ -779,7 +779,7 @@
"prio": 2,
"type_id": "value",
"type_name": "be_manager_relation",
"db_type": "text",
"db_type": "int(10) unsigned",
"list_hidden": 1,
"search": 0,
"name": "category_id",
Expand Down
59 changes: 59 additions & 0 deletions lib/neues.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

namespace FriendsOfRedaxo\Neues;

use rex;
use rex_fragment;
use rex_pager;
use rex_sql;
use rex_sql_column;
use rex_sql_index;
use rex_sql_table;

class Neues
{
Expand Down Expand Up @@ -55,4 +59,59 @@ public static function getEntry(int $postId): string
$fragment->setVar('post', $post);
return $fragment->parse('neues/entry.php');
}

public static function ensureDbScheme()
{
rex_sql_table::get(rex::getTable('neues_entry'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('status', 'int(11)'))
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('teaser', 'text'))
->ensureColumn(new rex_sql_column('description', 'text'))
->ensureColumn(new rex_sql_column('domain_ids', 'text'))
->ensureColumn(new rex_sql_column('lang_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('publishdate', 'datetime'))
->ensureColumn(new rex_sql_column('author_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('url', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image', 'text'))
->ensureColumn(new rex_sql_column('images', 'text'))
->ensureColumn(new rex_sql_column('createdate', 'datetime'))
->ensureColumn(new rex_sql_column('createuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updatedate', 'datetime'))
->ensureColumn(new rex_sql_column('updateuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensureIndex(new rex_sql_index('uuid', ['uuid'], rex_sql_index::UNIQUE))
->ensureIndex(new rex_sql_index('status', ['status']))
->ensureIndex(new rex_sql_index('publishdate', ['publishdate']))
->ensureIndex(new rex_sql_index('description', ['description'], rex_sql_index::FULLTEXT))
->ensure();

rex_sql_table::get(rex::getTable('neues_category'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('image', 'text'))
->ensureColumn(new rex_sql_column('status', 'text'))
->ensureColumn(new rex_sql_column('createuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updateuser', 'varchar(191)'))
->ensureColumn(new rex_sql_column('updatedate', 'datetime'))
->ensureColumn(new rex_sql_column('createdate', 'datetime'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensureIndex(new rex_sql_index('uuid', ['uuid'], rex_sql_index::UNIQUE))
->ensure();
rex_sql_table::get(rex::getTable('neues_author'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('name', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('nickname', 'varchar(191)', false, ''))
->ensureColumn(new rex_sql_column('text', 'text'))
->ensureColumn(new rex_sql_column('be_user_id', 'text'))
->ensureColumn(new rex_sql_column('uuid', 'varchar(36)'))
->ensure();

rex_sql_table::get(rex::getTable('neues_entry_category_rel'))
->ensurePrimaryIdColumn()
->ensureColumn(new rex_sql_column('entry_id', 'int(10) unsigned'))
->ensureColumn(new rex_sql_column('category_id', 'int(10) unsigned'))
->ensureIndex(new rex_sql_index('entry_id_category_id', ['entry_id', 'category_id'], rex_sql_index::UNIQUE))
->ensure();
}
}

0 comments on commit 3bbef07

Please sign in to comment.