<commit_before><?php
/**
 * @author      <NAME>
 * @contributor <NAME>, <NAME>
 *
 * @copyright   2006-2018 <NAME>, 2008-2011 <NAME>, 2008 <NAME>
 *
 * @see        http://www.jelix.org
 * @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
 */
class htmlbootstrapFormWidget extends \jelix\forms\HtmlWidget\RootWidget
{
    public function outputHeader($builder)
    {
        $conf = jApp::config()->urlengine;
        $collection = jApp::config()->webassets['useCollection'];
        $jquery = jApp::config()->{'webassets_'.$collection}['jquery.js'];
        if (is_array($jquery)) {
            $jquery = $jquery[0];
        }

        $form = $builder->getForm();
        $privateData = $form->getContainer()->privateData;
        $groupDependencies = array();
        if (array_key_exists('qgis_groupDependencies', $privateData)) {
            $groupDependencies = $privateData['qgis_groupDependencies'];
        }

        // no scope into an anonymous js function, because jFormsJQ.tForm is used by other generated source code
        $js = "jFormsJQ.selectFillUrl='".jUrl::get('jelix~jforms:getListData')."';\n";
        $js .= 'jFormsJQ.groupVisibilitiesUrl=\''.jUrl::get('lizmap~edition:getGroupVisibilities')."';\n";
        $js .= 'jFormsJQ.config = {locale:'.$builder->escJsStr(jApp::config()->locale).
            ',basePath:'.$builder->escJsStr(jApp::urlBasePath()).
            ',jqueryPath:'.$builder->escJsStr($conf['jqueryPath']).
            ',jqueryFile:'.$builder->escJsStr($jquery).
            ',jelixWWWPath:'.$builder->escJsStr($conf['jelixWWWPath'])."};\n";
        $js .= "jFormsJQ.tForm = new jFormsJQForm('".$builder->getName()."','".
            $form->getSelector()."','".
            $form->getContainer()->formId."');\n";
        $js .= 'jFormsJQ.tForm.setErrorDecorator(new '.$builder->getOption('errorDecorator')."());\n";
        $js .= 'jFormsJQ.tForm.groupDependencies = '.json_encode($groupDependencies).";\n";
        $js .= "jFormsJQ.declareForm(jFormsJQ.tForm);\n";
        $this->addJs($js);

        if ($builder->getOption('modal')) {
            echo '<div class="modal-body">';
        }
    }

    /**
     * @param \jelix\forms\Builder\HtmlBuilder $builder
     */
    public function outputFooter($builder)
    {
        if ($builder->getOption('modal')) {
            echo '</div>';
        }
        $js = "jQuery(document).ready(function() { var c, c2;\n".$this->js.$this->finalJs.'});';
        $container = $builder->getForm()->getContainer();
        $container->privateData['__jforms_js'] = $js;
        $formId = $container->formId;
        $formName = $builder->getForm()->getSelector();
        echo '<script type="text/javascript" src="'.\jUrl::get(
            'jelix~jforms:js',
            array('__form' => $formName, '__fid' => $formId)
        ).'"></script>';
    }
}
<commit_msg>Fix a regression into htmlbootstrap widgets<commit_after><?php
/**
 * @author      <NAME>
 * @contributor <NAME>, <NAME>
 *
 * @copyright   2006-2018 <NAME>, 2008-2011 <NAME>, 2008 <NAME>
 *
 * @see        http://www.jelix.org
 * @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
 */
class htmlbootstrapFormWidget extends \jelix\forms\HtmlWidget\RootWidget
{
    public function outputHeader($builder)
    {
        $conf = jApp::config()->urlengine;
        $collection = jApp::config()->webassets['useCollection'];
        $jquery = jApp::config()->{'webassets_'.$collection}['jquery.js'];
        if (is_array($jquery)) {
            $jquery = $jquery[0];
        }

        $form = $builder->getForm();
        $privateData = $form->getContainer()->privateData;
        $groupDependencies = array();
        if (array_key_exists('qgis_groupDependencies', $privateData)) {
            $groupDependencies = $privateData['qgis_groupDependencies'];
        }

        // no scope into an anonymous js function, because jFormsJQ.tForm is used by other generated source code
        $js = "jFormsJQ.selectFillUrl='".jUrl::get('jelix~jforms:getListData')."';\n";
        $js .= 'jFormsJQ.groupVisibilitiesUrl=\''.jUrl::get('lizmap~edition:getGroupVisibilities')."';\n";
        $js .= 'jFormsJQ.config = {locale:'.$builder->escJsStr(jApp::config()->locale).
            ',basePath:'.$builder->escJsStr(jApp::urlBasePath()).
            ',jqueryPath:'.$builder->escJsStr($conf['jqueryPath']).
            ',jqueryFile:'.$builder->escJsStr($jquery).
            ',jelixWWWPath:'.$builder->escJsStr($conf['jelixWWWPath'])."};\n";
        $js .= "jFormsJQ.tForm = new jFormsJQForm('".$builder->getName()."','".
            $form->getSelector()."','".
            $form->getContainer()->formId."');\n";
        $js .= 'jFormsJQ.tForm.setErrorDecorator(new '.$builder->getOption('errorDecorator')."());\n";
        $js .= 'jFormsJQ.tForm.groupDependencies = '.json_encode($groupDependencies).";\n";
        $js .= "jFormsJQ.declareForm(jFormsJQ.tForm);\n";
        $this->addJs($js);

        if ($builder->getOption('modal')) {
            echo '<div class="modal-body">';
        }
    }

    /**
     * @param \jelix\forms\Builder\HtmlBuilder $builder
     */
    public function outputFooter($builder)
    {
        if ($builder->getOption('modal')) {
            echo '</div>';
        }
        parent::outputFooter($builder);
    }
}

{'fraction_non_alphanumeric': 0.19409361069836553, 'fraction_numerical': 0.007986627043090638, 'mean_word_length': 2.851931330472103, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 71, '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': '6816943', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1680, 'n_words': 249}