| 1 |
<?php |
| 2 |
|
| 3 |
namespace ResponsiveMenu\ViewModels\Components\Admin; |
| 4 |
|
| 5 |
class Tabs { |
| 6 |
|
| 7 |
private $config; |
| 8 |
private $current_tab; |
| 9 |
|
| 10 |
public function __construct(array $config, $current_tab) { |
| 11 |
$this->config = $config; |
| 12 |
$this->current_tab = $current_tab; |
| 13 |
} |
| 14 |
|
| 15 |
public function render() { |
| 16 |
$output = ''; |
| 17 |
foreach(array_keys($this->config) as $tab_name) { |
| 18 |
$active_class = $this->i($tab_name) == $this->current_tab ? ' active_tab' : ''; |
| 19 |
$output .= '<a id="tab_' . $this->i($tab_name) . '" class="tab page-title-action' . $active_class . '">' . $tab_name . '</a>'; |
| 20 |
} |
| 21 |
return $output; |
| 22 |
} |
| 23 |
|
| 24 |
public function i($data) { |
| 25 |
return strtolower(str_replace([' ', '/'], '_', $data)); |
| 26 |
} |
| 27 |
|
| 28 |
} |
| 29 |
|