<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace DataTables\Controller\Component;

use Cake\Controller\Component;
use Cake\Utility\Inflector;

/**
 * CakePHP DataTableConfigComponent
 * @author allan
 */
class DataTablesConfigComponent extends Component
{

    private $dataTableConfig = [];
    private $currentConfig   = null;
    private $defaultOptions = [];

    public function initialize(array $config)
    {
        $this->dataTableConfig = &$config['DataTablesConfig'];
        parent::initialize($config);
    }

    /**
     * Set initial config name
     * @param string $name
     * @return $this
     */
    public function setDataTableConfig($name, $defaultOptions)
    {
        $this->defaultOptions = $defaultOptions;
        $this->currentConfig                   = $name;
        $this->dataTableConfig[$name]['id']    = 'dt' . $name;
        $this->dataTableConfig[$name]['table'] = $name;
        $this->dataTableConfig[$name]['queryOptions'] = [];
        $this->dataTableConfig[$name]['options'] = $this->defaultOptions;
        $this->dataTableConfig[$name]['finder'] = "all";
        return $this;
    }
    
    public function setFinder($finder = "all") {
        $this->dataTableConfig[$this->currentConfig]['finder'] = $finder;
    }

    /**
     * Set a custom table name. Default is config name
     * @param string $name
     * @return $this
     */
    public function table($name)
    {
        $this->dataTableConfig[$this->currentConfig]['table'] = $name;

        return $this;
    }

    /**
     * Set a column at datatable config
     * @param type $name
     * @param array $options
     * @return DataTablesConfigComponent
     */
    public function column($name, array $options = [])
    {
        if (!empty($options['order']))
        {
            if (!in_array($options['order'], ['asc', 'desc']))
            {
                unset($options['order']);
            }
        }<commit_msg>2017-11-07 1311<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace DataTables\Controller\Component;

use Cake\Controller\Component;
use Cake\Utility\Inflector;

/**
 * CakePHP DataTableConfigComponent
 * @author allan
 */
class DataTablesConfigComponent extends Component
{

    private $dataTableConfig = [];
    private $currentConfig   = null;
    private $defaultOptions = [];

    public function initialize(array $config)
    {
        $this->dataTableConfig = &$config['DataTablesConfig'];
        parent::initialize($config);
    }

    /**
     * Set initial config name
     * @param string $name
     * @return $this
     */
    public function setDataTableConfig($name, $defaultOptions)
    {
        $this->defaultOptions = $defaultOptions;
        $this->currentConfig                   = $name;
        $this->dataTableConfig[$name]['id']    = 'dt' . $name;
        $this->dataTableConfig[$name]['table'] = $name;
        $this->dataTableConfig[$name]['queryOptions'] = [];
        $this->dataTableConfig[$name]['options'] = $this->defaultOptions;
        $this->dataTableConfig[$name]['finder'] = "all";
        return $this;
    }
    
    public function finder($finder = "all") {
        $this->dataTableConfig[$this->currentConfig]['finder'] = $finder;
    }

    /**
     * Set a custom table name. Default is config name
     * @param string $name
     * @return $this
     */
    public function table($name)
    {
        $this->dataTableConfig[$this->currentConfig]['table'] = $name;

        return $this;
    }

    /**
     * Set a column at datatable config
     * @param type $name
     * @param array $options
     * @return DataTablesConfigComponent
     */
    public function column($name, array $options = [])
    {
        if (!empty($options['order']))
        {
            if (!in_array($options['order'], ['asc', 'desc']))
            {
                unset($options['order']);
            }
        }
{'fraction_non_alphanumeric': 0.1409252669039146, 'fraction_numerical': 0.0028469750889679717, 'mean_word_length': 2.5309882747068677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '4902854', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1145, 'n_words': 275}