diff --git a/composer.json b/composer.json index 173c143a82..d100c6fc53 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "AGPL-3.0-only", "description": "Code for tatoeba.org, a multilingual sentence and translation database", "require": { - "cakephp/cakephp": "3.8.*", + "cakephp/cakephp": "3.10.*", "cakephp/plugin-installer": "^1.0", "dereuromark/cakephp-queue": "dev-cake3", "markstory/asset_compress": "^3.5", diff --git a/composer.lock b/composer.lock index c2da76f7e7..b7f6a1b63c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "19696de60b3da4f1145fd0e9d017475f", + "content-hash": "a365b93f0ea17f74ca1d08c5a3d3b36e", "packages": [ { "name": "aura/intl", @@ -61,16 +61,16 @@ }, { "name": "cakephp/cakephp", - "version": "3.8.13", + "version": "3.10.5", "source": { "type": "git", "url": "https://github.com/cakephp/cakephp.git", - "reference": "1915d78f659d374224b2be0a5ad7822d96fb8366" + "reference": "571fb867995ccfa4034ec5b66577f0ab2acd4429" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cakephp/cakephp/zipball/1915d78f659d374224b2be0a5ad7822d96fb8366", - "reference": "1915d78f659d374224b2be0a5ad7822d96fb8366", + "url": "https://api.github.com/repos/cakephp/cakephp/zipball/571fb867995ccfa4034ec5b66577f0ab2acd4429", + "reference": "571fb867995ccfa4034ec5b66577f0ab2acd4429", "shasum": "" }, "require": { @@ -78,10 +78,11 @@ "cakephp/chronos": "^1.0.1", "ext-intl": "*", "ext-mbstring": "*", - "php": ">=5.6.0", + "laminas/laminas-diactoros": "^1.4.0", + "paragonie/random_compat": "^1.4|^2.0|9.99.99", + "php": ">=5.6.0,<8.0.0", "psr/log": "^1.0.0", - "psr/simple-cache": "^1.0.0", - "zendframework/zend-diactoros": "^1.4.0" + "psr/simple-cache": "^1.0.0" }, "conflict": { "phpunit/phpunit": "<5.7" @@ -104,12 +105,14 @@ "require-dev": { "cakephp/cakephp-codesniffer": "^3.0", "cakephp/chronos": "^1.2.1", + "paragonie/csp-builder": "^1.4|^2.3", "phpunit/phpunit": "^5.7.14|^6.0" }, "suggest": { "ext-curl": "To enable more efficient network calls in Http\\Client.", "ext-openssl": "To use Security::encrypt() or have secure CSRF token generation.", - "lib-ICU": "The intl PHP library, to use Text::transliterate() or Text::slug()" + "lib-ICU": "The intl PHP library, to use Text::transliterate() or Text::slug()", + "paragonie/csp-builder": "CSP builder, to use the CSP Middleware" }, "type": "library", "autoload": { @@ -146,13 +149,7 @@ "rapid-development", "validation" ], - "support": { - "forum": "https://stackoverflow.com/tags/cakephp", - "irc": "irc://irc.freenode.org/cakephp", - "issues": "https://github.com/cakephp/cakephp/issues", - "source": "https://github.com/cakephp/cakephp" - }, - "time": "2020-06-19T18:52:08+00:00" + "time": "2023-01-02T02:53:00+00:00" }, { "name": "cakephp/chronos", @@ -424,6 +421,132 @@ }, "time": "2021-03-09T19:44:02+00:00" }, + { + "name": "laminas/laminas-diactoros", + "version": "1.8.7p2", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-diactoros.git", + "reference": "6991c1af7c8d2c8efee81b22ba97024781824aaa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/6991c1af7c8d2c8efee81b22ba97024781824aaa", + "reference": "6991c1af7c8d2c8efee81b22ba97024781824aaa", + "shasum": "" + }, + "require": { + "laminas/laminas-zendframework-bridge": "^1.0", + "php": "^5.6 || ^7.0", + "psr/http-message": "^1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "replace": { + "zendframework/zend-diactoros": "~1.8.7.0" + }, + "require-dev": { + "ext-dom": "*", + "ext-libxml": "*", + "laminas/laminas-coding-standard": "~1.0", + "php-http/psr7-integration-tests": "dev-master", + "phpunit/phpunit": "^5.7.16 || ^6.0.8 || ^7.2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-release-1.8": "1.8.x-dev" + } + }, + "autoload": { + "files": [ + "src/functions/create_uploaded_file.php", + "src/functions/marshal_headers_from_sapi.php", + "src/functions/marshal_method_from_sapi.php", + "src/functions/marshal_protocol_version_from_sapi.php", + "src/functions/marshal_uri_from_sapi.php", + "src/functions/normalize_server.php", + "src/functions/normalize_uploaded_files.php", + "src/functions/parse_cookie_header.php", + "src/functions/create_uploaded_file.legacy.php", + "src/functions/marshal_headers_from_sapi.legacy.php", + "src/functions/marshal_method_from_sapi.legacy.php", + "src/functions/marshal_protocol_version_from_sapi.legacy.php", + "src/functions/marshal_uri_from_sapi.legacy.php", + "src/functions/normalize_server.legacy.php", + "src/functions/normalize_uploaded_files.legacy.php", + "src/functions/parse_cookie_header.legacy.php" + ], + "psr-4": { + "Laminas\\Diactoros\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "PSR HTTP Message implementations", + "homepage": "https://laminas.dev", + "keywords": [ + "http", + "laminas", + "psr", + "psr-7" + ], + "time": "2020-03-23T15:28:28+00:00" + }, + { + "name": "laminas/laminas-zendframework-bridge", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-zendframework-bridge.git", + "reference": "88bf037259869891afce6504cacc4f8a07b24d0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/88bf037259869891afce6504cacc4f8a07b24d0f", + "reference": "88bf037259869891afce6504cacc4f8a07b24d0f", + "shasum": "" + }, + "require": { + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "psalm/plugin-phpunit": "^0.15.1", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.6" + }, + "type": "library", + "extra": { + "laminas": { + "module": "Laminas\\ZendFrameworkBridge" + } + }, + "autoload": { + "files": [ + "src/autoload.php" + ], + "psr-4": { + "Laminas\\ZendFrameworkBridge\\": "src//" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Alias legacy ZF class names to Laminas Project equivalents.", + "keywords": [ + "ZendFramework", + "autoloading", + "laminas", + "zf" + ], + "abandoned": true, + "time": "2021-12-21T14:34:37+00:00" + }, { "name": "league/climate", "version": "3.6.0", @@ -655,6 +778,51 @@ ], "time": "2018-01-09T11:15:01+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + }, { "name": "patchwork/jsqueeze", "version": "v2.0.5", @@ -754,25 +922,25 @@ }, { "name": "psr/http-message", - "version": "1.0.1", + "version": "1.1", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -800,10 +968,7 @@ "request", "response" ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/master" - }, - "time": "2016-08-06T14:39:51+00:00" + "time": "2023-04-04T09:50:52+00:00" }, { "name": "psr/log", @@ -1330,20 +1495,6 @@ "support": { "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2021-10-20T20:35:02+00:00" }, { @@ -1479,16 +1630,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.25.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", - "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -1502,9 +1653,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1541,24 +1689,7 @@ "portable", "shim" ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-11-30T18:21:41+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php73", @@ -1873,73 +2004,6 @@ "description": "Symfony Yaml Component", "homepage": "https://symfony.com", "time": "2020-11-28T10:57:20+00:00" - }, - { - "name": "zendframework/zend-diactoros", - "version": "1.8.7", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "a85e67b86e9b8520d07e6415fcbcb8391b44a75b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/a85e67b86e9b8520d07e6415fcbcb8391b44a75b", - "reference": "a85e67b86e9b8520d07e6415fcbcb8391b44a75b", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0", - "psr/http-message": "^1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "ext-dom": "*", - "ext-libxml": "*", - "php-http/psr7-integration-tests": "dev-master", - "phpunit/phpunit": "^5.7.16 || ^6.0.8 || ^7.2.7", - "zendframework/zend-coding-standard": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-release-1.8": "1.8.x-dev" - } - }, - "autoload": { - "files": [ - "src/functions/create_uploaded_file.php", - "src/functions/marshal_headers_from_sapi.php", - "src/functions/marshal_method_from_sapi.php", - "src/functions/marshal_protocol_version_from_sapi.php", - "src/functions/marshal_uri_from_sapi.php", - "src/functions/normalize_server.php", - "src/functions/normalize_uploaded_files.php", - "src/functions/parse_cookie_header.php" - ], - "psr-4": { - "Zend\\Diactoros\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "description": "PSR HTTP Message implementations", - "homepage": "https://github.com/zendframework/zend-diactoros", - "keywords": [ - "http", - "psr", - "psr-7" - ], - "support": { - "issues": "https://github.com/zendframework/zend-diactoros/issues", - "source": "https://github.com/zendframework/zend-diactoros" - }, - "abandoned": "laminas/laminas-diactoros", - "time": "2019-08-06T17:53:53+00:00" } ], "packages-dev": [ @@ -2067,6 +2131,7 @@ "issues": "https://github.com/aptoma/twig-markdown/issues", "source": "https://github.com/aptoma/twig-markdown/tree/master" }, + "abandoned": true, "time": "2015-10-23T20:27:08+00:00" }, { @@ -3066,6 +3131,7 @@ "keywords": [ "tokenizer" ], + "abandoned": true, "time": "2017-11-27T05:48:46+00:00" }, { @@ -3877,16 +3943,6 @@ "issues": "https://github.com/twigphp/Twig/issues", "source": "https://github.com/twigphp/Twig/tree/v1.44.6" }, - "funding": [ - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/twig/twig", - "type": "tidelift" - } - ], "time": "2021-11-25T13:31:46+00:00" }, { @@ -3939,12 +3995,12 @@ "version": "1.9.1", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", + "url": "https://github.com/webmozarts/assert.git", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, @@ -4054,9 +4110,5 @@ "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [], - "platform-overrides": { - "php": "7.3.31" - }, - "plugin-api-version": "2.3.0" + "platform-dev": [] } diff --git a/config/auth_actions.php b/config/auth_actions.php index 8a05f47411..24b3ddebf4 100644 --- a/config/auth_actions.php +++ b/config/auth_actions.php @@ -1,7 +1,7 @@ [ 'activities' => [ 'improve_sentences', 'translate_sentences_of' ], diff --git a/config/user_rights.php b/config/user_rights.php index 946af685dc..d381b4bdd8 100644 --- a/config/user_rights.php +++ b/config/user_rights.php @@ -1,7 +1,7 @@ [ ] ]; diff --git a/src/Controller/ApiV0Controller.php b/src/Controller/ApiV0Controller.php index c2bed61cc9..b51281f5aa 100644 --- a/src/Controller/ApiV0Controller.php +++ b/src/Controller/ApiV0Controller.php @@ -79,7 +79,7 @@ public function search() $limit = 10; $sphinx = $search->asSphinx(); - $sphinx['page'] = $this->request->query('page'); + $sphinx['page'] = $this->request->getQuery('page'); $sphinx['limit'] = $limit; $query = $this->Sentences diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 21b5dc0d8e..d2f88e5a20 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -29,12 +29,9 @@ use App\Lib\LanguagesLib; use App\Model\CurrentUser; use Cake\Controller\Controller; -use Cake\Core\Configure; use Cake\Event\Event; +use Cake\Http\ServerRequest; use Cake\Routing\Router; -use Cake\Utility\Security; -use Cake\I18n\I18n; -use Locale; /** * Controller for contributions. @@ -92,6 +89,63 @@ public function initialize() $this->loadComponent('Csrf'); } + /** + * This function is imported from CakePHP's 3.x Router.php + * It provides legacy support for named parameters on incoming URLs. + * + * Checks the passed parameters for elements containing `$options['separator']` + * Those parameters are split and parsed as if they were old style named parameters. + * + * The parsed parameters will be moved from params['pass'] to params['named']. + * + * ### Options + * + * - `separator` The string to use as a separator. Defaults to `:`. + * + * @param \Cake\Http\ServerRequest $request The request object to modify. + * @param array $options The array of options. + * @return \Cake\Http\ServerRequest The modified request + * @deprecated 3.3.0 Named parameter backwards compatibility will be removed in 4.0. + */ + private function parseNamedParams(ServerRequest $request, array $options = []) + { + $options += ['separator' => ':']; + if (!$request->getParam('pass')) { + return $request->withParam('named', []); + } + $named = []; + $pass = $request->getParam('pass'); + foreach ((array)$pass as $key => $value) { + if (strpos($value, $options['separator']) === false) { + continue; + } + unset($pass[$key]); + list($key, $value) = explode($options['separator'], $value, 2); + + if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { + $matches = array_reverse($matches); + $parts = explode('[', $key); + $key = array_shift($parts); + $arr = $value; + foreach ($matches as $match) { + if (empty($match[1])) { + $arr = [$arr]; + } else { + $arr = [ + $match[1] => $arr, + ]; + } + } + $value = $arr; + } + $named = array_merge_recursive($named, [$key => $value]); + } + + return $request + ->withParam('pass', $pass) + ->withParam('named', $named); + } + /** * * @@ -133,7 +187,7 @@ public function beforeFilter(Event $event) CurrentUser::store($user); // Restore named parameters removed in CakePHP 3 - $this->request = Router::parseNamedParams($this->request); + $this->request = $this->parseNamedParams($this->request); // Parse named parameters (e.g. /page:123) // as if they were query params (e.g. ?page=123) @@ -233,15 +287,15 @@ protected function redirectPaginationToLastPage() { $paging = $this->request->getParam('paging'); $lastPage = reset($paging)['page']; - $queryParams = $this->request->params['?']; + $queryParams = $this->request->getParam('?'); $queryParams['page'] = $lastPage; $url = Router::url(array_merge( [ - 'controller' => $this->request->params['controller'], - 'action' => $this->request->params['action'], + 'controller' => $this->request->getParam('controller'), + 'action' => $this->request->getParam('action'), '?' => $queryParams ], - $this->request->params['pass'] + $this->request->getParam('pass') )); return $this->redirect($url); } diff --git a/src/Controller/AudioController.php b/src/Controller/AudioController.php index 824afd35d2..c7d3bd9964 100644 --- a/src/Controller/AudioController.php +++ b/src/Controller/AudioController.php @@ -50,7 +50,7 @@ class AudioController extends AppController public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'save', 'delete', ]); @@ -118,13 +118,13 @@ public function of($username) { } public function save_settings() { - if (!empty($this->request->data)) { + if (!empty($this->request->getData())) { $currentUserId = CurrentUser::get('id'); $allowedFields = array( 'audio_license', 'audio_attribution_url', ); - $dataToSave = $this->filterKeys($this->request->data, $allowedFields); + $dataToSave = $this->filterKeys($this->request->getData(), $allowedFields); $this->loadModel('Users'); $user = $this->Users->get($currentUserId); $this->Users->patchEntity($user, $dataToSave); @@ -172,7 +172,7 @@ public function download($id) { } public function save($id) { - $this->viewBuilder()->autoLayout(false); + $this->viewBuilder()->enableAutoLayout(false); if ($this->request->is('post')) { $audio = false; @@ -204,7 +204,7 @@ public function save($id) { } public function delete($id) { - $this->viewBuilder()->autoLayout(false); + $this->viewBuilder()->enableAutoLayout(false); if ($this->request->is('post')) { $audio = false; diff --git a/src/Controller/CategoriesTreeController.php b/src/Controller/CategoriesTreeController.php index daa75ddca3..b4751b6e82 100644 --- a/src/Controller/CategoriesTreeController.php +++ b/src/Controller/CategoriesTreeController.php @@ -71,9 +71,9 @@ public function manage(){ } public function createorEditCategory() { - $name = $this->request->data('name'); - $description = $this->request->data('description'); - $parentName = $this->request->data('parentName'); + $name = $this->request->getData('name'); + $description = $this->request->getData('description'); + $parentName = $this->request->getData('parentName'); $res = $this->CategoriesTree->createOrEdit($name, $description, $parentName); @@ -95,8 +95,8 @@ public function removeCategory($categoryId) { } public function attachTagToCategory() { - $tagName = $this->request->data('tagName'); - $categoryName = $this->request->data('categoryName'); + $tagName = $this->request->getData('tagName'); + $categoryName = $this->request->getData('categoryName'); $this->loadModel('Tags'); $res = $this->Tags->attachToCategory($tagName, $categoryName); diff --git a/src/Controller/ExportsController.php b/src/Controller/ExportsController.php index c6c1b77430..6fafbc37b5 100644 --- a/src/Controller/ExportsController.php +++ b/src/Controller/ExportsController.php @@ -9,7 +9,7 @@ class ExportsController extends AppController { public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'add', ]); $this->Auth->allowedActions = ['add', 'get', 'download']; diff --git a/src/Controller/LicensingController.php b/src/Controller/LicensingController.php index 0c531cc81c..05ce6d2ab1 100644 --- a/src/Controller/LicensingController.php +++ b/src/Controller/LicensingController.php @@ -28,7 +28,7 @@ class LicensingController extends AppController { public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'refresh_license_switch_list', ]); diff --git a/src/Controller/LinksController.php b/src/Controller/LinksController.php index 6399d59d7f..af33726e1a 100644 --- a/src/Controller/LinksController.php +++ b/src/Controller/LinksController.php @@ -43,12 +43,12 @@ class LinksController extends AppController { public function initialize() { parent::initialize(); - $params = $this->request->params; + $request = $this->request; $noCsrfActions = [ 'add', 'delete' ]; - if (in_array($params['action'], $noCsrfActions)) { + if (in_array($request->getParam('action'), $noCsrfActions)) { $this->components()->unload('Csrf'); } } @@ -61,7 +61,7 @@ public function initialize() { public function beforeFilter(Event $event) { if($this->request->is('ajax')) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'add', 'delete' ]); @@ -73,7 +73,7 @@ public function beforeFilter(Event $event) private function _renderTranslationsOf($sentenceId, $message) { $this->loadModel('Sentences'); - $langFilter = $this->request->data['langFilter'] ?? 'und'; + $langFilter = $this->request->getData('langFilter') ?? 'und'; $translations = $this->Sentences->getSentenceWith($sentenceId, ['translations' => true], $langFilter)->translations; $this->set('sentenceId', $sentenceId); @@ -128,8 +128,8 @@ public function add($sentenceId, $translationId) if ($acceptsJson) { $this->_returnSentenceAndTranslations($sentenceId); } else if ($this->request->is('ajax')) { - if (isset($this->request->data['returnTranslations']) - && (bool)$this->request->data['returnTranslations']) + if (null !== $this->request->getData('returnTranslations') + && (bool)$this->request->getData('returnTranslations')) $this->_renderTranslationsOf($sentenceId, $flashMessage); } else { $this->flash($flashMessage, '/sentences/show/'.$sentenceId); @@ -172,8 +172,8 @@ public function delete($sentenceId, $translationId) if ($acceptsJson) { $this->_returnSentenceAndTranslations($sentenceId); } else if ($this->request->is('ajax')) { - if (isset($this->request->data['returnTranslations']) - && (bool)$this->request->data['returnTranslations']) + if (null !== $this->request->getData('returnTranslations') + && (bool)$this->request->getData('returnTranslations')) $this->_renderTranslationsOf($sentenceId, $flashMessage); } else { $this->flash($flashMessage, '/sentences/show/'.$sentenceId); diff --git a/src/Controller/SentenceAnnotationsController.php b/src/Controller/SentenceAnnotationsController.php index d9ba562338..e713665716 100644 --- a/src/Controller/SentenceAnnotationsController.php +++ b/src/Controller/SentenceAnnotationsController.php @@ -91,7 +91,7 @@ public function show($sentenceId = null) */ public function save() { - if (empty($this->request->data)) { + if (empty($this->request->getData())) { return; } diff --git a/src/Controller/SentenceCommentsController.php b/src/Controller/SentenceCommentsController.php index 390ed18a39..09509b2a8c 100644 --- a/src/Controller/SentenceCommentsController.php +++ b/src/Controller/SentenceCommentsController.php @@ -91,7 +91,7 @@ public function beforeFilter(Event $event) ); $eventManager = $this->SentenceComments->getEventManager(); - $eventManager->attach(new NotificationListener()); + $eventManager->on(new NotificationListener()); // disable Form Tampering Protection for actions where it's no big deal // (it was only protecting against changing the sentence_id) diff --git a/src/Controller/SentencesController.php b/src/Controller/SentencesController.php index 2629ef49ba..ab6c5de55f 100644 --- a/src/Controller/SentencesController.php +++ b/src/Controller/SentencesController.php @@ -86,9 +86,8 @@ class SentencesController extends AppController public function initialize() { parent::initialize(); - $params = $this->request->params; $noCsrfActions = ['edit_sentence', 'change_language']; - if (in_array($params['action'], $noCsrfActions)) { + if (in_array($this->request->getParam('action'), $noCsrfActions)) { $this->components()->unload('Csrf'); } } @@ -100,7 +99,7 @@ public function initialize() { */ public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'add_an_other_sentence', 'save_translation', 'change_language', @@ -337,7 +336,7 @@ public function add_an_other_sentence() public function edit_sentence() { $acceptsJson = $this->request->accepts('application/json'); - $sentence = $this->Sentences->editSentence($this->request->data); + $sentence = $this->Sentences->editSentence($this->request->getData()); if ($acceptsJson) { $sentence = $this->Sentences->getSentenceWith($sentence->id); $this->loadComponent('RequestHandler'); @@ -507,7 +506,7 @@ public function search() $limit = CurrentUser::getSetting('sentences_per_page'); $sphinx = $search->asSphinx(); - $sphinx['page'] = $this->request->query('page'); + $sphinx['page'] = $this->request->getQuery('page'); $sphinx['limit'] = $limit; $model = 'Sentences'; @@ -733,11 +732,11 @@ public function of_user($userName, $lang = null) */ public function change_language() { - if (isset($this->request->data['id']) - && isset($this->request->data['newLang']) + if (null !== $this->request->getData('id') + && null !== $this->request->getData('newLang') ) { - $newLang = $this->request->data['newLang']; - $id = $this->request->data['id']; + $newLang = $this->request->getData('newLang'); + $id = $this->request->getData('id'); $lang = $this->Sentences->changeLanguage($id, $newLang); $this->loadModel('UsersSentences'); diff --git a/src/Controller/SentencesListsController.php b/src/Controller/SentencesListsController.php index b68f2847bc..6e95603cf7 100644 --- a/src/Controller/SentencesListsController.php +++ b/src/Controller/SentencesListsController.php @@ -64,14 +64,14 @@ class SentencesListsController extends AppController public function initialize() { parent::initialize(); - $params = $this->request->params; + $request = $this->request; $noCsrfActions = [ 'set_option', 'save_name', 'add_new_sentence_to_list', 'add_sentence_to_new_list' ]; - if (in_array($params['action'], $noCsrfActions)) { + if (in_array($request->getParam('action'), $noCsrfActions)) { $this->components()->unload('Csrf'); } } @@ -84,7 +84,7 @@ public function initialize() { */ public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'set_option', 'save_name', 'add_new_sentence_to_list', @@ -481,7 +481,7 @@ public function set_option() $userId ); - $this->response->header('Content-Type: application/json'); + $this->response->withHeader('Content-Type', 'application/json'); if ($result) { $this->set('result', json_encode( $result->extract(['id', 'name', 'user_id', 'editable_by']) diff --git a/src/Controller/ToolsController.php b/src/Controller/ToolsController.php index 257c1c4b14..c35c1f3274 100644 --- a/src/Controller/ToolsController.php +++ b/src/Controller/ToolsController.php @@ -122,11 +122,11 @@ public function furigana() */ public function conversion_simplified_traditional_chinese() { - if (empty($this->request->data['Tool'])) { + if (empty($this->request->getData('Tool'))) { return; } - $text = $this->request->data['Tool']['query']; + $text = $this->request->getData('Tool')['query']; if (!empty($text)) { $script = $this->Transcription->detectScript('cmn', $text); @@ -161,8 +161,8 @@ public function conversion_simplified_traditional_chinese() */ public function shanghainese_to_ipa($text = null) { - if (empty($text) && !empty($this->request->data['Tool'])) { - $text = $this->request->data['Tool']['query']; + if (empty($text) && !empty($this->request->getData('Tool'))) { + $text = $this->request->getData('Tool')['query']; } if (!empty($text)) { diff --git a/src/Controller/TranscriptionsController.php b/src/Controller/TranscriptionsController.php index 16196e4dbc..db6cbe6b2d 100644 --- a/src/Controller/TranscriptionsController.php +++ b/src/Controller/TranscriptionsController.php @@ -42,7 +42,7 @@ class TranscriptionsController extends AppController public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'save', 'reset' ]); @@ -116,7 +116,7 @@ public function save($sentenceId, $script) { $data = array( 'sentence_id' => $sentenceId, 'script' => $script, - 'text' => $this->request->data['value'], + 'text' => $this->request->getData()['value'], 'user_id' => CurrentUser::get('id'), ); if ($transcr) { // Modifying existing transcription @@ -197,6 +197,6 @@ private function setViewVars($transcriptions, $sentenceId, $sentence = null) { $this->set('transcr', $transcriptions); $this->set('validationErrors', $this->Transcriptions->validationErrors); - $this->viewBuilder()->autoLayout(false); + $this->viewBuilder()->enableAutoLayout(false); } } diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 9429c85146..3113b6b40c 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -74,7 +74,7 @@ class UserController extends AppController public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'save_banner_setting', ]); diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index a084ab1aa2..532096181d 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -564,7 +564,7 @@ public function for_language($lang = null) public function login_dialog_template() { - $redirectUrl = $this->request->query('redirect'); + $redirectUrl = $this->request->getQuery('redirect'); $this->set('redirectUrl', $redirectUrl); $this->viewBuilder()->enableAutoLayout(false); } diff --git a/src/Controller/UsersLanguagesController.php b/src/Controller/UsersLanguagesController.php index be9f6a1d2d..17df2668f4 100644 --- a/src/Controller/UsersLanguagesController.php +++ b/src/Controller/UsersLanguagesController.php @@ -47,7 +47,7 @@ class UsersLanguagesController extends AppController public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'save', ]); diff --git a/src/Controller/VocabularyController.php b/src/Controller/VocabularyController.php index 7754a795d4..3b623d4017 100644 --- a/src/Controller/VocabularyController.php +++ b/src/Controller/VocabularyController.php @@ -55,7 +55,7 @@ class VocabularyController extends AppController */ public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'save', 'save_sentence' ]); return parent::beforeFilter($event); diff --git a/src/Controller/WallController.php b/src/Controller/WallController.php index a6df20fa64..a91fef1188 100644 --- a/src/Controller/WallController.php +++ b/src/Controller/WallController.php @@ -69,12 +69,12 @@ class WallController extends AppController public function beforeFilter(Event $event) { - $this->Security->config('unlockedActions', [ + $this->Security->setConfig('unlockedActions', [ 'save_inside', ]); $eventManager = $this->Wall->getEventManager(); - $eventManager->attach(new NotificationListener()); + $eventManager->on(new NotificationListener()); return parent::beforeFilter($event); } diff --git a/src/Event/NotificationListener.php b/src/Event/NotificationListener.php index d81e817a5f..d3fe534d65 100644 --- a/src/Event/NotificationListener.php +++ b/src/Event/NotificationListener.php @@ -75,16 +75,17 @@ public function sendWallReplyNotification($event) { $author = $User->getUsernameFromId($post['owner']); $subject = 'Tatoeba - ' . $author . ' has replied to you on the Wall'; - $this->Email + $email = $this->Email ->setTo($recipient) ->setSubject($subject) - ->setTemplate('wall_reply') ->setViewVars(array( 'author' => $author, 'postId' => $post['id'], 'messageContent' => $post['content'] - )) - ->send(); + )); + + $email->viewBuilder()->setTemplate('wall_reply'); + $email->send(); } public function sendPmNotification($event) { @@ -101,17 +102,18 @@ public function sendPmNotification($event) { $title = $message['title']; $content = $message['content']; - $this->Email + $email = $this->Email ->setTo($recipientEmail) ->setSubject('Tatoeba PM - ' . $title) - ->setTemplate('new_private_message') ->setViewVars(array( 'sender' => $sender, 'title' => $title, 'message' => $content, 'messageId' => $message['id'], - )) - ->send(); + )); + + $email->viewBuilder()->setTemplate('new_private_message'); + $email->send(); } private function _getMentionedUsernames($comment) @@ -182,17 +184,18 @@ private function _sendSentenceCommentNotification($recipient, $comment) { } $commentText = $comment['text']; - $this->Email + $email = $this->Email ->setTo($recipient) ->setSubject($subject) - ->setTemplate('comment_on_sentence') ->setViewVars(array( 'author' => $comment['author'], 'commentText' => $commentText, 'sentenceIsDeleted' => $sentenceIsDeleted, 'sentenceText' => $sentenceText, 'sentenceId' => $sentenceId, - )) - ->send(); + )); + + $email->viewBuilder()->setTemplate('comment_on_sentence'); + $email->send(); } } diff --git a/src/Model/Behavior/LimitResultsBehavior.php b/src/Model/Behavior/LimitResultsBehavior.php index 186c62f09c..ae0f310481 100644 --- a/src/Model/Behavior/LimitResultsBehavior.php +++ b/src/Model/Behavior/LimitResultsBehavior.php @@ -93,7 +93,7 @@ private function removeLeftJoins(Query $query) { * performance. */ public function findLatest(Query $query, array $options) { - $alias = $query->repository()->getAlias(); + $alias = $query->getRepository()->getAlias(); $additionalOrder = [$alias . '.id' => 'DESC']; $contain = $this->getMinimalContain($query); diff --git a/src/Model/Table/ExportsTable.php b/src/Model/Table/ExportsTable.php index 619934ec79..2fbd7063df 100644 --- a/src/Model/Table/ExportsTable.php +++ b/src/Model/Table/ExportsTable.php @@ -77,10 +77,10 @@ public function buildRules(RulesChecker $rules) $rules->add($rules->existsIn(['user_id'], 'Users')); $rules->add(function ($entity) { - $data = $entity->extract($this->schema()->columns(), true); - $validator = $this->validator('default'); - $errors = $validator->errors($data, $entity->isNew()); - $entity->errors($errors); + $data = $entity->extract($this->getSchema()->columns(), true); + $validator = $this->getValidator('default'); + $errors = $validator->validate($data, $entity->isNew()); + $entity->getErrors($errors); return empty($errors); }); diff --git a/src/Model/Table/VocabularyTable.php b/src/Model/Table/VocabularyTable.php index e94d6d8110..e63b5f9c6b 100644 --- a/src/Model/Table/VocabularyTable.php +++ b/src/Model/Table/VocabularyTable.php @@ -67,7 +67,7 @@ public function validationDefault(Validator $validator) public function beforeSave($event, $entity, $options) { - if ($entity->isNew() || $entity->dirty('lang') || $entity->dirty('text')) { + if ($entity->isNew() || $entity->isDirty('lang') || $entity->isDirty('text')) { $lang = $entity->lang; $text = $entity->text; $entity->numSentences = $this->_getNumberOfSentences($lang, $text); diff --git a/src/Shell/Task/QueueSwitchSentencesLicenseTask.php b/src/Shell/Task/QueueSwitchSentencesLicenseTask.php index 48efd4dfa9..8aa8160e31 100644 --- a/src/Shell/Task/QueueSwitchSentencesLicenseTask.php +++ b/src/Shell/Task/QueueSwitchSentencesLicenseTask.php @@ -94,7 +94,7 @@ private function _switchLicense($entities, $options) { __("Unable to change the license of sentence {id} to “{newLicense}” because:"), compact('id', 'newLicense') ); - $errors = $data->errors('license'); + $errors = $data->getError('license'); $this->out($message."\n - ".implode("\n - ", $errors)); } } diff --git a/src/Shell/TranscriptionsShell.php b/src/Shell/TranscriptionsShell.php index db7973ffea..1ddd15d68d 100644 --- a/src/Shell/TranscriptionsShell.php +++ b/src/Shell/TranscriptionsShell.php @@ -42,7 +42,7 @@ private function detectTranscriptionsFor($entities) { $text = $entity->text; $entity->script = $this->Transcriptions->detectScript($lang, $text); if ($entity->has('modified')) - $entity->dirty('modified', true); + $entity->setDirty('modified', true); } return $entities; } diff --git a/src/Template/Activities/translate_sentences.ctp b/src/Template/Activities/translate_sentences.ctp index e3d443fd8c..350ac19edb 100644 --- a/src/Template/Activities/translate_sentences.ctp +++ b/src/Template/Activities/translate_sentences.ctp @@ -105,7 +105,7 @@ $langsTo = $this->Languages->profileLanguagesArray();
Form->create( - 'Activity', + null, array( "url" => array("action" => "translate_sentences"), "type" => "get" diff --git a/src/Template/Audio/import.ctp b/src/Template/Audio/import.ctp index 4139ef14c5..45e5fb42c9 100644 --- a/src/Template/Audio/import.ctp +++ b/src/Template/Audio/import.ctp @@ -215,7 +215,7 @@ if ($filesToImport): ?> 'inside the import directory.'); ?>

Form->input('audioAuthor', ['required' => true]); +echo $this->Form->control('audioAuthor', ['required' => true]); echo $this->Form->submit(__d('admin', 'Import'), $canImport ? [] : ['disabled' => true]); echo $this->Form->end(); ?> diff --git a/src/Template/Audio/of.ctp b/src/Template/Audio/of.ctp index 249cef13ff..ba7fb41bb4 100644 --- a/src/Template/Audio/of.ctp +++ b/src/Template/Audio/of.ctp @@ -45,13 +45,13 @@ if (isset($sentencesWithAudio)) { 'url' => array('controller' => 'audio', 'action' => 'save_settings'), 'type' => 'post', )); - echo $this->Form->input('audio_license', array( + echo $this->Form->control('audio_license', array( 'label' => __('License:'), 'options' => $this->AudioLicense->getLicenseOptions() )); ?> - Form->input('audio_attribution_url', array( + Form->control('audio_attribution_url', array( 'label' => __('Attribution URL:'), )) ?>
diff --git a/src/Template/CategoriesTree/manage.ctp b/src/Template/CategoriesTree/manage.ctp index c9468b0967..0f491895f2 100644 --- a/src/Template/CategoriesTree/manage.ctp +++ b/src/Template/CategoriesTree/manage.ctp @@ -33,9 +33,9 @@ $messages = [
request['?'])) { - $action = array_keys($this->request['?'])[0]; - $error = ($this->request['?'][$action] == '0'); + if (null !== $this->request->getParam('?')) { + $action = array_keys($this->request->getParam('?'))[0]; + $error = ($this->request->getParam('?')[$action] == '0'); if (array_key_exists($action, $messages) && $error) { ?>
@@ -56,7 +56,7 @@ $messages = [
Form->create( - 'CreateOrEditCategory', + null, [ 'url' => [ 'controller' => 'categoriesTree', @@ -68,7 +68,7 @@ $messages = [ Form->input( + echo $this->Form->control( 'name', [ 'label' => __d('beta', 'Name (required)') @@ -79,7 +79,7 @@ $messages = [ Form->input( + echo $this->Form->control( 'description', [ 'label' => __d('beta', 'Description (optional)') @@ -90,7 +90,7 @@ $messages = [ Form->input( + echo $this->Form->control( 'parentName', [ 'id' => 'parentName', @@ -122,7 +122,7 @@ $messages = [
Form->create( - 'AttachTag', + null, [ 'url' => [ 'controller' => 'categories_tree', @@ -134,7 +134,7 @@ $messages = [ Form->input( + echo $this->Form->control( 'tagName', [ 'id' => 'tagName', @@ -147,7 +147,7 @@ $messages = [ Form->input( + echo $this->Form->control( 'categoryName', [ 'id' => 'categoryName', diff --git a/src/Template/Element/advanced_search_form.ctp b/src/Template/Element/advanced_search_form.ctp index 0c65202e25..b53666a230 100644 --- a/src/Template/Element/advanced_search_form.ctp +++ b/src/Template/Element/advanced_search_form.ctp @@ -21,7 +21,7 @@ $layout = isset($isSidebar) && $isSidebar ? 'column' : 'row'; $this->Html->script('sentences/search.ctrl.js', ['block' => 'scriptBottom']); -echo $this->Form->create('AdvancedSearch', [ +echo $this->Form->create(null, [ 'id' => 'advanced-search', 'url' => false, 'name' => 'form', @@ -59,7 +59,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('query', array( + echo $this->Form->control('query', array( 'label' => __('Words:'), 'lang' => '', 'dir' => 'auto', @@ -148,7 +148,7 @@ echo $this->Form->create('AdvancedSearch', [ Form->input('user', array( + echo $this->Form->control('user', array( 'label' => __('Owner:'), 'id' => 'OwnerSearch', 'ng-model' => 'filters.user', @@ -165,7 +165,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('orphans', [ + echo $this->Form->control('orphans', [ 'label' => '', 'options' => [ /* @translators: dropdown option of "Is orphan" field in search form */ @@ -189,7 +189,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('unapproved', array( + echo $this->Form->control('unapproved', array( 'label' => '', 'options' => array( /* @translators: dropdown option of "Is unapproved" field in search form */ @@ -210,7 +210,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('has_audio', array( + echo $this->Form->control('has_audio', array( 'label' => '', 'options' => array( /* @translators: dropdown option of "Has audio" field in search form */ @@ -226,7 +226,7 @@ echo $this->Form->create('AdvancedSearch', [ Form->input('tags', array( + echo $this->Form->control('tags', array( 'label' => __('Tags:'), 'id' => 'TagSearch', 'ng-model' => 'filters.tags', @@ -246,7 +246,7 @@ echo $this->Form->create('AdvancedSearch', [
Lists->listsAsSelectable($searchableLists->toList()); - echo $this->Form->input('list', [ + echo $this->Form->control('list', [ 'class' => 'list-select', 'label' => '', 'options' => $this->safeForAngular($listOptions), @@ -316,7 +316,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('trans_link', array( + echo $this->Form->control('trans_link', array( 'label' => '', 'options' => array( /* @translators: dropdown option of "Link" field in search form */ @@ -334,7 +334,7 @@ echo $this->Form->create('AdvancedSearch', [ Form->input('trans_user', array( + echo $this->Form->control('trans_user', array( 'label' => __('Owner:'), 'id' => 'TranslatorSearch', 'ng-model' => 'filters.trans_user', @@ -351,7 +351,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('trans_orphan', array( + echo $this->Form->control('trans_orphan', array( 'label' => '', 'options' => array( '' => __x('orphan', 'Any'), @@ -372,7 +372,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('trans_unapproved', array( + echo $this->Form->control('trans_unapproved', array( 'label' => '', 'options' => array( '' => __x('unapproved', 'Any'), @@ -392,7 +392,7 @@ echo $this->Form->create('AdvancedSearch', [
Form->input('trans_has_audio', array( + echo $this->Form->control('trans_has_audio', array( 'label' => '', 'options' => array( '' => __x('audio', 'Any'), @@ -416,7 +416,7 @@ echo $this->Form->create('AdvancedSearch', [ Form->input('sort', array( + echo $this->Form->control('sort', array( 'label' => '', 'options' => array( /* @translators: sort order dropdown option in search form */ diff --git a/src/Template/Element/announcement.ctp b/src/Template/Element/announcement.ctp index 16a4239b1b..dd849621ca 100644 --- a/src/Template/Element/announcement.ctp +++ b/src/Template/Element/announcement.ctp @@ -41,7 +41,7 @@ if (!CurrentUser::hasAcceptedNewTermsOfUse()) { 'controller' => 'pages', 'action' => 'contact' ]); - echo $this->Form->create('Users', [ + echo $this->Form->create(null, [ 'class' => 'announcement md-whiteframe-1dp', 'url' => ['controller' => 'user', 'action' => 'accept_new_terms_of_use'] ]); diff --git a/src/Template/Element/pmmenu.ctp b/src/Template/Element/pmmenu.ctp index 93473136d9..4dd480fb87 100644 --- a/src/Template/Element/pmmenu.ctp +++ b/src/Template/Element/pmmenu.ctp @@ -31,9 +31,9 @@ $dratftsUrl = $this->Url->build(['action' => 'folder', 'Drafts']); $sentUrl = $this->Url->build(['action' => 'folder', 'Sent']); $trashUrl = $this->Url->build(['action' => 'folder', 'Trash']); -$isTrashFolder = $this->request->params['action'] == 'folder' - && $this->request->params['pass'] - && $this->request->params['pass'][0] == 'Trash'; +$isTrashFolder = $this->request->getParam('action') == 'folder' + && $this->request->getParam('pass') + && $this->request->getParam('pass')[0] == 'Trash'; ?> Form->input('title', [ + echo $this->Form->control('title', [ /* @translators: title field label in private message form */ 'label' => __('Title'), 'value' => $this->safeForAngular($pm->title), diff --git a/src/Template/Element/search_bar.ctp b/src/Template/Element/search_bar.ctp index 0579fd05d8..91996f8d24 100644 --- a/src/Template/Element/search_bar.ctp +++ b/src/Template/Element/search_bar.ctp @@ -33,7 +33,7 @@ $searchQuery = h(str_replace('{{', '\{\{', json_encode($searchQuery)));
Form->create('Sentence', [ + echo $this->Form->create(null, [ 'layout' => 'column', 'url' => ['controller' => 'sentences', 'action' => 'search'], 'type' => 'get', @@ -63,16 +63,13 @@ $searchQuery = h(str_replace('{{', '\{\{', json_encode($searchQuery))); Form->create( - 'Sentence', - array( - 'id' => 'SentenceSearchForm', - 'name' => 'ctrl.form', - "url" => false, - 'ng-submit' => 'ctrl.submit(ctrl.form)', - "type" => "get" - ) -); +echo $this->Form->create(null, [ + 'id' => 'SentenceSearchForm', + 'name' => 'ctrl.form', + "url" => false, + 'ng-submit' => 'ctrl.submit(ctrl.form)', + "type" => "get" +]); ?>
Form->create('', [ + echo $this->Form->create(null, [ 'url' => ['controller' => 'sentence_comments', 'action' => 'save'] ]); echo $this->Form->hidden('sentence_id', ['value' => $sentenceId]); diff --git a/src/Template/Element/sentences/add_sentences_jquery.ctp b/src/Template/Element/sentences/add_sentences_jquery.ctp index a680ad7265..e1ea38e977 100644 --- a/src/Template/Element/sentences/add_sentences_jquery.ctp +++ b/src/Template/Element/sentences/add_sentences_jquery.ctp @@ -15,7 +15,7 @@ $this->Html->script(JS_PATH . 'sentences.contribute.js', ['block' => 'scriptBott } else { $preSelectedLang = $this->request->getSession()->read('contribute_lang'); - echo $this->Form->create('Sentence', [ + echo $this->Form->create(null, [ 'id' => 'sentence-form', 'url' => '/sentences/add_an_other_sentence', 'onsubmit' => 'return false', diff --git a/src/Template/Element/sentences/navigation.ctp b/src/Template/Element/sentences/navigation.ctp index 47547eb301..dce4fdcf3f 100644 --- a/src/Template/Element/sentences/navigation.ctp +++ b/src/Template/Element/sentences/navigation.ctp @@ -62,9 +62,9 @@ $sentenceUrl = $this->Url->build([ Form->create('Sentence', [ + echo $this->Form->create(null, [ 'id' => 'go-to-form', - 'url' => ['action' => 'go_to_sentence'], + 'url' => ['controller' => 'sentences', 'action' => 'go_to_sentence'], 'type' => 'get', 'hide-xs' => '', 'layout' => 'row', @@ -73,7 +73,7 @@ $sentenceUrl = $this->Url->build([ ?> Form->input('sentence_id', [ + echo $this->Form->control('sentence_id', [ 'type' => 'text', 'label' => __('Show sentence #: '), 'value' => $currentId, diff --git a/src/Template/Element/short_description.ctp b/src/Template/Element/short_description.ctp index e1436ead5e..9e2dc1f988 100644 --- a/src/Template/Element/short_description.ctp +++ b/src/Template/Element/short_description.ctp @@ -46,7 +46,7 @@
- Form->input('user_id', + Form->control('user_id', array( 'type' => 'text', 'label' => __d('admin', 'Numeric user id: ') @@ -75,7 +75,7 @@ $langArray = $this->Languages->onlyLanguagesArray();

Form->create( - 'Import', + null, array( 'url' => array( 'action' => 'import_sentences_with_translation' @@ -100,7 +100,7 @@ $langArray = $this->Languages->onlyLanguagesArray();
- Form->input('user_id', + Form->control('user_id', array( 'type' => 'text', 'label' => __d('admin', 'Numeric user id: ') diff --git a/src/Template/Sentences/of_user.ctp b/src/Template/Sentences/of_user.ctp index b6fec58be4..20fda5f888 100644 --- a/src/Template/Sentences/of_user.ctp +++ b/src/Template/Sentences/of_user.ctp @@ -30,7 +30,7 @@ if ($userExists === true) { $numberOfSentences = $this->Paginator->param('count'); $this->Paginator->options( array( - 'url' => $this->request->params['pass'] + 'url' => $this->request->getParam('pass') ) ); diff --git a/src/Template/Sentences/show.ctp b/src/Template/Sentences/show.ctp index bb59779052..442fdb8999 100644 --- a/src/Template/Sentences/show.ctp +++ b/src/Template/Sentences/show.ctp @@ -57,9 +57,9 @@ if (isset($sentence)) { } else { // Case where the sentence has been deleted $this->set('title_for_layout', $this->Pages->formatTitle( - __('Sentence does not exist: ') . $this->request->params['pass'][0] + __('Sentence does not exist: ') . $this->request->getParam('pass')[0] )); - $sentenceId = $this->request->params['pass'][0]; + $sentenceId = $this->request->getParam('pass')[0]; } @@ -109,7 +109,7 @@ echo $this->element('/sentences/navigation', [ 'There is no sentence with id {number}', true ), - array('number' => $this->request->params['pass'][0]) + array('number' => $this->request->getParam('pass')[0]) ); echo '
'; } diff --git a/src/Template/Tags/view_all.ctp b/src/Template/Tags/view_all.ctp index 8e09d064b4..8f943eb15a 100644 --- a/src/Template/Tags/view_all.ctp +++ b/src/Template/Tags/view_all.ctp @@ -36,13 +36,13 @@ $tagsIndexUrl = $this->Url->build([
Html->tag('h2', __('Search tags')); - echo $this->Form->create('Tags', [ + echo $this->Form->create(null, [ 'url' => array('action' => 'search'), ]); ?> Form->input('search', [ + echo $this->Form->control('search', [ 'value' => $this->safeForAngular($filter), 'label' => false, ]); diff --git a/src/Template/User/edit_profile.ctp b/src/Template/User/edit_profile.ctp index f9a090e53a..192dbfec43 100644 --- a/src/Template/User/edit_profile.ctp +++ b/src/Template/User/edit_profile.ctp @@ -45,7 +45,7 @@ $this->Languages->localizedAsort($countries);
Form->create( - 'profile_image', + null, array( 'url' => array( 'controller' => 'user', @@ -81,7 +81,7 @@ $this->Languages->localizedAsort($countries);
Form->create( - 'profile_image', + null, array( 'url' => array( 'controller' => 'user', diff --git a/src/Template/User/settings.ctp b/src/Template/User/settings.ctp index 059d2c548b..9a74c55a42 100644 --- a/src/Template/User/settings.ctp +++ b/src/Template/User/settings.ctp @@ -87,7 +87,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings')));

Form->input( + echo $this->Form->control( 'settings.is_public', array( 'value' => '{{isPublic}}' @@ -114,7 +114,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings'))); ) ?>

Form->input( + echo $this->Form->control( 'settings.use_most_recent_list', array( 'value' => '{{useRecent}}' @@ -140,7 +140,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings'))); ) ?>

Form->input( + echo $this->Form->control( 'settings.collapsible_translations', array( 'value' => '{{collapsibleTranslations}}' @@ -162,7 +162,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings')));

Form->input( + echo $this->Form->control( 'settings.show_transcriptions', array( 'value' => '{{showTranscriptions}}' @@ -187,7 +187,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings')));

Form->input( + echo $this->Form->control( 'settings.hide_random_sentence', array( 'value' => '{{hideRandomSentence}}' @@ -230,7 +230,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings')));

- Form->input('settings.sentences_per_page', array( + Form->control('settings.sentences_per_page', array( 'options' => array(10 => 10, 20 => 20, 50 => 50, 100 => 100), 'label' => '' )); ?> @@ -238,7 +238,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings')));

- Form->input('settings.max_visible_translations', [ + Form->control('settings.max_visible_translations', [ 'options' => [5 => 5, 10 => 10, 20 => 20, 50 => 50], 'label' => '' ]); ?> @@ -247,7 +247,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings'))); settings['can_switch_license']) : ?>

- Form->input('settings.default_license', [ + Form->control('settings.default_license', [ 'options' => $this->SentenceLicense->getLicenseOptions(), 'label' => '' ]); ?> @@ -282,7 +282,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings')));

Form->input( + echo $this->Form->control( 'settings.users_collections_ratings', array( 'value' => '{{collectionRatings}}' @@ -311,7 +311,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings'))); ) ?>

Form->input( + echo $this->Form->control( 'settings.native_indicator', array( 'value' => '{{nativeIndicator}}' @@ -335,7 +335,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Settings'))); ) ?>

Form->input( + echo $this->Form->control( 'settings.use_new_design', array( 'value' => '{{1-useOldDesign}}' diff --git a/src/Template/Users/all.ctp b/src/Template/Users/all.ctp index 464ff84a65..1f3e6c9fc0 100644 --- a/src/Template/Users/all.ctp +++ b/src/Template/Users/all.ctp @@ -43,12 +43,12 @@ $this->set('title_for_layout', $this->Pages->formatTitle(__('Members')));

Security->enableCSRFProtection(); - echo $this->Form->create('User', ['url' => ['action' => 'search']]); + echo $this->Form->create(null, ['url' => ['action' => 'search']]); ?> Form->input('search_username',[ + echo $this->Form->control('search_username',[ 'id' => 'usernameInput', 'label' => '', ]); diff --git a/src/Template/Users/edit.ctp b/src/Template/Users/edit.ctp index 1518358cbc..5ee3c5da48 100644 --- a/src/Template/Users/edit.ctp +++ b/src/Template/Users/edit.ctp @@ -82,14 +82,14 @@ echo $this->Form->create($user, array('id' => 'UserEditForm'));
Form->input('id', array('label' => __d('admin', 'Id'))); - echo $this->Form->input('username', array('label' => __d('admin', 'Username'))); - echo $this->Form->input('settings.lang', array('label' => __d('admin', 'Lang'))); - echo $this->Form->input('role', array( + echo $this->Form->control('id', array('label' => __d('admin', 'Id'))); + echo $this->Form->control('username', array('label' => __d('admin', 'Username'))); + echo $this->Form->control('settings.lang', array('label' => __d('admin', 'Lang'))); + echo $this->Form->control('role', array( 'options' => array_combine($groups, $groups), 'label' => __d('admin', 'Group'), )); - echo $this->Form->input( + echo $this->Form->control( 'level', array( 'type' => 'radio', @@ -101,11 +101,11 @@ echo $this->Form->create($user, array('id' => 'UserEditForm')); ) ); echo '
'; - echo $this->Form->input('send_notifications', array( + echo $this->Form->control('send_notifications', array( 'label' => __d('admin', 'Send notifications') )); - echo $this->Form->input('settings.can_switch_license', [ + echo $this->Form->control('settings.can_switch_license', [ 'type' => 'checkbox', 'label' => __('Can switch license') ]); diff --git a/src/Template/Users/login.ctp b/src/Template/Users/login.ctp index 6580146fa2..e5dc45359e 100644 --- a/src/Template/Users/login.ctp +++ b/src/Template/Users/login.ctp @@ -65,7 +65,7 @@ $registerUrl = $this->Url->build( $this->Security->enableCSRFProtection(); echo $this->Form->create( - 'User', + null, array( 'url' => $formTarget, 'id' => "UserLoginForm" @@ -78,7 +78,7 @@ echo $this->Form->create(
Form->input( + echo $this->Form->control( 'username', array( 'label' => __('Username'), ) @@ -88,7 +88,7 @@ echo $this->Form->create( Form->input( + echo $this->Form->control( 'password', array( 'label' => __('Password'), ) diff --git a/src/Template/Users/login_dialog_template.ctp b/src/Template/Users/login_dialog_template.ctp index 1a98fb0a70..fdd968cee9 100644 --- a/src/Template/Users/login_dialog_template.ctp +++ b/src/Template/Users/login_dialog_template.ctp @@ -11,11 +11,13 @@ $passwordUrl = $this->Url->build([ Security->enableCSRFProtection(); -echo $this->Form->create('User', ['url' => [ - 'controller' => 'users', - 'action' => 'check_login', - '?' => [AuthComponent::QUERY_STRING_REDIRECT => $redirectUrl], -]]); +echo $this->Form->create(null, [ + 'url' => [ + 'controller' => 'users', + 'action' => 'check_login', + '?' => [AuthComponent::QUERY_STRING_REDIRECT => $redirectUrl], + ] +]); ?> @@ -27,7 +29,7 @@ echo $this->Form->create('User', ['url' => [ Form->input('username', [ + echo $this->Form->control('username', [ 'label' => __('Username'), 'md-autofocus' => '' ]); @@ -36,7 +38,7 @@ echo $this->Form->create('User', ['url' => [ Form->input('password', [ + echo $this->Form->control('password', [ 'label' => __('Password') ]); ?> diff --git a/src/Template/Users/new_password.ctp b/src/Template/Users/new_password.ctp index 9ef6e428e8..b6e5ac3aed 100644 --- a/src/Template/Users/new_password.ctp +++ b/src/Template/Users/new_password.ctp @@ -42,13 +42,13 @@ $this->Security->enableCSRFProtection();

- Form->create('User', array( + Form->create(null, array( "ng-cloak" => true, "url" => array("action" => "new_password") )); ?> - Form->input('email', [ + Form->control('email', [ 'label' => __('Email'), ]) ?> diff --git a/src/Template/Users/register.ctp b/src/Template/Users/register.ctp index 249ea808fb..381f293953 100644 --- a/src/Template/Users/register.ctp +++ b/src/Template/Users/register.ctp @@ -64,7 +64,7 @@ $label = format( person Form->input( + echo $this->Form->control( 'username', array( 'label' => '', @@ -114,7 +114,7 @@ $label = format( lock Form->input( + echo $this->Form->control( 'password', array( 'label' => '', @@ -161,7 +161,7 @@ $label = format( email Form->input( + echo $this->Form->control( 'email', array( 'label' => '', @@ -204,7 +204,7 @@ $label = format( email Form->input( + echo $this->Form->control( 'confirm', array( /* @translators: This is a simple countermeasure against spam bots trying to diff --git a/src/Template/Vocabulary/add.ctp b/src/Template/Vocabulary/add.ctp index 2910d95e03..2f448a7cb9 100644 --- a/src/Template/Vocabulary/add.ctp +++ b/src/Template/Vocabulary/add.ctp @@ -56,7 +56,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle($title));
- Form->create('Vocabulary', [ + Form->create(null, [ 'ng-cloak' => true, 'id' => 'add-vocabulary-form', 'ng-submit' => 'ctrl.add()', @@ -86,7 +86,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle($title));
- Form->input('text', [ + Form->control('text', [ 'label' => __('Vocabulary item'), 'ng-model' => 'ctrl.data.text', 'ng-disabled' => 'ctrl.isAdding', diff --git a/src/Template/Vocabulary/add_sentences.ctp b/src/Template/Vocabulary/add_sentences.ctp index e5bc1150ea..3a2b247945 100644 --- a/src/Template/Vocabulary/add_sentences.ctp +++ b/src/Template/Vocabulary/add_sentences.ctp @@ -108,7 +108,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle($title));
- Form->create('Vocabulary', [ + Form->create(null, [ 'id' => 'form_'.$id, 'url' => ['controller' => 'vocabulary', 'action' => 'save_sentence', $id], 'class' => 'sentence-form', @@ -121,7 +121,7 @@ $this->set('title_for_layout', $this->Pages->formatTitle($title)); ]); ?> Form->hidden('lang', ['value' => $lang]) ?> - Form->input('text', [ + Form->control('text', [ 'id' => 'form_'.$id.'_input', /* @translators: sentence text field label of sentence addition form on vocabulary page */ 'label' => __('Sentence'), diff --git a/src/View/Helper/AppHelper.php b/src/View/Helper/AppHelper.php index 73352383e3..0467f982f6 100644 --- a/src/View/Helper/AppHelper.php +++ b/src/View/Helper/AppHelper.php @@ -49,10 +49,10 @@ class AppHelper extends Helper public function url($url = null, $full = false) { - if (isset($this->request->params['lang']) + if (isset($this->getView()->getRequest()->params['lang']) && is_array($url) && !isset($url['lang'])) { - $url['lang'] = $this->request->params['lang']; + $url['lang'] = $this->getView()->getRequest()->params['lang']; } diff --git a/src/View/Helper/ClickableLinksHelper.php b/src/View/Helper/ClickableLinksHelper.php index f2347be8e8..ba6c2d0b87 100644 --- a/src/View/Helper/ClickableLinksHelper.php +++ b/src/View/Helper/ClickableLinksHelper.php @@ -132,7 +132,7 @@ public function clickableSentence($text) $this::SENTENCE_ID_PATTERN, function ($m) use ($self, $model) { return $m[1] . $self->Html->link($m[2], - $self->request->scheme().'://'.$self->request->host().'/sentences/show/'.$m[3], + $self->getView()->getRequest()->scheme().'://'.$self->getView()->getRequest()->host().'/sentences/show/'.$m[3], array('title' => $model->getSentenceTextForId($m[3])) ); }, $text); diff --git a/src/View/Helper/CommonModulesHelper.php b/src/View/Helper/CommonModulesHelper.php index 59b005f829..27653a5e0b 100644 --- a/src/View/Helper/CommonModulesHelper.php +++ b/src/View/Helper/CommonModulesHelper.php @@ -68,11 +68,11 @@ public function createFilterByLangMod($maxNumberOfParams = 1) // without the language parameter $path ='/'; // language of the interface - $path .= $this->request->getParam('lang') .'/'; - $path .= Inflector::delimit($this->request->getParam('controller')).'/'; - $path .= $this->request->getParam('action'); + $path .= $this->getView()->getRequest()->getParam('lang') .'/'; + $path .= Inflector::delimit($this->getView()->getRequest()->getParam('controller')).'/'; + $path .= $this->getView()->getRequest()->getParam('action'); - $params = $this->request->getParam('pass'); + $params = $this->getView()->getRequest()->getParam('pass'); $numberOfParams = count($params); $paramsWithoutLang = $numberOfParams; diff --git a/src/View/Helper/LanguagesHelper.php b/src/View/Helper/LanguagesHelper.php index d9af6b04c0..cc9ebf326e 100644 --- a/src/View/Helper/LanguagesHelper.php +++ b/src/View/Helper/LanguagesHelper.php @@ -66,7 +66,7 @@ public function preferredLanguageFilter() { if (CurrentUser::isMember()) { return CurrentUser::getProfileLanguages(); } else { - return $this->request->getSession()->read('last_used_lang'); + return $this->getView()->getRequest()->getSession()->read('last_used_lang'); } } diff --git a/src/View/Helper/ListsHelper.php b/src/View/Helper/ListsHelper.php index 5bb0c5f598..330990a12b 100644 --- a/src/View/Helper/ListsHelper.php +++ b/src/View/Helper/ListsHelper.php @@ -585,7 +585,7 @@ public function displayAddSentenceForm($listId)
Form->input( + echo $this->Form->control( 'text', array( 'label' => __('Add a sentence to this list : '), @@ -676,7 +676,7 @@ public function displayCreateListForm()

Form->create('SentencesList', [ + echo $this->Form->create(null, [ 'url' => ['action' => 'add'], 'type' => 'post', ]); @@ -711,7 +711,7 @@ public function displaySearchForm($search, $extraHiddenParams = null) /* @translators: header text in List of lists page (noun) */ echo $this->Html->tag('h2', __x('header', 'Search')); - echo $this->Form->create('SentencesList', ['type' => 'get']); + echo $this->Form->create(null, ['type' => 'get']); if (!empty($extraHiddenParams)) { foreach ($extraHiddenParams as $key => $value) { @@ -722,7 +722,7 @@ public function displaySearchForm($search, $extraHiddenParams = null) Form->input('search', [ + echo $this->Form->control('search', [ 'value' => $this->_View->safeForAngular($search), 'label' => false ]); diff --git a/src/View/Helper/MenuHelper.php b/src/View/Helper/MenuHelper.php index 6ef4082b29..1befd44ca9 100644 --- a/src/View/Helper/MenuHelper.php +++ b/src/View/Helper/MenuHelper.php @@ -278,7 +278,7 @@ public function linkToSentenceButton($sentenceId, $langFilter = 'und') {