From 1e7220118e26bd03d66c3d1bdd31ab95e2842557 Mon Sep 17 00:00:00 2001 From: Jan Kristinus Date: Sat, 23 Sep 2023 02:08:09 +0200 Subject: [PATCH 01/15] Workflowumbau + CS --- .github/workflows/code-style.yml | 42 +++++++ .github/workflows/phpunit.yml | 86 +++++++++++++ .github/workflows/publish-to-redaxo.yml | 24 ++++ .github/workflows/rexlint.yml | 20 --- .github/workflows/rexstan.yml | 86 +++++++++++++ .gitignore | 1 + .php-cs-fixer.dist.php | 11 ++ .php_cs.dist | 67 ---------- .tools/.phpunit.result.cache | 1 - .tools/README.md | 12 -- .tools/bootstrap.php | 14 ++- .tools/phpunit.xml.dist | 18 --- .tools/psalm.xml | 25 ---- .tools/rexstan.php | 40 ++++++ composer.json | 18 ++- install.php | 4 +- lib/radio.php | 2 +- lib/yform.php | 10 +- lib/yform/action/db.php | 6 +- lib/yform/action/php.php | 2 +- lib/yform/base_abstract.php | 4 +- lib/yform/validate/in_table.php | 2 +- lib/yform/validate/size_range.php | 2 +- lib/yform/validate/type.php | 22 ++-- .../value/Choice/rex_yform_choice_view.php | 2 +- lib/yform/value/abstract.php | 2 +- lib/yform/value/choice.php | 18 +-- lib/yform/value/date.php | 26 ++-- lib/yform/value/datestamp.php | 6 +- lib/yform/value/datetime.php | 10 +- lib/yform/value/generate_key.php | 2 +- lib/yform/value/google_geocode.php | 6 +- lib/yform/value/hidden.php | 4 +- lib/yform/value/html.php | 1 - lib/yform/value/index.php | 12 +- lib/yform/value/integer.php | 10 +- lib/yform/value/number.php | 4 +- lib/yform/value/signature.php | 6 +- lib/yform/value/text.php | 4 +- lib/yform/value/time.php | 16 +-- lib/yform/value/upload.php | 40 +++--- lib/yform/value/uuid.php | 11 +- pages/docs.php | 9 +- pages/setup.php | 4 +- phpunit.xml.dist | 23 ++++ plugins/email/boot.php | 2 +- plugins/email/lib/yform_action_tpl2email.php | 1 - plugins/email/lib/yform_email_template.php | 18 +-- plugins/email/pages/index.php | 13 +- plugins/email/update.php | 2 +- .../yform/manager/action_buttons.php | 2 +- .../fragments/yform/manager/page/layout.php | 6 +- plugins/manager/install.php | 14 +-- plugins/manager/lib/list.php | 21 ++-- plugins/manager/lib/yform/manager.php | 116 +++++++++--------- .../manager/lib/yform/manager/collection.php | 22 ++-- plugins/manager/lib/yform/manager/dataset.php | 18 +-- plugins/manager/lib/yform/manager/field.php | 10 +- plugins/manager/lib/yform/manager/query.php | 70 +++++------ plugins/manager/lib/yform/manager/search.php | 8 +- plugins/manager/lib/yform/manager/table.php | 6 +- .../manager/lib/yform/manager/table/api.php | 6 +- .../lib/yform/manager/table/authorization.php | 10 +- .../lib/yform/manager/table/perm/edit.php | 2 +- .../lib/yform/manager/table/perm/view.php | 2 +- plugins/manager/lib/yform/value/be_link.php | 20 +-- .../lib/yform/value/be_manager_relation.php | 18 +-- plugins/manager/lib/yform/value/be_media.php | 18 +-- plugins/manager/lib/yform/value/be_table.php | 6 +- plugins/manager/lib/yform/value/be_user.php | 6 +- plugins/manager/lib/yform/value/prio.php | 6 +- plugins/manager/pages/data_edit.php | 2 +- plugins/manager/pages/data_export.php | 12 +- plugins/manager/pages/data_history.php | 58 +++++---- plugins/manager/pages/data_import.php | 14 +-- plugins/manager/pages/table_edit.php | 24 ++-- plugins/manager/pages/table_field.php | 2 +- plugins/manager/pages/tableset_export.php | 6 +- plugins/manager/update.php | 2 +- .../bootstrap/value.be_link.tpl.php | 12 +- ...ue.be_manager_inline_relation-view.tpl.php | 16 +-- .../value.be_manager_inline_relation.tpl.php | 26 ++-- ...ue.be_manager_inline_relation_form.tpl.php | 8 +- .../bootstrap/value.be_media.tpl.php | 14 +-- .../bootstrap/value.be_table-view.tpl.php | 10 +- .../bootstrap/value.be_table.tpl.php | 26 ++-- plugins/rest/lib/rest.php | 8 +- plugins/rest/lib/rest/auth/auth.php | 18 +-- plugins/rest/lib/rest/route.php | 34 ++--- plugins/rest/pages/access.php | 12 +- plugins/rest/pages/token.php | 12 +- plugins/rest/update.php | 8 +- .../tests => tests}/rex_yform_yorm_test.php | 75 +++++++---- update.php | 6 +- ytemplates/bootstrap/errors.tpl.php | 6 +- ytemplates/bootstrap/form.tpl.php | 10 +- ytemplates/bootstrap/value.article.tpl.php | 4 +- ytemplates/bootstrap/value.checkbox.tpl.php | 8 +- .../bootstrap/value.checkbox_group.tpl.php | 10 +- .../bootstrap/value.choice.check.tpl.php | 10 +- .../bootstrap/value.choice.select.tpl.php | 10 +- ytemplates/bootstrap/value.datetime.tpl.php | 30 ++--- ytemplates/bootstrap/value.fieldset.tpl.php | 8 +- .../bootstrap/value.google_geocode.tpl.php | 56 ++++----- ytemplates/bootstrap/value.hidden.tpl.php | 2 +- ytemplates/bootstrap/value.radio.tpl.php | 10 +- ytemplates/bootstrap/value.select.tpl.php | 30 ++--- ytemplates/bootstrap/value.showvalue.tpl.php | 10 +- ytemplates/bootstrap/value.signature.tpl.php | 36 +++--- ytemplates/bootstrap/value.submit.tpl.php | 4 +- ytemplates/bootstrap/value.text.tpl.php | 12 +- ytemplates/bootstrap/value.textarea.tpl.php | 6 +- ytemplates/bootstrap/value.upload.tpl.php | 24 ++-- ytemplates/bootstrap/value.view.tpl.php | 26 ++-- 114 files changed, 1021 insertions(+), 854 deletions(-) create mode 100644 .github/workflows/code-style.yml create mode 100644 .github/workflows/phpunit.yml create mode 100644 .github/workflows/publish-to-redaxo.yml delete mode 100644 .github/workflows/rexlint.yml create mode 100644 .github/workflows/rexstan.yml create mode 100644 .php-cs-fixer.dist.php delete mode 100644 .php_cs.dist delete mode 100644 .tools/.phpunit.result.cache delete mode 100644 .tools/README.md delete mode 100644 .tools/phpunit.xml.dist delete mode 100644 .tools/psalm.xml create mode 100644 .tools/rexstan.php create mode 100644 phpunit.xml.dist rename {.tools/tests => tests}/rex_yform_yorm_test.php (81%) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml new file mode 100644 index 000000000..10fc9e391 --- /dev/null +++ b/.github/workflows/code-style.yml @@ -0,0 +1,42 @@ +name: PHP-CS-Fixer + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +permissions: + contents: read + +jobs: + code-style: + + runs-on: ubuntu-latest + permissions: + contents: write # for Git to git apply + + steps: + - uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: gd, intl, pdo_mysql + coverage: none # disable xdebug, pcov + + # install dependencies from composer.json + - name: Install test dependencies + env: + COMPOSER: composer.json + run: composer install --prefer-dist --no-progress + + # run php-cs-fixer + - name: Run PHP CS Fixer + run: composer cs-dry + + # commit and push fixed files +# - uses: stefanzweifel/git-auto-commit-action@v4 +# with: +# commit_message: Apply php-cs-fixer changes diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 000000000..9db9e437a --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,86 @@ +name: PHPUnit + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +permissions: + contents: read + +jobs: + phpunit: + + runs-on: ubuntu-latest + permissions: + contents: write # for Git to git apply + + steps: + - uses: actions/checkout@v3 + + # setup PHP v8, install some extensions + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: gd, intl, pdo_mysql + coverage: none # disable xdebug, pcov + + # download the latest REDAXO release and unzip it + # credits https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/ + - name: Download latest REDAXO release + run: | + LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest) + REDAXO_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') + echo "Downloaded REDAXO $REDAXO_VERSION" + curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip + unzip -oq redaxo.zip -d redaxo_cms + rm redaxo.zip + + # start mysql service, create a database called redaxo5, apply config patch + - name: Init database + run: | + sudo /etc/init.d/mysql start + mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;' + + # run REDAXO setup with the following parameters + # Language: de + # DB password: root + # Create DB: no + # Admin username: admin + # Admin password: adminpassword + # Error E-mail: test@redaxo.invalid + - name: Setup REDAXO + run: | + php redaxo_cms/redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-host=127.0.0.1 --db-name=redaxo5 --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword --error-email=test@redaxo.invalid --ansi + php redaxo_cms/redaxo/bin/console config:set --type boolean debug.enabled true + php redaxo_cms/redaxo/bin/console config:set --type boolean debug.throw_always_exception true + + # copy Addon files, ignore some directories... + # install the addon + # if the addon name does not match the repository name, ${{ github.event.repository.name }} must be replaced with the addon name + # if additional addons are needed, they can be installed via the console commands + # see: https://www.redaxo.org/doku/main/basis-addons#console + - name: Copy and install Addons + run: | + rsync -av --exclude='./vendor' --exclude='.github' --exclude='.git' --exclude='redaxo_cms' './' 'redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}' + redaxo_cms/redaxo/bin/console install:download 'yform' '4.*' + redaxo_cms/redaxo/bin/console package:install 'yform' + redaxo_cms/redaxo/bin/console package:install 'cronjob' + redaxo_cms/redaxo/bin/console package:install '${{ github.event.repository.name }}' + + # install dependencies from composer.json + - name: Install test dependencies + working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }} + env: + COMPOSER: composer.json + run: composer install --prefer-dist --no-progress + + - name: Setup Problem Matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + # run unit tests, see composer.json + - name: Run phpunit + working-directory: redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }} + run: composer test diff --git a/.github/workflows/publish-to-redaxo.yml b/.github/workflows/publish-to-redaxo.yml new file mode 100644 index 000000000..c1927fd12 --- /dev/null +++ b/.github/workflows/publish-to-redaxo.yml @@ -0,0 +1,24 @@ +name: Publish release + +on: + release: + types: + - published + +jobs: + redaxo_publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + - uses: ramsey/composer-install@v2 + with: + composer-options: "--no-dev" + - uses: FriendsOfREDAXO/installer-action@v1 + with: + myredaxo-username: ${{ secrets.MYREDAXO_USERNAME }} + myredaxo-api-key: ${{ secrets.MYREDAXO_API_KEY }} + description: ${{ github.event.release.body }} + diff --git a/.github/workflows/rexlint.yml b/.github/workflows/rexlint.yml deleted file mode 100644 index 7cd4d6f71..000000000 --- a/.github/workflows/rexlint.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: PHP Checks - -on: - push: - -jobs: - - rex-lint: - name: REX Linting - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - extensions: intl - coverage: none # disable xdebug, pcov - - run: | - composer require --dev friendsofredaxo/linter && vendor/bin/rexlint diff --git a/.github/workflows/rexstan.yml b/.github/workflows/rexstan.yml new file mode 100644 index 000000000..19c86fd31 --- /dev/null +++ b/.github/workflows/rexstan.yml @@ -0,0 +1,86 @@ +name: rexstan + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +permissions: + contents: read + +jobs: + rexstan: + env: + ADDON_KEY: ${{ github.event.repository.name }} + + runs-on: ubuntu-latest + permissions: + contents: write # for Git to git apply + + steps: + - uses: actions/checkout@v3 + + # setup PHP v8, install some extensions + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: gd, intl, pdo_mysql + coverage: none # disable xdebug, pcov + + # download the latest REDAXO release and unzip it + # credits https://blog.markvincze.com/download-artifacts-from-a-latest-github-release-in-sh-and-powershell/ + - name: Download latest REDAXO release + run: | + LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/redaxo/redaxo/releases/latest) + REDAXO_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') + echo "Downloaded REDAXO $REDAXO_VERSION" + curl -Ls -o redaxo.zip https://github.com/redaxo/redaxo/releases/download/$REDAXO_VERSION/redaxo_$REDAXO_VERSION.zip + unzip -oq redaxo.zip -d redaxo_cms + rm redaxo.zip + + # start mysql service, create a database called redaxo5, apply config patch + - name: Init database + run: | + sudo /etc/init.d/mysql start + mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;' + + # run REDAXO setup with the following parameters + # Language: de + # DB password: root + # Create DB: no + # Admin username: admin + # Admin password: adminpassword + # Error E-mail: test@redaxo.invalid + - name: Setup REDAXO + run: | + php redaxo_cms/redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-host=127.0.0.1 --db-name=redaxo5 --db-password=root --db-createdb=no --db-setup=normal --admin-username=admin --admin-password=adminpassword --error-email=test@redaxo.invalid --ansi + php redaxo_cms/redaxo/bin/console config:set --type boolean debug.enabled true + php redaxo_cms/redaxo/bin/console config:set --type boolean debug.throw_always_exception true + + # copy Addon files, ignore some directories... + # install the addon + # if the addon name does not match the repository name, ${{ github.event.repository.name }} must be replaced with the addon name + # install latest rexstan + # if additional addons are needed, they can be installed via the console commands + # see: https://www.redaxo.org/doku/main/basis-addons#console + - name: Copy and install Addons + run: | + rsync -av --exclude='./vendor' --exclude='.github' --exclude='.git' --exclude='redaxo_cms' './' 'redaxo_cms/redaxo/src/addons/${{ github.event.repository.name }}' + redaxo_cms/redaxo/bin/console install:download 'rexstan' '1.*' + redaxo_cms/redaxo/bin/console package:install 'rexstan' + redaxo_cms/redaxo/bin/console install:download 'yform' '4.*' + redaxo_cms/redaxo/bin/console package:install 'yform' + redaxo_cms/redaxo/bin/console package:install 'cronjob' + redaxo_cms/redaxo/bin/console package:install '${{ github.event.repository.name }}' + + # execute rexstan.php to create the needed user-config.neon + - name: Execute .tools/rexstan.php + run: php -f redaxo/src/addons/${{ github.event.repository.name }}/.tools/rexstan.php + working-directory: redaxo_cms + + # run rexstan + - id: rexstan + name: Run rexstan + run: redaxo_cms/redaxo/bin/console rexstan:analyze diff --git a/.gitignore b/.gitignore index 0c46e8121..5eccfcd60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /composer.lock vendor/ +.phpunit.result.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 000000000..72be59328 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,11 @@ +in(__DIR__) +; + +return (new Redaxo\PhpCsFixerConfig\Config()) + ->setFinder($finder) + ; diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 428775b5c..000000000 --- a/.php_cs.dist +++ /dev/null @@ -1,67 +0,0 @@ -exclude('fragments') - ->in([ - $src.'/lib', - $src.'/module', - $src.'/plugins', - $src.'/pages', - $src.'/ytemplates', - ]) - ->append([ - __FILE__ - ]) -; - -return PhpCsFixer\Config::create() - ->setUsingCache(true) - ->setRiskyAllowed(true) - ->setRules([ - '@Symfony' => true, - '@Symfony:risky' => true, - '@PHP71Migration' => true, - '@PHP71Migration:risky' => true, - '@PHPUnit60Migration:risky' => true, - 'array_indentation' => true, - 'array_syntax' => ['syntax' => 'short'], - 'blank_line_before_statement' => false, - 'braces' => ['allow_single_line_closure' => false], - 'comment_to_phpdoc' => true, - 'concat_space' => false, - 'declare_strict_types' => false, - 'function_to_constant' => ['functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi']], - 'heredoc_to_nowdoc' => true, - 'list_syntax' => ['syntax' => 'short'], - 'logical_operators' => true, - 'native_constant_invocation' => false, - 'no_blank_lines_after_phpdoc' => false, - 'no_null_property_initialization' => true, - 'no_php4_constructor' => true, - 'no_superfluous_elseif' => true, - 'no_unreachable_default_argument_value' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'ordered_imports' => true, - 'php_unit_internal_class' => true, - 'php_unit_method_casing' => true, - 'php_unit_set_up_tear_down_visibility' => true, - 'php_unit_test_case_static_method_calls' => ['call_type' => 'this'], - 'phpdoc_annotation_without_dot' => false, - 'phpdoc_no_package' => false, - 'phpdoc_order' => true, - 'phpdoc_trim_consecutive_blank_line_separation' => true, - 'phpdoc_types_order' => false, - 'phpdoc_var_annotation_correct_order' => true, - 'psr4' => false, - 'semicolon_after_instruction' => false, - 'space_after_semicolon' => true, - 'static_lambda' => true, - 'string_line_ending' => true, - 'void_return' => false, - 'yoda_style' => true, - ]) - ->setFinder($finder) -; diff --git a/.tools/.phpunit.result.cache b/.tools/.phpunit.result.cache deleted file mode 100644 index a97301be5..000000000 --- a/.tools/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -{"version":1,"defects":{"rex_yform_yorm_test::testHasValue":5,"rex_yform_yorm_test::testGetValue":5,"Warning":6,"rex_yform_yorm_test::testAddTable":5,"rex_yform_yorm_test::testTableAPI":4},"times":{"rex_yform_yorm_test::testHasValue":0.002,"rex_yform_yorm_test::testGetValue":0,"Warning":0.003,"rex_yform_yorm_test::testAddTable":8.831,"rex_yform_yorm_test::testTableAPI":71.278}} \ No newline at end of file diff --git a/.tools/README.md b/.tools/README.md deleted file mode 100644 index c288a8e98..000000000 --- a/.tools/README.md +++ /dev/null @@ -1,12 +0,0 @@ - -## phpunit - -Aufruf von PHPUnit nur im REDAXO Kontext mit - -`phpunit -c redaxo/src/addons/yform/.tools/phpunit.xml.dist` - -## psalm - -Aufruf psalm im REDAXO Kontext mit - -`psalm -c redaxo/src/addons/yform/.tools/psalm.xml --no-cache` diff --git a/.tools/bootstrap.php b/.tools/bootstrap.php index 948ac66f4..56c33b7ef 100644 --- a/.tools/bootstrap.php +++ b/.tools/bootstrap.php @@ -1,5 +1,13 @@ - - - - tests - - - diff --git a/.tools/psalm.xml b/.tools/psalm.xml deleted file mode 100644 index b0ff516a9..000000000 --- a/.tools/psalm.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/.tools/rexstan.php b/.tools/rexstan.php new file mode 100644 index 000000000..ff341872d --- /dev/null +++ b/.tools/rexstan.php @@ -0,0 +1,40 @@ + delete -$pluginDocs = __DIR__.'/plugins/docs'; +$pluginDocs = __DIR__ . '/plugins/docs'; if (file_exists($pluginDocs)) { rex_dir::delete($pluginDocs); } foreach ($this->getInstalledPlugins() as $plugin) { // use path relative to __DIR__ to get correct path in update temp dir - $file = __DIR__.'/plugins/'.$plugin->getName().'/install.php'; + $file = __DIR__ . '/plugins/' . $plugin->getName() . '/install.php'; if (file_exists($file)) { $plugin->includeFile($file); diff --git a/lib/radio.php b/lib/radio.php index 12678ab0f..6c7152266 100644 --- a/lib/radio.php +++ b/lib/radio.php @@ -83,7 +83,7 @@ public function setId($id) */ public function setStyle($style) { - if (false !== strpos($style, 'class=')) { + if (str_contains($style, 'class=')) { if (preg_match('/class=["\']?([^"\']*)["\']?/i', $style, $matches)) { $this->setAttribute('class', $matches[1]); } diff --git a/lib/yform.php b/lib/yform.php index bbf7f107e..6c86bc5ea 100644 --- a/lib/yform.php +++ b/lib/yform.php @@ -169,7 +169,7 @@ public function setData($data): self $this->setObjectparams('data', $data); $data['id'] = isset($data['id']) ? (int) $data['id'] : 0; if (0 < $data['id']) { - $this->setObjectparams('main_where', 'id='.$data['id']); + $this->setObjectparams('main_where', 'id=' . $data['id']); } return $this; } @@ -572,7 +572,7 @@ public function getFieldName(string $label, array $params = []) // $id = '', $k if ('' != $label && count($params) > 1) { // 1. FormID // 2. SpecialKey - $label .= '['.$this->prepareLabel($params[1]).']'; + $label .= '[' . $this->prepareLabel($params[1]) . ']'; } return ($label) ?: current($params); } @@ -581,14 +581,14 @@ public function getFieldName(string $label, array $params = []) // $id = '', $k $params = [$label]; } - $fieldName = 'FORM['.$this->objparams['form_name'].']'; + $fieldName = 'FORM[' . $this->objparams['form_name'] . ']'; $params = array_merge($this->objparams['form_array'], $params); foreach ($params as $param) { $param = $this->prepareLabel($param); if ('' != $param) { - $fieldName .= '['.$this->prepareLabel($param).']'; + $fieldName .= '[' . $this->prepareLabel($param) . ']'; } } @@ -746,7 +746,7 @@ public static function showHelp(): string if (isset($definitions['formbuilder']) && !$definitions['formbuilder']) { } elseif ($class->isDeprecated()) { - $deprecatedInfo = isset($definitions['deprecated']) ? $definitions['deprecated'].'
' : ''; + $deprecatedInfo = isset($definitions['deprecated']) ? $definitions['deprecated'] . '
' : ''; $classesDeprecatedDescription[$arr_key] .= '' . $name . '' . $deprecatedInfo . $desc . ''; } elseif (isset($definitions['famous']) && $definitions['famous']) { $classesFamousDescription[$arr_key] .= '' . $name . '' . $desc . ''; diff --git a/lib/yform/action/db.php b/lib/yform/action/db.php index c246ef0dd..260689593 100644 --- a/lib/yform/action/db.php +++ b/lib/yform/action/db.php @@ -46,7 +46,7 @@ public function executeAction(): void foreach ($this->params['value_pool']['sql'] as $key => $value) { $sql->setValue($key, $value); if ('' != $where) { - $where = str_replace('###'.$key.'###', addslashes((string) $value), $where); + $where = str_replace('###' . $key . '###', addslashes((string) $value), $where); } } @@ -101,7 +101,7 @@ public function executeAction(): void 'action' => $action, 'id' => $this->params['main_id'], 'yform' => true, - ] + ], )); /** @@ -117,7 +117,7 @@ public function executeAction(): void 'action' => $action, 'id' => $this->params['main_id'], 'yform' => true, - ] + ], )); } } diff --git a/lib/yform/action/php.php b/lib/yform/action/php.php index 61a4b28e2..8679242b3 100644 --- a/lib/yform/action/php.php +++ b/lib/yform/action/php.php @@ -10,7 +10,7 @@ public function executeAction(): void return; } - eval('?>'.$php.'' . $php . 'params = &$params; $offset = 0; foreach ($elements as $key => $value) { - if (is_string($value) && !empty($value) && '#' == $value[0] && false !== strpos($value, ':')) { + if (is_string($value) && !empty($value) && '#' == $value[0] && str_contains($value, ':')) { [$key, $value] = explode(':', mb_substr($value, 1), 2); ++$offset; } @@ -79,7 +79,7 @@ public function getElement($i) public function getParam($param, $default = null) { - return isset($this->params[$param]) ? $this->params[$param] : $default; + return $this->params[$param] ?? $default; } public function setObjects(&$obj) diff --git a/lib/yform/validate/in_table.php b/lib/yform/validate/in_table.php index b5e2403ba..e81841f8e 100644 --- a/lib/yform/validate/in_table.php +++ b/lib/yform/validate/in_table.php @@ -46,7 +46,7 @@ public function enterObject() $sql = 'select * from ' . $table . ' WHERE (' . implode(' AND ', $qfields) . ')'; $extras = trim($this->getElement(6)); if ('' != $extras) { - $sql .= ' and ('.$extras.')'; + $sql .= ' and (' . $extras . ')'; } $sql .= ' LIMIT 2'; diff --git a/lib/yform/validate/size_range.php b/lib/yform/validate/size_range.php index 696ac331c..1c93a5245 100644 --- a/lib/yform/validate/size_range.php +++ b/lib/yform/validate/size_range.php @@ -33,7 +33,7 @@ public function enterObject() $maxsize = (int) $this->getElement('max'); } - $size = mb_strlen(strval($Object->getValue())); + $size = mb_strlen((string) $Object->getValue()); if ($minsize > -1 && $minsize > $size) { $w = true; diff --git a/lib/yform/validate/type.php b/lib/yform/validate/type.php index 0ef7b5ff5..371aec750 100644 --- a/lib/yform/validate/type.php +++ b/lib/yform/validate/type.php @@ -32,7 +32,7 @@ public function enterObject() } break; case 'float': - $xsRegEx_float = "/^([0-9]+|([0-9]+\.[0-9]+))$/i"; + $xsRegEx_float = '/^([0-9]+|([0-9]+\\.[0-9]+))$/i'; if (0 == preg_match($xsRegEx_float, $Object->getValue())) { $w = true; } @@ -45,32 +45,32 @@ public function enterObject() case 'string': break; case 'email': - if (!preg_match("/^[a-zä-üA-ZÄ-Ü0-9ß.!#$%&'*+\/=?^_`{|}~-]+@[a-zä-üA-ZÄ-Ü0-9ß](?:[a-zä-üA-ZÄ-Ü0-9ß-]{0,61}[a-zä-üA-ZÄ-Ü0-9ß])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/", $Object->getValue())) { + if (!preg_match("/^[a-zä-üA-ZÄ-Ü0-9ß.!#$%&'*+\\/=?^_`{|}~-]+@[a-zä-üA-ZÄ-Ü0-9ß](?:[a-zä-üA-ZÄ-Ü0-9ß-]{0,61}[a-zä-üA-ZÄ-Ü0-9ß])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/", $Object->getValue())) { $w = true; } break; case 'url': - $xsRegEx_url = '/^(?:http[s]?:\/\/)[a-zä-üA-ZÄ-Ü0-9ß][a-zä-üA-ZÄ-Ü0-9ß._-]*\.(?:[a-zä-üA-ZÄ-Ü0-9ß][a-zä-üA-ZÄ-Ü0-9ß._-]*\.)*[a-zA-Z]{2,20}(?:\/[^\\/\:\*\?\"<>\|]*)*(?:\/[a-zA-Z0-9_%,\.\=\?\-#&]*)*$' . '/'; + $xsRegEx_url = '/^(?:http[s]?:\/\/)[a-zä-üA-ZÄ-Ü0-9ß][a-zä-üA-ZÄ-Ü0-9ß._-]*\.(?:[a-zä-üA-ZÄ-Ü0-9ß][a-zä-üA-ZÄ-Ü0-9ß._-]*\.)*[a-zA-Z]{2,20}(?:\/[^\\/\:\*\?\"<>\|]*)*(?:\/[a-zA-Z0-9_%,\.\=\?\-#&]*)*$/'; if (0 == preg_match($xsRegEx_url, $Object->getValue())) { $w = true; } break; case 'time': - $timeObject = DateTime::createFromFormat('Y-m-d H:i:s', '2010-10-10 ' . $Object->getValue()); + $timeObject = DateTime::createFromFormat('Y-m-d H:i:s', '2010-10-10 ' . $Object->getValue()); $w = !($timeObject && $timeObject->format('H:i:s') == $Object->getValue()); break; case 'date': $w = true; - if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $Object->getValue(), $matches)) { - if (checkdate((int) $matches[2],(int) $matches[3],(int) $matches[1])) { + if (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $Object->getValue(), $matches)) { + if (checkdate((int) $matches[2], (int) $matches[3], (int) $matches[1])) { $w = false; } } break; case 'datetime': $w = true; - if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $Object->getValue(), $matches)) { - if (checkdate((int) $matches[2],(int) $matches[3],(int) $matches[1])) { + if (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/', $Object->getValue(), $matches)) { + if (checkdate((int) $matches[2], (int) $matches[3], (int) $matches[1])) { $w = false; } } @@ -99,7 +99,7 @@ public function enterObject() if (!isset($countries[mb_substr($iban, 0, 2)]) || mb_strlen($iban) != $countries[mb_substr($iban, 0, 2)]) { $w = true; } else { - $movedChar = mb_substr($iban, 4).mb_substr($iban, 0, 4); + $movedChar = mb_substr($iban, 4) . mb_substr($iban, 0, 4); $movedCharArray = mb_str_split($movedChar); $newString = ''; @@ -119,7 +119,7 @@ public function enterObject() $mod = ''; do { - $a = (int) $mod.mb_substr($x, 0, $take); + $a = (int) $mod . mb_substr($x, 0, $take); $x = mb_substr($x, $take); $mod = $a % $y; } while (mb_strlen($x)); @@ -151,7 +151,7 @@ public function enterObject() public function getDescription(): string { - return 'validate|type|name|int/float/numeric/string/email/url/date/datetime/hex/iban/json|warning_message|[1='.rex_i18n::msg('yform_validate_type_not_required').']'; + return 'validate|type|name|int/float/numeric/string/email/url/date/datetime/hex/iban/json|warning_message|[1=' . rex_i18n::msg('yform_validate_type_not_required') . ']'; } public function getDefinitions(): array diff --git a/lib/yform/value/Choice/rex_yform_choice_view.php b/lib/yform/value/Choice/rex_yform_choice_view.php index 79396adba..9458f84d1 100644 --- a/lib/yform/value/Choice/rex_yform_choice_view.php +++ b/lib/yform/value/Choice/rex_yform_choice_view.php @@ -48,7 +48,7 @@ public function __construct($value, $label, $attributes = null, array $requiredA $this->attributes = array_merge($this->attributes, $requiredAttributes); if (isset($this->attributes['id'])) { - $this->attributes['id'] .= '-'.rex_string::normalize($this->value, '-'); + $this->attributes['id'] .= '-' . rex_string::normalize($this->value, '-'); } } diff --git a/lib/yform/value/abstract.php b/lib/yform/value/abstract.php index 5cbb87adc..741d29cbb 100644 --- a/lib/yform/value/abstract.php +++ b/lib/yform/value/abstract.php @@ -142,7 +142,7 @@ public function getAttributeElements(array $attributes, array $direct_attributes $attributes = self::getAttributeArray($attributes, $direct_attributes); $return = []; foreach ($attributes as $attribute => $value) { - $return[] = $attribute.'="'.rex_escape($value).'"'; + $return[] = $attribute . '="' . rex_escape($value) . '"'; } return $return; diff --git a/lib/yform/value/choice.php b/lib/yform/value/choice.php index b3ce7b05c..3374d1156 100644 --- a/lib/yform/value/choice.php +++ b/lib/yform/value/choice.php @@ -38,7 +38,7 @@ public function enterObject() $defaultChoices = explode(',', $this->getElement('default')); } if (!$choiceList->isMultiple() && count($defaultChoices) >= 2) { - throw new InvalidArgumentException('Expecting one default value for '.$this->getFieldName().', but '.count($defaultChoices).' given!'); + throw new InvalidArgumentException('Expecting one default value for ' . $this->getFieldName() . ', but ' . count($defaultChoices) . ' given!'); } $this->setValue($choiceList->getDefaultValues($defaultChoices)); } @@ -87,7 +87,7 @@ public function enterObject() $template = str_replace('choice', 'choice-view', $template); $getChoices = static function ($choices, $options) use (&$getChoices) { foreach ($choices as $choice) { - if ('rex_yform_choice_group_view' == get_class($choice)) { + if ('rex_yform_choice_group_view' == $choice::class) { /** @var rex_yform_choice_group_view $choice */ $options = $getChoices($choice->choices, $options); } else { @@ -110,8 +110,8 @@ public function enterObject() $this->setValue(implode(',', $proofedValues)); $this->params['value_pool']['email'][$this->getName()] = $this->getValue(); - $this->params['value_pool']['email'][$this->getName().'_LABELS'] = implode(', ', $choiceList->getSelectedListForEmail($values)); - $this->params['value_pool']['email'][$this->getName().'_LIST'] = implode("\n", $choiceList->getCompleteListForEmail($values)); + $this->params['value_pool']['email'][$this->getName() . '_LABELS'] = implode(', ', $choiceList->getSelectedListForEmail($values)); + $this->params['value_pool']['email'][$this->getName() . '_LIST'] = implode("\n", $choiceList->getCompleteListForEmail($values)); if ($this->saveInDb()) { $this->params['value_pool']['sql'][$this->getName()] = $this->getValue(); @@ -131,9 +131,9 @@ public function getDefinitions(): array 'values' => [ 'name' => ['type' => 'name', 'label' => rex_i18n::msg('yform_values_defaults_name')], 'label' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_defaults_label')], - 'choices' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_choice_choices'), 'notice' => rex_i18n::msg('yform_values_choice_choices_notice').rex_i18n::rawMsg('yform_values_choice_choices_table')], + 'choices' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_choice_choices'), 'notice' => rex_i18n::msg('yform_values_choice_choices_notice') . rex_i18n::rawMsg('yform_values_choice_choices_table')], 'expanded' => ['type' => 'boolean', 'label' => rex_i18n::msg('yform_values_choice_expanded'), 'notice' => rex_i18n::msg('yform_values_choice_expanded_notice')], - 'multiple' => ['type' => 'boolean', 'label' => rex_i18n::msg('yform_values_choice_multiple'), 'notice' => rex_i18n::msg('yform_values_choice_multiple_notice').rex_i18n::rawMsg('yform_values_choice_expanded_multiple_table')], + 'multiple' => ['type' => 'boolean', 'label' => rex_i18n::msg('yform_values_choice_multiple'), 'notice' => rex_i18n::msg('yform_values_choice_multiple_notice') . rex_i18n::rawMsg('yform_values_choice_expanded_multiple_table')], 'default' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_choice_default'), 'notice' => rex_i18n::msg('yform_values_choice_default_notice')], 'group_by' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_choice_group_by'), 'notice' => rex_i18n::msg('yform_values_choice_group_by_notice')], 'preferred_choices' => ['type' => 'text', 'label' => rex_i18n::msg('yform_values_choice_preferred_choices'), 'notice' => rex_i18n::msg('yform_values_choice_preferred_choices_notice')], @@ -245,7 +245,7 @@ public static function getSearchField($params) 'choices' => $choices, 'multiple' => 1, 'notice' => rex_i18n::msg('yform_search_defaults_select_notice'), - ] + ], ); } @@ -326,7 +326,7 @@ private static function createChoiceList($elements) $sql = rex_sql::factory(); $sql->setDebug($self->getParam('debug')); $choiceList->createListFromSqlArray( - $sql->getArray($choicesElement) + $sql->getArray($choicesElement), ); } elseif (is_string($choicesElement) && mb_strlen(trim($choicesElement)) > 0 && '{' == mb_substr(trim($choicesElement), 0, 1) && '{{' != mb_substr(trim($choicesElement), 0, 2)) { $choiceList->createListFromJson($choicesElement); @@ -339,7 +339,7 @@ private static function createChoiceList($elements) } } else { $choiceList->createListFromStringArray( - $self->getArrayFromString($choicesElement) + $self->getArrayFromString($choicesElement), ); } return $choiceList; diff --git a/lib/yform/value/date.php b/lib/yform/value/date.php index 3298b81f2..dbb3fa729 100644 --- a/lib/yform/value/date.php +++ b/lib/yform/value/date.php @@ -101,17 +101,17 @@ public function enterObject() if (!$this->isEditable()) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.date-view.tpl.php', 'value.datetime-view.tpl.php', 'value.view.tpl.php'], - ['type' => 'text', 'value' => self::date_getFormattedDate($this->getElement('format'), $this->getValue())] + ['type' => 'text', 'value' => self::date_getFormattedDate($this->getElement('format'), $this->getValue())], ); } elseif ('input:text' == $this->getElement('widget')) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.text.tpl.php'], - ['type' => 'text', 'value' => $this->getValue()] + ['type' => 'text', 'value' => $this->getValue()], ); } elseif ('input:date' == $this->getElement('widget')) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.text.tpl.php'], - ['type' => 'date', 'value' => $this->getValue()] + ['type' => 'date', 'value' => $this->getValue()], ); } else { $format = 'YYYY-MM-DD'; // Format of Select Order @@ -120,7 +120,7 @@ public function enterObject() $day = (int) mb_substr($this->getValue(), 8, 2); $this->params['form_output'][$this->getId()] = $this->parse( ['value.date.tpl.php', 'value.datetime.tpl.php'], - compact('format', 'yearStart', 'yearEnd', 'year', 'month', 'day') + compact('format', 'yearStart', 'yearEnd', 'year', 'month', 'day'), ); } } @@ -129,7 +129,7 @@ public static function date_getFormattedDate($format, $date) { $format = (in_array($format, self::VALUE_DATE_FORMATS, true)) ? $format : self::VALUE_DATE_DEFAULT_FORMAT; $DTdate = DateTime::createFromFormat('Y-m-d', $date); - return (!$DTdate || $date != $DTdate->format('Y-m-d')) ? '['.$date.']' : $DTdate->format($format); + return (!$DTdate || $date != $DTdate->format('Y-m-d')) ? '[' . $date . ']' : $DTdate->format($format); } public function getDescription(): string @@ -163,7 +163,7 @@ public function getDefinitions(): array public static function getListValue($params) { - return ''.self::date_getFormattedDate($params['params']['field']['format'], $params['subject']).''; + return '' . self::date_getFormattedDate($params['params']['field']['format'], $params['subject']) . ''; } public static function getSearchField($params) @@ -206,7 +206,7 @@ public static function getSearchFilter($params) if (null != $month) { // Abfrage auf ein konkretes Datum YYYY-MM-DD, etc. if (null != $day) { - return $query->whereRaw('('.self::date_createDbDateComparison($field, $comparator, $year, $month, $day).')'); + return $query->whereRaw('(' . self::date_createDbDateComparison($field, $comparator, $year, $month, $day) . ')'); } // Abfrage auf YYYY-MM (=) @@ -223,21 +223,21 @@ public static function getSearchFilter($params) // >=2020-02 --> > 2020-02-00 // >2020-02 --> > 2020-02-99 $day = ('<' == $comparator || '>=' == $comparator) ? '00' : '99'; - return $query->whereRaw('('.self::date_createDbDateComparison($field, $comparator, $year, $month).')'); + return $query->whereRaw('(' . self::date_createDbDateComparison($field, $comparator, $year, $month) . ')'); } // Abfrage auf YYYY - return $query->whereRaw('( YEAR('.$field.') '.$comparator.' '.$year.' )'); + return $query->whereRaw('( YEAR(' . $field . ') ' . $comparator . ' ' . $year . ' )'); } if (null != $month) { - return $query->whereRaw('( MONTH('.$field.') '.$comparator.' '.$month.' )'); + return $query->whereRaw('( MONTH(' . $field . ') ' . $comparator . ' ' . $month . ' )'); } } // Range-Auswertung über Pattern: $value1 - $value2 $pattern2 = str_replace(['', '', ''], ['', '', ''], self::VALUE_SEARCH_PATTERN[$format]); - $pattern = '/^'.self::VALUE_SEARCH_PATTERN[$format].'\s* - \s*' . $pattern2 . '$/'; + $pattern = '/^' . self::VALUE_SEARCH_PATTERN[$format] . '\s* - \s*' . $pattern2 . '$/'; $ok = preg_match($pattern, $value, $match); if ($ok) { $year_from = $match['y'] ?: ''; @@ -255,12 +255,12 @@ public static function getSearchFilter($params) $day_to = $match['d2'] ?? '99'; if (4 == mb_strlen($value)) { - return $query->whereRaw('( YEAR('.$field.') >= '.$year_from.' AND YEAR('.$field.') <= '.$year_to.' )'); + return $query->whereRaw('( YEAR(' . $field . ') >= ' . $year_from . ' AND YEAR(' . $field . ') <= ' . $year_to . ' )'); } $from = self::date_createDbDateComparison($field, '>=', $year_from, $month_from, $day_from); $to = self::date_createDbDateComparison($field, '<=', $year_to, $month_to, $day_to); - return $query->whereRaw('( '.$from.' AND '.$to.' )'); + return $query->whereRaw('( ' . $from . ' AND ' . $to . ' )'); } // ungültige bzw. nicht verwertbare Eingabe ( kein valides SQL möglich ) diff --git a/lib/yform/value/datestamp.php b/lib/yform/value/datestamp.php index 6f1be9c1f..4358b8893 100644 --- a/lib/yform/value/datestamp.php +++ b/lib/yform/value/datestamp.php @@ -67,7 +67,7 @@ public function enterObject() 'type' => 'text', 'value' => ('' != $this->value_datestamp_currentValue) ? rex_yform_value_datetime::datetime_getFormattedDatetime($this->getElement('format'), $this->value_datestamp_currentValue) : '', 'notice' => $notice, - ] + ], ); } elseif ('' != $this->value_datestamp_currentValue) { $this->params['form_output'][$this->getId()] .= $this->parse( @@ -75,7 +75,7 @@ public function enterObject() [ 'type' => 'text', 'value' => rex_yform_value_datetime::datetime_getFormattedDatetime($this->getElement('format'), $this->value_datestamp_currentValue), - ] + ], ); } } @@ -85,7 +85,7 @@ public function enterObject() public function getDescription(): string { - return 'datestamp|name|label|[YmdHis/U/dmy/mysql]|[no_db]|[0-always,1-only if empty,2-never]'; + return 'datestamp|name|label|[Y-m-d H:i:s/U/dmy]|[no_db]|[0-always,1-only if empty,2-never]'; } public function getDefinitions(): array diff --git a/lib/yform/value/datetime.php b/lib/yform/value/datetime.php index aadd75bcf..2e8686518 100644 --- a/lib/yform/value/datetime.php +++ b/lib/yform/value/datetime.php @@ -113,12 +113,12 @@ public function enterObject() if (!$this->isEditable()) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.datetime-view.tpl.php', 'value.date-view.tpl.php', 'value.view.tpl.php'], - ['type' => 'text', 'value' => self::datetime_getFormattedDatetime($this->getElement('format'), $this->getValue())] + ['type' => 'text', 'value' => self::datetime_getFormattedDatetime($this->getElement('format'), $this->getValue())], ); } elseif ('input:text' == $this->getElement('widget')) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.text.tpl.php'], - ['type' => 'text', 'value' => $this->getValue()] + ['type' => 'text', 'value' => $this->getValue()], ); } else { $format = 'YYYY-MM-DD HH:ii:ss'; // Format of Select Order @@ -130,7 +130,7 @@ public function enterObject() $second = (int) mb_substr($this->getValue(), 17, 2); $this->params['form_output'][$this->getId()] = $this->parse( ['value.date.tpl.php', 'value.datetime.tpl.php'], - compact('format', 'yearStart', 'yearEnd', 'year', 'month', 'day', 'hour', 'minute', 'second') + compact('format', 'yearStart', 'yearEnd', 'year', 'month', 'day', 'hour', 'minute', 'second'), ); } } @@ -139,7 +139,7 @@ public static function datetime_getFormattedDatetime($format, $date) { $format = (in_array($format, self::VALUE_DATETIME_FORMATS, true)) ? $format : self::VALUE_DATETIME_DEFAULT_FORMAT; $DTdate = DateTime::createFromFormat('Y-m-d H:i:s', $date); - return (!$date || !$DTdate || $date != $DTdate->format('Y-m-d H:i:s')) ? '['.$date.']' : $DTdate->format($format); + return (!$date || !$DTdate || $date != $DTdate->format('Y-m-d H:i:s')) ? '[' . $date . ']' : $DTdate->format($format); } public function getDescription(): string @@ -172,7 +172,7 @@ public function getDefinitions(): array public static function getListValue($params): string { - return ''.self::datetime_getFormattedDatetime($params['params']['field']['format'], $params['subject']).''; + return '' . self::datetime_getFormattedDatetime($params['params']['field']['format'], $params['subject']) . ''; } public static function getSearchField($params) diff --git a/lib/yform/value/generate_key.php b/lib/yform/value/generate_key.php index 6f2d6455a..2dd960587 100644 --- a/lib/yform/value/generate_key.php +++ b/lib/yform/value/generate_key.php @@ -11,7 +11,7 @@ class rex_yform_value_generate_key extends rex_yform_value_abstract { public function preValidateAction(): void { - $generated_key = md5($this->params['form_name'].uniqid((string) (random_int(0, getrandmax())), true)); + $generated_key = md5($this->params['form_name'] . uniqid((string) random_int(0, getrandmax()), true)); if (1 != $this->getElement('only_empty')) { // wird immer neu gesetzt diff --git a/lib/yform/value/google_geocode.php b/lib/yform/value/google_geocode.php index e56824d1e..ac1ad5c0b 100644 --- a/lib/yform/value/google_geocode.php +++ b/lib/yform/value/google_geocode.php @@ -18,7 +18,7 @@ public function enterObject() $valueLng = $this->google_geocode_floattostr(0); } - $value = $valueLat.','.$valueLng; + $value = $valueLat . ',' . $valueLng; $this->setValue($value); @@ -46,7 +46,7 @@ public function enterObject() } else { $this->params['form_output'][$this->getId()] = $this->parse('value.text.tpl.php'); $this->params['form_output'][$this->getId()] .= $this->parse( - 'value.google_geocode.tpl.php', compact('value', 'mapWidth', 'mapHeight', 'mapZoom', 'address', 'googleapikey') + 'value.google_geocode.tpl.php', compact('value', 'mapWidth', 'mapHeight', 'mapZoom', 'address', 'googleapikey'), ); } } @@ -88,7 +88,7 @@ public function getDefinitions(): array public function google_geocode_floattostr($val) { - preg_match("#^([\+\-]|)([0-9]*)(\.([0-9]*?)|)(0*)$#", trim($val), $o); + preg_match('#^([\\+\\-]|)([0-9]*)(\\.([0-9]*?)|)(0*)$#', trim($val), $o); return @$o[1] . sprintf('%d', @$o[2]) . ('.' != @$o[3] ? @$o[3] : ''); } } diff --git a/lib/yform/value/hidden.php b/lib/yform/value/hidden.php index 7182378c1..a848d40fb 100644 --- a/lib/yform/value/hidden.php +++ b/lib/yform/value/hidden.php @@ -27,7 +27,7 @@ public function setValue($value) public function enterObject() { - if ($this->needsOutput() && (in_array($this->getElement(3), ['POST', 'REQUEST']))) { + if ($this->needsOutput() && in_array($this->getElement(3), ['POST', 'REQUEST'])) { $this->params['form_output'][$this->getId()] = $this->parse('value.hidden.tpl.php', ['fieldName' => $this->getElement(1)]); } @@ -39,6 +39,6 @@ public function enterObject() public function getDescription(): string { - return 'hidden|fieldname|value||[no_db]'."\n".'hidden|fieldname|key|REQUEST/GET/POST/SESSION|[no_db]'; + return 'hidden|fieldname|value||[no_db]' . "\n" . 'hidden|fieldname|key|REQUEST/GET/POST/SESSION|[no_db]'; } } diff --git a/lib/yform/value/html.php b/lib/yform/value/html.php index e34e92e16..a095e25e2 100644 --- a/lib/yform/value/html.php +++ b/lib/yform/value/html.php @@ -48,5 +48,4 @@ public function getDefinitions(): array 'is_hiddeninlist' => true, ]; } - } diff --git a/lib/yform/value/index.php b/lib/yform/value/index.php index a3d6f9bce..5b14b26e2 100644 --- a/lib/yform/value/index.php +++ b/lib/yform/value/index.php @@ -31,7 +31,7 @@ public function postFormAction(): void } if (isset($this->params['value_pool']['sql'][$name])) { - $value .= ' '.$this->params['value_pool']['sql'][$name]; + $value .= ' ' . $this->params['value_pool']['sql'][$name]; continue; } @@ -43,7 +43,7 @@ public function postFormAction(): void if ($relations) { foreach ($this->getRelationValues($relations) as $v) { - $value .= ' '.$v; + $value .= ' ' . $v; } } @@ -148,7 +148,7 @@ private function getRelationValues(array $relations) $sql->escapeIdentifier($table), $nextIndex, $index, - $sql->escapeIdentifier($name) + $sql->escapeIdentifier($name), ); return $nextIndex; @@ -159,7 +159,7 @@ private function getRelationValues(array $relations) $fieldFormat = 't%d.%s'; if ($relation->getElement('relation_table') || in_array($relation->getElement('type'), [1, 3, 4, 5])) { - $fieldFormat = 'GROUP_CONCAT('.$fieldFormat.' SEPARATOR " ")'; + $fieldFormat = 'GROUP_CONCAT(' . $fieldFormat . ' SEPARATOR " ")'; } foreach ($columns as $name => $sub) { @@ -231,7 +231,7 @@ private function getRelationValues(array $relations) 'SELECT %s FROM %s t0 %s WHERE ', implode(', ', $fields), $sql->escapeIdentifier($fromTable), - implode(' ', $joins) + implode(' ', $joins), ); switch ($type) { @@ -254,7 +254,7 @@ private function getRelationValues(array $relations) throw new LogicException(sprintf('Unknown relation type "%s"', $type)); } - $data = $sql->getArray($query.' LIMIT 1'); + $data = $sql->getArray($query . ' LIMIT 1'); if (!isset($data[0])) { continue; diff --git a/lib/yform/value/integer.php b/lib/yform/value/integer.php index e02553ec7..eeb35d65c 100644 --- a/lib/yform/value/integer.php +++ b/lib/yform/value/integer.php @@ -61,7 +61,7 @@ public function getDefinitions(): array public static function getListValue($params) { - return (!empty($params['params']['field']['unit']) && '' != $params['subject']) ? $params['params']['field']['unit'].' '.$params['subject'] : $params['subject']; + return (!empty($params['params']['field']['unit']) && '' != $params['subject']) ? $params['params']['field']['unit'] . ' ' . $params['subject'] : $params['subject']; } public static function getSearchField($params) @@ -77,18 +77,18 @@ public static function getSearchFilter($params) $field = $query->getTableAlias() . '.' . $params['field']->getName(); if ('(empty)' == $value) { - return $query->whereNested(function (rex_yform_manager_query $query) use ($field) { + return $query->whereNested(static function (rex_yform_manager_query $query) use ($field) { $query ->where($field, '') - ->where($field, NULL) + ->where($field, null) ; }, 'OR'); } if ('!(empty)' == $value) { - return $query->whereNested(function (rex_yform_manager_query $query) use ($field) { + return $query->whereNested(static function (rex_yform_manager_query $query) use ($field) { $query ->where($field, '', '<>') - ->where($field, NULL, '<>') + ->where($field, null, '<>') ; }, 'OR'); } diff --git a/lib/yform/value/number.php b/lib/yform/value/number.php index 99468aeeb..26a4cf9e7 100644 --- a/lib/yform/value/number.php +++ b/lib/yform/value/number.php @@ -33,7 +33,7 @@ public function enterObject() if (!$this->isEditable()) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.number-view.tpl.php', 'value.integer-view.tpl.php', 'value.view.tpl.php'], - ['prepend' => $this->getElement('unit')] + ['prepend' => $this->getElement('unit')], ); } else { $type = 'text'; @@ -42,7 +42,7 @@ public function enterObject() } $this->params['form_output'][$this->getId()] = $this->parse( ['value.number.tpl.php', 'value.integer.tpl.php', 'value.text.tpl.php'], - ['prepend' => $this->getElement('unit'), 'type' => $type] + ['prepend' => $this->getElement('unit'), 'type' => $type], ); } } diff --git a/lib/yform/value/signature.php b/lib/yform/value/signature.php index e97767f43..fbabe35cd 100644 --- a/lib/yform/value/signature.php +++ b/lib/yform/value/signature.php @@ -13,7 +13,7 @@ public function enterObject() { $this->setValue((string) $this->getValue()); - if ($this->getValue() == '' && !$this->params['send']) { + if ('' == $this->getValue() && !$this->params['send']) { $this->setValue($this->getElement('default')); } @@ -46,12 +46,12 @@ public function getDefinitions(): array 'description' => 'Fügt ein Zeichenfeld ein, in dem eine Unterschrift niedergeschrieben werden kann.', 'db_type' => ['text'], 'famous' => false, - 'search' => false + 'search' => false, ]; } public static function getListValue($params) { - return ($params['subject'] == "" ? 'ungesetzt' : ''); + return '' == $params['subject'] ? 'ungesetzt' : ''; } } diff --git a/lib/yform/value/text.php b/lib/yform/value/text.php index bf466ddbd..eb402c8a4 100644 --- a/lib/yform/value/text.php +++ b/lib/yform/value/text.php @@ -120,8 +120,8 @@ public static function getListValue($params) $value = (string) $params['subject']; $length = mb_strlen($value); if ($length > 100) { - $value = mb_substr($value, 0, 50).' ... '.mb_substr($value, -50); + $value = mb_substr($value, 0, 50) . ' ... ' . mb_substr($value, -50); } - return ''.rex_escape($value).''; + return '' . rex_escape($value) . ''; } } diff --git a/lib/yform/value/time.php b/lib/yform/value/time.php index 33d877509..56ced75f7 100644 --- a/lib/yform/value/time.php +++ b/lib/yform/value/time.php @@ -23,12 +23,12 @@ public function preValidateAction(): void $minute = (int) ($value['minute'] ?? 0); $second = (int) ($value['second'] ?? 0); } else { - $value = explode(":", (string) $value); + $value = explode(':', (string) $value); $hour = (int) ($value[0] ?? 0); $minute = (int) ($value[1] ?? 0); $second = (int) ($value[2] ?? 0); } - $value = sprintf("%02d:%02d:%02d", $hour, $minute, $second); + $value = sprintf('%02d:%02d:%02d', $hour, $minute, $second); $this->setValue($value); } @@ -40,12 +40,12 @@ public function enterObject() $minute = (int) ($value['minute'] ?? 0); $second = (int) ($value['second'] ?? 0); } else { - $value = explode(":", (string) $value); + $value = explode(':', (string) $value); $hour = (int) ($value[0] ?? 0); $minute = (int) ($value[1] ?? 0); $second = (int) ($value[2] ?? 0); } - $value = sprintf("%02d:%02d:%02d", $hour, $minute, $second); + $value = sprintf('%02d:%02d:%02d', $hour, $minute, $second); $this->setValue($value); $this->params['value_pool']['email'][$this->getName()] = $this->getValue(); @@ -60,12 +60,12 @@ public function enterObject() if (!$this->isEditable()) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.time-view.tpl.php', 'value.view.tpl.php'], - ['type' => 'text', 'value' => self::time_getFormattedTime($this->getElement('format'), $this->getValue())] + ['type' => 'text', 'value' => self::time_getFormattedTime($this->getElement('format'), $this->getValue())], ); } elseif ('input:text' == $this->getElement('widget')) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.text.tpl.php'], - ['type' => 'text', 'value' => $this->getValue()] + ['type' => 'text', 'value' => $this->getValue()], ); } else { $format = 'HH:ii:ss'; // Format of Select Order @@ -74,7 +74,7 @@ public function enterObject() $second = (int) mb_substr($this->getValue(), 6, 2); $this->params['form_output'][$this->getId()] = $this->parse( ['value.time.tpl.php', 'value.datetime.tpl.php'], - compact('format', 'hour', 'minute', 'second') + compact('format', 'hour', 'minute', 'second'), ); } } @@ -115,7 +115,7 @@ public static function time_getFormattedTime($format, $time) public static function getListValue($params) { - return ''.self::time_getFormattedTime($params['params']['field']['format'], $params['subject']).''; + return '' . self::time_getFormattedTime($params['params']['field']['format'], $params['subject']) . ''; } public static function getSearchField($params) diff --git a/lib/yform/value/upload.php b/lib/yform/value/upload.php index 4dd3851a9..c6131fa84 100644 --- a/lib/yform/value/upload.php +++ b/lib/yform/value/upload.php @@ -135,7 +135,7 @@ public function enterObject() $FILE['tmp_name'] = $_FILES[$this->upload_getSessionKey()]['tmp_name']; $FILE['tmp_yform_name'] = $temp_folder . '/' . $this->upload_getSessionKey() . '_' . $this->getId() . '_' . $FILE['name']; $FILE['upload_folder'] = $upload_folder; - $FILE['upload_name'] = $this->upload_getSessionKey().'_'.$FILE['name']; // default_name + $FILE['upload_name'] = $this->upload_getSessionKey() . '_' . $FILE['name']; // default_name unset($_FILES[$this->upload_getSessionKey()]); @@ -177,7 +177,7 @@ public function enterObject() if (isset($FILE['name'])) { $error_extensions = self::upload_checkExtensions($FILE, $configuration); if (0 < count($error_extensions)) { - $errors = $errors + $error_extensions; + $errors += $error_extensions; unset($FILE); } } @@ -187,11 +187,11 @@ public function enterObject() foreach ($configuration['callback'] as $callback) { $errors_callback = call_user_func($callback, ['file' => $FILE, 'configuration' => $configuration]); if (0 < count($errors_callback)) { - $errors_callbacks = $errors_callbacks + $errors_callback; + $errors_callbacks += $errors_callback; } } if (0 < count($errors_callbacks)) { - $errors = $errors + $errors_callbacks; + $errors += $errors_callbacks; unset($FILE); } } @@ -252,7 +252,7 @@ public function enterObject() } else { $filepath = $FILE['tmp_yform_name']; $filename = $FILE['name']; - $real_filepath = $FILE['upload_folder'].'/'.$FILE['upload_name']; + $real_filepath = $FILE['upload_folder'] . '/' . $FILE['upload_name']; } } @@ -279,7 +279,7 @@ public function enterObject() $this->setValue($filename); $this->params['value_pool']['email'][$this->getName()] = $this->getValue(); - $this->params['value_pool']['email'][$this->getName().'_folder'] = $this->getValue(); + $this->params['value_pool']['email'][$this->getName() . '_folder'] = $this->getValue(); if ($this->saveInDb()) { $this->params['value_pool']['sql'][$this->getName()] = $this->getValue(); } @@ -333,12 +333,12 @@ public function postAction(): void if (file_exists($FILE['tmp_yform_name'])) { $main_id = $this->getParam('main_id'); if ('' != $main_id && -1 != $main_id) { - $FILE['upload_name'] = $main_id.'_'.$FILE['name']; + $FILE['upload_name'] = $main_id . '_' . $FILE['name']; } else { - $FILE['upload_name'] = $this->upload_getSessionKey().'_'.$FILE['name']; + $FILE['upload_name'] = $this->upload_getSessionKey() . '_' . $FILE['name']; } - $upload_filefolder = $FILE['upload_folder'].'/'.$FILE['upload_name']; + $upload_filefolder = $FILE['upload_folder'] . '/' . $FILE['upload_name']; if (!move_uploaded_file($FILE['tmp_yform_name'], $upload_filefolder)) { if (!copy($FILE['tmp_yform_name'], $upload_filefolder)) { @@ -362,17 +362,17 @@ public function postAction(): void // delete temp files from this formfield $temp_folder = rex_path::pluginData('yform', 'manager', 'upload/temp'); - foreach (glob($temp_folder .'/'.$this->upload_getSessionKey().'*') as $f) { + foreach (glob($temp_folder . '/' . $this->upload_getSessionKey() . '*') as $f) { unlink($f); } // delete old files from cache $cu = date('U'); $offset = (60 * 60 * 0.5); // 30 min - $dir = $temp_folder.'/'; + $dir = $temp_folder . '/'; if ($dh = opendir($dir)) { while (false !== ($file = readdir($dh))) { - $f = $dir.$file; + $f = $dir . $file; $fu = date('U', filectime($f)); if (($cu - $fu) > $offset && '.' != $file && '..' != $file) { unlink($f); @@ -398,7 +398,7 @@ public function upload_getFolder(): string $folders[] = 'frontend'; } - return rex_path::pluginData('yform', 'manager', 'upload/'.implode('/', $folders)); + return rex_path::pluginData('yform', 'manager', 'upload/' . implode('/', $folders)); } public static function upload_checkdownloadFile(string $filename, string $filepath): void @@ -407,7 +407,7 @@ public static function upload_checkdownloadFile(string $filename, string $filepa ob_end_clean(); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename='.$filename); + header('Content-Disposition: attachment; filename=' . $filename); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); @@ -446,7 +446,7 @@ public function getDefinitions(): array public static function upload_getDownloadLink(string $table_name, string $field_name, int $data_id): string { if ('' != $table_name && '' != $field_name && 0 < $data_id) { - return '/redaxo/index.php?page=yform/manager/data_edit&table_name='.$table_name.'&data_id='.$data_id.'&func=edit&rex_upload_downloadfile='.urlencode($field_name); + return '/redaxo/index.php?page=yform/manager/data_edit&table_name=' . $table_name . '&data_id=' . $data_id . '&func=edit&rex_upload_downloadfile=' . urlencode($field_name); } return ''; } @@ -473,7 +473,7 @@ public static function upload_checkExtensions(array $FILE, array $configuration) in_array('multiple_extensions', $configuration['check']) && 0 < count(array_intersect(explode('.', $Filename), $configuration['disallowed_extensions'])) ) { - $errors[] = $configuration['messages']['type_multiple_error'] ?? 'multiple-extension-type-error: '.implode(', ', array_intersect(explode('.', $Filename), $configuration['disallowed_extensions'])); + $errors[] = $configuration['messages']['type_multiple_error'] ?? 'multiple-extension-type-error: ' . implode(', ', array_intersect(explode('.', $Filename), $configuration['disallowed_extensions'])); } if ( @@ -507,7 +507,7 @@ public static function upload_checkExtensions(array $FILE, array $configuration) if (3 < count($zip_error_files)) { $amount_files = count($zip_error_files); $zip_error_files = array_chunk($zip_error_files, 3)[0]; - $zip_error_files[] = ' ... ['.($amount_files - count($zip_error_files)).'] '; + $zip_error_files[] = ' ... [' . ($amount_files - count($zip_error_files)) . '] '; } if (0 < count($zip_error_files)) { @@ -542,14 +542,14 @@ public static function getListValue($params) $list = $params['list']; $title = $value; if ($length > 30) { - $value = mb_substr($value, 0, 15).' ... '.mb_substr($value, -15); + $value = mb_substr($value, 0, 15) . ' ... ' . mb_substr($value, -15); } $return = $value; if (rex::isBackend() && $list) { $field = new rex_yform_manager_field($params['params']['field']); if ('' != $value) { - $return = ''.rex_escape($value).''; + $return = '' . rex_escape($value) . ''; } } @@ -583,7 +583,7 @@ public function upload_getSessionVar(string $key, string $varType = 'string', mi $sessionVars = rex_session($this->upload_getSessionKey(), 'array', []); if (!is_scalar($varType)) { - throw new InvalidArgumentException('Scalar expected for $needle in arrayKeyCast(), got '. gettype($varType) .'!'); + throw new InvalidArgumentException('Scalar expected for $needle in arrayKeyCast(), got ' . gettype($varType) . '!'); } if (array_key_exists($key, $sessionVars)) { diff --git a/lib/yform/value/uuid.php b/lib/yform/value/uuid.php index 12b9bf164..5b8e74786 100644 --- a/lib/yform/value/uuid.php +++ b/lib/yform/value/uuid.php @@ -32,14 +32,15 @@ public function enterObject() } } - public static function guidv4($data = null) { + public static function guidv4($data = null) + { // Generate 16 bytes (128 bits) of random data or use the data passed into the function. - $data = $data ?? random_bytes(16); - + $data ??= random_bytes(16); + // Set version to 0100 - $data[6] = chr(ord($data[6]) & 0x0f | 0x40); + $data[6] = chr(ord($data[6]) & 0x0F | 0x40); // Set bits 6-7 to 10 - $data[8] = chr(ord($data[8]) & 0x3f | 0x80); + $data[8] = chr(ord($data[8]) & 0x3F | 0x80); // Output the 36 character UUID. return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); diff --git a/pages/docs.php b/pages/docs.php index 7bd20a841..f094c036f 100644 --- a/pages/docs.php +++ b/pages/docs.php @@ -6,7 +6,7 @@ */ $mdFiles = []; -foreach (glob(rex_addon::get('yform')->getPath('docs').'/*.md') as $file) { +foreach (glob(rex_addon::get('yform')->getPath('docs') . '/*.md') as $file) { $mdFiles[mb_substr(basename($file), 0, -3)] = $file; } @@ -20,10 +20,10 @@ foreach ($mdFiles as $key => $mdFile) { $keyWithoudPrio = mb_substr($key, 3); $currenMDFileWithoudPrio = mb_substr($currenMDFile, 3); - $page->addSubpage((new rex_be_page($key, rex_i18n::msg('yform_docs_'.$keyWithoudPrio))) + $page->addSubpage((new rex_be_page($key, rex_i18n::msg('yform_docs_' . $keyWithoudPrio))) ->setSubPath($mdFile) - ->setHref('index.php?page=yform/docs&mdfile='.$key) - ->setIsActive($key == $currenMDFile) + ->setHref('index.php?page=yform/docs&mdfile=' . $key) + ->setIsActive($key == $currenMDFile), ); } @@ -43,4 +43,3 @@ // $fragment->setVar('title', rex_i18n::msg('package_help') . ' ', false); $fragment->setVar('body', $content, false); echo $fragment->parse('core/page/section.php'); - diff --git a/pages/setup.php b/pages/setup.php index b3368e0ae..f0c2e2df8 100644 --- a/pages/setup.php +++ b/pages/setup.php @@ -12,7 +12,7 @@ $searchtext = 'module:yform_basic_output'; $gm = rex_sql::factory(); - $gm->setQuery('select * from '.rex::getTable('module').' where output LIKE "%' . $searchtext . '%"'); + $gm->setQuery('select * from ' . rex::getTable('module') . ' where output LIKE "%' . $searchtext . '%"'); $module_id = 0; $module_name = ''; @@ -46,7 +46,7 @@ } } - $content .= '

'.$this->i18n('install_modul_description').'

'; + $content .= '

' . $this->i18n('install_modul_description') . '

'; if ($module_id > 0) { $content .= '

' . $this->i18n('install_update_module', rex_escape((string) $module_name)) . '

'; diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000000000..15f426d69 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,23 @@ + + + + + + + + + tests + + + diff --git a/plugins/email/boot.php b/plugins/email/boot.php index b1d7fbb99..921ff3fd6 100644 --- a/plugins/email/boot.php +++ b/plugins/email/boot.php @@ -7,7 +7,7 @@ [ 'func' => 'edit', 'template_key' => $match[1], - ] + ], ); } }); diff --git a/plugins/email/lib/yform_action_tpl2email.php b/plugins/email/lib/yform_action_tpl2email.php index bd1a0f067..c0a80356c 100644 --- a/plugins/email/lib/yform_action_tpl2email.php +++ b/plugins/email/lib/yform_action_tpl2email.php @@ -84,7 +84,6 @@ public function executeAction(): void dump('Template: "' . rex_escape($template_name) . '" not found'); } - return; } public function getDescription(): string diff --git a/plugins/email/lib/yform_email_template.php b/plugins/email/lib/yform_email_template.php index 4832488be..2e0f87c0f 100644 --- a/plugins/email/lib/yform_email_template.php +++ b/plugins/email/lib/yform_email_template.php @@ -45,7 +45,7 @@ public static function replaceVars(array $template, $er = []) 'template' => $template, 'search_replace' => $er, 'status' => false, - ] + ], )); $template = $r['template']; @@ -66,13 +66,13 @@ public static function replaceVars(array $template, $er = []) $template[$k] = rex_var::parse($template[$k], null, 'yform_email_template', $er); } - $template['mail_from'] = rex_file::getOutput(rex_stream::factory('yform/email/template/'.$template['name'].'/mail_from', $template['mail_from'])); - $template['mail_from_name'] = rex_file::getOutput(rex_stream::factory('yform/email/template/'.$template['name'].'/mail_from_name', $template['mail_from_name'])); - $template['mail_reply_to'] = rex_file::getOutput(rex_stream::factory('yform/email/template/'.$template['name'].'/mail_reply_to', $template['mail_reply_to'])); - $template['mail_reply_to_name'] = rex_file::getOutput(rex_stream::factory('yform/email/template/'.$template['name'].'/mail_reply_to_name', $template['mail_reply_to_name'])); - $template['subject'] = rex_file::getOutput(rex_stream::factory('yform/email/template/'.$template['name'].'/subject', $template['subject'])); - $template['body'] = rex_file::getOutput(rex_stream::factory('yform/email/template/'.$template['name'].'/body', $template['body'])); - $template['body_html'] = rex_file::getOutput(rex_stream::factory('yform/email/template/'.$template['name'].'/body_html', $template['body_html'])); + $template['mail_from'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/mail_from', $template['mail_from'])); + $template['mail_from_name'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/mail_from_name', $template['mail_from_name'])); + $template['mail_reply_to'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/mail_reply_to', $template['mail_reply_to'])); + $template['mail_reply_to_name'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/mail_reply_to_name', $template['mail_reply_to_name'])); + $template['subject'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/subject', $template['subject'])); + $template['body'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body', $template['body'])); + $template['body_html'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body_html', $template['body_html'])); $template['mail_from'] = self::makeSingleLine($template['mail_from']); $template['mail_from_name'] = self::makeSingleLine($template['mail_from_name']); @@ -102,7 +102,7 @@ public static function sendMail(array $template, string $template_name = '') 'template' => $template, 'template_name' => $template_name, 'status' => false, - ] + ], )); $template = $r['template']; diff --git a/plugins/email/pages/index.php b/plugins/email/pages/index.php index e758115c1..43fa832ce 100644 --- a/plugins/email/pages/index.php +++ b/plugins/email/pages/index.php @@ -32,14 +32,13 @@ $template_id = $template['id']; } - $content = ''; $show_list = true; if ('delete' == $func && !rex_csrf_token::factory($_csrf_key)->isValid()) { echo rex_view::error(rex_i18n::msg('csrf_token_invalid')); } elseif ('delete' == $func && $template_id) { - rex_sql::factory()->setQuery('delete from '.$table.' where id=:template_id', ['template_id' => $template_id]); + rex_sql::factory()->setQuery('delete from ' . $table . ' where id=:template_id', ['template_id' => $template_id]); $content = rex_view::success(rex_i18n::msg('yform_email_info_template_deleted')); } elseif (('edit' == $func && $template_id) || 'add' == $func) { echo rex_view::info(rex_i18n::rawMsg('yform_email_info_text')); @@ -47,8 +46,8 @@ $form_data[] = 'text|name|translate:yform_email_key'; $form_data[] = 'validate|empty|name|Bitte key eintragen'; - $form_data[] = 'validate|unique|name|Dieser key existiet bereits|'.$table; - $form_data[] = 'validate|preg_match|name|([a-z0-9_.]+)|Bitte nur Buchstaben (Kleinschreibung), Zahlen und "_" für den key verwenden|'.$table; + $form_data[] = 'validate|unique|name|Dieser key existiet bereits|' . $table; + $form_data[] = 'validate|preg_match|name|([a-z0-9_.]+)|Bitte nur Buchstaben (Kleinschreibung), Zahlen und "_" für den key verwenden|' . $table; $form_data[] = 'html|html1|
'; $form_data[] = 'text|mail_from|translate:yform_email_from'; @@ -80,7 +79,7 @@ if ('edit' == $func) { $title = rex_i18n::msg('yform_email_update'); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->setHiddenField('template_id', $template_id); $yform->setHiddenField('func', $func); $yform->setActionField('db', [$table, "id=$template_id"]); @@ -138,7 +137,7 @@ $yform->setObjectparams('main_where', "id=$template_id"); $yform->setObjectparams('main_table', $table); $yform->setObjectparams('getdata', true); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->executeFields(); $content = $yform->executeActions(); @@ -146,7 +145,7 @@ $fragment->setVar('class', 'edit', false); $fragment->setVar('title', $title); $fragment->setVar('body', $content, false); - $content = rex_view::success(rex_i18n::msg('yform_email_info_template_added')).$fragment->parse('core/page/section.php'); + $content = rex_view::success(rex_i18n::msg('yform_email_info_template_added')) . $fragment->parse('core/page/section.php'); $show_list = false; } else { diff --git a/plugins/email/update.php b/plugins/email/update.php index c958b0b1e..b9438c13a 100644 --- a/plugins/email/update.php +++ b/plugins/email/update.php @@ -5,4 +5,4 @@ * @psalm-scope-this rex_plugin */ -$this->includeFile(__DIR__.'/install.php'); +$this->includeFile(__DIR__ . '/install.php'); diff --git a/plugins/manager/fragments/yform/manager/action_buttons.php b/plugins/manager/fragments/yform/manager/action_buttons.php index 46d6f05be..c11df9a71 100644 --- a/plugins/manager/fragments/yform/manager/action_buttons.php +++ b/plugins/manager/fragments/yform/manager/action_buttons.php @@ -13,7 +13,7 @@ diff --git a/plugins/manager/fragments/yform/manager/page/layout.php b/plugins/manager/fragments/yform/manager/page/layout.php index 4f319131e..99c8753ad 100644 --- a/plugins/manager/fragments/yform/manager/page/layout.php +++ b/plugins/manager/fragments/yform/manager/page/layout.php @@ -5,10 +5,10 @@ * @psalm-scope-this rex_fragment */ -/* @var $manager rex_yform_manager */ +/** @var rex_yform_manager $manager */ $manager = $this->getVar('this'); -/* @var $table rex_yform_manager_table */ +/** @var rex_yform_manager_table $table */ $table = $this->getVar('table'); $detailForm = $this->getVar('detailForm'); $historyPage = $this->getVar('historyPage'); @@ -31,7 +31,7 @@ foreach ($messages as $message) { if (!empty($message['link'])) { - $message['message'] = ''.$message['message'].''; + $message['message'] = '' . $message['message'] . ''; } switch ($message['type']) { diff --git a/plugins/manager/install.php b/plugins/manager/install.php index 4762f0b48..63e2f0e61 100644 --- a/plugins/manager/install.php +++ b/plugins/manager/install.php @@ -96,7 +96,7 @@ // from 4.0 on, but on every reinstall if ($this->isInstalled()) { foreach (rex_sql::factory()->getArray('SELECT id, perms FROM ' . rex::getTablePrefix() . 'user_role') as $role) { - if (false === strpos((string) $role['perms'], '"yform_manager_table_edit":')) { + if (!str_contains((string) $role['perms'], '"yform_manager_table_edit":')) { $perms = str_replace('"yform_manager_table":', '"yform_manager_table_edit":', (string) $role['perms']); rex_sql::factory()->setQuery('UPDATE ' . rex::getTablePrefix() . 'user_role SET perms=? where id=?', [$perms, $role['id']]); } @@ -165,7 +165,7 @@ 'id' => $field['id'], 'choices' => $field['options'], 'choice_attributes' => $field['attributes'] ?? '', - ] + ], ); break; @@ -184,7 +184,7 @@ 'id' => $field['id'], 'choices' => $field['options'], 'choice_attributes' => $field['attributes'] ?? '', - ] + ], ); break; @@ -201,7 +201,7 @@ [ 'id' => $field['id'], 'choices' => $field['query'] ?? '', - ] + ], ); break; @@ -220,7 +220,7 @@ 'id' => $field['id'], 'choices' => $field['query'] ?? '', 'choice_attributes' => $field['attributes'] ?? '', - ] + ], ); break; @@ -238,7 +238,7 @@ 'id' => $field['id'], 'choices' => $field['query'] ?? '', 'choice_attributes' => $field['attributes'] ?? '', - ] + ], ); break; case 'password': @@ -249,7 +249,7 @@ where id = :id', [ 'id' => $field['id'], - ] + ], ); break; } diff --git a/plugins/manager/lib/list.php b/plugins/manager/lib/list.php index 3dd3ac650..4a0e5261f 100644 --- a/plugins/manager/lib/list.php +++ b/plugins/manager/lib/list.php @@ -18,7 +18,7 @@ class rex_yform_list implements rex_url_provider_interface /** @var rex_yform_manager_dataset */ private $currentItem; /** @var bool */ - /* @phpstan-ignore-next-line */ + /** @phpstan-ignore-next-line */ private $debug; /** @var string */ private $noRowsMessage; @@ -129,7 +129,7 @@ protected function __construct(rex_yform_manager_query $query, int $rowsPerPage $this->rowAttributes = []; // --------- Pagination Attributes - $cursorName = $listName .'_start'; + $cursorName = $listName . '_start'; if (null === rex_request($cursorName, 'int', null) && rex_request('start', 'int')) { // BC: Fallback to "start" $cursorName = 'start'; @@ -147,7 +147,7 @@ protected function __construct(rex_yform_manager_query $query, int $rowsPerPage } // TODO: Performance - $this->rows = count($this->query->findValues($this->query->getTableAlias().'.id')); + $this->rows = count($this->query->findValues($this->query->getTableAlias() . '.id')); $this->pager->setRowCount($this->rows); $rowsPerPage = $this->pager->getRowsPerPage(); @@ -349,7 +349,7 @@ public function getLinkAttributes($column, $default = null) public function setRowAttributes($attr): void { if (!is_array($attr) && !is_callable($attr)) { - throw new InvalidArgumentException('$attr must be an array or a callable, but "'.get_debug_type($attr).'" given'); + throw new InvalidArgumentException('$attr must be an array or a callable, but "' . get_debug_type($attr) . '" given'); } $this->rowAttributes = $attr; @@ -659,7 +659,7 @@ public function getColumnPosition(string $columnName): int { $position = array_search($columnName, $this->columnNames); if (false === $position) { - throw new InvalidArgumentException('Unkown column name "'.$columnName.'".'); + throw new InvalidArgumentException('Unkown column name "' . $columnName . '".'); } return $position; } @@ -727,7 +727,7 @@ public function addTableColumn($width, $span = null, $class = null) { $tableColumn = []; if (is_numeric($width)) { - $width = $width . 'px'; + $width .= 'px'; } if ($width && '*' != $width) { $tableColumn['style'] = 'width:' . $width; @@ -754,9 +754,6 @@ public function addTableColumn($width, $span = null, $class = null) // ---------------------- Url generation - /** - * {@inheritdoc} - */ public function getUrl(array $params = [], $escape = true) { $params = array_merge($this->getParams(), $params); @@ -888,7 +885,7 @@ public function getSortType($default = null) $default = strtolower($default); if (!in_array($default, ['asc', 'desc'], true)) { - throw new InvalidArgumentException('Default sort type must be "asc", "desc" or null, but "'.$default.'" given'); + throw new InvalidArgumentException('Default sort type must be "asc", "desc" or null, but "' . $default . '" given'); } return $default; @@ -943,7 +940,7 @@ public function getHeader() */ public function replaceVariable($string, $varname) { - return str_replace(['###' . $varname . '###','___'.$varname.'___'], (string) rex_escape((string)$this->getValue($varname)), $string); + return str_replace(['###' . $varname . '###', '___' . $varname . '___'], (string) rex_escape((string) $this->getValue($varname)), $string); } /** @@ -998,7 +995,7 @@ public function formatValue($value, $format, $escape, $field = null) if (is_array($format)) { // Callbackfunktion -> Parameterliste aufbauen if ($this->isCustomFormat($format)) { - $format[2] = $format[2] ?? []; + $format[2] ??= []; $format[1] = [$format[1], ['list' => $this, 'field' => $field, 'value' => $value, 'format' => $format[0], 'escape' => $escape, 'params' => $format[2]]]; } diff --git a/plugins/manager/lib/yform/manager.php b/plugins/manager/lib/yform/manager.php index 8a97cc7a6..8742c5803 100644 --- a/plugins/manager/lib/yform/manager.php +++ b/plugins/manager/lib/yform/manager.php @@ -84,7 +84,7 @@ public function getDataPage() $rex_yform_list['list'] = rex_request('list', 'string'); $rex_yform_list['sort'] = rex_request('sort', 'string'); $rex_yform_list['sorttype'] = rex_request('sorttype', 'string'); - $rex_yform_list['start'] = rex_request('start', 'int', null) ?? rex_request($rex_yform_list['list'].'_start', 'int', null) ?? 0; + $rex_yform_list['start'] = rex_request('start', 'int', null) ?? rex_request($rex_yform_list['list'] . '_start', 'int', null) ?? 0; $_csrf_key = $this->table->getCSRFKey(); $rex_yform_list += rex_csrf_token::factory($_csrf_key)->getUrlParams(); @@ -135,8 +135,8 @@ public function getDataPage() rex_view::title(rex_i18n::msg('yform_table') . ': ' . $this->table->getNameLocalized() . ' [' . $this->table->getTablename() . ']' . $description . '', ''), [ 'yform' => $this, - ] - ) + ], + ), ); echo rex_extension::registerPoint(new rex_extension_point('YFORM_MANAGER_REX_INFO', '')); @@ -148,7 +148,7 @@ public function getDataPage() ['rex_yform_manager_opener' => $rex_yform_manager_opener], ['rex_yform_manager_popup' => $rex_yform_manager_popup], ['rex_yform_filter' => $rex_yform_filter], - ['rex_yform_set' => $rex_yform_set] + ['rex_yform_set' => $rex_yform_set], ); if ($data_id > 0) { @@ -272,7 +272,7 @@ public function getDataPage() } else { $data = 'add' == $func ? $this->table->createDataset() : $this->table->getRawDataset($data_id); $yform = $data->getForm(); - $yform->setObjectparams('form_name', 'data_edit-'.$this->table->getTableName()); + $yform->setObjectparams('form_name', 'data_edit-' . $this->table->getTableName()); } $yform->canEdit(rex_yform_manager_table_authorization::onAttribute('EDIT', $this->table, rex::getUser())); @@ -292,7 +292,7 @@ public function getDataPage() // rex_yform_show_formularblock=1 $text_block = ''; foreach ($this->table->getFields() as $field) { - $class = 'rex_yform_'.$field->getType().'_'.$field->getTypeName(); + $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName(); /** @var rex_yform_base_abstract $cl */ $cl = new $class(); @@ -334,13 +334,13 @@ public function getDataPage() case 'edit': $yform->setHiddenField('data_id', $data_id); $yform->setObjectparams('getdata', true); - $buttonLabels = rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'); + $buttonLabels = rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'); break; case 'add': - $buttonLabels = rex_i18n::msg('yform_add').','.rex_i18n::msg('yform_add_apply'); + $buttonLabels = rex_i18n::msg('yform_add') . ',' . rex_i18n::msg('yform_add_apply'); break; case 'collection_edit': - $buttonLabels = rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'); + $buttonLabels = rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'); } if ($yform->isEditable()) { @@ -392,9 +392,9 @@ public function getDataPage() // Submit-Buttons von "Edit" auf "Add" zurückstellen if ($v instanceof rex_yform_value_submit) { $yform->objparams['form_output'][$k] = str_replace( - [rex_i18n::msg('yform_save').'objparams['form_output'][$k] + [rex_i18n::msg('yform_save') . 'objparams['form_output'][$k], ); continue; } @@ -403,7 +403,7 @@ public function getDataPage() // verbundenen Sätze entfernen. Nur "inline" ist problematisch if ($v instanceof rex_yform_value_be_manager_relation && 5 == $v->getElement('type')) { $fieldName = preg_quote($v->getFieldName()); - $pattern = '//'; + $pattern = '//'; $yform->objparams['form_output'][$k] = preg_replace($pattern, '', $yform->objparams['form_output'][$k]); } } @@ -443,7 +443,7 @@ public function getDataPage() $yform->setObjectparams('main_where', "id=$data_id"); $yform->setObjectparams('getdata', true); $yform->setObjectparams('send', false); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $form = $yform->getForm(); } break; @@ -503,20 +503,20 @@ public function getDataPage() } } } catch (\Throwable $e) { - if ($sql_db->inTransaction()) { - $sql_db->rollBack(); - } - - $transactionErrorMessage = $e->getMessage(); - if ($transactionErrorMessage) { - if (rex::getUser()->isAdmin()) { - // dump($e); - } - $mainMessages[] = [ - 'type' => 'error', - 'message' => rex_i18n::msg('yform_editdata_collection_error_abort', $transactionErrorMessage), - ]; - } + if ($sql_db->inTransaction()) { + $sql_db->rollBack(); + } + + $transactionErrorMessage = $e->getMessage(); + if ($transactionErrorMessage) { + if (rex::getUser()->isAdmin()) { + // dump($e); + } + $mainMessages[] = [ + 'type' => 'error', + 'message' => rex_i18n::msg('yform_editdata_collection_error_abort', $transactionErrorMessage), + ]; + } } } break; @@ -606,8 +606,8 @@ public function getDataPage() new rex_extension_point( 'YFORM_DATA_LIST_LINKS', ['dataset_links' => $dataset_links, 'table_links' => $table_links, 'field_links' => $field_links], - ['table' => $this->table, 'popup' => $popup] - ) + ['table' => $this->table, 'popup' => $popup], + ), ); if (count($dataset_links) > 0) { @@ -682,8 +682,8 @@ public function getDataPage() 'table' => $this->table, 'this' => $this, 'link_vars' => $rex_link_vars, - ] - ) + ], + ), ); $fragment = new rex_fragment(); @@ -701,13 +701,13 @@ public function getDataPage() static function ($fnc) use ($data_page_function) { return in_array($fnc, $data_page_function) ? true : false; }, - false + false, ); $filterMessages = []; if ($rex_yform_filter) { $getFilter = static function (rex_yform_manager_field $field, $value, $table) { - $class = 'rex_yform_value_'.$field->getTypeName(); + $class = 'rex_yform_value_' . $field->getTypeName(); $listValues = ''; try { $listValues = $class::getListValue([ @@ -723,7 +723,7 @@ static function ($fnc) use ($data_page_function) { dump($e); } - return '' . rex_i18n::translate($field->getLabel()) .': ' . $listValues; + return '' . rex_i18n::translate($field->getLabel()) . ': ' . $listValues; }; foreach ($rex_yform_filter as $key => $value) { $field = $this->table->getValueField($key); @@ -740,7 +740,7 @@ static function ($fnc) use ($data_page_function) { return $this->table->parseLayout($mainFragment); } - public function getDataListQuery(rex_yform_manager_query $query, array $rex_filter = [], rex_yform_manager_search $searchObject = null) + public function getDataListQuery(rex_yform_manager_query $query, array $rex_filter = [], ?rex_yform_manager_search $searchObject = null) { $fields = $query->getTable()->getFields(); @@ -754,9 +754,9 @@ public function getDataListQuery(rex_yform_manager_query $query, array $rex_filt 'fields' => $fields, 'value' => $rex_filter[$field->getName()], 'query' => $query, - ] + ], ); - if ('rex_yform_manager_query' != get_class($query)) { + if ('rex_yform_manager_query' != $query::class) { throw new Exception('getSearchFilter in rex_yform_value_' . $field->getTypeName() . ' does not return a rex_yform_manager_query'); } } @@ -793,7 +793,7 @@ public function getFieldPage() $table = $this->table; - $table_info = '' . $table->getNameLocalized() . ' [' . $table->getTableName() . '] '; + $table_info = '' . $table->getNameLocalized() . ' [' . $table->getTableName() . '] '; echo rex_view::info($table_info); $_csrf_key = $this->table->getCSRFKey(); @@ -835,7 +835,7 @@ public function getFieldPage() $panels = []; if (!$table->hasId()) { - $content[] = rex_i18n::msg('yform_id_is_missing').''.rex_i18n::msg('yform_id_missing_info'); + $content[] = rex_i18n::msg('yform_id_is_missing') . '' . rex_i18n::msg('yform_id_missing_info'); } else { if ('' == $type_real_field && count($mfields) > 0) { $tmp = ''; @@ -862,14 +862,14 @@ public function getFieldPage() foreach ($types['value'] as $k => $v) { if (isset($v['manager']) && !$v['manager']) { } elseif (isset($v['deprecated']) && $v['deprecated']) { - $tmp_deprecated .= '' . $k . '' . $v['deprecated'] .'
' . $v['description'] . ''; + $tmp_deprecated .= '' . $k . '' . $v['deprecated'] . '
' . $v['description'] . ''; } elseif (isset($v['famous']) && $v['famous']) { $tmp_famous .= '' . $k . '' . $v['description'] . ''; } else { $tmp .= '' . $k . '' . $v['description'] . ''; } } - $tmp = ''.$tmp_famous.$tmp.$tmp_deprecated.'
'; + $tmp = '' . $tmp_famous . $tmp . $tmp_deprecated . '
'; } $fragment = new rex_fragment(); $fragment->setVar('title', $TYPE['value']); @@ -888,7 +888,7 @@ public function getFieldPage() $tmp .= '' . $k . '' . $v['description'] . ''; } } - $tmp = ''.$tmp_famous.$tmp.'
'; + $tmp = '' . $tmp_famous . $tmp . '
'; } $fragment = new rex_fragment(); @@ -961,7 +961,7 @@ public function getFieldPage() $yform->setValueField('text', [$k_field, rex_i18n::msg('yform_values_defaults_name'), $v['value'], 'notice' => $v['notice']]); $yform->setValidateField('empty', [$k_field, rex_i18n::msg('yform_validatenamenotempty')]); - $yform->setValidateField('preg_match', [$k_field, "/(([a-zA-Z])+([a-zA-Z0-9\_])*)/", rex_i18n::msg('yform_validatenamepregmatch')]); + $yform->setValidateField('preg_match', [$k_field, '/(([a-zA-Z])+([a-zA-Z0-9\\_])*)/', rex_i18n::msg('yform_validatenamepregmatch')]); $yform->setValidateField('customfunction', [$k_field, 'rex_yform_manager_checkField', ['table_name' => $table->getTableName()], rex_i18n::msg('yform_validatenamecheck')]); } break; @@ -1098,9 +1098,9 @@ public function getFieldPage() if ($yform->objparams['form_show']) { if ('add' == $func) { - $title = rex_i18n::msg('yform_addfield') . ' "' . $type_name. '"'; + $title = rex_i18n::msg('yform_addfield') . ' "' . $type_name . '"'; } else { - $title = rex_i18n::msg('yform_editfield') . ' "' . $type_name .'"'; + $title = rex_i18n::msg('yform_editfield') . ' "' . $type_name . '"'; } $fragment = new rex_fragment(); @@ -1177,7 +1177,7 @@ public function getFieldPage() $notation_php_pre = [ '$yform = new rex_yform();', - '$yform->setObjectparams(\'form_name\', \'table-'.$table->getTableName().'\');', + '$yform->setObjectparams(\'form_name\', \'table-' . $table->getTableName() . '\');', '$yform->setObjectparams(\'form_action\',rex_getUrl(\'REX_ARTICLE_ID\'));', '$yform->setObjectparams(\'form_ytemplate\', \'bootstrap\');', '$yform->setObjectparams(\'form_showformafterupdate\', 0);', @@ -1187,7 +1187,7 @@ public function getFieldPage() $notation_php .= implode("\n", $notation_php_pre) . "\n"; $notation_pipe_pre = [ - 'objparams|form_name|table-'.$table->getTableName().'', + 'objparams|form_name|table-' . $table->getTableName() . '', 'objparams|form_ytemplate|bootstrap', 'objparams|form_showformafterupdate|0', 'objparams|real_field_names|true', @@ -1196,7 +1196,7 @@ public function getFieldPage() $notation_pipe .= implode("\n", $notation_pipe_pre) . "\n"; foreach ($formbuilder_fields as $field) { - $class = 'rex_yform_'.$field->getType().'_'.$field->getTypeName(); + $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName(); $cl = new $class(); $definitions = $cl->getDefinitions(); @@ -1215,7 +1215,7 @@ public function getFieldPage() ++$i; } $php_values = array_map(static function ($v) { - return str_replace("'", "\'", $v); + return str_replace("'", "\\'", $v); }, $values); if ('value' == $field['type_id']) { @@ -1231,10 +1231,10 @@ public function getFieldPage() } } - $notation_php .= "\n\n" . '$yform->setActionField(\'tpl2email\', [\'emailtemplate\', \'emailfieldname/email@example.org\']);'; - $notation_php .= "\n".'echo $yform->getForm();'; + $notation_php .= "\n\n" . '$yform->setActionField(\'tpl2email\', [\'emailtemplate\', \'emailfieldname/email@example.org\']);'; + $notation_php .= "\n" . 'echo $yform->getForm();'; - $notation_pipe .= "\n\n" . 'action|tpl2email|emailtemplate|emailfieldname/email@example.org'; + $notation_pipe .= "\n\n" . 'action|tpl2email|emailtemplate|emailfieldname/email@example.org'; $fragment = new rex_fragment(); $fragment->setVar('title', 'PHP'); @@ -1266,13 +1266,13 @@ public function getFieldPage() [ 'table' => $table, 'link_vars' => $this->getLinkVars(), - ] - ) + ], + ), ); if ($show_list) { $context = new rex_context( - $this->getLinkVars() + $this->getLinkVars(), ); $fragment = new rex_fragment(); @@ -1295,7 +1295,7 @@ public function getFieldPage() $fragment->setVar('buttons', [ [ 'label' => rex_i18n::msg('yform_edit'), - 'url' => 'index.php?page=yform/manager/table_edit&func=edit&table_id='.$table->getId(), + 'url' => 'index.php?page=yform/manager/table_edit&func=edit&table_id=' . $table->getId(), 'attributes' => [ 'class' => [ 'btn-default', @@ -1321,7 +1321,7 @@ public function getFieldPage() ], ], [ - 'label' => rex_i18n::msg('yform_updatetable').' '.rex_i18n::msg('yform_updatetable_with_delete'), + 'label' => rex_i18n::msg('yform_updatetable') . ' ' . rex_i18n::msg('yform_updatetable_with_delete'), 'url' => $context->getUrl(['table_name' => $table->getTableName(), 'func' => 'updatetablewithdelete'] + rex_csrf_token::factory($_csrf_key)->getUrlParams()), 'attributes' => [ 'class' => [ diff --git a/plugins/manager/lib/yform/manager/collection.php b/plugins/manager/lib/yform/manager/collection.php index f764ef991..bd48c071d 100644 --- a/plugins/manager/lib/yform/manager/collection.php +++ b/plugins/manager/lib/yform/manager/collection.php @@ -1,7 +1,6 @@ * @@ -46,7 +45,7 @@ public function setData(array $data): self { foreach ($data as $dataset) { if (!$dataset instanceof rex_yform_manager_dataset) { - throw new InvalidArgumentException(sprintf('$data has to be an array of rex_yform_manager_dataset objects, found "%s" array element.', is_object($dataset) ? get_class($dataset) : gettype($dataset))); + throw new InvalidArgumentException(sprintf('$data has to be an array of rex_yform_manager_dataset objects, found "%s" array element.', is_object($dataset) ? $dataset::class : gettype($dataset))); } if ($dataset->getTableName() !== $this->table) { throw new InvalidArgumentException(sprintf('$data has to be an array of rex_yform_manager_dataset objects of table "%s", found dataset of table "%s".', $this->table, $dataset->getTableName())); @@ -167,7 +166,6 @@ public function chunk(int $size): array } /** - * @param string $key * @return T[] */ public function toKeyIndex(string $key = 'id'): array @@ -245,7 +243,7 @@ public function implode($value, string $separator, ?string $and = null): string $last = array_pop($data); - return implode($separator, $data).$and.$last; + return implode($separator, $data) . $and . $last; } /** @@ -379,10 +377,10 @@ public function populateRelation(string $key) } else { $columns = $this->getTable()->getRelationTableColumns($key); $query - ->join($relation['relation_table'], null, $relation['relation_table'].'.'.$columns['target'], $relation['table'].'.id') - ->where($relation['relation_table'].'.'.$columns['source'], $this->getIds()) - ->groupBy($relation['table'].'.id') - ->selectRaw(sprintf('GROUP_CONCAT(%s SEPARATOR ",")', $query->quoteIdentifier($relation['relation_table'].'.'.$columns['source'])), '__related_ids') + ->join($relation['relation_table'], null, $relation['relation_table'] . '.' . $columns['target'], $relation['table'] . '.id') + ->where($relation['relation_table'] . '.' . $columns['source'], $this->getIds()) + ->groupBy($relation['table'] . '.id') + ->selectRaw(sprintf('GROUP_CONCAT(%s SEPARATOR ",")', $query->quoteIdentifier($relation['relation_table'] . '.' . $columns['source'])), '__related_ids') ; $allRelatedDatasets = $query->find(); @@ -457,7 +455,7 @@ public function getForm(): rex_yform } /** @var class-string $class */ - $class = 'rex_yform_'.$field->getType().'_'.$field->getTypeName(); + $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName(); /** @var rex_yform_base_abstract $cl */ $cl = new $class(); @@ -512,7 +510,7 @@ public function getForm(): rex_yform if ($useCheckbox) { $yform->setValueField('checkbox', [ - 'name' => $key.'_multi_edit', + 'name' => $key . '_multi_edit', 'label' => rex_i18n::msg('yform_manager_multi_edit_field', $field->getLabel()), 'default' => $default, 'no_db' => true, @@ -542,7 +540,7 @@ public function getForm(): rex_yform /** * @param null|callable(rex_yform):void $afterFieldsExecuted */ - public function executeForm(rex_yform $yform, callable $afterFieldsExecuted = null): string + public function executeForm(rex_yform $yform, ?callable $afterFieldsExecuted = null): string { $yform->executeFields(); @@ -568,7 +566,7 @@ public function executeForm(rex_yform $yform, callable $afterFieldsExecuted = nu if (!$this->save()) { foreach ($this as $dataset) { foreach ($dataset->getMessages() as $message) { - $yform->objparams['warning_messages'][] = rex_i18n::msg('yform_data').' ID '.$dataset->getId().': '.$message; + $yform->objparams['warning_messages'][] = rex_i18n::msg('yform_data') . ' ID ' . $dataset->getId() . ': ' . $message; } } } diff --git a/plugins/manager/lib/yform/manager/dataset.php b/plugins/manager/lib/yform/manager/dataset.php index 5f2e44bba..38a714f0f 100644 --- a/plugins/manager/lib/yform/manager/dataset.php +++ b/plugins/manager/lib/yform/manager/dataset.php @@ -92,7 +92,7 @@ public static function require(int $id, ?string $table = null): self if (!$dataset) { $table = $table ?: static::modelToTable(); - throw new rex_exception('Dataset with ID "'.$id.'" does not exist in "'.$table.'"'); + throw new rex_exception('Dataset with ID "' . $id . '" does not exist in "' . $table . '"'); } return $dataset; @@ -307,7 +307,7 @@ public function getData(): array public function loadData(): void { $sql = rex_sql::factory(); - $rows = $sql->getArray('SELECT * FROM `'.$this->table.'` WHERE id = ? LIMIT 1', [$this->id]); + $rows = $sql->getArray('SELECT * FROM `' . $this->table . '` WHERE id = ? LIMIT 1', [$this->id]); $this->exists = isset($rows[0]); if ($this->exists) { $this->data = $rows[0]; @@ -390,8 +390,8 @@ public function getRelatedQuery(string $key): rex_yform_manager_query } else { $columns = $this->getTable()->getRelationTableColumns($key); $query - ->join($relation['relation_table'], null, $relation['relation_table'].'.'.$columns['target'], $relation['table'].'.id') - ->where($relation['relation_table'].'.'.$columns['source'], $this->getId()); + ->join($relation['relation_table'], null, $relation['relation_table'] . '.' . $columns['target'], $relation['table'] . '.id') + ->where($relation['relation_table'] . '.' . $columns['source'], $this->getId()); } return $query; @@ -507,7 +507,7 @@ public function getForm(): rex_yform /** * @param null|callable(rex_yform):void $afterFieldsExecuted */ - public function executeForm(rex_yform $yform, callable $afterFieldsExecuted = null): string + public function executeForm(rex_yform $yform, ?callable $afterFieldsExecuted = null): string { $exists = $this->exists(); $oldData = $this->getData(); @@ -604,7 +604,7 @@ public function makeSnapshot(string $action): void } $value = @$sql->getValue($fieldName); - if ('rex_yform_value_be_manager_relation' == get_class($fieldObject) && !$value) { + if ('rex_yform_value_be_manager_relation' == $fieldObject::class && !$value) { $collection = $this->getRelatedCollection($fieldName); $values = []; foreach ($collection as $item) { @@ -618,12 +618,12 @@ public function makeSnapshot(string $action): void '(%d, %s, %s)', $historyId, $sql->escape($fieldName), - $sql->escape((string) $value) + $sql->escape((string) $value), ); } } - $sql->setQuery('INSERT INTO '.rex::getTable('yform_history_field').' (`history_id`, `field`, `value`) VALUES '.implode(', ', $inserts)); + $sql->setQuery('INSERT INTO ' . rex::getTable('yform_history_field') . ' (`history_id`, `field`, `value`) VALUES ' . implode(', ', $inserts)); } public function restoreSnapshot(int $snapshotId): bool @@ -697,7 +697,7 @@ private function createForm(): rex_yform foreach ($fields as $field) { /** @var class-string $class */ - $class = 'rex_yform_'.$field->getType().'_'.$field->getTypeName(); + $class = 'rex_yform_' . $field->getType() . '_' . $field->getTypeName(); /** @var rex_yform_base_abstract $cl */ $cl = new $class(); diff --git a/plugins/manager/lib/yform/manager/field.php b/plugins/manager/lib/yform/manager/field.php index f5f866f46..5fc6a2584 100644 --- a/plugins/manager/lib/yform/manager/field.php +++ b/plugins/manager/lib/yform/manager/field.php @@ -8,8 +8,8 @@ class rex_yform_manager_field implements ArrayAccess protected static $types = ['value', 'validate', 'action']; protected static $protected_fields = ['id', 'table_name', 'prio', 'type_id', 'type_name', 'db_type', 'list_hidden', 'search', 'name', 'label', 'not_required']; - /** @var rex_yform_value_abstract|rex_yform_validate_abstract $object */ - protected $object = null; + /** @var rex_yform_value_abstract|rex_yform_validate_abstract */ + protected $object; /** * rex_yform_manager_field constructor. @@ -65,7 +65,7 @@ public function getObject() } /** - * example: rex_yform_select + * example: rex_yform_select. * @return mixed|string */ public function getTypeName() @@ -192,8 +192,8 @@ public function toArray() $keys = array_unique( array_merge( self::$protected_fields, - array_keys($this->definitions['values'] ?? []) - ) + array_keys($this->definitions['values'] ?? []), + ), ); return array_intersect_key($this->values, array_flip($keys)); diff --git a/plugins/manager/lib/yform/manager/query.php b/plugins/manager/lib/yform/manager/query.php index 87b63249c..466c895ef 100644 --- a/plugins/manager/lib/yform/manager/query.php +++ b/plugins/manager/lib/yform/manager/query.php @@ -134,7 +134,7 @@ public function selectRaw($expression, ?string $alias = null): self } if ($alias) { - $expression .= ' AS '.$this->quoteIdentifier($alias); + $expression .= ' AS ' . $this->quoteIdentifier($alias); } $this->select[] = $expression; @@ -182,13 +182,13 @@ public function joinTypeRelation(string $type, string $column, ?string $alias = $relatedTable = $alias ?: $relation['table']; if (4 == $relation['type'] || 5 == $relation['type']) { - return $this->joinType($type, $relation['table'], $alias, $this->getTableAlias().'.id', $relatedTable.'.'.$relation['field']); + return $this->joinType($type, $relation['table'], $alias, $this->getTableAlias() . '.id', $relatedTable . '.' . $relation['field']); } - $relatedField = $relatedTable.'.id'; + $relatedField = $relatedTable . '.id'; if (empty($relation['relation_table'])) { - $column = $this->getTableAlias().'.'.$column; + $column = $this->getTableAlias() . '.' . $column; $operator = in_array($relation['type'], [1, 3]) ? 'FIND_IN_SET' : '='; return $this->joinType($type, $relation['table'], $alias, $relatedField, $column, $operator); @@ -197,8 +197,8 @@ public function joinTypeRelation(string $type, string $column, ?string $alias = $relationColumns = $this->getTable()->getRelationTableColumns($column); return $this - ->joinType($type, $relation['relation_table'], null, $this->getTableAlias().'.id', $relation['relation_table'].'.'.$relationColumns['source']) - ->joinType($type, $relation['table'], $alias, $relation['relation_table'].'.'.$relationColumns['target'], $relatedField); + ->joinType($type, $relation['relation_table'], null, $this->getTableAlias() . '.id', $relation['relation_table'] . '.' . $relationColumns['source']) + ->joinType($type, $relation['table'], $alias, $relation['relation_table'] . '.' . $relationColumns['target'], $relatedField); } /** @@ -246,10 +246,10 @@ public function joinRaw(string $type, string $table, ?string $alias = null, ?str { $join = sprintf('%s JOIN `%s`', mb_strtoupper($type), $table); if ($alias) { - $join .= ' AS '.$this->quoteIdentifier($alias); + $join .= ' AS ' . $this->quoteIdentifier($alias); } if ($condition) { - $join .= ' ON '.$condition; + $join .= ' ON ' . $condition; } $this->joins[] = $join; @@ -307,7 +307,7 @@ public function whereNot(string $column, $value): self */ public function whereNull(string $column): self { - $this->where[] = $this->quoteIdentifier($column).' IS NULL'; + $this->where[] = $this->quoteIdentifier($column) . ' IS NULL'; return $this; } @@ -317,7 +317,7 @@ public function whereNull(string $column): self */ public function whereNotNull(string $column): self { - $this->where[] = $this->quoteIdentifier($column).' IS NOT NULL'; + $this->where[] = $this->quoteIdentifier($column) . ' IS NOT NULL'; return $this; } @@ -366,7 +366,7 @@ public function whereListContains(string $column, $value): self */ public function whereRaw(string $where, array $params = []): self { - $this->where[] = '('.$where.')'; + $this->where[] = '(' . $where . ')'; $this->params[self::PARAM_WHERE] = array_merge($this->params[self::PARAM_WHERE] ?? [], $params); return $this; @@ -383,7 +383,7 @@ public function whereNested($nested, string $operator = 'AND'): self $operator = strtoupper(trim($operator)); if (is_array($nested)) { - $this->where[] = '('.$this->buildNestedWhere($nested, $operator).')'; + $this->where[] = '(' . $this->buildNestedWhere($nested, $operator) . ')'; return $this; } @@ -395,7 +395,7 @@ public function whereNested($nested, string $operator = 'AND'): self call_user_func($nested, $query); if ($query->where) { - $this->where[] = '('.implode(' '.$operator.' ', $query->where).')'; + $this->where[] = '(' . implode(' ' . $operator . ' ', $query->where) . ')'; $this->params[self::PARAM_WHERE] = array_merge($this->params[self::PARAM_WHERE] ?? [], $query->params[self::PARAM_WHERE] ?? []); $this->paramCounter = $query->paramCounter; } @@ -454,7 +454,7 @@ public function havingNot(string $column, $value): self */ public function havingNull(string $column): self { - $this->having[] = $this->quoteIdentifier($column).' IS NULL'; + $this->having[] = $this->quoteIdentifier($column) . ' IS NULL'; return $this; } @@ -464,7 +464,7 @@ public function havingNull(string $column): self */ public function havingNotNull(string $column): self { - $this->having[] = $this->quoteIdentifier($column).' IS NOT NULL'; + $this->having[] = $this->quoteIdentifier($column) . ' IS NOT NULL'; return $this; } @@ -513,7 +513,7 @@ public function havingListContains(string $column, $value): self */ public function havingRaw(string $having, array $params = []): self { - $this->having[] = '('.$having.')'; + $this->having[] = '(' . $having . ')'; $this->params[self::PARAM_HAVING] = array_merge($this->params[self::PARAM_HAVING] ?? [], $params); return $this; @@ -566,7 +566,7 @@ public function resetOrderBy(): self */ public function orderBy(string $column, string $direction = 'ASC'): self { - $this->orderBy[] = $this->quoteIdentifier($column).' '.$direction; + $this->orderBy[] = $this->quoteIdentifier($column) . ' ' . $direction; return $this; } @@ -577,7 +577,7 @@ public function orderBy(string $column, string $direction = 'ASC'): self */ public function orderByRaw(string $expression, string $direction = 'ASC'): self { - $this->orderBy[] = $expression.' '.$direction; + $this->orderBy[] = $expression . ' ' . $direction; return $this; } @@ -597,7 +597,7 @@ public function resetLimit(): self */ public function limit(int $offsetOrRowCount, ?int $rowCount = null): self { - $this->limit = $rowCount ? $offsetOrRowCount.', '.$rowCount : (string) $offsetOrRowCount; + $this->limit = $rowCount ? $offsetOrRowCount . ', ' . $rowCount : (string) $offsetOrRowCount; return $this; } @@ -612,36 +612,36 @@ public function getQuery(): string $query = sprintf('SELECT %s FROM `%s`', implode(', ', $select), $this->table); if ($this->alias) { - $query .= ' AS '.$this->quoteIdentifier($this->alias); + $query .= ' AS ' . $this->quoteIdentifier($this->alias); } if ($this->joins) { - $query .= ' '.implode(' ', $this->joins); + $query .= ' ' . implode(' ', $this->joins); } if ($this->where) { - $query .= ' WHERE '.implode(' '.$this->whereOperator.' ', $this->where); + $query .= ' WHERE ' . implode(' ' . $this->whereOperator . ' ', $this->where); } if ($this->groupBy) { - $query .= ' GROUP BY '.implode(', ', $this->groupBy); + $query .= ' GROUP BY ' . implode(', ', $this->groupBy); } if ($this->having) { - $query .= ' HAVING '.implode(' '.$this->havingOperator.' ', $this->having); + $query .= ' HAVING ' . implode(' ' . $this->havingOperator . ' ', $this->having); } if (!$this->orderBy && !$this->orderByResetted) { $table = $this->getTable(); - $this->orderBy($this->getTableAlias().'.'.$table->getSortFieldName(), $table->getSortOrderName()); + $this->orderBy($this->getTableAlias() . '.' . $table->getSortFieldName(), $table->getSortOrderName()); } if ($this->orderBy) { - $query .= ' ORDER BY '.implode(', ', $this->orderBy); + $query .= ' ORDER BY ' . implode(', ', $this->orderBy); } if ($this->limit) { - $query .= ' LIMIT '.$this->limit; + $query .= ' LIMIT ' . $this->limit; } return $query; @@ -690,7 +690,7 @@ public function paginate(rex_pager $pager): rex_yform_manager_collection */ public function findIds(array $ids): rex_yform_manager_collection { - return $this->where($this->getTableAlias().'.id', $ids)->find(); + return $this->where($this->getTableAlias() . '.id', $ids)->find(); } /** @@ -709,7 +709,7 @@ public function findOne(): ?rex_yform_manager_dataset */ public function findId(int $id): ?rex_yform_manager_dataset { - return $this->where($this->getTableAlias().'.id', $id)->resetOrderBy()->findOne(); + return $this->where($this->getTableAlias() . '.id', $id)->resetOrderBy()->findOne(); } /** @@ -801,7 +801,7 @@ public function quoteIdentifier(string $identifier): string $identifier = explode('.', $identifier, 2); foreach ($identifier as &$part) { if ('*' !== $part) { - $part = '`'.str_replace('`', '``', $part).'`'; + $part = '`' . str_replace('`', '``', $part) . '`'; } } @@ -841,10 +841,10 @@ private function addParam(string $type, $value): string { $this->paramCounter[$type] = ($this->paramCounter[$type] ?? 0) + 1; - $param = $type.$this->paramCounter[$type]; + $param = $type . $this->paramCounter[$type]; $this->params[$type][$param] = $this->normalizeValue($value); - return ':'.$param; + return ':' . $param; } /** @@ -857,7 +857,7 @@ private function buildCondition(string $type, string $column, mixed $value, ?str foreach ($value as $v) { $param[] = $this->addParam($type, $v); } - $param = '('.implode(', ', $param).')'; + $param = '(' . implode(', ', $param) . ')'; $operator = $operator ?: 'IN'; } else { @@ -880,7 +880,7 @@ private function buildListContains(string $type, string $column, $value): string return sprintf('FIND_IN_SET(%s, %s)', $this->addParam($type, $value), $this->quoteIdentifier($column)); } - $regex = '(^|,)('.implode('|', array_map('intval', $value)).')(,|$)'; + $regex = '(^|,)(' . implode('|', array_map('intval', $value)) . ')(,|$)'; return sprintf('%s REGEXP %s', $this->quoteIdentifier($column), $this->addParam($type, $regex)); } @@ -902,6 +902,6 @@ private function buildNestedWhere(array $where, string $operator = 'AND'): strin $value = sprintf('%s = %s', $this->quoteIdentifier($key), $this->addParam(self::PARAM_WHERE, $value)); } - return implode(' '.$operator.' ', $where); + return implode(' ' . $operator . ' ', $where); } } diff --git a/plugins/manager/lib/yform/manager/search.php b/plugins/manager/lib/yform/manager/search.php index 9a4c40bba..a40459990 100644 --- a/plugins/manager/lib/yform/manager/search.php +++ b/plugins/manager/lib/yform/manager/search.php @@ -49,7 +49,7 @@ public function setScriptPath(string $scriptpath): self public function getYForm(): rex_yform { $yform = new rex_yform(); - $yform->setObjectparams('form_name', 'rex_yform_searchvars-'.$this->table->getTableName()); + $yform->setObjectparams('form_name', 'rex_yform_searchvars-' . $this->table->getTableName()); $yform->setObjectparams('form_showformafterupdate', 1); $yform->setObjectparams('csrf_protection', false); $yform->setObjectparams('form_action', $this->scriptPath); @@ -101,7 +101,7 @@ public function getSearchVars() return $return; } - function getQueryFilter($query) + public function getQueryFilter($query) { if (!$this->table->isSearchable()) { return $query; @@ -130,9 +130,9 @@ function getQueryFilter($query) 'fields' => $this->fields, 'value' => $vars[$field->getName()], 'query' => $query, - ] + ], ); - if ('rex_yform_manager_query' != get_class($query)) { + if ('rex_yform_manager_query' != $query::class) { throw new Exception('getSearchFilter in rex_yform_value_' . $field->getTypeName() . ' does not return a rex_yform_manager_query'); } } diff --git a/plugins/manager/lib/yform/manager/table.php b/plugins/manager/lib/yform/manager/table.php index 3e71064c2..e13353dad 100644 --- a/plugins/manager/lib/yform/manager/table.php +++ b/plugins/manager/lib/yform/manager/table.php @@ -79,7 +79,7 @@ public static function require(string $tableName): self $table = self::get($tableName); if (!$table) { - throw new rex_exception('Table "'.$tableName.'" does not exist'); + throw new rex_exception('Table "' . $tableName . '" does not exist'); } return $table; @@ -143,7 +143,7 @@ public function getNameLocalized(): string $table_name = $this->getTableName(); $name = $this->getName(); if ($name === $table_name) { - $name = 'translate:'.$name; + $name = 'translate:' . $name; } $name = rex_i18n::translate($name); if (preg_match('/^\[translate:(.*?)\]$/', $name, $match)) { @@ -564,6 +564,6 @@ public function isGranted(string $type, rex_user $user): bool public function getCSRFKey(): string { - return 'table_field-'.$this->getTableName(); + return 'table_field-' . $this->getTableName(); } } diff --git a/plugins/manager/lib/yform/manager/table/api.php b/plugins/manager/lib/yform/manager/table/api.php index 75a93453f..92691f577 100644 --- a/plugins/manager/lib/yform/manager/table/api.php +++ b/plugins/manager/lib/yform/manager/table/api.php @@ -2,9 +2,7 @@ class rex_yform_manager_table_api { - /** - * @var array - */ + /** @var array */ public static array $table_fields = ['status', 'name', 'description', 'list_amount', 'list_sortfield', 'list_sortorder', 'prio', 'search', 'hidden', 'export', 'import', 'schema_overwrite']; public static bool $debug = false; public static array $cacheColumnsByTable = []; @@ -539,7 +537,7 @@ public static function createMissingFieldColumns(array $field): void if (!isset(self::$cacheColumnsByTable[$table_name][$fieldKey])) { $alter = rex_sql::factory(); $alter->setDebug(self::$debug); - $alter->setQuery('ALTER TABLE `' . rex_yform_manager_field::table() . '` ADD `' . $fieldKey . '` TEXT NOT NULL'); + $alter->setQuery('ALTER TABLE `' . rex_yform_manager_field::table() . '` ADD `' . $fieldKey . '` TEXT NOT NULL'); self::$cacheColumnsByTable[$table_name][$fieldKey] = [ 'name' => $fieldKey, 'type' => 'text', diff --git a/plugins/manager/lib/yform/manager/table/authorization.php b/plugins/manager/lib/yform/manager/table/authorization.php index 3af57797e..9a8286b62 100644 --- a/plugins/manager/lib/yform/manager/table/authorization.php +++ b/plugins/manager/lib/yform/manager/table/authorization.php @@ -5,12 +5,10 @@ class rex_yform_manager_table_authorization public const VIEW = 'VIEW'; public const EDIT = 'EDIT'; - /** - * @var null|array - */ + /** @var null|array */ public static ?array $tableAuthorizations = null; - public static function onAttribute(string $attribute, rex_yform_manager_table $userTable, rex_user $user = null): bool + public static function onAttribute(string $attribute, rex_yform_manager_table $userTable, ?rex_user $user = null): bool { if (null !== self::$tableAuthorizations) { if (array_key_exists($attribute, self::$tableAuthorizations[$userTable->getTableName()] ?? [])) { @@ -39,7 +37,7 @@ public static function onAttribute(string $attribute, rex_yform_manager_table $u return self::onAttribute($attribute, $userTable, $user); } - private static function canView(rex_yform_manager_table $table, rex_user $user = null): bool + private static function canView(rex_yform_manager_table $table, ?rex_user $user = null): bool { if (!$user) { return false; @@ -55,7 +53,7 @@ private static function canView(rex_yform_manager_table $table, rex_user $user = return null !== $complexPerm && $complexPerm->hasPerm($table->getTableName()); } - private static function canEdit(rex_yform_manager_table $table, rex_user $user = null): bool + private static function canEdit(rex_yform_manager_table $table, ?rex_user $user = null): bool { if (!$user) { return false; diff --git a/plugins/manager/lib/yform/manager/table/perm/edit.php b/plugins/manager/lib/yform/manager/table/perm/edit.php index bf48b3694..30584e418 100644 --- a/plugins/manager/lib/yform/manager/table/perm/edit.php +++ b/plugins/manager/lib/yform/manager/table/perm/edit.php @@ -14,7 +14,7 @@ public static function getFieldParams() { $arrayOptions = []; foreach (rex_yform_manager_table::getAll() as $table) { - $arrayOptions[$table->getTableName()] = rex_i18n::translate($table->getName()).' ['.$table->getTableName().']'; + $arrayOptions[$table->getTableName()] = rex_i18n::translate($table->getName()) . ' [' . $table->getTableName() . ']'; } return [ diff --git a/plugins/manager/lib/yform/manager/table/perm/view.php b/plugins/manager/lib/yform/manager/table/perm/view.php index dd108c639..8d4dcf114 100644 --- a/plugins/manager/lib/yform/manager/table/perm/view.php +++ b/plugins/manager/lib/yform/manager/table/perm/view.php @@ -14,7 +14,7 @@ public static function getFieldParams() { $arrayOptions = []; foreach (rex_yform_manager_table::getAll() as $table) { - $arrayOptions[$table->getTableName()] = rex_i18n::translate($table->getName()).' ['.$table->getTableName().']'; + $arrayOptions[$table->getTableName()] = rex_i18n::translate($table->getName()) . ' [' . $table->getTableName() . ']'; } return [ diff --git a/plugins/manager/lib/yform/value/be_link.php b/plugins/manager/lib/yform/value/be_link.php index 620b5431a..bae806b65 100644 --- a/plugins/manager/lib/yform/value/be_link.php +++ b/plugins/manager/lib/yform/value/be_link.php @@ -78,32 +78,32 @@ public static function isArticleInUse(rex_extension_point $ep) $article = \rex_article::get($id); if ($article) { $sql = \rex_sql::factory(); - $sql->setQuery('SELECT * FROM `'.\rex_yform_manager_field::table().'` LIMIT 0'); + $sql->setQuery('SELECT * FROM `' . \rex_yform_manager_field::table() . '` LIMIT 0'); $columns = $sql->getFieldnames(); $select = in_array('multiple', $columns) ? ', `multiple`' : ''; - $fields = $sql->getArray('SELECT `table_name`, `name`'.$select.' FROM `'.\rex_yform_manager_field::table().'` WHERE `type_id`="value" AND `type_name` IN("be_link")'); + $fields = $sql->getArray('SELECT `table_name`, `name`' . $select . ' FROM `' . \rex_yform_manager_field::table() . '` WHERE `type_id`="value" AND `type_name` IN("be_link")'); $fields = \rex_extension::registerPoint(new \rex_extension_point('YFORM_ARTICLE_IS_IN_USE', $fields)); if (count($fields)) { $tables = []; foreach ($fields as $field) { $tableName = $field['table_name']; - $condition = $sql->escapeIdentifier((string) $field['name']).' = '.$article->getId(); + $condition = $sql->escapeIdentifier((string) $field['name']) . ' = ' . $article->getId(); if (isset($field['multiple']) && 1 == $field['multiple']) { - $condition = 'FIND_IN_SET('.$article->getId().', '.$sql->escapeIdentifier((string) $field['name']).')'; + $condition = 'FIND_IN_SET(' . $article->getId() . ', ' . $sql->escapeIdentifier((string) $field['name']) . ')'; } $tables[$tableName][] = $condition; } $messages = ''; foreach ($tables as $tableName => $conditions) { - $items = $sql->getArray('SELECT `id` FROM '.$tableName.' WHERE '.implode(' OR ', $conditions)); + $items = $sql->getArray('SELECT `id` FROM ' . $tableName . ' WHERE ' . implode(' OR ', $conditions)); if (count($items)) { foreach ($items as $item) { $sqlData = \rex_sql::factory(); - $sqlData->setQuery('SELECT `name` FROM `'.\rex_yform_manager_table::table().'` WHERE `table_name` = "'.$tableName.'"'); + $sqlData->setQuery('SELECT `name` FROM `' . \rex_yform_manager_table::table() . '` WHERE `table_name` = "' . $tableName . '"'); $url = \rex_url::backendController([ 'page' => 'yform/manager/data_edit', @@ -111,7 +111,7 @@ public static function isArticleInUse(rex_extension_point $ep) 'data_id' => $item['id'], 'func' => 'edit', ]); - $messages .= '
  • '.$sqlData->getValue('name').' [id='.$item['id'].']
  • '; + $messages .= '
  • ' . $sqlData->getValue('name') . ' [id=' . $item['id'] . ']
  • '; } } } @@ -121,9 +121,9 @@ public static function isArticleInUse(rex_extension_point $ep) \rex_extension::register('PAGE_TITLE_SHOWN', static function (rex_extension_point $ep) use ($article, $messages) { $warning = $article->isStartArticle() ? \rex_i18n::msg('yform_structure_category_could_not_be_deleted') : \rex_i18n::msg('yform_structure_article_could_not_be_deleted'); - $warning .= '
      '.$messages.'
    '; + $warning .= '
      ' . $messages . '
    '; $subject = $ep->getSubject(); - $ep->setSubject(\rex_view::error($warning).$subject); + $ep->setSubject(\rex_view::error($warning) . $subject); }); } } @@ -138,7 +138,7 @@ public static function getSearchField($params) [ 'name' => $params['field']->getName(), 'label' => $params['field']->getLabel(), - ] + ], ); } diff --git a/plugins/manager/lib/yform/value/be_manager_relation.php b/plugins/manager/lib/yform/value/be_manager_relation.php index f63b5c931..b5397a1ca 100644 --- a/plugins/manager/lib/yform/value/be_manager_relation.php +++ b/plugins/manager/lib/yform/value/be_manager_relation.php @@ -558,7 +558,7 @@ public static function getListValue($params) ' SELECT ' . $sql->escapeIdentifier($relationTableFields['target']) . ' as id FROM ' . $sql->escapeIdentifier($field['relation_table']) . ' - WHERE ' . $sql->escapeIdentifier($relationTableFields['source']) . ' = ' . (int) $params['list']->getValue('id') + WHERE ' . $sql->escapeIdentifier($relationTableFields['source']) . ' = ' . (int) $params['list']->getValue('id'), ); while ($sql->hasNext()) { $id = $sql->getValue('id'); @@ -688,7 +688,7 @@ private static function getFilterArray($rawFilter, $table, callable $getValueFor $rawFilter = preg_split('/\v+/', $rawFilter); $filter = []; $setValue = static function ($key, $value) use (&$filter) { - if (false !== strpos($key, '.')) { + if (str_contains($key, '.')) { [$key1, $key2] = explode('.', $key, 2); $filter[$key1][$key2] = $value; } else { @@ -702,7 +702,7 @@ private static function getFilterArray($rawFilter, $table, callable $getValueFor $value = trim($f[1]); if (preg_match('/^###(.+)###$/', $value, $matches)) { $value = $matches[1]; - if (false !== strpos($value, '.')) { + if (str_contains($value, '.')) { $value = explode('.', $value); $relation = rex_yform_manager_table::get($table)->getRelation($value[0]); $value[0] = $getValueForKey($value[0]); @@ -770,7 +770,7 @@ protected function getRelationTableValues() ' SELECT ' . $sql->escapeIdentifier($relationTableFields['target']) . ' as id FROM ' . $sql->escapeIdentifier($this->getElement('relation_table')) . ' - WHERE ' . $sql->escapeIdentifier($relationTableFields['source']) . ' = ' . (int) $this->params['main_id'] + WHERE ' . $sql->escapeIdentifier($relationTableFields['source']) . ' = ' . (int) $this->params['main_id'], ); while ($sql->hasNext()) { $id = $sql->getValue('id'); @@ -841,7 +841,7 @@ public static function getSearchFilter($params) $sql = rex_sql::factory(); if (!$field->getElement('relation_table')) { - return $query->whereListContains($query->getTableAlias().'.'.$field->getName(), $values); + return $query->whereListContains($query->getTableAlias() . '.' . $field->getName(), $values); } $relationTableFields = self::getRelationTableFieldsForTables($field->getElement('table_name'), $field->getElement('relation_table'), $field->getElement('table')); @@ -855,16 +855,16 @@ public static function getSearchFilter($params) $exists = []; foreach ($values as $value) { - $exists[] = '('.sprintf( + $exists[] = '(' . sprintf( 'EXISTS (SELECT * FROM %s WHERE %1$s.%s = t0.id AND %1$s.%s = %d)', $sql->escapeIdentifier($field->getElement('relation_table')), $sql->escapeIdentifier($relationTableFields['source']), $sql->escapeIdentifier($relationTableFields['target']), - (int) $value - ).')'; + (int) $value, + ) . ')'; } - $query->whereRaw('('.implode(' OR ', $exists).')'); + $query->whereRaw('(' . implode(' OR ', $exists) . ')'); } return $query; } diff --git a/plugins/manager/lib/yform/value/be_media.php b/plugins/manager/lib/yform/value/be_media.php index cbbe4932f..d9da4e0ce 100644 --- a/plugins/manager/lib/yform/value/be_media.php +++ b/plugins/manager/lib/yform/value/be_media.php @@ -38,7 +38,7 @@ public function enterObject() if (!$this->isEditable()) { $this->params['form_output'][$this->getId()] = $this->parse( ['value.view.tpl.php', 'value.be_media-view.tpl.php'], - ['counter' => $counter, 'value' => explode(',', $this->getValue()), 'types' => $types] + ['counter' => $counter, 'value' => explode(',', $this->getValue()), 'types' => $types], ); } else { $this->params['form_output'][$this->getId()] = $this->parse('value.be_media.tpl.php', compact('counter', 'types')); @@ -115,12 +115,12 @@ public static function isMediaInUse(rex_extension_point $ep) $warning = $ep->getSubject(); $sql = \rex_sql::factory(); - $sql->setQuery('SELECT * FROM `'.\rex_yform_manager_field::table().'` LIMIT 0'); + $sql->setQuery('SELECT * FROM `' . \rex_yform_manager_field::table() . '` LIMIT 0'); $columns = $sql->getFieldnames(); $select = in_array('multiple', $columns) ? ', `multiple`' : ''; - $fields = $sql->getArray('SELECT `table_name`, `name`'.$select.' FROM `'.\rex_yform_manager_field::table().'` WHERE `type_id`="value" AND `type_name` IN("be_media")'); + $fields = $sql->getArray('SELECT `table_name`, `name`' . $select . ' FROM `' . \rex_yform_manager_field::table() . '` WHERE `type_id`="value" AND `type_name` IN("be_media")'); $fields = \rex_extension::registerPoint(new \rex_extension_point('YFORM_MEDIA_IS_IN_USE', $fields)); if (!count($fields)) { @@ -131,29 +131,29 @@ public static function isMediaInUse(rex_extension_point $ep) $escapedFilename = $sql->escape($params['filename']); foreach ($fields as $field) { $tableName = $field['table_name']; - $condition = $sql->escapeIdentifier((string) $field['name']).' = '.$escapedFilename; + $condition = $sql->escapeIdentifier((string) $field['name']) . ' = ' . $escapedFilename; if (isset($field['multiple']) && 1 == $field['multiple']) { - $condition = 'FIND_IN_SET('.$escapedFilename.', '.$sql->escapeIdentifier((string) $field['name']).')'; + $condition = 'FIND_IN_SET(' . $escapedFilename . ', ' . $sql->escapeIdentifier((string) $field['name']) . ')'; } $tables[$tableName][] = $condition; } $messages = ''; foreach ($tables as $tableName => $conditions) { - $items = $sql->getArray('SELECT `id` FROM '.$tableName.' WHERE '.implode(' OR ', $conditions)); + $items = $sql->getArray('SELECT `id` FROM ' . $tableName . ' WHERE ' . implode(' OR ', $conditions)); if (count($items)) { foreach ($items as $item) { $sqlData = \rex_sql::factory(); - $sqlData->setQuery('SELECT `name` FROM `'.\rex_yform_manager_table::table().'` WHERE `table_name` = "'.$tableName.'"'); + $sqlData->setQuery('SELECT `name` FROM `' . \rex_yform_manager_table::table() . '` WHERE `table_name` = "' . $tableName . '"'); - $messages .= '
  • '.$sqlData->getValue('name').' [id='.$item['id'].']
  • '; + $messages .= '
  • ' . $sqlData->getValue('name') . ' [id=' . $item['id'] . ']
  • '; } } } if ('' != $messages) { - $warning[] = 'Tabelle
      '.$messages.'
    '; + $warning[] = 'Tabelle
      ' . $messages . '
    '; } return $warning; diff --git a/plugins/manager/lib/yform/value/be_table.php b/plugins/manager/lib/yform/value/be_table.php index 70ee636a3..f34348c43 100644 --- a/plugins/manager/lib/yform/value/be_table.php +++ b/plugins/manager/lib/yform/value/be_table.php @@ -27,7 +27,7 @@ public function preValidateAction(): void $id = $this->getName(); - $columns = preg_split("/(?<=[^\w\"]),|,(?=\{)|(?<=[A-Za-z]),(?=[^ ][\w,])|(?<=,\w),/", $this->getElement('columns')); + $columns = preg_split('/(?<=[^\\w"]),|,(?=\\{)|(?<=[A-Za-z]),(?=[^ ][\\w,])|(?<=,\\w),/', $this->getElement('columns')); if (0 == count($columns)) { return; } @@ -52,14 +52,14 @@ public static function getColumnsByName($definition) { $valueFields = []; $validateFields = []; - $_columns = preg_split("/(?<=[^\w\"]),|,(?=\{)|(?<=[A-Za-z]),(?=[^ ][\w,])|(?<=,\w),/", $definition); + $_columns = preg_split('/(?<=[^\\w"]),|,(?=\\{)|(?<=[A-Za-z]),(?=[^ ][\\w,])|(?<=,\\w),/', $definition); if (count($_columns)) { foreach ($_columns as $index => $col) { // Use ;; for separating choice columns instead of , $values = explode('|', trim(trim(str_replace(';;', ',', rex_yform::unhtmlentities($col))), '|')); if (1 == count($values)) { - $values = ['text', 'text_'. $index, $values[0]]; + $values = ['text', 'text_' . $index, $values[0]]; } $class = 'rex_yform_value_' . trim($values[0]); diff --git a/plugins/manager/lib/yform/value/be_user.php b/plugins/manager/lib/yform/value/be_user.php index 31f7fe2de..be91d5062 100644 --- a/plugins/manager/lib/yform/value/be_user.php +++ b/plugins/manager/lib/yform/value/be_user.php @@ -26,15 +26,15 @@ public function enterObject() // always change. update $value = $user_login; if ('' != $showValue) { - $showValue = rex_i18n::msg('yform_is').': '.$showValue."\n"; + $showValue = rex_i18n::msg('yform_is') . ': ' . $showValue . "\n"; } - $showValue .= rex_i18n::msg('yform_will_set_to').': '.$value; + $showValue .= rex_i18n::msg('yform_will_set_to') . ': ' . $value; break; case '1': // if empty / bei create if ('' == $showValue) { $value = $user_login; - $showValue = rex_i18n::msg('yform_will_set_to').': '.$value; + $showValue = rex_i18n::msg('yform_will_set_to') . ': ' . $value; } break; default: diff --git a/plugins/manager/lib/yform/value/prio.php b/plugins/manager/lib/yform/value/prio.php index 8a1d34dfc..3a591d863 100644 --- a/plugins/manager/lib/yform/value/prio.php +++ b/plugins/manager/lib/yform/value/prio.php @@ -41,7 +41,7 @@ public function enterObject() implode(', ', $selectFields), $this->getElement('name'), $this->params['main_table'], - $scopeWhere + $scopeWhere, )); $prio = 1; while ($sql->hasNext()) { @@ -133,7 +133,7 @@ public function postAction(): void $this->params['main_table'], $this->getElement('name'), $scopeWhere, - $this->params['main_id'] + $this->params['main_id'], )); } @@ -162,7 +162,7 @@ protected function getScopeWhere() 'SELECT `%s` FROM `%s` WHERE id = %d', $column, $this->params['main_table'], - $this->params['main_id'] + $this->params['main_id'], )); $value = $sql->getValue($column); } diff --git a/plugins/manager/pages/data_edit.php b/plugins/manager/pages/data_edit.php index 2aaed594e..ba59eb66d 100644 --- a/plugins/manager/pages/data_edit.php +++ b/plugins/manager/pages/data_edit.php @@ -19,7 +19,7 @@ $page->setLinkVars(['page' => rex_be_controller::getCurrentPage(), 'table_name' => $table->getTableName()]); echo $page->getDataPage(); } catch (Exception $e) { - echo rex_view::warning(nl2br($e->getMessage()."\n".$e->getTraceAsString())); + echo rex_view::warning(nl2br($e->getMessage() . "\n" . $e->getTraceAsString())); } } else { if (!$table) { diff --git a/plugins/manager/pages/data_export.php b/plugins/manager/pages/data_export.php index c21488b06..3a8eae4bb 100644 --- a/plugins/manager/pages/data_export.php +++ b/plugins/manager/pages/data_export.php @@ -5,15 +5,15 @@ * @psalm-scope-this rex_yform_manager */ -$rex_yform_filter = $rex_yform_filter ?? []; -$rex_yform_set = $rex_yform_set ?? []; -$searchObject = $searchObject ?? null; +$rex_yform_filter ??= []; +$rex_yform_set ??= []; +$searchObject ??= null; $query = $this ->table ->query() ->alias('t0'); -$query = $this->getDataListQuery($query, array_merge( $rex_yform_filter, $rex_yform_set), $searchObject); +$query = $this->getDataListQuery($query, array_merge($rex_yform_filter, $rex_yform_set), $searchObject); $query = rex_extension::registerPoint(new rex_extension_point('YFORM_DATA_TABLE_EXPORT', $query, ['filter' => $rex_yform_filter, 'set' => $rex_yform_set, 'searchObject' => $searchObject])); $fields = ['id' => '"id"']; @@ -32,9 +32,9 @@ $exportDataset[] = implode(';', $exportData); } -$fileContent = pack('CCC', 0xef, 0xbb, 0xbf); +$fileContent = pack('CCC', 0xEF, 0xBB, 0xBF); $fileContent .= implode(';', $fields); -$fileContent .= "\n".implode("\n", $exportDataset); +$fileContent .= "\n" . implode("\n", $exportDataset); $fileName = 'export_data_' . date('YmdHis') . '.csv'; header('Content-Disposition: attachment; filename="' . $fileName . '"; charset=utf-8'); diff --git a/plugins/manager/pages/data_history.php b/plugins/manager/pages/data_history.php index a93014b21..b735133da 100644 --- a/plugins/manager/pages/data_history.php +++ b/plugins/manager/pages/data_history.php @@ -1,14 +1,12 @@ ' . rex_i18n::msg('yform_history_dataset_id') .': ' . $datasetId); - $filterWhere = ' AND dataset_id = '.$datasetId; + echo rex_view::info('' . rex_i18n::msg('yform_history_dataset_id') . ': ' . $datasetId); + $filterWhere = ' AND dataset_id = ' . $datasetId; } if ($historySearchId) { @@ -64,7 +62,7 @@ } $value = $data[$field->getName()]; - $class = 'rex_yform_value_'.$field->getTypeName(); + $class = 'rex_yform_value_' . $field->getTypeName(); if (method_exists($class, 'getListValue')) { $value = $class::getListValue([ 'value' => $value, @@ -81,8 +79,8 @@ $rows .= ' - '.$field->getLabel().' - '.$value.' + ' . $field->getLabel() . ' + ' . $value . ' '; } @@ -90,19 +88,19 @@ '; @@ -117,11 +115,11 @@ } else { $error = '
      '; foreach ($dataset->getMessages() as $msg) { - $error .= '
    • '.rex_i18n::translate($msg).'
    • '; + $error .= '
    • ' . rex_i18n::translate($msg) . '
    • '; } $error .= '
    '; - echo rex_view::error(rex_i18n::msg('yform_history_restore_error').'
    '.$error); + echo rex_view::error(rex_i18n::msg('yform_history_restore_error') . '
    ' . $error); } } @@ -139,7 +137,7 @@ LEFT JOIN %s hf ON hf.history_id = h.id WHERE h.table_name = ? %s ', rex::getTable('yform_history'), rex::getTable('yform_history_field'), $where), - [$this->table->getTableName()] + [$this->table->getTableName()], ); echo rex_view::success(rex_i18n::msg('yform_history_delete_success')); @@ -151,18 +149,18 @@ h.id, dataset_id, id as title, `action`, `user`, `timestamp` - FROM '.rex::getTable('yform_history').' h + FROM ' . rex::getTable('yform_history') . ' h WHERE - `table_name` = '.$sql->escape($this->table->getTableName()). - $filterWhere.' + `table_name` = ' . $sql->escape($this->table->getTableName()) . + $filterWhere . ' GROUP BY h.id ORDER BY `timestamp` DESC'; $userQuery = 'SELECT distinct `user` - FROM '.rex::getTable('yform_history').' h + FROM ' . rex::getTable('yform_history') . ' h WHERE - `table_name` = '.$sql->escape($this->table->getTableName()); + `table_name` = ' . $sql->escape($this->table->getTableName()); $list = rex_list::factory($listQuery); @@ -199,14 +197,14 @@ $list->setColumnLabel('dataset_id', rex_i18n::msg('yform_history_dataset_id')); $list->setColumnLabel('title', rex_i18n::msg('yform_history_dataset')); $list->setColumnFormat('title', 'custom', static function (array $params) { - $result = rex_sql::factory()->getArray('select * from '.rex::getTable('yform_history_field').' where history_id=:history_id and field IN ("title", "titel", "name", "last_name") LIMIT 1', [ + $result = rex_sql::factory()->getArray('select * from ' . rex::getTable('yform_history_field') . ' where history_id=:history_id and field IN ("title", "titel", "name", "last_name") LIMIT 1', [ 'history_id' => $params['value'], ]); $title = '[no title found]'; if (isset($result[0])) { $title = $result[0]['value']; if (mb_strlen($title) > 50) { - $title = substr($title, 0, 50). '…'; + $title = substr($title, 0, 50) . '…'; } } return rex_escape($title); @@ -220,7 +218,7 @@ rex_yform_manager_dataset::ACTION_DELETE => 'danger', ]; $class = $classes[$params['subject']] ?? 'default'; - return sprintf('%s', $class, rex_i18n::msg('yform_history_action_'.$params['subject'])); + return sprintf('%s', $class, rex_i18n::msg('yform_history_action_' . $params['subject'])); }); $list->setColumnLabel('user', rex_i18n::msg('yform_history_user')); @@ -230,12 +228,12 @@ return (new DateTime($params['subject']))->format('d.m.Y H:i:s'); }); -$list->addColumn('view', ' '.rex_i18n::msg('yform_history_view'), -1, ['', '###VALUE###']); +$list->addColumn('view', ' ' . rex_i18n::msg('yform_history_view'), -1, ['', '###VALUE###']); $list->setColumnParams('view', ['subfunc' => 'view', 'data_id' => '###dataset_id###', 'history_id' => '###id###']); $list->addLinkAttribute('view', 'data-toggle', 'modal'); $list->addLinkAttribute('view', 'data-target', '#rex-yform-history-modal'); -$list->addColumn('restore', ' '.rex_i18n::msg('yform_history_restore'), -1, ['', '###VALUE###']); +$list->addColumn('restore', ' ' . rex_i18n::msg('yform_history_restore'), -1, ['', '###VALUE###']); $list->setColumnParams('restore', ['subfunc' => 'restore', 'data_id' => '###dataset_id###', 'history_id' => '###id###'] + rex_csrf_token::factory($_csrf_key)->getUrlParams()); $content = $list->get(); @@ -292,9 +290,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), + 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), ], ]); @@ -303,7 +301,7 @@ 'label' => 'User', 'choices' => array_merge( ['' => rex_i18n::msg('yform_manager_users_all')], - $users + $users, ), ]); diff --git a/plugins/manager/pages/data_import.php b/plugins/manager/pages/data_import.php index 55c01931a..fcd98171b 100644 --- a/plugins/manager/pages/data_import.php +++ b/plugins/manager/pages/data_import.php @@ -9,7 +9,7 @@ * @var rex_yform_manager $this */ -$_csrf_key = $_csrf_key ?? ''; +$_csrf_key ??= ''; $show_importform = true; $show_list = false; @@ -70,7 +70,7 @@ 'filename' => $filename, 'missing_columns' => $missing_columns, 'debug' => $debug, - ] + ], )); if ($import_start) { @@ -137,7 +137,7 @@ ->setValue('type_id', 'value') ->setValue('type_name', 'text') ->setValue('name', $mcc) - ->setValue('label', 'TEXT `'.$mcc.'`') + ->setValue('label', 'TEXT `' . $mcc . '`') ->setValue('list_hidden', 0) ->setValue('db_type', 'text') ->insert(); @@ -203,8 +203,8 @@ $messages[$key] = $msg; } ++$dcounter; - $dataId = 'ID: '.$id; - echo rex_view::error(rex_i18n::msg('yform_manager_import_error_dataimport', $dataId, '
    * ' .implode('
    * ', $messages))); + $dataId = 'ID: ' . $id; + echo rex_view::error(rex_i18n::msg('yform_manager_import_error_dataimport', $dataId, '
    * ' . implode('
    * ', $messages))); } elseif ($exists) { ++$rcounter; } else { @@ -230,7 +230,7 @@ 'data_replaced' => $rcounter, // replace counter 'data_inserted' => $icounter, // insert counter 'data_errors' => $errorcounter, - ] + ], )); $sql_db->commit(); } catch (\Throwable $e) { @@ -312,7 +312,7 @@ $n = []; $n['label'] = ''; $n['field'] = '' - .rex_csrf_token::factory($_csrf_key)->getHiddenField(); + . rex_csrf_token::factory($_csrf_key)->getHiddenField(); $formElements[] = $n; $fragment = new rex_fragment(); diff --git a/plugins/manager/pages/table_edit.php b/plugins/manager/pages/table_edit.php index 1a02f9bdc..d79fdb996 100644 --- a/plugins/manager/pages/table_edit.php +++ b/plugins/manager/pages/table_edit.php @@ -88,7 +88,7 @@ $yform->setObjectparams('main_table', rex_yform_manager_table::table()); $yform->setValueField('html', ['html' => '
    ']); - $yform->setValueField('html', ['html' => '']); + $yform->setValueField('html', ['html' => '']); $yform->setValueField('checkbox', ['status', rex_i18n::msg('yform_tbl_active')]); $yform->setValueField('prio', ['prio', rex_i18n::msg('yform_manager_table_prio'), 'name']); @@ -97,9 +97,9 @@ $yform->setObjectparams('submit_btn_label', rex_i18n::msg('yform_update_table')); $yform->setValueField('showvalue', ['table_name', rex_i18n::msg('yform_manager_table_name')]); $yform->setHiddenField('table_id', $table->getId()); - $yform->setActionField('db', [rex_yform_manager_table::table(), 'id='.$table->getId()]); + $yform->setActionField('db', [rex_yform_manager_table::table(), 'id=' . $table->getId()]); $yform->setObjectparams('main_id', $table->getId()); - $yform->setObjectparams('main_where', 'id='.$table->getId()); + $yform->setObjectparams('main_where', 'id=' . $table->getId()); $yform->setObjectparams('getdata', true); break; case 'add': @@ -120,18 +120,18 @@ $yform->setValueField('text', ['name', rex_i18n::msg('yform_manager_name')]); $yform->setValidateField('empty', ['name', rex_i18n::msg('yform_manager_table_enter_name')]); - $yform->setValueField('textarea', ['description', '
    '.rex_i18n::msg('yform_manager_table_description'), 'attributes' => '{"class":"form-control yform-textarea-short"}']); + $yform->setValueField('textarea', ['description', '
    ' . rex_i18n::msg('yform_manager_table_description'), 'attributes' => '{"class":"form-control yform-textarea-short"}']); $yform->setValueField('html', ['html' => '
    ']); - $yform->setValueField('html', ['html' => '']); + $yform->setValueField('html', ['html' => '']); $yform->setValueField('checkbox', ['search', rex_i18n::msg('yform_manager_search_active')]); $yform->setValueField('checkbox', ['hidden', rex_i18n::msg('yform_manager_table_hide')]); $yform->setValueField('checkbox', ['history', rex_i18n::msg('yform_manager_table_history')]); $yform->setValueField('checkbox', ['schema_overwrite', rex_i18n::msg('yform_manager_table_schema_overwrite'), 'default' => true]); - $yform->setValueField('html', ['html' => '']); + $yform->setValueField('html', ['html' => '']); $yform->setValueField('checkbox', ['export', rex_i18n::msg('yform_manager_table_allow_export')]); $yform->setValueField('checkbox', ['import', rex_i18n::msg('yform_manager_table_allow_import')]); @@ -140,7 +140,7 @@ $yform->setValueField('html', ['html' => '']); - $yform->setValueField('text', ['name' => 'list_amount', 'label' => '
    '.rex_i18n::msg('yform_manager_entries_per_page'), 'default' => '50']); + $yform->setValueField('text', ['name' => 'list_amount', 'label' => '
    ' . rex_i18n::msg('yform_manager_entries_per_page'), 'default' => '50']); $yform->setValidateField('type', ['list_amount', 'int', rex_i18n::msg('yform_manager_enter_number')]); $sortFields = ['id']; @@ -191,7 +191,7 @@ $fragment->setVar('buttons', [ [ 'label' => rex_i18n::msg('yform_edit'), - 'url' => 'index.php?page=yform/manager/table_field&table_name='.$table->getTableName(), + 'url' => 'index.php?page=yform/manager/table_field&table_name=' . $table->getTableName(), 'attributes' => [ 'class' => [ 'btn-default', @@ -201,7 +201,7 @@ ], false); $panel_options .= '' . rex_i18n::msg('yform_manager_fields') . ' ' . $fragment->parse('core/buttons/button_group.php'); - $title = rex_i18n::msg('yform_manager_edit_table'). ' `'.$table->getTableName().'`'; + $title = rex_i18n::msg('yform_manager_edit_table') . ' `' . $table->getTableName() . '`'; } else { $title = rex_i18n::msg('yform_manager_add_table'); } @@ -341,19 +341,19 @@ function rex_yform_list_translate($params) $list->setColumnFormat('name', 'custom', static function ($params) { $name = $params['value']; if ($name === $params['list']->getValue('table_name')) { - $name = 'translate:'.$name; + $name = 'translate:' . $name; } $name = rex_i18n::translate($name); if (preg_match('/^\[translate:(.*?)\]$/', $name, $match)) { $name = $match[1]; } - return $name.'

    '.rex_i18n::msg('yform_edit_datatable').'

    '; + return $name . '

    ' . rex_i18n::msg('yform_edit_datatable') . '

    '; }); $list->setColumnLabel('table_name', rex_i18n::msg('yform_manager_table_name')); $list->setColumnFormat('table_name', 'custom', static function ($params) { $name = $params['value']; - return $name.'

    '.rex_i18n::msg('yform_manager_edit_table').'

    '; + return $name . '

    ' . rex_i18n::msg('yform_manager_edit_table') . '

    '; }); $list->setColumnLabel('status', rex_i18n::msg('yform_manager_table_status')); diff --git a/plugins/manager/pages/table_field.php b/plugins/manager/pages/table_field.php index 934ec3ade..b79a1d63f 100644 --- a/plugins/manager/pages/table_field.php +++ b/plugins/manager/pages/table_field.php @@ -19,7 +19,7 @@ $page->setLinkVars(['page' => 'yform/manager/table_field']); echo $page->getFieldPage(); } catch (Exception $e) { - $message = nl2br($e->getMessage()."\n".$e->getTraceAsString()); + $message = nl2br($e->getMessage() . "\n" . $e->getTraceAsString()); echo rex_view::warning($message); } } else { diff --git a/plugins/manager/pages/tableset_export.php b/plugins/manager/pages/tableset_export.php index cdde63a48..5201dc7da 100644 --- a/plugins/manager/pages/tableset_export.php +++ b/plugins/manager/pages/tableset_export.php @@ -15,7 +15,7 @@ $yform_tables = []; foreach (rex_yform_manager_table::getAll() as $g_table) { $table_name = $g_table->getTableName(); - $yform_tables[$table_name] = rex_i18n::translate($g_table->getNameLocalized()).' ['.$table_name.']'; + $yform_tables[$table_name] = rex_i18n::translate($g_table->getNameLocalized()) . ' [' . $table_name . ']'; } $yform = new rex_yform(); @@ -33,10 +33,10 @@ $tablenames = implode('_', $table_names); if (mb_strlen($tablenames) > 100) { - $tables = mb_substr($tablenames, 0, 100).'_etc_'; + $tables = mb_substr($tablenames, 0, 100) . '_etc_'; } - $fileName = 'yform_manager_tableset_export_tables_'.$tablenames.'_'.date('YmdHis').'.json'; + $fileName = 'yform_manager_tableset_export_tables_' . $tablenames . '_' . date('YmdHis') . '.json'; header('Content-Disposition: attachment; filename="' . $fileName . '"; charset=utf-8'); rex_response::sendContent($fileContent, 'application/octetstream'); exit; diff --git a/plugins/manager/update.php b/plugins/manager/update.php index c958b0b1e..b9438c13a 100644 --- a/plugins/manager/update.php +++ b/plugins/manager/update.php @@ -5,4 +5,4 @@ * @psalm-scope-this rex_plugin */ -$this->includeFile(__DIR__.'/install.php'); +$this->includeFile(__DIR__ . '/install.php'); diff --git a/plugins/manager/ytemplates/bootstrap/value.be_link.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_link.tpl.php index d6b921c7b..b08d25bfc 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_link.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_link.tpl.php @@ -5,9 +5,9 @@ * @psalm-scope-this rex_yform_value_be_link */ -$counter = $counter ?? 1; +$counter ??= 1; -$buttonId = 'yf_'.uniqid().'_'.$counter; +$buttonId = 'yf_' . uniqid() . '_' . $counter; $categoryId = 0; $name = $this->getFieldName(); $value = rex_escape($this->getValue() ?? ''); @@ -34,8 +34,8 @@ } ?> -
    - - - +
    + + +
    diff --git a/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation-view.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation-view.tpl.php index 4ad947a85..61575f087 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation-view.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation-view.tpl.php @@ -5,21 +5,21 @@ * @psalm-scope-this rex_yform_value_be_manager_relation */ -$fieldkey = $fieldkey ?? ''; -$forms = $forms ?? []; -$relationKey = $relationKey ?? ''; +$fieldkey ??= ''; +$forms ??= []; +$relationKey ??= ''; $class_group = trim('form-group ' . $this->getHTMLClass()); // . ' ' . $this->getWarningClass() $id = sprintf('%u', crc32($this->params['form_name'])) . random_int(0, 10000) . $this->getId(); -$fieldkey = 'y'.sha1($fieldkey.'-'.rex_escape($relationKey)); // no number first +$fieldkey = 'y' . sha1($fieldkey . '-' . rex_escape($relationKey)); // no number first echo ' -
    - -
    '; +
    + +
    '; $counter = 1; foreach ($forms as $form) { - $counterfieldkey = $fieldkey.'-'.$counter; + $counterfieldkey = $fieldkey . '-' . $counter; echo '
    ' . $form . '
    '; diff --git a/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation.tpl.php index 79db228a1..19e782ff8 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation.tpl.php @@ -5,11 +5,11 @@ * @psalm-scope-this rex_yform_value_be_manager_relation */ -$fieldkey = $fieldkey ?? 1; -$relationKey = $relationKey ?? 1; -$prototypeForm = $prototypeForm ?? ''; -$forms = $forms ?? []; -$prioFieldName = $prioFieldName ?? ''; +$fieldkey ??= 1; +$relationKey ??= 1; +$prototypeForm ??= ''; +$forms ??= []; +$prioFieldName ??= ''; $class_group = trim('form-group ' . $this->getHTMLClass()); // . ' ' . $this->getWarningClass() @@ -26,31 +26,31 @@ $notice = ''; } -$prototypeForm = $this->parse('value.be_manager_inline_relation_form.tpl.php', ['counterfieldkey' => $fieldkey.'-'.rex_escape($relationKey), 'form' => $prototypeForm, 'prioFieldName' => $prioFieldName]); +$prototypeForm = $this->parse('value.be_manager_inline_relation_form.tpl.php', ['counterfieldkey' => $fieldkey . '-' . rex_escape($relationKey), 'form' => $prototypeForm, 'prioFieldName' => $prioFieldName]); $sortable = 'data-yform-be-relation-sortable'; if ('' == $prioFieldName) { $sortable = ''; } -$fieldkey = 'y'.sha1($fieldkey.'-'.rex_escape($relationKey)); // no number first +$fieldkey = 'y' . sha1($fieldkey . '-' . rex_escape($relationKey)); // no number first echo ' -
    - -
    '; +
    + +
    '; $counter = 1; foreach ($forms as $form) { - echo $this->parse('value.be_manager_inline_relation_form.tpl.php', ['counterfieldkey' => $fieldkey.'-'.$counter, 'form' => $form, 'prioFieldName' => $prioFieldName]); + echo $this->parse('value.be_manager_inline_relation_form.tpl.php', ['counterfieldkey' => $fieldkey . '-' . $counter, 'form' => $form, 'prioFieldName' => $prioFieldName]); ++$counter; } echo '
    - +
    - '.$notice.' + ' . $notice . '
    '; diff --git a/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation_form.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation_form.tpl.php index aa218d440..cc08766ef 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation_form.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_manager_inline_relation_form.tpl.php @@ -1,8 +1,8 @@
    - +
    ' . $sortButtons . ' diff --git a/plugins/manager/ytemplates/bootstrap/value.be_media.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_media.tpl.php index 113117450..86182e352 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_media.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_media.tpl.php @@ -5,17 +5,17 @@ * @psalm-scope-this rex_yform_value_be_media */ -$counter = $counter ?? 1; +$counter ??= 1; $buttonId = $counter; $name = $this->getFieldName(); $value = rex_escape($this->getValue()); -$types = $types ?? $this->getElement('types'); +$types ??= $this->getElement('types'); $widget_params = []; $widget_params['category'] = 0; if ('' != $this->getElement('category')) { - $widget_params['category'] = (int) ($this->getElement('category')); + $widget_params['category'] = (int) $this->getElement('category'); } $widget_params['preview'] = $this->getElement('preview'); if ('' != $types) { @@ -44,8 +44,8 @@ } ?> -
    - - - +
    + + +
    diff --git a/plugins/manager/ytemplates/bootstrap/value.be_table-view.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_table-view.tpl.php index 358be2bd4..f2164b5f9 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_table-view.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_table-view.tpl.php @@ -5,8 +5,8 @@ * @psalm-scope-this rex_yform_value_be_table */ -$columns = $columns ?? []; -$data = $data ?? []; +$columns ??= []; +$data ??= []; $class_group = trim('form-group ' . $this->getHTMLClass() . ' ' . $this->getWarningClass()); @@ -29,12 +29,12 @@ ?>
    - + - + @@ -72,5 +72,5 @@
    - +
    diff --git a/plugins/manager/ytemplates/bootstrap/value.be_table.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_table.tpl.php index f712bcb0c..ef8f103e9 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_table.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_table.tpl.php @@ -5,8 +5,8 @@ * @psalm-scope-this rex_yform_value_be_table */ -$columns = $columns ?? []; -$data = $data ?? []; +$columns ??= []; +$data ??= []; $class_group = trim('form-group ' . $this->getHTMLClass() . ' ' . $this->getWarningClass()); @@ -29,14 +29,14 @@ ?>
    - + - + - + @@ -68,16 +68,16 @@ ?> - +
    - + - - +
    diff --git a/plugins/rest/lib/rest.php b/plugins/rest/lib/rest.php index 52515972f..19e414ead 100644 --- a/plugins/rest/lib/rest.php +++ b/plugins/rest/lib/rest.php @@ -22,9 +22,6 @@ class rex_yform_rest protected static $additionalHeaders = []; protected static $routes = []; - /** - * @param $route - */ public static function addRoute(rex_yform_rest_route $route) { self::$routes[] = $route; @@ -114,8 +111,6 @@ public static function sendError($status = '404', $error = 'error', $description } /** - * @param $status - * @param $content * @param string $contentType */ public static function sendContent($status, $content, $contentType = 'application/json') @@ -193,12 +188,11 @@ public static function getLinkByPath(rex_yform_rest_route $route, $params = [], } /** - * @param $instance * @return null|mixed */ public static function getRouteByInstance($instance) { - $instanceType = get_class($instance); + $instanceType = $instance::class; foreach (self::$routes as $route) { if ($route->type == $instanceType) { diff --git a/plugins/rest/lib/rest/auth/auth.php b/plugins/rest/lib/rest/auth/auth.php index 0e2460d0b..d9a56a9cd 100644 --- a/plugins/rest/lib/rest/auth/auth.php +++ b/plugins/rest/lib/rest/auth/auth.php @@ -12,15 +12,13 @@ class rex_yform_rest_auth_token public static $tokenList = []; /** - * @param rex_yform_rest_route $route * @throws rex_sql_exception - * @return bool */ public static function checkToken(rex_yform_rest_route $route): bool { $myToken = rex_yform_rest::getHeader('token'); - $TokenAuths = rex_sql::factory()->getArray('select * from '.rex::getTable('yform_rest_token').' where status=1 and token=? and FIND_IN_SET(?, paths)', [$myToken, $route->getPath()]); + $TokenAuths = rex_sql::factory()->getArray('select * from ' . rex::getTable('yform_rest_token') . ' where status=1 and token=? and FIND_IN_SET(?, paths)', [$myToken, $route->getPath()]); if (1 != count($TokenAuths)) { return false; @@ -51,7 +49,6 @@ public static function checkToken(rex_yform_rest_route $route): bool } /** - * @param array $TokenAuth * @throws rex_sql_exception */ public static function addHit(array $TokenAuth) @@ -65,14 +62,13 @@ public static function addHit(array $TokenAuth) } /** - * @param int $id * @throws rex_sql_exception * @return null|mixed */ public static function get(int $id) { if (0 == count(self::$tokenList)) { - self::$tokenList = rex_sql::factory()->getArray('select * from '.rex::getTable('yform_rest_token')); + self::$tokenList = rex_sql::factory()->getArray('select * from ' . rex::getTable('yform_rest_token')); } foreach (self::$tokenList as $token) { @@ -84,8 +80,6 @@ public static function get(int $id) } /** - * @param string $interval - * @param $token_id * @throws rex_sql_exception * @return null|mixed */ @@ -93,17 +87,17 @@ public static function getCurrentIntervalAmount(string $interval, $token_id) { switch ($interval) { case 'month': - $count = rex_sql::factory()->setQuery('select count(*) as c from '.rex::getTable('yform_rest_token_access').' where token_id = ? and datetime_created LIKE ?', [$token_id, date('Y-m-').'%']); + $count = rex_sql::factory()->setQuery('select count(*) as c from ' . rex::getTable('yform_rest_token_access') . ' where token_id = ? and datetime_created LIKE ?', [$token_id, date('Y-m-') . '%']); break; case 'day': - $count = rex_sql::factory()->setQuery('select count(*) as c from '.rex::getTable('yform_rest_token_access').' where token_id = ? and datetime_created LIKE ?', [$token_id, date('Y-m-d ').'%']); + $count = rex_sql::factory()->setQuery('select count(*) as c from ' . rex::getTable('yform_rest_token_access') . ' where token_id = ? and datetime_created LIKE ?', [$token_id, date('Y-m-d ') . '%']); break; case 'hour': - $count = rex_sql::factory()->setQuery('select count(*) as c from '.rex::getTable('yform_rest_token_access').' where token_id = ? and datetime_created LIKE ?', [$token_id, date('Y-m-d H:').'%']); + $count = rex_sql::factory()->setQuery('select count(*) as c from ' . rex::getTable('yform_rest_token_access') . ' where token_id = ? and datetime_created LIKE ?', [$token_id, date('Y-m-d H:') . '%']); break; case 'overall': default: - $count = rex_sql::factory()->setQuery('select count(*) as c from '.rex::getTable('yform_rest_token_access').' where token_id = ?', [$token_id]); + $count = rex_sql::factory()->setQuery('select count(*) as c from ' . rex::getTable('yform_rest_token_access') . ' where token_id = ?', [$token_id]); break; } diff --git a/plugins/rest/lib/rest/route.php b/plugins/rest/lib/rest/route.php index d245d6ae0..686fcd414 100644 --- a/plugins/rest/lib/rest/route.php +++ b/plugins/rest/lib/rest/route.php @@ -41,8 +41,6 @@ public function setHeader(string $name, string $value) } /** - * @param $status - * @param $content * @param string $contentType */ public function sendContent($status, $content, $contentType = 'application/json') @@ -75,8 +73,6 @@ public function getPath() } /** - * @param $paths - * @param $get * @throws rex_api_exception */ public function handleRequest(array $paths, array $get) @@ -180,7 +176,7 @@ public function handleRequest(array $paths, array $get) $id = $path; $id_column = 'id'; if ('' != $query->getTableAlias()) { - $id_column = $query->getTableAlias().'.id'; + $id_column = $query->getTableAlias() . '.id'; } $query @@ -217,7 +213,7 @@ public function handleRequest(array $paths, array $get) foreach ($instances as $instance) { $data[] = $this->getInstanceData( $instance, - array_merge($paths, [$instance->getId()]) + array_merge($paths, [$instance->getId()]), ); } @@ -248,18 +244,18 @@ public function handleRequest(array $paths, array $get) $links['self'] = rex_yform_rest::getLinkByPath($this, $linkParams); $links['first'] = rex_yform_rest::getLinkByPath($this, array_merge( $linkParams, - ['page' => 1] + ['page' => 1], )); if (($currentPage - 1) > 0) { $links['prev'] = rex_yform_rest::getLinkByPath($this, array_merge( $linkParams, - ['page' => ($currentPage - 1)] + ['page' => ($currentPage - 1)], )); } if (($currentPage * $per_page) < $itemsAll) { $links['next'] = rex_yform_rest::getLinkByPath($this, array_merge( $linkParams, - ['page' => ($currentPage + 1)] + ['page' => ($currentPage + 1)], )); } @@ -275,7 +271,7 @@ public function handleRequest(array $paths, array $get) } else { $data = $this->getInstanceData( $instance, - array_merge($paths) + array_merge($paths), ); } } @@ -284,7 +280,7 @@ public function handleRequest(array $paths, array $get) break; - // ----- /END GET + // ----- /END GET case 'post': $instance = $table->createDataset(); @@ -417,7 +413,6 @@ public function handleRequest(array $paths, array $get) } /** - * @param $instance * @throws rex_api_exception * @return rex_yform_manager_field[] */ @@ -457,11 +452,6 @@ public function getFields(string $type = 'get', $instance = null): array return $returnFields; } - /** - * @param $query - * @param $fields - * @param $get - */ public function getFilterQuery(rex_yform_manager_query $query, array $fields, array $get): rex_yform_manager_query { if (isset($get['filter']) && is_array($get['filter'])) { @@ -491,8 +481,6 @@ public function getFilterQuery(rex_yform_manager_query $query, array $fields, ar } /** - * @param $instance - * @param $paths * @param bool $onlyId */ public function getInstanceData($instance, $paths, $onlyId = false, $parents = []): array @@ -564,7 +552,7 @@ private function filterFieldsByInclude(array $fields, array $parents = []): arra $newFields = []; foreach ($fields as $key => $field) { - $compareKey = 0 == count($parents) ? $key : implode('.', $parents).'.'.$key; + $compareKey = 0 == count($parents) ? $key : implode('.', $parents) . '.' . $key; if (in_array($compareKey, $this->getIncludes(), true)) { $newFields[$key] = $field; } @@ -602,7 +590,7 @@ public function getInstanceRelationships(rex_yform_manager_dataset $instance, $p $relationInstance, array_merge($paths, [$field->getName(), $relationInstance->getId()]), $onlyId, - $fieldParents + $fieldParents, ); } $return[$field->getName()] = [ @@ -628,8 +616,6 @@ public function getInstanceRelationships(rex_yform_manager_dataset $instance, $p } /** - * @param $instance - * @param $key * @param false $attributCall * @return mixed */ @@ -654,7 +640,7 @@ public function getTypeFromInstance($instance = null): string if (!$instance) { $type = 'not-defined'; } else { - $type = get_class($instance); + $type = $instance::class; if ('rex_yform_manager_dataset' == $type || 'rex_yform_rest_route' == $instance || !$type) { $type = 'not-defined'; } diff --git a/plugins/rest/pages/access.php b/plugins/rest/pages/access.php index 24548e4d4..1bf82f220 100644 --- a/plugins/rest/pages/access.php +++ b/plugins/rest/pages/access.php @@ -30,7 +30,7 @@ } elseif ('edit' == $func || 'add' == $func) { $form_data = []; - $form_data[] = 'choice|token_id|translate:yform_rest_token|select id, name from '.rex::getTablePrefix() . 'yform_rest_token'.'|'; + $form_data[] = 'choice|token_id|translate:yform_rest_token|select id, name from ' . rex::getTablePrefix() . 'yform_rest_token|'; $form_data[] = 'datetime|datetime_created|translate:yform_rest_token_access_datetime_created'; $form_data[] = 'text|url|translate:yform_rest_token_url'; @@ -44,7 +44,7 @@ if ('edit' == $func) { $title = rex_i18n::msg('yform_rest_token_access_update'); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->setHiddenField('data_id', $data_id); $yform->setHiddenField('func', $func); $yform->setActionField('db', [$table, "id=$data_id"]); @@ -56,7 +56,7 @@ } else { $yform->setHiddenField('func', $func); $title = rex_i18n::msg('yform_rest_token_create'); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_add').','.rex_i18n::msg('yform_add_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_add') . ',' . rex_i18n::msg('yform_add_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->setActionField('db', [$table]); $yform->setActionField('showtext', [rex_view::success(rex_i18n::msg('yform_rest_token_info_added')), '', '', 1]); } @@ -104,7 +104,7 @@ $yform->setObjectparams('main_where', "id=$data_id"); $yform->setObjectparams('main_table', $table); $yform->setObjectparams('getdata', true); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->executeFields(); $content = $yform->executeActions(); @@ -112,7 +112,7 @@ $fragment->setVar('class', 'edit', false); $fragment->setVar('title', $title); $fragment->setVar('body', $content, false); - $content = rex_view::success(rex_i18n::msg('yform_rest_token_access_added')).$fragment->parse('core/page/section.php'); + $content = rex_view::success(rex_i18n::msg('yform_rest_token_access_added')) . $fragment->parse('core/page/section.php'); $show_list = false; } else { @@ -158,7 +158,7 @@ $list->setColumnFormat('token_id', 'custom', static function ($params) { $token = rex_yform_rest_auth_token::get($params['subject']); if ($token) { - return ''.$token['name'].''; + return '' . $token['name'] . ''; } return '-'; // rex_i18n::translate($params['value']).' [###table_name###]

    '.rex_i18n::msg('yform_edit_datatable').'

    '; }); diff --git a/plugins/rest/pages/token.php b/plugins/rest/pages/token.php index 4def812b4..73de5b6e5 100644 --- a/plugins/rest/pages/token.php +++ b/plugins/rest/pages/token.php @@ -40,11 +40,11 @@ $form_data[] = 'checkbox|status|translate:yform_rest_token_status'; $form_data[] = 'text|name|translate:yform_rest_token_name'; $form_data[] = 'validate|empty|name|translate:yform_rest_token_name_validate'; - $form_data[] = 'text|token|translate:yform_rest_token_token|#notice:'.rex_i18n::msg('yform_rest_token_token_notice', $dummyToken); + $form_data[] = 'text|token|translate:yform_rest_token_token|#notice:' . rex_i18n::msg('yform_rest_token_token_notice', $dummyToken); $form_data[] = 'validate|empty|token|translate:yform_rest_token_token_validate'; $form_data[] = 'choice|interval|translate:yform_rest_token_interval|translate:yform_rest_token_none=none,translate:yform_rest_token_overall=overall,translate:yform_rest_token_per_hour=hour,translate:yform_rest_token_per_day=day,translate:yform_rest_token_per_month=month|#attributes:{"class": "form-control yform-rest-token-interval-select"}'; $form_data[] = 'integer|amount|translate:yform_rest_token_amount'; - $form_data[] = 'choice|paths|translate:yform_rest_token_token_paths|'.implode(',', $routes).'||1'; + $form_data[] = 'choice|paths|translate:yform_rest_token_token_paths|' . implode(',', $routes) . '||1'; $yform = rex_yform::factory(); $yform->setObjectparams('form_action', 'index.php?page=yform/rest/token'); @@ -57,7 +57,7 @@ if ('edit' == $func) { $title = rex_i18n::msg('yform_rest_token_update'); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->setHiddenField('data_id', $data_id); $yform->setHiddenField('func', $func); $yform->setActionField('db', [$table, "id=$data_id"]); @@ -69,7 +69,7 @@ } else { $yform->setHiddenField('func', $func); $title = rex_i18n::msg('yform_rest_token_create'); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_add').','.rex_i18n::msg('yform_add_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_add') . ',' . rex_i18n::msg('yform_add_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->setActionField('db', [$table]); $yform->setActionField('showtext', [rex_view::success(rex_i18n::msg('yform_rest_token_info_added')), '', '', 1]); } @@ -117,7 +117,7 @@ $yform->setObjectparams('main_where', "id=$data_id"); $yform->setObjectparams('main_table', $table); $yform->setObjectparams('getdata', true); - $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save').','.rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); + $yform->setValueField('submit', ['name' => 'submit', 'labels' => rex_i18n::msg('yform_save') . ',' . rex_i18n::msg('yform_save_apply'), 'values' => '1,2', 'no_db' => true, 'css_classes' => 'btn-save,btn-apply']); $yform->executeFields(); $content = $yform->executeActions(); @@ -125,7 +125,7 @@ $fragment->setVar('class', 'edit', false); $fragment->setVar('title', $title); $fragment->setVar('body', $content, false); - $content = rex_view::success(rex_i18n::msg('yform_rest_token_added')).$fragment->parse('core/page/section.php'); + $content = rex_view::success(rex_i18n::msg('yform_rest_token_added')) . $fragment->parse('core/page/section.php'); $show_list = false; } else { diff --git a/plugins/rest/update.php b/plugins/rest/update.php index 8f3561d52..b9438c13a 100644 --- a/plugins/rest/update.php +++ b/plugins/rest/update.php @@ -1,8 +1,8 @@ includeFile(__DIR__.'/install.php'); +$this->includeFile(__DIR__ . '/install.php'); diff --git a/.tools/tests/rex_yform_yorm_test.php b/tests/rex_yform_yorm_test.php similarity index 81% rename from .tools/tests/rex_yform_yorm_test.php rename to tests/rex_yform_yorm_test.php index d8203d993..9d0e52c51 100644 --- a/.tools/tests/rex_yform_yorm_test.php +++ b/tests/rex_yform_yorm_test.php @@ -1,6 +1,15 @@ $tableName, - 'name' => 'Name of Table - '.$tableName, - 'description' => 'Description of Table - '.$tableName, + 'name' => 'Name of Table - ' . $tableName, + 'description' => 'Description of Table - ' . $tableName, 'status' => 1, 'list_amount' => 10, 'list_sortfield' => 'id', @@ -23,18 +32,18 @@ public static function setUpTable($tableName) 'export' => 1, 'import' => 1, 'schema_overwrite' => 1, - ] + ], ); return $table; } public static function setUpTableField(rex_yform_manager_table $table, $field) { - $field['type_id'] = $field['type_id'] ?? 'value'; - $field['type_name'] = $field['type_name'] ?? 'text'; - $field['name'] = $field['name'] ?? 'default'; - $field['label'] = $field['label'] ?? 'Titel:'; - $field['list_hidden'] = $field['list_hidden'] ?? 0; + $field['type_id'] ??= 'value'; + $field['type_name'] ??= 'text'; + $field['name'] ??= 'default'; + $field['label'] ??= 'Titel:'; + $field['list_hidden'] ??= 0; $field['search'] = $field['list_hidden'] ?? 0; $field['prio'] = $field['list_hidden'] ?? 99999; @@ -44,11 +53,15 @@ public static function setUpTableField(rex_yform_manager_table $table, $field) public function testTableAPI() { - $prefix = 'unittest_yform_table_'.date('YmdHis').'_'; - $tableName = $prefix.'base'; + $prefix = 'unittest_yform_table_' . date('YmdHis') . '_'; + $tableName = $prefix . 'base'; $table = self::setUpTable($tableName); - static::assertEquals(get_class($table), 'rex_yform_manager_table', 'table creation failed. (rex_yform_manager_table_api::setTable)'); + static::assertEquals( + $table::class, + 'rex_yform_manager_table', + 'table creation failed. (rex_yform_manager_table_api::setTable)', + ); if ($table) { $fieldName = 'field_title'; @@ -62,7 +75,11 @@ public function testTableAPI() // prüfen ob es angelegt ist. $fields = rex_yform_manager_table::get($tableName)->getFields(); - static::assertEquals(count($fields), 1, 'field creation failed (rex_yform_manager_table_api::setTableField)'); + static::assertEquals( + count($fields), + 1, + 'field creation failed (rex_yform_manager_table_api::setTableField)', + ); if (1 == count($fields)) { static::assertEquals($fields[0]->getName(), $fieldName, 'fieldname validation failed'); @@ -75,11 +92,15 @@ public function testTableAPI() $dataset->setValue($fieldName, $fieldValue); static::assertTrue($dataset->save(), 'dataset creation failed (rex_yform_manager_dataset::create)'); - static::assertEquals(count($dataset->getMessages()), 0, 'dataset creation failed with Messages: '.implode(',', $dataset->getMessages())); + static::assertEquals( + count($dataset->getMessages()), + 0, + 'dataset creation failed with Messages: ' . implode(',', $dataset->getMessages()), + ); if (0 == count($dataset->getMessages())) { $SQLDatasets = rex_sql::factory()->getArray( - 'select * from ' . $tableName + 'select * from ' . $tableName, ); static::assertEquals(count($SQLDatasets), 1, 'dataset not found - creation failed (SQL Test)'); @@ -89,12 +110,16 @@ public function testTableAPI() static::assertNotNull($dataset, 'dataset not found - get via ID failed'); // YORM - Datensatz bearbeiten - $fieldValueEdit = $fieldValue.' overwrite'; + $fieldValueEdit = $fieldValue . ' overwrite'; $dataset ->setValue($fieldName, $fieldValueEdit) ->save(); $dataset = rex_yform_manager_dataset::get($datasetId, $tableName); - static::assertEquals($dataset->getValue($fieldName), $fieldValueEdit, 'dataset update failes - YOrm update failed'); + static::assertEquals( + $dataset->getValue($fieldName), + $fieldValueEdit, + 'dataset update failes - YOrm update failed', + ); // YORM - Datensatz löschen if ($dataset) { @@ -110,8 +135,8 @@ public function testTableAPI() // Bezugstabelle // Verknüpfungstabelle - $tableNameCategories = $prefix.'category'; - $tableNameRelation = $prefix.'related'; + $tableNameCategories = $prefix . 'category'; + $tableNameRelation = $prefix . 'related'; $tableCategories = self::setUpTable($tableNameCategories); $tableRelation = self::setUpTable($tableNameRelation); @@ -196,25 +221,25 @@ public function testTableAPI() // Cleanup try { rex_sql::factory()->setQuery( - 'DROP Table ' . $tableName + 'DROP Table ' . $tableName, ); rex_sql::factory()->setQuery( - 'DROP Table ' . $tableNameCategories + 'DROP Table ' . $tableNameCategories, ); rex_sql::factory()->setQuery( - 'DROP Table ' . $tableNameRelation + 'DROP Table ' . $tableNameRelation, ); rex_sql::factory()->setQuery( 'delete from ' . rex_yform_manager_table::table() . ' where table_name LIKE :table_name ', [ - ':table_name' => $prefix.'%', - ] + ':table_name' => $prefix . '%', + ], ); rex_sql::factory()->setQuery( 'delete from ' . rex_yform_manager_field::table() . ' where table_name LIKE :table_name ', [ - ':table_name' => $prefix.'%', - ] + ':table_name' => $prefix . '%', + ], ); rex_yform_manager_table::deleteCache(); diff --git a/update.php b/update.php index f760806f7..414708a43 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,4 @@ includeFile(__DIR__.'/install.php'); +/** @var rex_addon $this */ +$this->includeFile(__DIR__ . '/install.php'); diff --git a/ytemplates/bootstrap/errors.tpl.php b/ytemplates/bootstrap/errors.tpl.php index 407e05e31..f83b12905 100644 --- a/ytemplates/bootstrap/errors.tpl.php +++ b/ytemplates/bootstrap/errors.tpl.php @@ -11,12 +11,12 @@ if ($this->objparams['warning_messages'] || $this->objparams['unique_error']): if ($this->objparams['Error-occured']): ?>
    -
    objparams['Error-occured'] ?>
    +
    objparams['Error-occured'] ?>
        - + objparams['unique_error']) { - echo '
      • '.rex_i18n::translate(preg_replace('~\\*|:|\\(.*\\)~Usim', '', $this->objparams['unique_error'])).'
      • '; + echo '
      • ' . rex_i18n::translate(preg_replace('~\\*|:|\\(.*\\)~Usim', '', $this->objparams['unique_error'])) . '
      • '; } ?> diff --git a/ytemplates/bootstrap/form.tpl.php b/ytemplates/bootstrap/form.tpl.php index cb281299f..32403cf10 100644 --- a/ytemplates/bootstrap/form.tpl.php +++ b/ytemplates/bootstrap/form.tpl.php @@ -6,7 +6,7 @@ */ ?> -
        +
        objparams['form_action']) { @@ -18,11 +18,11 @@ parse_str(html_entity_decode($action_url_splitted[1]), $query_array); } if (0 < count($this->objparams['form_action_query_params'])) { - $query_array = $query_array + $this->objparams['form_action_query_params']; + $query_array += $this->objparams['form_action_query_params']; $action_url = $action_url_splitted[0] . '?' . http_build_query($query_array, '', '&', PHP_QUERY_RFC3986); } - echo '
        '; + echo ''; } ?> @@ -46,10 +46,10 @@ $recArray = static function ($key, $paramsArray) use (&$recArray) { if (!is_array($paramsArray)) { - echo "\n".''; + echo "\n" . ''; } elseif (is_array($paramsArray)) { foreach ($paramsArray as $k => $v) { - $recArray($key.'['.$k.']', $v); + $recArray($key . '[' . $k . ']', $v); } } }; diff --git a/ytemplates/bootstrap/value.article.tpl.php b/ytemplates/bootstrap/value.article.tpl.php index b2ce09fcf..f8d9027d3 100644 --- a/ytemplates/bootstrap/value.article.tpl.php +++ b/ytemplates/bootstrap/value.article.tpl.php @@ -8,6 +8,6 @@ $class_group = trim('form-group ' . $this->getHTMLClass() . ' ' . $this->getWarningClass()); ?> -
        - getArticle() ?> +
        + getArticle() ?>
        diff --git a/ytemplates/bootstrap/value.checkbox.tpl.php b/ytemplates/bootstrap/value.checkbox.tpl.php index 93d3e6642..29ca2195a 100644 --- a/ytemplates/bootstrap/value.checkbox.tpl.php +++ b/ytemplates/bootstrap/value.checkbox.tpl.php @@ -5,7 +5,7 @@ * @psalm-scope-this rex_yform_value_checkbox */ -$value = $value ?? $this->getValue() ?? ''; +$value ??= $this->getValue() ?? ''; $notices = []; if ('' != $this->getElement('notice')) { @@ -35,7 +35,7 @@ $attributes = $this->getAttributeElements($attributes, ['required', 'disabled', 'autofocus']); ?> -
        - - +
        + +
        diff --git a/ytemplates/bootstrap/value.checkbox_group.tpl.php b/ytemplates/bootstrap/value.checkbox_group.tpl.php index f81db570d..7ad007324 100644 --- a/ytemplates/bootstrap/value.checkbox_group.tpl.php +++ b/ytemplates/bootstrap/value.checkbox_group.tpl.php @@ -5,7 +5,7 @@ * @psalm-scope-this rex_yform_value_checkbox */ -$options = $options ?? []; +$options ??= []; $notices = []; if ('' != $this->getElement('notice')) { @@ -24,9 +24,9 @@ getLabel())): ?>
        - + - + $v): ?>
        - + getLabel())): ?>
        - + diff --git a/ytemplates/bootstrap/value.choice.check.tpl.php b/ytemplates/bootstrap/value.choice.check.tpl.php index af9d8ca01..469c87e61 100644 --- a/ytemplates/bootstrap/value.choice.check.tpl.php +++ b/ytemplates/bootstrap/value.choice.check.tpl.php @@ -12,7 +12,7 @@ $notices[] = rex_i18n::translate($this->getElement('notice'), false); } if (isset($this->params['warning_messages'][$this->getId()]) && !$this->params['hide_field_warning_messages']) { - $notices[] = ''.rex_i18n::translate($this->params['warning_messages'][$this->getId()], false).''; + $notices[] = '' . rex_i18n::translate($this->params['warning_messages'][$this->getId()], false) . ''; } if (!isset($groupAttributes)) { @@ -23,7 +23,7 @@ if (isset($groupAttributes['class']) && is_array($groupAttributes['class'])) { $groupAttributes['class'][] = $groupClass; } elseif (isset($groupAttributes['class'])) { - $groupAttributes['class'] .= ' '.$groupClass; + $groupAttributes['class'] .= ' ' . $groupClass; } else { $groupAttributes['class'] = $groupClass; } @@ -31,11 +31,11 @@ if (!isset($elementAttributes)) { $elementAttributes = []; } -$elementClass = trim(($choiceList->isMultiple() ? 'checkbox' : 'radio').' '.$this->getWarningClass()); +$elementClass = trim(($choiceList->isMultiple() ? 'checkbox' : 'radio') . ' ' . $this->getWarningClass()); if (isset($elementAttributes['class']) && is_array($elementAttributes['class'])) { $elementAttributes['class'][] = $elementClass; } elseif (isset($elementAttributes['class'])) { - $elementAttributes['class'] .= ' '.$elementClass; + $elementAttributes['class'] .= ' ' . $elementClass; } else { $elementAttributes['class'] = $elementClass; } @@ -48,7 +48,7 @@