block.tab.php
Блок «Вкладки»
Вызывается из:
Исходный код
<?php
ob_start();
$switcher = null;
if (isset($block['data']['list']) && is_array($block['data']['list'])) foreach ($block['data']['list'] as $item) {
if (!$item['active']) continue;
print '<li>';
print '<a>' . (strlen($item['title']) ? $item['title'] : ' ') . '</a>';
print '</li>';
$switcher .= '<li class="uk-clearfix">' . $item['html'] . '</li>';
}
if (!$html = ob_get_clean()) return;
$classNames = array('uk-tab');
$options = array();
if ($value = $block['data']['active']) {
$options['active'] = intval($value);
}
if ($block['data']['tab-options']) foreach (is_array($block['data']['tab-options']) ? $block['data']['tab-options'] : explode('|', $block['data']['tab-options']) as $option) if ($option) {
if (substr($option, 0, 3) === 'uk-') $classNames[] = $option;
}
if ($options) foreach ($options as $k => $v) if (is_string($k)) $options[$k] = $k . ': ' . $v;
print '<ul class="' . implode(' ', $classNames) . '" uk-tab' . ($options ? '="' . htmlspecialchars(implode('; ', $options)) . '"' : '') . '>';
print $html;
print '</ul>';
print '<ul class="uk-switcher" uk-switcher' . ($options ? '="' . htmlspecialchars(implode('; ', $options)) . '"' : '') . '>';
print $switcher;
print '</ul>';
?>
<script>
cmsRequire(['uikit']);
</script>
<?php
$html = ob_get_clean();
ob_start();
print $Main->callTemplate('block/block', 'block', $Page, array( 'block' => $block, 'html' => $html ));
?>