<commit_before><?php

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

namespace Integrated\Bundle\ContentBundle\Controller;

use Integrated\Bundle\ContentBundle\Document\Content\Content;
use Integrated\Bundle\ContentBundle\Document\Content\Image;
use Integrated\Bundle\ContentBundle\Document\Relation\Relation;
use Integrated\Bundle\ContentBundle\Form\Type\ActionsType;
use Integrated\Bundle\ContentBundle\Form\Type\DeleteFormType;
use Integrated\Bundle\UserBundle\Model\GroupableInterface;
use Integrated\Bundle\UserBundle\Model\UserManagerInterface;
use Integrated\Common\Content\ContentInterface;
use Integrated\Common\Content\Form\ContentFormType;
use Integrated\Common\ContentType\ContentTypeInterface;
use Integrated\Common\Locks;
use Integrated\Common\Security\Permissions;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Traversable;

/**
 * @author <NAME> <<EMAIL>>
 */
class ContentController extends Controller
{
    /**
     * @var string
     */
    protected $relationClass = 'Integrated\\Bundle\\ContentBundle\\Document\\Relation\\Relation';

    /**
     * @param Request $request
     *
     * @return Response
     */
    public function indexAction(Request $request)
    {
        // group the types based on there class
        $types = [];

        // Store contentTypes in array
        $displayTypes = [];

        // Store facetTitles in array
        $facetTitles = [];

        //remember search state
        $session = $request->getSession();
        if ($request->query->get('remember') && $session->has('content_index_view')) {
            $request->query->add(unserialize($session->get('content_index_view')));
            $request->query->remove('remember');
        } elseif (!$request->getRequestFormat() == 'json') {
            $session->set('content_index_view', serialize($request->query->all()));
        }

        /** @var $type \Integrated\Common\ContentType\ContentTypeInterface */
        foreach ($this->get('integrated.form.resolver')->getTypes() as $type) {
            $types[$type->getClass()][$type->getType()] = $type;
            $displayTypes[$type->getType()] = $type->getName();
        }

        foreach (array_keys($types) as $key) {
            ksort($types[$key]);
        }

        /** @var $client \Solarium\Client */
        $client = $this->get('solarium.client');
        $query = $client->createSelect();

        $facetSet = $query->getFacetSet();
        $facetSet->setMinCount(1);
        $facetSet->createFacetField('contenttypes')->setField('type_name')->addExclude('contenttypes');
        $facetSet->createFacetField('channels')->setField('facet_channels')->addExclude('channels');

        $facetSet->createFacetField('workflow_state')->setField('facet_workflow_state')->addExclude('workflow_state');
        $facetTitles['workflow_state'] = 'Workflow status';

        $facetSet->createFacetField('workflow_assigned')->setField('facet_workflow_assigned')->addExclude('workflow_assigned');
        $facetTitles['workflow_assigned'] = 'Assigned user';

        $facetSet->createFacetField('authors')->setField('facet_authors')->addExclude('authors');
        $facetTitles['authors'] = 'Author';

        $facetSet->createFacetField('properties')->setField('facet_properties')->addExclude('properties');

        // If the request query contains a relation parameter we need to fetch all the targets of the relation in order
        // to filter on these targets.
        // TODO this code should be somewhere else
        $relation = $request->query->get('relation');
        $relations = [];<commit_msg>Use POST requests in content navigator<commit_after><?php

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

namespace Integrated\Bundle\ContentBundle\Controller;

use Integrated\Bundle\ContentBundle\Document\Content\Content;
use Integrated\Bundle\ContentBundle\Document\Content\Image;
use Integrated\Bundle\ContentBundle\Document\Relation\Relation;
use Integrated\Bundle\ContentBundle\Form\Type\ActionsType;
use Integrated\Bundle\ContentBundle\Form\Type\DeleteFormType;
use Integrated\Bundle\UserBundle\Model\GroupableInterface;
use Integrated\Bundle\UserBundle\Model\UserManagerInterface;
use Integrated\Common\Content\ContentInterface;
use Integrated\Common\Content\Form\ContentFormType;
use Integrated\Common\ContentType\ContentTypeInterface;
use Integrated\Common\Locks;
use Integrated\Common\Security\Permissions;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Traversable;

/**
 * @author <NAME> <<EMAIL>>
 */
class ContentController extends Controller
{
    /**
     * @var string
     */
    protected $relationClass = 'Integrated\\Bundle\\ContentBundle\\Document\\Relation\\Relation';

    /**
     * @param Request $request
     *
     * @return Response
     */
    public function indexAction(Request $request)
    {
        // group the types based on there class
        $types = [];

        // Store contentTypes in array
        $displayTypes = [];

        // Store facetTitles in array
        $facetTitles = [];

        //remember search state
        $session = $request->getSession();
        if ($request->query->get('remember') && $session->has('content_index_view')) {
            $request->query->add(unserialize($session->get('content_index_view')));
            $request->query->remove('remember');
        } elseif (!$request->getRequestFormat() == 'json') {
            $session->set('content_index_view', serialize($request->query->all()));
        }

        /** @var $type \Integrated\Common\ContentType\ContentTypeInterface */
        foreach ($this->get('integrated.form.resolver')->getTypes() as $type) {
            $types[$type->getClass()][$type->getType()] = $type;
            $displayTypes[$type->getType()] = $type->getName();
        }

        foreach (array_keys($types) as $key) {
            ksort($types[$key]);
        }

        /** @var $client \Solarium\Client */
        $client = $this->get('solarium.client');
        $client->getPlugin('postbigrequest');

        $query = $client->createSelect();

        $facetSet = $query->getFacetSet();
        $facetSet->setMinCount(1);
        $facetSet->createFacetField('contenttypes')->setField('type_name')->addExclude('contenttypes');
        $facetSet->createFacetField('channels')->setField('facet_channels')->addExclude('channels');

        $facetSet->createFacetField('workflow_state')->setField('facet_workflow_state')->addExclude('workflow_state');
        $facetTitles['workflow_state'] = 'Workflow status';

        $facetSet->createFacetField('workflow_assigned')->setField('facet_workflow_assigned')->addExclude('workflow_assigned');
        $facetTitles['workflow_assigned'] = 'Assigned user';

        $facetSet->createFacetField('authors')->setField('facet_authors')->addExclude('authors');
        $facetTitles['authors'] = 'Author';

        $facetSet->createFacetField('properties')->setField('facet_properties')->addExclude('properties');

        // If the request query contains a relation parameter we need to fetch all the targets of the relation in order
        // to filter on these targets.
        // TODO this code should be somewhere else
        $relation = $request->query->get('relation');
        $relations = [];
{'fraction_non_alphanumeric': 0.14171122994652408, 'fraction_numerical': 0.00024307243558580456, 'mean_word_length': 3.726593911545089, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 100, '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': '1690149', 'n_tokens_mistral': 2303, 'n_tokens_neox': 2246, 'n_words': 412}