From 9fe0eb6c3f712129c471090889f9a4c844fbadfc Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Fri, 25 Oct 2013 12:02:09 +0200 Subject: [PATCH 1/8] add sorting icons to gridview sort links in basic and advanced app css --- apps/advanced/backend/web/css/site.css | 21 +++++++++++++++++++++ apps/advanced/frontend/web/css/site.css | 21 +++++++++++++++++++++ apps/basic/web/css/site.css | 21 +++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/apps/advanced/backend/web/css/site.css b/apps/advanced/backend/web/css/site.css index e6db73c..6a355bd 100644 --- a/apps/advanced/backend/web/css/site.css +++ b/apps/advanced/backend/web/css/site.css @@ -17,3 +17,24 @@ body { font-size: 21px; padding: 14px 24px; } + +/* add sorting icons to gridview sort links */ +a.asc:after, a.desc:after { + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + padding-left: 5px; +} + +a.asc:after { content: /*"\e113"*/"\e151"; } +a.desc:after { content: /*"\e114"*/"\e152"; } + +.sort-numerical a.asc:after { content: "\e153"; } +.sort-numerical a.desc:after { content: "\e154"; } + +.sort-ordinal a.asc:after { content: "\e155"; } +.sort-ordinal a.desc:after { content: "\e156"; } diff --git a/apps/advanced/frontend/web/css/site.css b/apps/advanced/frontend/web/css/site.css index e6db73c..6a355bd 100644 --- a/apps/advanced/frontend/web/css/site.css +++ b/apps/advanced/frontend/web/css/site.css @@ -17,3 +17,24 @@ body { font-size: 21px; padding: 14px 24px; } + +/* add sorting icons to gridview sort links */ +a.asc:after, a.desc:after { + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + padding-left: 5px; +} + +a.asc:after { content: /*"\e113"*/"\e151"; } +a.desc:after { content: /*"\e114"*/"\e152"; } + +.sort-numerical a.asc:after { content: "\e153"; } +.sort-numerical a.desc:after { content: "\e154"; } + +.sort-ordinal a.asc:after { content: "\e155"; } +.sort-ordinal a.desc:after { content: "\e156"; } diff --git a/apps/basic/web/css/site.css b/apps/basic/web/css/site.css index 84c46e8..707c66d 100644 --- a/apps/basic/web/css/site.css +++ b/apps/basic/web/css/site.css @@ -18,3 +18,24 @@ body { font-size: 21px; padding: 14px 24px; } + +/* add sorting icons to gridview sort links */ +a.asc:after, a.desc:after { + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + padding-left: 5px; +} + +a.asc:after { content: /*"\e113"*/"\e151"; } +a.desc:after { content: /*"\e114"*/"\e152"; } + +.sort-numerical a.asc:after { content: "\e153"; } +.sort-numerical a.desc:after { content: "\e154"; } + +.sort-ordinal a.asc:after { content: "\e155"; } +.sort-ordinal a.desc:after { content: "\e156"; } From e4299afac1b017662f454cb7b48776b8ae995db3 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 25 Oct 2013 20:33:16 -0400 Subject: [PATCH 2/8] minor code refacotring. --- framework/yii/base/View.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/base/View.php b/framework/yii/base/View.php index 68b1094..57f2fc1 100644 --- a/framework/yii/base/View.php +++ b/framework/yii/base/View.php @@ -259,16 +259,16 @@ class View extends Component $output = ''; if ($this->beforeRender($viewFile)) { + Yii::trace("Rendering view file: $viewFile", __METHOD__); $ext = pathinfo($viewFile, PATHINFO_EXTENSION); if (isset($this->renderers[$ext])) { - if (is_array($this->renderers[$ext])) { + if (is_array($this->renderers[$ext]) || is_string($this->renders[$ext])) { $this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /** @var ViewRenderer $renderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { - Yii::trace("Rendering view file: $viewFile", __METHOD__); $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $output); From 786163c13f742ff5ca11b91ddf408e89a4cd2a81 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 26 Oct 2013 19:30:21 -0400 Subject: [PATCH 3/8] Fixes #1075: changed the default value of GridView::empty. --- framework/yii/grid/GridView.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/framework/yii/grid/GridView.php b/framework/yii/grid/GridView.php index 8a3196b..2981c82 100644 --- a/framework/yii/grid/GridView.php +++ b/framework/yii/grid/GridView.php @@ -89,6 +89,11 @@ class GridView extends BaseListView */ public $showFooter = false; /** + * @var string|boolean the HTML content to be displayed when [[dataProvider]] does not have any data. + * If false, the grid view will still be displayed (without body content though). + */ + public $empty = false; + /** * @var array|Formatter the formatter used to format model attribute values into displayable texts. * This can be either an instance of [[Formatter]] or an configuration array for creating the [[Formatter]] * instance. If this property is not set, the "formatter" application component will be used. From c50154fe3a6134f8f2f8da5db396cd5d8226cb02 Mon Sep 17 00:00:00 2001 From: Gudz Taras Date: Sun, 27 Oct 2013 12:23:26 +0300 Subject: [PATCH 4/8] Fixes issue #1078: Typo in comment --- framework/yii/bootstrap/ButtonGroup.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/bootstrap/ButtonGroup.php b/framework/yii/bootstrap/ButtonGroup.php index 529c7ef..4fc2eb3 100644 --- a/framework/yii/bootstrap/ButtonGroup.php +++ b/framework/yii/bootstrap/ButtonGroup.php @@ -17,7 +17,7 @@ use yii\helpers\Html; * * ```php * // a button group with items configuration - * echo ButtonGroup::::widget([ + * echo ButtonGroup::widget([ * 'buttons' => [ * ['label' => 'A'], * ['label' => 'B'], @@ -25,7 +25,7 @@ use yii\helpers\Html; * ]); * * // button group with an item as a string - * echo ButtonGroup::::widget([ + * echo ButtonGroup::widget([ * 'buttons' => [ * Button::widget(['label' => 'A']), * ['label' => 'B'], From b316ebee7fc2899ff55cdd25afadfb03594a6ff6 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 27 Oct 2013 10:16:10 -0400 Subject: [PATCH 5/8] typo fix. --- framework/yii/base/View.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/yii/base/View.php b/framework/yii/base/View.php index 57f2fc1..d3db27d 100644 --- a/framework/yii/base/View.php +++ b/framework/yii/base/View.php @@ -262,7 +262,7 @@ class View extends Component Yii::trace("Rendering view file: $viewFile", __METHOD__); $ext = pathinfo($viewFile, PATHINFO_EXTENSION); if (isset($this->renderers[$ext])) { - if (is_array($this->renderers[$ext]) || is_string($this->renders[$ext])) { + if (is_array($this->renderers[$ext]) || is_string($this->renderers[$ext])) { $this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /** @var ViewRenderer $renderer */ From 733263ba132bad78df1afc615ad1ef44b11f4fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=92=D0=BE?= =?UTF-8?q?=D0=BB=D0=BA=D0=BE=D0=B2?= Date: Sun, 27 Oct 2013 21:54:48 +0200 Subject: [PATCH 6/8] Update FallbackMessageFormatter.php Fix declarations for yii\i18n\FallbackMessageFormatter::format() and yii\i18n\FallbackMessageFormatter::formatMessage() --- framework/yii/i18n/FallbackMessageFormatter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/i18n/FallbackMessageFormatter.php b/framework/yii/i18n/FallbackMessageFormatter.php index 16d38f5..17928f5 100644 --- a/framework/yii/i18n/FallbackMessageFormatter.php +++ b/framework/yii/i18n/FallbackMessageFormatter.php @@ -66,7 +66,7 @@ class FallbackMessageFormatter * @param array $args Arguments to insert into the format string * @return string The formatted string, or `FALSE` if an error occurred */ - public function format(array $args) + public function format($args) { return static::formatMessage($this->_locale, $this->_pattern, $args); } @@ -79,7 +79,7 @@ class FallbackMessageFormatter * @param array $args The array of values to insert into the format string * @return string The formatted pattern string or `FALSE` if an error occurred */ - public static function formatMessage($locale, $pattern, array $args) + public static function formatMessage($locale, $pattern, $args) { if (($tokens = static::tokenizePattern($pattern)) === false) { return false; From c62e0cbbfb165e015b679d1d90ea10a921cb2071 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 28 Oct 2013 10:48:18 +0100 Subject: [PATCH 7/8] added unit test to verify AR afterSave isNewRecord value closes #1084 --- tests/unit/data/ar/Customer.php | 10 ++++++++++ tests/unit/framework/db/ActiveRecordTest.php | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/unit/data/ar/Customer.php b/tests/unit/data/ar/Customer.php index 60a68b5..0d2add1 100644 --- a/tests/unit/data/ar/Customer.php +++ b/tests/unit/data/ar/Customer.php @@ -17,6 +17,9 @@ class Customer extends ActiveRecord public $status2; + public static $afterSaveInsert = null; + public static $afterSaveNewRecord = null; + public static function tableName() { return 'tbl_customer'; @@ -31,4 +34,11 @@ class Customer extends ActiveRecord { $query->andWhere('status=1'); } + + public function afterSave($insert) + { + static::$afterSaveInsert = $insert; + static::$afterSaveNewRecord = $this->isNewRecord; + parent::afterSave($insert); + } } diff --git a/tests/unit/framework/db/ActiveRecordTest.php b/tests/unit/framework/db/ActiveRecordTest.php index eb9d425..d8d8f8f 100644 --- a/tests/unit/framework/db/ActiveRecordTest.php +++ b/tests/unit/framework/db/ActiveRecordTest.php @@ -295,10 +295,14 @@ class ActiveRecordTest extends DatabaseTestCase $this->assertNull($customer->id); $this->assertTrue($customer->isNewRecord); + Customer::$afterSaveNewRecord = null; + Customer::$afterSaveInsert = null; $customer->save(); $this->assertEquals(4, $customer->id); + $this->assertFalse(Customer::$afterSaveNewRecord); + $this->assertTrue(Customer::$afterSaveInsert); $this->assertFalse($customer->isNewRecord); } @@ -309,10 +313,15 @@ class ActiveRecordTest extends DatabaseTestCase $this->assertTrue($customer instanceof Customer); $this->assertEquals('user2', $customer->name); $this->assertFalse($customer->isNewRecord); + Customer::$afterSaveNewRecord = null; + Customer::$afterSaveInsert = null; + $customer->name = 'user2x'; $customer->save(); $this->assertEquals('user2x', $customer->name); $this->assertFalse($customer->isNewRecord); + $this->assertFalse(Customer::$afterSaveNewRecord); + $this->assertFalse(Customer::$afterSaveInsert); $customer2 = Customer::find(2); $this->assertEquals('user2x', $customer2->name); From 3b05e71561afcea47884eeedf843cb9eea0c003f Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 28 Oct 2013 11:01:38 +0100 Subject: [PATCH 8/8] ensure parameter types in baselistview message fixes #1072 --- framework/yii/data/ActiveDataProvider.php | 2 +- framework/yii/widgets/BaseListView.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/data/ActiveDataProvider.php b/framework/yii/data/ActiveDataProvider.php index e95e4b8..012b7dd 100644 --- a/framework/yii/data/ActiveDataProvider.php +++ b/framework/yii/data/ActiveDataProvider.php @@ -158,7 +158,7 @@ class ActiveDataProvider extends BaseDataProvider throw new InvalidConfigException('The "query" property must be an instance of Query or its subclass.'); } $query = clone $this->query; - return $query->limit(-1)->offset(-1)->count('*', $this->db); + return (int) $query->limit(-1)->offset(-1)->count('*', $this->db); } /** diff --git a/framework/yii/widgets/BaseListView.php b/framework/yii/widgets/BaseListView.php index 27b2eaf..ffbba38 100644 --- a/framework/yii/widgets/BaseListView.php +++ b/framework/yii/widgets/BaseListView.php @@ -139,7 +139,7 @@ abstract class BaseListView extends Widget $pageCount = $pagination->pageCount; if (($summaryContent = $this->summary) === null) { $summaryContent = '
' - . Yii::t('yii', 'Showing {totalCount, plural, =0{0} other{{begin}-{end}}} of {totalCount} {totalCount, plural, one{item} other{items}}.') + . Yii::t('yii', 'Showing {totalCount, plural, =0{0} other{{begin, number, integer}-{end, number, integer}}} of {totalCount, number, integer} {totalCount, plural, one{item} other{items}}.') . '
'; } } else {