|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* RisolutoViewTrait |
|
4
|
|
|
* |
|
5
|
|
|
* View関連用メソッドTrait |
|
6
|
|
|
* |
|
7
|
|
|
* @package risoluto |
|
8
|
|
|
* @author Risoluto Developers |
|
9
|
|
|
* @license http://opensource.org/licenses/bsd-license.php new BSD license |
|
10
|
|
|
* @copyright (C) 2008-2015 Risoluto Developers / All Rights Reserved. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
//------------------------------------------------------// |
|
14
|
|
|
// 名前空間の定義 |
|
15
|
|
|
//------------------------------------------------------// |
|
16
|
|
|
namespace Risoluto; |
|
17
|
|
|
|
|
18
|
|
|
trait RisolutoViewTrait |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* risolutoView(array $assign_values, $mode = 'view', $path = '', $name = '', array $options = [ ], array $extres = [ ]) |
|
22
|
|
|
* |
|
23
|
|
|
* Viewに関する処理を実行する(ヘルパーメソッド) |
|
24
|
|
|
* |
|
25
|
|
|
* @access private |
|
26
|
|
|
* |
|
27
|
|
|
* @param array $assign_values テンプレートへのアサイン内容 |
|
28
|
|
|
* @param string $mode モード(view:そのまま表示/fetch:表示内容を取得) |
|
29
|
|
|
* @param string $path テンプレートのパス |
|
30
|
|
|
* @param string $name テンプレートファイル名 |
|
31
|
|
|
* @param array $options initTemplateに引き渡すオプション |
|
32
|
|
|
* @param array $extres initTemplateに引き渡す外部リソース情報 |
|
33
|
|
|
* |
|
34
|
|
|
* @return mixed $mode=view:常にtrue / $mode=fetch:表示内容/想定外の場合:false |
|
35
|
|
|
*/ |
|
36
|
|
|
private function risolutoView( |
|
37
|
|
|
array $assign_values = [ ], |
|
38
|
|
|
$mode = 'view', |
|
39
|
|
|
$path = '', |
|
40
|
|
|
$name = '', |
|
41
|
|
|
array $options = [ ], |
|
42
|
|
|
array $extres = [ ] |
|
43
|
|
|
) { |
|
44
|
|
|
// 呼び出し元クラスの情報を取得 |
|
45
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
46
|
|
|
if ($path) { |
|
47
|
|
|
$tmpl_path = str_replace( DS . DS, DS, DS . str_replace( '../', '', $path ) . DS ); |
|
48
|
|
|
} else { |
|
49
|
|
|
$tmpl_path = str_replace( 'RisolutoApps', '', str_replace( '\\', DS, $called->getNamespaceName() ) . DS ); |
|
50
|
|
|
} |
|
51
|
|
|
if ($name) { |
|
52
|
|
|
$tmpl_name = $name; |
|
53
|
|
|
} else { |
|
54
|
|
|
$tmpl_name = $called->getShortName() . '.tpl'; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
// テンプレートエンジンを初期設定してインスタンスを取得 |
|
58
|
|
|
$tmpl_instance = $this->initTemplate( $tmpl_path, $options, $extres ); |
|
59
|
|
|
|
|
60
|
|
|
// テンプレートに値をアサイン |
|
61
|
|
|
$this->assignTemplate( $tmpl_instance, $assign_values ); |
|
62
|
|
|
|
|
63
|
|
|
// テンプレート処理を実行して結果を返す |
|
64
|
|
|
return $this->dispTemplate( $tmpl_instance, $tmpl_name, $mode ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* initTemplate($tmpl_path = '', array $options = [ ], array $extres = [ ]) |
|
69
|
|
|
* |
|
70
|
|
|
* テンプレートエンジンのインスタンスを生成する |
|
71
|
|
|
* |
|
72
|
|
|
* @access private |
|
73
|
|
|
* |
|
74
|
|
|
* @param string $tmpl_path テンプレートファイルが格納されているディレクトリのパス |
|
75
|
|
|
* @param array $options Smartyに引き渡すオプション |
|
76
|
|
|
* @param array $extres 外部リソースの定義 |
|
77
|
|
|
* |
|
78
|
|
|
* @return object テンプレートエンジンのインスタンス |
|
79
|
|
|
*/ |
|
80
|
|
|
private function initTemplate( |
|
81
|
|
|
$tmpl_path = '', |
|
82
|
|
|
array $options = [ |
|
83
|
|
|
'cache' => [ |
|
84
|
|
|
'lifetime' => 3600, |
|
85
|
|
|
], |
|
86
|
|
|
'compile' => [ |
|
87
|
|
|
'check' => true, |
|
88
|
|
|
'force' => false, |
|
89
|
|
|
], |
|
90
|
|
|
'debug' => [ |
|
91
|
|
|
'enable' => false, |
|
92
|
|
|
'ctrl' => 'NONE', |
|
93
|
|
|
], |
|
94
|
|
|
], |
|
95
|
|
|
array $extres = [ ] |
|
96
|
|
|
) { |
|
97
|
|
|
// テンプレートパスをアプリケーション格納フォルダ配下に限定 |
|
98
|
|
|
$tmpl_path = str_replace( DS . DS, DS, RISOLUTO_APPS . 'RisolutoApps/' . str_replace( '../', '', $tmpl_path )); |
|
99
|
|
|
|
|
100
|
|
|
// テンプレートエンジン関連定義(Smartyを使用) |
|
101
|
|
|
$tmpl = new \Smarty; |
|
102
|
|
|
|
|
103
|
|
|
//--- テンプレートキャッシュの設定 |
|
104
|
|
|
$tmpl->setCacheDir( RISOLUTO_CACHE ); |
|
105
|
|
|
$tmpl->cache_lifetime = ( isset( $options[ 'cache' ][ 'lifetime' ] ) ? $options[ 'cache' ][ 'lifetime' ] : 3600 ); |
|
106
|
|
|
|
|
107
|
|
|
//--- コンパイル済みテンプレートの設定 |
|
108
|
|
|
$tmpl->setCompileDir( RISOLUTO_CACHE ); |
|
109
|
|
|
$tmpl->compile_check = ( isset( $options[ 'compile' ][ 'check' ] ) ? $options[ 'compile' ][ 'check' ] : true ); |
|
110
|
|
|
$tmpl->force_compile = ( isset( $options[ 'compile' ][ 'force' ] ) ? $options[ 'compile' ][ 'force' ] : false ); |
|
111
|
|
|
|
|
112
|
|
|
//--- テンプレート用コンフィグファイルの設定 |
|
113
|
|
|
$tmpl->setConfigDir( $tmpl_path ); |
|
114
|
|
|
|
|
115
|
|
|
//--- テンプレートのデバッグ設定 |
|
116
|
|
|
$tmpl->debugging = ( isset( $options[ 'debug' ][ 'enable' ] ) ? $options[ 'debug' ][ 'enable' ] : false ); |
|
117
|
|
|
$tmpl->debugging_ctrl = ( isset( $options[ 'debug' ][ 'ctrl' ] ) ? $options[ 'debug' ][ 'ctrl' ] : 'NONE' ); |
|
118
|
|
|
|
|
119
|
|
|
//--- テンプレートファイルのパス |
|
120
|
|
|
$tmpl->setTemplateDir( $tmpl_path ); |
|
121
|
|
|
|
|
122
|
|
|
// 外部リソースの登録 |
|
123
|
|
|
if (isset( $extres )) { |
|
124
|
|
|
foreach ($extres as $dat) { |
|
125
|
|
|
if (isset( $dat[ 'name' ] ) and isset( $dat[ 'class' ] )) { |
|
126
|
|
|
$tmpl->register_resource( |
|
127
|
|
|
$dat[ 'name' ], |
|
128
|
|
|
[ $dat[ 'class' ], 'getTemplate', 'getTimeStamp', 'getSecure', 'getTrusted' ] |
|
129
|
|
|
); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
return $tmpl; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* assignTemplate(\Smarty $tmpl_instance,array $values) |
|
140
|
|
|
* |
|
141
|
|
|
* テンプレートに表示内容をアサインする |
|
142
|
|
|
* |
|
143
|
|
|
* @access private |
|
144
|
|
|
* |
|
145
|
|
|
* @param \Smarty $tmpl_instance テンプレートエンジンのインスタンス |
|
146
|
|
|
* @param array $values アサイン内容 |
|
147
|
|
|
* |
|
148
|
|
|
* @return boolean 常にtrue |
|
149
|
|
|
*/ |
|
150
|
|
|
private function assignTemplate( \Smarty $tmpl_instance, array $values ) |
|
151
|
|
|
{ |
|
152
|
|
|
// デフォルトでテンプレートに引き渡す情報 |
|
153
|
|
|
$tmpl_instance->assign( '__RISOLUTO_APPS', RISOLUTO_APPS ); |
|
154
|
|
|
|
|
155
|
|
|
// 与えられた引数の内容をテンプレートにアサインする |
|
156
|
|
|
foreach ($values as $key => $val) { |
|
157
|
|
|
$tmpl_instance->assign( $key, $val ); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
// 戻り値を返却 |
|
161
|
|
|
return true; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* dispTemplate(\Smarty $tmpl_instance, $tmpl_name, $mode = 'view') |
|
166
|
|
|
* |
|
167
|
|
|
* テンプレートを表示または表示内容を取得する |
|
168
|
|
|
* |
|
169
|
|
|
* @access private |
|
170
|
|
|
* |
|
171
|
|
|
* @param \Smarty $tmpl_instance テンプレートエンジンのインスタンス |
|
172
|
|
|
* @param string $tmpl_name テンプレート名 |
|
173
|
|
|
* @param string $mode モード(view:そのまま表示/fetch:表示内容を取得) |
|
174
|
|
|
* |
|
175
|
|
|
* @return mixed $mode=view:常にtrue / $mode=fetch:表示内容/想定外の場合:false |
|
176
|
|
|
*/ |
|
177
|
|
|
private function dispTemplate( |
|
178
|
|
|
\Smarty $tmpl_instance, |
|
179
|
|
|
$tmpl_name, |
|
180
|
|
|
$mode = 'view' |
|
181
|
|
|
) { |
|
182
|
|
|
// $modeに応じて呼び出すメソッドを変更する |
|
183
|
|
|
switch ($mode) { |
|
184
|
|
|
// 変数格納時の時 |
|
185
|
|
|
case 'fetch': |
|
186
|
|
|
$retval = $tmpl_instance->fetch( $tmpl_name ); |
|
187
|
|
|
break; |
|
188
|
|
|
|
|
189
|
|
|
// 画面表示の時(デフォルト) |
|
190
|
|
|
case 'view': // FALL THRU |
|
191
|
|
|
default: |
|
192
|
|
|
$tmpl_instance->display( $tmpl_name ); |
|
193
|
|
|
$retval = true; |
|
194
|
|
|
break; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
// 戻り値を返却 |
|
198
|
|
|
return $retval; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* getDefaultHeader() |
|
203
|
|
|
* |
|
204
|
|
|
* デフォルトのヘッダ情報が格納された配列を返却する |
|
205
|
|
|
* |
|
206
|
|
|
* @access private |
|
207
|
|
|
* |
|
208
|
|
|
* @param void |
|
209
|
|
|
* |
|
210
|
|
|
* @return array デフォルトのヘッダ |
|
211
|
|
|
*/ |
|
212
|
|
|
private function getDefaultHeader() |
|
213
|
|
|
{ |
|
214
|
|
|
// Risolutoのコンフィグからテーマの情報を取得する |
|
215
|
|
|
$conf = new Conf(); |
|
216
|
|
|
$conf->parse( RISOLUTO_CONF . 'risoluto.ini' ); |
|
217
|
|
|
$outboards = $conf->getIni( 'THEME', 'outboards' ); |
|
218
|
|
|
|
|
219
|
|
|
return [ |
|
220
|
|
|
'robots' => $this->getDefaultHeaderRobots(), // robots |
|
221
|
|
|
'description' => $this->getDefaultHeaderDescription(), // Description |
|
222
|
|
|
'keywords' => $this->getDefaultHeaderKeywords(), // Keywords |
|
223
|
|
|
'author' => $this->getDefaultHeaderAuthor(), // Author |
|
224
|
|
|
'css' => $this->getDefaultHeaderCss( $outboards ), // CSS |
|
225
|
|
|
'js' => $this->getDefaultHeaderJavaScript( $outboards ), // JavaScript |
|
226
|
|
|
'favicon' => $this->getDefaultHeaderFavicon( $outboards ), // Favicon |
|
227
|
|
|
'title' => $this->getDefaultHeaderTitle(), // Title |
|
228
|
|
|
'outboards' => $outboards, // テーマ格納ディレクトリ名 |
|
229
|
|
|
]; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* replaceHeader() |
|
235
|
|
|
* |
|
236
|
|
|
* ヘッダ情報を置き換える |
|
237
|
|
|
* |
|
238
|
|
|
* @access private |
|
239
|
|
|
* |
|
240
|
|
|
* @param array $target ヘッダ情報がセットされた配列(GetDefaultHeader()の戻り値など) |
|
241
|
|
|
* @param string $key 置き換えるヘッダのキー |
|
242
|
|
|
* @param string $val 置き換える値 |
|
243
|
|
|
* |
|
244
|
|
|
* @return array 変更後のヘッダ情報がセットされた配列 / false: 変更失敗 |
|
245
|
|
|
*/ |
|
246
|
|
|
private function replaceHeader( array $target, $key, $val ) |
|
247
|
|
|
{ |
|
248
|
|
|
// ヘッダ情報の格納された配列が存在しなければ即時戻る |
|
249
|
|
|
if (empty( $target )) { |
|
250
|
|
|
return false; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
// 既存の項目が存在していたら置き換え、存在していなければ失敗とみなす |
|
254
|
|
|
if (array_key_exists( $key, $target )) { |
|
255
|
|
|
$target[ $key ] = $val; |
|
256
|
|
|
} else { |
|
257
|
|
|
return false; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
return $target; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* getDefaultHeaderRobots() |
|
265
|
|
|
* |
|
266
|
|
|
* デフォルトのヘッダ情報(robots)を返却する |
|
267
|
|
|
* |
|
268
|
|
|
* @access private |
|
269
|
|
|
* |
|
270
|
|
|
* @param void |
|
271
|
|
|
* |
|
272
|
|
|
* @return string デフォルトのヘッダ(robots) |
|
273
|
|
|
*/ |
|
274
|
|
|
private function getDefaultHeaderRobots() |
|
275
|
|
|
{ |
|
276
|
|
|
// 親クラスの情報を取得 |
|
277
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
278
|
|
|
$parent = $called->getParentClass(); |
|
279
|
|
|
|
|
280
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
281
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderRobots' )) { |
|
282
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
283
|
|
|
return parent::getUserHeaderRobots(); |
|
|
|
|
|
|
284
|
|
|
} else { |
|
285
|
|
|
return 'INDEX,FOLLOW'; |
|
286
|
|
|
} |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* getDefaultHeaderDescription() |
|
291
|
|
|
* |
|
292
|
|
|
* デフォルトのヘッダ情報(description)を返却する |
|
293
|
|
|
* |
|
294
|
|
|
* @access private |
|
295
|
|
|
* |
|
296
|
|
|
* @param void |
|
297
|
|
|
* |
|
298
|
|
|
* @return string デフォルトのヘッダ(description) |
|
299
|
|
|
*/ |
|
300
|
|
|
private function getDefaultHeaderDescription() |
|
301
|
|
|
{ |
|
302
|
|
|
// 親クラスの情報を取得 |
|
303
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
304
|
|
|
$parent = $called->getParentClass(); |
|
305
|
|
|
|
|
306
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
307
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderDescription' )) { |
|
308
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
309
|
|
|
return parent::getUserHeaderDescription(); |
|
|
|
|
|
|
310
|
|
|
} else { |
|
311
|
|
|
return 'Risoluto'; |
|
312
|
|
|
} |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
/** |
|
316
|
|
|
* getDefaultHeaderKeywords() |
|
317
|
|
|
* |
|
318
|
|
|
* デフォルトのヘッダ情報(keywords)を返却する |
|
319
|
|
|
* |
|
320
|
|
|
* @access private |
|
321
|
|
|
* |
|
322
|
|
|
* @param void |
|
323
|
|
|
* |
|
324
|
|
|
* @return string デフォルトのヘッダ(keywords) |
|
325
|
|
|
*/ |
|
326
|
|
|
private function getDefaultHeaderKeywords() |
|
327
|
|
|
{ |
|
328
|
|
|
// 親クラスの情報を取得 |
|
329
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
330
|
|
|
$parent = $called->getParentClass(); |
|
331
|
|
|
|
|
332
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
333
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderKeywords' )) { |
|
334
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
335
|
|
|
return parent::getUserHeaderKeywords(); |
|
|
|
|
|
|
336
|
|
|
} else { |
|
337
|
|
|
return 'Risoluto'; |
|
338
|
|
|
} |
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
|
|
/** |
|
342
|
|
|
* getDefaultHeaderAuthor() |
|
343
|
|
|
* |
|
344
|
|
|
* デフォルトのヘッダ情報(author)を返却する |
|
345
|
|
|
* |
|
346
|
|
|
* @access private |
|
347
|
|
|
* |
|
348
|
|
|
* @param void |
|
349
|
|
|
* |
|
350
|
|
|
* @return string デフォルトのヘッダ(author) |
|
351
|
|
|
*/ |
|
352
|
|
|
private function getDefaultHeaderAuthor() |
|
353
|
|
|
{ |
|
354
|
|
|
// 親クラスの情報を取得 |
|
355
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
356
|
|
|
$parent = $called->getParentClass(); |
|
357
|
|
|
|
|
358
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
359
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderAuthor' )) { |
|
360
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
361
|
|
|
return parent::getUserHeaderAuthor(); |
|
|
|
|
|
|
362
|
|
|
} else { |
|
363
|
|
|
return 'Risoluto'; |
|
364
|
|
|
} |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
/** |
|
368
|
|
|
* getDefaultHeaderCss() |
|
369
|
|
|
* |
|
370
|
|
|
* デフォルトのヘッダ情報(CSS)を返却する |
|
371
|
|
|
* |
|
372
|
|
|
* @access private |
|
373
|
|
|
* |
|
374
|
|
|
* @param string $outboards テーマ格納ディレクトリ名 |
|
375
|
|
|
* |
|
376
|
|
|
* @return string デフォルトのヘッダ(CSS) |
|
377
|
|
|
*/ |
|
378
|
|
View Code Duplication |
private function getDefaultHeaderCss( $outboards ) |
|
|
|
|
|
|
379
|
|
|
{ |
|
380
|
|
|
// 親クラスの情報を取得 |
|
381
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
382
|
|
|
$parent = $called->getParentClass(); |
|
383
|
|
|
|
|
384
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
385
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderCss' )) { |
|
386
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
387
|
|
|
return parent::getUserHeaderCss(); |
|
|
|
|
|
|
388
|
|
|
} else { |
|
389
|
|
|
return [ |
|
390
|
|
|
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css', |
|
391
|
|
|
'/outboards/' . $outboards . '/css/common.css' |
|
392
|
|
|
]; |
|
393
|
|
|
} |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
/** |
|
397
|
|
|
* getDefaultHeaderJavaScript() |
|
398
|
|
|
* |
|
399
|
|
|
* デフォルトのヘッダ情報(JavaScript)を返却する |
|
400
|
|
|
* |
|
401
|
|
|
* @access private |
|
402
|
|
|
* |
|
403
|
|
|
* @param string $outboards テーマ格納ディレクトリ名 |
|
404
|
|
|
* |
|
405
|
|
|
* @return string デフォルトのヘッダ(JavaScript) |
|
406
|
|
|
*/ |
|
407
|
|
View Code Duplication |
private function getDefaultHeaderJavaScript( $outboards ) |
|
|
|
|
|
|
408
|
|
|
{ |
|
409
|
|
|
// 親クラスの情報を取得 |
|
410
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
411
|
|
|
$parent = $called->getParentClass(); |
|
412
|
|
|
|
|
413
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
414
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderJs' )) { |
|
415
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
416
|
|
|
return parent::getUserHeaderJs(); |
|
|
|
|
|
|
417
|
|
|
} else { |
|
418
|
|
|
return [ |
|
419
|
|
|
'//code.jquery.com/jquery-2.1.1.min.js', |
|
420
|
|
|
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js', |
|
421
|
|
|
'/outboards/' . $outboards . '/js/common.js', |
|
422
|
|
|
]; |
|
423
|
|
|
} |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
/** |
|
427
|
|
|
* getDefaultHeaderFavicon() |
|
428
|
|
|
* |
|
429
|
|
|
* デフォルトのヘッダ情報(favicon)を返却する |
|
430
|
|
|
* |
|
431
|
|
|
* @access private |
|
432
|
|
|
* |
|
433
|
|
|
* @param string $outboards テーマ格納ディレクトリ名 |
|
434
|
|
|
* |
|
435
|
|
|
* @return string デフォルトのヘッダ(favicon) |
|
436
|
|
|
*/ |
|
437
|
|
View Code Duplication |
private function getDefaultHeaderFavicon( $outboards ) |
|
|
|
|
|
|
438
|
|
|
{ |
|
439
|
|
|
// 親クラスの情報を取得 |
|
440
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
441
|
|
|
$parent = $called->getParentClass(); |
|
442
|
|
|
|
|
443
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
444
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderFavicon' )) { |
|
445
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
446
|
|
|
return parent::getUserHeaderFavicon(); |
|
|
|
|
|
|
447
|
|
|
} else { |
|
448
|
|
|
return '/outboards/' . $outboards . '/img/favicon.ico'; |
|
449
|
|
|
} |
|
450
|
|
|
} |
|
451
|
|
|
|
|
452
|
|
|
/** |
|
453
|
|
|
* getDefaultHeaderTitle() |
|
454
|
|
|
* |
|
455
|
|
|
* デフォルトのヘッダ情報(title)を返却する |
|
456
|
|
|
* |
|
457
|
|
|
* @access private |
|
458
|
|
|
* |
|
459
|
|
|
* @param void |
|
460
|
|
|
* |
|
461
|
|
|
* @return string デフォルトのヘッダ(title) |
|
462
|
|
|
*/ |
|
463
|
|
|
private function getDefaultHeaderTitle() |
|
464
|
|
|
{ |
|
465
|
|
|
// 親クラスの情報を取得 |
|
466
|
|
|
$called = new \ReflectionClass( get_called_class() ); |
|
467
|
|
|
$parent = $called->getParentClass(); |
|
468
|
|
|
|
|
469
|
|
|
// 基底クラスでオーバーライド用メソッドが定義されていたらそちらを優先する |
|
470
|
|
|
if (method_exists( $parent->getName(), 'getUserHeaderTitle' )) { |
|
471
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
472
|
|
|
return parent::getUserHeaderTitle(); |
|
|
|
|
|
|
473
|
|
|
} else { |
|
474
|
|
|
return 'ようこそ!Risolutoの世界へ!'; |
|
475
|
|
|
} |
|
476
|
|
|
} |
|
477
|
|
|
} |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.