-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDeprecatedBrowserComponent.php
More file actions
98 lines (87 loc) · 2.07 KB
/
DeprecatedBrowserComponent.php
File metadata and controls
98 lines (87 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* 非推奨ブラウザ関連 Component
*
* @author Mitsuru Mutaguchi <mutaguchi@opensource-workshop.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('Component', 'Controller');
/**
* 非推奨ブラウザ関連 Component
*
* @property \SessionComponent $Session
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\Auth\Controller\Component
*/
class DeprecatedBrowserComponent extends Component {
/**
* 使用するComponents
*
* @var array
*/
public $components = [
'Session',
];
/**
* コントローラ
*
* @var array
*/
public $controller;
/**
* メッセージ
*
* @var string
*/
private $__flashMessage;
/**
* Called before the Controller::beforeFilter().
*
* @param Controller $controller Instantiating controller
* @return void
*/
public function initialize(Controller $controller) {
$this->controller = $controller;
$this->__flashMessage = __d(
'net_commons',
'Internet Explorer(IE) is deprecated. ' .
'If you are using IE, please change to the latest version such as Edge, Chrome, Firefox, etc.'
);
}
/**
* 非推奨ブラウザのチェック
*
* @return bool
*/
public function isDeprecatedBrowser() {
$browser = strtolower(env('HTTP_USER_AGENT'));
return (strstr($browser, 'trident') || strstr($browser, 'msie'));
}
/**
* 非推奨ブラウザエラーメッセージをセットする
*
* @param strin $message メッセージ
* @return void
*/
public function setFlashMessage(string $message) {
$this->__flashMessage = $message;
}
/**
* 非推奨ブラウザエラーメッセージ
*
* @return void
*/
public function setFlashNotification() {
if ($this->controller->Session->read('NetCommons.DeprecatedBrowser')) {
return;
}
$this->controller->NetCommons->setFlashNotification(
$this->__flashMessage,
['class' => 'danger', 'interval' => 10000]
);
$this->controller->Session->write('NetCommons.DeprecatedBrowser', true);
}
}