|
2 | 2 |
|
3 | 3 | namespace FriendsOfRedaxo\Neues;
|
4 | 4 |
|
| 5 | +use rex; |
| 6 | +use rex_be_controller; |
| 7 | +use rex_be_page; |
| 8 | +use rex_csrf_token; |
| 9 | +use rex_extension_point; |
5 | 10 | use rex_fragment;
|
6 | 11 | use rex_pager;
|
7 | 12 | use rex_sql;
|
| 13 | +use rex_url; |
8 | 14 |
|
9 | 15 | use const ENT_QUOTES;
|
10 | 16 |
|
@@ -62,9 +68,45 @@ public static function getEntry(int $postId): string
|
62 | 68 | return $fragment->parse('neues/entry.php');
|
63 | 69 | }
|
64 | 70 |
|
65 |
| - /* Hilfsklasse für JSON-LD Fragmente */ |
66 |
| - public static function htmlEncode($value) |
| 71 | + /** |
| 72 | + * Hilfsklasse für JSON-LD Fragmente. |
| 73 | + * |
| 74 | + * @api |
| 75 | + */ |
| 76 | + public static function htmlEncode(string $value): string |
67 | 77 | {
|
68 | 78 | return htmlentities($value, ENT_QUOTES, 'UTF-8');
|
69 | 79 | }
|
| 80 | + |
| 81 | + /** |
| 82 | + * EP-Callback für PAGES_PREPARED. |
| 83 | + * |
| 84 | + * Ergänzt den Backend-Menüpunkt um einen Plus-Button. Dies aber nur dann, |
| 85 | + * wenn die Instanz nicht via Redaxo-Konsole aufgerufen wurde. |
| 86 | + * (Prüfung zeitverzögert im EP, da die Konsole während der boot.php noch |
| 87 | + * nicht initialisiert ist). |
| 88 | + * |
| 89 | + * @api |
| 90 | + * @param rex_extension_point<array<string,rex_be_page>> $ep |
| 91 | + */ |
| 92 | + public static function epPagesPrepared(rex_extension_point $ep): void |
| 93 | + { |
| 94 | + if (null === rex::getConsole()) { |
| 95 | + $_csrf_key = Entry::table()->getCSRFKey(); |
| 96 | + |
| 97 | + $params = rex_csrf_token::factory($_csrf_key)->getUrlParams(); |
| 98 | + |
| 99 | + $params['table_name'] = Entry::table()->getTableName(); // Tabellenname anpassen |
| 100 | + $params['rex_yform_manager_popup'] = '0'; |
| 101 | + $params['func'] = 'add'; |
| 102 | + |
| 103 | + $href = rex_url::backendPage('neues/entry', $params); |
| 104 | + |
| 105 | + $neues = rex_be_controller::getPageObject('neues'); |
| 106 | + $neues->setTitle( |
| 107 | + $neues->getTitle() . |
| 108 | + ' <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>', |
| 109 | + ); |
| 110 | + } |
| 111 | + } |
70 | 112 | }
|
0 commit comments