Skip to content

Commit 20fbe10

Browse files
author
Samuel Akopyan
committed
Chunk
1 parent ba69464 commit 20fbe10

File tree

3 files changed

+218
-2
lines changed

3 files changed

+218
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
return array(
3+
// database settings
4+
'db' => array(
5+
'driver' => 'mysql',
6+
'host' => 'localhost',
7+
'database' => 'test',
8+
'username' => 'root',
9+
'password' => '',
10+
'prefix' => 'mb_',
11+
)
12+
);
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
<?php
2+
3+
return array(
4+
// application data
5+
'name' => 'Simple Blog',
6+
'version' => '1.0.2',
7+
8+
// Directy CMF data
9+
'directy_cmf_version' => '',
10+
11+
// installation settings
12+
'installationKey' => '2x4686fpyk',
13+
14+
// Password keys settings (for database passwords only)
15+
// Remember: changing these settings after installation may lead to unstable work of application
16+
// encryptAlgorithm - md5, sha1 (not recommended), sha256, whirlpool, etc
17+
'password' => array(
18+
'encryption' => true,
19+
'encryptAlgorithm' => 'sha256',
20+
'encryptSalt' => true,
21+
'hashKey' => 'apphp_directy_login_system',
22+
),
23+
24+
// Text encryption settings (for database text fields only)
25+
// Remember: changing these settings after installation may lead to unstable work of application
26+
// Encryption level - PHP or DB
27+
// encryptAlgorithm - PHP: aes-256-cbc DB: AES
28+
'text' => array(
29+
'encryption' => true,
30+
'encryptAlgorithm' => 'aes-256-cbc',
31+
'encryptKey' => 'apphp_directy_cmf',
32+
),
33+
34+
// Default email settings
35+
'email' => array(
36+
'mailer' => 'smtpMailer', /* phpMail | phpMailer | smtpMailer */
37+
'from' => 'info@email.me',
38+
'fromName' => '', /* John Smith */
39+
'isHtml' => true,
40+
'smtp' => array(
41+
'auth' => true, /* true or false */
42+
'secure' => 'ssl', /* 'ssl', 'tls' or '' */
43+
'host' => 'smtp.gmail.com',
44+
'port' => '465',
45+
'username' => '',
46+
'password' => '',
47+
),
48+
),
49+
50+
// Validations
51+
// Define array of 'excluded' controllers, ex.: array('PaymentProviders', 'Checkout')
52+
// Token type: 'session', 'cookie' or 'multipages'
53+
'validation' => array(
54+
'csrf' => array('enable' => false, 'exclude' => array('PaymentProviders'), 'tokenType' => 'session'),
55+
'bruteforce' => array('enable' => true, 'badLogins' => 5, 'badRestores' => 5, 'redirectDelay' => 3)
56+
),
57+
58+
// Exception handling
59+
// Define exceptions exceptions in application
60+
'exceptionHandling' => array(
61+
'enable' => true,
62+
'level' => 'global'
63+
),
64+
65+
// Output compression
66+
'compression' => array(
67+
'gzip' => array('enable' => false),
68+
'html' => array('enable' => false),
69+
'css' => array('enable' => false, 'path' => 'assets/minified/css/', 'minify' => true),
70+
'js' => array('enable' => false, 'path' => 'assets/minified/js/', 'minify' => true),
71+
),
72+
73+
// Session settings
74+
'session' => array(
75+
'customStorage' => false, /* true value means use a custom storage (database), false - standard storage */
76+
'cacheLimiter' => '', /* to prevent 'Web Page expired' message for POST request use "private,must-revalidate" */
77+
'lifetime' => 24, /* session timeout in minutes, default: 24 min = 1440 sec */
78+
),
79+
80+
// Cookies settings
81+
'cookies' => array(
82+
'domain' => '',
83+
'path' => '/'
84+
),
85+
86+
// Cache settings
87+
'cache' => array(
88+
'enable' => false,
89+
'type' => 'auto', /* 'auto' or 'manual' */
90+
'lifetime' => 20, /* in minutes */
91+
'path' => 'protected/tmp/cache/'
92+
),
93+
94+
// Logger settings
95+
'log' => array(
96+
'enable' => false,
97+
'path' => 'protected/tmp/logs/',
98+
'fileExtension' => 'php',
99+
'dateFormat' => 'Y-m-d H:i:s',
100+
'threshold' => 1,
101+
'filePermissions' => 0644,
102+
'lifetime' => 30 /* in days */
103+
),
104+
105+
// RSS Feed settings
106+
'rss' => array(
107+
'path' => 'feeds/'
108+
),
109+
110+
// Datetime settings
111+
'defaultTimeZone' => 'UTC',
112+
113+
// Template default settings
114+
'template' => array(
115+
'default' => 'default'
116+
),
117+
118+
// Layout default settings
119+
'layouts' => array(
120+
'enable' => false,
121+
'default' => 'default'
122+
),
123+
124+
// Layout default settings
125+
'layouts' => array(
126+
'enable' => array('frontend' => false, 'backend' => false),
127+
'default' => 'default'
128+
),
129+
130+
// Application default settings
131+
'defaultBackendDirectory' => 'backoffice', /* default backoffice directory */
132+
'defaultErrorController' => 'Error', /* may be overridden by module settings */
133+
'defaultController' => 'Index', /* may be overridden by module settings */
134+
'defaultAction' => 'index', /* may be overridden by module settings */
135+
136+
// Application Backend settings
137+
'restoreAdminPassword' => array(
138+
'enable' => true,
139+
'recoveryType' => 'direct' /* 'direct' - send new password directly, 'recovery' - send link to recovery page */
140+
),
141+
142+
// Application components
143+
'components' => array(
144+
'Bootstrap' => array('enable' => true, 'class' => 'Bootstrap'),
145+
'BlogMenu' => array('enable' => true, 'class' => 'BlogMenu'),
146+
),
147+
148+
// Logger settings
149+
'log' => array(
150+
'enable' => false,
151+
'path' => 'protected/tmp/logs/',
152+
'fileExtension' => 'php',
153+
'dateFormat' => 'Y-m-d H:i:s',
154+
'threshold' => 1,
155+
'filePermissions' => 0644,
156+
'lifetime' => 30 /* in days */
157+
),
158+
159+
// Widget settings
160+
'widgets' => array(
161+
'paramKeysSensitive' => true
162+
),
163+
164+
// Application helpers
165+
'helpers' => array(
166+
//'helper' => array('enable' => true, 'class' => 'Helper'),
167+
),
168+
169+
// Application modules
170+
'modules' => array(
171+
'setup' => array('enable' => true, 'removable' => false, 'backendDefaultUrl' => ''),
172+
),
173+
174+
// Url manager
175+
'urlManager' => array(
176+
'urlFormat' => 'shortPath', /* get | path | shortPath */
177+
'rules' => array(
178+
// Required by payments module. If you remove these rules - make sure you define full path URL for pyment providers
179+
//'paymentProviders/handlePayment/provider/([a-zA-Z0-9\_]+)/handler/([a-zA-Z0-9\_]+)/module/([a-zA-Z0-9\_]+)[\/]?$' => 'paymentProviders/handlePayment/provider/{$0}/handler/{$1}/module/{$2}',
180+
'paymentProviders/handlePayment/([a-zA-Z0-9\_]+)/([a-zA-Z0-9\_]+)/([a-zA-Z0-9\_]+)[\/]?$' => 'paymentProviders/handlePayment/provider/{$0}/handler/{$1}/module/{$2}',
181+
//'paymentProviders/handlePayment/provider/([a-zA-Z0-9\_]+)/handler/([a-zA-Z0-9\_]+)[\/]?$' => 'paymentProviders/handlePayment/provider/{$0}/handler/{$1}',
182+
'paymentProviders/handlePayment/([a-zA-Z0-9\_]+)/([a-zA-Z0-9\_]+)[\/]?$' => 'paymentProviders/handlePayment/provider/{$0}/handler/{$1}',
183+
//'paymentProviders/handlePayment/provider/([a-zA-Z0-9\_]+)[\/]?$' => 'paymentProviders/handlePayment/provider/{$0}',
184+
'paymentProviders/handlePayment/([a-zA-Z0-9\_]+)[\/]?$' => 'paymentProviders/handlePayment/provider/{$0}',
185+
// Required by dynamic pages, if you want to use user-friendly URLs
186+
//'controller/action/value1/value2' => 'controllerName/action/param1/value1/param2/value2',
187+
//'sitepages/show/example-page-1' => 'sitePages/show/name/about-us',
188+
//'value1' => 'controllerName/action/param1/value1',
189+
//'about-us' => 'sitePages/show/name/about-us',
190+
),
191+
),
192+
193+
);

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,21 @@ public function indexAction($msg = '')
135135
if (!$this->_view->currentPage) {
136136
$this->_view->actionMessage = CWidget::create('CMessage', array('error', 'Wrong parameter passed! Please try again later.', array('button' => true)));
137137
} else {
138-
$this->_view->posts = Posts::model()->findAll(array(
138+
/* $this->_view->posts = Posts::model()->findAll(array(
139139
'limit' => (($this->_view->currentPage - 1) * $this->_view->pageSize) . ', ' . $this->_view->pageSize,
140140
'order' => 'post_datetime DESC',
141-
));
141+
));*/
142+
143+
$posts = null;
144+
Posts::model()->chunk(2, function ($records) use(&$posts){
145+
foreach ($records as $key => $record) {
146+
$posts[] = $record;
147+
}
148+
//CDebug::d($record);
149+
});
150+
//CDebug::dd($posts);
151+
152+
$this->_view->posts = $posts;
142153
}
143154

144155
$this->_view->render('posts/index');

0 commit comments

Comments
 (0)