<?php

namespace common\modules\rubrication\helpers;
use Yii;
use yii\helpers\Html;

class RubricationHelper {
    public static $types;
    /**
     * @inheritdoc
     * Returns labels of appropriate main-statuses
     * @return array.
     */
    static public function getStatusLabels() {
        return [
            0 => Yii::t('order', 'Invisible'),
            1 => Yii::t('order', 'Active'),
        ];
    }

    /**
     * @inheritdoc
     * Returns sort-interval of appropriate options and others
     * @return array.
     */
    static public function SortArray($low = 0, $high = 100) {
        return range($low, $high);
    }

    static public function OptionTypes() {
        if (!is_null(self::$types)) {
            return self::$types;
        }

        $module = \Yii::$app->getModule('rubrication');

        if (!is_array($module->types))
            return [];

        return $module->types;

    }

    public function checkboxList($items, $options = [])
    {
        $this->adjustLabelFor($options);
        $this->parts['{input}'] = Html::activeCheckboxList($this->model, $this->attribute, $items, $options);

        return $this;
    }
}