CMSimple_XH 開発者ドキュメント
PluginMenu.php
1 <?php
2 
16 namespace XH;
17 
29 abstract class PluginMenu
30 {
36  protected $scriptName;
37 
43  protected $plugin;
44 
50  protected $mainLabel;
51 
57  protected $cssLabel;
58 
64  protected $configLabel;
65 
71  protected $languageLabel;
72 
78  protected $helpLabel;
79 
85  protected $mainUrl;
86 
92  protected $cssUrl;
93 
99  protected $configUrl;
100 
106  protected $languageUrl;
107 
113  protected $helpUrl;
114 
120  public function __construct()
121  {
122  global $sn;
123 
124  $this->scriptName = $sn;
125  }
126 
137  public function render($showMain)
138  {
139  global $plugin, $pth;
140 
141  $this->plugin = $plugin;
142  pluginFiles($this->plugin);
143  $this->initLabels();
144  $this->initUrls();
145  if ($showMain) {
146  $this->makeMainItem();
147  }
148  if (is_readable($pth['file']['plugin_stylesheet'])) {
149  $this->makeStylesheetItem();
150  }
151  if (is_readable($pth['file']['plugin_config'])) {
152  $this->makeConfigItem();
153  }
154  if (is_readable($pth['file']['plugin_language'])) {
155  $this->makeLanguageItem();
156  }
157  if (is_readable($pth['file']['plugin_help'])) {
158  $this->makeHelpItem($pth['file']['plugin_help']);
159  }
160  }
161 
170  private function initLabels()
171  {
172  global $tx, $plugin_tx;
173 
174  $this->mainLabel = empty($plugin_tx[$this->plugin]['menu_main'])
175  ? $tx['menu']['tab_main']
176  : $plugin_tx[$this->plugin]['menu_main'];
177  $this->cssLabel = empty($plugin_tx[$this->plugin]['menu_css'])
178  ? $tx['menu']['tab_css']
179  : $plugin_tx[$this->plugin]['menu_css'];
180  $this->configLabel = empty($plugin_tx[$this->plugin]['menu_config'])
181  ? $tx['menu']['tab_config']
182  : $plugin_tx[$this->plugin]['menu_config'];
183  $this->languageLabel = empty($plugin_tx[$this->plugin]['menu_language'])
184  ? $tx['menu']['tab_language']
185  : $plugin_tx[$this->plugin]['menu_language'];
186  $this->helpLabel = empty($plugin_tx[$this->plugin]['menu_help'])
187  ? $tx['menu']['tab_help']
188  : $plugin_tx[$this->plugin]['menu_help'];
189  }
190 
198  private function initUrls()
199  {
200  global $pth;
201 
202  $this->mainUrl = $this->scriptName . '?&' . $this->plugin
203  . '&admin=plugin_main&action=plugin_text&normal';
204  $this->cssUrl = $this->scriptName . '?&' . $this->plugin
205  . '&admin=plugin_stylesheet&action=plugin_text&normal';
206  $this->configUrl = $this->scriptName . '?&' . $this->plugin
207  . '&admin=plugin_config&action=plugin_edit&normal';
208  $this->languageUrl = $this->scriptName . '?&' . $this->plugin
209  . '&admin=plugin_language&action=plugin_edit&normal';
210  $this->helpUrl = $pth['file']['plugin_help'];
211  }
212 }
render($showMain)
Definition: PluginMenu.php:137
$plugin
Definition: cms.php:856
pluginFiles($plugin)
Definition: functions.php:1377
$plugin_tx
Definition: cms.php:1095
$sn
Definition: cms.php:434
$tx
Definition: cms.php:363
$pth
Definition: cms.php:230