Skip to content

Commit

Permalink
Merge pull request #93 from FriendsOfREDAXO/cb-4
Browse files Browse the repository at this point in the history
API und Cronjobs mit RexStan bearbeitet
  • Loading branch information
alxndr-w authored Aug 22, 2024
2 parents f7f6e6b + 8cd579f commit 410a16f
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 58 deletions.
4 changes: 2 additions & 2 deletions lang/da_da.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s indlæg er blevet offentliggjort med succes.
neues_entry_publish_error = %s indlæg kunne ikke offentliggøres.
neues_entry_publish_success = %d indlæg er blevet offentliggjort med succes.
neues_entry_publish_error = %d indlæg kunne ikke offentliggøres.
neues_entry_publish_cronjob = Offentliggør planlagte indlæg. (Aktuelt)
4 changes: 2 additions & 2 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s Beiträge wurden erfolgreich veröffentlicht.
neues_entry_publish_error = %s Beiträge konnten nicht veröffentlicht werden.
neues_entry_publish_success = %d Beiträge wurden erfolgreich veröffentlicht.
neues_entry_publish_error = %d Beiträge konnten nicht veröffentlicht werden.
neues_entry_publish_cronjob = Geplante Beiträge veröffentlichen. (Aktuelles)

neues_entry_sync_error = Fehler beim Synchronisieren der Beiträge.
Expand Down
4 changes: 2 additions & 2 deletions lang/el_el.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s Καταχωρήσεις δημοσιεύτηκαν επιτυχώς.
neues_entry_publish_error = %s Καταχωρήσεις δεν μπόρεσαν να δημοσιευτούν.
neues_entry_publish_success = %d Καταχωρήσεις δημοσιεύτηκαν επιτυχώς.
neues_entry_publish_error = %d Καταχωρήσεις δεν μπόρεσαν να δημοσιευτούν.
neues_entry_publish_cronjob = Δημοσίευση προγραμματισμένων καταχωρήσεων. (Νέα)
4 changes: 2 additions & 2 deletions lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s posts have been successfully published.
neues_entry_publish_error = %s posts could not be published.
neues_entry_publish_success = %d posts have been successfully published.
neues_entry_publish_error = %d posts could not be published.
neues_entry_publish_cronjob = Publish planned posts. (Current)
4 changes: 2 additions & 2 deletions lang/es_es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s entradas se han publicado con éxito.
neues_entry_publish_error = %s entradas no se pudieron publicar.
neues_entry_publish_success = %d entradas se han publicado con éxito.
neues_entry_publish_error = %d entradas no se pudieron publicar.
neues_entry_publish_cronjob = Publicar entradas planificadas. (Actual)
4 changes: 2 additions & 2 deletions lang/fi_fi.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s artikkelia on julkaistu onnistuneesti.
neues_entry_publish_error = %s artikkelia ei voitu julkaista.
neues_entry_publish_success = %d artikkelia on julkaistu onnistuneesti.
neues_entry_publish_error = %d artikkelia ei voitu julkaista.
neues_entry_publish_cronjob = Julkaise suunnitellut artikkelit. (Uutiset)
4 changes: 2 additions & 2 deletions lang/fr_fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ neues_docs_restful_api = API RESTful YForm

# Cronjob

neues_entry_publish_success = %s articles ont été publiés avec succès.
neues_entry_publish_error = %s articles n'ont pas pu être publiés.
neues_entry_publish_success = %d articles ont été publiés avec succès.
neues_entry_publish_error = %d articles n'ont pas pu être publiés.
neues_entry_publish_cronjob = Publier des articles planifiés. (Actuel)
4 changes: 2 additions & 2 deletions lang/it_it.lang
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ neues_docs_restful_api = YForm API RESTful

# Cronjob

neues_entry_publish_success = %s articoli sono stati pubblicati con successo.
neues_entry_publish_error = %s articoli non sono stati pubblicati.
neues_entry_publish_success = %d articoli sono stati pubblicati con successo.
neues_entry_publish_error = %d articoli non sono stati pubblicati.
neues_entry_publish_cronjob = Pubblica articoli pianificati. (Corrente)
4 changes: 2 additions & 2 deletions lang/nl_nl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s berichten zijn succesvol gepubliceerd.
neues_entry_publish_error = %s berichten konden niet worden gepubliceerd.
neues_entry_publish_success = %d berichten zijn succesvol gepubliceerd.
neues_entry_publish_error = %d berichten konden niet worden gepubliceerd.
neues_entry_publish_cronjob = Geplande berichten publiceren. (Nieuws)
4 changes: 2 additions & 2 deletions lang/no_no.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s innlegg har blitt publisert.
neues_entry_publish_error = %s innlegg kunne ikke publiseres.
neues_entry_publish_success = %d innlegg har blitt publisert.
neues_entry_publish_error = %d innlegg kunne ikke publiseres.
neues_entry_publish_cronjob = Publiser planlagte innlegg. (Aktuelt)
4 changes: 2 additions & 2 deletions lang/pl_pl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s wpisów zostało pomyślnie opublikowanych.
neues_entry_publish_error = %s wpisów nie udało się opublikować.
neues_entry_publish_success = %d wpisów zostało pomyślnie opublikowanych.
neues_entry_publish_error = %d wpisów nie udało się opublikować.
neues_entry_publish_cronjob = Publikowanie zaplanowanych wpisów. (Aktualności)
4 changes: 2 additions & 2 deletions lang/ro_ro.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s articole au fost publicate cu succes.
neues_entry_publish_error = %s articole nu au putut fi publicate.
neues_entry_publish_success = %d articole au fost publicate cu succes.
neues_entry_publish_error = %d articole nu au putut fi publicate.
neues_entry_publish_cronjob = Publică articolele planificate. (Noutăți)
4 changes: 2 additions & 2 deletions lang/sv_se.lang
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s inlägg har publicerats framgångsrikt.
neues_entry_publish_error = %s inlägg kunde inte publiceras.
neues_entry_publish_success = %d inlägg har publicerats framgångsrikt.
neues_entry_publish_error = %d inlägg kunde inte publiceras.
neues_entry_publish_cronjob = Publicera planerade inlägg.
4 changes: 2 additions & 2 deletions lang/tr_tr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s giriş başarıyla yayınlandı.
neues_entry_publish_error = %s giriş yayınlanamadı.
neues_entry_publish_success = %d giriş başarıyla yayınlandı.
neues_entry_publish_error = %d giriş yayınlanamadı.
neues_entry_publish_cronjob = Planlanan girişleri yayınla. (Yeni)
4 changes: 2 additions & 2 deletions lang/uk_uk.lang
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ neues_docs_restful_api = YForm RESTful API

# Cronjob

neues_entry_publish_success = %s записів було успішно опубліковано.
neues_entry_publish_error = %s записів не вдалося опублікувати.
neues_entry_publish_success = %d записів було успішно опубліковано.
neues_entry_publish_error = %d записів не вдалося опублікувати.
neues_entry_publish_cronjob = Опублікувати заплановані записи. (Новини)
22 changes: 11 additions & 11 deletions lib/Api/Restful.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function init(): void
'query' => Entry::query(),
'get' => [
'fields' => [
'FriendsOfRedaxo\Neues\Entry' => [
Entry::class => [
'id',
'status',
'name',
Expand All @@ -40,7 +40,7 @@ public static function init(): void
'updateuser',
'uuid',
],
'FriendsOfRedaxo\Neues\Category' => [
Category::class => [
'id',
'name',
'image',
Expand All @@ -51,7 +51,7 @@ public static function init(): void
'updateuser',
'uuid',
],
'FriendsOfRedaxo\Neues\Author' => [
Author::class => [
'id',
'name',
'nickname',
Expand All @@ -68,7 +68,7 @@ public static function init(): void
],
'post' => [
'fields' => [
'FriendsOfRedaxo\Neues\Entry' => [
Entry::class => [
'status',
'name',
'teaser',
Expand All @@ -89,7 +89,7 @@ public static function init(): void
],
'delete' => [
'fields' => [
'FriendsOfRedaxo\Neues\Entry' => [
Entry::class => [
'id',
],
],
Expand All @@ -108,7 +108,7 @@ public static function init(): void
'query' => Category::query(),
'get' => [
'fields' => [
'FriendsOfRedaxo\Neues\Category' => [
Category::class => [
'id',
'name',
'image',
Expand All @@ -123,7 +123,7 @@ public static function init(): void
],
'post' => [
'fields' => [
'FriendsOfRedaxo\Neues\Category' => [
Category::class => [
'name',
'image',
'status',
Expand All @@ -133,7 +133,7 @@ public static function init(): void
],
'delete' => [
'fields' => [
'FriendsOfRedaxo\Neues\Category' => [
Category::class => [
'id',
],
],
Expand All @@ -152,7 +152,7 @@ public static function init(): void
'query' => Author::query(),
'get' => [
'fields' => [
'FriendsOfRedaxo\Neues\Author' => [
Author::class => [
'id',
'name',
'nickname',
Expand All @@ -169,7 +169,7 @@ public static function init(): void
],
'post' => [
'fields' => [
'FriendsOfRedaxo\Neues\Author' => [
Author::class => [
'name',
'nickname',
'text',
Expand All @@ -180,7 +180,7 @@ public static function init(): void
],
'delete' => [
'fields' => [
'FriendsOfRedaxo\Neues\Author' => [
Author::class => [
'id',
],
],
Expand Down
21 changes: 10 additions & 11 deletions lib/Api/Rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ public function execute(): rex_api_result
$lang_id = rex_request('lang_id', 'int', null);
$category_id = rex_request('category_id', 'int', null);

if ($category_id && $category = Category::get($category_id)) {
$category = null;
if (null !== $category_id) {
$category = Category::get($category_id);
}

if (null !== $category) {
$collection = Entry::findOnline($category_id);
$filename = 'rss.neues.' . rex_string::normalize($category->getName()) . '.xml';
$description = 'RSS-FEED: ' . rex::getServerName() . ' | ' . rex_escape($category->getName());
} else {
$collection = Entry::findOnline();
$description = 'RSS-FEED: ' . rex::getServerName();
$filename = 'rss.neues.xml';
$description = 'RSS-FEED: ' . rex::getServerName();
}

rex_response::cleanOutputBuffers();
Expand All @@ -49,10 +54,8 @@ public function execute(): rex_api_result
/**
* @param rex_yform_manager_collection<Entry> $collection
* @api
*
* TODO: Parameter Domain wird nicht benutzt: Klären ob der weg kann. Type fehlt
*/
public static function getRssFeed($collection, $domain, int $lang, string $description, string $filename): string|bool
public static function getRssFeed(rex_yform_manager_collection $collection, int $domain_id, int $lang, string $description, string $filename): string|bool
{
return self::createRssFeed($collection, $domain, $lang, $description, $filename);
}
Expand All @@ -68,10 +71,8 @@ public static function joinUrls(string $url1, string $url2): string
/**
* @param rex_yform_manager_collection<Entry> $collection
* @api
*
* TODO: Parameter Domain wird nicht benutzt: Klären ob der weg kann. Type fehlt
*/
public static function createRssFeed(rex_yform_manager_collection $collection, $domain, int $lang, string $description, string $filename = 'rss.neues.xml'): string|bool
public static function createRssFeed(rex_yform_manager_collection $collection, int $domain_id, int $lang, string $description, string $filename = 'rss.neues.xml'): string|bool
{
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom"></rss>');

Expand All @@ -80,9 +81,7 @@ public static function createRssFeed(rex_yform_manager_collection $collection, $
$channel->addChild('description', $description);
$channel->addChild('link', rex::getServer());

// RexStan: Only booleans are allowed in &&, int given on the left side.
// TODO: klären was der Teil `$lang &&` bewirken soll und ggf. rauswerfen
if ($lang && $lang > 0) {
if ($lang > 0) {
$channel->addChild('language', rex_clang::get($lang)->getCode());
}

Expand Down
3 changes: 3 additions & 0 deletions lib/Cronjob/Publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

class Publish extends rex_cronjob
{
/**
* @return bool
*/
public function execute()
{
/* Collection von Neues-Einträgen, die noch nicht veröffentlicht sind, aber es sein sollten. (geplant) */
Expand Down
25 changes: 19 additions & 6 deletions lib/Cronjob/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use rex_cronjob;
use rex_i18n;
use rex_socket;
use rex_socket_response;

class Sync extends rex_cronjob
{
Expand All @@ -17,21 +16,28 @@ class Sync extends rex_cronjob
'author' => '/rest/neues/author/5.0.0/',
'entry' => '/rest/neues/entry/5.0.0/'];

/**
* @return bool
*/
public function execute()
{
$data = [];

foreach ($this->rest_urls as $type => $url) {
$url = $this->getParam('url') . $url;
$token = $this->getParam('token');
$status = $this->getParam('status');
$baseUrl = $this->getParam('url');
$token = $this->getParam('token');
$status = $this->getParam('status');

foreach ($this->rest_urls as $type => $url) {
$url = $baseUrl . $url;
$socket = rex_socket::factoryUrl($url);
$socket->addHeader('token', $token);
/** @var rex_socket_response $response */
$response = $socket->doGet();

if (!$response->isOk()) {
/**
* TODO: in 'neues_entry_sync_error' Platzhalter für den Code. einfügen.
* TODO: reicht auch $this->setMessage(rex_i18n::msg('neues_entry_sync_error') ??
*/
$this->setMessage(sprintf(rex_i18n::msg('neues_entry_sync_error'), $response->getStatusCode()));
return false;
}
Expand Down Expand Up @@ -106,6 +112,13 @@ public function execute()
$neues_entry->setValue('updatedate', $entry['updatedate']);
$neues_entry->save();
}

/**
* REVIEW: Ist hier der letzte Status-Code wirklich erforderlich? Es wäre eh nur der der letzten Abfrage
* FIXME: Der Eintrag 'neues_entry_sync_success' kommt in den .lang-Dateien nicht vor.
* REXSTAN: Variable $response might not be defined.
* -> unwahrscheinlich, da es fix drei $data-Einträge gibt. Dennoch ....
*/
$this->setMessage(sprintf(rex_i18n::msg('neues_entry_sync_success'), $response->getStatusCode()));
return true;
}
Expand Down

0 comments on commit 410a16f

Please sign in to comment.