Skip to content

Commit

Permalink
Merge pull request #62 from aeberhard/Extension-Points
Browse files Browse the repository at this point in the history
Update Extension points
  • Loading branch information
aeberhard authored Jun 23, 2020
2 parents 4227dae + 5e9d056 commit 5229950
Show file tree
Hide file tree
Showing 147 changed files with 577 additions and 168 deletions.
1 change: 1 addition & 0 deletions lib/demo_addon_logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function log($logstr, $logname = '<strong>* Demo_Addon *</strong>'
$data = [
$logname,
$logstr,
rex::isFrontend(),
];

self::$logfile->add($data);
Expand Down
3 changes: 3 additions & 0 deletions pages/eps.logfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
/** @var rex_log_entry $entry */
$data = $entry->getData();
$class = 'notice';
if ('1' === $data[2]) {
$class = 'warning';
}

$content .= '
<tr class="rex-state-' . $class . '">
Expand Down
6 changes: 3 additions & 3 deletions pages/extensionpoints/core/EDITOR_URL.de.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

**Beschreibung:** `EDITOR_URL`
**Beschreibung:** Über den EP `EDITOR_URL` können die URLs für den Editor (Systemeinstellung) manipuliert werden

**Übergabewerte**

```
Subject: ...
Parameter: ...
Subject: null
Parameter: ['file' => $file, 'line' => $line]
```
11 changes: 9 additions & 2 deletions pages/extensionpoints/core/EDITOR_URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

rex_extension::register('EDITOR_URL', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
$var = rex_escape(var_export($ep, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());

$file = $ep->getParam('file');
$line = $ep->getParam('line');
demo_addon_logger::log('file: ' . $file . '<br>line: ' . $line, $ep->getName());

// Die Url kann in diesem Fall mit return geändert werden
// return $meineurl;
});
2 changes: 1 addition & 1 deletion pages/extensionpoints/core/FE_OUTPUT.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Durch setSubject kann hier noch vor Ausgabe der Webseite eine Ausgabe generiert
**Übergabewerte**

```
Subject: Content
Subject: $content
Parameter: keine
```
4 changes: 3 additions & 1 deletion pages/extensionpoints/core/FE_OUTPUT.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
//(demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());

$content = $ep->getSubject();
demo_addon_logger::log(strlen($content) . ' Bytes Subject', $ep->getName());
$url = " - $_SERVER[REQUEST_URI]";

demo_addon_logger::log('Subject: ' . strlen($content) . ' Bytes<br>URL: ' . $url, $ep->getName());
});
7 changes: 6 additions & 1 deletion pages/extensionpoints/core/META_NAVI.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@

// Aufbereiten für die Ausgabe im Logfile
$var = rex_escape(var_export($content, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
demo_addon_logger::log('Subject: <pre>' . $var . '</pre>', $ep->getName());

// Zusätzlichen Link in der Meta-Navi einfügen
//$content[] = '<li><a href="#"><i class="rex-icon rex-icon-view"></i> Neuer Link</a></li>'; # Link am Ende anhängen
//array_unshift($content, '<li><a href="#"><i class="rex-icon rex-icon-view"></i> Neuer Link</a></li>'); # Link vorne einfügen
//$ep->setSubject($content);
});
12 changes: 5 additions & 7 deletions pages/extensionpoints/core/OUTPUT_FILTER.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

rex_extension::register('OUTPUT_FILTER', static function (rex_extension_point $ep) {
$content = $ep->getSubject(); // HTML-Code aus Subject

// Modus Backend und Frontend evtl. unterscheiden
if (rex::isBackend() && rex::getUser()) {
// Ersetzungen im Backend ...
Expand All @@ -14,16 +16,12 @@
$url = " - $_SERVER[REQUEST_URI]";

// Ausgabe der Anzahl Bytes, Modus und URL im Logfile
demo_addon_logger::log(strlen($ep->getSubject()) . ' Bytes - Mode: ' . $rxmode . '<br>URL: ' . $url, $ep->getName());

// Ausgabe der Übergabewerte im Logfile
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
demo_addon_logger::log('Subject: ' . strlen($content) . ' Bytes - Mode: ' . $rxmode . '<br>URL: ' . $url, $ep->getName());

// Ersetzung im HTML-Code durchführen und zurückliefern
$search = '</html>';
$replace = '</html><!-- OUTPUT_FILTER Demo-AddOn - ' . $rxmode . ' -->';

// Mit setSubject wird der veränderte HTML-Code zurückgeschrieben
$ep->setSubject(str_replace($search, $replace, $ep->getSubject()));
// Mit setSubject wird der veränderte HTML-Code zurückgeliefert
$ep->setSubject(str_replace($search, $replace, $content));
});
2 changes: 1 addition & 1 deletion pages/extensionpoints/core/PACKAGES_INCLUDED.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

// Modus und URL für die Logfile-Ausgabe
$rxmode = (rex::isBackend() && rex::getUser()) ? 'Backend' : 'Frontend';
$url = " - $_SERVER[REQUEST_URI]";
$url = $_SERVER['REQUEST_URI'];
demo_addon_logger::log('Mode: ' . $rxmode . '<br>URL: ' . $url, $ep->getName());
});
2 changes: 1 addition & 1 deletion pages/extensionpoints/core/PAGES_PREPARED.de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

**Beschreibung:** `PAGES_PREPARED`
**Beschreibung:** Über den EP `PAGES_PREPARED` kann im Backend die REDAXO-Navigation mit den einzelnen Pages noch beeinflusst werden.

**Übergabewerte**

Expand Down
15 changes: 13 additions & 2 deletions pages/extensionpoints/core/PAGES_PREPARED.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());

$pages = $ep->getSubject(); // rex_be_controller::getPages()
demo_addon_logger::log('Count pages: ' . count($pages), $ep->getName());
// Pages aus Subject - rex_be_controller::getPages()
$pages = $ep->getSubject();

// Modus und Counter für die Logfile-Ausgabe
$rxmode = (rex::isBackend() && rex::getUser()) ? 'Backend' : 'Frontend';
$pagecount = count($ep->getSubject());
$url = $_SERVER['REQUEST_URI'];

demo_addon_logger::log('Mode: ' . $rxmode . '<br>Count pages: ' . $pagecount . '<br>URL: ' . $url, $ep->getName());

// Pages verändern und zurückliefern
//$pages['AddOn-Name']->setHref('MeineUrl');
//$ep->setSubject($pages);
});
6 changes: 3 additions & 3 deletions pages/extensionpoints/core/PAGE_BODY_ATTR.de.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

**Beschreibung:** `PAGE_BODY_ATTR`
**Beschreibung:** Über den EP `PAGE_BODY_ATTR` können die BODY-Attribute im Backend abgefragt und auch geändert werden.

**Übergabewerte**

```
Subject: ...
Parameter: ...
Subject: $attr_items
Parameter: keine
```
16 changes: 14 additions & 2 deletions pages/extensionpoints/core/PAGE_BODY_ATTR.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

rex_extension::register('PAGE_BODY_ATTR', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
$var = rex_escape(var_export($ep, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());

$attributes = $ep->getSubject();
$log = '';
foreach ($attributes as $attr => $values) {
$log .= $attr . ': ' . implode(' ', $values) . PHP_EOL;
}
demo_addon_logger::log('Subject:<br><pre>' . $log . '</pre>', $ep->getName());

// BODY-Attribute ändern
//$attributes['id'][] = 'demo-addon'; # zusätzliche Id
//$attributes['class'][] = 'demo-addon'; # zusätzliche Klasse
//$ep->setSubject($attributes);
});
2 changes: 1 addition & 1 deletion pages/extensionpoints/core/PAGE_CHECKED.de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

**Beschreibung:** `PAGE_CHECKED`
**Beschreibung:** Der EP `PAGE_CHECKED` enthält das nach dem EP `PAGES_PREPARED` evtl. veränderte Pages-Objekt (rex_be_controller::getPages()).

**Übergabewerte**

Expand Down
8 changes: 6 additions & 2 deletions pages/extensionpoints/core/PAGE_CHECKED.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());

$pages = $ep->getParam('pages'); // rex_be_controller::getPages()
demo_addon_logger::log('Count pages: ' . count($pages), $ep->getName());
// Modus und Counter für die Logfile-Ausgabe
$rxmode = (rex::isBackend() && rex::getUser()) ? 'Backend' : 'Frontend';
$pages = count($ep->getParam('pages')); // rex_be_controller::getPages()
$page = $ep->getSubject();

demo_addon_logger::log('Mode: ' . $rxmode . '<br>Count pages: ' . $pages . '<br>Page: ' . $page, $ep->getName());
});
4 changes: 3 additions & 1 deletion pages/extensionpoints/core/PAGE_HEADER.de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

**Beschreibung:** `PAGE_HEADER`
**Beschreibung:** Über den EP `PAGE_HEADER` kann im Backend zusätzlicher Code im HEAD-Bereich ausgegeben werden.

> **Hinweis:** Für die Ausgabe von zusätzlichem CSS oder JavaScript die Funktionen `rex_view::addCssFile()` und `rex_view::addJsFile()` verwenden! Siehe [https://redaxo.org/doku/master/addon-assets](https://redaxo.org/doku/master/addon-assets)
**Übergabewerte**

Expand Down
9 changes: 6 additions & 3 deletions pages/extensionpoints/core/PAGE_HEADER.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

rex_extension::register('PAGE_HEADER', static function (rex_extension_point $ep) {
$content = $ep->getSubject(); // Array mit den Meta Navi Links
$content = $ep->getSubject(); // Content HEAD-Bereich

// Ausgabe der Übergabewerte im Logfile
$var = nl2br(rex_escape($content));
demo_addon_logger::log('PAGE_HEADER Subject:<br>' . $var, $ep->getName());
$var = rex_escape($content);
demo_addon_logger::log('Subject:<br><pre> ' . $var . '</pre>', $ep->getName());

// Hier kann zusätzlicher Code ausgegeben werden, Zeilen sollten mit "\n" abgeschlossen werden
//$ep->setSubject($content . PHP_EOL . $zusatzContent);
});
2 changes: 1 addition & 1 deletion pages/extensionpoints/core/PAGE_TITLE.de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

**Beschreibung:** `PAGE_TITLE`
**Beschreibung:** Mit dem EP `PAGE_TITLE` kann im Backend der Seitentitel angepasst werden.

**Übergabewerte**

Expand Down
8 changes: 6 additions & 2 deletions pages/extensionpoints/core/PAGE_TITLE.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());

// Der Seitentitel kann hier per setSubject angepasst werden
$title = $ep->getSubject();
demo_addon_logger::log('Seitentitel: ' . $title, $ep->getName());
$url = $_SERVER['REQUEST_URI'];

demo_addon_logger::log('Seitentitel: ' . $title . '<br>URL: ' . $url, $ep->getName());

// Der Seitentitel kann hier per setSubject() angepasst werden
//$ep->setSubject($title . ' - ' . $meintext);
});
2 changes: 1 addition & 1 deletion pages/extensionpoints/core/PAGE_TITLE_SHOWN.de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

**Beschreibung:** `PAGE_TITLE_SHOWN`
**Beschreibung:** Über den EP `PAGE_TITLE_SHOWN` kann zusätzlicher HTML-Code nach dem AddOn-Header (Titel + Navi-Leiste) ausgegeben werden.

**Übergabewerte**

Expand Down
5 changes: 5 additions & 0 deletions pages/extensionpoints/core/PAGE_TITLE_SHOWN.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());

demo_addon_logger::log('Keine Übergabewerte!', $ep->getName());

// Hier besteht die Möglichkeit zusätzlichen HTML-Code nach dem AddOn-Header (Titel + Navi-Leiste) auszugeben
//$ep->setSubject($meinHtmlCode);
// oder
//return $meinHtmlCode;
});
4 changes: 2 additions & 2 deletions pages/extensionpoints/core/PROFILE_UPDATED.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
**Übergabewerte**

```
Subject: $title
Parameter: keine
Subject: ...
Parameter: ...
```
2 changes: 1 addition & 1 deletion pages/extensionpoints/core/RESPONSE_SHUTDOWN.de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

**Beschreibung:** Der EP `RESPONSE_SHUTDOWN` ist der letzte Extension Point vor der Ausgabe der Seite an den Browser. Subject ist der finale HTML-Output (evtl. durch andere EP's verändert). Der Output kann nicht mehr geändert werden (readonly).
**Beschreibung:** Der EP `RESPONSE_SHUTDOWN` ist der letzte Extension Point vor der Ausgabe der Seite an den Browser (Backend und Frontend). Subject ist der finale HTML-Output (evtl. durch andere EP's verändert). Der Output kann nicht mehr geändert werden (readonly).

**Übergabewerte**

Expand Down
4 changes: 2 additions & 2 deletions pages/extensionpoints/core/RESPONSE_SHUTDOWN.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
rex_extension::register('RESPONSE_SHUTDOWN', static function (rex_extension_point $ep) {
// Modus und URL für die Logfile-Ausgabe
$rxmode = (rex::isBackend() && rex::getUser()) ? 'Backend' : 'Frontend';
$url = " - $_SERVER[REQUEST_URI]";
$url = $_SERVER['REQUEST_URI'];

// Ausgabe der Anzahl Bytes, Modus und URL im Logfile
demo_addon_logger::log(strlen($ep->getSubject()) . ' Bytes - Mode: ' . $rxmode . '<br>URL: ' . $url, $ep->getName());
demo_addon_logger::log('Subject: '. strlen($ep->getSubject()) . ' Bytes - Mode: ' . $rxmode . '<br>URL: ' . $url, $ep->getName());
});
1 change: 1 addition & 0 deletions pages/extensionpoints/core/REX_FORM_CONTROL_FIELDS.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

rex_extension::register('REX_FORM_CONTROL_FIELDS', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
// Achtung erzeugt einen ellenlangen Eintrag im Logfile und eine Warning im Systemlog!
$var = rex_escape(var_export($ep, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
});
5 changes: 3 additions & 2 deletions pages/extensionpoints/core/REX_FORM_GET.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

rex_extension::register('REX_FORM_GET', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
$var = rex_escape(var_export($ep, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
// Achtung erzeugt einen ellenlangen Eintrag im Logfile und eine Warning im Systemlog!
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
});
3 changes: 2 additions & 1 deletion pages/extensionpoints/core/REX_FORM_SAVED.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

rex_extension::register('REX_FORM_SAVED', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
$var = rex_escape(var_export($ep, true));
//$var = rex_escape(var_export($ep, true));
$var = '...';
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
});
5 changes: 3 additions & 2 deletions pages/extensionpoints/core/REX_LIST_GET.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

rex_extension::register('REX_LIST_GET', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
$var = rex_escape(var_export($ep, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
// Achtung erzeugt einen ellenlangen Eintrag im Logfile und eine Warning im Systemlog!
//$var = rex_escape(var_export($ep, true));
//demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
});
4 changes: 2 additions & 2 deletions pages/extensionpoints/core/USER_ADDED.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
**Übergabewerte**

```
Subject: $title
Parameter: keine
Subject: ...
Parameter: ...
```
4 changes: 2 additions & 2 deletions pages/extensionpoints/core/USER_UPDATED.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
**Übergabewerte**

```
Subject: $title
Parameter: keine
Subject: ...
Parameter: ...
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

**Beschreibung:** ...

**Beschreibung:** `MEDIA_ADD`

**Übergabewerte**

Expand Down
7 changes: 7 additions & 0 deletions pages/extensionpoints/medienpool/MEDIA_ADD.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

rex_extension::register('MEDIA_ADD', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
$var = rex_escape(var_export($ep, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
**Übergabewerte**

```
Subject: $title
Parameter: keine
Subject: ...
Parameter: ...
```
4 changes: 2 additions & 2 deletions pages/extensionpoints/medienpool/MEDIA_DETAIL_SIDEBAR.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
**Übergabewerte**

```
Subject: $title
Parameter: keine
Subject: ...
Parameter: ...
```
4 changes: 2 additions & 2 deletions pages/extensionpoints/medienpool/MEDIA_MOVED.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
**Übergabewerte**

```
Subject: $title
Parameter: keine
Subject: ...
Parameter: ...
```
3 changes: 1 addition & 2 deletions pages/extensionpoints/structure/ART_ADDED.de.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

**Beschreibung:** ...

**Beschreibung:** `ART_ADDED`

**Übergabewerte**

Expand Down
7 changes: 7 additions & 0 deletions pages/extensionpoints/structure/ART_ADDED.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

rex_extension::register('ART_ADDED', static function (rex_extension_point $ep) {
// Ausgabe der Übergabewerte im Logfile
$var = rex_escape(var_export($ep, true));
demo_addon_logger::log('<pre>' . $var . '</pre>', $ep->getName());
});
Loading

0 comments on commit 5229950

Please sign in to comment.