Commit aa9d3b3e by Carsten Brandt

Merge branch 'master' of github.com:yiisoft/yii2

* 'master' of github.com:yiisoft/yii2: (40 commits) Fixes #2624: Html::textArea() should respect "name" option. Removed unused "use" statements Changed "and" to "&&" Used ternary operator instead of "or" for constant definition Removed unused variables Removed executable flag from asset files Changelog for #2607 Added note about overriding asset bundles according to #2556 Added some documentation to new pjax attribute Add unit tests typo fix. Update MessageController.php Update MessageController.php add findAndModify() method to the Collection class Add an option to ignore pjax request on some links. fix code style php5.4 syntax Inline control structures are not allowed fix code style fix code style fix typo double `;`, `Each PHP statement must be on a line by itself` ...
parents 80cc3108 c64ab9d7
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// the entry script URL (without host info) for functional and acceptance tests // the entry script URL (without host info) for functional and acceptance tests
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/backend/web/index-test.php'); defined('TEST_ENTRY_URL') ?: define('TEST_ENTRY_URL', '/backend/web/index-test.php');
// the entry script file path for functional and acceptance tests // the entry script file path for functional and acceptance tests
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); defined('TEST_ENTRY_FILE') ?: define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../common/config/aliases.php'); require_once(__DIR__ . '/../../common/config/aliases.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
use yii\mail\BaseMessage;
/** /**
* @var \yii\web\View $this * @var \yii\web\View $this
* @var BaseMessage $content * @var \yii\mail\BaseMessage $content
*/ */
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// the entry script URL (without host info) for functional and acceptance tests // the entry script URL (without host info) for functional and acceptance tests
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/index-test.php'); defined('TEST_ENTRY_URL') ?: define('TEST_ENTRY_URL', '/index-test.php');
// the entry script file path for functional and acceptance tests // the entry script file path for functional and acceptance tests
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/index-test.php'); defined('TEST_ENTRY_FILE') ?: define('TEST_ENTRY_FILE', dirname(__DIR__) . '/index-test.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../common/config/aliases.php'); require_once(__DIR__ . '/../../common/config/aliases.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// the entry script URL (without host info) for functional and acceptance tests // the entry script URL (without host info) for functional and acceptance tests
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/index-test.php'); defined('TEST_ENTRY_URL') ?: define('TEST_ENTRY_URL', '/index-test.php');
// the entry script file path for functional and acceptance tests // the entry script file path for functional and acceptance tests
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/index-test.php'); defined('TEST_ENTRY_FILE') ?: define('TEST_ENTRY_FILE', dirname(__DIR__) . '/index-test.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../common/config/aliases.php'); require_once(__DIR__ . '/../../common/config/aliases.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
...@@ -5,8 +5,8 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) { ...@@ -5,8 +5,8 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.'); die('You are not allowed to access this file.');
} }
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
......
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev'); defined('YII_ENV') ?: define('YII_ENV', 'dev');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
......
...@@ -5,8 +5,8 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) { ...@@ -5,8 +5,8 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.'); die('You are not allowed to access this file.');
} }
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
......
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev'); defined('YII_ENV') ?: define('YII_ENV', 'dev');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev'); defined('YII_ENV') ?: define('YII_ENV', 'dev');
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
......
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod'); defined('YII_ENV') ?: define('YII_ENV', 'prod');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
......
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod'); defined('YII_ENV') ?: define('YII_ENV', 'prod');
require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod'); defined('YII_ENV') ?: define('YII_ENV', 'prod');
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// the entry script URL (without host info) for functional and acceptance tests // the entry script URL (without host info) for functional and acceptance tests
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/frontend/web/index-test.php'); defined('TEST_ENTRY_URL') ?: define('TEST_ENTRY_URL', '/frontend/web/index-test.php');
// the entry script file path for functional and acceptance tests // the entry script file path for functional and acceptance tests
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); defined('TEST_ENTRY_FILE') ?: define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../common/config/aliases.php'); require_once(__DIR__ . '/../../common/config/aliases.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php'); require_once(__DIR__ . '/../_console.php');
......
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
use yii\mail\BaseMessage;
/** /**
* @var \yii\web\View $this * @var \yii\web\View $this
* @var BaseMessage $content * @var \yii\mail\BaseMessage $content
*/ */
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// the entry script URL (without host info) for functional and acceptance tests // the entry script URL (without host info) for functional and acceptance tests
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/basic/web/index-test.php'); defined('TEST_ENTRY_URL') ?: define('TEST_ENTRY_URL', '/basic/web/index-test.php');
// the entry script file path for functional and acceptance tests // the entry script file path for functional and acceptance tests
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); defined('TEST_ENTRY_FILE') ?: define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php');
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require_once(__DIR__ . '/../vendor/autoload.php'); require_once(__DIR__ . '/../vendor/autoload.php');
......
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
...@@ -5,8 +5,8 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) { ...@@ -5,8 +5,8 @@ if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
die('You are not allowed to access this file.'); die('You are not allowed to access this file.');
} }
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test'); defined('YII_ENV') ?: define('YII_ENV', 'test');
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
......
<?php <?php
// comment out the following two lines when deployed to production // comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev'); defined('YII_ENV') ?: define('YII_ENV', 'dev');
require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
......
<?php <?php
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
require(__DIR__ . '/protected/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/protected/vendor/yiisoft/yii2/Yii.php');
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
*/ */
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
define('YII_DEBUG', true); define('YII_DEBUG', true);
......
...@@ -52,7 +52,7 @@ class ClassmapController extends Controller ...@@ -52,7 +52,7 @@ class ClassmapController extends Controller
$files = FileHelper::findFiles($root, $options); $files = FileHelper::findFiles($root, $options);
$map = []; $map = [];
foreach ($files as $file) { foreach ($files as $file) {
if (($pos = strpos($file, $root)) !== 0) { if (strpos($file, $root) !== 0) {
die("Something wrong: $file\n"); die("Something wrong: $file\n");
} }
$path = str_replace('\\', '/', substr($file, strlen($root))); $path = str_replace('\\', '/', substr($file, strlen($root)));
......
...@@ -81,18 +81,26 @@ following way: ...@@ -81,18 +81,26 @@ following way:
```php ```php
class LanguageAsset extends AssetBundle class LanguageAsset extends AssetBundle
{ {
public $sourcePath = '@app/assets/language'; public $language;
public $js = [ public $sourcePath = '@app/assets/language';
]; public $js = [
];
public function init()
{ public function registerAssetFiles($view)
$this->js[] = 'language-' . Yii::$app->language . '.js'; {
parent::init(); $language = $this->language ? $this->language : Yii::$app->language;
} $this->js[] = 'language-' . $language . '.js';
parent::registerAssetFiles($view);
}
} }
``` ```
In order to set language use the following code when registering an asset bundle in a view:
```php
LanguageAsset::register($this)->language = $language;
```
Registering asset bundle Registering asset bundle
------------------------ ------------------------
...@@ -114,6 +122,10 @@ To register an asset inside of a widget, the view instance is available as `$thi ...@@ -114,6 +122,10 @@ To register an asset inside of a widget, the view instance is available as `$thi
AppAsset::register($this->view); AppAsset::register($this->view);
``` ```
> Note: If there is a need to modify third party asset bundles it is recommended to create your own bundles depending
on third party ones and use CSS and JavaScript features to modify behavior instead of editing files directly or
copying them over.
Overriding asset bundles Overriding asset bundles
------------------------ ------------------------
......
...@@ -24,14 +24,14 @@ Like any resource in your Yii application, the bootstrap file can be edited to f ...@@ -24,14 +24,14 @@ Like any resource in your Yii application, the bootstrap file can be edited to f
The default bootstrap structure sets `YII_DEBUG` to `false` if not defined: The default bootstrap structure sets `YII_DEBUG` to `false` if not defined:
```php ```php
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
``` ```
During development, you can change this to `true`: During development, you can change this to `true`:
```php ```php
define('YII_DEBUG', true); // Development only define('YII_DEBUG', true); // Development only
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
``` ```
Configuring the application instance Configuring the application instance
......
...@@ -40,11 +40,11 @@ code like the following: ...@@ -40,11 +40,11 @@ code like the following:
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
......
...@@ -76,7 +76,7 @@ return [ ...@@ -76,7 +76,7 @@ return [
By default it's automatically set to `3` if Yii is run in debug mode i.e. your `index.php` file contains the following: By default it's automatically set to `3` if Yii is run in debug mode i.e. your `index.php` file contains the following:
```php ```php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
``` ```
> Note: Make sure to disable debug mode on production since it may have significan performance effect and expose sensible > Note: Make sure to disable debug mode on production since it may have significan performance effect and expose sensible
......
...@@ -28,7 +28,7 @@ is to disable debug mode. A Yii application runs in debug mode if the constant ...@@ -28,7 +28,7 @@ is to disable debug mode. A Yii application runs in debug mode if the constant
should be in your `index.php`: should be in your `index.php`:
```php ```php
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
``` ```
Debug mode is very useful during development stage, but it would impact performance Debug mode is very useful during development stage, but it would impact performance
......
Theming Theming
======= =======
TBD A theme is a directory of view and layout files. Each file of the theme overrides corresponding file of an application
when rendered. A single application may use multiple themes and each may provide totally different experience. At any
time only one theme can be active.
> Note: Themes usually do not meant to be redistributed since views are too application specific. If you want to
redistribute customized look and feel consider CSS and JavaScript files in form of [asset bundles](assets.md) instead.
Configuring current theme Configuring current theme
------------------------- -------------------------
...@@ -18,4 +23,27 @@ be in your application config file: ...@@ -18,4 +23,27 @@ be in your application config file:
], ],
], ],
], ],
``` ```
\ No newline at end of file
In the above `pathMap` defines where to look for view files while `baseUrl` defines base URL for resources referenced
from these files. For example, if `pathMap` is `['/web/views' => '/web/themes/basic']`, then the themed version
for a view file `/web/views/site/index.php` will be `/web/themes/basic/site/index.php`.
Using multiple paths
--------------------
It is possible to map a single path to multiple paths. For example,
```php
'pathMap' => [
'/web/views' => [
'/web/themes/christmas',
'/web/themes/basic',
],
]
```
In this case, the view will be searched in `/web/themes/christmas/site/index.php` then if it's not found it will check
`/web/themes/basic/site/index.php`. If there's no view there as well application view will be used.
This ability is especially useful if you want to temporary or conditionally override some views.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
$composerAutoload = [ $composerAutoload = [
__DIR__ . '/vendor/autoload.php', // standalone with "composer install" run __DIR__ . '/vendor/autoload.php', // standalone with "composer install" run
......
<?php <?php
use yii\helpers\Html;
/** /**
* @var yii\debug\panels\ConfigPanel $panel * @var yii\debug\panels\ConfigPanel $panel
*/ */
......
<?php <?php
use yii\helpers\Html;
/** /**
* @var yii\debug\panels\ConfigPanel $panel * @var yii\debug\panels\ConfigPanel $panel
*/ */
......
...@@ -13,6 +13,7 @@ Yii Framework 2 gii extension Change Log ...@@ -13,6 +13,7 @@ Yii Framework 2 gii extension Change Log
- Enh #1897: diff markup is now copy paste friendly (samdark) - Enh #1897: diff markup is now copy paste friendly (samdark)
- Enh #2327: better visual representation of changed files, added header and refresh button to diff modal (thiagotalma) - Enh #2327: better visual representation of changed files, added header and refresh button to diff modal (thiagotalma)
- Enh #2491: Added support for using the same base class name of search model and data model in Gii (qiangxue) - Enh #2491: Added support for using the same base class name of search model and data model in Gii (qiangxue)
- Enh #2595: Browse through all generated files using right and left arrows (thiagotalma)
2.0.0 alpha, December 1, 2013 2.0.0 alpha, December 1, 2013
----------------------------- -----------------------------
......
...@@ -35,10 +35,13 @@ yii.gii = (function ($) { ...@@ -35,10 +35,13 @@ yii.gii = (function ($) {
}; };
var initPreviewDiffLinks = function () { var initPreviewDiffLinks = function () {
$('.preview-code, .diff-code, .modal-refresh').on('click', function () { $('.preview-code, .diff-code, .modal-refresh, .modal-previous, .modal-next').on('click', function () {
var $modal = $('#preview-modal'); var $modal = $('#preview-modal');
var $link = $(this); var $link = $(this);
$modal.find('.modal-refresh').attr('href', $link.prop('href')); $modal.find('.modal-refresh').attr('href', $link.attr('href'));
if ($link.hasClass('preview-code') || $link.hasClass('diff-code')) {
$modal.data('action', ($link.hasClass('preview-code') ? 'preview-code' : 'diff-code'))
}
$modal.find('.modal-title').text($link.data('title')); $modal.find('.modal-title').text($link.data('title'));
$modal.find('.modal-body').html('Loading ...'); $modal.find('.modal-body').html('Loading ...');
$modal.modal('show'); $modal.modal('show');
...@@ -48,6 +51,15 @@ yii.gii = (function ($) { ...@@ -48,6 +51,15 @@ yii.gii = (function ($) {
url: $link.prop('href'), url: $link.prop('href'),
data: $('.default-view form').serializeArray(), data: $('.default-view form').serializeArray(),
success: function (data) { success: function (data) {
if (!$link.hasClass('modal-refresh')) {
var filesSelector = 'a.' + $modal.data('action');
var $files = $(filesSelector);
var index = $files.filter('[href="' + $link.attr('href') + '"]').index(filesSelector);
var $prev = $files.eq(index-1);
var $next = $files.eq((index+1 == $files.length ? 0 : index+1));
$modal.find('.modal-previous').attr('href', $prev.attr('href')).data('title', $prev.data('title'));
$modal.find('.modal-next').attr('href', $next.attr('href')).data('title', $next.data('title'));
}
$modal.find('.modal-body').html(data); $modal.find('.modal-body').html(data);
$modal.find('.content').css('max-height', ($(window).height() - 200) + 'px'); $modal.find('.content').css('max-height', ($(window).height() - 200) + 'px');
}, },
......
...@@ -471,7 +471,7 @@ class Generator extends \yii\gii\Generator ...@@ -471,7 +471,7 @@ class Generator extends \yii\gii\Generator
*/ */
public function validateTableName() public function validateTableName()
{ {
if (($pos = strpos($this->tableName, '*')) !== false && substr($this->tableName, -1) !== '*') { if (strpos($this->tableName, '*') !== false && substr($this->tableName, -1) !== '*') {
$this->addError('tableName', 'Asterisk is only allowed as the last character.'); $this->addError('tableName', 'Asterisk is only allowed as the last character.');
return; return;
} }
......
...@@ -81,7 +81,14 @@ use yii\gii\CodeFile; ...@@ -81,7 +81,14 @@ use yii\gii\CodeFile;
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4><a class="modal-refresh glyphicon glyphicon-refresh" href="#"></a> <span class="modal-title">Modal title</span></h4> <div class="btn-group pull-left">
<a class="modal-previous btn btn-xs btn-default" href="#"><span class="glyphicon glyphicon-arrow-left"></span></a>
<a class="modal-next btn btn-xs btn-default" href="#"><span class="glyphicon glyphicon-arrow-right"></span></a>
<a class="modal-refresh btn btn-xs btn-default" href="#"><span class="glyphicon glyphicon-refresh"></span></a>
&nbsp;
</div>
<strong class="modal-title pull-left">Modal title</strong>
<div class="clearfix"></div>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Please wait ...</p> <p>Please wait ...</p>
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
...@@ -260,7 +260,7 @@ class Collection extends Object ...@@ -260,7 +260,7 @@ class Collection extends Object
} }
/** /**
* Returns a a single document. * Returns a single document.
* @param array $condition query condition * @param array $condition query condition
* @param array $fields fields to be selected * @param array $fields fields to be selected
* @return array|null the single document. Null is returned if the query results in nothing. * @return array|null the single document. Null is returned if the query results in nothing.
...@@ -272,6 +272,32 @@ class Collection extends Object ...@@ -272,6 +272,32 @@ class Collection extends Object
} }
/** /**
* Updates a document and returns it.
* @param array $condition query condition
* @param array $update update criteria
* @param array $fields fields to be returned
* @param array $options list of options in format: optionName => optionValue.
* @return array|null the original document, or the modified document when $options['new'] is set.
* @throws Exception on failure.
* @see http://www.php.net/manual/en/mongocollection.findandmodify.php
*/
public function findAndModify($condition, $update, $fields = [], $options = [])
{
$condition = $this->buildCondition($condition);
$token = $this->composeLogToken('findAndModify', [$condition, $update, $fields, $options]);
Yii::info($token, __METHOD__);
try {
Yii::beginProfile($token, __METHOD__);
$result = $this->mongoCollection->findAndModify($condition, $update, $fields, $options);
Yii::endProfile($token, __METHOD__);
return $result;
} catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
}
/**
* Inserts new data into collection. * Inserts new data into collection.
* @param array|object $data data to be inserted. * @param array|object $data data to be inserted.
* @param array $options list of options in format: optionName => optionValue. * @param array $options list of options in format: optionName => optionValue.
......
...@@ -19,7 +19,7 @@ use yii\mail\BaseMailer; ...@@ -19,7 +19,7 @@ use yii\mail\BaseMailer;
* ~~~ * ~~~
* 'components' => [ * 'components' => [
* ... * ...
* 'email' => [ * 'mail' => [
* 'class' => 'yii\swiftmailer\Mailer', * 'class' => 'yii\swiftmailer\Mailer',
* 'transport' => [ * 'transport' => [
* 'class' => 'Swift_SmtpTransport', * 'class' => 'Swift_SmtpTransport',
......
...@@ -14,37 +14,37 @@ use yii\log\Logger; ...@@ -14,37 +14,37 @@ use yii\log\Logger;
/** /**
* Gets the application start timestamp. * Gets the application start timestamp.
*/ */
defined('YII_BEGIN_TIME') or define('YII_BEGIN_TIME', microtime(true)); defined('YII_BEGIN_TIME') ?: define('YII_BEGIN_TIME', microtime(true));
/** /**
* This constant defines the framework installation directory. * This constant defines the framework installation directory.
*/ */
defined('YII_PATH') or define('YII_PATH', __DIR__); defined('YII_PATH') ?: define('YII_PATH', __DIR__);
/** /**
* This constant defines whether the application should be in debug mode or not. Defaults to false. * This constant defines whether the application should be in debug mode or not. Defaults to false.
*/ */
defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_DEBUG') ?: define('YII_DEBUG', false);
/** /**
* This constant defines in which environment the application is running. Defaults to 'prod', meaning production environment. * This constant defines in which environment the application is running. Defaults to 'prod', meaning production environment.
* You may define this constant in the bootstrap script. The value could be 'prod' (production), 'dev' (development), 'test', 'staging', etc. * You may define this constant in the bootstrap script. The value could be 'prod' (production), 'dev' (development), 'test', 'staging', etc.
*/ */
defined('YII_ENV') or define('YII_ENV', 'prod'); defined('YII_ENV') ?: define('YII_ENV', 'prod');
/** /**
* Whether the the application is running in production environment * Whether the the application is running in production environment
*/ */
defined('YII_ENV_PROD') or define('YII_ENV_PROD', YII_ENV === 'prod'); defined('YII_ENV_PROD') ?: define('YII_ENV_PROD', YII_ENV === 'prod');
/** /**
* Whether the the application is running in development environment * Whether the the application is running in development environment
*/ */
defined('YII_ENV_DEV') or define('YII_ENV_DEV', YII_ENV === 'dev'); defined('YII_ENV_DEV') ?: define('YII_ENV_DEV', YII_ENV === 'dev');
/** /**
* Whether the the application is running in testing environment * Whether the the application is running in testing environment
*/ */
defined('YII_ENV_TEST') or define('YII_ENV_TEST', YII_ENV === 'test'); defined('YII_ENV_TEST') ?: define('YII_ENV_TEST', YII_ENV === 'test');
/** /**
* This constant defines whether error handling should be enabled. Defaults to true. * This constant defines whether error handling should be enabled. Defaults to true.
*/ */
defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', true); defined('YII_ENABLE_ERROR_HANDLER') ?: define('YII_ENABLE_ERROR_HANDLER', true);
/** /**
...@@ -356,7 +356,7 @@ class BaseYii ...@@ -356,7 +356,7 @@ class BaseYii
$config = array_merge(static::$objectConfig[$class], $config); $config = array_merge(static::$objectConfig[$class], $config);
} }
if (($n = func_num_args()) > 1) { if (func_num_args() > 1) {
/** @var \ReflectionClass $reflection */ /** @var \ReflectionClass $reflection */
if (isset($reflections[$class])) { if (isset($reflections[$class])) {
$reflection = $reflections[$class]; $reflection = $reflections[$class];
......
...@@ -49,6 +49,9 @@ Yii Framework 2 Change Log ...@@ -49,6 +49,9 @@ Yii Framework 2 Change Log
- Bug #2502: Unclear error message when `$_SERVER['DOCUMENT_ROOT']` is empty (samdark) - Bug #2502: Unclear error message when `$_SERVER['DOCUMENT_ROOT']` is empty (samdark)
- Bug #2519: MessageSource removed translation messages when event handler was bound to `missingTranslation`-event (cebe) - Bug #2519: MessageSource removed translation messages when event handler was bound to `missingTranslation`-event (cebe)
- Bug #2527: Source language for `app` message category was always `en` no matter which application `sourceLanguage` was used (samdark) - Bug #2527: Source language for `app` message category was always `en` no matter which application `sourceLanguage` was used (samdark)
- Bug #2559: Going back on browser history breaks GridView filtering with `Pjax` (tonydspaniard)
- Bug #2607: `yii message` tool wasn't updating `message` table (mitalcoi)
- Bug #2624: Html::textArea() should respect "name" option. (qiangxue)
- Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark) - Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark)
- Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark) - Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark)
- Bug: Json::encode() did not handle objects that implement JsonSerializable interface correctly (cebe) - Bug: Json::encode() did not handle objects that implement JsonSerializable interface correctly (cebe)
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
// event - "click" jQuery.Event // event - "click" jQuery.Event
// options - pjax options // options - pjax options
// //
// If the click event target has 'data-pjax="0"' attribute, the event is ignored, and no pjax call is made.
//
// Examples // Examples
// //
// $(document).on('click', 'a', $.pjax.click) // $(document).on('click', 'a', $.pjax.click)
...@@ -61,6 +63,10 @@ ...@@ -61,6 +63,10 @@
var link = event.currentTarget var link = event.currentTarget
// Ignore links with data-pjax="0"
if ($(link).data('pjax')==0)
return
if (link.tagName.toUpperCase() !== 'A') if (link.tagName.toUpperCase() !== 'A')
throw "$.fn.pjax or $.pjax.click requires an anchor element" throw "$.fn.pjax or $.pjax.click requires an anchor element"
......
...@@ -26,17 +26,18 @@ ...@@ -26,17 +26,18 @@
filterSelector: undefined filterSelector: undefined
}; };
var gridData = {};
var methods = { var methods = {
init: function (options) { init: function (options) {
return this.each(function () { return this.each(function () {
var $e = $(this); var $e = $(this);
var settings = $.extend({}, defaults, options || {}); var settings = $.extend({}, defaults, options || {});
$e.data('yiiGridView', { gridData[$e.prop('id')] = {settings: settings};
settings: settings
});
var enterPressed = false; var enterPressed = false;
$(settings.filterSelector).on('change.yiiGridView keydown.yiiGridView', function (event) { $(document).off('change.yiiGridView keydown.yiiGridView', settings.filterSelector)
.on('change.yiiGridView keydown.yiiGridView', settings.filterSelector, function (event) {
if (event.type === 'keydown') { if (event.type === 'keydown') {
if (event.keyCode !== 13) { if (event.keyCode !== 13) {
return; // only react to enter key return; // only react to enter key
...@@ -60,7 +61,7 @@ ...@@ -60,7 +61,7 @@
applyFilter: function () { applyFilter: function () {
var $grid = $(this); var $grid = $(this);
var settings = $grid.data('yiiGridView').settings; var settings = gridData[$grid.prop('id')].settings;
var data = {}; var data = {};
$.each($(settings.filterSelector).serializeArray(), function () { $.each($(settings.filterSelector).serializeArray(), function () {
data[this.name] = this.value; data[this.name] = this.value;
...@@ -85,15 +86,16 @@ ...@@ -85,15 +86,16 @@
setSelectionColumn: function (options) { setSelectionColumn: function (options) {
var $grid = $(this); var $grid = $(this);
var data = $grid.data('yiiGridView'); var id = $(this).prop('id');
data.selectionColumn = options.name; gridData[id].selectionColumn = options.name;
if (!options.multiple) { if (!options.multiple) {
return; return;
} }
$grid.on('click.yiiGridView', "input[name='" + options.checkAll + "']", function () { var inputs = "#" + id + " input[name='" + options.checkAll + "']";
$(document).off('click.yiiGridView', inputs).on('click.yiiGridView', inputs, function () {
$grid.find("input[name='" + options.name + "']:enabled").prop('checked', this.checked); $grid.find("input[name='" + options.name + "']:enabled").prop('checked', this.checked);
}); });
$grid.on('click.yiiGridView', "input[name='" + options.name + "']:enabled", function () { $(document).off('click.yiiGridView', inputs + ":enabled").on('click.yiiGridView', inputs + ":enabled", function () {
var all = $grid.find("input[name='" + options.name + "']").length == $grid.find("input[name='" + options.name + "']:checked").length; var all = $grid.find("input[name='" + options.name + "']").length == $grid.find("input[name='" + options.name + "']:checked").length;
$grid.find("input[name='" + options.checkAll + "']").prop('checked', all); $grid.find("input[name='" + options.checkAll + "']").prop('checked', all);
}); });
...@@ -101,7 +103,7 @@ ...@@ -101,7 +103,7 @@
getSelectedRows: function () { getSelectedRows: function () {
var $grid = $(this); var $grid = $(this);
var data = $grid.data('yiiGridView'); var data = gridData[$grid.prop('id')];
var keys = []; var keys = [];
if (data.selectionColumn) { if (data.selectionColumn) {
$grid.find("input[name='" + data.selectionColumn + "']:checked").each(function () { $grid.find("input[name='" + data.selectionColumn + "']:checked").each(function () {
...@@ -118,8 +120,9 @@ ...@@ -118,8 +120,9 @@
}); });
}, },
data: function() { data: function () {
return this.data('yiiGridView'); var id = $(this).prop('id');
return gridData[id];
} }
}; };
})(window.jQuery); })(window.jQuery);
......
...@@ -442,17 +442,17 @@ class Formatter extends Component ...@@ -442,17 +442,17 @@ class Formatter extends Component
switch($position) { switch($position) {
case 0: case 0:
return $verbose ? Yii::t('yii','{n, plural, =1{# byte} other{# bytes}}', $params) : Yii::t('yii', '{n} B', $params); return $verbose ? Yii::t('yii', '{n, plural, =1{# byte} other{# bytes}}', $params) : Yii::t('yii', '{n} B', $params);
case 1: case 1:
return $verbose ? Yii::t('yii','{n, plural, =1{# kilobyte} other{# kilobytes}}', $params) : Yii::t('yii','{n} KB', $params); return $verbose ? Yii::t('yii', '{n, plural, =1{# kilobyte} other{# kilobytes}}', $params) : Yii::t('yii', '{n} KB', $params);
case 2: case 2:
return $verbose ? Yii::t('yii','{n, plural, =1{# megabyte} other{# megabytes}}', $params) : Yii::t('yii','{n} MB', $params); return $verbose ? Yii::t('yii', '{n, plural, =1{# megabyte} other{# megabytes}}', $params) : Yii::t('yii', '{n} MB', $params);
case 3: case 3:
return $verbose ? Yii::t('yii','{n, plural, =1{# gigabyte} other{# gigabytes}}', $params) : Yii::t('yii','{n} GB', $params); return $verbose ? Yii::t('yii', '{n, plural, =1{# gigabyte} other{# gigabytes}}', $params) : Yii::t('yii', '{n} GB', $params);
case 4: case 4:
return $verbose ? Yii::t('yii','{n, plural, =1{# terabyte} other{# terabytes}}', $params) : Yii::t('yii','{n} TB', $params); return $verbose ? Yii::t('yii', '{n, plural, =1{# terabyte} other{# terabytes}}', $params) : Yii::t('yii', '{n} TB', $params);
default: default:
return $verbose ? Yii::t('yii','{n, plural, =1{# petabyte} other{# petabytes}}', $params) : Yii::t('yii','{n} PB', $params); return $verbose ? Yii::t('yii', '{n, plural, =1{# petabyte} other{# petabytes}}', $params) : Yii::t('yii', '{n} PB', $params);
} }
} }
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\base; namespace yii\base;
use Yii; use Yii;
/** /**
......
...@@ -13,7 +13,7 @@ use yii\helpers\FileHelper; ...@@ -13,7 +13,7 @@ use yii\helpers\FileHelper;
/** /**
* Theme represents an application theme. * Theme represents an application theme.
* *
* When [[View]] renders a view file, it will check the [[Application::theme|active theme]] * When [[View]] renders a view file, it will check the [[View::theme|active theme]]
* to see if there is a themed version of the view file exists. If so, the themed version will be rendered instead. * to see if there is a themed version of the view file exists. If so, the themed version will be rendered instead.
* *
* A theme is a directory consisting of view files which are meant to replace their non-themed counterparts. * A theme is a directory consisting of view files which are meant to replace their non-themed counterparts.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\caching; namespace yii\caching;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\caching; namespace yii\caching;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
/** /**
......
...@@ -64,7 +64,7 @@ class FixtureController extends Controller ...@@ -64,7 +64,7 @@ class FixtureController extends Controller
public function globalOptions() public function globalOptions()
{ {
return array_merge(parent::globalOptions(), [ return array_merge(parent::globalOptions(), [
'namespace','globalFixtures' 'namespace', 'globalFixtures'
]); ]);
} }
...@@ -74,6 +74,7 @@ class FixtureController extends Controller ...@@ -74,6 +74,7 @@ class FixtureController extends Controller
* whitespace between names. Note that if you are loading fixtures to storage, for example: database or nosql, * whitespace between names. Note that if you are loading fixtures to storage, for example: database or nosql,
* storage will not be cleared, data will be appended to already existed. * storage will not be cleared, data will be appended to already existed.
* @param array $fixtures * @param array $fixtures
* @param array $except
* @throws \yii\console\Exception * @throws \yii\console\Exception
*/ */
public function actionLoad(array $fixtures, array $except = []) public function actionLoad(array $fixtures, array $except = [])
...@@ -99,7 +100,7 @@ class FixtureController extends Controller ...@@ -99,7 +100,7 @@ class FixtureController extends Controller
} }
$filtered = array_diff($foundFixtures, $except); $filtered = array_diff($foundFixtures, $except);
$fixtures = $this->getFixturesConfig(array_merge($this->globalFixtures ,$filtered)); $fixtures = $this->getFixturesConfig(array_merge($this->globalFixtures, $filtered));
if (!$fixtures) { if (!$fixtures) {
throw new Exception('No fixtures were found in namespace: "' . $this->namespace . '"' . ''); throw new Exception('No fixtures were found in namespace: "' . $this->namespace . '"' . '');
...@@ -317,5 +318,4 @@ class FixtureController extends Controller ...@@ -317,5 +318,4 @@ class FixtureController extends Controller
{ {
return Yii::getAlias('@' . str_replace('\\', '/', $this->namespace)); return Yii::getAlias('@' . str_replace('\\', '/', $this->namespace));
} }
} }
...@@ -134,11 +134,14 @@ class MessageController extends Controller ...@@ -134,11 +134,14 @@ class MessageController extends Controller
throw new Exception('The "db" option must refer to a valid database application component.'); throw new Exception('The "db" option must refer to a valid database application component.');
} }
$sourceMessageTable = isset($config['sourceMessageTable']) ? $config['sourceMessageTable'] : '{{%source_message}}'; $sourceMessageTable = isset($config['sourceMessageTable']) ? $config['sourceMessageTable'] : '{{%source_message}}';
$messageTable = isset($config['messageTable']) ? $config['messageTable'] : '{{%message}}';
$this->saveMessagesToDb( $this->saveMessagesToDb(
$messages, $messages,
$db, $db,
$sourceMessageTable, $sourceMessageTable,
$config['removeUnused'] $messageTable,
$config['removeUnused'],
$config['languages']
); );
} }
} }
...@@ -149,9 +152,11 @@ class MessageController extends Controller ...@@ -149,9 +152,11 @@ class MessageController extends Controller
* @param array $messages * @param array $messages
* @param \yii\db\Connection $db * @param \yii\db\Connection $db
* @param string $sourceMessageTable * @param string $sourceMessageTable
* @param string $messageTable
* @param boolean $removeUnused * @param boolean $removeUnused
* @param array $languages
*/ */
protected function saveMessagesToDb($messages, $db, $sourceMessageTable, $removeUnused) protected function saveMessagesToDb($messages, $db, $sourceMessageTable, $messageTable, $removeUnused, $languages)
{ {
$q = new \yii\db\Query; $q = new \yii\db\Query;
$current = []; $current = [];
...@@ -190,12 +195,17 @@ class MessageController extends Controller ...@@ -190,12 +195,17 @@ class MessageController extends Controller
echo "Inserting new messages..."; echo "Inserting new messages...";
$savedFlag = false; $savedFlag = false;
foreach ($new as $category => $msgs) { foreach ($new as $category => $msgs) {
foreach ($msgs as $m) { foreach ($msgs as $m) {
$savedFlag = true; $savedFlag = true;
$db->createCommand() $db->createCommand()
->insert($sourceMessageTable, ['category' => $category, 'message' => $m])->execute(); ->insert($sourceMessageTable, ['category' => $category, 'message' => $m])->execute();
$lastId = $db->getLastInsertID();
foreach ($languages as $language) {
$db->createCommand()
->insert($messageTable, ['id' => $lastId, 'language' => $language])->execute();
}
} }
} }
...@@ -207,15 +217,20 @@ class MessageController extends Controller ...@@ -207,15 +217,20 @@ class MessageController extends Controller
} else { } else {
if ($removeUnused) { if ($removeUnused) {
$db->createCommand() $db->createCommand()
->delete($sourceMessageTable, ['in', 'id', $obsolete])->execute(); ->delete($sourceMessageTable, ['in', 'id', $obsolete])->execute();
echo "deleted.\n"; echo "deleted.\n";
} else { } else {
$last_id = $db->getLastInsertID();
$db->createCommand() $db->createCommand()
->update( ->update(
$sourceMessageTable, $sourceMessageTable,
['message' => new \yii\db\Expression("CONCAT('@@',message,'@@')")], ['message' => new \yii\db\Expression("CONCAT('@@',message,'@@')")],
['in', 'id', $obsolete] ['in', 'id', $obsolete]
)->execute(); )->execute();
foreach ($languages as $language) {
$db->createCommand()
->insert($messageTable, ['id' => $last_id, 'language' => $language])->execute();
}
echo "updated.\n"; echo "updated.\n";
} }
} }
...@@ -268,7 +283,7 @@ class MessageController extends Controller ...@@ -268,7 +283,7 @@ class MessageController extends Controller
{ {
echo "Saving messages to $fileName..."; echo "Saving messages to $fileName...";
if (is_file($fileName)) { if (is_file($fileName)) {
if($format === 'po'){ if ($format === 'po') {
$translated = file_get_contents($fileName); $translated = file_get_contents($fileName);
preg_match_all('/(?<=msgid ").*(?="\n(#*)msgstr)/', $translated, $keys); preg_match_all('/(?<=msgid ").*(?="\n(#*)msgstr)/', $translated, $keys);
preg_match_all('/(?<=msgstr ").*(?="\n\n)/', $translated, $values); preg_match_all('/(?<=msgstr ").*(?="\n\n)/', $translated, $values);
...@@ -285,7 +300,7 @@ class MessageController extends Controller ...@@ -285,7 +300,7 @@ class MessageController extends Controller
$merged = []; $merged = [];
$untranslated = []; $untranslated = [];
foreach ($messages as $message) { foreach ($messages as $message) {
if($format === 'po'){ if ($format === 'po') {
$message = preg_replace('/\"/', '\"', $message); $message = preg_replace('/\"/', '\"', $message);
} }
if (array_key_exists($message, $translated) && strlen($translated[$message]) > 0) { if (array_key_exists($message, $translated) && strlen($translated[$message]) > 0) {
...@@ -317,9 +332,9 @@ class MessageController extends Controller ...@@ -317,9 +332,9 @@ class MessageController extends Controller
if (false === $overwrite) { if (false === $overwrite) {
$fileName .= '.merged'; $fileName .= '.merged';
} }
if ($format === 'po'){ if ($format === 'po') {
$output = ''; $output = '';
foreach ($merged as $k => $v){ foreach ($merged as $k => $v) {
$k = preg_replace('/(\")|(\\\")/', "\\\"", $k); $k = preg_replace('/(\")|(\\\")/', "\\\"", $k);
$v = preg_replace('/(\")|(\\\")/', "\\\"", $v); $v = preg_replace('/(\")|(\\\")/', "\\\"", $v);
if (substr($v, 0, 2) === '@@' && substr($v, -2) === '@@') { if (substr($v, 0, 2) === '@@' && substr($v, -2) === '@@') {
...@@ -338,7 +353,7 @@ class MessageController extends Controller ...@@ -338,7 +353,7 @@ class MessageController extends Controller
if ($format === 'po') { if ($format === 'po') {
$merged = ''; $merged = '';
sort($messages); sort($messages);
foreach($messages as $message) { foreach ($messages as $message) {
$message = preg_replace('/(\")|(\\\")/', '\\\"', $message); $message = preg_replace('/(\")|(\\\")/', '\\\"', $message);
$merged .= "msgid \"$message\"\n"; $merged .= "msgid \"$message\"\n";
$merged .= "msgstr \"\"\n"; $merged .= "msgstr \"\"\n";
......
...@@ -120,7 +120,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -120,7 +120,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models); $this->findWith($this->with, $models);
} }
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
......
...@@ -288,7 +288,7 @@ trait ActiveRelationTrait ...@@ -288,7 +288,7 @@ trait ActiveRelationTrait
foreach ($primaryModels as $i => $primaryModel) { foreach ($primaryModels as $i => $primaryModel) {
if ($primaryModels[$i][$primaryName] instanceof ActiveRecordInterface) { if ($primaryModels[$i][$primaryName] instanceof ActiveRecordInterface) {
$primaryModels[$i][$primaryName]->populateRelation($name, $primaryModel); $primaryModels[$i][$primaryName]->populateRelation($name, $primaryModel);
} elseif (!empty($primaryModels[$i][$primaryName])) { } elseif (!empty($primaryModels[$i][$primaryName])) {
$primaryModels[$i][$primaryName][$name] = $primaryModel; $primaryModels[$i][$primaryName][$name] = $primaryModel;
} }
} }
......
...@@ -599,7 +599,7 @@ class QueryBuilder extends \yii\base\Object ...@@ -599,7 +599,7 @@ class QueryBuilder extends \yii\base\Object
if (strpos($column, '(') === false) { if (strpos($column, '(') === false) {
$column = $this->db->quoteColumnName($column); $column = $this->db->quoteColumnName($column);
} }
$columns[$i] = "$column AS " . $this->db->quoteColumnName($i);; $columns[$i] = "$column AS " . $this->db->quoteColumnName($i);
} elseif (strpos($column, '(') === false) { } elseif (strpos($column, '(') === false) {
if (preg_match('/^(.*?)(?i:\s+as\s+|\s+)([\w\-_\.]+)$/', $column, $matches)) { if (preg_match('/^(.*?)(?i:\s+as\s+|\s+)([\w\-_\.]+)$/', $column, $matches)) {
$columns[$i] = $this->db->quoteColumnName($matches[1]) . ' AS ' . $this->db->quoteColumnName($matches[2]); $columns[$i] = $this->db->quoteColumnName($matches[1]) . ' AS ' . $this->db->quoteColumnName($matches[2]);
......
...@@ -242,7 +242,7 @@ EOD; ...@@ -242,7 +242,7 @@ EOD;
} elseif (strpos($dbType, 'NUMBER') !== false || strpos($dbType, 'INTEGER') !== false) { } elseif (strpos($dbType, 'NUMBER') !== false || strpos($dbType, 'INTEGER') !== false) {
if (strpos($dbType, '(') && preg_match('/\((.*)\)/', $dbType, $matches)) { if (strpos($dbType, '(') && preg_match('/\((.*)\)/', $dbType, $matches)) {
$values = explode(',', $matches[1]); $values = explode(',', $matches[1]);
if (isset($values[1]) and (((int)$values[1]) > 0)) { if (isset($values[1]) && (((int)$values[1]) > 0)) {
$column->type = 'double'; $column->type = 'double';
} else { } else {
$column->type = 'integer'; $column->type = 'integer';
......
...@@ -88,6 +88,7 @@ class ActionColumn extends Column ...@@ -88,6 +88,7 @@ class ActionColumn extends Column
$this->buttons['view'] = function ($url, $model) { $this->buttons['view'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [ return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => Yii::t('yii', 'View'), 'title' => Yii::t('yii', 'View'),
'data-pjax' => '0',
]); ]);
}; };
} }
...@@ -95,6 +96,7 @@ class ActionColumn extends Column ...@@ -95,6 +96,7 @@ class ActionColumn extends Column
$this->buttons['update'] = function ($url, $model) { $this->buttons['update'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
'title' => Yii::t('yii', 'Update'), 'title' => Yii::t('yii', 'Update'),
'data-pjax' => '0',
]); ]);
}; };
} }
...@@ -104,6 +106,7 @@ class ActionColumn extends Column ...@@ -104,6 +106,7 @@ class ActionColumn extends Column
'title' => Yii::t('yii', 'Delete'), 'title' => Yii::t('yii', 'Delete'),
'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'),
'data-method' => 'post', 'data-method' => 'post',
'data-pjax' => '0',
]); ]);
}; };
} }
......
...@@ -152,7 +152,7 @@ class DataColumn extends Column ...@@ -152,7 +152,7 @@ class DataColumn extends Column
return parent::getDataCellContent($model, $key, $index); return parent::getDataCellContent($model, $key, $index);
} }
return $value; return $value;
} }
/** /**
* @inheritdoc * @inheritdoc
......
...@@ -147,6 +147,7 @@ class BaseFileHelper ...@@ -147,6 +147,7 @@ class BaseFileHelper
* @param string $src the source directory * @param string $src the source directory
* @param string $dst the destination directory * @param string $dst the destination directory
* @param array $options options for directory copy. Valid options are: * @param array $options options for directory copy. Valid options are:
* @throws \yii\base\InvalidParamException if unable to open directory
* *
* - dirMode: integer, the permission to be set for newly copied directories. Defaults to 0775. * - dirMode: integer, the permission to be set for newly copied directories. Defaults to 0775.
* - fileMode: integer, the permission to be set for newly copied files. Defaults to the current environment setting. * - fileMode: integer, the permission to be set for newly copied files. Defaults to the current environment setting.
...@@ -280,14 +281,14 @@ class BaseFileHelper ...@@ -280,14 +281,14 @@ class BaseFileHelper
$options['basePath'] = realpath($dir); $options['basePath'] = realpath($dir);
// this should also be done only once // this should also be done only once
if (isset($options['except'])) { if (isset($options['except'])) {
foreach($options['except'] as $key=>$value) { foreach ($options['except'] as $key => $value) {
if (is_string($value)) { if (is_string($value)) {
$options['except'][$key] = static::parseExcludePattern($value); $options['except'][$key] = static::parseExcludePattern($value);
} }
} }
} }
if (isset($options['only'])) { if (isset($options['only'])) {
foreach($options['only'] as $key=>$value) { foreach ($options['only'] as $key => $value) {
if (is_string($value)) { if (is_string($value)) {
$options['only'][$key] = static::parseExcludePattern($value); $options['only'][$key] = static::parseExcludePattern($value);
} }
...@@ -397,7 +398,7 @@ class BaseFileHelper ...@@ -397,7 +398,7 @@ class BaseFileHelper
if ($pattern === $baseName) { if ($pattern === $baseName) {
return true; return true;
} }
} else if ($flags & self::PATTERN_ENDSWITH) { } elseif ($flags & self::PATTERN_ENDSWITH) {
/* "*literal" matching against "fooliteral" */ /* "*literal" matching against "fooliteral" */
$n = StringHelper::byteLength($pattern); $n = StringHelper::byteLength($pattern);
if (StringHelper::byteSubstr($pattern, 1, $n) === StringHelper::byteSubstr($baseName, -$n, $n)) { if (StringHelper::byteSubstr($pattern, 1, $n) === StringHelper::byteSubstr($baseName, -$n, $n)) {
...@@ -472,7 +473,7 @@ class BaseFileHelper ...@@ -472,7 +473,7 @@ class BaseFileHelper
*/ */
private static function lastExcludeMatchingFromList($basePath, $path, $excludes) private static function lastExcludeMatchingFromList($basePath, $path, $excludes)
{ {
foreach(array_reverse($excludes) as $exclude) { foreach (array_reverse($excludes) as $exclude) {
if (is_string($exclude)) { if (is_string($exclude)) {
$exclude = self::parseExcludePattern($exclude); $exclude = self::parseExcludePattern($exclude);
} }
...@@ -508,13 +509,14 @@ class BaseFileHelper ...@@ -508,13 +509,14 @@ class BaseFileHelper
if (!is_string($pattern)) { if (!is_string($pattern)) {
throw new InvalidParamException('Exclude/include pattern must be a string.'); throw new InvalidParamException('Exclude/include pattern must be a string.');
} }
$result = array( $result = [
'pattern' => $pattern, 'pattern' => $pattern,
'flags' => 0, 'flags' => 0,
'firstWildcard' => false, 'firstWildcard' => false,
); ];
if (!isset($pattern[0])) if (!isset($pattern[0])) {
return $result; return $result;
}
if ($pattern[0] == '!') { if ($pattern[0] == '!') {
$result['flags'] |= self::PATTERN_NEGATIVE; $result['flags'] |= self::PATTERN_NEGATIVE;
...@@ -526,11 +528,13 @@ class BaseFileHelper ...@@ -526,11 +528,13 @@ class BaseFileHelper
$len--; $len--;
$result['flags'] |= self::PATTERN_MUSTBEDIR; $result['flags'] |= self::PATTERN_MUSTBEDIR;
} }
if (strpos($pattern, '/') === false) if (strpos($pattern, '/') === false) {
$result['flags'] |= self::PATTERN_NODIR; $result['flags'] |= self::PATTERN_NODIR;
}
$result['firstWildcard'] = self::firstWildcardInPattern($pattern); $result['firstWildcard'] = self::firstWildcardInPattern($pattern);
if ($pattern[0] == '*' && self::firstWildcardInPattern(StringHelper::byteSubstr($pattern, 1, StringHelper::byteLength($pattern))) === false) if ($pattern[0] == '*' && self::firstWildcardInPattern(StringHelper::byteSubstr($pattern, 1, StringHelper::byteLength($pattern))) === false) {
$result['flags'] |= self::PATTERN_ENDSWITH; $result['flags'] |= self::PATTERN_ENDSWITH;
}
$result['pattern'] = $pattern; $result['pattern'] = $pattern;
return $result; return $result;
} }
...@@ -542,8 +546,8 @@ class BaseFileHelper ...@@ -542,8 +546,8 @@ class BaseFileHelper
*/ */
private static function firstWildcardInPattern($pattern) private static function firstWildcardInPattern($pattern)
{ {
$wildcards = array('*','?','[','\\'); $wildcards = ['*', '?', '[', '\\'];
$wildcardSearch = function($r, $c) use ($pattern) { $wildcardSearch = function ($r, $c) use ($pattern) {
$p = strpos($pattern, $c); $p = strpos($pattern, $c);
return $r===false ? $p : ($p===false ? $r : min($r, $p)); return $r===false ? $p : ($p===false ? $r : min($r, $p));
}; };
......
...@@ -1140,12 +1140,12 @@ class BaseHtml ...@@ -1140,12 +1140,12 @@ class BaseHtml
* about attribute expression. * about attribute expression.
* @param array $options the tag options in terms of name-value pairs. These will be rendered as * @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* See [[renderTagAttributes()]] for details on how these are beeing rendered. * See [[renderTagAttributes()]] for details on how these are being rendered.
* @return string the generated textarea tag * @return string the generated textarea tag
*/ */
public static function activeTextarea($model, $attribute, $options = []) public static function activeTextarea($model, $attribute, $options = [])
{ {
$name = static::getInputName($model, $attribute); $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$value = static::getAttributeValue($model, $attribute); $value = static::getAttributeValue($model, $attribute);
if (!array_key_exists('id', $options)) { if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute); $options['id'] = static::getInputId($model, $attribute);
...@@ -1579,7 +1579,7 @@ class BaseHtml ...@@ -1579,7 +1579,7 @@ class BaseHtml
{ {
if (isset($options['class'])) { if (isset($options['class'])) {
$classes = ' ' . $options['class'] . ' '; $classes = ' ' . $options['class'] . ' ';
if (($pos = strpos($classes, ' ' . $class . ' ')) === false) { if (strpos($classes, ' ' . $class . ' ') === false) {
$options['class'] .= ' ' . $class; $options['class'] .= ' ' . $class;
} }
} else { } else {
......
...@@ -86,7 +86,7 @@ class BaseMarkdown ...@@ -86,7 +86,7 @@ class BaseMarkdown
/** @var \cebe\markdown\Markdown $parser */ /** @var \cebe\markdown\Markdown $parser */
if (!isset(static::$flavors[$flavor])) { if (!isset(static::$flavors[$flavor])) {
throw new InvalidParamException("Markdown flavor '$flavor' is not defined.'"); throw new InvalidParamException("Markdown flavor '$flavor' is not defined.'");
} elseif(!is_object($config = static::$flavors[$flavor])) { } elseif (!is_object($config = static::$flavors[$flavor])) {
$parser = Yii::createObject($config); $parser = Yii::createObject($config);
if (is_array($config)) { if (is_array($config)) {
foreach ($config as $name => $value) { foreach ($config as $name => $value) {
......
...@@ -107,10 +107,10 @@ class BaseSecurity ...@@ -107,10 +107,10 @@ class BaseSecurity
*/ */
protected static function stripPadding($data) protected static function stripPadding($data)
{ {
$end = StringHelper::byteSubstr($data, -1, NULL); $end = StringHelper::byteSubstr($data, -1, null);
$last = ord($end); $last = ord($end);
$n = StringHelper::byteLength($data) - $last; $n = StringHelper::byteLength($data) - $last;
if (StringHelper::byteSubstr($data, $n, NULL) == str_repeat($end, $last)) { if (StringHelper::byteSubstr($data, $n, null) == str_repeat($end, $last)) {
return StringHelper::byteSubstr($data, 0, $n); return StringHelper::byteSubstr($data, 0, $n);
} }
return false; return false;
......
...@@ -70,9 +70,9 @@ class GettextMessageSource extends MessageSource ...@@ -70,9 +70,9 @@ class GettextMessageSource extends MessageSource
if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) { if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) {
Yii::error("The message file for category '$category' does not exist: $messageFile Fallback file does not exist as well: $fallbackMessageFile", __METHOD__); Yii::error("The message file for category '$category' does not exist: $messageFile Fallback file does not exist as well: $fallbackMessageFile", __METHOD__);
} else if (empty($messages)) { } elseif (empty($messages)) {
return $fallbackMessages; return $fallbackMessages;
} else if (!empty($fallbackMessages)) { } elseif (!empty($fallbackMessages)) {
foreach ($fallbackMessages as $key => $value) { foreach ($fallbackMessages as $key => $value) {
if (!empty($value) && empty($messages[$key])) { if (!empty($value) && empty($messages[$key])) {
$messages[$key] = $fallbackMessages[$key]; $messages[$key] = $fallbackMessages[$key];
......
...@@ -126,7 +126,7 @@ class I18N extends Component ...@@ -126,7 +126,7 @@ class I18N extends Component
} }
$p = []; $p = [];
foreach($params as $name => $value) { foreach ($params as $name => $value) {
$p['{' . $name . '}'] = $value; $p['{' . $name . '}'] = $value;
} }
return strtr($message, $p); return strtr($message, $p);
......
...@@ -143,7 +143,7 @@ class MessageFormatter extends Component ...@@ -143,7 +143,7 @@ class MessageFormatter extends Component
return false; return false;
} }
$map = []; $map = [];
foreach($tokens as $i => $token) { foreach ($tokens as $i => $token) {
if (is_array($token)) { if (is_array($token)) {
$param = trim($token[0]); $param = trim($token[0]);
if (!isset($map[$param])) { if (!isset($map[$param])) {
...@@ -169,7 +169,7 @@ class MessageFormatter extends Component ...@@ -169,7 +169,7 @@ class MessageFormatter extends Component
return false; return false;
} else { } else {
$values = []; $values = [];
foreach($result as $key => $value) { foreach ($result as $key => $value) {
$values[$map[$key]] = $value; $values[$map[$key]] = $value;
} }
return $values; return $values;
...@@ -190,7 +190,7 @@ class MessageFormatter extends Component ...@@ -190,7 +190,7 @@ class MessageFormatter extends Component
if (($tokens = self::tokenizePattern($pattern)) === false) { if (($tokens = self::tokenizePattern($pattern)) === false) {
return false; return false;
} }
foreach($tokens as $i => $token) { foreach ($tokens as $i => $token) {
if (!is_array($token)) { if (!is_array($token)) {
continue; continue;
} }
...@@ -210,7 +210,7 @@ class MessageFormatter extends Component ...@@ -210,7 +210,7 @@ class MessageFormatter extends Component
} }
$type = isset($token[1]) ? trim($token[1]) : 'none'; $type = isset($token[1]) ? trim($token[1]) : 'none';
// replace plural and select format recursively // replace plural and select format recursively
if ($type == 'plural' || $type == 'select') { if ($type == 'plural' || $type == 'select') {
if (!isset($token[2])) { if (!isset($token[2])) {
return false; return false;
} }
...@@ -244,7 +244,7 @@ class MessageFormatter extends Component ...@@ -244,7 +244,7 @@ class MessageFormatter extends Component
$this->_errorMessage = "Message pattern is invalid."; $this->_errorMessage = "Message pattern is invalid.";
return false; return false;
} }
foreach($tokens as $i => $token) { foreach ($tokens as $i => $token) {
if (is_array($token)) { if (is_array($token)) {
if (($tokens[$i] = $this->parseToken($token, $args, $locale)) === false) { if (($tokens[$i] = $this->parseToken($token, $args, $locale)) === false) {
$this->_errorCode = -1; $this->_errorCode = -1;
......
...@@ -73,9 +73,9 @@ class PhpMessageSource extends MessageSource ...@@ -73,9 +73,9 @@ class PhpMessageSource extends MessageSource
if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) { if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) {
Yii::error("The message file for category '$category' does not exist: $messageFile Fallback file does not exist as well: $fallbackMessageFile", __METHOD__); Yii::error("The message file for category '$category' does not exist: $messageFile Fallback file does not exist as well: $fallbackMessageFile", __METHOD__);
} else if (empty($messages)) { } elseif (empty($messages)) {
return $fallbackMessages; return $fallbackMessages;
} else if (!empty($fallbackMessages)) { } elseif (!empty($fallbackMessages)) {
foreach ($fallbackMessages as $key => $value) { foreach ($fallbackMessages as $key => $value) {
if (!empty($value) && empty($messages[$key])) { if (!empty($value) && empty($messages[$key])) {
$messages[$key] = $fallbackMessages[$key]; $messages[$key] = $fallbackMessages[$key];
......
...@@ -348,5 +348,4 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont ...@@ -348,5 +348,4 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
$event = new MailEvent(['message' => $message, 'isSuccessful' => $isSuccessful]); $event = new MailEvent(['message' => $message, 'isSuccessful' => $isSuccessful]);
$this->trigger(self::EVENT_AFTER_SEND, $event); $this->trigger(self::EVENT_AFTER_SEND, $event);
} }
} }
...@@ -82,4 +82,3 @@ class Fixture extends Component ...@@ -82,4 +82,3 @@ class Fixture extends Component
{ {
} }
} }
...@@ -124,7 +124,7 @@ class ImageValidator extends FileValidator ...@@ -124,7 +124,7 @@ class ImageValidator extends FileValidator
} }
if ($this->underHeight === null) { if ($this->underHeight === null) {
$this->underHeight = Yii::t('yii', 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.'); $this->underHeight = Yii::t('yii', 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
} }
if ($this->overWidth === null) { if ($this->overWidth === null) {
$this->overWidth = Yii::t('yii', 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.'); $this->overWidth = Yii::t('yii', 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\validators; namespace yii\validators;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\validators; namespace yii\validators;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -82,7 +82,7 @@ class AssetConverter extends Component implements AssetConverterInterface ...@@ -82,7 +82,7 @@ class AssetConverter extends Component implements AssetConverterInterface
$proc = proc_open($command, $descriptor, $pipes, $basePath); $proc = proc_open($command, $descriptor, $pipes, $basePath);
$stdout = stream_get_contents($pipes[1]); $stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]); $stderr = stream_get_contents($pipes[2]);
foreach($pipes as $pipe) { foreach ($pipes as $pipe) {
fclose($pipe); fclose($pipe);
} }
$status = proc_close($proc); $status = proc_close($proc);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\widgets; namespace yii\widgets;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -128,7 +128,7 @@ class LinkPager extends Widget ...@@ -128,7 +128,7 @@ class LinkPager extends Widget
protected function registerLinkTags() protected function registerLinkTags()
{ {
$view = $this->getView(); $view = $this->getView();
foreach($this->pagination->getLinks() as $rel => $href) { foreach ($this->pagination->getLinks() as $rel => $href) {
$view->registerLinkTag(['rel' => $rel, 'href' => $href], $rel); $view->registerLinkTag(['rel' => $rel, 'href' => $href], $rel);
} }
} }
......
...@@ -25,6 +25,8 @@ use yii\web\Response; ...@@ -25,6 +25,8 @@ use yii\web\Response;
* You may configure [[linkSelector]] to specify which links should trigger pjax, and configure [[formSelector]] * You may configure [[linkSelector]] to specify which links should trigger pjax, and configure [[formSelector]]
* to specify which form submission may trigger pjax. * to specify which form submission may trigger pjax.
* *
* You may disable pjax for a specific link inside the container by adding `data-pjax="0"` attribute to this link.
*
* The following example shows how to use Pjax with the [[\yii\gridview\GridView]] widget so that the grid pagination, * The following example shows how to use Pjax with the [[\yii\gridview\GridView]] widget so that the grid pagination,
* sorting and filtering can be done via pjax: * sorting and filtering can be done via pjax:
* *
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') ?: define('YII_DEBUG', true);
// fcgi doesn't have STDIN and STDOUT defined by default // fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDIN') ?: define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); defined('STDOUT') ?: define('STDOUT', fopen('php://stdout', 'w'));
require(__DIR__ . '/Yii.php'); require(__DIR__ . '/Yii.php');
......
...@@ -187,6 +187,60 @@ class CollectionTest extends MongoDbTestCase ...@@ -187,6 +187,60 @@ class CollectionTest extends MongoDbTestCase
$this->assertNotEmpty($result[0]['items']); $this->assertNotEmpty($result[0]['items']);
} }
public function testFindAndModify()
{
$collection = $this->getConnection()->getCollection('customer');
$rows = [
[
'name' => 'customer 1',
'status' => 1,
'amount' => 100,
],
[
'name' => 'customer 2',
'status' => 1,
'amount' => 200,
],
];
$collection->batchInsert($rows);
// increment field
$result = $collection->findAndModify(['name' => 'customer 1'], ['$inc' => ['status' => 1]]);
$this->assertEquals('customer 1', $result['name']);
$this->assertEquals(1, $result['status']);
$newResult = $collection->findOne(['name' => 'customer 1']);
$this->assertEquals(2, $newResult['status']);
// $set and return modified document
$result = $collection->findAndModify(
['name' => 'customer 2'],
['$set' => ['status' => 2]],
[],
['new' => true]
);
$this->assertEquals('customer 2', $result['name']);
$this->assertEquals(2, $result['status']);
// Full update document
$data = [
'name' => 'customer 3',
'city' => 'Minsk'
];
$result = $collection->findAndModify(
['name' => 'customer 2'],
$data,
[],
['new' => true]
);
$this->assertEquals('customer 3', $result['name']);
$this->assertEquals('Minsk', $result['city']);
$this->assertTrue(!isset($result['status']));
// Test exceptions
$this->setExpectedException('\yii\mongodb\Exception');
$collection->findAndModify(['name' => 'customer 1'], ['$wrongOperator' => ['status' => 1]]);
}
/** /**
* @depends testBatchInsert * @depends testBatchInsert
*/ */
...@@ -240,54 +294,54 @@ class CollectionTest extends MongoDbTestCase ...@@ -240,54 +294,54 @@ class CollectionTest extends MongoDbTestCase
$this->assertEquals($expectedRows, $rows); $this->assertEquals($expectedRows, $rows);
} }
/** /**
* @depends testMapReduce * @depends testMapReduce
*/ */
public function testMapReduceInline() public function testMapReduceInline()
{ {
$collection = $this->getConnection()->getCollection('customer'); $collection = $this->getConnection()->getCollection('customer');
$rows = [ $rows = [
[ [
'name' => 'customer 1', 'name' => 'customer 1',
'status' => 1, 'status' => 1,
'amount' => 100, 'amount' => 100,
], ],
[ [
'name' => 'customer 2', 'name' => 'customer 2',
'status' => 1, 'status' => 1,
'amount' => 200, 'amount' => 200,
], ],
[ [
'name' => 'customer 2', 'name' => 'customer 2',
'status' => 2, 'status' => 2,
'amount' => 400, 'amount' => 400,
], ],
[ [
'name' => 'customer 2', 'name' => 'customer 2',
'status' => 3, 'status' => 3,
'amount' => 500, 'amount' => 500,
], ],
]; ];
$collection->batchInsert($rows); $collection->batchInsert($rows);
$result = $collection->mapReduce( $result = $collection->mapReduce(
'function () {emit(this.status, this.amount)}', 'function () {emit(this.status, this.amount)}',
'function (key, values) {return Array.sum(values)}', 'function (key, values) {return Array.sum(values)}',
['inline' => true], ['inline' => true],
['status' => ['$lt' => 3]] ['status' => ['$lt' => 3]]
); );
$expectedRows = [ $expectedRows = [
[ [
'_id' => 1, '_id' => 1,
'value' => 300, 'value' => 300,
], ],
[ [
'_id' => 2, '_id' => 2,
'value' => 400, 'value' => 400,
], ],
]; ];
$this->assertEquals($expectedRows, $result); $this->assertEquals($expectedRows, $result);
} }
public function testCreateIndex() public function testCreateIndex()
{ {
......
...@@ -15,7 +15,7 @@ class ExceptionTest extends TestCase ...@@ -15,7 +15,7 @@ class ExceptionTest extends TestCase
$this->assertEquals('bar', $array['message']); $this->assertEquals('bar', $array['message']);
$this->assertEquals('foo', $array['previous']['message']); $this->assertEquals('foo', $array['previous']['message']);
$e = new InvalidCallException('bar', 0 ,new UserException('foo')); $e = new InvalidCallException('bar', 0, new UserException('foo'));
$array = $e->toArray(); $array = $e->toArray();
$this->assertEquals('bar', $array['message']); $this->assertEquals('bar', $array['message']);
$this->assertEquals('foo', $array['previous']['message']); $this->assertEquals('foo', $array['previous']['message']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment