Skip to content

Commit

Permalink
Merge pull request #123 from FriendsOfREDAXO/christophboecker-patch-1
Browse files Browse the repository at this point in the history
$_REQUEST-Nutzung aufgelöst
  • Loading branch information
alxndr-w authored Sep 17, 2024
2 parents 67db35d + f0e4aed commit ca995cf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
26 changes: 1 addition & 25 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
use rex_addon;
use rex_api_function;
use rex_cronjob_manager;
use rex_csrf_token;
use rex_extension;
use rex_plugin;
use rex_url;
use rex_yform_manager_dataset;

use function count;

/**
* Tabellen in YForm mit eigener Model-Class.
*/
Expand Down Expand Up @@ -53,33 +49,13 @@
}

if (rex::isBackend()) {
$addon = rex_addon::get('neues');
$pages = $addon->getProperty('pages');

/**
* Individualiserte Liste für Enries.
*/
rex_extension::register('YFORM_DATA_LIST', Entry::epYformDataList(...));

/**
* Plus(Add)-Button im Hauptmenü-Punkt des Addon bereitstellen.
*
* RexStan: Using $_REQUEST is forbidden, use rex_request::request() or rex_request() instead.
* Kommentar: Für diese Nutzung ist keine rex-Alternative verfügbar
* @phpstan-ignore-next-line
*/
if (0 < count($_REQUEST)) {
$_csrf_key = Entry::table()->getCSRFKey();

$params = rex_csrf_token::factory($_csrf_key)->getUrlParams();

$params['table_name'] = Entry::table()->getTableName(); // Tabellenname anpassen
$params['rex_yform_manager_popup'] = '0';
$params['func'] = 'add';

$href = rex_url::backendPage('neues/entry', $params);

$pages['neues']['title'] .= ' <a class="label label-primary tex-primary" style="position: absolute; right: 18px; top: 10px; padding: 0.2em 0.6em 0.3em; border-radius: 3px; color: white; display: inline; width: auto;" href="' . $href . '">+</a>';
$addon->setProperty('pages', $pages);
}
rex_extension::register('PAGES_PREPARED', Neues::epPagesPrepared(...));
}
46 changes: 44 additions & 2 deletions lib/neues.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

namespace FriendsOfRedaxo\Neues;

use rex;
use rex_be_controller;
use rex_be_page;
use rex_csrf_token;
use rex_extension_point;
use rex_fragment;
use rex_pager;
use rex_sql;
use rex_url;

use const ENT_QUOTES;

Expand Down Expand Up @@ -62,9 +68,45 @@ public static function getEntry(int $postId): string
return $fragment->parse('neues/entry.php');
}

/* Hilfsklasse für JSON-LD Fragmente */
public static function htmlEncode($value)
/**
* Hilfsklasse für JSON-LD Fragmente.
*
* @api
*/
public static function htmlEncode(string $value): string
{
return htmlentities($value, ENT_QUOTES, 'UTF-8');
}

/**
* EP-Callback für PAGES_PREPARED.
*
* Ergänzt den Backend-Menüpunkt um einen Plus-Button. Dies aber nur dann,
* wenn die Instanz nicht via Redaxo-Konsole aufgerufen wurde.
* (Prüfung zeitverzögert im EP, da die Konsole während der boot.php noch
* nicht initialisiert ist).
*
* @api
* @param rex_extension_point<array<string,rex_be_page>> $ep
*/
public static function epPagesPrepared(rex_extension_point $ep): void
{
if (null === rex::getConsole()) {
$_csrf_key = Entry::table()->getCSRFKey();

$params = rex_csrf_token::factory($_csrf_key)->getUrlParams();

$params['table_name'] = Entry::table()->getTableName(); // Tabellenname anpassen
$params['rex_yform_manager_popup'] = '0';
$params['func'] = 'add';

$href = rex_url::backendPage('neues/entry', $params);

$neues = rex_be_controller::getPageObject('neues');
$neues->setTitle(
$neues->getTitle() .
' <a class="label label-primary tex-primary" style="position: absolute; right: 18px; top: 10px; padding: 0.2em 0.6em 0.3em; border-radius: 3px; color: white; display: inline; width: auto;" href="' . $href . '">+</a>',
);
}
}
}

0 comments on commit ca995cf

Please sign in to comment.