Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kleinere Formatierungen und Änderungen #85

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion fragments/neues/entry.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

use FriendsOfRedaxo\Neues\Entry;

/** @var rex_fragment $this */

/** @var neues_entry $post */
/** @var Entry $post */
$post = $this->getVar('post');
?>

Expand Down
5 changes: 4 additions & 1 deletion fragments/neues/list-entry.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

use FriendsOfRedaxo\Neues\Entry;

/** @var rex_fragment $this */

/** @var neues_entry $post */
/** @var Entry $post */
$post = $this->getVar('post');
?>

Expand Down
1 change: 1 addition & 0 deletions fragments/neues/list.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/** @var rex_fragment $this */

/** @var rex_pager $pager */
Expand Down
6 changes: 3 additions & 3 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use rex;
use rex_addon;
use rex_article;
use rex_config;
use rex_file;
use rex_media;
Expand All @@ -23,7 +24,6 @@
$sql->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')) {
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 0 additions & 4 deletions lib/neues.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions lib/neues_author.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions lib/neues_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/neues_entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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[] = '<a href="' . rex_url::backendPage('neues/category', $params) . '">' . $neues_category->getName() . '</a>';
Expand Down
4 changes: 2 additions & 2 deletions lib/neues_entry_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
21 changes: 10 additions & 11 deletions lib/neues_restful_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down Expand Up @@ -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(
[
Expand Down Expand Up @@ -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(
[
Expand Down Expand Up @@ -183,9 +184,7 @@ public static function init() :void {
],
],
);

rex_yform_rest::addRoute($rex_neues_author_route);

}

}
4 changes: 2 additions & 2 deletions lib/rex_cronjob_neues_publish.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php


use FriendsOfRedaxo\Neues\Entry;

use function count;

Expand All @@ -9,7 +9,7 @@ class rex_cronjob_neues_publish extends rex_cronjob
public function execute()
{
/* Collection von Neues-Einträgen, die noch nicht veröffentlicht sind, aber es sein sollten. (geplant) */
$neues_entry_to_publish = FriendsOfRedaxo\Neues\Entry::query()->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)));
Expand Down
25 changes: 13 additions & 12 deletions lib/rex_cronjob_neues_sync.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

use FriendsOfRedaxo\Neues\Author;
use FriendsOfRedaxo\Neues\Category;
use FriendsOfRedaxo\Neues\Entry;

class rex_cronjob_neues_sync extends rex_cronjob
{
private $rest_urls = ['category' => '/rest/neues/category/5.0.0/',
Expand Down Expand Up @@ -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']);
Expand All @@ -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']);
Expand All @@ -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']);
Expand Down Expand Up @@ -127,6 +128,6 @@ public function getParamFields()
],
];

return $fields;
return $fields;
}
}
2 changes: 1 addition & 1 deletion package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion pages/neues.author.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

use FriendsOfRedaxo\Neues\Author;

echo rex_view::title(rex_addon::get('neues')->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 */
Expand Down
4 changes: 3 additions & 1 deletion pages/neues.category.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

use FriendsOfRedaxo\Neues\Category;

echo rex_view::title(rex_addon::get('neues')->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;
Expand Down
4 changes: 3 additions & 1 deletion pages/neues.entry.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

use FriendsOfRedaxo\Neues\Entry;

echo rex_view::title(rex_addon::get('neues')->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;
Expand Down
4 changes: 3 additions & 1 deletion pages/neues.lang.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

use FriendsOfRedaxo\Neues\EntryLang;

echo rex_view::title(rex_addon::get('neues')->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;
Expand Down
10 changes: 5 additions & 5 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Loading