<commit_before><?php

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

namespace Armd\BlogBundle\Admin;

use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;

use Sonata\AdminBundle\Admin\Admin;

class Blog extends Admin
{
    protected $translationDomain = 'ArmdBlogBundle';
    protected $container;


    public function __construct($code, $class, $baseControllerName, $container)
    {
        parent::__construct($code, $class, $baseControllerName);
        $this->container = $container;
    }


    /**
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
     *
     * @return void
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $isNew = ($this->getSubject() && !$this->getSubject()->getId());
        $formMapper
            ->with('General')
            ->add('title')
            ->add(
                'lead',
                null,
                array(
                    'attr' => array('class' => 'tinymce'),
                )
            )
            ->add(
                'content',
                null,
                array(
                    'attr' => array('class' => 'tinymce'),
                )
            )
            ->add('description')
            ->add(
                'topImage',
                'armd_media_file_type',
                array(
                    'required' => $isNew,
                    'with_remove' => false,
                    'media_context' => 'blog_image',
                    'media_provider' => 'sonata.media.provider.image',
                )
            )
            ->add(
                'user',
                'blogger_type',
                array(
                    'required' => true,
                    'multiple' => false,
                    'attr' => array('class' => 'chzn-select atlas-object-categories-select'),
                )
            )
            ->end();

        parent::configureFormFields($formMapper);
    }

    /**
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
     *
     * @return void
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('title')
            ->add('user')
            ->add('created_at')
            ->add('updated_at');

        parent::configureListFields($listMapper);
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('title');
    }

    public function getTemplate($name)
    {
        switch ($name) {
            case 'edit':
                return 'ArmdNewsBundle:Form:edit_container.html.twig';
                break;
            default:
                return parent::getTemplate($name);
                break;<commit_msg>#12200<commit_after><?php

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

namespace Armd\BlogBundle\Admin;

use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;

use Sonata\AdminBundle\Admin\Admin;

class Blog extends Admin
{
    protected $translationDomain = 'BlogBundle';
    protected $container;


    public function __construct($code, $class, $baseControllerName, $container)
    {
        parent::__construct($code, $class, $baseControllerName);
        $this->container = $container;
    }


    /**
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
     *
     * @return void
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $isNew = ($this->getSubject() && !$this->getSubject()->getId());
        $formMapper
            ->with('General')
            ->add('title', null, array('label' => 'Заголовок'))
            ->add(
                'lead',
                null,
                array(
                    'attr' => array('class' => 'tinymce'),
                    'label' => 'Лид'
                )
            )
            ->add(
                'content',
                null,
                array(
                    'attr' => array('class' => 'tinymce'),
                    'label' => 'Содержание'
                )
            )
            ->add(
                'topImage',
                'armd_media_file_type',
                array(
                    'label' => 'Картинка',
                    'required' => $isNew,
                    'with_remove' => false,
                    'media_context' => 'blog_image',
                    'media_provider' => 'sonata.media.provider.image',
                )
            )
            ->add('description', null, array('label' => 'Описание для картинки'))
            ->add(
                'user',
                'blogger_type',
                array(
                    'label' => 'Автор',
                    'required' => true,
                    'multiple' => false,
                    'attr' => array('class' => 'chzn-select atlas-object-categories-select'),
                )
            )
            ->end();

        $formMapper->setHelps(array(
                'lead' => 'Короткое описание, которое будет выводиться под заголовком на странице блогов или в блоках Популярные, Последние',
                'topImage' => 'Картинка, которая отображается на странице блогов у первого блога, а также сверху страницы блога',
                'description' => 'Короткое описание, которое отображается под заглавной картинкой на странице записи блога'
            ));

        parent::configureFormFields($formMapper);
    }

    /**
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
     *
     * @return void
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('title', null, array('label' => 'Заголовок'))
            ->add('user', null, array('label' => 'Автор'))
            ->add('created_at', null, array('label' => 'Дата создания'))
            ->add('updated_at', null, array('label' => 'Дата обновления'));

        parent::configureListFields($listMapper);
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('title', null, array('label' => 'Заголовок'));
    }

    public function getTemplate($name)
    {
        switch ($name) {
            case 'edit':
                return 'ArmdNewsBundle:Form:edit_container.html.twig';
                break;
            default:
                return parent::getTemplate($name);
                break;
{'fraction_non_alphanumeric': 0.12489307100085544, 'fraction_numerical': 0.00071285999429712, 'mean_word_length': 1.6582038651004167, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 82, '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': '2995998', 'n_tokens_mistral': 1987, 'n_tokens_neox': 1930, 'n_words': 384}