diff --git a/fragments/neues/entry.php b/fragments/neues/entry.php index 13723ca..b62e374 100644 --- a/fragments/neues/entry.php +++ b/fragments/neues/entry.php @@ -1,7 +1,10 @@ getVar('post'); ?> diff --git a/fragments/neues/list-entry.php b/fragments/neues/list-entry.php index effc3d6..db027cc 100644 --- a/fragments/neues/list-entry.php +++ b/fragments/neues/list-entry.php @@ -1,7 +1,10 @@ getVar('post'); ?> diff --git a/fragments/neues/list.php b/fragments/neues/list.php index 92231e3..7c924e6 100644 --- a/fragments/neues/list.php +++ b/fragments/neues/list.php @@ -1,4 +1,5 @@ setQuery('UPDATE ' . rex::getTable('neues_entry') . ' SET uuid = uuid() WHERE uuid IS NULL OR uuid = ""'); require_once __DIR__ . '/install/update_scheme.php'; - } if (!rex_media::get('neues_entry_fallback_image.png')) { @@ -53,12 +53,12 @@ if (false === rex_config::get('neues', 'url_profile', false)) { $rex_neues_category = array_filter(rex_sql::factory()->getArray("SELECT * FROM rex_url_generator_profile WHERE `table_name` = '1_xxx_rex_neues_category'")); if (!$rex_neues_category) { - $query = \str_replace("999999", \rex_article::getSiteStartArticleId(), rex_file::get(__DIR__ . '/install/rex_url_profile_neues_category.sql')); + $query = str_replace('999999', rex_article::getSiteStartArticleId(), rex_file::get(__DIR__ . '/install/rex_url_profile_neues_category.sql')); rex_sql::factory()->setQuery($query); } $rex_neues_entry = array_filter(rex_sql::factory()->getArray("SELECT * FROM rex_url_generator_profile WHERE `table_name` = '1_xxx_rex_neues_entry'")); if (!$rex_neues_entry) { - $query = \str_replace("999999", \rex_article::getSiteStartArticleId(), rex_file::get(__DIR__ . '/install/rex_url_profile_neues_entry.sql')); + $query = str_replace('999999', rex_article::getSiteStartArticleId(), rex_file::get(__DIR__ . '/install/rex_url_profile_neues_entry.sql')); rex_sql::factory()->setQuery($query); } /* URL-Profile wurden bereits einmal installiert, daher nicht nochmals installieren und Entwickler-Einstellungen respektieren */ diff --git a/lib/neues.php b/lib/neues.php index 082044d..2c81604 100644 --- a/lib/neues.php +++ b/lib/neues.php @@ -2,13 +2,9 @@ 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 { diff --git a/lib/neues_author.php b/lib/neues_author.php index 3a10ae0..83530e9 100644 --- a/lib/neues_author.php +++ b/lib/neues_author.php @@ -6,12 +6,12 @@ use rex_yform_manager_dataset; /** - * Klasse neues_author. + * Klasse Author (ex. neues_author). * * Diese Klasse repräsentiert einen Autor in der News-Verwaltung. * Sie erbt von der rex_yform_manager_dataset Klasse. * - * Class neues_author + * Class Author (ex. neues_author) * * This class represents an author in the news management. * It inherits from the rex_yform_manager_dataset class. diff --git a/lib/neues_category.php b/lib/neues_category.php index a7afec2..40e0317 100644 --- a/lib/neues_category.php +++ b/lib/neues_category.php @@ -6,17 +6,17 @@ use rex_yform_manager_dataset; /** - * Klasse neues_category. + * Klasse Category (ex. neues_category). * * Diese Klasse repräsentiert eine Kategorie in der News-Verwaltung. * Sie erbt von der rex_yform_manager_dataset Klasse. * - * Class neues_category + * Class Category (ex. neues_category). * * This class represents a Category in the news management. * It inherits from the rex_yform_manager_dataset class. * - * $category = FriendsOfRedaxo\Neues\Categoycreate(); + * $category = FriendsOfRedaxo\Neues\Categoy::create(); * $category->setValue('name', 'Neue Kategorie'); * $category->save(); */ diff --git a/lib/neues_entry.php b/lib/neues_entry.php index dad1f23..1e21277 100644 --- a/lib/neues_entry.php +++ b/lib/neues_entry.php @@ -17,7 +17,7 @@ use rex_yform_manager_table; /** - * Class neues_entry. + * Class Entry (ex. neues_entry). * * Diese Klasse repräsentiert einen neuen Eintrag. * This class represents a new entry. @@ -125,7 +125,7 @@ static function ($a) { $category_ids = array_filter(array_map('intval', explode(',', $a['value']))); foreach ($category_ids as $category_id) { - /** @var null|Category $neues_category */ + /** @var Category|null $neues_category */ $neues_category = Category::get($category_id); if (null !== $neues_category) { $return[] = '' . $neues_category->getName() . ''; diff --git a/lib/neues_entry_lang.php b/lib/neues_entry_lang.php index f2ce926..18e81a0 100644 --- a/lib/neues_entry_lang.php +++ b/lib/neues_entry_lang.php @@ -6,13 +6,13 @@ use rex_yform_manager_dataset; /** - * Class neues_entry_lang. + * Class EntryLang (ex. neues_entry_lang). * * Diese Klasse repräsentiert einen neuen Eintrag. * This class represents a new entry. * * Beispiel / Example: - * $entry = neues_entry_lang::get($id); + * $entry = EntryLang::get($id); * * @package rex_yform_manager_dataset */ diff --git a/lib/neues_restful_api.php b/lib/neues_restful_api.php index 6383602..4ec56ad 100644 --- a/lib/neues_restful_api.php +++ b/lib/neues_restful_api.php @@ -2,12 +2,13 @@ namespace FriendsOfRedaxo\Neues; -use rex_yform_rest_route; use rex_yform_rest; +use rex_yform_rest_route; -class RestfulApi { - - public static function init() :void { +class RestfulApi +{ + public static function init(): void + { $rex_neues_entry_route = new rex_yform_rest_route( [ 'path' => '/neues/entry/5.0.0/', @@ -92,9 +93,9 @@ public static function init() :void { ], ], ); - + rex_yform_rest::addRoute($rex_neues_entry_route); - + /* YForm Rest API */ $rex_neues_category_route = new rex_yform_rest_route( [ @@ -136,9 +137,9 @@ public static function init() :void { ], ], ); - + rex_yform_rest::addRoute($rex_neues_category_route); - + /* YForm Rest API */ $rex_neues_author_route = new rex_yform_rest_route( [ @@ -183,9 +184,7 @@ public static function init() :void { ], ], ); - + rex_yform_rest::addRoute($rex_neues_author_route); - } - } diff --git a/lib/rex_cronjob_neues_publish.php b/lib/rex_cronjob_neues_publish.php index 280093e..674aa34 100644 --- a/lib/rex_cronjob_neues_publish.php +++ b/lib/rex_cronjob_neues_publish.php @@ -1,6 +1,6 @@ where('status', 0)->where('publishdate', date('Y-m-d'), '<')->find(); + $neues_entry_to_publish = Entry::query()->where('status', 0)->where('publishdate', date('Y-m-d'), '<')->find(); $neues_entry_to_publish->setValue('status', 1); if (!$neues_entry_to_publish->save()) { $this->setMessage(sprintf(rex_i18n::msg('neues_entry_publish_error'), count($neues_entry_to_publish))); diff --git a/lib/rex_cronjob_neues_sync.php b/lib/rex_cronjob_neues_sync.php index 61c9840..6864bf5 100644 --- a/lib/rex_cronjob_neues_sync.php +++ b/lib/rex_cronjob_neues_sync.php @@ -1,5 +1,9 @@ '/rest/neues/category/5.0.0/', @@ -28,15 +32,14 @@ public function execute() $data[$type] = json_decode($response->getBody(), true); } - if(isset($data['category']['data'])) { - + if (isset($data['category']['data'])) { foreach ($data['category']['data'] as $category) { $category = $category['attributes']; // Überprüfe, ob UUID bereits in der Datenbank vorhanden ist - $neues_category = FriendsOfRedaxo\Neues\Category::query()->where('uuid', $category['uuid'])->findOne(); + $neues_category = Category::query()->where('uuid', $category['uuid'])->findOne(); if (null === $neues_category) { - $neues_category = FriendsOfRedaxo\Neues\Category::create(); + $neues_category = Category::create(); } $neues_category->setValue('uuid', $category['uuid']); @@ -51,15 +54,14 @@ public function execute() } } - if(isset($data['author']['data'])) { - + if (isset($data['author']['data'])) { foreach ($data['author']['data'] as $author) { $author = $author['attributes']; // Überprüfe, ob UUID bereits in der Datenbank vorhanden ist - $neues_author = FriendsOfRedaxo\Neues\Author::query()->where('uuid', $author['uuid'])->findOne(); + $neues_author = Author::query()->where('uuid', $author['uuid'])->findOne(); if (null === $neues_author) { - $neues_author = FriendsOfRedaxo\Neues\Author::create(); + $neues_author = Author::create(); } $neues_author->setValue('uuid', $author['uuid']); @@ -73,12 +75,11 @@ public function execute() foreach ($data['entry']['data'] as $entry) { $entry = $entry['attributes']; // Überprüfe, ob UUID bereits in der Datenbank vorhanden ist - $neues_entry = FriendsOfRedaxo\Neues\Entry::query()->where('uuid', $entry['uuid'])->findOne(); + $neues_entry = Entry::query()->where('uuid', $entry['uuid'])->findOne(); if (null === $neues_entry) { - $neues_entry = FriendsOfRedaxo\Neues\Entry::create(); + $neues_entry = Entry::create(); } - $neues_entry->setValue('uuid', $entry['uuid']); $neues_entry->setValue('name', $entry['name']); $neues_entry->setValue('teaser', $entry['teaser']); @@ -127,6 +128,6 @@ public function getParamFields() ], ]; - return $fields; + return $fields; } } diff --git a/package.yml b/package.yml index fef0a06..b72038e 100644 --- a/package.yml +++ b/package.yml @@ -58,7 +58,7 @@ pages: default_config: default_author: "Redaktion" - default_thumbnail: "neues_entry_fallback_iamge.png" + default_thumbnail: "neues_entry_fallback_image.png" external_url_label: "Zur Website" editor: 'class="form-control redactor-editor--default"' url_profile: false diff --git a/pages/neues.author.php b/pages/neues.author.php index 1640c1d..44288c1 100644 --- a/pages/neues.author.php +++ b/pages/neues.author.php @@ -1,11 +1,13 @@ getProperty('page')['title']); $currentPage = rex_be_controller::getCurrentPageObject(); $wrapper = ''; -$table_name = 'rex_neues_author'; +$table_name = Author::table()->getTableName(); if (!rex_request('table_name', 'string', '')) { /* @phpstan-ignore-next-line */ diff --git a/pages/neues.category.php b/pages/neues.category.php index 0db1623..3618ca6 100644 --- a/pages/neues.category.php +++ b/pages/neues.category.php @@ -1,11 +1,13 @@ getProperty('page')['title']); $currentPage = rex_be_controller::getCurrentPageObject(); $wrapper = ''; -$table_name = 'rex_neues_category'; +$table_name = Category::table()->getTableName(); if (!rex_request('table_name', 'string', '')) { /* @phpstan-ignore-next-line */ $_REQUEST['table_name'] = $table_name; diff --git a/pages/neues.entry.php b/pages/neues.entry.php index 2582afb..05bc2c2 100644 --- a/pages/neues.entry.php +++ b/pages/neues.entry.php @@ -1,11 +1,13 @@ getProperty('page')['title']); $currentPage = rex_be_controller::getCurrentPageObject(); $wrapper = ''; -$table_name = 'rex_neues_entry'; +$table_name = Entry::table()->getTableName(); if (!rex_request('table_name', 'string', '')) { /* @phpstan-ignore-next-line */ $_REQUEST['table_name'] = $table_name; diff --git a/pages/neues.lang.php b/pages/neues.lang.php index 1e33b47..f78a6d0 100644 --- a/pages/neues.lang.php +++ b/pages/neues.lang.php @@ -1,11 +1,13 @@ getProperty('page')['title']); $currentPage = rex_be_controller::getCurrentPageObject(); $wrapper = ''; -$table_name = 'rex_neues_entry_lang'; +$table_name = EntryLang::table()->getTableName(); if (!rex_request('table_name', 'string', '')) { /* @phpstan-ignore-next-line */ $_REQUEST['table_name'] = $table_name; diff --git a/uninstall.php b/uninstall.php index 3d3bebc..8d372bd 100644 --- a/uninstall.php +++ b/uninstall.php @@ -2,9 +2,9 @@ rex_config::removeNamespace('neues'); if (rex_addon::get('yform')->isAvailable() && !rex::isSafeMode()) { - rex_yform_manager_table_api::removeTable('rex_neues_category'); - rex_yform_manager_table_api::removeTable('rex_neues_entry'); - rex_yform_manager_table_api::removeTable('rex_neues_entry_category_rel'); - rex_yform_manager_table_api::removeTable('rex_neues_author'); - rex_yform_manager_table_api::removeTable('rex_neues_entry_lang'); + rex_yform_manager_table_api::removeTable(rex::getTable('neues_category')); + rex_yform_manager_table_api::removeTable(rex::getTable('neues_entry')); + rex_yform_manager_table_api::removeTable(rex::getTable('neues_entry_category_rel')); + rex_yform_manager_table_api::removeTable(rex::getTable('neues_author')); + rex_yform_manager_table_api::removeTable(rex::getTable('neues_entry_lang')); }