' . rex_i18n::msg('yform_thankyouforentry') . '
']); - $yform->setObjectparams('main_table', rex_yform_manager_field::table()); + $yform->setObjectparams('main_table', Field::table()); switch ($func) { case 'edit': $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_field_update')); $yform->setHiddenField('field_id', $field_id); - $yform->setActionField('manage_db', [rex_yform_manager_field::table(), "id=$field_id"]); + $yform->setActionField('manage_db', [Field::table(), "id=$field_id"]); $yform->setObjectparams('main_id', $field_id); $yform->setObjectparams('main_where', "id=$field_id"); $sql = rex_sql::factory(); - $sql->setQuery('SELECT * FROM ' . rex_yform_manager_field::table() . " WHERE id=$field_id"); + $sql->setQuery('SELECT * FROM ' . Field::table() . " WHERE id=$field_id"); foreach ($selectFields as $alias => $s_field) { if ($alias != $s_field) { if ((!$sql->hasValue($s_field) || null === $sql->getValue($s_field) || '' === $sql->getValue($s_field)) && $sql->hasValue($alias)) { @@ -1070,7 +1085,7 @@ public function getFieldPage() case 'add': default: $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_field_add')); - $yform->setActionField('manage_db', [rex_yform_manager_field::table()]); + $yform->setActionField('manage_db', [Field::table()]); break; } @@ -1117,12 +1132,12 @@ public function getFieldPage() } else { switch ($func) { case 'edit': - rex_yform_manager_table_api::generateTableAndFields($table); + Api::generateTableAndFields($table); echo rex_view::success(rex_i18n::msg('yform_thankyouforupdate')); break; case 'add': default: - rex_yform_manager_table_api::generateTableAndFields($table); + Api::generateTableAndFields($table); echo rex_view::success(rex_i18n::msg('yform_thankyouforentry')); break; } @@ -1136,15 +1151,15 @@ public function getFieldPage() } else { $sf = rex_sql::factory(); $sf->setDebug(self::$debug); - $sf->setQuery('select * from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id); + $sf->setQuery('select * from ' . Field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id); $sfa = $sf->getArray(); - if (1 == count($sfa)) { - $query = 'delete from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id; + if (1 == \count($sfa)) { + $query = 'delete from ' . Field::table() . ' where table_name="' . $table->getTableName() . '" and id=' . $field_id; $delsql = rex_sql::factory(); $delsql->setDebug(self::$debug); $delsql->setQuery($query); echo rex_view::success(rex_i18n::msg('yform_tablefielddeleted')); - rex_yform_manager_table_api::generateTableAndFields($table); + Api::generateTableAndFields($table); } else { echo rex_view::warning(rex_i18n::msg('yform_tablefieldnotfound')); } @@ -1154,13 +1169,13 @@ public function getFieldPage() // ********************************************* CREATE/UPDATE FIELDS if ('updatetable' == $func) { - rex_yform_manager_table_api::generateTableAndFields($table); + Api::generateTableAndFields($table); echo rex_view::info(rex_i18n::msg('yform_tablesupdated')); $func = 'list'; } if ('updatetablewithdelete' == $func) { - rex_yform_manager_table_api::generateTableAndFields($table, true); + Api::generateTableAndFields($table, true); echo rex_view::info(rex_i18n::msg('yform_tablesupdated')); $func = 'list'; } @@ -1332,7 +1347,7 @@ public function getFieldPage() ], false); $panel_options .= '' . rex_i18n::msg('yform_table') . ' ' . $fragment->parse('core/buttons/button_group.php'); - $sql = 'select id, prio, type_id, type_name, name, label from ' . rex_yform_manager_field::table() . ' where table_name="' . $table->getTableName() . '"'; + $sql = 'select id, prio, type_id, type_name, name, label from ' . Field::table() . ' where table_name="' . $table->getTableName() . '"'; $list = rex_list::factory($sql, rowsPerPage: 200, defaultSort: [ 'prio' => 'asc', ]); @@ -1399,7 +1414,7 @@ public function getFieldPage() private function getFieldName($key, $type) { - if (is_int($key)) { + if (\is_int($key)) { ++$key; if (1 === $key) { return 'name'; @@ -1410,7 +1425,7 @@ private function getFieldName($key, $type) return 'f' . $key; } - if (in_array($key, self::$reservedFieldColumns)) { + if (\in_array($key, self::$reservedFieldColumns)) { $key = 'field_' . $key; } return $key; @@ -1422,7 +1437,7 @@ private function getFieldName($key, $type) public static function checkField($l, $v, $p) { - $q = 'select * from ' . rex_yform_manager_field::table() . ' where table_name="' . $p['table_name'] . '" and type_id="value" and ' . $l . '="' . $v . '" LIMIT 1'; + $q = 'select * from ' . Field::table() . ' where table_name="' . $p['table_name'] . '" and type_id="value" and ' . $l . '="' . $v . '" LIMIT 1'; $c = rex_sql::factory(); $c->setDebug(self::$debug); $c->setQuery($q); @@ -1442,8 +1457,8 @@ public function createTable($mifix, $data_table, $params = [], $debug = false) // Tabellenset in die Basics einbauen, wenn noch nicht vorhanden $c = rex_sql::factory(); $c->setDebug($debug); - $c->setQuery('DELETE FROM ' . rex_yform_manager_table::table() . ' where table_name="' . $data_table . '"'); - $c->setTable(rex_yform_manager_table::table()); + $c->setQuery('DELETE FROM ' . Table::table() . ' where table_name="' . $data_table . '"'); + $c->setTable(Table::table()); $params['table_name'] = $data_table; if (!isset($params['status'])) { @@ -1481,7 +1496,7 @@ public function createTable($mifix, $data_table, $params = [], $debug = false) public static function url(string $tableName, int $id = 0, array $params = []): string { - $table = rex_yform_manager_table::require($tableName); + $table = Table::require($tableName); $params['table_name'] = $table->getTableName(); diff --git a/lib/manager/query.php b/lib/manager/query.php index 466c895ef..96f442016 100644 --- a/lib/manager/query.php +++ b/lib/manager/query.php @@ -1,10 +1,27 @@ */ -class rex_yform_manager_query implements IteratorAggregate, Countable + +namespace Yakamara\YForm\Manager; + +use Countable; +use DateTimeInterface; +use InvalidArgumentException; +use IteratorAggregate; +use rex_pager; +use rex_sql; +use Yakamara\YForm\Manager\Table\Table; + +use function call_user_func; +use function in_array; +use function is_array; +use function is_bool; +use function is_object; + +class Query implements IteratorAggregate, Countable { private const PARAM_WHERE = 'where'; private const PARAM_HAVING = 'having'; @@ -71,9 +88,9 @@ public function getTableName(): string return $this->table; } - public function getTable(): rex_yform_manager_table + public function getTable(): Table { - return rex_yform_manager_table::require($this->table); + return Table::require($this->table); } /** @@ -350,7 +367,7 @@ public function whereNotBetween(string $column, $from, $to): self * Where the comma separated list column contains the given value or any of the given values. * * @param string $column Column with comma separated list - * @param string|int|int[] $value Single value (string or int) or array of values (ints only) + * @param string|int|array'; - $return .= '' . $option['name'] . '' . "\n"; - $return .= '
'; - } - - return $return; - } -} diff --git a/lib/rest/auth/auth.php b/lib/rest/AuthToken.php similarity index 90% rename from lib/rest/auth/auth.php rename to lib/rest/AuthToken.php index d9a56a9cd..6810d810f 100644 --- a/lib/rest/auth/auth.php +++ b/lib/rest/AuthToken.php @@ -1,6 +1,14 @@ getArray('select * from ' . rex::getTable('yform_rest_token') . ' where status=1 and token=? and FIND_IN_SET(?, paths)', [$myToken, $route->getPath()]); @@ -57,13 +65,13 @@ public static function addHit(array $TokenAuth) ->setTable(rex::getTable('yform_rest_token_access')) ->setValue('token_id', $TokenAuth['id']) ->setValue('datetime_created', date(rex_sql::FORMAT_DATETIME)) - ->setValue('url', rex_yform_rest::getCurrentUrl()) + ->setValue('url', Rest::getCurrentUrl()) ->insert(); } /** * @throws rex_sql_exception - * @return null|mixed + * @return mixed|null */ public static function get(int $id) { @@ -81,7 +89,7 @@ public static function get(int $id) /** * @throws rex_sql_exception - * @return null|mixed + * @return mixed|null */ public static function getCurrentIntervalAmount(string $interval, $token_id) { diff --git a/lib/rest/rest.php b/lib/rest/rest.php index f82d8810a..dec6b5d52 100644 --- a/lib/rest/rest.php +++ b/lib/rest/rest.php @@ -1,6 +1,13 @@ hasAuth()) { self::sendError('400', 'no-access'); } else { @@ -163,7 +169,7 @@ public static function getHeader($key = '', $default = '') * @param array $params * @param array $additionalPaths */ - public static function getLinkByPath(rex_yform_rest_route $route, $params = [], $additionalPaths = []): string + public static function getLinkByPath(Route $route, $params = [], $additionalPaths = []): string { if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO']) { $url = 'https://'; @@ -188,7 +194,7 @@ public static function getLinkByPath(rex_yform_rest_route $route, $params = [], } /** - * @return null|mixed + * @return mixed|null */ public static function getRouteByInstance($instance) { diff --git a/lib/rest/route.php b/lib/rest/route.php index 625645587..77acab3f9 100644 --- a/lib/rest/route.php +++ b/lib/rest/route.php @@ -1,15 +1,35 @@ additionalHeaders as $name => $value) { - rex_yform_rest::setHeader($name, $value); + Rest::setHeader($name, $value); } - rex_yform_rest::sendContent($status, $content, $contentType); + Rest::sendContent($status, $content, $contentType); exit; } @@ -87,15 +107,15 @@ public function getPath() public function handleRequest(array $paths, array $get) { if (!isset($this->config['table'])) { - rex_yform_rest::sendError('400', 'table-not-available'); + Rest::sendError('400', 'table-not-available'); } $requestMethod = $this->getRequestMethod(); if (in_array($requestMethod, self::$requestMethods) && !isset($this->config[$requestMethod])) { - rex_yform_rest::sendError('400', 'request-method-not-available'); + Rest::sendError('400', 'request-method-not-available'); } - /** @var rex_yform_manager_table $table */ + /** @var Table $table */ $table = $this->getTable(); $query = $this->getQuery(); @@ -108,9 +128,9 @@ public function handleRequest(array $paths, array $get) $instance = $table->createDataset(); $fields = $this->getFields('get', $instance); - /** @var rex_yform_manager_dataset $instance */ + /** @var Dataset $instance */ $instance = null; - /** @var rex_yform_manager_collection $instance */ + /** @var Collection $instance */ $instances = null; $attribute = null; $baseInstances = false; @@ -150,7 +170,7 @@ public function handleRequest(array $paths, array $get) $instances = $query->find(); } catch (rex_sql_exception $e) { - rex_yform_rest::sendError('400', 'query-error', []); + Rest::sendError('400', 'query-error', []); } } @@ -178,7 +198,7 @@ public function handleRequest(array $paths, array $get) } if (!$instance) { - rex_yform_rest::sendError('400', 'dataset-not-found', ['paths' => $paths, 'table' => $instances->getTable()->getTableName()]); + Rest::sendError('400', 'dataset-not-found', ['paths' => $paths, 'table' => $instances->getTable()->getTableName()]); } $attribute = null; $instances = null; @@ -194,7 +214,7 @@ public function handleRequest(array $paths, array $get) $instance = $query->findOne(); if (!$instance) { - rex_yform_rest::sendError('400', 'dataset-not-found', ['paths' => $paths, 'table' => $query->getTable()->getTableName()]); + Rest::sendError('400', 'dataset-not-found', ['paths' => $paths, 'table' => $query->getTable()->getTableName()]); } $fields = $this->getFields('get', $instance); @@ -203,7 +223,7 @@ public function handleRequest(array $paths, array $get) $attribute = $path; if (!array_key_exists($attribute, $fields)) { - rex_yform_rest::sendError('400', 'attribute-not-found', ['paths' => $paths, 'table' => $table->getTableName()]); + Rest::sendError('400', 'attribute-not-found', ['paths' => $paths, 'table' => $table->getTableName()]); } if ('be_manager_relation' == $fields[$attribute]->getTypeName()) { @@ -221,7 +241,6 @@ public function handleRequest(array $paths, array $get) $data = []; if ($instances) { foreach ($instances as $instance) { - $instance_data = $this->getInstanceData( $instance, array_merge($paths, [$instance->getId()]), @@ -256,19 +275,19 @@ public function handleRequest(array $paths, array $get) $meta['itemsPerPage'] = $per_page; $meta['currentPage'] = $currentPage; - $links['self'] = rex_yform_rest::getLinkByPath($this, $linkParams); - $links['first'] = rex_yform_rest::getLinkByPath($this, array_merge( + $links['self'] = Rest::getLinkByPath($this, $linkParams); + $links['first'] = Rest::getLinkByPath($this, array_merge( $linkParams, ['page' => 1], )); if (($currentPage - 1) > 0) { - $links['prev'] = rex_yform_rest::getLinkByPath($this, array_merge( + $links['prev'] = Rest::getLinkByPath($this, array_merge( $linkParams, ['page' => ($currentPage - 1)], )); } if (($currentPage * $per_page) < $itemsAll) { - $links['next'] = rex_yform_rest::getLinkByPath($this, array_merge( + $links['next'] = Rest::getLinkByPath($this, array_merge( $linkParams, ['page' => ($currentPage + 1)], )); @@ -317,11 +336,11 @@ public function handleRequest(array $paths, array $get) $status = '400'; if (self::getTypeFromInstance($instance) != $type) { - rex_yform_rest::sendError($status, 'post-data-type-different'); + Rest::sendError($status, 'post-data-type-different'); } if (0 == count($data)) { - rex_yform_rest::sendError($status, 'post-data-attributes-empty'); + Rest::sendError($status, 'post-data-attributes-empty'); } else { $dataset = null; if (isset($in['id'])) { @@ -369,12 +388,12 @@ public function handleRequest(array $paths, array $get) } if ($dataset->save()) { - rex_yform_rest::sendContent($status, ['id' => $dataset->getId()]); + Rest::sendContent($status, ['id' => $dataset->getId()]); } else { foreach ($dataset->getMessages() as $message_key => $message) { $errors[] = rex_i18n::translate($message); } - rex_yform_rest::sendError($status, 'errors-set', $errors); + Rest::sendError($status, 'errors-set', $errors); } } @@ -389,12 +408,12 @@ public function handleRequest(array $paths, array $get) $query = $this->getFilterQuery($query, $fields, $get); if ($queryClone === $query && isset($get['filter'])) { - rex_yform_rest::sendError($status, 'no-available-filter-set'); + Rest::sendError($status, 'no-available-filter-set'); } elseif ($queryClone->getQuery() !== $query->getQuery()) { // filter set -> true $status = '200'; } elseif (0 == count($paths)) { - rex_yform_rest::sendError($status, 'no-id-set'); + Rest::sendError($status, 'no-id-set'); } else { $id = current($paths); $query->where('id', $id); @@ -419,7 +438,7 @@ public function handleRequest(array $paths, array $get) $content['dataset'][] = $date; } - rex_yform_rest::sendContent($status, $content); + Rest::sendContent($status, $content); break; @@ -430,19 +449,19 @@ public function handleRequest(array $paths, array $get) $availableMethods[] = strtoupper($method); } } - rex_yform_rest::sendError('404', 'no-request-method-found', ['please only use: ' . implode(',', $availableMethods)]); + Rest::sendError('404', 'no-request-method-found', ['please only use: ' . implode(',', $availableMethods)]); } } /** * @throws rex_api_exception - * @return rex_yform_manager_field[] + * @return array<\Yakamara\YForm\Manager\Field> */ public function getFields(string $type = 'get', $instance = null): array { $class = $this->getTypeFromInstance($instance); - $returnFields = ['id' => new rex_yform_manager_field([ + $returnFields = ['id' => new Field([ 'name' => 'id', 'type_id' => 'value', 'type_name' => 'integer', @@ -452,8 +471,8 @@ public function getFields(string $type = 'get', $instance = null): array return $returnFields; } - /** @var rex_yform_manager_table $table */ - /** @var rex_yform_manager_dataset $class */ + /** @var Table $table */ + /** @var Dataset $class */ $table = $class::table(); if (!is_object($table)) { @@ -475,12 +494,12 @@ public function getFields(string $type = 'get', $instance = null): array return $returnFields; } - public function getFilterQuery(rex_yform_manager_query $query, array $fields, array $get): rex_yform_manager_query + public function getFilterQuery(Query $query, array $fields, array $get): Query { if (isset($get['filter']) && is_array($get['filter'])) { foreach ($get['filter'] as $filterKey => $filterValue) { foreach ($fields as $fieldName => $field) { - /* @var rex_yform_manager_field $field */ + /* @var Field $field */ if ($fieldName == $filterKey) { if (method_exists('rex_yform_value_' . $field->getTypeName(), 'getSearchFilter')) { try { @@ -490,7 +509,7 @@ public function getFilterQuery(rex_yform_manager_query $query, array $fields, ar 'query' => $query, ]); } catch (Error $e) { - rex_yform_rest::sendError('400', 'field-static-method-call-failed', ['class' => 'rex_yform_value_' . $field->getTypeName(), 'field' => $fieldName]); + Rest::sendError('400', 'field-static-method-call-failed', ['class' => 'rex_yform_value_' . $field->getTypeName(), 'field' => $fieldName]); exit; } } else { @@ -509,7 +528,7 @@ public function getFilterQuery(rex_yform_manager_query $query, array $fields, ar public function getInstanceData($instance, $paths, $onlyId = false, $parents = []): array { $links = []; - $links['self'] = rex_yform_rest::getLinkByPath($this, [], $paths); + $links['self'] = Rest::getLinkByPath($this, [], $paths); if ($onlyId) { return @@ -532,7 +551,7 @@ public function getInstanceData($instance, $paths, $onlyId = false, $parents = [ /** * @throws rex_api_exception */ - public function getInstanceAttributes(rex_yform_manager_dataset $instance, $parents = []): array + public function getInstanceAttributes(Dataset $instance, $parents = []): array { $data = []; @@ -551,7 +570,7 @@ public function getInstanceAttributes(rex_yform_manager_dataset $instance, $pare private function getIncludes(): array { if (null === $this->includes) { - $includes = @rex_request('include', 'string', ''); + $includes = @rex_request('include', 'string'); if ('' == $includes) { $this->includes = []; } else { @@ -587,7 +606,7 @@ private function filterFieldsByInclude(array $fields, array $parents = []): arra /** * @throws rex_api_exception */ - public function getInstanceRelationships(rex_yform_manager_dataset $instance, $parents = []): array + public function getInstanceRelationships(Dataset $instance, $parents = []): array { $paths[] = $instance->getId(); @@ -621,13 +640,13 @@ public function getInstanceRelationships(rex_yform_manager_dataset $instance, $p ]; $links = []; - $links['self'] = rex_yform_rest::getLinkByPath($this, [], array_merge($paths, [$field->getName()])); + $links['self'] = Rest::getLinkByPath($this, [], array_merge($paths, [$field->getName()])); if (isset($relationInstance)) { - $route = rex_yform_rest::getRouteByInstance($relationInstance); + $route = Rest::getRouteByInstance($relationInstance); if ($route) { - $links['absolute'] = rex_yform_rest::getLinkByPath($route, []); + $links['absolute'] = Rest::getLinkByPath($route, []); } } @@ -667,24 +686,24 @@ public function getTypeFromInstance($instance = null): string return $type; } - public function setQuery(rex_yform_manager_query $query): self + public function setQuery(Query $query): self { $this->query = $query; return $this; } - public function getQuery(): rex_yform_manager_query + public function getQuery(): Query { return $this->query; } - public function setTable(rex_yform_manager_table $table): self + public function setTable(Table $table): self { $this->table = $table; return $this; } - public function getTable(): rex_yform_manager_table + public function getTable(): Table { return $this->table; } diff --git a/lib/yform/action/abstract.php b/lib/yform/action/abstract.php deleted file mode 100644 index dfac1b286..000000000 --- a/lib/yform/action/abstract.php +++ /dev/null @@ -1,18 +0,0 @@ -www.yakamara.de - */ - -abstract class rex_yform_action_abstract extends rex_yform_base_abstract -{ - public $action = []; - - protected function getElementMappingOffset() - { - return 1; - } -} diff --git a/lib/yform/action/createdb.php b/lib/yform/action/createdb.php deleted file mode 100644 index 916bffe55..000000000 --- a/lib/yform/action/createdb.php +++ /dev/null @@ -1,50 +0,0 @@ -www.yakamara.de - */ - -class rex_yform_action_createdb extends rex_yform_action_abstract -{ - public function executeAction(): void - { - $table_name = $this->getElement(2); - $table_exists = false; - - $tables = rex_sql::factory()->getArray('show tables'); - foreach ($tables as $table) { - if (current($table) == $table_name) { - $table_exists = true; - break; - } - } - - if (!$table_exists) { - rex_sql::factory()->setQuery('CREATE TABLE `' . $table_name . '` (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;'); - } - - $cols = []; - foreach (rex_sql::factory()->getArray('show columns from ' . $table_name) as $k => $v) { - $cols[] = $v['Field']; - } - - foreach ($this->params['value_pool']['sql'] as $key => $value) { - if (!in_array($key, $cols)) { - rex_sql::factory()->setQuery('ALTER TABLE `' . $table_name . '` ADD `' . $key . '` TEXT NOT NULL;'); - } - } - } - - public function getDescription(): string - { - return 'action|createdb|tablename'; - } - - public function isDeprecated(): bool - { - return true; - } -} diff --git a/lib/yform/value/Choice/rex_yform_choice_group_view.php b/lib/yform/value/Choice/rex_yform_choice_group_view.php deleted file mode 100644 index 9aeafc9aa..000000000 --- a/lib/yform/value/Choice/rex_yform_choice_group_view.php +++ /dev/null @@ -1,29 +0,0 @@ -label = $label; - $this->choices = $choices; - } - - public function getChoices() - { - return $this->choices; - } - - public function getLabel() - { - return $this->label; - } -} diff --git a/pages/email.php b/pages/email.php index 1dac02ff8..3fc5b846a 100644 --- a/pages/email.php +++ b/pages/email.php @@ -1,11 +1,7 @@ www.yakamara.de - */ +use Yakamara\YForm\Email\Template; +use Yakamara\YForm\YForm; $_csrf_key = 'yform_email'; @@ -22,9 +18,9 @@ $template = null; if ($template_key) { - $template = rex_yform_email_template::getTemplate($template_key); + $template = Template::getTemplate($template_key); } elseif ($template_id) { - $template = rex_yform_email_template::getTemplateById($template_id); + $template = Template::getTemplateById($template_id); } $template_id = null; @@ -68,7 +64,7 @@ $form_data[] = 'datestamp|updatedate||||0'; - $yform = rex_yform::factory(); + $yform = YForm::factory(); $yform->setObjectparams('form_action', 'index.php?page=yform/email'); $yform->setObjectparams('form_name', 'yform-email-template'); diff --git a/pages/manager.data_edit.php b/pages/manager.data_edit.php index ba59eb66d..00096c99b 100644 --- a/pages/manager.data_edit.php +++ b/pages/manager.data_edit.php @@ -1,20 +1,14 @@ www.yakamara.de - */ - -// echo rex_view::title(rex_i18n::msg('yform')); +use Yakamara\YForm\Manager\Manager; +use Yakamara\YForm\Manager\Table\Table; $table_name = rex_request('table_name', 'string'); -$table = rex_yform_manager_table::get($table_name); +$table = Table::get($table_name); if ($table && $table->isGranted('VIEW', rex::getUser())) { try { - $page = new rex_yform_manager(); + $page = new Manager(); $page->setTable($table); $page->setLinkVars(['page' => rex_be_controller::getCurrentPage(), 'table_name' => $table->getTableName()]); echo $page->getDataPage(); diff --git a/pages/manager.data_export.php b/pages/manager.data_export.php index 3a8eae4bb..6e45b8503 100644 --- a/pages/manager.data_export.php +++ b/pages/manager.data_export.php @@ -1,9 +1,8 @@ table->getTableName()); + $dataset = Dataset::getRaw($datasetId, $this->table->getTableName()); } else { $filterDataset = false; } @@ -214,9 +218,9 @@ $list->setColumnLabel('action', rex_i18n::msg('yform_history_action')); $list->setColumnFormat('action', 'custom', static function (array $params) { static $classes = [ - rex_yform_manager_dataset::ACTION_CREATE => 'success', - rex_yform_manager_dataset::ACTION_UPDATE => 'primary', - rex_yform_manager_dataset::ACTION_DELETE => 'danger', + Dataset::ACTION_CREATE => 'success', + Dataset::ACTION_UPDATE => 'primary', + Dataset::ACTION_DELETE => 'danger', ]; $class = $classes[$params['subject']] ?? 'default'; return sprintf('%s', $class, rex_i18n::msg('yform_history_action_' . $params['subject'])); @@ -264,7 +268,7 @@ $options = '' . rex_i18n::msg('yform_history_delete') . ': ' . $fragment->parse('core/buttons/button_group.php'); } -$historySearchForm = new rex_yform(); +$historySearchForm = new YForm(); $historySearchForm->setObjectparams('form_action', $list->getUrl()); $historySearchForm->setObjectparams('form_showformafterupdate', true); $historySearchForm->setObjectparams('real_field_names', true); @@ -291,9 +295,9 @@ 'label' => 'Action', 'choices' => [ '' => rex_i18n::msg('yform_manager_actions_all'), - rex_yform_manager_dataset::ACTION_CREATE => rex_i18n::msg('yform_history_action_' . rex_yform_manager_dataset::ACTION_CREATE), - rex_yform_manager_dataset::ACTION_UPDATE => rex_i18n::msg('yform_history_action_' . rex_yform_manager_dataset::ACTION_UPDATE), - rex_yform_manager_dataset::ACTION_DELETE => rex_i18n::msg('yform_history_action_' . rex_yform_manager_dataset::ACTION_DELETE), + Dataset::ACTION_CREATE => rex_i18n::msg('yform_history_action_' . Dataset::ACTION_CREATE), + Dataset::ACTION_UPDATE => rex_i18n::msg('yform_history_action_' . Dataset::ACTION_UPDATE), + Dataset::ACTION_DELETE => rex_i18n::msg('yform_history_action_' . Dataset::ACTION_DELETE), ], ]); diff --git a/pages/manager.data_import.php b/pages/manager.data_import.php index bcc2ae593..cd9c6d7bd 100644 --- a/pages/manager.data_import.php +++ b/pages/manager.data_import.php @@ -1,13 +1,11 @@ www.yakamara.de - * - * @var rex_yform_manager $this - */ +use Yakamara\YForm\Manager\Field; +use Yakamara\YForm\Manager\Manager; +use Yakamara\YForm\Manager\Table\Api; +use Yakamara\YForm\Manager\Table\Table; + +/** @var Manager $this */ $_csrf_key ??= ''; @@ -79,7 +77,6 @@ try { $sql_db->transactional(function () use ($filename, $show_importform, $div, $fieldarray, $missing_columns, $debug, &$counter, &$dcounter, &$ecounter, &$rcounter, &$icounter, &$errorcounter, $fields) { - $fp = fopen($filename, 'r'); $firstbytes = fread($fp, 3); $bom = pack('CCC', 0xEF, 0xBB, 0xBF); @@ -131,7 +128,7 @@ foreach ($mc as $mcc) { rex_sql::factory() - ->setTable(rex_yform_manager_field::table()) + ->setTable(Field::table()) ->setValue('table_name', $this->table->getTablename()) ->setValue('prio', 999) ->setValue('type_id', 'value') @@ -145,10 +142,10 @@ echo rex_view::info(rex_i18n::msg('yform_manager_import_field_added', $mcc)); } - rex_yform_manager_table_api::generateTablesAndFields(); + Api::generateTablesAndFields(); $fields = []; - foreach (rex_yform_manager_table::get($this->table->getTableName())->getFields() as $field) { + foreach (Table::get($this->table->getTableName())->getFields() as $field) { $fields[strtolower($field->getName())] = $field; } } else { @@ -232,10 +229,8 @@ 'data_errors' => $errorcounter, ], )); - }); - - } catch (\Throwable $e) { + } catch (Throwable $e) { $error_message = $e->getMessage(); } @@ -252,7 +247,7 @@ echo rex_view::error(rex_i18n::msg('yform_manager_import_info_data_imported', $dcounter)); } - rex_yform_manager_table::deleteCache(); + Table::deleteCache(); } } diff --git a/pages/manager.table_edit.php b/pages/manager.table_edit.php index 66fb690dc..4ccb34bf7 100644 --- a/pages/manager.table_edit.php +++ b/pages/manager.table_edit.php @@ -1,11 +1,9 @@ www.yakamara.de - */ +use Yakamara\YForm\Manager\Field; +use Yakamara\YForm\Manager\Table\Api; +use Yakamara\YForm\Manager\Table\Table; +use Yakamara\YForm\YForm; echo rex_view::title(rex_i18n::msg('yform')); $_csrf_key = 'yform_table_edit'; @@ -19,7 +17,7 @@ $show_list = true; if ('tableset_import' == $func && rex::getUser()->isAdmin()) { - $yform = new rex_yform(); + $yform = new YForm(); $yform->setDebug(true); $yform->setHiddenField('page', $page); $yform->setHiddenField('func', $func); @@ -58,7 +56,7 @@ } else { try { $content = file_get_contents($yform->objparams['value_pool']['email']['importfile']); - rex_yform_manager_table_api::importTablesets($content); + Api::importTablesets($content); echo rex_view::info(rex_i18n::msg('yform_manager_table_import_success')); } catch (Exception $e) { echo rex_view::warning(rex_i18n::msg('yform_manager_table_import_failed', '', $e->getMessage())); @@ -67,13 +65,13 @@ } elseif (('add' == $func || 'edit' == $func) && rex::getUser()->isAdmin()) { $table = null; if ('edit' == $func) { - $table = rex_yform_manager_table::getById($table_id); + $table = Table::getById($table_id); if (!$table) { $func = 'add'; } } - $yform = new rex_yform(); + $yform = new YForm(); // $yform->setDebug(TRUE); $yform->setObjectparams('form_name', $_csrf_key); $yform->setHiddenField('page', $page); @@ -85,7 +83,7 @@ $yform->setHiddenField('start', rex_request('start', 'string')); $yform->setActionField('showtext', ['', rex_i18n::msg('yform_manager_table_entry_saved')]); - $yform->setObjectparams('main_table', rex_yform_manager_table::table()); + $yform->setObjectparams('main_table', Table::table()); $yform->setValueField('html', ['html' => '