CMSimple_XH 開発者ドキュメント
ClassicPluginMenu.php
1 <?php
2 
16 namespace XH;
17 
30 {
36  private $menu;
37 
41  public function __construct()
42  {
43  parent::__construct();
44  $this->menu = '';
45  }
46 
56  public function render($showMain)
57  {
58  $this->makeRow();
59  parent::render($showMain);
60  return $this->show();
61  }
62 
68  protected function makeMainItem()
69  {
70  $this->makeTab(XH_hsc($this->mainUrl), '', $this->mainLabel);
71  }
72 
78  protected function makeStylesheetItem()
79  {
80  $this->makeTab(XH_hsc($this->cssUrl), '', $this->cssLabel);
81  }
82 
88  protected function makeConfigItem()
89  {
90  $this->makeTab(XH_hsc($this->configUrl), '', $this->configLabel);
91  }
92 
98  protected function makeLanguageItem()
99  {
100  $this->makeTab(XH_hsc($this->languageUrl), '', $this->languageLabel);
101  }
102 
108  protected function makeHelpItem()
109  {
110  $this->makeTab(XH_hsc($this->helpUrl), 'target="_blank"', $this->helpLabel);
111  }
112 
120  public function makeRow(array $style = array())
121  {
122  if (!isset($style['row'])) {
123  $style['row'] = 'class="edit" style="width: 100%;"';
124  }
125  $template = '<table {{STYLE_ROW}}>' . "\n"
126  . '<tr>' . "\n" . '{{TAB}}</tr>' . "\n" . '</table>' . "\n" . "\n";
127 
128  $this->menu .= str_replace('{{STYLE_ROW}}', $style['row'], $template);
129  }
130 
141  public function makeTab($link, $target, $text, array $style = array())
142  {
143  if (!isset($style['tab'])) {
144  $style['tab'] = '';
145  }
146  if (!isset($style['link'])) {
147  $style['link'] = '';
148  }
149  $tab = strtr(
150  '<td {{STYLE_TAB}}><a {{STYLE_LINK}} href="{{LINK}}"'
151  . ' {{TARGET}}>{{TEXT}}</a></td>' . "\n",
152  array(
153  '{{STYLE_TAB}}' => $style['tab'],
154  '{{STYLE_LINK}}' => $style['link'],
155  '{{LINK}}' => $link,
156  '{{TARGET}}' => $target,
157  '{{TEXT}}' => $text
158  )
159  );
160  $this->menu = str_replace('{{TAB}}', $tab . '{{TAB}}', $this->menu);
161  }
162 
171  public function makeData($text, array $style = array())
172  {
173  if (!isset($style['data'])) {
174  $style['data'] = '';
175  }
176  $data = strtr(
177  '<td {{STYLE_DATA}}>{{TEXT}}</td>' . "\n",
178  array(
179  '{{STYLE_DATA}}' => $style['data'],
180  '{{TEXT}}' => $text
181  )
182  );
183  $this->menu = str_replace('{{TAB}}', $data . '{{TAB}}', $this->menu);
184  }
185 
191  public function show()
192  {
193  $this->menu = str_replace('{{TAB}}', '', $this->menu);
194  $result = $this->menu;
195  $this->menu = '';
196  return $result;
197  }
198 }
makeData($text, array $style=array())
makeRow(array $style=array())
makeTab($link, $target, $text, array $style=array())
$text
Definition: cms.php:698
XH_hsc($string)
Definition: functions.php:2204