-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSystemManagerHelper.php
More file actions
175 lines (157 loc) · 4.06 KB
/
SystemManagerHelper.php
File metadata and controls
175 lines (157 loc) · 4.06 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* SystemManager Helper
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('AppHelper', 'View/Helper');
/**
* システム管理ヘルパー
*
* @author Shohei Nakajima <nakajimashouhei@gmail.com>
* @package NetCommons\SystemManager\View\Helper
*/
class SystemManagerHelper extends AppHelper {
/**
* 使用するヘルパー
*
* @var array
*/
public $helpers = array(
'SiteManager.SiteManager',
'NetCommons.NetCommonsForm',
'NetCommons.NetCommonsHtml',
);
/**
* タブ
*
* @var array
*/
protected $_tabs = array(
'system_manager' => array(
'controller' => 'system_manager',
'action' => 'edit',
),
'auth_settings' => array(
'controller' => 'auth_settings',
'action' => 'edit',
),
'web_server' => array(
'controller' => 'web_server',
'action' => 'edit',
),
'mail_server' => array(
'controller' => 'mail_server',
'action' => 'edit',
),
'security_settings' => array(
'controller' => 'security_settings',
'action' => 'edit',
),
'developer' => array(
'controller' => 'developer',
'action' => 'edit',
),
);
/**
* SiteManagerHelperラップ用マジックメソッド。
*
* @param string $method メソッド
* @param array $params パラメータ
* @return mixed
*/
public function __call($method, $params) {
return call_user_func_array(array($this->SiteManager, $method), $params);
}
/**
* Before render callback. beforeRender is called before the view file is rendered.
*
* Overridden in subclasses.
*
* @param string $viewFile The view file that is going to be rendered
* @return void
*/
public function beforeRender($viewFile) {
$this->NetCommonsHtml->css(array(
'/site_manager/css/style.css'
));
$this->NetCommonsHtml->script(array(
'/system_manager/js/system_manager.js'
));
parent::beforeRender($viewFile);
}
/**
* タブの出力
*
* @param string|null $active アクティブタブ
* @return string HTML
*/
public function tabs($active = null) {
if (! isset($active)) {
$active = $this->_View->request->params['controller'];
}
// 外部認証プラグイン(AuthXXX)がなければ、ログイン設定タブを除外
if (! Hash::get($this->_View->viewVars, 'useAuthSettingTab')) {
unset($this->_tabs['auth_settings']);
}
$output = '';
$output .= '<ul class="nav nav-tabs" role="tablist">';
foreach ($this->_tabs as $key => $tab) {
$output .= '<li class="' . ($key === $active ? 'active' : '') . '">';
$output .= $this->NetCommonsHtml->link(__d('system_manager', 'Tab.' . $key), $tab);
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
/**
* inputタグ
*
* @param string $model モデル名
* @param string $key キー
* @param array $options オプション
* @return string HTML
*/
public function inputCommon($model, $key, $options = array()) {
return $this->SiteManager->inputCommon($model, $key, $options);
}
/**
* inputタグ(言語)
*
* @param string $model モデル名
* @param string $key キー
* @param array $options オプション
* @return string HTML
*/
public function inputLanguage($model, $key, $options = array()) {
return $this->SiteManager->inputLanguage($model, $key, $options);
}
/**
* Authタブの出力
*
* @return string HTML
*/
public function authTabs() {
$output = '';
$output .= '<ul class="nav nav-pills" role="tablist">';
$active = Hash::get($this->_View->viewVars, 'activeAuthTab');
foreach ($this->_View->viewVars['authTabs'] as $key => $tab) {
if ($key === $active) {
$output .= '<li class="active">';
} else {
$output .= '<li>';
}
$output .= '<a href="#' . $key . '" aria-controls="' . $key . '" role="tab" data-toggle="tab" ' .
'ng-click="' . $this->domId('activeAuthTab') . ' = \'' . $key . '\'">';
$output .= $tab['label'];
$output .= '</a>';
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
}