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

input.sort.php

Поле «Сортировка элементов»

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

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

$attributes = $Field->getFieldInputAttributes(array(
    'grid-margin' => $Field->getInputMargin(),
    'grid-width' => $Field->getInputWidth(),
    'class' => 'field-input field-input--' . $Field->type,
));
print '<span';
foreach ($attributes as $attributeName => $attributeValue) if ($attributeValue !== null) print ' ' . $attributeName . '="' . $attributeValue . '"';
print '>';

print '<ul id="' . $Field->id('-input') . '">';
if (is_array($Field->list) && !empty($Field->list)) {
    foreach ($Field->list as $id => $item) {
        print "\n" . '<li>';
        print '<label class="input-label--checkbox">';
        $checkbox = is_array($item) && isset($item['id']) && isset($item['menu']);
        if ($checkbox) {
            if ($Field->name === 'order' && is_array($item)) $name = $Field->name . '-menu[' . $item['table'] . '][' . $item['id'] . ']';
            else $name = $Field->name . '-menu[' . $item['id'] . ']';
            print '<input type="checkbox" name="' . $name . '" value="Y"' . ($item['menu'] ? ' checked=""' : '') . ' class="input--checkbox">';
        }
        print '<span class="label-text">' . htmlspecialchars(is_array($item) ? $item['title'] : $item) . '</span>';
        if ($src = is_array($item) ? $item['image'] : '') {
            print $Main->displayImage($src, 'rc150x150', 150, 150);
        }
        if ($Field->name === 'order' && is_array($item)) $name = $Field->name . '[' . $item['table'] . '][]';
        else $name = $Field->name . '[]';
        print '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars(is_array($item) ? $item['id'] : $id) . '">';
        print '</label>';
        print '</li>';
    }
}
print "\n" . '</ul>';

print '</span>';

?>

<script>
cmsRequire(['form/script/input.sort'], init => init(document.getElementById(<?=$Field->jId('-input')?>)));
</script>