<commit_before><?php
/**
 * NOVIUS
 *
 * @copyright  2014 Novius
 * @license    GNU Affero General Public License v3 or (at your option) any later version
 *             http://www.gnu.org/licenses/agpl-3.0.html
 * @link http://www.novius.com
 */

// Get the available drivers
$config = \Config::load('novius_onlinemediafiles::config', true);

// Load the drivers common config
list($application, $file) = \Config::configFile('\Novius\OnlineMediaFiles\Driver');
$common_config = \Config::load($application . '::' . $file, true);
if (!is_array($common_config)) {
	$common_config = array();
}

$data = array();
foreach ($config['drivers'] as $driver_name) {
	$driver_class = \Novius\OnlineMediaFiles\Driver::buildDriverClass($driver_name);

	// Loads the driver's custom config
	list($application, $file) = \Config::configFile($driver_class);
	$driver_config = \Config::load($application . '::' . $file, true);

    // Merges with common config
	$driver_config = \Arr::merge($common_config, (array) $driver_config);


	$data[] = array(
		'id' 	=> $driver_name,
		'title' => \Arr::get($driver_config, 'name', $driver_name),
		'icon' 	=> \Arr::get($driver_config, 'icon.16'),
	);

}

//$data = array(
//	array(
//		'id' => 'Youtube',
//		'title' => __('vidéo Youtube'),
//		'icon' => 'youtube.jpg',
//	),
//	array(
//		'id' => 'Dailymotion',
//		'title' => __('vidéo Dailymotion'),
//		'icon' => 'dailymotion.png',
//	),
//	array(
//		'id' => 'Vimeo',
//		'title' => __('vidéos Vimeo'),
//		'icon' => 'vimeo.png',
//	),
//);

return array(
    'data' => $data,
    'input' => array(
        'key' => 'onme_driver_name',
        'query' => function ($value, $query) {
            $ext = array();
            $other = array();
            $value = (array) $value;

			$config = \Config::load('novius_onlinemediafiles::config', true);
            foreach ($config['drivers'] as $driver) {
                if (in_array($driver, $value)) {
                    $ext[] = $driver;
                } else {
                    $other[] = $driver;
                }
            }
            $opened = false;
            if (!empty($ext)) {
                $opened or $query->and_where_open();
                $opened = true;
                $query->or_where(array('onme_driver_name', 'IN', $ext));
            }
            if (in_array('other', $value)) {
                $opened or $query->and_where_open();
                $opened = true;
                $query->or_where(array('onme_driver_name', 'NOT IN', $other));
            }<commit_msg>Remove old code<commit_after><?php
/**
 * NOVIUS
 *
 * @copyright  2014 Novius
 * @license    GNU Affero General Public License v3 or (at your option) any later version
 *             http://www.gnu.org/licenses/agpl-3.0.html
 * @link http://www.novius.com
 */

// Get the available drivers
$config = \Config::load('novius_onlinemediafiles::config', true);

// Load the drivers common config
list($application, $file) = \Config::configFile('\Novius\OnlineMediaFiles\Driver');
$common_config = \Config::load($application . '::' . $file, true);
if (!is_array($common_config)) {
	$common_config = array();
}

$data = array();
foreach ($config['drivers'] as $driver_name) {
	$driver_class = \Novius\OnlineMediaFiles\Driver::buildDriverClass($driver_name);

	// Loads the driver's custom config
	list($application, $file) = \Config::configFile($driver_class);
	$driver_config = \Config::load($application . '::' . $file, true);

    // Merges with common config
	$driver_config = \Arr::merge($common_config, (array) $driver_config);


	$data[] = array(
		'id' 	=> $driver_name,
		'title' => \Arr::get($driver_config, 'name', $driver_name),
		'icon' 	=> \Arr::get($driver_config, 'icon.16'),
	);
}

return array(
    'data' => $data,
    'input' => array(
        'key' => 'onme_driver_name',
        'query' => function ($value, $query) {
            $ext = array();
            $other = array();
            $value = (array) $value;

			$config = \Config::load('novius_onlinemediafiles::config', true);
            foreach ($config['drivers'] as $driver) {
                if (in_array($driver, $value)) {
                    $ext[] = $driver;
                } else {
                    $other[] = $driver;
                }
            }
            $opened = false;
            if (!empty($ext)) {
                $opened or $query->and_where_open();
                $opened = true;
                $query->or_where(array('onme_driver_name', 'IN', $ext));
            }
            if (in_array('other', $value)) {
                $opened or $query->and_where_open();
                $opened = true;
                $query->or_where(array('onme_driver_name', 'NOT IN', $other));
            }
{'fraction_non_alphanumeric': 0.18624338624338624, 'fraction_numerical': 0.0038095238095238095, 'mean_word_length': 2.4546783625730995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5758440', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1529, 'n_words': 312}