<?php

/**
 * Основной класс вывода
 * Создан для того, чтоб при изменении не юзать весь двиг
 */
class document {
    #Выводит (Нет результатов)

    static function NoResult() {
        echo "<div class='list-group-item-null list-group-item-info'><i class='fa fa-clone fa-fw'></i> " . lang('Нет результатов') . "</div>";
    }

    #Выводит заголовок страницы

    static function Title($text) {
        global $set;
        $set['title'] = lang($text);
    }

    static function Input($name, $title, $length = null, $value = null, $class = 'form-control', $type = 'text', $required = null) {
        echo lang($title) . "<br />";
        echo "<input name='$name' maxlength='$length' length='$length' type='$type' value='$value' $required class='$class'>";
    }

    static function Checkbox($name, $title, $value = null, $if_checked = null, $icon = null) {
        if (!$icon) {
            $i = null;
        } else {
            $i = "<i class='fa fa-$icon fa-fw'></i>";
        }
        echo "<label class='custom-control custom-checkbox'><input type='checkbox' name='$name' value='$value' $if_checked class='custom-control-input'><span class='custom-control-indicator'></span> <span class='custom-control-description'>$i " . lang("$title") . "</span></label><br />";
    }

    static function Radio($name, $title, $value = null, $if_checked = null, $icon = null) {
        if (!$icon) {
            $i = null;
        } else {
            $i = "<i class='fa fa-$icon fa-fw'></i>";
        }
        echo "<label class='custom-control custom-radio'><input name='$name' type='radio' $if_checked value='$value' class='custom-control-input'><span class='custom-control-indicator'></span> <span class='custom-control-description'>$i " . lang($title) . "</span></label><br />";
    }

    static function Textarea($name, $title, $length = null, $value = null, $class = 'form-control', $rows = '3') {
        echo lang($title) . "<br />";
        echo "<textarea name='$name' maxlength='$length' length='$length' rows='$rows' class='$class'>$value</textarea>";
    }

    static function File($name, $title = null, $accept = null) {
        if (!$title) {
            $t = null;
        } else {
            $t = lang("$title");
        }
        echo "$t<br />";
        echo "<label class='custom-file'><input name='$name' type='file' accept='$accept' class='custom-file-input'><span class='custom-file-control'></span></label><br /><br />";
    }

    static function Button($class = null, $name = null, $icon = null, $title = null) {
        if ($icon == null) {
            $i = null;
        } else {
            $i = "<i class='fa fa-$icon fa-fw'></i> ";
        }
        echo "<button class='$class' name='$name'>$i " . lang($title) . "</button> ";
    }

    static function Link($class = null, $href = null, $icon = null, $title = null) {
        if ($icon == null) {
            $i = null;
        } else {
            $i = "<i class='fa fa-$icon fa-fw'></i> ";
        }
        if ($class == null) {
            $class = null;
        } else {
            $class = "class='$class'";
        }
        echo "<a $class href='$href'>$i " . lang($title) . "</a> ";
    }

    static function Link2($class = null, $href = null, $icon = null, $title = null) {
        if ($icon == null) {
            $i = null;
        } else {
            $i = "<i class='fa fa-$icon fa-fw'></i> ";
        }
        if ($class == null) {
            $class = null;
        } else {
            $class = "class='$class'";
        }
        echo "<a $class href='$href'>$i $title</a> ";
    }

    #Самая простая функция с переводом текста

    static function Text($title, $br = null) {
        echo lang($title) . "$br";
    }

}
