diff --git a/CHANGELOG b/CHANGELOG index 232ebf6..c2be854 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,16 @@ +Version 1.4.x - +---------------------------- +- New: added new helper CSecureHeaders with possibility to define secure headers +- Enh: added possibility to hide system queries in debug panel +- Enh: added possibility to close debug panel to minimum size +- Enh: added possibility to get records by chunks with chuck() method of Active Record +- Bug: fixed wrong assignment of _isRendered in CView + + Version 1.3.2 - 24 Jan, 2020 ---------------------------- - New: added CRecordEntity to ORM model -- New: added phpunit tests +- New: added PHPUnit tests - Enh: added possibility to use create() and update() methods in CActiveRecord - Enh: changes in components CHttpRequest - Enh: minor changes in database migrations @@ -13,7 +22,7 @@ Version 1.3.2 - 24 Jan, 2020 - Enh: added possibility for lazy loading of core components via config - Enh: fixed wrong path of log file in CLogger component - Bug: fixed PHP7 syntax requirements in TCPDF vendor, CValidator helper -- Bug: fixed overwriting existing vars in View rendeting +- Bug: fixed overwriting existing vars in View rendering Version 1.2.2 - 01 Jan, 2019 diff --git a/README.md b/README.md index 6bd08ef..b42ed90 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@

Build Status License LGPL -Stable Version +Stable Version +Total Downloads

## About ApPHP Framework @@ -96,4 +97,4 @@ Please visit the project website for tutorials, class reference and join discuss - [Official Website](http://www.apphpframework.com) - [Website](https://www.apphp.com/php-framework/) -- [GitHub Repository](https://github.com/apphp/php-mvc-framework) \ No newline at end of file +- [GitHub Repository](https://github.com/apphp/php-mvc-framework) diff --git a/bin/aii b/bin/aii new file mode 100644 index 0000000..d9509a0 --- /dev/null +++ b/bin/aii @@ -0,0 +1,15 @@ +#!/usr/bin/env php + + * @link http://www.apphpframework.com/ + * @copyright Copyright (c) 2012 - 2020 ApPHP Framework + * @license http://www.apphpframework.com/license/ + */ + +require_once(dirname(__FILE__).'/aii.php'); diff --git a/bin/aii.bat b/bin/aii.bat new file mode 100644 index 0000000..0627de6 --- /dev/null +++ b/bin/aii.bat @@ -0,0 +1,23 @@ +@echo off + +rem ------------------------------------------------------------- +rem Aii command line script for Windows. +rem +rem This is the bootstrap script for running aii on Windows. +rem +rem @project ApPHP Framework +rem @author ApPHP +rem @link http://www.apphpframework.com/ +rem @copyright Copyright (c) 2012 - 2020 ApPHP Framework +rem @license http://www.apphpframework.com/license/ +rem ------------------------------------------------------------- + +@setlocal + +set APPHP_PATH=%~dp0 + +if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe + +"%PHP_COMMAND%" "%APPHP_PATH%aii" %* + +@endlocal \ No newline at end of file diff --git a/bin/aii.php b/bin/aii.php new file mode 100644 index 0000000..c7d402a --- /dev/null +++ b/bin/aii.php @@ -0,0 +1,23 @@ +run(); + +// We get automatically $argv and $argc, as we run command line command +$console = new CConsole($argv); +$consoleCommand = new CConsoleCommand( + $console->getCommand(), + $console->getParams() +); +$consoleCommand->run(); diff --git a/composer.lock b/composer.lock index 76c50b6..22c8d3f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,25 +4,25 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a57272a03f835344d931c2917c41d6bd", + "content-hash": "e678da7134869beac197a8686ab32b43", "packages": [], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.3.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^6.0", @@ -61,24 +61,24 @@ "constructor", "instantiate" ], - "time": "2019-10-21T16:45:58+00:00" + "time": "2020-05-29T17:27:14+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.3", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", - "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -109,7 +109,7 @@ "object", "object graph" ], - "time": "2019-08-09T12:45:53+00:00" + "time": "2020-06-29T13:22:24+00:00" }, { "name": "phar-io/manifest", @@ -215,28 +215,25 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" - }, - "require-dev": { - "phpunit/phpunit": "~6" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -263,44 +260,41 @@ "reflection", "static analysis" ], - "time": "2018-08-07T13:53:10+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", + "version": "5.2.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + "reference": "d870572532cd70bc3fab58f2e23ad423c8404c44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d870572532cd70bc3fab58f2e23ad423c8404c44", + "reference": "d870572532cd70bc3fab58f2e23ad423c8404c44", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "mockery/mockery": "~1.3.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "5.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -311,38 +305,40 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" + "time": "2020-08-15T11:14:08+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.0.1", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", "shasum": "" }, "require": { - "php": "^7.1", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.1", - "mockery/mockery": "~1", - "phpunit/phpunit": "^7.0" + "ext-tokenizer": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { @@ -361,37 +357,37 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2019-08-22T18:11:29+00:00" + "time": "2020-06-27T10:12:23+00:00" }, { "name": "phpspec/prophecy", - "version": "1.9.0", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b20034be5efcdab4fb60ca3a29cba2949aead160", + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "doctrine/instantiator": "^1.2", + "php": "^7.2", + "phpdocumentor/reflection-docblock": "^5.0", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.11.x-dev" } }, "autoload": { @@ -424,7 +420,7 @@ "spy", "stub" ], - "time": "2019-10-03T11:07:50+00:00" + "time": "2020-07-08T12:44:21+00:00" }, { "name": "phpunit/php-code-coverage", @@ -676,20 +672,21 @@ "keywords": [ "tokenizer" ], + "abandoned": true, "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "7.5.18", + "version": "7.5.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "fcf6c4bfafaadc07785528b06385cce88935474d" + "reference": "9467db479d1b0487c99733bb1e7944d32deded2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fcf6c4bfafaadc07785528b06385cce88935474d", - "reference": "fcf6c4bfafaadc07785528b06385cce88935474d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c", + "reference": "9467db479d1b0487c99733bb1e7944d32deded2c", "shasum": "" }, "require": { @@ -760,7 +757,7 @@ "testing", "xunit" ], - "time": "2019-12-06T05:14:37+00:00" + "time": "2020-01-08T08:45:45+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1330,16 +1327,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.13.1", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", "shasum": "" }, "require": { @@ -1351,7 +1348,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1384,27 +1385,27 @@ "polyfill", "portable" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "theseer/tokenizer", - "version": "1.1.3", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + "reference": "75a63c33a8577608444246075ea0af0d052e452a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", + "reference": "75a63c33a8577608444246075ea0af0d052e452a", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": "^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -1424,28 +1425,29 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" + "time": "2020-07-12T23:59:07+00:00" }, { "name": "webmozart/assert", - "version": "1.6.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "vimeo/psalm": "<3.6.0" + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<3.9.1" }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" @@ -1472,13 +1474,13 @@ "check", "validate" ], - "time": "2019-11-24T13:36:37+00:00" + "time": "2020-07-08T17:02:28+00:00" } ], "aliases": [], - "minimum-stability": "stable", + "minimum-stability": "dev", "stability-flags": [], - "prefer-stable": false, + "prefer-stable": true, "prefer-lowest": false, "platform": { "php": ">=7.1.0" diff --git a/demos/login-system/protected/components/Bootstrap.php b/demos/login-system/protected/components/Bootstrap.php index 76fa107..51f8e6e 100644 --- a/demos/login-system/protected/components/Bootstrap.php +++ b/demos/login-system/protected/components/Bootstrap.php @@ -24,15 +24,15 @@ class Bootstrap extends CComponent */ function __construct() { - A::app()->attachEventHandler('_onBeginRequest', array($this, 'setTimeZone')); - A::app()->attachEventHandler('_onBeginRequest', array($this, 'setSslMode')); - A::app()->attachEventHandler('_onBeginRequest', array($this, 'setCron')); - - A::app()->attachEventHandler('_onEndRequest', array($this, 'setLastVisitedPage')); - } - - /** - * Returns the instance of object + A::app()->attachEventHandler('_onBeginRequest', [$this, 'setTimeZone']); + A::app()->attachEventHandler('_onBeginRequest', [$this, 'setSslMode']); + A::app()->attachEventHandler('_onBeginRequest', [$this, 'setCron']); + + A::app()->attachEventHandler('_onEndRequest', [$this, 'setLastVisitedPage']); + } + + /** + * Returns the instance of object * @return current class */ public static function init() diff --git a/demos/login-system/protected/controllers/AccountController.php b/demos/login-system/protected/controllers/AccountController.php index 9b1b241..903bebd 100644 --- a/demos/login-system/protected/controllers/AccountController.php +++ b/demos/login-system/protected/controllers/AccountController.php @@ -33,12 +33,11 @@ public function editAction() if ($cRequest->getPost('act') == 'send') { // Perform account edit form validation - $result = CWidget::create('CFormValidation', array( - 'fields' => array( - //'username'=>array('title'=>'Username' 'validation'=>array('required'=>true, 'type'=>'username', 'minLength'=>4)), - 'password' => array('title' => 'Password', 'validation' => array('required' => true, 'type' => 'password', 'minLength' => 4)), - ), - )); + $result = CWidget::create('CFormValidation', [ + 'fields' => [ + 'password' => ['title' => 'Password', 'validation' => ['required' => true, 'type' => 'password', 'minLength' => 4]], + ], + ]); if ($result['error']) { $msg = $result['errorMessage']; @@ -62,8 +61,8 @@ public function editAction() if (!empty($msg)) { $this->_view->username = $cRequest->getPost('username', 'string'); - $this->_view->actionMessage = CWidget::create('CMessage', array($msgType, $msg, array('button' => true))); - } else { + $this->_view->actionMessage = CWidget::create('CMessage', [$msgType, $msg, ['button' => true]]); + } else { $this->_view->username = $info['username']; } } else { diff --git a/demos/login-system/protected/controllers/LoginController.php b/demos/login-system/protected/controllers/LoginController.php index 2234043..3ddbe26 100644 --- a/demos/login-system/protected/controllers/LoginController.php +++ b/demos/login-system/protected/controllers/LoginController.php @@ -41,14 +41,17 @@ public function runAction() if ($cRequest->getPost('act') == 'send') { // perform login form validation - $result = CWidget::create('CFormValidation', array( - 'fields' => array( - 'username' => array('title' => 'Username', 'validation' => array('required' => true, 'type' => 'any')), - 'password' => array('title' => 'Password', 'validation' => array('required' => true, 'type' => 'any')), - ), - )); - - if ($result['error']) { + $result = CWidget::create( + 'CFormValidation', + [ + 'fields' => [ + 'username' => ['title' => 'Username', 'validation' => ['required' => true, 'type' => 'any']], + 'password' => ['title' => 'Password', 'validation' => ['required' => true, 'type' => 'any']], + ], + ] + ); + + if ($result['error']) { $msg = $result['errorMessage']; $msgType = 'validation'; $this->_view->errorField = $result['errorField']; @@ -66,8 +69,8 @@ public function runAction() if (!empty($msg)) { $this->_view->username = $cRequest->getPost('username', 'string'); $this->_view->password = $cRequest->getPost('password', 'string'); - $this->_view->actionMessage = CWidget::create('CMessage', array($msgType, $msg)); - } + $this->_view->actionMessage = CWidget::create('CMessage', [$msgType, $msg]); + } } $this->_view->render('login/index'); } diff --git a/demos/login-system/protected/modules/setup/config/main.php b/demos/login-system/protected/modules/setup/config/main.php index 5dd721b..bb35704 100644 --- a/demos/login-system/protected/modules/setup/config/main.php +++ b/demos/login-system/protected/modules/setup/config/main.php @@ -1,8 +1,8 @@ array( - 'Modules\Setup\Controllers\Setup' - ) -); +return [ + // Module classes + 'classes' => [ + 'Modules\Setup\Controllers\Setup' + ] +]; diff --git a/demos/login-system/protected/modules/setup/controllers/SetupController.php b/demos/login-system/protected/modules/setup/controllers/SetupController.php index b6d9500..36232da 100644 --- a/demos/login-system/protected/modules/setup/controllers/SetupController.php +++ b/demos/login-system/protected/modules/setup/controllers/SetupController.php @@ -49,9 +49,9 @@ public function __construct() $this->_cRequest = A::app()->getRequest(); $this->_pdoExtensionRequired = true; $this->_configMain = include(APPHP_PATH . '/protected/data/config.main.tpl'); - $this->_languages = array('en' => 'English', 'es' => utf8_encode('Español'), 'de' => utf8_encode('Deutsch')); - - $this->_view->errorField = ''; + $this->_languages = ['en' => 'English', 'es' => utf8_encode('Español'), 'de' => utf8_encode('Deutsch')]; + + $this->_view->errorField = ''; $this->_view->_programName = isset($this->_configMain['name']) ? $this->_configMain['name'] : ''; $this->_view->_programVersion = isset($this->_configMain['version']) ? $this->_configMain['version'] : ''; @@ -80,18 +80,28 @@ public function indexAction() $this->_view->actionMessage = ''; $msg = ''; - - $this->_view->formFields = array( - 'act' => array('type' => 'hidden', 'value' => 'send'), - 'language' => array('type' => 'dropdownlist', 'value' => $language, 'title' => A::t('setup', 'Language'), 'mandatoryStar' => false, 'data' => $this->_languages, 'htmlOptions' => array(), 'validation' => array('required' => true, 'type' => 'set', 'source' => array_keys($this->_languages))), - ); - - if ($this->_cRequest->getPost('act') == 'send') { - $result = CWidget::create('CFormValidation', array( - 'fields' => $this->_view->formFields - )); - - if ($result['error']) { + + $this->_view->formFields = [ + 'act' => ['type' => 'hidden', 'value' => 'send'], + 'language' => ['type' => 'dropdownlist', + 'value' => $language, + 'title' => A::t('setup', 'Language'), + 'mandatoryStar' => false, + 'data' => $this->_languages, + 'htmlOptions' => [], + 'validation' => ['required' => true, 'type' => 'set', 'source' => array_keys($this->_languages)] + ], + ]; + + if ($this->_cRequest->getPost('act') == 'send') { + $result = CWidget::create( + 'CFormValidation', + [ + 'fields' => $this->_view->formFields + ] + ); + + if ($result['error']) { $msg = $result['errorMessage']; $this->_view->errorField = $result['errorField']; } else { @@ -100,26 +110,44 @@ public function indexAction() } if (!empty($msg)) { - $this->_view->actionMessage = CWidget::create('CMessage', array('validation', $msg)); - } + $this->_view->actionMessage = CWidget::create('CMessage', ['validation', $msg]); + } } $modeRewrite = $this->_checkModRewrite(); if (!$modeRewrite) { - $this->_view->actionMessage = CWidget::create('CMessage', array('warning', 'This program requires "mod_rewrite" module to use friendly URLs, but it is not enabled or its status unknown. You may proceed current installation on your own risk.')); - } - - $htaccessFile = !CFile::fileExists('.htaccess'); + $this->_view->actionMessage = CWidget::create( + 'CMessage', + [ + 'warning', + 'This program requires "mod_rewrite" module to use friendly URLs, but it is not enabled or its status unknown. You may proceed current installation on your own risk.' + ] + ); + } + + $htaccessFile = !CFile::fileExists('.htaccess'); if ($htaccessFile) { - $this->_view->actionMessage .= CWidget::create('CMessage', array('warning', 'This program requires ".htaccess" file with "mod_rewrite" rules in the root directory. You may proceed current installation on your own risk.')); - } - - $hostName = A::app()->getRequest()->getHostName(); + $this->_view->actionMessage .= CWidget::create( + 'CMessage', + [ + 'warning', + 'This program requires ".htaccess" file with "mod_rewrite" rules in the root directory. You may proceed current installation on your own risk.' + ] + ); + } + + $hostName = A::app()->getRequest()->getHostName(); if (CValidator::isIpAddress($hostName)) { - $this->_view->actionMessage .= CWidget::create('CMessage', array('warning', 'You\'re trying to install this script using IP address (without domain name), so you have to add some changes in your .htaccess file to provide a correct work of the "mod_rewrite". Find more information here.')); - } - - $phpInfo = $this->_getPhpInfo(); + $this->_view->actionMessage .= CWidget::create( + 'CMessage', + [ + 'warning', + 'You\'re trying to install this script using IP address (without domain name), so you have to add some changes in your .htaccess file to provide a correct work of the "mod_rewrite". Find more information here.' + ] + ); + } + + $phpInfo = $this->_getPhpInfo(); // Check pdoExtension $pdoExtension = $this->_checkPdoExtension($phpInfo); @@ -160,28 +188,28 @@ public function requirementsAction() $shortOpenTag = isset($phpInfo[$phpCoreIndex]['short_open_tag'][0]) ? strtolower($phpInfo[$phpCoreIndex]['short_open_tag'][0]) : false; if (version_compare(phpversion(), '5.4.0', '<')) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('error', 'This program requires at least PHP version 5.4.0 installed. You cannot proceed current installation.')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['error', 'This program requires at least PHP version 5.4.0 installed. You cannot proceed current installation.']); $this->_view->isCriticalError = true; } elseif (!is_writable(APPHP_PATH . '/protected/config/')) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('error', 'The directory ' . APPHP_PATH . '/protected/config/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['error', 'The directory ' . APPHP_PATH . '/protected/config/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!']); $this->_view->isCriticalError = true; } elseif (!is_writable(APPHP_PATH . '/assets/modules/')) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('error', 'The directory ' . APPHP_PATH . '/assets/modules/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['error', 'The directory ' . APPHP_PATH . '/assets/modules/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!']); $this->_view->isCriticalError = true; } elseif (!is_writable(APPHP_PATH . '/protected/messages/')) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('error', 'The directory ' . APPHP_PATH . '/protected/messages/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['error', 'The directory ' . APPHP_PATH . '/protected/messages/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!']); $this->_view->isCriticalError = true; } elseif (!is_writable(APPHP_PATH . '/templates/backend/images/icons/')) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('error', 'The directory ' . APPHP_PATH . '/templates/backend/images/icons/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['error', 'The directory ' . APPHP_PATH . '/templates/backend/images/icons/ is not writable!
You must grant "write" permissions (access rights 0755 or 777, depending on your system settings) to this directory before you start current installation!']); $this->_view->isCriticalError = true; } elseif (!$modeRewrite) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('warning', 'This program requires "mod_rewrite" module to use friendly URLs, but it is not enabled or its status unknown. You may proceed current installation on your own risk.')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['warning', 'This program requires "mod_rewrite" module to use friendly URLs, but it is not enabled or its status unknown. You may proceed current installation on your own risk.']); $this->_view->isCriticalError = false; } elseif ($this->_pdoExtensionRequired && !$pdoExtension) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('error', 'This program requires "PDO" extension enabled. You cannot proceed current installation.')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['error', 'This program requires "PDO" extension enabled. You cannot proceed current installation.']); $this->_view->isCriticalError = true; } elseif ($shortOpenTag != 'on' && version_compare(phpversion(), '5.4.0', '<')) { - $this->_view->notifyMessage = CWidget::create('CMessage', array('warning', 'This program requires "Short Open Tag" enabled. You cannot proceed current installation.')); + $this->_view->notifyMessage = CWidget::create('CMessage', ['warning', 'This program requires "Short Open Tag" enabled. You cannot proceed current installation.']); $this->_view->isCriticalError = true; } @@ -248,26 +276,26 @@ public function databaseAction() } $this->_view->actionMessage = ''; - $dbDrivers = array('mysql' => 'MySql'); - $dbConnectTypes = array('host' => A::t('setup', 'host'), 'socket' => A::t('setup', 'socket')); - $msg = ''; - - $separatorGeneralFields = array( - 'separatorInfo' => array('legend' => 'General Settings'), - 'setupType' => array('type' => 'dropdownlist', 'value' => $this->_view->setupType, 'title' => A::t('setup', 'Setup Type'), 'mandatoryStar' => false, 'data' => array('install' => A::t('setup', 'New Installation'), 'update' => A::t('setup', 'Update')), 'htmlOptions' => array(), 'validation' => array('required' => true, 'type' => 'text', 'source' => array('install'))), - 'dbDriver' => array('type' => 'dropdownlist', 'value' => $this->_view->dbDriver, 'title' => A::t('setup', 'Database Driver'), 'mandatoryStar' => true, 'data' => $dbDrivers, 'htmlOptions' => array('style' => 'width:85px'), 'validation' => array('required' => true, 'type' => 'text', 'source' => array_keys($dbDrivers))), - 'dbPrefix' => array('type' => 'textbox', 'value' => $this->_view->dbPrefix, 'title' => A::t('setup', 'Database (tables) Prefix'), 'mandatoryStar' => false, 'htmlOptions' => array('maxLength' => '10', 'autocomplete' => 'off'), 'validation' => array('required' => false, 'type' => 'variable')), - ); - $separatorConenctionSettingsFields = array( - 'separatorInfo' => array('legend' => 'Connection Settings'), - 'dbConnectType' => array('type' => 'dropdownlist', 'value' => $this->_view->dbConnectType, 'title' => A::t('setup', 'Connection Type'), 'mandatoryStar' => true, 'data' => $dbConnectTypes, 'htmlOptions' => array('style' => 'width:85px'), 'validation' => array('required' => true, 'type' => 'text', 'source' => array_keys($dbConnectTypes))), - 'dbSocket' => array('type' => 'textbox', 'value' => $this->_view->dbSocket, 'title' => A::t('setup', 'Database Socket'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '60', 'autocomplete' => 'off', 'placeholder' => '/tmp/mysql.sock'), 'validation' => array('required' => ($this->_view->dbConnectType == 'socket' ? true : false), 'type' => 'text'), 'disabled' => ($this->_view->dbConnectType == 'socket' ? false : true)), - 'dbHost' => array('type' => 'textbox', 'value' => $this->_view->dbHost, 'title' => A::t('setup', 'Database Host'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '60', 'autocomplete' => 'off', 'placeholder' => 'e.g. localhost'), 'validation' => array('required' => ($this->_view->dbConnectType == 'host' ? true : false), 'type' => 'text'), 'disabled' => ($this->_view->dbConnectType == 'host' ? false : true)), - 'dbPort' => array('type' => 'textbox', 'value' => $this->_view->dbPort, 'title' => A::t('setup', 'Database Port'), 'mandatoryStar' => false, 'htmlOptions' => array('maxLength' => '10', 'autocomplete' => 'off', 'placeholder' => 'e.g. 3306', 'style' => 'width:80px'), 'validation' => array('required' => false, 'type' => 'integer'), 'disabled' => ($this->_view->dbConnectType == 'host' ? false : true)), - 'dbName' => array('type' => 'textbox', 'value' => $this->_view->dbName, 'title' => A::t('setup', 'Database Name'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '30', 'autocomplete' => 'off'), 'validation' => array('required' => true, 'type' => 'text')), - 'dbUser' => array('type' => 'textbox', 'value' => $this->_view->dbUser, 'title' => A::t('setup', 'Database User'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '30', 'autocomplete' => 'off'), 'validation' => array('required' => true, 'type' => 'text')), - 'dbPassword' => array('type' => 'password', 'value' => $this->_view->dbPassword, 'title' => A::t('setup', 'Database Password'), 'mandatoryStar' => false, 'htmlOptions' => array('maxLength' => '20', 'autocomplete' => 'off', 'id' => 'db_password'), 'validation' => array('required' => false, 'type' => 'text'), 'appendCode' => '
'), - ); + $dbDrivers = ['mysql' => 'MySql']; + $dbConnectTypes = ['host' => A::t('setup', 'host'), 'socket' => A::t('setup', 'socket')]; + $msg = ''; + + $separatorGeneralFields = [ + 'separatorInfo' => ['legend' => 'General Settings'], + 'setupType' => ['type' => 'dropdownlist', 'value' => $this->_view->setupType, 'title' => A::t('setup', 'Setup Type'), 'mandatoryStar' => false, 'data' => array('install' => A::t('setup', 'New Installation'), 'update' => A::t('setup', 'Update')), 'htmlOptions' => [], 'validation' => array('required' => true, 'type' => 'text', 'source' => array('install'))], + 'dbDriver' => ['type' => 'dropdownlist', 'value' => $this->_view->dbDriver, 'title' => A::t('setup', 'Database Driver'), 'mandatoryStar' => true, 'data' => $dbDrivers, 'htmlOptions' => array('style' => 'width:85px'), 'validation' => array('required' => true, 'type' => 'text', 'source' => array_keys($dbDrivers))], + 'dbPrefix' => ['type' => 'textbox', 'value' => $this->_view->dbPrefix, 'title' => A::t('setup', 'Database (tables) Prefix'), 'mandatoryStar' => false, 'htmlOptions' => array('maxLength' => '10', 'autocomplete' => 'off'), 'validation' => array('required' => false, 'type' => 'variable')], + ]; + $separatorConenctionSettingsFields = [ + 'separatorInfo' => ['legend' => 'Connection Settings'], + 'dbConnectType' => ['type' => 'dropdownlist', 'value' => $this->_view->dbConnectType, 'title' => A::t('setup', 'Connection Type'), 'mandatoryStar' => true, 'data' => $dbConnectTypes, 'htmlOptions' => array('style' => 'width:85px'), 'validation' => ['required' => true, 'type' => 'text', 'source' => array_keys($dbConnectTypes)]], + 'dbSocket' => ['type' => 'textbox', 'value' => $this->_view->dbSocket, 'title' => A::t('setup', 'Database Socket'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '60', 'autocomplete' => 'off', 'placeholder' => '/tmp/mysql.sock'), 'validation' => array('required' => ($this->_view->dbConnectType == 'socket' ? true : false), 'type' => 'text'), 'disabled' => ($this->_view->dbConnectType == 'socket' ? false : true)], + 'dbHost' => ['type' => 'textbox', 'value' => $this->_view->dbHost, 'title' => A::t('setup', 'Database Host'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '60', 'autocomplete' => 'off', 'placeholder' => 'e.g. localhost'), 'validation' => array('required' => ($this->_view->dbConnectType == 'host' ? true : false), 'type' => 'text'), 'disabled' => ($this->_view->dbConnectType == 'host' ? false : true)], + 'dbPort' => ['type' => 'textbox', 'value' => $this->_view->dbPort, 'title' => A::t('setup', 'Database Port'), 'mandatoryStar' => false, 'htmlOptions' => array('maxLength' => '10', 'autocomplete' => 'off', 'placeholder' => 'e.g. 3306', 'style' => 'width:80px'), 'validation' => array('required' => false, 'type' => 'integer'), 'disabled' => ($this->_view->dbConnectType == 'host' ? false : true)], + 'dbName' => ['type' => 'textbox', 'value' => $this->_view->dbName, 'title' => A::t('setup', 'Database Name'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '30', 'autocomplete' => 'off'), 'validation' => array('required' => true, 'type' => 'text')], + 'dbUser' => ['type' => 'textbox', 'value' => $this->_view->dbUser, 'title' => A::t('setup', 'Database User'), 'mandatoryStar' => true, 'htmlOptions' => array('maxLength' => '30', 'autocomplete' => 'off'), 'validation' => array('required' => true, 'type' => 'text')], + 'dbPassword' => ['type' => 'password', 'value' => $this->_view->dbPassword, 'title' => A::t('setup', 'Database Password'), 'mandatoryStar' => false, 'htmlOptions' => array('maxLength' => '20', 'autocomplete' => 'off', 'id' => 'db_password'), 'validation' => array('required' => false, 'type' => 'text'), 'appendCode' => '
'], + ]; $validationFields = array_merge($separatorGeneralFields, $separatorConenctionSettingsFields); $this->_view->formFields = array( 'act' => array('type' => 'hidden', 'value' => 'send'), @@ -279,16 +307,13 @@ public function databaseAction() if ($this->_cSession->get('step') < 2) { $this->redirect('setup/index'); } elseif ($this->_cRequest->getPost('act') == 'send') { - - $result = CWidget::create('CFormValidation', array( - 'fields' => $validationFields - )); - - if ($result['error']) { + $result = CWidget::create('CFormValidation', ['fields' => $validationFields]); + + if ($result['error']) { $msg = $result['errorMessage']; $this->_view->errorField = $result['errorField']; } else { - $model = new Setup(array( + $model = new Setup([ 'dbDriver' => $this->_view->dbDriver, 'dbConnectType' => $this->_view->dbConnectType, 'dbSocket' => $this->_view->dbSocket, @@ -297,11 +322,11 @@ public function databaseAction() 'dbName' => $this->_view->dbName, 'dbUser' => $this->_view->dbUser, 'dbPassword' => $this->_view->dbPassword - )); + ]); if ($model->getError()) { - $this->_view->actionMessage = CWidget::create('CMessage', array('error', $model->getErrorMessage())); - } else { + $this->_view->actionMessage = CWidget::create('CMessage', ['error', $model->getErrorMessage()]); + } else { // Go to the next step $this->_cSession->set('setupType', $this->_view->setupType); $this->_cSession->set('dbDriver', $this->_view->dbDriver); @@ -320,8 +345,8 @@ public function databaseAction() } if (!empty($msg)) { - $this->_view->actionMessage = CWidget::create('CMessage', array('validation', $msg)); - } + $this->_view->actionMessage = CWidget::create('CMessage', ['validation', $msg]); + } } $this->_view->setMetaTags('title', A::t('setup', 'Database Settings | Setup Wizard')); @@ -351,13 +376,13 @@ public function administratorAction() $this->_view->username = $this->_cRequest->getPost('username'); $this->_view->password = $this->_cRequest->getPost('password'); - $result = CWidget::create('CFormValidation', array( - 'fields' => array( - 'email' => array('title' => A::t('setup', 'Email'), 'validation' => array('required' => false, 'type' => 'email')), - 'username' => array('title' => A::t('setup', 'Username'), 'validation' => array('required' => true, 'type' => 'any', 'minLength' => 4, 'maxLength' => 32)), - 'password' => array('title' => A::t('setup', 'Password'), 'validation' => array('required' => true, 'type' => 'any', 'minLength' => 4, 'maxLength' => 25)), - ), - )); + $result = CWidget::create('CFormValidation', [ + 'fields' => [ + 'email' => ['title' => A::t('setup', 'Email'), 'validation' => ['required' => false, 'type' => 'email']], + 'username' => ['title' => A::t('setup', 'Username'), 'validation' => ['required' => true, 'type' => 'any', 'minLength' => 4, 'maxLength' => 32]], + 'password' => ['title' => A::t('setup', 'Password'), 'validation' => ['required' => true, 'type' => 'any', 'minLength' => 4, 'maxLength' => 25]], + ], + ]); if ($result['error']) { $msg = $result['errorMessage']; @@ -373,8 +398,8 @@ public function administratorAction() } if (!empty($msg)) { - $this->_view->actionMessage = CWidget::create('CMessage', array('validation', $msg)); - } + $this->_view->actionMessage = CWidget::create('CMessage', ['validation', $msg]); + } } $this->_view->setMetaTags('title', A::t('setup', 'Administrator Account | Setup Wizard')); @@ -398,7 +423,7 @@ public function readyAction() $sqlDumpPath = APPHP_PATH . '/protected/data/schema' . ($this->_cSession->get('setupType') == 'update' ? '.update' : '') . '.' . strtolower($dbDriver) . '.sql'; $sqlDump = file($sqlDumpPath); if (empty($sqlDump)) { - $this->_view->actionMessage = CWidget::create('CMessage', array('error', 'Could not read file ' . $sqlDumpPath . '! Please check if this file exists.')); + $this->_view->actionMessage = CWidget::create('CMessage', ['error', 'Could not read file ' . $sqlDumpPath . '! Please check if this file exists.']); } else { $encryption = isset($this->_configMain['password']['encryption']) ? $this->_configMain['password']['encryption'] : false; $encryptAlgorithm = isset($this->_configMain['password']['encryptAlgorithm']) ? $this->_configMain['password']['encryptAlgorithm'] : ''; @@ -416,7 +441,7 @@ public function readyAction() $sqlDump = str_ireplace('', date('Y-m-d', time() + (date('I', time()) ? 3600 : 0)), $sqlDump); $sqlDump = str_ireplace('', date('Y-m-d H:i:s', time() + (date('I', time()) ? 3600 : 0)), $sqlDump); - $model = new Setup(array( + $model = new Setup([ 'dbDriver' => $dbDriver, 'dbConnectType' => $this->_cSession->get('dbConnectType'), 'dbSocket' => $this->_cSession->get('dbSocket'), @@ -425,11 +450,11 @@ public function readyAction() 'dbName' => $this->_cSession->get('dbName'), 'dbUser' => $this->_cSession->get('dbUser'), 'dbPassword' => $this->_cSession->get('dbPassword') - )); + ]); if ($model->getError()) { - $this->_view->actionMessage = CWidget::create('CMessage', array('error', $model->getErrorMessage())); - } else { + $this->_view->actionMessage = CWidget::create('CMessage', ['error', $model->getErrorMessage()]); + } else { if ($model->install($sqlDump)) { $modulesError = false; $modulesWarning = false; @@ -453,7 +478,7 @@ public function readyAction() $model->doBeginTransaction(); if (!$model->install($sqlDump, false)) { $modulesError = true; - $this->_view->actionMessage = CWidget::create('CMessage', array('error', $model->getErrorMessage())); + $this->_view->actionMessage = CWidget::create('CMessage', ['error', $model->getErrorMessage()]); } else { // Copy module files foreach ($xml->files->children() as $folder) { @@ -641,13 +666,13 @@ private function _getPhpInfo() { ob_start(); if (function_exists('phpinfo')) @phpinfo(-1); - $phpInfo = array('phpinfo' => array()); + $phpInfo = array('phpinfo' => []); if (preg_match_all('#(?:

(?:)?(.*?)(?:)?

)|(?:(.*?)\s*(?:(.*?)\s*(?:(.*?)\s*)?)?)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) foreach ($matches as $match) { $arrayKeys = array_keys($phpInfo); $endArrayKeys = end($arrayKeys); if (strlen($match[1])) { - $phpInfo[$match[1]] = array(); + $phpInfo[$match[1]] = []; } elseif (isset($match[3])) { $phpInfo[$endArrayKeys][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3]; } else { diff --git a/demos/login-system/protected/modules/setup/models/Setup.php b/demos/login-system/protected/modules/setup/models/Setup.php index e5cd06f..185589c 100644 --- a/demos/login-system/protected/modules/setup/models/Setup.php +++ b/demos/login-system/protected/modules/setup/models/Setup.php @@ -23,7 +23,7 @@ class Setup extends CModel { - public function __construct($params = array()) + public function __construct($params = []) { parent::__construct($params); } diff --git a/demos/login-system/protected/modules/setup/views/setup/database.php b/demos/login-system/protected/modules/setup/views/setup/database.php index 16a4ee4..a25e63b 100644 --- a/demos/login-system/protected/modules/setup/views/setup/database.php +++ b/demos/login-system/protected/modules/setup/views/setup/database.php @@ -12,22 +12,27 @@
'setup/database', - 'method' => 'post', - 'htmlOptions' => array( - 'name' => 'frmSetup', - 'id' => 'frmSetup' - ), - 'fields' => $formFields, - 'buttons' => array( - 'back' => array('type' => 'button', 'value' => A::t('setup', 'Previous'), 'htmlOptions' => array('name' => '', 'onclick' => "$(location).attr('href','setup/requirements');")), - 'submit' => array('type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => array('name' => '')) - ), - 'events' => array( - 'focus' => array('field' => $errorField) - ), - 'return' => true, -)); +echo CWidget::create( + 'CFormView', [ + 'action' => 'setup/database', + 'method' => 'post', + 'htmlOptions' => [ + 'name' => 'frmSetup', + 'id' => 'frmSetup' + ], + 'fields' => $formFields, + 'buttons' => [ + 'back' => [ + 'type' => 'button', + 'value' => A::t('setup', 'Previous'), + 'htmlOptions' => ['name' => '', 'onclick' => "$(location).attr('href','setup/requirements');"] + ], + 'submit' => ['type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => ['name' => '']] + ], + 'events' => [ + 'focus' => ['field' => $errorField] + ], + 'return' => true, + ]); ?>
diff --git a/demos/login-system/protected/modules/setup/views/setup/index.php b/demos/login-system/protected/modules/setup/views/setup/index.php index 53774cb..4d3640d 100644 --- a/demos/login-system/protected/modules/setup/views/setup/index.php +++ b/demos/login-system/protected/modules/setup/views/setup/index.php @@ -10,17 +10,21 @@
'setup/index', - 'method' => 'post', - 'htmlOptions' => array( - 'name' => 'frmSetup', - ), - 'fields' => $formFields, - 'buttons' => array( - 'submit' => array('type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => array('name' => '')) - ), - 'return' => true, -)); + +echo CWidget::create( + 'CFormView', + [ + 'action' => 'setup/index', + 'method' => 'post', + 'htmlOptions' => [ + 'name' => 'frmSetup', + ], + 'fields' => $formFields, + 'buttons' => [ + 'submit' => ['type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => ['name' => '']] + ], + 'return' => true, + ] +); ?>
diff --git a/demos/login-system/protected/modules/setup/views/setup/requirements.php b/demos/login-system/protected/modules/setup/views/setup/requirements.php index 56e7f5b..7369bd5 100644 --- a/demos/login-system/protected/modules/setup/views/setup/requirements.php +++ b/demos/login-system/protected/modules/setup/views/setup/requirements.php @@ -50,22 +50,30 @@ 'setup/requirements', - 'method' => 'post', - 'htmlOptions' => array( - 'name' => 'frmSetup', - ), - 'fields' => array( - 'act' => array('type' => 'hidden', 'value' => 'send'), - ), - 'buttons' => array( - 'back' => array('type' => 'button', 'value' => A::t('setup', 'Previous'), 'htmlOptions' => array('name' => '', 'onclick' => "$(location).attr('href','setup/index');")), - 'submit' => array('type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => array('name' => '')) - ), - 'return' => true, - )); + +if ( ! $isCriticalError) { + echo CWidget::create( + 'CFormView', + [ + 'action' => 'setup/requirements', + 'method' => 'post', + 'htmlOptions' => [ + 'name' => 'frmSetup', + ], + 'fields' => [ + 'act' => ['type' => 'hidden', 'value' => 'send'], + ], + 'buttons' => [ + 'back' => [ + 'type' => 'button', + 'value' => A::t('setup', 'Previous'), + 'htmlOptions' => ['name' => '', 'onclick' => "$(location).attr('href','setup/index');"] + ], + 'submit' => ['type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => ['name' => '']] + ], + 'return' => true, + ] + ); } ?>
diff --git a/demos/login-system/protected/views/index/index.php b/demos/login-system/protected/views/index/index.php index 1975146..75b8984 100644 --- a/demos/login-system/protected/views/index/index.php +++ b/demos/login-system/protected/views/index/index.php @@ -9,6 +9,6 @@ here to log into the system as administrator.')); + echo CWidget::create('CMessage', ['info', 'Click here to log into the system as administrator.']); } ?> diff --git a/demos/login-system/protected/views/login/index.php b/demos/login-system/protected/views/login/index.php index 235dfc9..8c09884 100644 --- a/demos/login-system/protected/views/login/index.php +++ b/demos/login-system/protected/views/login/index.php @@ -6,7 +6,7 @@ Username: admin
Password: test')); + echo CWidget::create('CMessage', ['info', 'To access the demo account enter
Username: admin
Password: test']); } ?> @@ -17,25 +17,25 @@ 'login/run', 'method'=>'post', - 'htmlOptions'=>array( - 'name'=>'frmLogin' - ), - 'fields'=>array( - 'act' =>array('type'=>'hidden', 'value'=>'send'), - 'username'=>array('type'=>'textbox', 'value'=>$username, 'title'=>'Username', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxlength'=>'32', 'autocomplete'=>'off')), - 'password'=>array('type'=>'password', 'value'=>$password, 'title'=>'Password', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxLength'=>'20')), - ), - 'buttons'=>array( - 'submit'=>array('type'=>'submit', 'value'=>'Login'), - ), - 'events'=>array( - 'focus'=>array('field'=>$errorField) - ), + 'htmlOptions' => [ + 'name' => 'frmLogin' + ], + 'fields'=>[ + 'act' =>['type'=>'hidden', 'value'=>'send'], + 'username'=>['type'=>'textbox', 'value'=>$username, 'title'=>'Username', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxlength'=>'32', 'autocomplete'=>'off')], + 'password'=>['type'=>'password', 'value'=>$password, 'title'=>'Password', 'mandatoryStar'=>false, 'htmlOptions'=>array('maxLength'=>'20')], + ], + 'buttons' => [ + 'submit' => ['type' => 'submit', 'value' => 'Login'], + ], + 'events' => [ + 'focus' => ['field' => $errorField] + ], 'return'=>true, - )); + ]); ?> diff --git a/demos/login-system/templates/default/default.php b/demos/login-system/templates/default/default.php index 9eaaf56..162f092 100644 --- a/demos/login-system/templates/default/default.php +++ b/demos/login-system/templates/default/default.php @@ -19,41 +19,55 @@
$this->_breadCrumbs, - 'return' => false, - )); - ?> - view->getContent(); ?> + CWidget::create( + 'CBreadCrumbs', + [ + 'links' => $this->_breadCrumbs, + 'return' => false, + ] + ); + ?> + view->getContent(); ?>