<commit_before><?php

    use papalapa\yiistart\modules\menu\models\Menu;
    use papalapa\yiistart\widgets\ControlButtonsPanel;
    use papalapa\yiistart\widgets\GridActionColumn;
    use papalapa\yiistart\widgets\GridExistColumn;
    use papalapa\yiistart\widgets\GridOrderColumn;
    use papalapa\yiistart\widgets\GridToggleColumn;
    use yii\grid\GridView;
    use yii\helpers\ArrayHelper;
    use yii\helpers\Html;
    use yii\widgets\Pjax;

    /* @var $this yii\web\View */
    /* @var $searchModel papalapa\yiistart\modules\menu\models\MenuSearch */
    /* @var $dataProvider yii\data\ActiveDataProvider */

    $this->title                   = 'Меню';
    $this->params['breadcrumbs'][] = $this->title;
?>
<div class="menu-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <?
        echo ControlButtonsPanel::widget([
            'items' => [
                'createMenu' => [
                    'title' => 'Создать',
                    'url'   => ['create'],
                    'ico'   => 'fa fa-plus-circle',
                    'class' => 'btn btn-success',
                ],
            ],
        ]);
    ?>

    <?php Pjax::begin(['id' => 'pjax-menu-index', 'options' => ['class' => 'pjax-spinner table-responsive'], 'timeout' => 10000]); ?>

    <?
        $siteUrlManager          = clone (Yii::$app->urlManager);
        $siteUrlManager->baseUrl = '/';

        $orders = Menu::find()->select(['order'])->orderBy(['order' => SORT_ASC])->column();

        echo GridView::widget([
            'dataProvider' => $dataProvider,
            'filterModel'  => $searchModel,
            'columns'      => [
                //['class' => 'yii\grid\SerialColumn'],
                [
                    'class'      => GridOrderColumn::className(),
                    'attribute'  => 'order',
                    'labelTitle' => 'Порядок',
                    'labelIco'   => 'fa fa-sort',
                ],
                [
                    'attribute' => 'position',
                    'filter'    => Menu::positions(),
                    'content'   => function ($model, $key, $index, $column) /* @var Menu $model */ {
                        return ArrayHelper::getValue(Menu::positions(), $model->position);
                    },
                ],
                [
                    'attribute' => 'title',
                ],
                [
                    'attribute' => 'parent',
                    'filter'    => ArrayHelper::map(Menu::roots(), 'id', 'title'),
                    'content'   => function ($model, $key, $index, $column) /* @var Menu $model */ use ($roots) {
                        $root = ArrayHelper::getValue($roots, $model->parent);

                        return $root ? $root->title : null;
                    },
                ],
                [
                    'attribute' => 'url',
                    'content'   => function ($model, $key, $index, $column) use ($siteUrlManager) {
                        return Html::a($model->url, $siteUrlManager->createUrl([$model->url]), ['target' => '_blank']);
                    },
                ],
                [
                    'class'       => GridExistColumn::className(),
                    'attribute'   => 'is_static',
                    'label'       => Html::tag('i', null, ['class' => 'fa fa-external-link', 'title' => 'Статичная ссылка', 'data-toggle' => 'tooltip']),
                    'encodeLabel' => false,
                ],
                [
                    'class'      => GridToggleColumn::className(),
                    'attribute'  => 'is_active',
                    'labelTitle' => 'Активность',
                    'labelIco'   => 'fa fa-eye',
                ],
                // 'created_by',
                // 'updated_by',
                // 'created_at',
                // 'updated_at',
                [
                    'class'       => GridActionColumn::className(),<commit_msg>Remove context as default option in Page::module, fix bugs in duplicates in parent Menu<commit_after><?php

    use papalapa\yiistart\modules\menu\models\Menu;
    use papalapa\yiistart\widgets\ControlButtonsPanel;
    use papalapa\yiistart\widgets\GridActionColumn;
    use papalapa\yiistart\widgets\GridExistColumn;
    use papalapa\yiistart\widgets\GridOrderColumn;
    use papalapa\yiistart\widgets\GridToggleColumn;
    use yii\grid\GridView;
    use yii\helpers\ArrayHelper;
    use yii\helpers\Html;
    use yii\widgets\Pjax;

    /* @var $this yii\web\View */
    /* @var $searchModel papalapa\yiistart\modules\menu\models\MenuSearch */
    /* @var $dataProvider yii\data\ActiveDataProvider */

    $this->title                   = 'Меню';
    $this->params['breadcrumbs'][] = $this->title;
?>
<div class="menu-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <?
        echo ControlButtonsPanel::widget([
            'items' => [
                'createMenu' => [
                    'title' => 'Создать',
                    'url'   => ['create'],
                    'ico'   => 'fa fa-plus-circle',
                    'class' => 'btn btn-success',
                ],
            ],
        ]);
    ?>

    <?php Pjax::begin(['id' => 'pjax-menu-index', 'options' => ['class' => 'pjax-spinner table-responsive'], 'timeout' => 10000]); ?>

    <?
        $siteUrlManager          = clone (Yii::$app->urlManager);
        $siteUrlManager->baseUrl = '/';

        $roots  = Menu::roots();
        $orders = Menu::find()->select(['order'])->orderBy(['order' => SORT_ASC])->column();

        echo GridView::widget([
            'dataProvider' => $dataProvider,
            'filterModel'  => $searchModel,
            'columns'      => [
                //['class' => 'yii\grid\SerialColumn'],
                [
                    'class'      => GridOrderColumn::className(),
                    'attribute'  => 'order',
                    'labelTitle' => 'Порядок',
                    'labelIco'   => 'fa fa-sort',
                ],
                [
                    'attribute' => 'position',
                    'filter'    => Menu::positions(),
                    'content'   => function ($model, $key, $index, $column) /* @var Menu $model */ {
                        return ArrayHelper::getValue(Menu::positions(), $model->position);
                    },
                ],
                [
                    'attribute' => 'title',
                ],
                [
                    'attribute' => 'parent',
                    'filter'    => ArrayHelper::map($roots, 'id', 'title'),
                    'content'   => function ($model, $key, $index, $column) /* @var Menu $model */ use ($roots) {
                        $root = ArrayHelper::getValue($roots, $model->parent);

                        return $root ? $root->title : null;
                    },
                ],
                [
                    'attribute' => 'url',
                    'content'   => function ($model, $key, $index, $column) use ($siteUrlManager) {
                        return Html::a($model->url, $siteUrlManager->createUrl([$model->url]), ['target' => '_blank']);
                    },
                ],
                [
                    'class'       => GridExistColumn::className(),
                    'attribute'   => 'is_static',
                    'label'       => Html::tag('i', null, ['class' => 'fa fa-external-link', 'title' => 'Статичная ссылка', 'data-toggle' => 'tooltip']),
                    'encodeLabel' => false,
                ],
                [
                    'class'      => GridToggleColumn::className(),
                    'attribute'  => 'is_active',
                    'labelTitle' => 'Активность',
                    'labelIco'   => 'fa fa-eye',
                ],
                // 'created_by',
                // 'updated_by',
                // 'created_at',
                // 'updated_at',
                [
                    'class'       => GridActionColumn::className(),
{'fraction_non_alphanumeric': 0.16264310602289697, 'fraction_numerical': 0.0017421602787456446, 'mean_word_length': 1.3862826603325415, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6798222', 'n_tokens_mistral': 2309, 'n_tokens_neox': 2148, 'n_words': 366}