質問編集履歴
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
原因がわからず困っています。
|
6
6
|
|
7
|
+
クエリの重複確認は
|
8
|
+
|
9
|
+
code Profilerにて確認済みです。
|
10
|
+
|
7
11
|
他のファイルでも同様なことが起きているのでいます。
|
8
12
|
|
9
13
|
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
原因がわからず困っています。
|
6
6
|
|
7
|
-
他のファイルでも同様なことが起きているので
|
7
|
+
他のファイルでも同様なことが起きているのでいます。
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
-
コントローラー
|
11
|
+
コントローラー
|
12
12
|
|
13
13
|
```ここに言語を入力
|
14
14
|
|
@@ -26,6 +26,572 @@
|
|
26
26
|
|
27
27
|
```
|
28
28
|
|
29
|
+
|
30
|
+
|
31
|
+
モデル
|
32
|
+
|
33
|
+
```ここに言語を入力
|
34
|
+
|
35
|
+
viewmodel.php
|
36
|
+
|
37
|
+
abstract class ViewModel
|
38
|
+
|
39
|
+
{
|
40
|
+
|
41
|
+
/**
|
42
|
+
|
43
|
+
* Factory for fetching the ViewModel
|
44
|
+
|
45
|
+
*
|
46
|
+
|
47
|
+
* @param string ViewModel classname without View_ prefix or full classname
|
48
|
+
|
49
|
+
* @param string Method to execute
|
50
|
+
|
51
|
+
* @return ViewModel
|
52
|
+
|
53
|
+
*/
|
54
|
+
|
55
|
+
public static function forge($viewmodel, $method = 'view', $auto_filter = null, $view = null)
|
56
|
+
|
57
|
+
{
|
58
|
+
|
59
|
+
// if no custom view is given, make it equal to the viewmodel name
|
60
|
+
|
61
|
+
is_null($view) and $view = $viewmodel;
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
// strip any extensions from the view name to determine the viewmodel to load
|
66
|
+
|
67
|
+
$viewmodel = \Inflector::words_to_upper(str_replace(
|
68
|
+
|
69
|
+
array('/', DS),
|
70
|
+
|
71
|
+
'_',
|
72
|
+
|
73
|
+
strpos($viewmodel, '.') === false ? $viewmodel : substr($viewmodel, 0, -strlen(strrchr($viewmodel, '.')))
|
74
|
+
|
75
|
+
));
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
// determine the viewmodel namespace from the current request context
|
80
|
+
|
81
|
+
$namespace = \Request::active() ? ucfirst(\Request::active()->module) : '';
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
// list of possible viewmodel classnames, start with the namespaced one
|
86
|
+
|
87
|
+
$classes = array($namespace.'\\View_'.$viewmodel);
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
// add the global version if needed
|
92
|
+
|
93
|
+
empty($namespace) or $classes[] = 'View_'.$viewmodel;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
/**
|
98
|
+
|
99
|
+
* Add non View_ prefixed classnames to the list, for BC reasons
|
100
|
+
|
101
|
+
*
|
102
|
+
|
103
|
+
* @deprecated 1.6
|
104
|
+
|
105
|
+
*/
|
106
|
+
|
107
|
+
$classes[] = $namespace.'\\'.$viewmodel;
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
// and add the global version of that if needed
|
112
|
+
|
113
|
+
empty($namespace) or $classes[] = $viewmodel;
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
// check if we can find one
|
118
|
+
|
119
|
+
foreach ($classes as $class)
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
if (class_exists($class))
|
124
|
+
|
125
|
+
{
|
126
|
+
|
127
|
+
return new $class($method, $auto_filter, $view);
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
throw new \OutOfBoundsException('ViewModel "'.reset($classes).'" could not be found.');
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
/**
|
142
|
+
|
143
|
+
* @var string method to execute when rendering
|
144
|
+
|
145
|
+
*/
|
146
|
+
|
147
|
+
protected $_method;
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
/**
|
152
|
+
|
153
|
+
* @var string|View view name, after instantiation a View object
|
154
|
+
|
155
|
+
*/
|
156
|
+
|
157
|
+
protected $_view;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
/**
|
162
|
+
|
163
|
+
* @var bool whether or not to use auto filtering
|
164
|
+
|
165
|
+
*/
|
166
|
+
|
167
|
+
protected $_auto_filter;
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
/**
|
172
|
+
|
173
|
+
* @var Request active request during ViewModel creation for proper context
|
174
|
+
|
175
|
+
*/
|
176
|
+
|
177
|
+
protected $_active_request;
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
protected function __construct($method, $auto_filter = null, $view = null)
|
182
|
+
|
183
|
+
{
|
184
|
+
|
185
|
+
$this->_auto_filter = $auto_filter;
|
186
|
+
|
187
|
+
$this->_view === null and $this->_view = $view;
|
188
|
+
|
189
|
+
class_exists('Request', false) and $this->_active_request = \Request::active();
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
if (empty($this->_view))
|
194
|
+
|
195
|
+
{
|
196
|
+
|
197
|
+
// Take the class name and guess the view name
|
198
|
+
|
199
|
+
$class = get_class($this);
|
200
|
+
|
201
|
+
$this->_view = strtolower(str_replace('_', DS, preg_replace('#^([a-z0-9_]*\\\\)?(View_)?#i', '', $class)));
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
$this->set_view();
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
$this->_method = $method;
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
/**
|
218
|
+
|
219
|
+
* Returns the View object associated with this Viewmodel
|
220
|
+
|
221
|
+
*
|
222
|
+
|
223
|
+
* @return View
|
224
|
+
|
225
|
+
*/
|
226
|
+
|
227
|
+
public function get_view()
|
228
|
+
|
229
|
+
{
|
230
|
+
|
231
|
+
return $this->_view;
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
/**
|
238
|
+
|
239
|
+
* Construct the View object
|
240
|
+
|
241
|
+
*/
|
242
|
+
|
243
|
+
protected function set_view()
|
244
|
+
|
245
|
+
{
|
246
|
+
|
247
|
+
$this->_view instanceOf View or $this->_view = \View::forge($this->_view);
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
/**
|
254
|
+
|
255
|
+
* Returns the active request object.
|
256
|
+
|
257
|
+
*
|
258
|
+
|
259
|
+
* @return Request
|
260
|
+
|
261
|
+
*/
|
262
|
+
|
263
|
+
protected function request()
|
264
|
+
|
265
|
+
{
|
266
|
+
|
267
|
+
return $this->_active_request;
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
/**
|
274
|
+
|
275
|
+
* Executed before the view method
|
276
|
+
|
277
|
+
*/
|
278
|
+
|
279
|
+
public function before() {}
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
/**
|
284
|
+
|
285
|
+
* The default view method
|
286
|
+
|
287
|
+
* Should set all expected variables upon itself
|
288
|
+
|
289
|
+
*/
|
290
|
+
|
291
|
+
public function view() {}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
/**
|
296
|
+
|
297
|
+
* Executed after the view method
|
298
|
+
|
299
|
+
*/
|
300
|
+
|
301
|
+
public function after() {}
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
/**
|
306
|
+
|
307
|
+
* Fetches an existing value from the template
|
308
|
+
|
309
|
+
*
|
310
|
+
|
311
|
+
* @return mixed
|
312
|
+
|
313
|
+
*/
|
314
|
+
|
315
|
+
public function & __get($name)
|
316
|
+
|
317
|
+
{
|
318
|
+
|
319
|
+
return $this->get($name);
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
/**
|
326
|
+
|
327
|
+
* Gets a variable from the template
|
328
|
+
|
329
|
+
*
|
330
|
+
|
331
|
+
* @param string
|
332
|
+
|
333
|
+
*/
|
334
|
+
|
335
|
+
public function & get($key = null, $default = null)
|
336
|
+
|
337
|
+
{
|
338
|
+
|
339
|
+
if (is_null($default) and func_num_args() === 1)
|
340
|
+
|
341
|
+
{
|
342
|
+
|
343
|
+
return $this->_view->get($key);
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
return $this->_view->get($key, $default);
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
/**
|
354
|
+
|
355
|
+
* Sets and sanitizes a variable on the template
|
356
|
+
|
357
|
+
*
|
358
|
+
|
359
|
+
* @param string
|
360
|
+
|
361
|
+
* @param mixed
|
362
|
+
|
363
|
+
*/
|
364
|
+
|
365
|
+
public function __set($key, $value)
|
366
|
+
|
367
|
+
{
|
368
|
+
|
369
|
+
return $this->set($key, $value);
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
/**
|
376
|
+
|
377
|
+
* Sets a variable on the template
|
378
|
+
|
379
|
+
*
|
380
|
+
|
381
|
+
* @param string
|
382
|
+
|
383
|
+
* @param mixed
|
384
|
+
|
385
|
+
* @param bool|null
|
386
|
+
|
387
|
+
*/
|
388
|
+
|
389
|
+
public function set($key, $value = null, $filter = null)
|
390
|
+
|
391
|
+
{
|
392
|
+
|
393
|
+
is_null($filter) and $filter = $this->_auto_filter;
|
394
|
+
|
395
|
+
$this->_view->set($key, $value, $filter);
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
return $this;
|
400
|
+
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
/**
|
406
|
+
|
407
|
+
* Magic method, determines if a variable is set.
|
408
|
+
|
409
|
+
*
|
410
|
+
|
411
|
+
* isset($view->foo);
|
412
|
+
|
413
|
+
*
|
414
|
+
|
415
|
+
* @param string variable name
|
416
|
+
|
417
|
+
* @return boolean
|
418
|
+
|
419
|
+
*/
|
420
|
+
|
421
|
+
public function __isset($key)
|
422
|
+
|
423
|
+
{
|
424
|
+
|
425
|
+
return isset($this->_view->$key);
|
426
|
+
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
/**
|
432
|
+
|
433
|
+
* Assigns a value by reference. The benefit of binding is that values can
|
434
|
+
|
435
|
+
* be altered without re-setting them. It is also possible to bind variables
|
436
|
+
|
437
|
+
* before they have values. Assigned values will be available as a
|
438
|
+
|
439
|
+
* variable within the view file:
|
440
|
+
|
441
|
+
*
|
442
|
+
|
443
|
+
* $this->bind('ref', $bar);
|
444
|
+
|
445
|
+
*
|
446
|
+
|
447
|
+
* @param string variable name
|
448
|
+
|
449
|
+
* @param mixed referenced variable
|
450
|
+
|
451
|
+
* @param bool Whether to filter the var on output
|
452
|
+
|
453
|
+
* @return $this
|
454
|
+
|
455
|
+
*/
|
456
|
+
|
457
|
+
public function bind($key, &$value, $filter = null)
|
458
|
+
|
459
|
+
{
|
460
|
+
|
461
|
+
$this->_view->bind($key, $value, $filter);
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
return $this;
|
466
|
+
|
467
|
+
}
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
/**
|
472
|
+
|
473
|
+
* Change auto filter setting
|
474
|
+
|
475
|
+
*
|
476
|
+
|
477
|
+
* @param null|bool change setting (bool) or get the current setting (null)
|
478
|
+
|
479
|
+
* @return void|bool returns current setting or nothing when it is changed
|
480
|
+
|
481
|
+
*/
|
482
|
+
|
483
|
+
public function auto_filter($setting = null)
|
484
|
+
|
485
|
+
{
|
486
|
+
|
487
|
+
if (func_num_args() == 0)
|
488
|
+
|
489
|
+
{
|
490
|
+
|
491
|
+
return $this->_view->auto_filter();
|
492
|
+
|
493
|
+
}
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
return $this->_view->auto_filter($setting);
|
498
|
+
|
499
|
+
}
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
/**
|
506
|
+
|
507
|
+
* Add variables through method and after() and create template as a string
|
508
|
+
|
509
|
+
*/
|
510
|
+
|
511
|
+
public function render()
|
512
|
+
|
513
|
+
{
|
514
|
+
|
515
|
+
if (class_exists('Request', false))
|
516
|
+
|
517
|
+
{
|
518
|
+
|
519
|
+
$current_request = Request::active();
|
520
|
+
|
521
|
+
Request::active($this->_active_request);
|
522
|
+
|
523
|
+
}
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
$this->before();
|
528
|
+
|
529
|
+
$this->{$this->_method}();
|
530
|
+
|
531
|
+
$this->after();
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
$return = $this->_view->render();
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
if (class_exists('Request', false))
|
540
|
+
|
541
|
+
{
|
542
|
+
|
543
|
+
Request::active($current_request);
|
544
|
+
|
545
|
+
}
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
return $return;
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
/**
|
556
|
+
|
557
|
+
* Auto-render on toString
|
558
|
+
|
559
|
+
*/
|
560
|
+
|
561
|
+
public function __toString()
|
562
|
+
|
563
|
+
{
|
564
|
+
|
565
|
+
try
|
566
|
+
|
567
|
+
{
|
568
|
+
|
569
|
+
return $this->render();
|
570
|
+
|
571
|
+
}
|
572
|
+
|
573
|
+
catch (\Exception $e)
|
574
|
+
|
575
|
+
{
|
576
|
+
|
577
|
+
\Error::exception_handler($e);
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
return '';
|
582
|
+
|
583
|
+
}
|
584
|
+
|
585
|
+
}
|
586
|
+
|
587
|
+
}
|
588
|
+
|
589
|
+
```
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
|
594
|
+
|
29
595
|
viewファイル
|
30
596
|
|
31
597
|
```ここに言語を入力
|
@@ -98,606 +664,26 @@
|
|
98
664
|
|
99
665
|
```
|
100
666
|
|
101
|
-
|
102
|
-
|
103
|
-
ここの変数をviewsに渡しています。
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
この時に
|
108
|
-
|
109
|
-
viewファイルが三回読み込みされていてクエリが重複して発行されています。
|
110
|
-
|
111
|
-
veiwファイルが何回も読み込まれる原因は何でしょうか。。?
|
112
|
-
|
113
|
-
SQLなどの問題ではないのは確認済みです。
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
667
|
+
追記
|
118
|
-
|
668
|
+
|
119
|
-
|
669
|
+
読みこみ回数は
|
120
670
|
|
121
671
|
```ここに言語を入力
|
122
672
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
{
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
* @param string ViewModel classname without View_ prefix or full classname
|
136
|
-
|
137
|
-
* @param string Method to execute
|
138
|
-
|
139
|
-
* @return ViewModel
|
140
|
-
|
141
|
-
*/
|
142
|
-
|
143
|
-
public static function forge($viewmodel, $method = 'view', $auto_filter = null, $view = null)
|
144
|
-
|
145
|
-
{
|
146
|
-
|
147
|
-
// if no custom view is given, make it equal to the viewmodel name
|
148
|
-
|
149
|
-
is_null($view) and $view = $viewmodel;
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
// strip any extensions from the view name to determine the viewmodel to load
|
154
|
-
|
155
|
-
$viewmodel = \Inflector::words_to_upper(str_replace(
|
156
|
-
|
157
|
-
array('/', DS),
|
158
|
-
|
159
|
-
'_',
|
160
|
-
|
161
|
-
strpos($viewmodel, '.') === false ? $viewmodel : substr($viewmodel, 0, -strlen(strrchr($viewmodel, '.')))
|
162
|
-
|
163
|
-
));
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
// determine the viewmodel namespace from the current request context
|
168
|
-
|
169
|
-
$namespace = \Request::active() ? ucfirst(\Request::active()->module) : '';
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
// list of possible viewmodel classnames, start with the namespaced one
|
174
|
-
|
175
|
-
$classes = array($namespace.'\\View_'.$viewmodel);
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
// add the global version if needed
|
180
|
-
|
181
|
-
empty($namespace) or $classes[] = 'View_'.$viewmodel;
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
/**
|
186
|
-
|
187
|
-
* Add non View_ prefixed classnames to the list, for BC reasons
|
188
|
-
|
189
|
-
*
|
190
|
-
|
191
|
-
* @deprecated 1.6
|
192
|
-
|
193
|
-
*/
|
194
|
-
|
195
|
-
$classes[] = $namespace.'\\'.$viewmodel;
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
// and add the global version of that if needed
|
200
|
-
|
201
|
-
empty($namespace) or $classes[] = $viewmodel;
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
// check if we can find one
|
206
|
-
|
207
|
-
foreach ($classes as $class)
|
208
|
-
|
209
|
-
{
|
210
|
-
|
211
|
-
if (class_exists($class))
|
212
|
-
|
213
|
-
{
|
214
|
-
|
215
|
-
return new $class($method, $auto_filter, $view);
|
216
|
-
|
217
|
-
}
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
throw new \OutOfBoundsException('ViewModel "'.reset($classes).'" could not be found.');
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
/**
|
230
|
-
|
231
|
-
* @var string method to execute when rendering
|
232
|
-
|
233
|
-
*/
|
234
|
-
|
235
|
-
protected $_method;
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
/**
|
240
|
-
|
241
|
-
* @var string|View view name, after instantiation a View object
|
242
|
-
|
243
|
-
*/
|
244
|
-
|
245
|
-
protected $_view;
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
/**
|
250
|
-
|
251
|
-
* @var bool whether or not to use auto filtering
|
252
|
-
|
253
|
-
*/
|
254
|
-
|
255
|
-
protected $_auto_filter;
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
/**
|
260
|
-
|
261
|
-
* @var Request active request during ViewModel creation for proper context
|
262
|
-
|
263
|
-
*/
|
264
|
-
|
265
|
-
protected $_active_request;
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
protected function __construct($method, $auto_filter = null, $view = null)
|
270
|
-
|
271
|
-
{
|
272
|
-
|
273
|
-
$this->_auto_filter = $auto_filter;
|
274
|
-
|
275
|
-
$this->_view === null and $this->_view = $view;
|
276
|
-
|
277
|
-
class_exists('Request', false) and $this->_active_request = \Request::active();
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
if (empty($this->_view))
|
282
|
-
|
283
|
-
{
|
284
|
-
|
285
|
-
// Take the class name and guess the view name
|
286
|
-
|
287
|
-
$class = get_class($this);
|
288
|
-
|
289
|
-
$this->_view = strtolower(str_replace('_', DS, preg_replace('#^([a-z0-9_]*\\\\)?(View_)?#i', '', $class)));
|
290
|
-
|
291
|
-
}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
$this->set_view();
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
$this->_method = $method;
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
/**
|
306
|
-
|
307
|
-
* Returns the View object associated with this Viewmodel
|
308
|
-
|
309
|
-
*
|
310
|
-
|
311
|
-
* @return View
|
312
|
-
|
313
|
-
*/
|
314
|
-
|
315
|
-
public function get_view()
|
316
|
-
|
317
|
-
{
|
318
|
-
|
319
|
-
return $this->_view;
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
/**
|
326
|
-
|
327
|
-
* Construct the View object
|
328
|
-
|
329
|
-
*/
|
330
|
-
|
331
|
-
protected function set_view()
|
332
|
-
|
333
|
-
{
|
334
|
-
|
335
|
-
$this->_view instanceOf View or $this->_view = \View::forge($this->_view);
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
/**
|
342
|
-
|
343
|
-
* Returns the active request object.
|
344
|
-
|
345
|
-
*
|
346
|
-
|
347
|
-
* @return Request
|
348
|
-
|
349
|
-
*/
|
350
|
-
|
351
|
-
protected function request()
|
352
|
-
|
353
|
-
{
|
354
|
-
|
355
|
-
return $this->_active_request;
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
/**
|
362
|
-
|
363
|
-
* Executed before the view method
|
364
|
-
|
365
|
-
*/
|
366
|
-
|
367
|
-
public function before() {}
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
/**
|
372
|
-
|
373
|
-
* The default view method
|
374
|
-
|
375
|
-
* Should set all expected variables upon itself
|
376
|
-
|
377
|
-
*/
|
378
|
-
|
379
|
-
public function view() {}
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
/**
|
384
|
-
|
385
|
-
* Executed after the view method
|
386
|
-
|
387
|
-
*/
|
388
|
-
|
389
|
-
public function after() {}
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
/**
|
394
|
-
|
395
|
-
* Fetches an existing value from the template
|
396
|
-
|
397
|
-
*
|
398
|
-
|
399
|
-
* @return mixed
|
400
|
-
|
401
|
-
*/
|
402
|
-
|
403
|
-
public function & __get($name)
|
404
|
-
|
405
|
-
{
|
406
|
-
|
407
|
-
return $this->get($name);
|
408
|
-
|
409
|
-
}
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
/**
|
414
|
-
|
415
|
-
* Gets a variable from the template
|
416
|
-
|
417
|
-
*
|
418
|
-
|
419
|
-
* @param string
|
420
|
-
|
421
|
-
*/
|
422
|
-
|
423
|
-
public function & get($key = null, $default = null)
|
424
|
-
|
425
|
-
{
|
426
|
-
|
427
|
-
if (is_null($default) and func_num_args() === 1)
|
428
|
-
|
429
|
-
{
|
430
|
-
|
431
|
-
return $this->_view->get($key);
|
432
|
-
|
433
|
-
}
|
434
|
-
|
435
|
-
return $this->_view->get($key, $default);
|
436
|
-
|
437
|
-
}
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
/**
|
442
|
-
|
443
|
-
* Sets and sanitizes a variable on the template
|
444
|
-
|
445
|
-
*
|
446
|
-
|
447
|
-
* @param string
|
448
|
-
|
449
|
-
* @param mixed
|
450
|
-
|
451
|
-
*/
|
452
|
-
|
453
|
-
public function __set($key, $value)
|
454
|
-
|
455
|
-
{
|
456
|
-
|
457
|
-
return $this->set($key, $value);
|
458
|
-
|
459
|
-
}
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
/**
|
464
|
-
|
465
|
-
* Sets a variable on the template
|
466
|
-
|
467
|
-
*
|
468
|
-
|
469
|
-
* @param string
|
470
|
-
|
471
|
-
* @param mixed
|
472
|
-
|
473
|
-
* @param bool|null
|
474
|
-
|
475
|
-
*/
|
476
|
-
|
477
|
-
public function set($key, $value = null, $filter = null)
|
478
|
-
|
479
|
-
{
|
480
|
-
|
481
|
-
is_null($filter) and $filter = $this->_auto_filter;
|
482
|
-
|
483
|
-
$this->_view->set($key, $value, $filter);
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
return $this;
|
488
|
-
|
489
|
-
}
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
/**
|
494
|
-
|
495
|
-
* Magic method, determines if a variable is set.
|
496
|
-
|
497
|
-
*
|
498
|
-
|
499
|
-
* isset($view->foo);
|
500
|
-
|
501
|
-
*
|
502
|
-
|
503
|
-
* @param string variable name
|
504
|
-
|
505
|
-
* @return boolean
|
506
|
-
|
507
|
-
*/
|
508
|
-
|
509
|
-
public function __isset($key)
|
510
|
-
|
511
|
-
{
|
512
|
-
|
513
|
-
return isset($this->_view->$key);
|
514
|
-
|
515
|
-
}
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
/**
|
520
|
-
|
521
|
-
* Assigns a value by reference. The benefit of binding is that values can
|
522
|
-
|
523
|
-
* be altered without re-setting them. It is also possible to bind variables
|
524
|
-
|
525
|
-
* before they have values. Assigned values will be available as a
|
526
|
-
|
527
|
-
* variable within the view file:
|
528
|
-
|
529
|
-
*
|
530
|
-
|
531
|
-
* $this->bind('ref', $bar);
|
532
|
-
|
533
|
-
*
|
534
|
-
|
535
|
-
* @param string variable name
|
536
|
-
|
537
|
-
* @param mixed referenced variable
|
538
|
-
|
539
|
-
* @param bool Whether to filter the var on output
|
540
|
-
|
541
|
-
* @return $this
|
542
|
-
|
543
|
-
*/
|
544
|
-
|
545
|
-
public function bind($key, &$value, $filter = null)
|
546
|
-
|
547
|
-
{
|
548
|
-
|
549
|
-
$this->_view->bind($key, $value, $filter);
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
return $this;
|
554
|
-
|
555
|
-
}
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
/**
|
560
|
-
|
561
|
-
* Change auto filter setting
|
562
|
-
|
563
|
-
*
|
564
|
-
|
565
|
-
* @param null|bool change setting (bool) or get the current setting (null)
|
566
|
-
|
567
|
-
* @return void|bool returns current setting or nothing when it is changed
|
568
|
-
|
569
|
-
*/
|
570
|
-
|
571
|
-
public function auto_filter($setting = null)
|
572
|
-
|
573
|
-
{
|
574
|
-
|
575
|
-
if (func_num_args() == 0)
|
576
|
-
|
577
|
-
{
|
578
|
-
|
579
|
-
return $this->_view->auto_filter();
|
580
|
-
|
581
|
-
}
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
return $this->_view->auto_filter($setting);
|
586
|
-
|
587
|
-
}
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
/**
|
594
|
-
|
595
|
-
* Add variables through method and after() and create template as a string
|
596
|
-
|
597
|
-
*/
|
598
|
-
|
599
|
-
public function render()
|
600
|
-
|
601
|
-
{
|
602
|
-
|
603
|
-
if (class_exists('Request', false))
|
604
|
-
|
605
|
-
{
|
606
|
-
|
607
|
-
$current_request = Request::active();
|
608
|
-
|
609
|
-
Request::active($this->_active_request);
|
610
|
-
|
611
|
-
}
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
$this->before();
|
616
|
-
|
617
|
-
$this->{$this->_method}();
|
618
|
-
|
619
|
-
$this->after();
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
$return = $this->_view->render();
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
if (class_exists('Request', false))
|
628
|
-
|
629
|
-
{
|
630
|
-
|
631
|
-
Request::active($current_request);
|
632
|
-
|
633
|
-
}
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
return $return;
|
638
|
-
|
639
|
-
}
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
/**
|
644
|
-
|
645
|
-
* Auto-render on toString
|
646
|
-
|
647
|
-
*/
|
648
|
-
|
649
|
-
public function __toString()
|
650
|
-
|
651
|
-
{
|
652
|
-
|
653
|
-
try
|
654
|
-
|
655
|
-
{
|
656
|
-
|
657
|
-
return $this->render();
|
658
|
-
|
659
|
-
}
|
660
|
-
|
661
|
-
catch (\Exception $e)
|
662
|
-
|
663
|
-
{
|
664
|
-
|
665
|
-
\Error::exception_handler($e);
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
return '';
|
670
|
-
|
671
|
-
}
|
672
|
-
|
673
|
-
}
|
674
|
-
|
675
|
-
}
|
673
|
+
if (!isset($_SESSION['count'])) {
|
674
|
+
|
675
|
+
$_SESSION['count'] = 1;
|
676
|
+
|
677
|
+
} else {
|
678
|
+
|
679
|
+
$_SESSION['count']++;
|
680
|
+
|
681
|
+
}
|
682
|
+
|
683
|
+
var_dump($_SESSION['count']."回読み込み");
|
676
684
|
|
677
685
|
```
|
678
686
|
|
679
|
-
|
680
|
-
|
681
|
-
追記
|
682
|
-
|
683
|
-
読みこみ回数は
|
684
|
-
|
685
|
-
```ここに言語を入力
|
686
|
-
|
687
|
-
if (!isset($_SESSION['count'])) {
|
688
|
-
|
689
|
-
$_SESSION['count'] = 1;
|
690
|
-
|
691
|
-
} else {
|
692
|
-
|
693
|
-
$_SESSION['count']++;
|
694
|
-
|
695
|
-
}
|
696
|
-
|
697
|
-
var_dump($_SESSION['count']."回読み込み");
|
698
|
-
|
699
|
-
```
|
700
|
-
|
701
687
|
にて
|
702
688
|
|
703
689
|
数えました
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
|
7
7
|
他のファイルでも同様なことが起きているので
|
8
8
|
|
9
|
-
何が原因かわからず困っています。。
|
10
|
-
|
11
9
|
|
12
10
|
|
13
11
|
コントローラーより
|
@@ -18,7 +16,7 @@
|
|
18
16
|
|
19
17
|
{
|
20
18
|
|
21
|
-
parent::$_view->set('content', ViewModel::forge('admin/
|
19
|
+
parent::$_view->set('content', ViewModel::forge('admin/member/index')->set("self_admin",self::$_admin));
|
22
20
|
|
23
21
|
parent::$_view->set('title', 'タイトル | '.'サイト名');
|
24
22
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -677,3 +677,29 @@
|
|
677
677
|
}
|
678
678
|
|
679
679
|
```
|
680
|
+
|
681
|
+
|
682
|
+
|
683
|
+
追記
|
684
|
+
|
685
|
+
読みこみ回数は
|
686
|
+
|
687
|
+
```ここに言語を入力
|
688
|
+
|
689
|
+
if (!isset($_SESSION['count'])) {
|
690
|
+
|
691
|
+
$_SESSION['count'] = 1;
|
692
|
+
|
693
|
+
} else {
|
694
|
+
|
695
|
+
$_SESSION['count']++;
|
696
|
+
|
697
|
+
}
|
698
|
+
|
699
|
+
var_dump($_SESSION['count']."回読み込み");
|
700
|
+
|
701
|
+
```
|
702
|
+
|
703
|
+
にて
|
704
|
+
|
705
|
+
数えました
|