Skip to content

Commit

Permalink
WIP: Plugin less (#1526)
Browse files Browse the repository at this point in the history
* E-Mail Plugin ins AddOn

* REST plugIn  ins addon

* Tools PlugIn ins AddOn

* Plugin Manager entfernt

* CS

* Docs
  • Loading branch information
dergel authored Sep 7, 2024
1 parent df79eff commit ada7342
Show file tree
Hide file tree
Showing 128 changed files with 2,321 additions and 2,370 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
131 changes: 131 additions & 0 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,134 @@
}
});
}

// E-Mail

rex_extension::register('EDITOR_URL', static function (rex_extension_point $ep) {
if (preg_match('@^rex:///yform/email/template/(.*)/(.*)@', $ep->getParam('file'), $match)) {
return rex_url::backendPage(
'yform/email/index',
[
'func' => 'edit',
'template_key' => $match[1],
],
);
}
});

// REST

rex_extension::register('PACKAGES_INCLUDED', static function () {
if (!rex::isBackend()) {
rex_yform_rest::handleRoutes();
}
});

// Tools

if (rex::isBackend() && rex::getUser()) {
rex_view::addJsFile($this->getAssetsUrl('daterangepicker/moment.min.js'));
rex_view::addJsFile($this->getAssetsUrl('daterangepicker/daterangepicker.js'));
rex_view::addCssFile($this->getAssetsUrl('daterangepicker/daterangepicker.css'));
rex_view::addJsFile($this->getAssetsUrl('inputmask/dist/jquery.inputmask.min.js'));
rex_view::addJsFile($this->getAssetsUrl('tools.js'));
}

// Manager

rex_complex_perm::register('yform_manager_table_edit', 'rex_yform_manager_table_perm_edit');
rex_complex_perm::register('yform_manager_table_view', 'rex_yform_manager_table_perm_view');

if (rex::isBackend() && rex::getUser()) {
rex_extension::register('PACKAGES_INCLUDED', function () {
if ($this->getProperty('compile')) {
$compiler = new rex_scss_compiler();
$compiler->setRootDir($this->getPath('scss/'));
$compiler->setScssFile($this->getPath('scss/manager.scss'));
$compiler->setCssFile($this->getPath('assets/manager.css'));
$compiler->compile();
rex_dir::copy($this->getPath('assets'), $this->getAssetsPath()); // copy whole assets directory
}
});

rex_view::addJsFile($this->getAssetsUrl('manager.js'));
rex_view::addJsFile($this->getAssetsUrl('relations.js'));
rex_view::addCssFile($this->getAssetsUrl('manager.css'));
rex_view::addJsFile($this->getAssetsUrl('widget.js'));

if (!rex::getUser()->isAdmin()) {
$page = $this->getProperty('page');
$page['hidden'] = true;
$this->setProperty('page', $page);
}

try {
$tables = rex_yform_manager_table::getAll();
} catch (Exception $e) {
$tables = [];
}
$pages = [];

$prio = 1;
foreach ($tables as $table) {
if ($table->isActive() && $table->isGranted('VIEW', rex::getUser())) {
$be_page = new rex_be_page_main('yform_tables', $table->getTableName(), rex_escape($table->getNameLocalized()));
$be_page->setHref('index.php?page=yform/manager/data_edit&table_name=' . $table->getTableName());
$icon = rex_escape($table->getCustomIcon() ?: 'rex-icon-module');
$be_page->setIcon('rex-icon ' . $icon);
$be_page->setPrio($prio);

if ($table->isHidden()) {
$be_page->setHidden();
}

if ('yform/manager/data_edit' == rex_request('page', 'string') && rex_request('table_name', 'string') == $table->getTableName()) {
$be_page->setIsActive();

$main_page = $this->getAddon()->getProperty('page');
$main_page['isActive'] = false;

$rex_yform_manager_opener = rex_request('rex_yform_manager_opener', 'array');
$rex_yform_manager_popup = rex_request('rex_yform_manager_popup', 'int');
$rex_yform_filter = rex_request('rex_yform_filter', 'array');

if ((isset($rex_yform_manager_opener['id']) && '' != $rex_yform_manager_opener['id']) || 1 == $rex_yform_manager_popup) {
$main_page['popup'] = true;
}

$this->getAddon()->setProperty('page', $main_page);
}

$pages[] = $be_page;

++$prio;
}
}

$this->setProperty('pages', $pages);
}

rex_extension::register('MEDIA_IS_IN_USE', 'rex_yform_value_be_media::isMediaInUse');
rex_extension::register('PACKAGES_INCLUDED', 'rex_yform_value_be_link::isArticleInUse');

rex_extension::register('YFORM_SAVED', static function (rex_extension_point $ep) {
if ($ep->getSubject() instanceof Exception) {
return;
}

$table = rex_yform_manager_table::get($ep->getParam('table'));
if (!$table) {
return;
}

$dataset = $ep->getParam('form')->getParam('manager_dataset');
if (!$dataset) {
$dataset = rex_yform_manager_dataset::getRaw($ep->getParam('id'), $table->getTableName());
}
$dataset->invalidateData();

if ($table->hasHistory() && $dataset->isHistoryEnabled()) {
$action = 'insert' === $ep->getParam('action') ? rex_yform_manager_dataset::ACTION_CREATE : rex_yform_manager_dataset::ACTION_UPDATE;
$dataset->makeSnapshot($action);
}
});
7 changes: 2 additions & 5 deletions docs/02_email.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# E-Mail-Templates (PlugIn)

> **Hinweis:**
> Plugins erweitern YForm und können optional aktiviert werden.
# E-Mail-Templates

## Zweck der E-Mail-Templates

Expand Down Expand Up @@ -138,7 +135,7 @@ REX_YFORM_DATA[field="custom"]

## Variante 2: E-Mail-Versand zur Verwendung in Cronjobs, Addons, etc.

Dieser Code basiert auf [plugins/email/lib/yform_action_tpl2email.php](https://github.com/yakamara/redaxo_yform/blob/master/plugins/email/lib/yform_action_tpl2email.php).
Dieser Code basiert auf [lib/yform/action/tpl2email.php](https://github.com/yakamara/redaxo_yform/blob/master/plugins/email/lib/yform_action_tpl2email.php).

```php
<?php
Expand Down
2 changes: 1 addition & 1 deletion docs/03_table_manager.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Table Manager (PlugIn)
# Table Manager

> **Hinweis:**
> Plugins erweitern YForm und können optional aktiviert werden.
Expand Down
2 changes: 1 addition & 1 deletion docs/05_rest.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# REST-API (PlugIn)
# REST-API

> **Hinweis:**
> Plugins erweitern YForm und können optional aktiviert werden.
Expand Down
2 changes: 1 addition & 1 deletion docs/08_tools.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tools (Plugin)
# Tools

> **Hinweis:**
> Plugins erweitern YForm und können optional aktiviert werden.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ada7342

Please sign in to comment.