<commit_before><?php

/*
 * This file is part of the RednoseFrameworkBundle package.
 *
 * (c) RedNose <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Rednose\FrameworkBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * WYSIWYG document editor wrapper form
 */
class EditorType extends AbstractType
{
    protected $request;

    /**
     * Constructor
     *
     * @param Request $request Request object
     */
    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $builder
            ->setAttribute('toolbar', $options['toolbar'])
            ->setAttribute('scayt', $options['scayt'])
            ->setAttribute('height', $options['height'])
            ->setAttribute('inline', $options['inline'])
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $view->vars['toolbar'] = $form->getConfig()->getAttribute('toolbar');
        $view->vars['scayt']   = $form->getConfig()->getAttribute('scayt');
        $view->vars['height']  = $form->getConfig()->getAttribute('height');
        $view->vars['inline']  = $form->getConfig()->getAttribute('inline');
        $view->vars['locale']  = $this->request->getLocale();
    }


    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'textarea';
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'rednose_widget_editor';
    }

    /**
     * {@inheritdoc}
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'required' => false,
            'inline'   => false,
            'scayt'    => true,
            'height'   => 250,

            // WYSIWYG features. Options are carefully chosen, keeping dictated corporate identity guidelines and multi-device support
            // in mind.
            'toolbar'  => array(
                array('name' => 'styles', 'items' => array('Styles')),

                // Standard bold, italic, underline. Remove format is only here to clean up the mess from pasted stuff.
                array('name' => 'basicstyles', 'items' => array('Bold', 'Italic', 'Underline', '-', 'RemoveFormat')),

                // Basic lists.
                array('name' => 'paragraph', 'items' => array('NumberedList', 'BulletedList')),

                // URL support, essential.
                array('name' => 'links', 'items' => array('Link')),

                // Essential and no reason to not implement them.
                array('name' => 'clipboard', 'items' => array('Undo', 'Redo')),

                // Cut / copy / paste. These features are limited to clients running on a desktop, as other devices have these implemented into their basic
                // text input API's.
                array('name' => 'clipboard', 'items' => array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord')),

                // Nice to have. All clients should implement this.
                array('name' => 'tools', 'items' => array('Maximize')),
            ),
        ));
    }
}
<commit_msg>Scayt button added (right mouse function seems not to work very well)<commit_after><?php

/*
 * This file is part of the RednoseFrameworkBundle package.
 *
 * (c) RedNose <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Rednose\FrameworkBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * WYSIWYG document editor wrapper form
 */
class EditorType extends AbstractType
{
    protected $request;

    /**
     * Constructor
     *
     * @param Request $request Request object
     */
    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $builder
            ->setAttribute('toolbar', $options['toolbar'])
            ->setAttribute('scayt', $options['scayt'])
            ->setAttribute('height', $options['height'])
            ->setAttribute('inline', $options['inline'])
        ;
    }

    /**
     * {@inheritdoc}
     */
    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $view->vars['toolbar'] = $form->getConfig()->getAttribute('toolbar');
        $view->vars['scayt']   = $form->getConfig()->getAttribute('scayt');
        $view->vars['height']  = $form->getConfig()->getAttribute('height');
        $view->vars['inline']  = $form->getConfig()->getAttribute('inline');
        $view->vars['locale']  = $this->request->getLocale();
    }


    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'textarea';
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'rednose_widget_editor';
    }

    /**
     * {@inheritdoc}
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'required' => false,
            'inline'   => false,
            'scayt'    => true,
            'height'   => 250,

            // WYSIWYG features. Options are carefully chosen, keeping dictated corporate identity guidelines and multi-device support
            // in mind.
            'toolbar'  => array(
                array('name' => 'styles', 'items' => array('Styles')),

                // Standard bold, italic, underline. Remove format is only here to clean up the mess from pasted stuff.
                array('name' => 'basicstyles', 'items' => array('Bold', 'Italic', 'Underline', '-', 'RemoveFormat')),

                // Basic lists.
                array('name' => 'paragraph', 'items' => array('NumberedList', 'BulletedList')),

                // URL support, essential.
                array('name' => 'links', 'items' => array('Link')),

                // Essential and no reason to not implement them.
                array('name' => 'clipboard', 'items' => array('Undo', 'Redo')),

                // Cut / copy / paste. These features are limited to clients running on a desktop, as other devices have these implemented into their basic
                // text input API's.
                array('name' => 'clipboard', 'items' => array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord')),

                // Nice to have. All clients should implement this.
                array('name' => 'tools', 'items' => array('Maximize', 'Scayt')),
            ),
        ));
    }
}

{'fraction_non_alphanumeric': 0.1467877654601309, 'fraction_numerical': 0.0008013890743956191, 'mean_word_length': 2.35333631885356, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 87, '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': '4192580', 'n_tokens_mistral': 2065, 'n_tokens_neox': 2005, 'n_words': 510}