Select the template to render search results with

@param HTTPRequest $request
@return array
175469
protected function getResultsTemplate($request)
    {
        $templates = [
            Page::class . '_results',
            Page::class
        ];

        if ($request->getVar('format') == 'rss') {
            array_unshift($templates, Page::class . '_results_rss');
        }

        if ($request->getVar('format') == 'atom') {
            array_unshift($templates, Page::class . '_results_atom');
        }

        return $templates;
    }
407196
public function listAction(Request $request)
    {
        return $this->render('SynapsePageBundle:Admin/Page:list.html.twig', array(
            'pages' => $this->container->get('synapse.page.loader')->retrieveAll(),
            'page_rendering_route' => $this->container->getParameter('synapse.page.rendering_route'),
        ));
    }
1272756
public function selectLinkAction(Request $request)
    {
        $params = $this->getTemplateParameters($request);
        $params['cke'] = false;
        $params['multilanguage'] = $this->getParameter('kunstmaan_admin.multi_language');

        return $params;
    }
896654
private function getTemplateParameters(Request $request)
    {
        // When the media bundle is available, we show a link in the header to the media chooser
        $allBundles = $this->getParameter('kernel.bundles');
        $mediaChooserLink = null;

        if (array_key_exists('KunstmaanMediaBundle', $allBundles)) {
            $params = ['linkChooser' => 1];
            $cKEditorFuncNum = $request->get('CKEditorFuncNum');
            if (!empty($cKEditorFuncNum)) {
                $params['CKEditorFuncNum'] = $cKEditorFuncNum;
            }
            $mediaChooserLink = $this->generateUrl(
                'KunstmaanMediaBundle_chooser',
                $params
            );
        }

        return [
            'mediaChooserLink' => $mediaChooserLink,
        ];
    }
1355244
public function show(Request $request)
    {
        $count = $request->query->get('count', \Bolt\Stack::MAX_ITEMS);
        $options = $request->query->get('options');

        if ($options === 'ck') {
            $template = '@bolt/components/stack/ck.twig';
        } elseif ($options === 'list') {
            $template = '@bolt/components/stack/list.twig';
        } else {
            $template = '@bolt/components/stack/panel.twig';
        }

        $context = [
            'count'     => $count,
            'filetypes' => $this->getOption('general/accept_file_types'),
            'namespace' => $this->app['upload.namespace'],
            'canUpload' => $this->isAllowed('files:uploads'),
        ];

        return $this->render($template, ['context' => $context]);
    }
1215677
public function preview(HTTPRequest $request)
    {
        // Ensure this URL doesn't get picked up by HTTP caches
        HTTPCacheControlMiddleware::singleton()->disableCache();

        $key = $request->param('Key');
        $token = $request->param('Token');
        try {
            $session = $this->getRequest()->getSession();
        } catch (BadMethodCallException $e) {
            // Create a new session
            $session = $this->getRequest()
                ->setSession(Injector::inst()->create(Session::class, []))
                ->getSession();
        }
        /** @var ShareToken $shareToken */
        $shareToken = ShareToken::get()->filter('Token', $token)->first();

        if (!$shareToken) {
            return $this->errorPage();
        }

        /** @var SiteTree|ShareDraftContentSiteTreeExtension $page */
        $page = Versioned::get_by_stage(SiteTree::class, Versioned::DRAFT)
            ->byID($shareToken->PageID);

        $latest = Versioned::get_latest_version(SiteTree::class, $shareToken->PageID);

        $controller = $this->getControllerFor($page);

        if (!$shareToken->isExpired() && $page->generateKey($shareToken->Token) === $key) {
            Requirements::css('silverstripe/sharedraftcontent: client/dist/styles/bundle-frontend.css');

            // Temporarily un-secure the draft site and switch to draft
            $oldSecured = $this->getIsDraftSecured($session);
            $oldMode = Versioned::get_reading_mode();

            // Process page inside an unsecured draft container
            try {
                $this->setIsDraftSecured($session, false);
                Versioned::set_stage('Stage');

                // Hack to get around ContentController::init() redirecting on home page
                $_FILES = array(array());

                // Create mock request; Simplify request to single top level request
                $pageRequest = new HTTPRequest('GET', $page->URLSegment);
                $pageRequest->match('$URLSegment//$Action/$ID/$OtherID', true);
                $pageRequest->setSession($session);
                $rendered = $controller->handleRequest($pageRequest);

                // Render draft heading
                $data = new ArrayData(array(
                    'Page' => $page,
                    'Latest' => $latest,
                ));
                $include = (string) $data->renderWith('Includes/TopBar');
            } finally {
                $this->setIsDraftSecured($session, $oldSecured);
                Versioned::set_reading_mode($oldMode);
            }

            return str_replace('</body>', $include . '</body>', (string) $rendered->getBody());
        } else {
            return $this->errorPage();
        }
    }
928582
public function getElementHtml(Request $request)
    {
        $attributes = $this->repository->findMany($request->get('attribute_id'));

        $tmpString = '__RANDOM__STRING__';
        $view = view('avored-ecommerce::attribute.get-element')
            ->with('attributes', $attributes)
            ->with('tmpString', $tmpString);

        return new JsonResponse(['success' => true, 'content' => $view->render()]);
    }
607071
public function index(ApiRequest $request)
    {
        $this->crude = CrudeInstance::get($request->crudeName);

        $page = $request->input('page', 1);
        $numRows = $request->input('numRows', config('crude.defaults.numRows'));
        $sortAttr = $request->input('sortAttr', config('crude.defaults.sortAttr'));
        $sortOrder = $request->input('sortOrder', config('crude.defaults.sortOrder'));
        $searchAttr = $request->input('searchAttr', config('crude.defaults.searchAttr'));
        $searchValue = $request->input('searchValue', '');
        $richFilters = $request->input('richFilters', []);

        $count = $this->crude->countFiltered($searchAttr, $searchValue, $richFilters);
        $numPages = $numRows > 0
            ? ceil($count / $numRows)
            : 1;

        if ($page < 1)
            $page = 1;
        if ($page > $numPages)
            $page = $numPages;

        $collection = $this->crude->getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters);

        return $this->successResponse([
            'collection' => $collection,
            'pagination' => [
                'page' => $page,
                'numRows' => $numRows,
                'numPages' => $numPages,
                'count' => $count,
            ],
            'sort' => [
                'attr' => $sortAttr,
                'order' => $sortOrder
            ],
            'search' => [
                'attr' => $searchAttr,
                'value' => $searchValue
            ],

            'setup' => $this->crude->getCrudeSetupData()
        ]);
    }
754810
public function submitAction(Request $request)
    {
        $template = 'EnhavoSearchBundle:Admin:Search/result.html.twig';

        $term = $request->get('q', '');

        $filter = new Filter();
        $filter->setTerm($term);

        $results = $this->searchEngine->searchPaginated($filter);
        $results = $this->resultConverter->convert($results, $term);

        return $this->render($template, [
            'results' => $results,
            'term' => $term
        ]);
    }
1074729
protected function getFilters(Request $request)
    {
        $type = $this->getFilterType($request);

        if (!$type) {
            return $request->query->get('search')['value'];
        }

        $filter = new $type();

        $param = $filter->getBlockPrefix();

        return $request->query->get($param);
    }
260185
public function indexAction(Request $request)
    {

        $page = $request->get("page", 1);
        $em = $this->getDoctrine()->getManager();
        $dql = "SELECT p FROM AmulenPageBundle:Page p";
        $query = $em->createQuery($dql);
        $paginator = $this->get('knp_paginator');
        $pagination = $paginator->paginate($query, $this->get('request')->query->get('page', $page));

        return array(
            'pagination' => $pagination,
        );
    }
809142
public function searchAction(Request $request)
    {
        $expression = $request->request->get('expression');

        $results = $this->get('ekyna_cms.wide_search')->search($expression);

        return $this->render('@EkynaCms/Cms/search.html.twig', array(
            'expression' => $expression,
            'results'    => $results,
        ))->setPrivate();
    }
833663
public function search(Request $request): Response
    {
        $configResolver = $this->getConfigResolver();
        $queryType = $this->getQueryTypeRegistry()->getQueryType('NetgenSite:Search');

        $searchText = trim($request->query->get('searchText', ''));

        if (empty($searchText)) {
            return $this->render(
                $configResolver->getParameter('template.search', 'ngsite'),
                [
                    'search_text' => '',
                    'pager' => null,
                ]
            );
        }

        $pager = new Pagerfanta(
            new FindAdapter(
                $queryType->getQuery(['search_text' => $searchText]),
                $this->getSite()->getFindService()
            )
        );

        $pager->setNormalizeOutOfRangePages(true);
        $pager->setMaxPerPage((int) $configResolver->getParameter('search.default_limit', 'ngsite'));

        $currentPage = $request->query->getInt('page', 1);
        $pager->setCurrentPage($currentPage > 0 ? $currentPage : 1);

        return $this->render(
            $configResolver->getParameter('template.search', 'ngsite'),
            [
                'search_text' => $searchText,
                'pager' => $pager,
            ]
        );
    }
1060023
private function getRequestOptions(Request $request)
    {
        $options = [
            'http_errors' => false,
            'synchronous' => true
        ];

        if ($request->getQuery()) {
            $options['query'] = array_merge($this->getDefaultQuery(), $request->getQuery());
        } else {
            $options['query'] = $this->getDefaultQuery();
        }
        if ($request->getParams())
            $options['json'] = $request->getParams();

        return $options;
    }
686249
public function queryAction(Request $request)
    {
        $query = $this->getRequestParameter($request, 'q', true);

        $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocale();
        $webspace = $this->requestAnalyzer->getWebspace();

        $queryString = '';
        if (strlen($query) < 3) {
            $queryString .= '+("' . self::escapeDoubleQuotes($query) . '") ';
        } else {
            $queryValues = explode(' ', $query);
            foreach ($queryValues as $queryValue) {
                if (strlen($queryValue) > 2) {
                    $queryString .= '+("' . self::escapeDoubleQuotes($queryValue) . '" OR ' .
                        '"' . preg_replace('/([^\pL\s\d])/u', '?', $queryValue) . '*" OR ' .
                        '"' . preg_replace('/([^\pL\s\d])/u', '', $queryValue) . '~") ';
                } else {
                    $queryString .= '+("' . self::escapeDoubleQuotes($queryValue) . '") ';
                }
            }
        }

        $hits = $this->searchManager
            ->createSearch($queryString)
            ->locale($locale)
            ->index('page_' . $webspace->getKey() . '_published')
            ->execute();

        $template = $webspace->getTemplate('search', $request->getRequestFormat());

        if (!$this->twig->getLoader()->exists($template)) {
            throw new NotFoundHttpException();
        }

        return new Response($this->twig->render(
            $template,
            $this->parameterResolver->resolve(
                ['query' => $query, 'hits' => $hits],
                $this->requestAnalyzer
            )
        ));
    }
778712
public function listAction(Request $request)
    {
        $type = $request->get('type', Elementtype::TYPE_FULL);

        $elementtypeService = $this->get('phlexible_elementtype.elementtype_service');

        $elementtypes = [];
        foreach ($elementtypeService->findAllElementtypes() as $elementtype) {
            if ($type !== $elementtype->getType()) {
                continue;
            }

            if ($elementtype->getDeleted()) {
                continue;
            }

            $elementtypes[$elementtype->getTitle().$elementtype->getId()] = [
                'id' => $elementtype->getId(),
                'title' => $elementtype->getTitle(),
                'icon' => $elementtype->getIcon(),
                'version' => $elementtype->getRevision(),
                'type' => $elementtype->getType(),
            ];
        }

        ksort($elementtypes);
        $elementtypes = array_values($elementtypes);

        $checker = $this->get('phlexible_element.checker');
        $changes = $checker->check();
        $hasChanges = false;
        foreach ($changes as $change) {
            if ($change->getNeedImport()) {
                $hasChanges = true;
                break;
            }
        }

        return new JsonResponse([
            'elementtypes' => $elementtypes,
            'total' => count($elementtypes),
            'changes' => $hasChanges,
        ]);
    }
1182157
public function search(SearchRequest $request)
    {
        $this->eventDispatcher->dispatch(ONGRFilterManagerEvents::PRE_SEARCH, new PreSearchEvent($request));

        $search = $this->container->buildSearch($request);

        /** @var FilterInterface $filter */
        foreach ($this->container->all() as $name => $filter) {
            $relatedSearch = new Search();

            if ($filter->isRelated()) {
                // We simply exclude not related filters and current filter itself.
                $relatedFilters = $this->container->getFiltersByRelation(
                    new AndRelation([$filter->getSearchRelation(), new ExcludeRelation([$name])])
                );
                $relatedSearch = $this->container->buildSearch($request, $relatedFilters);
            }

            $this->eventDispatcher->dispatch(
                ONGRFilterManagerEvents::PRE_PROCESS_SEARCH,
                new PreProcessSearchEvent($request->get($name), $relatedSearch)
            );

            $filter->preProcessSearch(
                $search,
                $relatedSearch,
                $request->get($name)
            );
        }

        $result = $this->repository->findDocuments($search);
        $this->eventDispatcher->dispatch(ONGRFilterManagerEvents::SEARCH_RESPONSE, new SearchResponseEvent($result));

        return new SearchResponse(
            $this->getFiltersViewData($result, $request),
            $result,
            $this->composeUrlParameters($request),
            $this->serializer
        );
    }