<commit_before><?php
/**
 * Part of the ETD Framework Form Package
 *
 * @copyright   Copyright (C) 2015 ETD Solutions, SARL Etudoo. Tous droits réservés.
 * @license     Apache License 2.0; see LICENSE
 * @author      ETD Solutions http://etd-solutions.com
 */

namespace EtdSolutions\Form\Field;

use EtdSolutions\Utility\RequireJSUtility;
use Joomla\Form\Field;

class FileField extends Field {

    /**
     * @var RequireJSUtility
     */
    protected $requirejs;
    protected $modules = "";

    /**
     * Method to get the radio button field input markup.
     *
     * @return  string  The field input markup.
     */
    protected function getInput() {

        $this->requirejs = new RequireJSUtility();
        $this->modules = "";

        $options = $this->getOptions();

        // JS
        $js = "$('#" . $this->id . "').fileinput(" . json_encode($options) . ")";

        if (isset($this->element['uploadUrl'])) {
            $js .= ".on('fileuploaded', function(event, data, previewId, index) {
    \$('input[name=\"" . $this->name . "\"]').val(data.response.name);
})";
        }

        $js .= ";";

        // On ajoute les ressources.
        $this->requirejs
            ->addRequireJSModule("fileinput", "js/vendor/fileinput.min", true, array("bootstrap", "jquery"))
            ->addDomReadyJS($js, false, "fileinput". $this->modules  .", css!/css/vendor/fileinput.min.css");

        // Initialize some field attributes.
        $accept = $this->element['accept'] ? ' accept="' . (string) $this->element['accept'] . '"' : '';
        $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
        $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
        $disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';

        // Initialize JavaScript field attributes.
        $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

        return '<input type="file" name="' . $this->fieldname . '_upload" id="' . $this->id . '"' . ' value=""' . $accept . $disabled . $class . $size
        . $onchange . '><input type="hidden" name="' . $this->name . '" value="' . $this->value . '">';

    }
<commit_msg>Amélioration FileField<commit_after><?php
/**
 * Part of the ETD Framework Form Package
 *
 * @copyright   Copyright (C) 2015 ETD Solutions, SARL Etudoo. Tous droits réservés.
 * @license     Apache License 2.0; see LICENSE
 * @author      ETD Solutions http://etd-solutions.com
 */

namespace EtdSolutions\Form\Field;

use EtdSolutions\Utility\RequireJSUtility;
use Joomla\Form\Field;

class FileField extends Field {

    /**
     * @var RequireJSUtility
     */
    protected $requirejs;
    protected $modules = "";

    /**
     * Method to get the radio button field input markup.
     *
     * @return  string  The field input markup.
     */
    protected function getInput() {

        $this->requirejs = new RequireJSUtility();
        $this->modules = "";

        $options = $this->getOptions();

        // JS
        $js = "$('#" . $this->id . "').fileinput(" . json_encode($options) . ").on('filecleared', function() {
    \$('input[name=\"" . $this->name . "\"]').val('###DELETED###');
})";

        if (isset($this->element['uploadUrl'])) {
            $js .= ".on('fileuploaded', function(event, data, previewId, index) {
    \$('input[name=\"" . $this->name . "\"]').val(data.response.name);
})";
        }

        $js .= ";";

        // On ajoute les ressources.
        $this->requirejs
            ->addRequireJSModule("fileinput", "js/vendor/fileinput.min", true, array("bootstrap", "jquery"))
            ->addDomReadyJS($js, false, "fileinput". $this->modules  .", css!/css/vendor/fileinput.min.css");

        // Initialize some field attributes.
        $accept = $this->element['accept'] ? ' accept="' . (string) $this->element['accept'] . '"' : '';
        $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
        $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
        $disabled = ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';

        // Initialize JavaScript field attributes.
        $onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';

        return '<input type="file" name="' . $this->fieldname . '_upload" id="' . $this->id . '"' . ' value=""' . $accept . $disabled . $class . $size
        . $onchange . '><input type="hidden" name="' . $this->name . '" value="' . $this->value . '">';

    }

{'fraction_non_alphanumeric': 0.20924781589601535, 'fraction_numerical': 0.0025569997869166845, 'mean_word_length': 2.5996932515337425, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 54, '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': '4297696', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1427, 'n_words': 314}