<commit_before><?php
/**
 * Created by PhpStorm.
 * User: execut
 * Date: 12/29/16
 * Time: 2:09 PM
 */

namespace execut\actions\action\adapter\gridView;


use yii\helpers\ArrayHelper;
use kartik\daterange\DateRangePicker;
use kartik\detail\DetailView;
use kartik\grid\ActionColumn;
use kartik\grid\BooleanColumn;
use kartik\grid\GridView;
use yii\data\ActiveDataProvider;
use yii\helpers\Inflector;
use yii\helpers\Url;
use yii\web\JsExpression;

trait ModelHelper
{
    public function getStandardFields($columns = []) {
        $standardColumns = [
            'id' => [
                'displayOnly' => true,
                'attribute' => 'id',
            ],
            'visible' => [
                'type' => DetailView::INPUT_CHECKBOX,
                'attribute' => 'visible',
            ],
            'name' => [
                'attribute' => 'name'
            ],
            'created' => [
                'displayOnly' => true,
                'attribute' => 'created',
            ],
            'updated' => [
                'displayOnly' => true,
                'attribute' => 'updated',
            ],
        ];

        foreach ($standardColumns as $key => $column) {
            if (isset($column['attribute']) && !$this->hasAttribute($column['attribute'])) {
                unset($columns[$key]);
            }
        }

        $columns = ArrayHelper::merge($standardColumns, $columns);

        return $columns;
    }

    public function getStandardColumns($columns = []) {
        $standardColumns = [
            'id' => [
                'attribute' => 'id',
            ],
//            'visible' => [
//                'class' => BooleanColumn::class,
//                'attribute' => 'visible',
//            ],
            'name' => [
                'attribute' => 'name'
            ],
            'created' => [
                'attribute' => 'created',
                'filter' => DateRangePicker::widget([
                    'attribute' => 'created',
                    'model' => $this,
                    'convertFormat'=>true,
                    'pluginOptions'=>[
                        'locale'=>['format'=>'Y-m-d']
                    ]
                ]),
            ],
            'updated' => [
                'attribute' => 'updated',
                'filter' => DateRangePicker::widget([
                    'attribute' => 'updated',
                    'model' => $this,
                    'convertFormat'=>true,
                    'pluginOptions'=>[
                        'locale'=>['format'=>'Y-m-d']
                    ]
                ]),
            ],
            'actions' => [
                'class' => ActionColumn::className(),
            ],
        ];

        foreach ($standardColumns as $key => $column) {
            if (isset($column['attribute']) && !$this->hasAttribute($column['attribute'])) {<commit_msg>extracted in function getting config for boolean column<commit_after><?php
/**
 * Created by PhpStorm.
 * User: execut
 * Date: 12/29/16
 * Time: 2:09 PM
 */

namespace execut\actions\action\adapter\gridView;


use yii\helpers\ArrayHelper;
use kartik\daterange\DateRangePicker;
use kartik\detail\DetailView;
use kartik\grid\ActionColumn;
use kartik\grid\BooleanColumn;
use kartik\grid\GridView;
use yii\data\ActiveDataProvider;
use yii\helpers\Inflector;
use yii\helpers\Url;
use yii\web\JsExpression;

trait ModelHelper
{
    public function getStandardFields($columns = []) {
        $standardColumns = [
            'id' => [
                'displayOnly' => true,
                'attribute' => 'id',
            ],
            'visible' => [
                'type' => DetailView::INPUT_CHECKBOX,
                'attribute' => 'visible',
            ],
            'name' => [
                'attribute' => 'name'
            ],
            'created' => [
                'displayOnly' => true,
                'attribute' => 'created',
            ],
            'updated' => [
                'displayOnly' => true,
                'attribute' => 'updated',
            ],
        ];

        foreach ($standardColumns as $key => $column) {
            if (isset($column['attribute']) && !$this->hasAttribute($column['attribute'])) {
                unset($columns[$key]);
            }
        }

        $columns = ArrayHelper::merge($standardColumns, $columns);

        return $columns;
    }

    public function getBooleanColumn($name) {
        return [
            'class' => BooleanColumn::class,
            'attribute' => $name,
        ];
    }

    public function getStandardColumns($columns = []) {
        $standardColumns = [
            'id' => [
                'attribute' => 'id',
            ],
            'visible' => $this->getBooleanColumn('visible'),
            'name' => [
                'attribute' => 'name'
            ],
            'created' => [
                'attribute' => 'created',
                'filter' => DateRangePicker::widget([
                    'attribute' => 'created',
                    'model' => $this,
                    'convertFormat'=>true,
                    'pluginOptions'=>[
                        'locale'=>['format'=>'Y-m-d']
                    ]
                ]),
            ],
            'updated' => [
                'attribute' => 'updated',
                'filter' => DateRangePicker::widget([
                    'attribute' => 'updated',
                    'model' => $this,
                    'convertFormat'=>true,
                    'pluginOptions'=>[
                        'locale'=>['format'=>'Y-m-d']
                    ]
                ]),
            ],
            'actions' => [
                'class' => ActionColumn::className(),
                'buttons' => [
                    'view' => function () {},
                ],
            ],
        ];

        foreach ($standardColumns as $key => $column) {
            if (isset($column['attribute']) && !$this->hasAttribute($column['attribute'])) {
{'fraction_non_alphanumeric': 0.1543579507651364, 'fraction_numerical': 0.0029940119760479044, 'mean_word_length': 1.3543461237274863, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 96, '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': '5093533', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1533, 'n_words': 267}