@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Models; |
2 | 2 | |
3 | -use Illuminate\Database\Eloquent; |
|
4 | 3 | use EvolutionCMS\Traits; |
4 | +use Illuminate\Database\Eloquent; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EvolutionCMS\Models\UserAttribute |
@@ -46,52 +46,52 @@ |
||
46 | 46 | { |
47 | 47 | use Traits\Models\TimeMutator; |
48 | 48 | |
49 | - const CREATED_AT = 'createdon'; |
|
50 | - const UPDATED_AT = 'editedon'; |
|
49 | + const CREATED_AT = 'createdon'; |
|
50 | + const UPDATED_AT = 'editedon'; |
|
51 | 51 | protected $dateFormat = 'U'; |
52 | 52 | |
53 | - protected $casts = [ |
|
54 | - 'internalKey' => 'int', |
|
55 | - 'role' => 'int', |
|
56 | - 'blocked' => 'int', |
|
57 | - 'blockeduntil' => 'int', |
|
58 | - 'blockedafter' => 'int', |
|
59 | - 'logincount' => 'int', |
|
60 | - 'lastlogin' => 'int', |
|
61 | - 'thislogin' => 'int', |
|
62 | - 'failedlogincount' => 'int', |
|
63 | - 'dob' => 'int', |
|
64 | - 'gender' => 'int', |
|
65 | - 'createdon' => 'int', |
|
66 | - 'editedon' => 'int' |
|
67 | - ]; |
|
53 | + protected $casts = [ |
|
54 | + 'internalKey' => 'int', |
|
55 | + 'role' => 'int', |
|
56 | + 'blocked' => 'int', |
|
57 | + 'blockeduntil' => 'int', |
|
58 | + 'blockedafter' => 'int', |
|
59 | + 'logincount' => 'int', |
|
60 | + 'lastlogin' => 'int', |
|
61 | + 'thislogin' => 'int', |
|
62 | + 'failedlogincount' => 'int', |
|
63 | + 'dob' => 'int', |
|
64 | + 'gender' => 'int', |
|
65 | + 'createdon' => 'int', |
|
66 | + 'editedon' => 'int' |
|
67 | + ]; |
|
68 | 68 | |
69 | - protected $fillable = [ |
|
70 | - 'internalKey', |
|
71 | - 'fullname', |
|
72 | - 'role', |
|
73 | - 'email', |
|
74 | - 'phone', |
|
75 | - 'mobilephone', |
|
76 | - 'blocked', |
|
77 | - 'blockeduntil', |
|
78 | - 'blockedafter', |
|
79 | - 'logincount', |
|
80 | - 'lastlogin', |
|
81 | - 'thislogin', |
|
82 | - 'failedlogincount', |
|
83 | - 'sessionid', |
|
84 | - 'dob', |
|
85 | - 'gender', |
|
86 | - 'country', |
|
87 | - 'street', |
|
88 | - 'city', |
|
89 | - 'state', |
|
90 | - 'zip', |
|
91 | - 'fax', |
|
92 | - 'photo', |
|
93 | - 'comment' |
|
94 | - ]; |
|
69 | + protected $fillable = [ |
|
70 | + 'internalKey', |
|
71 | + 'fullname', |
|
72 | + 'role', |
|
73 | + 'email', |
|
74 | + 'phone', |
|
75 | + 'mobilephone', |
|
76 | + 'blocked', |
|
77 | + 'blockeduntil', |
|
78 | + 'blockedafter', |
|
79 | + 'logincount', |
|
80 | + 'lastlogin', |
|
81 | + 'thislogin', |
|
82 | + 'failedlogincount', |
|
83 | + 'sessionid', |
|
84 | + 'dob', |
|
85 | + 'gender', |
|
86 | + 'country', |
|
87 | + 'street', |
|
88 | + 'city', |
|
89 | + 'state', |
|
90 | + 'zip', |
|
91 | + 'fax', |
|
92 | + 'photo', |
|
93 | + 'comment' |
|
94 | + ]; |
|
95 | 95 | |
96 | 96 | public function getCreatedAtAttribute() |
97 | 97 | { |
@@ -105,6 +105,6 @@ |
||
105 | 105 | |
106 | 106 | public function user() |
107 | 107 | { |
108 | - return $this->belongsTo(ManagerUser::class,'internalKey','id'); |
|
108 | + return $this->belongsTo(ManagerUser::class, 'internalKey', 'id'); |
|
109 | 109 | } |
110 | 110 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Models; |
2 | 2 | |
3 | -use Illuminate\Database\Eloquent; |
|
4 | 3 | use EvolutionCMS\Traits; |
4 | +use Illuminate\Database\Eloquent; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EvolutionCMS\Models\UserRole |
@@ -93,162 +93,162 @@ |
||
93 | 93 | { |
94 | 94 | use Traits\Models\ManagerActions; |
95 | 95 | |
96 | - public $timestamps = false; |
|
96 | + public $timestamps = false; |
|
97 | 97 | |
98 | - protected $casts = [ |
|
99 | - 'frames' => 'int', |
|
100 | - 'home' => 'int', |
|
101 | - 'view_document' => 'int', |
|
102 | - 'new_document' => 'int', |
|
103 | - 'save_document' => 'int', |
|
104 | - 'publish_document' => 'int', |
|
105 | - 'delete_document' => 'int', |
|
106 | - 'empty_trash' => 'int', |
|
107 | - 'action_ok' => 'int', |
|
108 | - 'logout' => 'int', |
|
109 | - 'help' => 'int', |
|
110 | - 'messages' => 'int', |
|
111 | - 'new_user' => 'int', |
|
112 | - 'edit_user' => 'int', |
|
113 | - 'logs' => 'int', |
|
114 | - 'edit_parser' => 'int', |
|
115 | - 'save_parser' => 'int', |
|
116 | - 'edit_template' => 'int', |
|
117 | - 'settings' => 'int', |
|
118 | - 'credits' => 'int', |
|
119 | - 'new_template' => 'int', |
|
120 | - 'save_template' => 'int', |
|
121 | - 'delete_template' => 'int', |
|
122 | - 'edit_snippet' => 'int', |
|
123 | - 'new_snippet' => 'int', |
|
124 | - 'save_snippet' => 'int', |
|
125 | - 'delete_snippet' => 'int', |
|
126 | - 'edit_chunk' => 'int', |
|
127 | - 'new_chunk' => 'int', |
|
128 | - 'save_chunk' => 'int', |
|
129 | - 'delete_chunk' => 'int', |
|
130 | - 'empty_cache' => 'int', |
|
131 | - 'edit_document' => 'int', |
|
132 | - 'change_password' => 'int', |
|
133 | - 'error_dialog' => 'int', |
|
134 | - 'about' => 'int', |
|
135 | - 'category_manager' => 'int', |
|
136 | - 'file_manager' => 'int', |
|
137 | - 'assets_files' => 'int', |
|
138 | - 'assets_images' => 'int', |
|
139 | - 'save_user' => 'int', |
|
140 | - 'delete_user' => 'int', |
|
141 | - 'save_password' => 'int', |
|
142 | - 'edit_role' => 'int', |
|
143 | - 'save_role' => 'int', |
|
144 | - 'delete_role' => 'int', |
|
145 | - 'new_role' => 'int', |
|
146 | - 'access_permissions' => 'int', |
|
147 | - 'bk_manager' => 'int', |
|
148 | - 'new_plugin' => 'int', |
|
149 | - 'edit_plugin' => 'int', |
|
150 | - 'save_plugin' => 'int', |
|
151 | - 'delete_plugin' => 'int', |
|
152 | - 'new_module' => 'int', |
|
153 | - 'edit_module' => 'int', |
|
154 | - 'save_module' => 'int', |
|
155 | - 'delete_module' => 'int', |
|
156 | - 'exec_module' => 'int', |
|
157 | - 'view_eventlog' => 'int', |
|
158 | - 'delete_eventlog' => 'int', |
|
159 | - 'new_web_user' => 'int', |
|
160 | - 'edit_web_user' => 'int', |
|
161 | - 'save_web_user' => 'int', |
|
162 | - 'delete_web_user' => 'int', |
|
163 | - 'web_access_permissions' => 'int', |
|
164 | - 'view_unpublished' => 'int', |
|
165 | - 'import_static' => 'int', |
|
166 | - 'export_static' => 'int', |
|
167 | - 'remove_locks' => 'int', |
|
168 | - 'display_locks' => 'int', |
|
169 | - 'change_resourcetype' => 'int' |
|
170 | - ]; |
|
98 | + protected $casts = [ |
|
99 | + 'frames' => 'int', |
|
100 | + 'home' => 'int', |
|
101 | + 'view_document' => 'int', |
|
102 | + 'new_document' => 'int', |
|
103 | + 'save_document' => 'int', |
|
104 | + 'publish_document' => 'int', |
|
105 | + 'delete_document' => 'int', |
|
106 | + 'empty_trash' => 'int', |
|
107 | + 'action_ok' => 'int', |
|
108 | + 'logout' => 'int', |
|
109 | + 'help' => 'int', |
|
110 | + 'messages' => 'int', |
|
111 | + 'new_user' => 'int', |
|
112 | + 'edit_user' => 'int', |
|
113 | + 'logs' => 'int', |
|
114 | + 'edit_parser' => 'int', |
|
115 | + 'save_parser' => 'int', |
|
116 | + 'edit_template' => 'int', |
|
117 | + 'settings' => 'int', |
|
118 | + 'credits' => 'int', |
|
119 | + 'new_template' => 'int', |
|
120 | + 'save_template' => 'int', |
|
121 | + 'delete_template' => 'int', |
|
122 | + 'edit_snippet' => 'int', |
|
123 | + 'new_snippet' => 'int', |
|
124 | + 'save_snippet' => 'int', |
|
125 | + 'delete_snippet' => 'int', |
|
126 | + 'edit_chunk' => 'int', |
|
127 | + 'new_chunk' => 'int', |
|
128 | + 'save_chunk' => 'int', |
|
129 | + 'delete_chunk' => 'int', |
|
130 | + 'empty_cache' => 'int', |
|
131 | + 'edit_document' => 'int', |
|
132 | + 'change_password' => 'int', |
|
133 | + 'error_dialog' => 'int', |
|
134 | + 'about' => 'int', |
|
135 | + 'category_manager' => 'int', |
|
136 | + 'file_manager' => 'int', |
|
137 | + 'assets_files' => 'int', |
|
138 | + 'assets_images' => 'int', |
|
139 | + 'save_user' => 'int', |
|
140 | + 'delete_user' => 'int', |
|
141 | + 'save_password' => 'int', |
|
142 | + 'edit_role' => 'int', |
|
143 | + 'save_role' => 'int', |
|
144 | + 'delete_role' => 'int', |
|
145 | + 'new_role' => 'int', |
|
146 | + 'access_permissions' => 'int', |
|
147 | + 'bk_manager' => 'int', |
|
148 | + 'new_plugin' => 'int', |
|
149 | + 'edit_plugin' => 'int', |
|
150 | + 'save_plugin' => 'int', |
|
151 | + 'delete_plugin' => 'int', |
|
152 | + 'new_module' => 'int', |
|
153 | + 'edit_module' => 'int', |
|
154 | + 'save_module' => 'int', |
|
155 | + 'delete_module' => 'int', |
|
156 | + 'exec_module' => 'int', |
|
157 | + 'view_eventlog' => 'int', |
|
158 | + 'delete_eventlog' => 'int', |
|
159 | + 'new_web_user' => 'int', |
|
160 | + 'edit_web_user' => 'int', |
|
161 | + 'save_web_user' => 'int', |
|
162 | + 'delete_web_user' => 'int', |
|
163 | + 'web_access_permissions' => 'int', |
|
164 | + 'view_unpublished' => 'int', |
|
165 | + 'import_static' => 'int', |
|
166 | + 'export_static' => 'int', |
|
167 | + 'remove_locks' => 'int', |
|
168 | + 'display_locks' => 'int', |
|
169 | + 'change_resourcetype' => 'int' |
|
170 | + ]; |
|
171 | 171 | |
172 | - protected $hidden = [ |
|
173 | - 'change_password', |
|
174 | - 'save_password' |
|
175 | - ]; |
|
172 | + protected $hidden = [ |
|
173 | + 'change_password', |
|
174 | + 'save_password' |
|
175 | + ]; |
|
176 | 176 | |
177 | - protected $fillable = [ |
|
178 | - 'name', |
|
179 | - 'description', |
|
180 | - 'frames', |
|
181 | - 'home', |
|
182 | - 'view_document', |
|
183 | - 'new_document', |
|
184 | - 'save_document', |
|
185 | - 'publish_document', |
|
186 | - 'delete_document', |
|
187 | - 'empty_trash', |
|
188 | - 'action_ok', |
|
189 | - 'logout', |
|
190 | - 'help', |
|
191 | - 'messages', |
|
192 | - 'new_user', |
|
193 | - 'edit_user', |
|
194 | - 'logs', |
|
195 | - 'edit_parser', |
|
196 | - 'save_parser', |
|
197 | - 'edit_template', |
|
198 | - 'settings', |
|
199 | - 'credits', |
|
200 | - 'new_template', |
|
201 | - 'save_template', |
|
202 | - 'delete_template', |
|
203 | - 'edit_snippet', |
|
204 | - 'new_snippet', |
|
205 | - 'save_snippet', |
|
206 | - 'delete_snippet', |
|
207 | - 'edit_chunk', |
|
208 | - 'new_chunk', |
|
209 | - 'save_chunk', |
|
210 | - 'delete_chunk', |
|
211 | - 'empty_cache', |
|
212 | - 'edit_document', |
|
213 | - 'change_password', |
|
214 | - 'error_dialog', |
|
215 | - 'about', |
|
216 | - 'category_manager', |
|
217 | - 'file_manager', |
|
218 | - 'assets_files', |
|
219 | - 'assets_images', |
|
220 | - 'save_user', |
|
221 | - 'delete_user', |
|
222 | - 'save_password', |
|
223 | - 'edit_role', |
|
224 | - 'save_role', |
|
225 | - 'delete_role', |
|
226 | - 'new_role', |
|
227 | - 'access_permissions', |
|
228 | - 'bk_manager', |
|
229 | - 'new_plugin', |
|
230 | - 'edit_plugin', |
|
231 | - 'save_plugin', |
|
232 | - 'delete_plugin', |
|
233 | - 'new_module', |
|
234 | - 'edit_module', |
|
235 | - 'save_module', |
|
236 | - 'delete_module', |
|
237 | - 'exec_module', |
|
238 | - 'view_eventlog', |
|
239 | - 'delete_eventlog', |
|
240 | - 'new_web_user', |
|
241 | - 'edit_web_user', |
|
242 | - 'save_web_user', |
|
243 | - 'delete_web_user', |
|
244 | - 'web_access_permissions', |
|
245 | - 'view_unpublished', |
|
246 | - 'import_static', |
|
247 | - 'export_static', |
|
248 | - 'remove_locks', |
|
249 | - 'display_locks', |
|
250 | - 'change_resourcetype' |
|
251 | - ]; |
|
177 | + protected $fillable = [ |
|
178 | + 'name', |
|
179 | + 'description', |
|
180 | + 'frames', |
|
181 | + 'home', |
|
182 | + 'view_document', |
|
183 | + 'new_document', |
|
184 | + 'save_document', |
|
185 | + 'publish_document', |
|
186 | + 'delete_document', |
|
187 | + 'empty_trash', |
|
188 | + 'action_ok', |
|
189 | + 'logout', |
|
190 | + 'help', |
|
191 | + 'messages', |
|
192 | + 'new_user', |
|
193 | + 'edit_user', |
|
194 | + 'logs', |
|
195 | + 'edit_parser', |
|
196 | + 'save_parser', |
|
197 | + 'edit_template', |
|
198 | + 'settings', |
|
199 | + 'credits', |
|
200 | + 'new_template', |
|
201 | + 'save_template', |
|
202 | + 'delete_template', |
|
203 | + 'edit_snippet', |
|
204 | + 'new_snippet', |
|
205 | + 'save_snippet', |
|
206 | + 'delete_snippet', |
|
207 | + 'edit_chunk', |
|
208 | + 'new_chunk', |
|
209 | + 'save_chunk', |
|
210 | + 'delete_chunk', |
|
211 | + 'empty_cache', |
|
212 | + 'edit_document', |
|
213 | + 'change_password', |
|
214 | + 'error_dialog', |
|
215 | + 'about', |
|
216 | + 'category_manager', |
|
217 | + 'file_manager', |
|
218 | + 'assets_files', |
|
219 | + 'assets_images', |
|
220 | + 'save_user', |
|
221 | + 'delete_user', |
|
222 | + 'save_password', |
|
223 | + 'edit_role', |
|
224 | + 'save_role', |
|
225 | + 'delete_role', |
|
226 | + 'new_role', |
|
227 | + 'access_permissions', |
|
228 | + 'bk_manager', |
|
229 | + 'new_plugin', |
|
230 | + 'edit_plugin', |
|
231 | + 'save_plugin', |
|
232 | + 'delete_plugin', |
|
233 | + 'new_module', |
|
234 | + 'edit_module', |
|
235 | + 'save_module', |
|
236 | + 'delete_module', |
|
237 | + 'exec_module', |
|
238 | + 'view_eventlog', |
|
239 | + 'delete_eventlog', |
|
240 | + 'new_web_user', |
|
241 | + 'edit_web_user', |
|
242 | + 'save_web_user', |
|
243 | + 'delete_web_user', |
|
244 | + 'web_access_permissions', |
|
245 | + 'view_unpublished', |
|
246 | + 'import_static', |
|
247 | + 'export_static', |
|
248 | + 'remove_locks', |
|
249 | + 'display_locks', |
|
250 | + 'change_resourcetype' |
|
251 | + ]; |
|
252 | 252 | |
253 | 253 | protected $managerActionsMap = [ |
254 | 254 | 'actions.new' => 38, |
@@ -267,7 +267,7 @@ |
||
267 | 267 | return array_key_exists($this->getKey(), self::getLockedElements()); |
268 | 268 | } |
269 | 269 | |
270 | - public function getAlreadyEditInfoAttribute() :? array |
|
270 | + public function getAlreadyEditInfoAttribute() : ? array |
|
271 | 271 | { |
272 | 272 | return $this->isAlreadyEdit ? self::getLockedElements()[$this->getKey()] : null; |
273 | 273 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Models; |
2 | 2 | |
3 | -use Illuminate\Database\Eloquent; |
|
4 | 3 | use EvolutionCMS\Traits; |
4 | +use Illuminate\Database\Eloquent; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EvolutionCMS\Models\WebUser |
@@ -17,17 +17,17 @@ |
||
17 | 17 | { |
18 | 18 | use Traits\Models\ManagerActions; |
19 | 19 | |
20 | - public $timestamps = false; |
|
20 | + public $timestamps = false; |
|
21 | 21 | |
22 | - protected $hidden = [ |
|
23 | - 'password' |
|
24 | - ]; |
|
22 | + protected $hidden = [ |
|
23 | + 'password' |
|
24 | + ]; |
|
25 | 25 | |
26 | - protected $fillable = [ |
|
27 | - 'username', |
|
28 | - 'password', |
|
29 | - 'cachepwd' |
|
30 | - ]; |
|
26 | + protected $fillable = [ |
|
27 | + 'username', |
|
28 | + 'password', |
|
29 | + 'cachepwd' |
|
30 | + ]; |
|
31 | 31 | |
32 | 32 | public function attributes() |
33 | 33 | { |
@@ -31,17 +31,17 @@ |
||
31 | 31 | |
32 | 32 | public function attributes() |
33 | 33 | { |
34 | - return $this->hasOne(WebUserAttribute::class,'internalKey','id'); |
|
34 | + return $this->hasOne(WebUserAttribute::class, 'internalKey', 'id'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function memberGroups() |
38 | 38 | { |
39 | - return $this->hasMany(WebGroup::class,'webuser','id'); |
|
39 | + return $this->hasMany(WebGroup::class, 'webuser', 'id'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function settings() |
43 | 43 | { |
44 | - return $this->hasMany(WebUserSetting::class,'webuser','id'); |
|
44 | + return $this->hasMany(WebUserSetting::class, 'webuser', 'id'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function delete() |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Models; |
2 | 2 | |
3 | -use Illuminate\Database\Eloquent; |
|
4 | 3 | use EvolutionCMS\Traits; |
4 | +use Illuminate\Database\Eloquent; |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EvolutionCMS\Models\WebUserAttribute |
@@ -46,52 +46,52 @@ |
||
46 | 46 | { |
47 | 47 | use Traits\Models\TimeMutator; |
48 | 48 | |
49 | - const CREATED_AT = 'createdon'; |
|
50 | - const UPDATED_AT = 'editedon'; |
|
49 | + const CREATED_AT = 'createdon'; |
|
50 | + const UPDATED_AT = 'editedon'; |
|
51 | 51 | protected $dateFormat = 'U'; |
52 | 52 | |
53 | - protected $casts = [ |
|
54 | - 'internalKey' => 'int', |
|
55 | - 'role' => 'int', |
|
56 | - 'blocked' => 'int', |
|
57 | - 'blockeduntil' => 'int', |
|
58 | - 'blockedafter' => 'int', |
|
59 | - 'logincount' => 'int', |
|
60 | - 'lastlogin' => 'int', |
|
61 | - 'thislogin' => 'int', |
|
62 | - 'failedlogincount' => 'int', |
|
63 | - 'dob' => 'int', |
|
64 | - 'gender' => 'int', |
|
65 | - 'createdon' => 'int', |
|
66 | - 'editedon' => 'int' |
|
67 | - ]; |
|
53 | + protected $casts = [ |
|
54 | + 'internalKey' => 'int', |
|
55 | + 'role' => 'int', |
|
56 | + 'blocked' => 'int', |
|
57 | + 'blockeduntil' => 'int', |
|
58 | + 'blockedafter' => 'int', |
|
59 | + 'logincount' => 'int', |
|
60 | + 'lastlogin' => 'int', |
|
61 | + 'thislogin' => 'int', |
|
62 | + 'failedlogincount' => 'int', |
|
63 | + 'dob' => 'int', |
|
64 | + 'gender' => 'int', |
|
65 | + 'createdon' => 'int', |
|
66 | + 'editedon' => 'int' |
|
67 | + ]; |
|
68 | 68 | |
69 | - protected $fillable = [ |
|
70 | - 'internalKey', |
|
71 | - 'fullname', |
|
72 | - 'role', |
|
73 | - 'email', |
|
74 | - 'phone', |
|
75 | - 'mobilephone', |
|
76 | - 'blocked', |
|
77 | - 'blockeduntil', |
|
78 | - 'blockedafter', |
|
79 | - 'logincount', |
|
80 | - 'lastlogin', |
|
81 | - 'thislogin', |
|
82 | - 'failedlogincount', |
|
83 | - 'sessionid', |
|
84 | - 'dob', |
|
85 | - 'gender', |
|
86 | - 'country', |
|
87 | - 'street', |
|
88 | - 'city', |
|
89 | - 'state', |
|
90 | - 'zip', |
|
91 | - 'fax', |
|
92 | - 'photo', |
|
93 | - 'comment' |
|
94 | - ]; |
|
69 | + protected $fillable = [ |
|
70 | + 'internalKey', |
|
71 | + 'fullname', |
|
72 | + 'role', |
|
73 | + 'email', |
|
74 | + 'phone', |
|
75 | + 'mobilephone', |
|
76 | + 'blocked', |
|
77 | + 'blockeduntil', |
|
78 | + 'blockedafter', |
|
79 | + 'logincount', |
|
80 | + 'lastlogin', |
|
81 | + 'thislogin', |
|
82 | + 'failedlogincount', |
|
83 | + 'sessionid', |
|
84 | + 'dob', |
|
85 | + 'gender', |
|
86 | + 'country', |
|
87 | + 'street', |
|
88 | + 'city', |
|
89 | + 'state', |
|
90 | + 'zip', |
|
91 | + 'fax', |
|
92 | + 'photo', |
|
93 | + 'comment' |
|
94 | + ]; |
|
95 | 95 | |
96 | 96 | public function getCreatedAtAttribute() |
97 | 97 | { |
@@ -105,6 +105,6 @@ |
||
105 | 105 | |
106 | 106 | public function user() |
107 | 107 | { |
108 | - return $this->belongsTo(WebUser::class,'internalKey','id'); |
|
108 | + return $this->belongsTo(WebUser::class, 'internalKey', 'id'); |
|
109 | 109 | } |
110 | 110 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @param string $name |
383 | 383 | * @param string $tpl |
384 | - * @return null |
|
384 | + * @return string |
|
385 | 385 | */ |
386 | 386 | protected function getTwig($name, $tpl) |
387 | 387 | { |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | /** |
449 | 449 | * @param $out |
450 | 450 | * @param Core|null $modx |
451 | - * @return mixed|string |
|
451 | + * @return string |
|
452 | 452 | */ |
453 | 453 | public function parseDocumentSource($out, $modx = null) |
454 | 454 | { |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | ) && isset($tmp[2], $tmp[3])) ? $tmp[2] : false; |
165 | 165 | $subTmp = (isset($tmp[3])) ? trim($tmp[3]) : null; |
166 | 166 | if ($this->twigEnabled) { |
167 | - $mode = '@' . substr($mode, 3); |
|
167 | + $mode = '@'.substr($mode, 3); |
|
168 | 168 | } |
169 | 169 | switch ($mode) { |
170 | 170 | case '@FILE': |
171 | 171 | if ($subTmp != '') { |
172 | - $real = realpath(MODX_BASE_PATH . $this->templatePath); |
|
173 | - $path = realpath(MODX_BASE_PATH . $this->templatePath . preg_replace(array( |
|
172 | + $real = realpath(MODX_BASE_PATH.$this->templatePath); |
|
173 | + $path = realpath(MODX_BASE_PATH.$this->templatePath.preg_replace(array( |
|
174 | 174 | '/\.*[\/|\\\]/i', |
175 | 175 | '/[\/|\\\]+/i' |
176 | - ), array('/', '/'), $subTmp) . '.' . $this->templateExtension); |
|
176 | + ), array('/', '/'), $subTmp).'.'.$this->templateExtension); |
|
177 | 177 | $fname = explode(".", $path); |
178 | 178 | if ($real == substr( |
179 | 179 | $path, |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | case '@DOCUMENT': |
199 | 199 | case '@DOC': |
200 | 200 | switch (true) { |
201 | - case ((int)$subTmp > 0): |
|
202 | - $tpl = $this->modx->getPageInfo((int)$subTmp, 0, "content"); |
|
201 | + case ((int) $subTmp > 0): |
|
202 | + $tpl = $this->modx->getPageInfo((int) $subTmp, 0, "content"); |
|
203 | 203 | $tpl = isset($tpl['content']) ? $tpl['content'] : ''; |
204 | 204 | break; |
205 | - case ((int)$subTmp == 0): |
|
205 | + case ((int) $subTmp == 0): |
|
206 | 206 | $tpl = $this->modx->documentObject['content']; |
207 | 207 | break; |
208 | 208 | } |
@@ -264,14 +264,14 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function renderDoc($id, $events = false, $tpl = null) |
266 | 266 | { |
267 | - $id = (int)$id; |
|
267 | + $id = (int) $id; |
|
268 | 268 | if ($id <= 0) { |
269 | 269 | return ''; |
270 | 270 | } |
271 | 271 | |
272 | 272 | $m = clone $this->modx; //Чтобы была возможность вызывать события |
273 | 273 | $m->documentIdentifier = $id; |
274 | - $m->documentObject = $m->getDocumentObject('id', (int)$id, $events ? 'prepareResponse' : null); |
|
274 | + $m->documentObject = $m->getDocumentObject('id', (int) $id, $events ? 'prepareResponse' : null); |
|
275 | 275 | if ($m->documentObject['type'] == "reference") { |
276 | 276 | if (is_numeric($m->documentObject['content']) && $m->documentObject['content'] > 0) { |
277 | 277 | $m->documentObject['content'] = $this->renderDoc($m->documentObject['content'], $events); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | public function getTemplate($id) |
307 | 307 | { |
308 | 308 | $tpl = null; |
309 | - $id = (int)$id; |
|
309 | + $id = (int) $id; |
|
310 | 310 | if ($id > 0) { |
311 | 311 | $tpl = $this->modx->getDatabase()->getValue("SELECT `content` FROM {$this->modx->getDatabase()->getFullTableName("site_templates")} WHERE `id` = {$id}"); |
312 | 312 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | public function setPHxPlaceholders($value = '', $key = '', $path = '') |
367 | 367 | { |
368 | - $keypath = !empty($path) ? $path . "." . $key : $key; |
|
368 | + $keypath = !empty($path) ? $path.".".$key : $key; |
|
369 | 369 | $this->phx->curPass = 0; |
370 | 370 | if (is_array($value)) { |
371 | 371 | foreach ($value as $subkey => $subval) { |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | public function createPHx($debug = 0, $maxpass = 50) |
426 | 426 | { |
427 | 427 | if (!class_exists('DLphx')) { |
428 | - include_once(__DIR__ . '/DLphx.class.php'); |
|
428 | + include_once(__DIR__.'/DLphx.class.php'); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | return new DLphx($this->modx, $debug, $maxpass); |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | /** |
4 | 4 | */ |
5 | -class Parser |
|
6 | -{ |
|
5 | +class Parser |
|
6 | +{ |
|
7 | 7 | /** |
8 | 8 | * Объект Core - основной класс MODX |
9 | 9 | * @var Core $modx |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return self |
38 | 38 | */ |
39 | - public static function getInstance(Core $modx) |
|
40 | - { |
|
39 | + public static function getInstance(Core $modx) |
|
40 | + { |
|
41 | 41 | |
42 | - if (null === self::$instance) { |
|
42 | + if (null === self::$instance) { |
|
43 | 43 | self::$instance = new self($modx); |
44 | 44 | } |
45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * is not allowed to call from outside: private! |
51 | 51 | * |
52 | 52 | */ |
53 | - private function __construct(Core $modx) |
|
54 | - { |
|
53 | + private function __construct(Core $modx) |
|
54 | + { |
|
55 | 55 | $this->modx = $modx; |
56 | 56 | } |
57 | 57 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - private function __clone() |
|
64 | - { |
|
63 | + private function __clone() |
|
64 | + { |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - private function __wakeup() |
|
73 | - { |
|
72 | + private function __wakeup() |
|
73 | + { |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | * @param $path |
80 | 80 | * @return $this |
81 | 81 | */ |
82 | - public function setTemplatePath($path) |
|
83 | - { |
|
82 | + public function setTemplatePath($path) |
|
83 | + { |
|
84 | 84 | $path = trim($path); |
85 | 85 | $path = preg_replace(array( |
86 | 86 | '/\.*[\/|\\\]/i', |
87 | 87 | '/[\/|\\\]+/i' |
88 | 88 | ), array('/', '/'), $path); |
89 | 89 | |
90 | - if (!empty($path)) { |
|
90 | + if (!empty($path)) { |
|
91 | 91 | $this->templatePath = $path; |
92 | 92 | } |
93 | 93 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | * @param $ext |
101 | 101 | * @return $this |
102 | 102 | */ |
103 | - public function setTemplateExtension($ext) |
|
104 | - { |
|
103 | + public function setTemplateExtension($ext) |
|
104 | + { |
|
105 | 105 | $ext = trim($ext, ". \t\n\r\0\x0B"); |
106 | - if (!empty($ext)) { |
|
106 | + if (!empty($ext)) { |
|
107 | 107 | $this->templateExtension = $ext; |
108 | 108 | } |
109 | 109 | |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param array $data |
117 | 117 | * @return $this |
118 | 118 | */ |
119 | - public function setTwigTemplateVars($data = array()) |
|
120 | - { |
|
121 | - if (is_array($data)) { |
|
119 | + public function setTwigTemplateVars($data = array()) |
|
120 | + { |
|
121 | + if (is_array($data)) { |
|
122 | 122 | $this->twigTemplateVars = $data; |
123 | 123 | } |
124 | 124 | |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | * @param string $prefix префикс для ключей массива |
135 | 135 | * @return string |
136 | 136 | */ |
137 | - public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder', $prefix = '') |
|
138 | - { |
|
137 | + public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder', $prefix = '') |
|
138 | + { |
|
139 | 139 | $out = ''; |
140 | - if ($set != 0) { |
|
140 | + if ($set != 0) { |
|
141 | 141 | $this->modx->toPlaceholder($key, $data, $prefix); |
142 | - } else { |
|
142 | + } else { |
|
143 | 143 | $out = $data; |
144 | 144 | } |
145 | 145 | |
@@ -152,23 +152,23 @@ discard block |
||
152 | 152 | * @param string $name Template: chunk name || @CODE: template || @FILE: file with template |
153 | 153 | * @return string html template with placeholders without data |
154 | 154 | */ |
155 | - public function getChunk($name) |
|
156 | - { |
|
155 | + public function getChunk($name) |
|
156 | + { |
|
157 | 157 | $tpl = ''; |
158 | 158 | $this->twigEnabled = substr($name, 0, 3) == '@T_'; |
159 | - if ($name != '' && !isset($this->modx->chunkCache[$name])) { |
|
159 | + if ($name != '' && !isset($this->modx->chunkCache[$name])) { |
|
160 | 160 | $mode = (preg_match( |
161 | 161 | '/^((@[A-Z_]+)[:]{0,1})(.*)/Asu', |
162 | 162 | trim($name), |
163 | 163 | $tmp |
164 | 164 | ) && isset($tmp[2], $tmp[3])) ? $tmp[2] : false; |
165 | 165 | $subTmp = (isset($tmp[3])) ? trim($tmp[3]) : null; |
166 | - if ($this->twigEnabled) { |
|
166 | + if ($this->twigEnabled) { |
|
167 | 167 | $mode = '@' . substr($mode, 3); |
168 | 168 | } |
169 | - switch ($mode) { |
|
169 | + switch ($mode) { |
|
170 | 170 | case '@FILE': |
171 | - if ($subTmp != '') { |
|
171 | + if ($subTmp != '') { |
|
172 | 172 | $real = realpath(MODX_BASE_PATH . $this->templatePath); |
173 | 173 | $path = realpath(MODX_BASE_PATH . $this->templatePath . preg_replace(array( |
174 | 174 | '/\.*[\/|\\\]/i', |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | 0, |
181 | 181 | strlen($real) |
182 | 182 | ) && end($fname) == $this->templateExtension && file_exists($path) |
183 | - ) { |
|
183 | + ) { |
|
184 | 184 | $tpl = file_get_contents($path); |
185 | 185 | } |
186 | 186 | } |
187 | 187 | break; |
188 | 188 | case '@CHUNK': |
189 | - if ($subTmp != '') { |
|
189 | + if ($subTmp != '') { |
|
190 | 190 | $tpl = $this->modx->getChunk($subTmp); |
191 | 191 | } |
192 | 192 | break; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | break; |
198 | 198 | case '@DOCUMENT': |
199 | 199 | case '@DOC': |
200 | - switch (true) { |
|
200 | + switch (true) { |
|
201 | 201 | case ((int)$subTmp > 0): |
202 | 202 | $tpl = $this->modx->getPageInfo((int)$subTmp, 0, "content"); |
203 | 203 | $tpl = isset($tpl['content']) ? $tpl['content'] : ''; |
@@ -209,19 +209,19 @@ discard block |
||
209 | 209 | break; |
210 | 210 | case '@PLH': |
211 | 211 | case '@PLACEHOLDER': |
212 | - if ($subTmp != '') { |
|
212 | + if ($subTmp != '') { |
|
213 | 213 | $tpl = $this->modx->getPlaceholder($subTmp); |
214 | 214 | } |
215 | 215 | break; |
216 | 216 | case '@CFG': |
217 | 217 | case '@CONFIG': |
218 | 218 | case '@OPTIONS': |
219 | - if ($subTmp != '') { |
|
219 | + if ($subTmp != '') { |
|
220 | 220 | $tpl = $this->modx->getConfig($subTmp); |
221 | 221 | } |
222 | 222 | break; |
223 | 223 | case '@SNIPPET': |
224 | - if ($subTmp != '') { |
|
224 | + if ($subTmp != '') { |
|
225 | 225 | $tpl = $this->modx->runSnippet($subTmp, $this->modx->event->params); |
226 | 226 | } |
227 | 227 | break; |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | $tpl = $this->modx->getChunk($name); |
239 | 239 | } |
240 | 240 | $this->modx->chunkCache[$name] = $tpl; |
241 | - } else { |
|
242 | - if ($name != '') { |
|
241 | + } else { |
|
242 | + if ($name != '') { |
|
243 | 243 | $tpl = $this->modx->getChunk($name); |
244 | 244 | } |
245 | 245 | } |
@@ -262,22 +262,22 @@ discard block |
||
262 | 262 | * - с источиком от куда произошел вызов события |
263 | 263 | * - оригинальный экземпляр класса Core |
264 | 264 | */ |
265 | - public function renderDoc($id, $events = false, $tpl = null) |
|
266 | - { |
|
265 | + public function renderDoc($id, $events = false, $tpl = null) |
|
266 | + { |
|
267 | 267 | $id = (int)$id; |
268 | - if ($id <= 0) { |
|
268 | + if ($id <= 0) { |
|
269 | 269 | return ''; |
270 | 270 | } |
271 | 271 | |
272 | 272 | $m = clone $this->modx; //Чтобы была возможность вызывать события |
273 | 273 | $m->documentIdentifier = $id; |
274 | 274 | $m->documentObject = $m->getDocumentObject('id', (int)$id, $events ? 'prepareResponse' : null); |
275 | - if ($m->documentObject['type'] == "reference") { |
|
276 | - if (is_numeric($m->documentObject['content']) && $m->documentObject['content'] > 0) { |
|
275 | + if ($m->documentObject['type'] == "reference") { |
|
276 | + if (is_numeric($m->documentObject['content']) && $m->documentObject['content'] > 0) { |
|
277 | 277 | $m->documentObject['content'] = $this->renderDoc($m->documentObject['content'], $events); |
278 | 278 | } |
279 | 279 | } |
280 | - switch (true) { |
|
280 | + switch (true) { |
|
281 | 281 | case is_integer($tpl): |
282 | 282 | $tpl = $this->getTemplate($tpl); |
283 | 283 | break; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $tpl = $this->getTemplate($m->documentObject['template']); |
289 | 289 | } |
290 | 290 | $m->documentContent = $tpl; |
291 | - if ($events) { |
|
291 | + if ($events) { |
|
292 | 292 | $m->invokeEvent("OnLoadWebDocument", array( |
293 | 293 | 'source' => 'DLTemplate', |
294 | 294 | 'mainModx' => $this->modx, |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | * @param int $id Номер шаблона |
304 | 304 | * @return string HTML код шаблона |
305 | 305 | */ |
306 | - public function getTemplate($id) |
|
307 | - { |
|
306 | + public function getTemplate($id) |
|
307 | + { |
|
308 | 308 | $tpl = null; |
309 | 309 | $id = (int)$id; |
310 | - if ($id > 0) { |
|
310 | + if ($id > 0) { |
|
311 | 311 | $tpl = $this->modx->getDatabase()->getValue("SELECT `content` FROM {$this->modx->getDatabase()->getFullTableName("site_templates")} WHERE `id` = {$id}"); |
312 | 312 | } |
313 | - if (is_null($tpl)) { |
|
313 | + if (is_null($tpl)) { |
|
314 | 314 | $tpl = '[*content*]'; |
315 | 315 | } |
316 | 316 | |
@@ -325,22 +325,22 @@ discard block |
||
325 | 325 | * @param bool $parseDocumentSource render html template via Core::parseDocumentSource() |
326 | 326 | * @return string html template with data without placeholders |
327 | 327 | */ |
328 | - public function parseChunk($name, $data = array(), $parseDocumentSource = false, $disablePHx = false) |
|
329 | - { |
|
328 | + public function parseChunk($name, $data = array(), $parseDocumentSource = false, $disablePHx = false) |
|
329 | + { |
|
330 | 330 | $out = $this->getChunk($name); |
331 | - if ($this->twigEnabled && ($out != '') && ($twig = $this->getTwig($name, $out))) { |
|
331 | + if ($this->twigEnabled && ($out != '') && ($twig = $this->getTwig($name, $out))) { |
|
332 | 332 | $plh = $this->twigTemplateVars; |
333 | 333 | $plh['data'] = $data; |
334 | 334 | $plh['modx'] = $this->modx; |
335 | 335 | $out = $twig->render(md5($name), $plh); |
336 | - } else { |
|
337 | - if (is_array($data) && ($out != '')) { |
|
338 | - if (preg_match("/\[\+[A-Z0-9\.\_\-]+\+\]/is", $out)) { |
|
336 | + } else { |
|
337 | + if (is_array($data) && ($out != '')) { |
|
338 | + if (preg_match("/\[\+[A-Z0-9\.\_\-]+\+\]/is", $out)) { |
|
339 | 339 | $item = $this->renameKeyArr($data, '[', ']', '+'); |
340 | 340 | $out = str_replace(array_keys($item), array_values($item), $out); |
341 | 341 | } |
342 | - if (!$disablePHx && preg_match("/:([^:=]+)(?:=`(.*?)`(?=:[^:=]+|$))?/is", $out)) { |
|
343 | - if (is_null($this->phx) || !($this->phx instanceof DLphx)) { |
|
342 | + if (!$disablePHx && preg_match("/:([^:=]+)(?:=`(.*?)`(?=:[^:=]+|$))?/is", $out)) { |
|
343 | + if (is_null($this->phx) || !($this->phx instanceof DLphx)) { |
|
344 | 344 | $this->phx = $this->createPHx(0, 1000); |
345 | 345 | } |
346 | 346 | $this->phx->placeholders = array(); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | } |
351 | 351 | } |
352 | 352 | } |
353 | - if ($parseDocumentSource) { |
|
353 | + if ($parseDocumentSource) { |
|
354 | 354 | $out = $this->parseDocumentSource($out); |
355 | 355 | } |
356 | 356 | |
@@ -363,15 +363,15 @@ discard block |
||
363 | 363 | * @param string $key |
364 | 364 | * @param string $path |
365 | 365 | */ |
366 | - public function setPHxPlaceholders($value = '', $key = '', $path = '') |
|
367 | - { |
|
366 | + public function setPHxPlaceholders($value = '', $key = '', $path = '') |
|
367 | + { |
|
368 | 368 | $keypath = !empty($path) ? $path . "." . $key : $key; |
369 | 369 | $this->phx->curPass = 0; |
370 | - if (is_array($value)) { |
|
371 | - foreach ($value as $subkey => $subval) { |
|
370 | + if (is_array($value)) { |
|
371 | + foreach ($value as $subkey => $subval) { |
|
372 | 372 | $this->setPHxPlaceholders($subval, $subkey, $keypath); |
373 | 373 | } |
374 | - } else { |
|
374 | + } else { |
|
375 | 375 | $this->phx->setPHxVariable($keypath, $value); |
376 | 376 | } |
377 | 377 | } |
@@ -383,15 +383,15 @@ discard block |
||
383 | 383 | * @param string $tpl |
384 | 384 | * @return null |
385 | 385 | */ |
386 | - protected function getTwig($name, $tpl) |
|
387 | - { |
|
388 | - if (is_null($this->twig) && isset($this->modx->twig)) { |
|
386 | + protected function getTwig($name, $tpl) |
|
387 | + { |
|
388 | + if (is_null($this->twig) && isset($this->modx->twig)) { |
|
389 | 389 | $twig = clone $this->modx->twig; |
390 | 390 | $this->twig = $twig; |
391 | - } else { |
|
391 | + } else { |
|
392 | 392 | $twig = $this->twig; |
393 | 393 | } |
394 | - if ($twig && class_exists('Twig_Loader_Array')) { |
|
394 | + if ($twig && class_exists('Twig_Loader_Array')) { |
|
395 | 395 | $twig->getLoader()->addLoader( |
396 | 396 | new Twig_Loader_Array(array( |
397 | 397 | md5($name) => $tpl |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | * @param string $string |
408 | 408 | * @return string |
409 | 409 | */ |
410 | - public function cleanPHx($string) |
|
411 | - { |
|
410 | + public function cleanPHx($string) |
|
411 | + { |
|
412 | 412 | preg_match_all('~\[(\+|\*|\()([^:\+\[\]]+)([^\[\]]*?)(\1|\))\]~s', $string, $matches); |
413 | - if ($matches[0]) { |
|
413 | + if ($matches[0]) { |
|
414 | 414 | $string = str_replace($matches[0], '', $string); |
415 | 415 | } |
416 | 416 | |
@@ -422,9 +422,9 @@ discard block |
||
422 | 422 | * @param int $maxpass |
423 | 423 | * @return DLphx |
424 | 424 | */ |
425 | - public function createPHx($debug = 0, $maxpass = 50) |
|
426 | - { |
|
427 | - if (!class_exists('DLphx')) { |
|
425 | + public function createPHx($debug = 0, $maxpass = 50) |
|
426 | + { |
|
427 | + if (!class_exists('DLphx')) { |
|
428 | 428 | include_once(__DIR__ . '/DLphx.class.php'); |
429 | 429 | } |
430 | 430 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $sep разделитель суффиксов, префиксов и ключей массива |
441 | 441 | * @return array массив с переименованными ключами |
442 | 442 | */ |
443 | - public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.') |
|
444 | - { |
|
443 | + public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.') |
|
444 | + { |
|
445 | 445 | return APIhelpers::renameKeyArr($data, $prefix, $suffix, $sep); |
446 | 446 | } |
447 | 447 | |
@@ -450,23 +450,23 @@ discard block |
||
450 | 450 | * @param Core|null $modx |
451 | 451 | * @return mixed|string |
452 | 452 | */ |
453 | - public function parseDocumentSource($out, $modx = null) |
|
454 | - { |
|
455 | - if (!is_object($modx)) { |
|
453 | + public function parseDocumentSource($out, $modx = null) |
|
454 | + { |
|
455 | + if (!is_object($modx)) { |
|
456 | 456 | $modx = $this->modx; |
457 | 457 | } |
458 | 458 | $minPasses = empty($modx->minParserPasses) ? 2 : $modx->minParserPasses; |
459 | 459 | $maxPasses = empty($modx->maxParserPasses) ? 10 : $modx->maxParserPasses; |
460 | 460 | $site_status = $modx->getConfig('site_status'); |
461 | 461 | $modx->config['site_status'] = 0; |
462 | - for ($i = 1; $i <= $maxPasses; $i++) { |
|
462 | + for ($i = 1; $i <= $maxPasses; $i++) { |
|
463 | 463 | $html = $out; |
464 | - if (preg_match('/\[\!(.*)\!\]/us', $out)) { |
|
464 | + if (preg_match('/\[\!(.*)\!\]/us', $out)) { |
|
465 | 465 | $out = str_replace(array('[!', '!]'), array('[[', ']]'), $out); |
466 | 466 | } |
467 | - if ($i <= $minPasses || $out != $html) { |
|
467 | + if ($i <= $minPasses || $out != $html) { |
|
468 | 468 | $out = $modx->parseDocumentSource($out); |
469 | - } else { |
|
469 | + } else { |
|
470 | 470 | break; |
471 | 471 | } |
472 | 472 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php namespace EvolutionCMS; |
2 | 2 | |
3 | 3 | use Exception; |
4 | -use Illuminate\Filesystem\Filesystem; |
|
5 | 4 | use Illuminate\Contracts\Foundation\Application as ApplicationContract; |
5 | +use Illuminate\Filesystem\Filesystem; |
|
6 | 6 | |
7 | 7 | class ProviderRepository |
8 | 8 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | if (count($events) < 1) { |
108 | 108 | return; |
109 | 109 | } |
110 | - $this->app->make('events')->listen($events, function () use ($provider) { |
|
110 | + $this->app->make('events')->listen($events, function() use ($provider) { |
|
111 | 111 | $this->app->register($provider); |
112 | 112 | }); |
113 | 113 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function writeManifest($manifest) |
165 | 165 | { |
166 | - if (! is_writable(dirname($this->manifestPath))) { |
|
166 | + if (!is_writable(dirname($this->manifestPath))) { |
|
167 | 167 | throw new Exception('The bootstrap/cache directory must be present and writable.'); |
168 | 168 | } |
169 | 169 | $this->files->put( |
@@ -107,7 +107,7 @@ |
||
107 | 107 | if (count($events) < 1) { |
108 | 108 | return; |
109 | 109 | } |
110 | - $this->app->make('events')->listen($events, function () use ($provider) { |
|
110 | + $this->app->make('events')->listen($events, function () use ($provider){ |
|
111 | 111 | $this->app->register($provider); |
112 | 112 | }); |
113 | 113 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | /** |
47 | 47 | * Get the services provided by the provider. |
48 | 48 | * |
49 | - * @return array |
|
49 | + * @return string[] |
|
50 | 50 | */ |
51 | 51 | public function provides() |
52 | 52 | { |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php namespace EvolutionCMS\Providers; |
2 | 2 | |
3 | -use EvolutionCMS\ServiceProvider; |
|
4 | 3 | use EvolutionCMS\ManagerTheme; |
4 | +use EvolutionCMS\ServiceProvider; |
|
5 | 5 | |
6 | 6 | class ManagerThemeServiceProvider extends ServiceProvider |
7 | 7 | { |
@@ -23,22 +23,22 @@ |
||
23 | 23 | { |
24 | 24 | $theme = $this->app->getConfig('manager_theme', 'default'); |
25 | 25 | |
26 | - $this->app->singleton('ManagerTheme', function ($app) use ($theme) { |
|
26 | + $this->app->singleton('ManagerTheme', function($app) use ($theme) { |
|
27 | 27 | return new ManagerTheme($app, $theme); |
28 | 28 | }); |
29 | 29 | |
30 | 30 | $this->loadViewsFrom([ |
31 | - MODX_MANAGER_PATH . 'media/style/' . $theme . '/views/', |
|
32 | - MODX_MANAGER_PATH . '/views/' |
|
31 | + MODX_MANAGER_PATH.'media/style/'.$theme.'/views/', |
|
32 | + MODX_MANAGER_PATH.'/views/' |
|
33 | 33 | ], $this->namespace); |
34 | 34 | |
35 | 35 | $this->loadSnippetsFrom( |
36 | - MODX_MANAGER_PATH . 'media/style/' . $theme . '/snippets/', |
|
36 | + MODX_MANAGER_PATH.'media/style/'.$theme.'/snippets/', |
|
37 | 37 | $this->namespace |
38 | 38 | ); |
39 | 39 | |
40 | 40 | $this->loadChunksFrom( |
41 | - MODX_MANAGER_PATH . 'media/style/' . $theme . '/chunks/', |
|
41 | + MODX_MANAGER_PATH.'media/style/'.$theme.'/chunks/', |
|
42 | 42 | $this->namespace |
43 | 43 | ); |
44 | 44 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | { |
24 | 24 | $theme = $this->app->getConfig('manager_theme', 'default'); |
25 | 25 | |
26 | - $this->app->singleton('ManagerTheme', function ($app) use ($theme) { |
|
26 | + $this->app->singleton('ManagerTheme', function ($app) use ($theme){ |
|
27 | 27 | return new ManagerTheme($app, $theme); |
28 | 28 | }); |
29 | 29 |
@@ -75,6 +75,10 @@ discard block |
||
75 | 75 | |
76 | 76 | public static $dataGridCnt; |
77 | 77 | |
78 | + /** |
|
79 | + * @param null|string $id |
|
80 | + * @param string $ds |
|
81 | + */ |
|
78 | 82 | public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
79 | 83 | // set id |
80 | 84 | self::$dataGridCnt++; |
@@ -207,6 +211,9 @@ discard block |
||
207 | 211 | |
208 | 212 | // format column values |
209 | 213 | |
214 | + /** |
|
215 | + * @param integer $n |
|
216 | + */ |
|
210 | 217 | public function RenderRowFnc($n, $row) { |
211 | 218 | if($this->_alt == 0) { |
212 | 219 | $Style = $this->_itemStyle; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | class DataGrid implements DataGridInterface{ |
15 | 15 | |
16 | - public $ds; // datasource |
|
16 | + public $ds; // datasource |
|
17 | 17 | public $id; |
18 | 18 | public $pageSize; // pager settings |
19 | 19 | public $pageNumber; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public $colWraps; |
38 | 38 | public $colColors; |
39 | 39 | public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
40 | - // data type: integer,float,currency,date |
|
40 | + // data type: integer,float,currency,date |
|
41 | 41 | |
42 | 42 | public $header; |
43 | 43 | public $footer; |
@@ -76,236 +76,236 @@ discard block |
||
76 | 76 | public static $dataGridCnt; |
77 | 77 | |
78 | 78 | public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
79 | - // set id |
|
80 | - self::$dataGridCnt++; |
|
81 | - $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
|
79 | + // set id |
|
80 | + self::$dataGridCnt++; |
|
81 | + $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
|
82 | 82 | |
83 | - // set datasource |
|
84 | - $this->ds = $ds; |
|
83 | + // set datasource |
|
84 | + $this->ds = $ds; |
|
85 | 85 | |
86 | - // set pager |
|
87 | - $this->pageSize = $pageSize; |
|
88 | - $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
89 | - $this->pagerLocation = 'top-right'; |
|
90 | - } |
|
86 | + // set pager |
|
87 | + $this->pageSize = $pageSize; |
|
88 | + $this->pageNumber = $pageNumber; // by setting pager to -1 will cause pager to load it's last page number |
|
89 | + $this->pagerLocation = 'top-right'; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | public function setDataSource($ds) { |
93 | - $this->ds = $ds; |
|
94 | - } |
|
93 | + $this->ds = $ds; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | public function render() { |
97 | 97 | $modx = evolutionCMS(); |
98 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
99 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
100 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
101 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
102 | - |
|
103 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
104 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
105 | - |
|
106 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
107 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
108 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
109 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
110 | - |
|
111 | - $this->_alt = 0; |
|
112 | - $this->_total = 0; |
|
113 | - |
|
114 | - $this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array |
|
115 | - |
|
116 | - if(!$cssStyle && !$cssClass) { |
|
117 | - $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
118 | - } |
|
119 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
120 | - $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
121 | - } |
|
122 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
123 | - $this->_itemStyle = "style='color:black;'"; |
|
124 | - } |
|
125 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
126 | - $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
127 | - } |
|
128 | - |
|
129 | - if($this->_isDataset && !$this->columns) { |
|
130 | - $cols = $modx->getDatabase()->numFields($this->ds); |
|
131 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
132 | - } |
|
133 | - |
|
134 | - // start grid |
|
135 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
136 | - $tblEnd = "</table>"; |
|
137 | - |
|
138 | - // build column header |
|
139 | - $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
140 | - $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
141 | - $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
142 | - $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
143 | - $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
144 | - $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
145 | - $this->_colcount = count($this->_colnames); |
|
146 | - if(!$this->_isDataset) { |
|
147 | - $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
148 | - $this->ds = array_chunk($this->ds, $this->_colcount); |
|
149 | - } |
|
150 | - $tblColHdr = "<thead><tr>"; |
|
151 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
152 | - $name = $this->_colnames[$c]; |
|
153 | - $width = $this->_colwidths[$c]; |
|
154 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
155 | - } |
|
156 | - $tblColHdr .= "</tr></thead>\n"; |
|
157 | - |
|
158 | - // build rows |
|
159 | - $rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
160 | - $this->_fieldnames = explode(",", $this->fields); |
|
161 | - if($rowcount == 0) { |
|
162 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
163 | - } else { |
|
164 | - // render grid items |
|
165 | - if($this->pageSize <= 0) { |
|
166 | - for($r = 0; $r < $rowcount; $r++) { |
|
167 | - $row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r]; |
|
168 | - $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
169 | - } |
|
170 | - } else { |
|
171 | - if(!$this->pager) { |
|
172 | - $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
173 | - $this->pager->setRenderRowFnc($this); // pass this object |
|
174 | - $this->pager->cssStyle = $pagerStyle; |
|
175 | - $this->pager->cssClass = $pagerClass; |
|
176 | - } else { |
|
177 | - $this->pager->pageSize = $this->pageSize; |
|
178 | - $this->pager->pageNumber = $this->pageNumber; |
|
179 | - } |
|
180 | - |
|
181 | - $this->pager->render(); |
|
182 | - $tblRows = $this->pager->getRenderedRows(); |
|
183 | - $tblPager = $this->pager->getRenderedPager(); |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - // setup header,pager and footer |
|
188 | - $o = $tblStart; |
|
189 | - $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
190 | - $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
191 | - if($this->header) { |
|
192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
193 | - } |
|
194 | - if($tblPager && $ptop) { |
|
195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
196 | - } |
|
197 | - $o .= $tblColHdr . $tblRows; |
|
198 | - if($tblPager && $pbot) { |
|
199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
200 | - } |
|
201 | - if($this->footer) { |
|
202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
203 | - } |
|
204 | - $o .= $tblEnd; |
|
205 | - return $o; |
|
206 | - } |
|
207 | - |
|
208 | - // format column values |
|
98 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
99 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
100 | + $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
101 | + $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
102 | + |
|
103 | + $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
104 | + $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
105 | + |
|
106 | + $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
107 | + $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
108 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
109 | + $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
110 | + |
|
111 | + $this->_alt = 0; |
|
112 | + $this->_total = 0; |
|
113 | + |
|
114 | + $this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array |
|
115 | + |
|
116 | + if(!$cssStyle && !$cssClass) { |
|
117 | + $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
|
118 | + } |
|
119 | + if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
120 | + $columnHeaderStyle = "style='color:black;background-color:silver'"; |
|
121 | + } |
|
122 | + if(!$this->_itemStyle && !$this->_itemClass) { |
|
123 | + $this->_itemStyle = "style='color:black;'"; |
|
124 | + } |
|
125 | + if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
126 | + $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
|
127 | + } |
|
128 | + |
|
129 | + if($this->_isDataset && !$this->columns) { |
|
130 | + $cols = $modx->getDatabase()->numFields($this->ds); |
|
131 | + for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
132 | + } |
|
133 | + |
|
134 | + // start grid |
|
135 | + $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
136 | + $tblEnd = "</table>"; |
|
137 | + |
|
138 | + // build column header |
|
139 | + $this->_colnames = explode((strstr($this->columns, "||") !== false ? "||" : ","), $this->columns); |
|
140 | + $this->_colwidths = explode((strstr($this->colWidths, "||") !== false ? "||" : ","), $this->colWidths); |
|
141 | + $this->_colaligns = explode((strstr($this->colAligns, "||") !== false ? "||" : ","), $this->colAligns); |
|
142 | + $this->_colwraps = explode((strstr($this->colWraps, "||") !== false ? "||" : ","), $this->colWraps); |
|
143 | + $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
|
144 | + $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
|
145 | + $this->_colcount = count($this->_colnames); |
|
146 | + if(!$this->_isDataset) { |
|
147 | + $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
|
148 | + $this->ds = array_chunk($this->ds, $this->_colcount); |
|
149 | + } |
|
150 | + $tblColHdr = "<thead><tr>"; |
|
151 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
152 | + $name = $this->_colnames[$c]; |
|
153 | + $width = $this->_colwidths[$c]; |
|
154 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
155 | + } |
|
156 | + $tblColHdr .= "</tr></thead>\n"; |
|
157 | + |
|
158 | + // build rows |
|
159 | + $rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
160 | + $this->_fieldnames = explode(",", $this->fields); |
|
161 | + if($rowcount == 0) { |
|
162 | + $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
163 | + } else { |
|
164 | + // render grid items |
|
165 | + if($this->pageSize <= 0) { |
|
166 | + for($r = 0; $r < $rowcount; $r++) { |
|
167 | + $row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r]; |
|
168 | + $tblRows .= $this->RenderRowFnc($r + 1, $row); |
|
169 | + } |
|
170 | + } else { |
|
171 | + if(!$this->pager) { |
|
172 | + $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
|
173 | + $this->pager->setRenderRowFnc($this); // pass this object |
|
174 | + $this->pager->cssStyle = $pagerStyle; |
|
175 | + $this->pager->cssClass = $pagerClass; |
|
176 | + } else { |
|
177 | + $this->pager->pageSize = $this->pageSize; |
|
178 | + $this->pager->pageNumber = $this->pageNumber; |
|
179 | + } |
|
180 | + |
|
181 | + $this->pager->render(); |
|
182 | + $tblRows = $this->pager->getRenderedRows(); |
|
183 | + $tblPager = $this->pager->getRenderedPager(); |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + // setup header,pager and footer |
|
188 | + $o = $tblStart; |
|
189 | + $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
190 | + $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
|
191 | + if($this->header) { |
|
192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
193 | + } |
|
194 | + if($tblPager && $ptop) { |
|
195 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
196 | + } |
|
197 | + $o .= $tblColHdr . $tblRows; |
|
198 | + if($tblPager && $pbot) { |
|
199 | + $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
200 | + } |
|
201 | + if($this->footer) { |
|
202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
203 | + } |
|
204 | + $o .= $tblEnd; |
|
205 | + return $o; |
|
206 | + } |
|
207 | + |
|
208 | + // format column values |
|
209 | 209 | |
210 | 210 | public function RenderRowFnc($n, $row) { |
211 | - if($this->_alt == 0) { |
|
212 | - $Style = $this->_itemStyle; |
|
213 | - $Class = $this->_itemClass; |
|
214 | - $this->_alt = 1; |
|
215 | - } else { |
|
216 | - $Style = $this->_altItemStyle; |
|
217 | - $Class = $this->_altItemClass; |
|
218 | - $this->_alt = 0; |
|
219 | - } |
|
220 | - $o = "<tr>"; |
|
221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
222 | - $colStyle = $Style; |
|
223 | - $fld = trim($this->_fieldnames[$c]); |
|
224 | - $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
225 | - $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
226 | - $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
227 | - $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
228 | - $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
229 | - $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
230 | - if($color && $Style) { |
|
231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
232 | - } |
|
233 | - $value = $this->formatColumnValue($row, $value, $type, $align); |
|
234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
235 | - } |
|
236 | - $o .= "</tr>\n"; |
|
237 | - return $o; |
|
238 | - } |
|
211 | + if($this->_alt == 0) { |
|
212 | + $Style = $this->_itemStyle; |
|
213 | + $Class = $this->_itemClass; |
|
214 | + $this->_alt = 1; |
|
215 | + } else { |
|
216 | + $Style = $this->_altItemStyle; |
|
217 | + $Class = $this->_altItemClass; |
|
218 | + $this->_alt = 0; |
|
219 | + } |
|
220 | + $o = "<tr>"; |
|
221 | + for($c = 0; $c < $this->_colcount; $c++) { |
|
222 | + $colStyle = $Style; |
|
223 | + $fld = trim($this->_fieldnames[$c]); |
|
224 | + $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
|
225 | + $align = isset($this->_colaligns[$c]) ? $this->_colaligns[$c] : null; |
|
226 | + $color = isset($this->_colcolors[$c]) ? $this->_colcolors[$c] : null; |
|
227 | + $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
|
228 | + $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
|
229 | + $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
|
230 | + if($color && $Style) { |
|
231 | + $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
232 | + } |
|
233 | + $value = $this->formatColumnValue($row, $value, $type, $align); |
|
234 | + $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
235 | + } |
|
236 | + $o .= "</tr>\n"; |
|
237 | + return $o; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | public function formatColumnValue($row, $value, $type, &$align) { |
241 | - if(strpos($type, ":") !== false) { |
|
242 | - list($type, $type_format) = explode(":", $type, 2); |
|
243 | - } |
|
244 | - switch(strtolower($type)) { |
|
245 | - case "integer": |
|
246 | - if($align == "") { |
|
247 | - $align = "right"; |
|
248 | - } |
|
249 | - $value = number_format($value); |
|
250 | - break; |
|
251 | - |
|
252 | - case "float": |
|
253 | - if($align == "") { |
|
254 | - $align = "right"; |
|
255 | - } |
|
256 | - if(!$type_format) { |
|
257 | - $type_format = 2; |
|
258 | - } |
|
259 | - $value = number_format($value, $type_format); |
|
260 | - break; |
|
261 | - |
|
262 | - case "currency": |
|
263 | - if($align == "") { |
|
264 | - $align = "right"; |
|
265 | - } |
|
266 | - if(!$type_format) { |
|
267 | - $type_format = 2; |
|
268 | - } |
|
269 | - $value = "$" . number_format($value, $type_format); |
|
270 | - break; |
|
271 | - |
|
272 | - case "date": |
|
273 | - if($align == "") { |
|
274 | - $align = "right"; |
|
275 | - } |
|
276 | - if(!is_numeric($value)) { |
|
277 | - $value = strtotime($value); |
|
278 | - } |
|
279 | - if(!$type_format) { |
|
280 | - $type_format = "%A %d, %B %Y"; |
|
281 | - } |
|
282 | - $value = strftime($type_format, $value); |
|
283 | - break; |
|
284 | - |
|
285 | - case "boolean": |
|
286 | - if($align == '') { |
|
287 | - $align = "center"; |
|
288 | - } |
|
289 | - $value = number_format($value); |
|
290 | - if($value) { |
|
291 | - $value = '•'; |
|
292 | - } else { |
|
293 | - $value = ' '; |
|
294 | - } |
|
295 | - break; |
|
296 | - |
|
297 | - case "template": |
|
298 | - // replace [+value+] first |
|
299 | - $value = str_replace("[+value+]", $value, $type_format); |
|
300 | - // replace other [+fields+] |
|
301 | - if(strpos($value, "[+") !== false) { |
|
302 | - foreach($row as $k => $v) { |
|
303 | - $value = str_replace("[+$k+]", $v, $value); |
|
304 | - } |
|
305 | - } |
|
306 | - break; |
|
307 | - |
|
308 | - } |
|
309 | - return $value; |
|
310 | - } |
|
241 | + if(strpos($type, ":") !== false) { |
|
242 | + list($type, $type_format) = explode(":", $type, 2); |
|
243 | + } |
|
244 | + switch(strtolower($type)) { |
|
245 | + case "integer": |
|
246 | + if($align == "") { |
|
247 | + $align = "right"; |
|
248 | + } |
|
249 | + $value = number_format($value); |
|
250 | + break; |
|
251 | + |
|
252 | + case "float": |
|
253 | + if($align == "") { |
|
254 | + $align = "right"; |
|
255 | + } |
|
256 | + if(!$type_format) { |
|
257 | + $type_format = 2; |
|
258 | + } |
|
259 | + $value = number_format($value, $type_format); |
|
260 | + break; |
|
261 | + |
|
262 | + case "currency": |
|
263 | + if($align == "") { |
|
264 | + $align = "right"; |
|
265 | + } |
|
266 | + if(!$type_format) { |
|
267 | + $type_format = 2; |
|
268 | + } |
|
269 | + $value = "$" . number_format($value, $type_format); |
|
270 | + break; |
|
271 | + |
|
272 | + case "date": |
|
273 | + if($align == "") { |
|
274 | + $align = "right"; |
|
275 | + } |
|
276 | + if(!is_numeric($value)) { |
|
277 | + $value = strtotime($value); |
|
278 | + } |
|
279 | + if(!$type_format) { |
|
280 | + $type_format = "%A %d, %B %Y"; |
|
281 | + } |
|
282 | + $value = strftime($type_format, $value); |
|
283 | + break; |
|
284 | + |
|
285 | + case "boolean": |
|
286 | + if($align == '') { |
|
287 | + $align = "center"; |
|
288 | + } |
|
289 | + $value = number_format($value); |
|
290 | + if($value) { |
|
291 | + $value = '•'; |
|
292 | + } else { |
|
293 | + $value = ' '; |
|
294 | + } |
|
295 | + break; |
|
296 | + |
|
297 | + case "template": |
|
298 | + // replace [+value+] first |
|
299 | + $value = str_replace("[+value+]", $value, $type_format); |
|
300 | + // replace other [+fields+] |
|
301 | + if(strpos($value, "[+") !== false) { |
|
302 | + foreach($row as $k => $v) { |
|
303 | + $value = str_replace("[+$k+]", $v, $value); |
|
304 | + } |
|
305 | + } |
|
306 | + break; |
|
307 | + |
|
308 | + } |
|
309 | + return $value; |
|
310 | + } |
|
311 | 311 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | |
16 | 16 | public $ds; // datasource |
17 | 17 | public $id; |
18 | - public $pageSize; // pager settings |
|
18 | + public $pageSize; // pager settings |
|
19 | 19 | public $pageNumber; |
20 | 20 | public $pager; |
21 | - public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
21 | + public $pagerLocation; // top-right, top-left, bottom-left, bottom-right, both-left, both-right |
|
22 | 22 | |
23 | 23 | public $cssStyle; |
24 | 24 | public $cssClass; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public $colAligns; |
37 | 37 | public $colWraps; |
38 | 38 | public $colColors; |
39 | - public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
39 | + public $colTypes; // coltype1, coltype2, etc or coltype1:format1, e.g. date:%Y %m |
|
40 | 40 | // data type: integer,float,currency,date |
41 | 41 | |
42 | 42 | public $header; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public $cellPadding; |
45 | 45 | public $cellSpacing; |
46 | 46 | |
47 | - public $rowAlign; // vertical alignment: top, middle, bottom |
|
47 | + public $rowAlign; // vertical alignment: top, middle, bottom |
|
48 | 48 | public $rowIdField; |
49 | 49 | |
50 | 50 | public $pagerStyle; |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | |
76 | 76 | public static $dataGridCnt; |
77 | 77 | |
78 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
78 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1){ |
|
79 | 79 | // set id |
80 | 80 | self::$dataGridCnt++; |
81 | - $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
|
81 | + $this->id = $this->id ? empty($id) : "dg".self::$dataGridCnt; |
|
82 | 82 | |
83 | 83 | // set datasource |
84 | 84 | $this->ds = $ds; |
@@ -89,50 +89,50 @@ discard block |
||
89 | 89 | $this->pagerLocation = 'top-right'; |
90 | 90 | } |
91 | 91 | |
92 | - public function setDataSource($ds) { |
|
92 | + public function setDataSource($ds){ |
|
93 | 93 | $this->ds = $ds; |
94 | 94 | } |
95 | 95 | |
96 | - public function render() { |
|
96 | + public function render(){ |
|
97 | 97 | $modx = evolutionCMS(); |
98 | - $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
|
99 | - $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
|
100 | - $cssStyle = ($this->cssStyle) ? "style='" . $this->cssStyle . "'" : ''; |
|
101 | - $cssClass = ($this->cssClass) ? "class='" . $this->cssClass . "'" : ''; |
|
98 | + $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='".$this->columnHeaderStyle."'" : ''; |
|
99 | + $columnHeaderClass = ($this->columnHeaderClass) ? "class='".$this->columnHeaderClass."'" : ""; |
|
100 | + $cssStyle = ($this->cssStyle) ? "style='".$this->cssStyle."'" : ''; |
|
101 | + $cssClass = ($this->cssClass) ? "class='".$this->cssClass."'" : ''; |
|
102 | 102 | |
103 | - $pagerClass = ($this->pagerClass) ? "class='" . $this->pagerClass . "'" : ''; |
|
104 | - $pagerStyle = ($this->pagerStyle) ? "style='" . $this->pagerStyle . "'" : "style='background-color:#ffffff;'"; |
|
103 | + $pagerClass = ($this->pagerClass) ? "class='".$this->pagerClass."'" : ''; |
|
104 | + $pagerStyle = ($this->pagerStyle) ? "style='".$this->pagerStyle."'" : "style='background-color:#ffffff;'"; |
|
105 | 105 | |
106 | - $this->_itemStyle = ($this->itemStyle) ? "style='" . $this->itemStyle . "'" : ''; |
|
107 | - $this->_itemClass = ($this->itemClass) ? "class='" . $this->itemClass . "'" : ''; |
|
108 | - $this->_altItemStyle = ($this->altItemStyle) ? "style='" . $this->altItemStyle . "'" : ''; |
|
109 | - $this->_altItemClass = ($this->altItemClass) ? "class='" . $this->altItemClass . "'" : ''; |
|
106 | + $this->_itemStyle = ($this->itemStyle) ? "style='".$this->itemStyle."'" : ''; |
|
107 | + $this->_itemClass = ($this->itemClass) ? "class='".$this->itemClass."'" : ''; |
|
108 | + $this->_altItemStyle = ($this->altItemStyle) ? "style='".$this->altItemStyle."'" : ''; |
|
109 | + $this->_altItemClass = ($this->altItemClass) ? "class='".$this->altItemClass."'" : ''; |
|
110 | 110 | |
111 | 111 | $this->_alt = 0; |
112 | 112 | $this->_total = 0; |
113 | 113 | |
114 | 114 | $this->_isDataset = $modx->getDatabase()->isResult($this->ds); // if not dataset then treat as array |
115 | 115 | |
116 | - if(!$cssStyle && !$cssClass) { |
|
116 | + if (!$cssStyle && !$cssClass) { |
|
117 | 117 | $cssStyle = "style='width:100%;border:1px solid silver;font-family:verdana,arial; font-size:11px;'"; |
118 | 118 | } |
119 | - if(!$columnHeaderStyle && !$columnHeaderClass) { |
|
119 | + if (!$columnHeaderStyle && !$columnHeaderClass) { |
|
120 | 120 | $columnHeaderStyle = "style='color:black;background-color:silver'"; |
121 | 121 | } |
122 | - if(!$this->_itemStyle && !$this->_itemClass) { |
|
122 | + if (!$this->_itemStyle && !$this->_itemClass) { |
|
123 | 123 | $this->_itemStyle = "style='color:black;'"; |
124 | 124 | } |
125 | - if(!$this->_altItemStyle && !$this->_altItemClass) { |
|
125 | + if (!$this->_altItemStyle && !$this->_altItemClass) { |
|
126 | 126 | $this->_altItemStyle = "style='color:black;background-color:#eeeeee'"; |
127 | 127 | } |
128 | 128 | |
129 | - if($this->_isDataset && !$this->columns) { |
|
129 | + if ($this->_isDataset && !$this->columns) { |
|
130 | 130 | $cols = $modx->getDatabase()->numFields($this->ds); |
131 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
131 | + for ($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "").$modx->getDatabase()->fieldName($this->ds, $i); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // start grid |
135 | - $tblStart = "<table $cssClass $cssStyle cellpadding='" . (isset($this->cellPadding) ? (int) $this->cellPadding : 1) . "' cellspacing='" . (isset($this->cellSpacing) ? (int) $this->cellSpacing : 1) . "'>"; |
|
135 | + $tblStart = "<table $cssClass $cssStyle cellpadding='".(isset($this->cellPadding) ? (int) $this->cellPadding : 1)."' cellspacing='".(isset($this->cellSpacing) ? (int) $this->cellSpacing : 1)."'>"; |
|
136 | 136 | $tblEnd = "</table>"; |
137 | 137 | |
138 | 138 | // build column header |
@@ -143,32 +143,32 @@ discard block |
||
143 | 143 | $this->_colcolors = explode((strstr($this->colColors, "||") !== false ? "||" : ","), $this->colColors); |
144 | 144 | $this->_coltypes = explode((strstr($this->colTypes, "||") !== false ? "||" : ","), $this->colTypes); |
145 | 145 | $this->_colcount = count($this->_colnames); |
146 | - if(!$this->_isDataset) { |
|
146 | + if (!$this->_isDataset) { |
|
147 | 147 | $this->ds = explode((strstr($this->ds, "||") !== false ? "||" : ","), $this->ds); |
148 | 148 | $this->ds = array_chunk($this->ds, $this->_colcount); |
149 | 149 | } |
150 | 150 | $tblColHdr = "<thead><tr>"; |
151 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
151 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
152 | 152 | $name = $this->_colnames[$c]; |
153 | 153 | $width = $this->_colwidths[$c]; |
154 | - $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass" . ($width ? " width='$width'" : "") . ">$name</td>"; |
|
154 | + $tblColHdr .= "<td $columnHeaderStyle $columnHeaderClass".($width ? " width='$width'" : "").">$name</td>"; |
|
155 | 155 | } |
156 | 156 | $tblColHdr .= "</tr></thead>\n"; |
157 | 157 | |
158 | 158 | // build rows |
159 | 159 | $rowcount = $this->_isDataset ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
160 | 160 | $this->_fieldnames = explode(",", $this->fields); |
161 | - if($rowcount == 0) { |
|
162 | - $tblRows .= "<tr><td " . $this->_itemStyle . " " . $this->_itemClass . " colspan='" . $this->_colcount . "'>" . $this->noRecordMsg . "</td></tr>\n"; |
|
161 | + if ($rowcount == 0) { |
|
162 | + $tblRows .= "<tr><td ".$this->_itemStyle." ".$this->_itemClass." colspan='".$this->_colcount."'>".$this->noRecordMsg."</td></tr>\n"; |
|
163 | 163 | } else { |
164 | 164 | // render grid items |
165 | - if($this->pageSize <= 0) { |
|
166 | - for($r = 0; $r < $rowcount; $r++) { |
|
165 | + if ($this->pageSize <= 0) { |
|
166 | + for ($r = 0; $r < $rowcount; $r++) { |
|
167 | 167 | $row = $this->_isDataset ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$r]; |
168 | 168 | $tblRows .= $this->RenderRowFnc($r + 1, $row); |
169 | 169 | } |
170 | 170 | } else { |
171 | - if(!$this->pager) { |
|
171 | + if (!$this->pager) { |
|
172 | 172 | $this->pager = new DataSetPager($this->id, $this->ds, $this->pageSize, $this->pageNumber); |
173 | 173 | $this->pager->setRenderRowFnc($this); // pass this object |
174 | 174 | $this->pager->cssStyle = $pagerStyle; |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | $o = $tblStart; |
189 | 189 | $ptop = (substr($this->pagerLocation, 0, 3) == "top") || (substr($this->pagerLocation, 0, 4) == "both"); |
190 | 190 | $pbot = (substr($this->pagerLocation, 0, 3) == "bot") || (substr($this->pagerLocation, 0, 4) == "both"); |
191 | - if($this->header) { |
|
192 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->header . "</td></tr>"; |
|
191 | + if ($this->header) { |
|
192 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->header."</td></tr>"; |
|
193 | 193 | } |
194 | - if($tblPager && $ptop) { |
|
195 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
194 | + if ($tblPager && $ptop) { |
|
195 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
196 | 196 | } |
197 | - $o .= $tblColHdr . $tblRows; |
|
198 | - if($tblPager && $pbot) { |
|
199 | - $o .= "<tr><td align='" . (substr($this->pagerLocation, -4) == "left" ? "left" : "right") . "' $pagerClass $pagerStyle colspan='" . $this->_colcount . "'>" . $tblPager . " </td></tr>"; |
|
197 | + $o .= $tblColHdr.$tblRows; |
|
198 | + if ($tblPager && $pbot) { |
|
199 | + $o .= "<tr><td align='".(substr($this->pagerLocation, -4) == "left" ? "left" : "right")."' $pagerClass $pagerStyle colspan='".$this->_colcount."'>".$tblPager." </td></tr>"; |
|
200 | 200 | } |
201 | - if($this->footer) { |
|
202 | - $o .= "<tr><td bgcolor='#ffffff' colspan='" . $this->_colcount . "'>" . $this->footer . "</td></tr>"; |
|
201 | + if ($this->footer) { |
|
202 | + $o .= "<tr><td bgcolor='#ffffff' colspan='".$this->_colcount."'>".$this->footer."</td></tr>"; |
|
203 | 203 | } |
204 | 204 | $o .= $tblEnd; |
205 | 205 | return $o; |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | |
208 | 208 | // format column values |
209 | 209 | |
210 | - public function RenderRowFnc($n, $row) { |
|
211 | - if($this->_alt == 0) { |
|
210 | + public function RenderRowFnc($n, $row){ |
|
211 | + if ($this->_alt == 0) { |
|
212 | 212 | $Style = $this->_itemStyle; |
213 | 213 | $Class = $this->_itemClass; |
214 | 214 | $this->_alt = 1; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $this->_alt = 0; |
219 | 219 | } |
220 | 220 | $o = "<tr>"; |
221 | - for($c = 0; $c < $this->_colcount; $c++) { |
|
221 | + for ($c = 0; $c < $this->_colcount; $c++) { |
|
222 | 222 | $colStyle = $Style; |
223 | 223 | $fld = trim($this->_fieldnames[$c]); |
224 | 224 | $width = isset($this->_colwidths[$c]) ? $this->_colwidths[$c] : null; |
@@ -227,67 +227,67 @@ discard block |
||
227 | 227 | $type = isset($this->_coltypes[$c]) ? $this->_coltypes[$c] : null; |
228 | 228 | $nowrap = isset($this->_colwraps[$c]) ? $this->_colwraps[$c] : null; |
229 | 229 | $value = $row[($this->_isDataset && $fld ? $fld : $c)]; |
230 | - if($color && $Style) { |
|
231 | - $colStyle = substr($colStyle, 0, -1) . ";background-color:$color;'"; |
|
230 | + if ($color && $Style) { |
|
231 | + $colStyle = substr($colStyle, 0, -1).";background-color:$color;'"; |
|
232 | 232 | } |
233 | 233 | $value = $this->formatColumnValue($row, $value, $type, $align); |
234 | - $o .= "<td $colStyle $Class" . ($align ? " align='$align'" : "") . ($color ? " bgcolor='$color'" : "") . ($nowrap ? " nowrap='$nowrap'" : "") . ($width ? " width='$width'" : "") . ">$value</td>"; |
|
234 | + $o .= "<td $colStyle $Class".($align ? " align='$align'" : "").($color ? " bgcolor='$color'" : "").($nowrap ? " nowrap='$nowrap'" : "").($width ? " width='$width'" : "").">$value</td>"; |
|
235 | 235 | } |
236 | 236 | $o .= "</tr>\n"; |
237 | 237 | return $o; |
238 | 238 | } |
239 | 239 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
241 | - if(strpos($type, ":") !== false) { |
|
240 | + public function formatColumnValue($row, $value, $type, &$align){ |
|
241 | + if (strpos($type, ":") !== false) { |
|
242 | 242 | list($type, $type_format) = explode(":", $type, 2); |
243 | 243 | } |
244 | - switch(strtolower($type)) { |
|
244 | + switch (strtolower($type)) { |
|
245 | 245 | case "integer": |
246 | - if($align == "") { |
|
246 | + if ($align == "") { |
|
247 | 247 | $align = "right"; |
248 | 248 | } |
249 | 249 | $value = number_format($value); |
250 | 250 | break; |
251 | 251 | |
252 | 252 | case "float": |
253 | - if($align == "") { |
|
253 | + if ($align == "") { |
|
254 | 254 | $align = "right"; |
255 | 255 | } |
256 | - if(!$type_format) { |
|
256 | + if (!$type_format) { |
|
257 | 257 | $type_format = 2; |
258 | 258 | } |
259 | 259 | $value = number_format($value, $type_format); |
260 | 260 | break; |
261 | 261 | |
262 | 262 | case "currency": |
263 | - if($align == "") { |
|
263 | + if ($align == "") { |
|
264 | 264 | $align = "right"; |
265 | 265 | } |
266 | - if(!$type_format) { |
|
266 | + if (!$type_format) { |
|
267 | 267 | $type_format = 2; |
268 | 268 | } |
269 | - $value = "$" . number_format($value, $type_format); |
|
269 | + $value = "$".number_format($value, $type_format); |
|
270 | 270 | break; |
271 | 271 | |
272 | 272 | case "date": |
273 | - if($align == "") { |
|
273 | + if ($align == "") { |
|
274 | 274 | $align = "right"; |
275 | 275 | } |
276 | - if(!is_numeric($value)) { |
|
276 | + if (!is_numeric($value)) { |
|
277 | 277 | $value = strtotime($value); |
278 | 278 | } |
279 | - if(!$type_format) { |
|
279 | + if (!$type_format) { |
|
280 | 280 | $type_format = "%A %d, %B %Y"; |
281 | 281 | } |
282 | 282 | $value = strftime($type_format, $value); |
283 | 283 | break; |
284 | 284 | |
285 | 285 | case "boolean": |
286 | - if($align == '') { |
|
286 | + if ($align == '') { |
|
287 | 287 | $align = "center"; |
288 | 288 | } |
289 | 289 | $value = number_format($value); |
290 | - if($value) { |
|
290 | + if ($value) { |
|
291 | 291 | $value = '•'; |
292 | 292 | } else { |
293 | 293 | $value = ' '; |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | // replace [+value+] first |
299 | 299 | $value = str_replace("[+value+]", $value, $type_format); |
300 | 300 | // replace other [+fields+] |
301 | - if(strpos($value, "[+") !== false) { |
|
302 | - foreach($row as $k => $v) { |
|
301 | + if (strpos($value, "[+") !== false) { |
|
302 | + foreach ($row as $k => $v) { |
|
303 | 303 | $value = str_replace("[+$k+]", $v, $value); |
304 | 304 | } |
305 | 305 | } |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | # ----------------------------------------- |
12 | 12 | # |
13 | 13 | |
14 | -class DataGrid implements DataGridInterface{ |
|
14 | +class DataGrid implements DataGridInterface |
|
15 | +{ |
|
15 | 16 | |
16 | 17 | public $ds; // datasource |
17 | 18 | public $id; |
@@ -75,7 +76,8 @@ discard block |
||
75 | 76 | |
76 | 77 | public static $dataGridCnt; |
77 | 78 | |
78 | - public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) { |
|
79 | + public function __construct($id, $ds, $pageSize = 20, $pageNumber = -1) |
|
80 | + { |
|
79 | 81 | // set id |
80 | 82 | self::$dataGridCnt++; |
81 | 83 | $this->id = $this->id ? empty($id) : "dg" . self::$dataGridCnt; |
@@ -89,11 +91,13 @@ discard block |
||
89 | 91 | $this->pagerLocation = 'top-right'; |
90 | 92 | } |
91 | 93 | |
92 | - public function setDataSource($ds) { |
|
94 | + public function setDataSource($ds) |
|
95 | + { |
|
93 | 96 | $this->ds = $ds; |
94 | 97 | } |
95 | 98 | |
96 | - public function render() { |
|
99 | + public function render() |
|
100 | + { |
|
97 | 101 | $modx = evolutionCMS(); |
98 | 102 | $columnHeaderStyle = ($this->columnHeaderStyle) ? "style='" . $this->columnHeaderStyle . "'" : ''; |
99 | 103 | $columnHeaderClass = ($this->columnHeaderClass) ? "class='" . $this->columnHeaderClass . "'" : ""; |
@@ -128,7 +132,9 @@ discard block |
||
128 | 132 | |
129 | 133 | if($this->_isDataset && !$this->columns) { |
130 | 134 | $cols = $modx->getDatabase()->numFields($this->ds); |
131 | - for($i = 0; $i < $cols; $i++) $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
135 | + for($i = 0; $i < $cols; $i++) { |
|
136 | + $this->columns .= ($i ? "," : "") . $modx->getDatabase()->fieldName($this->ds, $i); |
|
137 | + } |
|
132 | 138 | } |
133 | 139 | |
134 | 140 | // start grid |
@@ -207,7 +213,8 @@ discard block |
||
207 | 213 | |
208 | 214 | // format column values |
209 | 215 | |
210 | - public function RenderRowFnc($n, $row) { |
|
216 | + public function RenderRowFnc($n, $row) |
|
217 | + { |
|
211 | 218 | if($this->_alt == 0) { |
212 | 219 | $Style = $this->_itemStyle; |
213 | 220 | $Class = $this->_itemClass; |
@@ -237,7 +244,8 @@ discard block |
||
237 | 244 | return $o; |
238 | 245 | } |
239 | 246 | |
240 | - public function formatColumnValue($row, $value, $type, &$align) { |
|
247 | + public function formatColumnValue($row, $value, $type, &$align) |
|
248 | + { |
|
241 | 249 | if(strpos($type, ":") !== false) { |
242 | 250 | list($type, $type_format) = explode(":", $type, 2); |
243 | 251 | } |
@@ -33,6 +33,9 @@ discard block |
||
33 | 33 | public $renderPagerFncArgs; |
34 | 34 | public static $dataSetPagerCnt; |
35 | 35 | |
36 | + /** |
|
37 | + * @param boolean|string $id |
|
38 | + */ |
|
36 | 39 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
37 | 40 | global $_PAGE; // use view state object |
38 | 41 | |
@@ -77,6 +80,9 @@ discard block |
||
77 | 80 | $this->pageSize = $ps; |
78 | 81 | } |
79 | 82 | |
83 | + /** |
|
84 | + * @param DataGrid $fncName |
|
85 | + */ |
|
80 | 86 | public function setRenderRowFnc($fncName, $args = "") { |
81 | 87 | $this->renderRowFnc = &$fncName; |
82 | 88 | $this->renderRowFncArgs = $args; // extra agruments |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | |
14 | 14 | class DataSetPager implements DataSetPagerInterface{ |
15 | 15 | |
16 | - public $ds; // datasource |
|
16 | + public $ds; // datasource |
|
17 | 17 | public $pageSize; |
18 | 18 | public $pageNumber; |
19 | 19 | public $rows; |
20 | 20 | public $pager; |
21 | 21 | public $id; |
22 | 22 | |
23 | - // normal page |
|
23 | + // normal page |
|
24 | 24 | public $pageStyle; |
25 | 25 | public $pageClass; |
26 | 26 | |
27 | - // selected page |
|
27 | + // selected page |
|
28 | 28 | public $selPageStyle; |
29 | 29 | public $selPageClass; |
30 | 30 | public $renderRowFnc; |
@@ -34,164 +34,164 @@ discard block |
||
34 | 34 | public static $dataSetPagerCnt; |
35 | 35 | |
36 | 36 | public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
37 | - global $_PAGE; // use view state object |
|
38 | - |
|
39 | - // set id |
|
40 | - self::$dataSetPagerCnt++; |
|
41 | - $this->id = !empty($id) ? $id : "dsp" . self::$dataSetPagerCnt; |
|
42 | - |
|
43 | - // get pagenumber |
|
44 | - // by setting pager to -1 cause pager to load it's last page number |
|
45 | - if($pageNumber == -1) { |
|
46 | - $pageNumber = 1; |
|
47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
51 | - } |
|
52 | - } |
|
53 | - if(!is_numeric($pageNumber)) { |
|
54 | - $pageNumber = 1; |
|
55 | - } |
|
56 | - |
|
57 | - $this->ds = $ds; // datasource |
|
58 | - $this->pageSize = $pageSize; |
|
59 | - $this->pageNumber = $pageNumber; |
|
60 | - $this->rows = ''; |
|
61 | - $this->pager = ''; |
|
62 | - } |
|
37 | + global $_PAGE; // use view state object |
|
38 | + |
|
39 | + // set id |
|
40 | + self::$dataSetPagerCnt++; |
|
41 | + $this->id = !empty($id) ? $id : "dsp" . self::$dataSetPagerCnt; |
|
42 | + |
|
43 | + // get pagenumber |
|
44 | + // by setting pager to -1 cause pager to load it's last page number |
|
45 | + if($pageNumber == -1) { |
|
46 | + $pageNumber = 1; |
|
47 | + if(isset($_GET["dpgn" . $this->id])) { |
|
48 | + $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | + } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | + $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
51 | + } |
|
52 | + } |
|
53 | + if(!is_numeric($pageNumber)) { |
|
54 | + $pageNumber = 1; |
|
55 | + } |
|
56 | + |
|
57 | + $this->ds = $ds; // datasource |
|
58 | + $this->pageSize = $pageSize; |
|
59 | + $this->pageNumber = $pageNumber; |
|
60 | + $this->rows = ''; |
|
61 | + $this->pager = ''; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | public function getRenderedPager() { |
65 | - return $this->pager; |
|
66 | - } |
|
65 | + return $this->pager; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | public function getRenderedRows() { |
69 | - return $this->rows; |
|
70 | - } |
|
69 | + return $this->rows; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | public function setDataSource($ds) { |
73 | - $this->ds = $ds; |
|
74 | - } |
|
73 | + $this->ds = $ds; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | public function setPageSize($ps) { |
77 | - $this->pageSize = $ps; |
|
78 | - } |
|
77 | + $this->pageSize = $ps; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | public function setRenderRowFnc($fncName, $args = "") { |
81 | - $this->renderRowFnc = &$fncName; |
|
82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
81 | + $this->renderRowFnc = &$fncName; |
|
82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
83 | 83 | |
84 | 84 | |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | public function setRenderPagerFnc($fncName, $args = "") { |
88 | - $this->renderPagerFnc = $fncName; |
|
89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | - } |
|
88 | + $this->renderPagerFnc = $fncName; |
|
89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | + } |
|
91 | 91 | |
92 | 92 | public function render() { |
93 | - $modx = evolutionCMS(); global $_PAGE; |
|
94 | - |
|
95 | - $isDataset = $modx->getDatabase()->isResult($this->ds); |
|
96 | - |
|
97 | - if(!$this->selPageStyle) { |
|
98 | - $this->selPageStyle = "font-weight:bold"; |
|
99 | - } |
|
100 | - |
|
101 | - // get total number of rows |
|
102 | - $tnr = ($isDataset) ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
103 | - |
|
104 | - // render: no records found |
|
105 | - if($tnr <= 0) { |
|
106 | - $fnc = $this->renderRowFnc; |
|
107 | - $args = $this->renderRowFncArgs; |
|
108 | - if(isset($fnc)) { |
|
109 | - if($args != "") { |
|
110 | - $this->rows .= $fnc(0, null, $args); |
|
111 | - } // if agrs was specified then we will pass three params |
|
112 | - else { |
|
113 | - $this->rows .= $fnc(0, null); |
|
114 | - } // otherwise two will be passed |
|
115 | - } |
|
116 | - return; |
|
117 | - } |
|
118 | - |
|
119 | - // get total pages |
|
120 | - $tp = ceil($tnr / $this->pageSize); |
|
121 | - if($this->pageNumber > $tp) { |
|
122 | - $this->pageNumber = 1; |
|
123 | - } |
|
124 | - |
|
125 | - // get page number |
|
126 | - $p = $this->pageNumber; |
|
127 | - |
|
128 | - // save page number to view state if available |
|
129 | - if(isset($_PAGE['vs'])) { |
|
130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
131 | - } |
|
132 | - |
|
133 | - // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
134 | - if($tp > 1) { |
|
135 | - $url = ''; |
|
136 | - $fnc = $this->renderPagerFnc; |
|
137 | - $args = $this->renderPagerFncArgs; |
|
138 | - if(!isset($fnc)) { |
|
139 | - if($modx->isFrontend()) { |
|
140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
141 | - } else { |
|
142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
143 | - } |
|
144 | - $i = 0; |
|
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
146 | - $i++; |
|
147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
148 | - } |
|
149 | - if($i >= 1) { |
|
150 | - $url .= "&"; |
|
151 | - } |
|
152 | - } |
|
153 | - for($i = 1; $i <= $tp; $i++) { |
|
154 | - if(isset($fnc)) { |
|
155 | - if($args != "") { |
|
156 | - $this->pager .= $fnc($p, $i, $args); |
|
157 | - } else { |
|
158 | - $this->pager .= $fnc($p, $i); |
|
159 | - } |
|
160 | - } else { |
|
161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
167 | - $fnc = $this->renderRowFnc; |
|
168 | - $args = $this->renderRowFncArgs; |
|
169 | - |
|
170 | - if(isset($fnc)) { |
|
171 | - $i = 1; |
|
172 | - $fncObject = is_object($fnc); |
|
173 | - $minitems = (($p - 1) * $this->pageSize) + 1; |
|
174 | - $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | - if($i >= $minitems && $i <= $maxitems) { |
|
177 | - if($fncObject) { |
|
178 | - if($args != "") { |
|
179 | - $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
180 | - } else { |
|
181 | - $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
182 | - } |
|
183 | - } else { |
|
184 | - if($args != "") { |
|
185 | - $this->rows .= $fnc($i, $row, $args); |
|
186 | - } // if agrs was specified then we wil pass three params |
|
187 | - else { |
|
188 | - $this->rows .= $fnc($i, $row); |
|
189 | - } // otherwise two will be passed |
|
190 | - } |
|
191 | - |
|
192 | - } |
|
193 | - $i++; |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
93 | + $modx = evolutionCMS(); global $_PAGE; |
|
94 | + |
|
95 | + $isDataset = $modx->getDatabase()->isResult($this->ds); |
|
96 | + |
|
97 | + if(!$this->selPageStyle) { |
|
98 | + $this->selPageStyle = "font-weight:bold"; |
|
99 | + } |
|
100 | + |
|
101 | + // get total number of rows |
|
102 | + $tnr = ($isDataset) ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
|
103 | + |
|
104 | + // render: no records found |
|
105 | + if($tnr <= 0) { |
|
106 | + $fnc = $this->renderRowFnc; |
|
107 | + $args = $this->renderRowFncArgs; |
|
108 | + if(isset($fnc)) { |
|
109 | + if($args != "") { |
|
110 | + $this->rows .= $fnc(0, null, $args); |
|
111 | + } // if agrs was specified then we will pass three params |
|
112 | + else { |
|
113 | + $this->rows .= $fnc(0, null); |
|
114 | + } // otherwise two will be passed |
|
115 | + } |
|
116 | + return; |
|
117 | + } |
|
118 | + |
|
119 | + // get total pages |
|
120 | + $tp = ceil($tnr / $this->pageSize); |
|
121 | + if($this->pageNumber > $tp) { |
|
122 | + $this->pageNumber = 1; |
|
123 | + } |
|
124 | + |
|
125 | + // get page number |
|
126 | + $p = $this->pageNumber; |
|
127 | + |
|
128 | + // save page number to view state if available |
|
129 | + if(isset($_PAGE['vs'])) { |
|
130 | + $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
131 | + } |
|
132 | + |
|
133 | + // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
|
134 | + if($tp > 1) { |
|
135 | + $url = ''; |
|
136 | + $fnc = $this->renderPagerFnc; |
|
137 | + $args = $this->renderPagerFncArgs; |
|
138 | + if(!isset($fnc)) { |
|
139 | + if($modx->isFrontend()) { |
|
140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
141 | + } else { |
|
142 | + $url = $_SERVER['PHP_SELF'] . '?'; |
|
143 | + } |
|
144 | + $i = 0; |
|
145 | + foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
146 | + $i++; |
|
147 | + $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
148 | + } |
|
149 | + if($i >= 1) { |
|
150 | + $url .= "&"; |
|
151 | + } |
|
152 | + } |
|
153 | + for($i = 1; $i <= $tp; $i++) { |
|
154 | + if(isset($fnc)) { |
|
155 | + if($args != "") { |
|
156 | + $this->pager .= $fnc($p, $i, $args); |
|
157 | + } else { |
|
158 | + $this->pager .= $fnc($p, $i); |
|
159 | + } |
|
160 | + } else { |
|
161 | + $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + // render row : renderRowFnc($rowNumber,$row,$arguments="") |
|
167 | + $fnc = $this->renderRowFnc; |
|
168 | + $args = $this->renderRowFncArgs; |
|
169 | + |
|
170 | + if(isset($fnc)) { |
|
171 | + $i = 1; |
|
172 | + $fncObject = is_object($fnc); |
|
173 | + $minitems = (($p - 1) * $this->pageSize) + 1; |
|
174 | + $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
|
175 | + while($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | + if($i >= $minitems && $i <= $maxitems) { |
|
177 | + if($fncObject) { |
|
178 | + if($args != "") { |
|
179 | + $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
|
180 | + } else { |
|
181 | + $this->rows .= $fnc->RenderRowFnc($i, $row); |
|
182 | + } |
|
183 | + } else { |
|
184 | + if($args != "") { |
|
185 | + $this->rows .= $fnc($i, $row, $args); |
|
186 | + } // if agrs was specified then we wil pass three params |
|
187 | + else { |
|
188 | + $this->rows .= $fnc($i, $row); |
|
189 | + } // otherwise two will be passed |
|
190 | + } |
|
191 | + |
|
192 | + } |
|
193 | + $i++; |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | 197 | } |
@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | public $renderPagerFncArgs; |
34 | 34 | public static $dataSetPagerCnt; |
35 | 35 | |
36 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
36 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1){ |
|
37 | 37 | global $_PAGE; // use view state object |
38 | 38 | |
39 | 39 | // set id |
40 | 40 | self::$dataSetPagerCnt++; |
41 | - $this->id = !empty($id) ? $id : "dsp" . self::$dataSetPagerCnt; |
|
41 | + $this->id = !empty($id) ? $id : "dsp".self::$dataSetPagerCnt; |
|
42 | 42 | |
43 | 43 | // get pagenumber |
44 | 44 | // by setting pager to -1 cause pager to load it's last page number |
45 | - if($pageNumber == -1) { |
|
45 | + if ($pageNumber == -1) { |
|
46 | 46 | $pageNumber = 1; |
47 | - if(isset($_GET["dpgn" . $this->id])) { |
|
48 | - $pageNumber = $_GET["dpgn" . $this->id]; |
|
49 | - } elseif(isset($_PAGE['vs'][$id . '_dpgn'])) { |
|
50 | - $pageNumber = $_PAGE['vs'][$id . '_dpgn']; |
|
47 | + if (isset($_GET["dpgn".$this->id])) { |
|
48 | + $pageNumber = $_GET["dpgn".$this->id]; |
|
49 | + } elseif (isset($_PAGE['vs'][$id.'_dpgn'])) { |
|
50 | + $pageNumber = $_PAGE['vs'][$id.'_dpgn']; |
|
51 | 51 | } |
52 | 52 | } |
53 | - if(!is_numeric($pageNumber)) { |
|
53 | + if (!is_numeric($pageNumber)) { |
|
54 | 54 | $pageNumber = 1; |
55 | 55 | } |
56 | 56 | |
@@ -61,40 +61,40 @@ discard block |
||
61 | 61 | $this->pager = ''; |
62 | 62 | } |
63 | 63 | |
64 | - public function getRenderedPager() { |
|
64 | + public function getRenderedPager(){ |
|
65 | 65 | return $this->pager; |
66 | 66 | } |
67 | 67 | |
68 | - public function getRenderedRows() { |
|
68 | + public function getRenderedRows(){ |
|
69 | 69 | return $this->rows; |
70 | 70 | } |
71 | 71 | |
72 | - public function setDataSource($ds) { |
|
72 | + public function setDataSource($ds){ |
|
73 | 73 | $this->ds = $ds; |
74 | 74 | } |
75 | 75 | |
76 | - public function setPageSize($ps) { |
|
76 | + public function setPageSize($ps){ |
|
77 | 77 | $this->pageSize = $ps; |
78 | 78 | } |
79 | 79 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
80 | + public function setRenderRowFnc($fncName, $args = ""){ |
|
81 | 81 | $this->renderRowFnc = &$fncName; |
82 | - $this->renderRowFncArgs = $args; // extra agruments |
|
82 | + $this->renderRowFncArgs = $args; // extra agruments |
|
83 | 83 | |
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
87 | + public function setRenderPagerFnc($fncName, $args = ""){ |
|
88 | 88 | $this->renderPagerFnc = $fncName; |
89 | - $this->renderPagerFncArgs = $args; // extra agruments |
|
89 | + $this->renderPagerFncArgs = $args; // extra agruments |
|
90 | 90 | } |
91 | 91 | |
92 | - public function render() { |
|
92 | + public function render(){ |
|
93 | 93 | $modx = evolutionCMS(); global $_PAGE; |
94 | 94 | |
95 | 95 | $isDataset = $modx->getDatabase()->isResult($this->ds); |
96 | 96 | |
97 | - if(!$this->selPageStyle) { |
|
97 | + if (!$this->selPageStyle) { |
|
98 | 98 | $this->selPageStyle = "font-weight:bold"; |
99 | 99 | } |
100 | 100 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $tnr = ($isDataset) ? $modx->getDatabase()->getRecordCount($this->ds) : count($this->ds); |
103 | 103 | |
104 | 104 | // render: no records found |
105 | - if($tnr <= 0) { |
|
105 | + if ($tnr <= 0) { |
|
106 | 106 | $fnc = $this->renderRowFnc; |
107 | 107 | $args = $this->renderRowFncArgs; |
108 | - if(isset($fnc)) { |
|
109 | - if($args != "") { |
|
108 | + if (isset($fnc)) { |
|
109 | + if ($args != "") { |
|
110 | 110 | $this->rows .= $fnc(0, null, $args); |
111 | 111 | } // if agrs was specified then we will pass three params |
112 | 112 | else { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // get total pages |
120 | 120 | $tp = ceil($tnr / $this->pageSize); |
121 | - if($this->pageNumber > $tp) { |
|
121 | + if ($this->pageNumber > $tp) { |
|
122 | 122 | $this->pageNumber = 1; |
123 | 123 | } |
124 | 124 | |
@@ -126,39 +126,39 @@ discard block |
||
126 | 126 | $p = $this->pageNumber; |
127 | 127 | |
128 | 128 | // save page number to view state if available |
129 | - if(isset($_PAGE['vs'])) { |
|
130 | - $_PAGE['vs'][$this->id . '_dpgn'] = $p; |
|
129 | + if (isset($_PAGE['vs'])) { |
|
130 | + $_PAGE['vs'][$this->id.'_dpgn'] = $p; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // render pager : renderPagerFnc($cuurentPage,$pagerNumber,$arguments=""); |
134 | - if($tp > 1) { |
|
134 | + if ($tp > 1) { |
|
135 | 135 | $url = ''; |
136 | 136 | $fnc = $this->renderPagerFnc; |
137 | 137 | $args = $this->renderPagerFncArgs; |
138 | - if(!isset($fnc)) { |
|
139 | - if($modx->isFrontend()) { |
|
140 | - $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full') . '?'; |
|
138 | + if (!isset($fnc)) { |
|
139 | + if ($modx->isFrontend()) { |
|
140 | + $url = $modx->makeUrl($modx->documentIdentifier, '', '', 'full').'?'; |
|
141 | 141 | } else { |
142 | - $url = $_SERVER['PHP_SELF'] . '?'; |
|
142 | + $url = $_SERVER['PHP_SELF'].'?'; |
|
143 | 143 | } |
144 | 144 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
145 | + foreach ($_GET as $n => $v) if ($n != 'dpgn'.$this->id) { |
|
146 | 146 | $i++; |
147 | - $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
|
147 | + $url .= (($i > 1) ? "&" : "")."$n=$v"; |
|
148 | 148 | } |
149 | - if($i >= 1) { |
|
149 | + if ($i >= 1) { |
|
150 | 150 | $url .= "&"; |
151 | 151 | } |
152 | 152 | } |
153 | - for($i = 1; $i <= $tp; $i++) { |
|
154 | - if(isset($fnc)) { |
|
155 | - if($args != "") { |
|
153 | + for ($i = 1; $i <= $tp; $i++) { |
|
154 | + if (isset($fnc)) { |
|
155 | + if ($args != "") { |
|
156 | 156 | $this->pager .= $fnc($p, $i, $args); |
157 | 157 | } else { |
158 | 158 | $this->pager .= $fnc($p, $i); |
159 | 159 | } |
160 | 160 | } else { |
161 | - $this->pager .= ($p == $i) ? " <span class='" . $this->selPageClass . "' style='" . $this->selPageStyle . "'>$i</span> " : " <a href='" . $url . "dpgn" . $this->id . "=$i' class='" . $this->pageClass . "' style='" . $this->pageStyle . "'>$i</a> "; |
|
161 | + $this->pager .= ($p == $i) ? " <span class='".$this->selPageClass."' style='".$this->selPageStyle."'>$i</span> " : " <a href='".$url."dpgn".$this->id."=$i' class='".$this->pageClass."' style='".$this->pageStyle."'>$i</a> "; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | $fnc = $this->renderRowFnc; |
168 | 168 | $args = $this->renderRowFncArgs; |
169 | 169 | |
170 | - if(isset($fnc)) { |
|
170 | + if (isset($fnc)) { |
|
171 | 171 | $i = 1; |
172 | 172 | $fncObject = is_object($fnc); |
173 | 173 | $minitems = (($p - 1) * $this->pageSize) + 1; |
174 | 174 | $maxitems = (($p - 1) * $this->pageSize) + $this->pageSize; |
175 | - while($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | - if($i >= $minitems && $i <= $maxitems) { |
|
177 | - if($fncObject) { |
|
178 | - if($args != "") { |
|
175 | + while ($i <= $maxitems && ($row = ($isDataset) ? $modx->getDatabase()->getRow($this->ds) : $this->ds[$i - 1])) { |
|
176 | + if ($i >= $minitems && $i <= $maxitems) { |
|
177 | + if ($fncObject) { |
|
178 | + if ($args != "") { |
|
179 | 179 | $this->rows .= $fnc->RenderRowFnc($i, $row, $args); |
180 | 180 | } else { |
181 | 181 | $this->rows .= $fnc->RenderRowFnc($i, $row); |
182 | 182 | } |
183 | 183 | } else { |
184 | - if($args != "") { |
|
184 | + if ($args != "") { |
|
185 | 185 | $this->rows .= $fnc($i, $row, $args); |
186 | 186 | } // if agrs was specified then we wil pass three params |
187 | 187 | else { |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | # ----------------------------------------- |
12 | 12 | # |
13 | 13 | |
14 | -class DataSetPager implements DataSetPagerInterface{ |
|
14 | +class DataSetPager implements DataSetPagerInterface |
|
15 | +{ |
|
15 | 16 | |
16 | 17 | public $ds; // datasource |
17 | 18 | public $pageSize; |
@@ -33,7 +34,8 @@ discard block |
||
33 | 34 | public $renderPagerFncArgs; |
34 | 35 | public static $dataSetPagerCnt; |
35 | 36 | |
36 | - public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) { |
|
37 | + public function __construct($id, $ds, $pageSize = 10, $pageNumber = -1) |
|
38 | + { |
|
37 | 39 | global $_PAGE; // use view state object |
38 | 40 | |
39 | 41 | // set id |
@@ -61,35 +63,42 @@ discard block |
||
61 | 63 | $this->pager = ''; |
62 | 64 | } |
63 | 65 | |
64 | - public function getRenderedPager() { |
|
66 | + public function getRenderedPager() |
|
67 | + { |
|
65 | 68 | return $this->pager; |
66 | 69 | } |
67 | 70 | |
68 | - public function getRenderedRows() { |
|
71 | + public function getRenderedRows() |
|
72 | + { |
|
69 | 73 | return $this->rows; |
70 | 74 | } |
71 | 75 | |
72 | - public function setDataSource($ds) { |
|
76 | + public function setDataSource($ds) |
|
77 | + { |
|
73 | 78 | $this->ds = $ds; |
74 | 79 | } |
75 | 80 | |
76 | - public function setPageSize($ps) { |
|
81 | + public function setPageSize($ps) |
|
82 | + { |
|
77 | 83 | $this->pageSize = $ps; |
78 | 84 | } |
79 | 85 | |
80 | - public function setRenderRowFnc($fncName, $args = "") { |
|
86 | + public function setRenderRowFnc($fncName, $args = "") |
|
87 | + { |
|
81 | 88 | $this->renderRowFnc = &$fncName; |
82 | 89 | $this->renderRowFncArgs = $args; // extra agruments |
83 | 90 | |
84 | 91 | |
85 | 92 | } |
86 | 93 | |
87 | - public function setRenderPagerFnc($fncName, $args = "") { |
|
94 | + public function setRenderPagerFnc($fncName, $args = "") |
|
95 | + { |
|
88 | 96 | $this->renderPagerFnc = $fncName; |
89 | 97 | $this->renderPagerFncArgs = $args; // extra agruments |
90 | 98 | } |
91 | 99 | |
92 | - public function render() { |
|
100 | + public function render() |
|
101 | + { |
|
93 | 102 | $modx = evolutionCMS(); global $_PAGE; |
94 | 103 | |
95 | 104 | $isDataset = $modx->getDatabase()->isResult($this->ds); |
@@ -142,8 +151,10 @@ discard block |
||
142 | 151 | $url = $_SERVER['PHP_SELF'] . '?'; |
143 | 152 | } |
144 | 153 | $i = 0; |
145 | - foreach($_GET as $n => $v) if($n != 'dpgn' . $this->id) { |
|
154 | + foreach($_GET as $n => $v) { |
|
155 | + if($n != 'dpgn' . $this->id) { |
|
146 | 156 | $i++; |
157 | + } |
|
147 | 158 | $url .= (($i > 1) ? "&" : "") . "$n=$v"; |
148 | 159 | } |
149 | 160 | if($i >= 1) { |