Система управления «Сайт PRO»
Версия 20240107

block.wrapper.php

Блок «Разметка»

Вызывается из:

Исходный код
<?php

if ($block['data']['html-test'] && strlen($block['data']['test'])) {
    if (!eval(strpos($block['data']['test'], 'return') === false ? "return {$block['data']['test']};" : "{$block['data']['test']};")) return;
}

$html = null;
if ($block['data']['html-code'] && strlen($block['data']['code'])) {
    ob_start();
    eval('?' . '>' . $block['data']['code']);
    $html = ob_get_clean();
}

$classNames = array('cms-block-' . $block['block']);
if ($block['block'] === 'grid' || $block['data']['grid-options']) {
    $classNames['uk-grid'] = 'uk-grid';
    $classNames['uk-child-width'] = 'uk-child-width';
    if ($block['data']['grid-options']) foreach (is_array($block['data']['grid-options']) ? $block['data']['grid-options'] : explode('|', $block['data']['grid-options']) as $option) if ($option) {
        if (substr($option, 0, 3) === 'uk-') $classNames[$option] = $option;
    }
}
if ($block['block'] === 'col' || $block['data']['col-options']) {
    if ($block['data']['col-options']) foreach (is_array($block['data']['col-options']) ? $block['data']['col-options'] : explode('|', $block['data']['col-options']) as $option) if ($option) {
        if (substr($option, 0, 3) === 'uk-') $classNames[$option] = $option;
    }
}
if ($block['data']['html-class']) foreach (explode(' ', $block['data']['html-class']) as $className) $classNames[$className] = $className;

$wrapper = count($classNames) > 1 || $block['data']['html-id'];

if ($wrapper) {
    print '<div class="' . implode(' ', $classNames) . '"' . ($block['data']['html-id'] ? ' id="' . htmlspecialchars($block['data']['html-id']) . '"' : '') . '>';
}

if (!is_array($children = $block['children'])) $children = array();

foreach (preg_split('~<block(/|\s+[^<>]*)?' . '>~si', strval($html)) as $html) {
    print $html;
    if ($child = array_shift($children)) print $child['html'];
}

while ($child = array_shift($children)) print $child['html'];

if ($wrapper) {
    print '</div>';
}

?>