Skip to content

Commit 98ad58e

Browse files
author
Samuel Akopyan
committed
Added chuck method for Active Records, code array => [] changes
1 parent 6b1f76a commit 98ad58e

File tree

27 files changed

+847
-1030
lines changed

27 files changed

+847
-1030
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Version 1.4.x -
22
----------------------------
33
- Enh: added possibility to hide system queries in debug panel
44
- Enh: added possibility to close debug panel to minimum size
5+
- Enh: added possibility to get records by chunks with chuck() method of Active Record
56
- Bug: fixed wrong assignment of _isRendered in CView
67

78

demos/login-system/protected/modules/setup/views/setup/requirements.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,30 @@
5050
</fieldset>
5151

5252
<?php
53-
if (!$isCriticalError) {
54-
echo CWidget::create('CFormView', array(
55-
'action' => 'setup/requirements',
56-
'method' => 'post',
57-
'htmlOptions' => array(
58-
'name' => 'frmSetup',
59-
),
60-
'fields' => array(
61-
'act' => array('type' => 'hidden', 'value' => 'send'),
62-
),
63-
'buttons' => array(
64-
'back' => array('type' => 'button', 'value' => A::t('setup', 'Previous'), 'htmlOptions' => array('name' => '', 'onclick' => "$(location).attr('href','setup/index');")),
65-
'submit' => array('type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => array('name' => ''))
66-
),
67-
'return' => true,
68-
));
53+
54+
if ( ! $isCriticalError) {
55+
echo CWidget::create(
56+
'CFormView',
57+
[
58+
'action' => 'setup/requirements',
59+
'method' => 'post',
60+
'htmlOptions' => [
61+
'name' => 'frmSetup',
62+
],
63+
'fields' => [
64+
'act' => ['type' => 'hidden', 'value' => 'send'],
65+
],
66+
'buttons' => [
67+
'back' => [
68+
'type' => 'button',
69+
'value' => A::t('setup', 'Previous'),
70+
'htmlOptions' => ['name' => '', 'onclick' => "$(location).attr('href','setup/index');"]
71+
],
72+
'submit' => ['type' => 'submit', 'value' => A::t('setup', 'Next'), 'htmlOptions' => ['name' => '']]
73+
],
74+
'return' => true,
75+
]
76+
);
6977
}
7078
?>
7179
<br>

demos/simple-blog/protected/config/db.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

demos/simple-blog/protected/config/main.php

Lines changed: 0 additions & 193 deletions
This file was deleted.

demos/simple-blog/protected/controllers/PostsController.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function indexAction($msg = '')
129129
// prepare pagination vars
130130
$this->_view->targetPage = 'posts/index';
131131
$this->_view->currentPage = A::app()->getRequest()->getQuery('page', 'integer', 1);
132-
$this->_view->pageSize = '15';
132+
$this->_view->pageSize = 15;
133133
$this->_view->totalRecords = Posts::model()->count();
134134

135135
if (!$this->_view->currentPage) {
@@ -147,13 +147,11 @@ public function indexAction($msg = '')
147147
));
148148
}else{
149149
$posts = null;
150-
Posts::model()->chunk($conditions, [], 2, function ($records) use(&$posts){
150+
Posts::model()->chunk($conditions, [], 10, function ($records) use(&$posts){
151151
foreach ($records as $key => $record) {
152152
$posts[] = $record;
153153
}
154-
//CDebug::d($record);
155154
});
156-
//CDebug::dd($posts);
157155
$this->_view->posts = $posts;
158156
}
159157
}

demos/simple-blog/protected/views/categories/add.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
<?= $actionMessage; ?>
55

66
<div class="panel-content">
7-
<?php
8-
echo CWidget::create('CFormView', array(
7+
<?php
8+
echo CWidget::create('CFormView', [
99
'action' => 'categories/insert',
1010
'method' => 'post',
11-
'htmlOptions' => array(
11+
'htmlOptions' => [
1212
'name' => 'frmAddCategory',
13-
),
14-
'fields' => array(
15-
'act' => array('type' => 'hidden', 'value' => 'send'),
16-
'categoryName' => array('type' => 'textbox', 'title' => 'Category Name', 'mandatoryStar' => true, 'htmlOptions' => array('maxlength' => '50', 'class' => 'text_header')),
17-
),
18-
'buttons' => array(
19-
'cancel' => array('type' => 'button', 'value' => 'Cancel', 'htmlOptions' => array('name' => '', 'onclick' => "$(location).attr('href','categories/index');")),
20-
'submit' => array('type' => 'submit', 'value' => 'Create'),
21-
),
22-
'events' => array(
23-
'focus' => array('field' => $errorField),
24-
),
13+
],
14+
'fields' => [
15+
'act' => ['type' => 'hidden', 'value' => 'send'],
16+
'categoryName' => ['type' => 'textbox', 'title' => 'Category Name', 'mandatoryStar' => true, 'htmlOptions' => ['maxlength' => '50', 'class' => 'text_header']],
17+
],
18+
'buttons' => [
19+
'cancel' => ['type' => 'button', 'value' => 'Cancel', 'htmlOptions' => ['name' => '', 'onclick' => "$(location).attr('href','categories/index');"]],
20+
'submit' => ['type' => 'submit', 'value' => 'Create'],
21+
],
22+
'events' => [
23+
'focus' => ['field' => $errorField],
24+
],
2525
'return' => true,
26-
));
27-
?>
26+
]);
27+
?>
2828
</div>
2929
<div class="panel-settings">
3030
This page provides you possibility to add new category.

demos/simple-blog/protected/views/categories/edit.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
echo CWidget::create('CFormView', array(
1010
'action' => 'categories/update',
1111
'method' => 'post',
12-
'htmlOptions' => array(
13-
'name' => 'frmEditCategory',
14-
),
12+
'htmlOptions' => [
13+
'name' => 'frmEditCategory',
14+
],
1515
'fields' => array(
1616
'act' => array('type' => 'hidden', 'value' => 'send'),
1717
'categoryId' => array('type' => 'hidden', 'value' => $categoryId),
@@ -20,12 +20,12 @@
2020
),
2121
'buttons' => array(
2222
'cancel' => array('type' => 'button', 'value' => 'Cancel', 'htmlOptions' => array('name' => '', 'onclick' => "$(location).attr('href','categories/index');")),
23-
'submit' => array('type' => 'submit', 'value' => 'Update'),
24-
),
25-
'events' => array(
26-
'focus' => array('field' => $errorField),
27-
),
28-
'return' => true,
23+
'submit' => ['type' => 'submit', 'value' => 'Update'],
24+
),
25+
'events' => array(
26+
'focus' => ['field' => $errorField],
27+
),
28+
'return' => true,
2929
));
3030
?>
3131
</div>

0 commit comments

Comments
 (0)