Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whoops bei Rollen vermeiden, neue data_edit #12

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: neues
version: '3.0.1'
version: '3.1.0'
author: 'Alexander Walther'
supportpage: https://alexplusde.github.io/neues/
load: late
Expand Down Expand Up @@ -31,26 +31,29 @@ pages:
title: translate:neues_entry
icon: rex-icon fa-bullhorn
subPath: pages/data_edit.php
yformTable: rex_neues_entry
yformClass: rex_neues_entry
yformTitle: false
yform:
table_name: rex_neues_entry
wrapper_class: rex_neues_entry
show_title: false
perm: neues[date]
category:
title: translate:neues_category
icon: rex-icon fa-folder
subPath: pages/data_edit.php
yformTable: rex_neues_category
yformClass: rex_neues_category
yformTitle: false
yform:
table_name: rex_neues_category
wrapper_class: rex_neues_category
show_title: false
perm: neues[category]
date_lang:
title: translate:neues_lang
perm: neues[date_lang]
icon: rex-icon fa-flag
subPath: pages/data_edit.php
yformTable: rex_neues_entry_lang
yformClass: rex_neues_entry_lang
yformTitle: false
yform:
table_name: rex_neues_entry_lang
wrapper_class: rex_neues_entry_lang
show_title: false
settings:
title: translate:neues_settings
icon: rex-icon fa-gear
Expand Down
82 changes: 26 additions & 56 deletions pages/data_edit.php
Original file line number Diff line number Diff line change
@@ -1,63 +1,33 @@
<?php
$target_page = rex_request('page', 'string');
if ($target_page == 'yform/manager/data_edit') {
$table_name = rex_request('table_name', 'string');
$wrapper = '';
$show_title = true;
} elseif (isset(rex_package::get("neues")->getProperty('pages')[rex_be_controller::getCurrentPagePart(1)])) {
# page-Properties allgemein abrufen
$properties = rex_package::get("neues")->getProperty('pages')[rex_be_controller::getCurrentPagePart(1)];
if ($sub=rex_be_controller::getCurrentPagePart(2)) {
$properties = $properties['subpages'][$sub];
}
# yform-properties
$table_name = isset($properties['yformTable']) ? $properties['yformTable'] : '';
$wrapper = isset($properties['yformClass']) ? $properties['yformClass'] : '';
$show_title = $properties['yformTitle'] ?? false;
} else {
$table_name = '';
}

$table = rex_yform_manager_table::get($table_name);
$yform = rex_package::get("neues")->getProperty('pages')[rex_be_controller::getCurrentPagePart(1)]['subpages'][rex_be_controller::getCurrentPagePart(2)]['yform'];

if ($table && rex::getUser() && (rex::getUser()->isAdmin() || rex::getUser()->getComplexPerm('yform_manager_table')->hasPerm($table->getTableName()))) {
try {
$page = new rex_yform_manager();
$page->setTable($table);
$page->setLinkVars(['page' => $target_page, 'table_name' => $table->getTableName()]);
$table_name = $yform['table_name'] ?? '';
$show_title = true === ($yform['show_title'] ?? false);
$wrapper_class = $yform['wrapper_class'] ?? '';

if ($wrapper) {
echo "<div class=\"$wrapper\">";
}
if ($table_name) {
$_REQUEST['table_name'] = $table_name;
}

if ($show_title) {
echo $page->getDataPage();
} else {
# Seite erzeugen und abfangen
ob_start();
echo $page->getDataPage();
$page = ob_get_clean();
# Such den Header - Fall 1: mit Suchspalte?
$p = strpos($page, '<div class="row">');
# Such den Header - Fall 2: ohne Suchspalte
if ($p === false) {
$p = strpos($page, '<section class="rex-page-section">');
}
# Header rauswerfen
if ($p !== false) {
$page = ''.substr($page, $p);
if (!$show_title) {
\rex_extension::register(
'YFORM_MANAGER_DATA_PAGE_HEADER',
function (\rex_extension_point $ep) {
if ($ep->getParam('yform')->table->getTableName() === $ep->getParam('table_name')) {
return '';
}
# ausgabe
echo $page;
}
},
\rex_extension::EARLY,
['table_name'=>$table_name]
);
}

if ($wrapper_class) {
echo '<div class="',$wrapper_class,'">';
}

include \rex_path::plugin('yform', 'manager', 'pages/data_edit.php');

if ($wrapper) {
echo '</div>';
}
} catch (Exception $e) {
$message = nl2br($e->getMessage()."\n".$e->getTraceAsString());
echo rex_view::warning($message);
}
} elseif (!$table) {
echo rex_view::warning(rex_i18n::msg('yform_table_not_found'));
if ($wrapper_class) {
echo '</div>';
}