Search medias.

@param Request $request

@return Response array of medias
509499
public function searchMediaAction(Request $request)
    {
        $response = $this->getFilter($request);
        if ($response['success'] === false) {
            return $response['value'];
        }
        $filter = $response['crypted'];

        $mm = $this->getMediaManager();

        $q = ($request->query->has('q')) ? $request->query->get('q') : null;
        $type = ($request->query->has('type')) ? $request->query->get('type') : null;

        $medias = $mm->search($filter, $q, $type);

        return $this->createResponse($medias);
    }
150943
public function delete(Request $request)
    {
        $isOk = "OK";
        // loop throw file array
        foreach ($request->all() as $key => $file){
            if ($key === "postTypes") {
                continue;
            }

            // check if user has permissions to access this link
            if(!User::hasAccess('Media', 'delete', $file['mediaID'], true)) {
                return $this->noPermission();
            }

            // get file info from database
            $media = Media::find($file['mediaID']);
            MediaRelation::where("mediaID", $file['mediaID'])->delete();
            if ($media->delete()) { // delete from database
                if(file_exists($media->url)) {
                    unlink($media->url); // delete original file
                }
                $media->deleteThumbs();
            }else{
                $isOk =  "ERR";
            }
        }
        return $isOk;
    }
760984
public function fileAction(Request $request)
    {
        $fileId = $request->get('file_id');

        $volumeManager = $this->get('phlexible_media_manager.volume_manager');

        $volume = $volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);

        $debug = [
            ['key' => 'mimeType', 'value' => $file->getMimeType()],
            ['key' => 'mediaType', 'value' => strtolower($file->getMediaType())],
            ['key' => 'fileId', 'value' => $file->getId()],
            ['key' => 'folderId', 'value' => $file->getFolderId()],
        ];

        return new JsonResponse(['debug' => $debug]);
    }
978101
public function searchAction(Request $request)
    {
        $queryString = $request->query->get('q');
        $index = $request->query->get('index', null);
        $locale = $request->query->get('locale', null);

        $page = $this->listRestHelper->getPage();
        $limit = $this->listRestHelper->getLimit();
        $startTime = microtime(true);

        $indexes = $index ? [$index] : $this->getAllowedIndexes();

        $query = $this->searchManager->createSearch($queryString);

        if ($locale) {
            $query->locale($locale);
        }

        $query->indexes($indexes);
        $query->setLimit($limit);

        $time = microtime(true) - $startTime;

        $adapter = new ArrayAdapter(iterator_to_array($query->execute()));
        $pager = new Pagerfanta($adapter);
        $pager->setMaxPerPage($limit);
        $pager->setCurrentPage($page);

        $representation = new SearchResultRepresentation(
            new CollectionRepresentation($pager->getCurrentPageResults(), 'result'),
            'sulu_search_search',
            [
                'locale' => $locale,
                'query' => $query,
                'index' => $index,
            ],
            (int) $page,
            (int) $limit,
            $pager->getNbPages(),
            'page',
            'limit',
            false,
            $adapter->getNbResults(),
            $this->getIndexTotals($adapter->getArray()),
            number_format($time, 8)
        );

        $view = View::create($representation);
        $context = new Context();
        $context->enableMaxDepth();
        $view->setContext($context);

        return $this->viewHandler->handle($view);
    }
133477
public function searchAction(Request $request)
    {
        if ($request->get('admin') && $request->isXmlHttpRequest()) {
            try {
                $admin = $this->getAdminPool()->getAdminByAdminCode($request->get('admin'));
            } catch (ServiceNotFoundException $e) {
                throw new \RuntimeException('Unable to find the Admin instance', $e->getCode(), $e);
            }

            if (!$admin instanceof AdminInterface) {
                throw new \RuntimeException('The requested service is not an Admin instance');
            }

            $handler = $this->getSearchHandler();

            $results = array();

            if ($pager = $handler->search($admin, $request->get('q'), $request->get('page'), $request->get('offset'))) {
                foreach ($pager->getResults() as $result) {
                    $results[] = array(
                        'label' => $admin->toString($result),
                        'link'  => $admin->generateObjectUrl('show', $result),  // Sonata uses "edit", we prefer "show"
                        'id'    => $admin->id($result),
                    );
                }
            }

            $response = new JsonResponse(array(
                'results' => $results,
                'page'    => $pager ? (int) $pager->getPage() : false,
                'total'   => $pager ? (int) $pager->getNbResults() : false,
            ));
            $response->setPrivate();

            return $response;
        }

        return $this->render($this->container->get('sonata.admin.pool')->getTemplate('search'), array(
            'base_template'       => $this->getBaseTemplate(),
            'breadcrumbs_builder' => $this->get('sonata.admin.breadcrumbs_builder'),
            'admin_pool'          => $this->container->get('sonata.admin.pool'),
            'query'               => $request->get('q'),
            'groups'              => $this->getAdminPool()->getDashboardGroups(),
        ));
    }
390959
public function listAction(Request $request)
    {
        $response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Storage');
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        /* @var $rep StorageRepository */
        $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Storage');

        return $this->render('AnimeDbCatalogBundle:Storage:list.html.twig', [
            'storages' => $rep->getList(),
        ], $response);
    }
1217058
protected function getMediaType(Request $request)
    {
        foreach ($request->getAcceptableContentTypes() as $mimeType) {
            if (preg_match('(^([a-z0-9-/.]+)\+.*$)', strtolower($mimeType), $matches)) {
                return $matches[1];
            }
        }

        return 'unknown/unknown';
    }
985209
public function searchAction(Request $request)
    {
        $this->denyAccessIfProfilerDisabled();

        $ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
        $method = $request->query->get('method');
        $statusCode = $request->query->get('status_code');
        $url = $request->query->get('url');
        $start = $request->query->get('start', null);
        $end = $request->query->get('end', null);
        $limit = $request->query->get('limit');
        $token = $request->query->get('token');

        if ($request->hasSession()) {
            $session = $request->getSession();

            $session->set('_profiler_search_ip', $ip);
            $session->set('_profiler_search_method', $method);
            $session->set('_profiler_search_status_code', $statusCode);
            $session->set('_profiler_search_url', $url);
            $session->set('_profiler_search_start', $start);
            $session->set('_profiler_search_end', $end);
            $session->set('_profiler_search_limit', $limit);
            $session->set('_profiler_search_token', $token);
        }

        if (!empty($token)) {
            return new RedirectResponse($this->generator->generate('_profiler', ['token' => $token]), 302, ['Content-Type' => 'text/html']);
        }

        $tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode);

        return new RedirectResponse($this->generator->generate('_profiler_search_results', [
            'token' => $tokens ? $tokens[0]['token'] : 'empty',
            'ip' => $ip,
            'method' => $method,
            'status_code' => $statusCode,
            'url' => $url,
            'start' => $start,
            'end' => $end,
            'limit' => $limit,
        ]), 302, ['Content-Type' => 'text/html']);
    }
137539
public function index(Request $request)
	{
		$request = $this->getRequest();

		return $this->response()
			->collection($this->getModel()->search($request->input('q', ''))->limit(100)->get())
			->view($this->getView('index'), [
				'entities' => $this->getModel()->getRepository()->all()->get()
			]);
	}
1212374
public function move(Request $request)
    {
        $path = $request->get('path');
        $currentFileName = $request->get('currentItem');
        $newPath = $request->get('newPath');
        $type = $request->get('type');

        $currentFile = str_finish($path, DIRECTORY_SEPARATOR).$currentFileName;
        $newFile = str_finish($newPath, DIRECTORY_SEPARATOR).$currentFileName;

        try {
            if ($type == 'Folder') {
                $result = $this->mediaManager->moveFolder($currentFile, $newFile);
            } else {
                $result = $this->mediaManager->moveFile($currentFile, $newFile);
            }

            if ($result !== true) {
                $error = $this->mediaManager->errors() ?: trans('media-manager::messages.move_error', ['entity' => $type]);

                return $this->errorResponse($error);
            }

            return ['success' => trans('media-manager::messages.move_success', ['entity' => $type])];
        } catch (\Exception $e) {
            return $this->errorResponse($e->getMessage());
        }
    }
397480
public function indexAction(Request $request) {
        $page = $request->get("page", 1);
        $searchStr = $request->get("search");
        $type = $request->get("type");
        $em = $this->getDoctrine()->getManager();
        $query = $em->getRepository("AmulenMediaBundle:Gallery")->getQuerySearch($searchStr, $type);

        $paginator = $this->get('knp_paginator');
        $pagination = $paginator->paginate(
                $query, $this->get('request')->query->get('page', $page));

        return array(
            'pagination' => $pagination,
            'searchStr' => $searchStr,
            'type' => $type,
        );
    }
331337
public function getAction(Request $request)
    {
        $filename = $request->get('file');
        $filename = $this->container->getParameter('phlexible_media_template.previewer.temp_dir').basename($filename);

        $file = new File($filename);

        return new BinaryFileResponse($file);
    }
352762
public function store(Request $request)
    {
        if (is_null(request()->file('media'))) {
            $attributes = request()->validate(array_except(PageContent::$rules, 'media'),
                PageContent::$messages);
        }
        else {
            $attributes = request()->validate(PageContent::$rules, PageContent::$messages);

            $media = $this->moveAndCreatePhoto($attributes['media']);
            if ($media) {
                $attributes['media'] = $media;
            }
        }

        $pageContent = $this->createEntry(PageContent::class, $attributes);

        return redirect('admin/pages/'.$request->page_id.'/sections/content/'.$pageContent->id.'/edit');
    }
85769
public function searchFillerAction(Request $request)
    {
        /* @var $chain ChainFiller */
        $chain = $this->get('anime_db.plugin.filler');
        $response = $this->getResponseFromChain($chain);

        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        $entity = new SearchFiller($chain);
        /* @var $form Form */
        $form = $this->createForm(new SearchFillerForm(), $entity)->handleRequest($request);
        if ($form->isValid()) {
            return $this->redirect($entity->getFiller()->getLinkForFill($entity->getUrl()));
        }

        return $this->render('AnimeDbCatalogBundle:Fill:search_filler.html.twig', [
            'form' => $form->createView(),
        ], $response);
    }
741350
public function index(Request $request)
    {
        $storage_root     = $this->getRootDir();
        $accepted_files   = $this->config->get('media.accepted_files');
        $max_file_size    = $this->config->get('media.max_file_size', 3);
        $this->currentDir = $request->get('folder', $storage_root);

        if ($this->folderIsNotAccessible($request)) {
            return redirect()->route('administrator.media.index');
        }

        $items = $this->buildFileAndDirectoryListing();

        $directories = $this->buildDirectory(
            $this->scanDirectory($storage_root),
            $storage_root
        );

        return view('administrator.media.index')
            ->with('template', $this->template)
            ->with('items', $items)
            ->with('current_directory', $this->currentDir)
            ->with('directories', $directories)
            ->with('accepted_files', $accepted_files)
            ->with('storage_root', $storage_root)
            ->with('max_file_size', $max_file_size);
    }
802583
public function indexAction(Request $request)
    {
        $query = $request->query->get('query');
        $limit = $request->query->get('limit');
        $start = $request->query->get('start');

        $searchProviders = $this->get('search.providers');

        $content = '';
        $content .= '<h3>Registered Search Providers:</h3><table><tr><th>Class</th><th>Resource</th><th>Search key</th></tr>';
        foreach ($searchProviders as $searchProvider) {
            $content .= '<tr>';
            $content .= '<td>'.get_class($searchProvider).'</td>';
            $content .= '<td>'.$searchProvider->getResource().'</td>';
            $content .= '<td>'.$searchProvider->getSearchKey().'</td>';
            $content .= '</tr>';
        }
        $content .= '</table>';

        $content .= '<h3>Search:</h3>';
        $content .= '<form><input name="query" value="'.$query.'"/><input type="submit" value="send" /></form>';

        if ($query) {
            $content .= '<h3>Results:</h3>';
            $search = $this->getContainer()->get('search.search');
            $results = $search->search($query);
            $content .= '<pre>';
            $content .= print_r($results, true);
            $content .= '</pre>';
        }

        return new Response($content);
    }
930971
public function listAction(Request $request)
    {
        $mediaTypeManager = $this->get('phlexible_media_type.media_type_manager');
        $iconResolver = $this->get('phlexible_media_type.icon_resolver');

        $mediaTypes = [];
        foreach ($mediaTypeManager->findAll() as $mediaType) {
            $mediaTypes[] = [
                'id' => $mediaType->getName(),
                'key' => $mediaType->getName(),
                'upperkey' => strtoupper($mediaType->getName()),
                'type' => $mediaType->getCategory(),
                'de' => $mediaType->getTitle('de'),
                'en' => $mediaType->getTitle('en'),
                'mimetypes' => $mediaType->getMimetypes(),
                'icon16' => (bool) $iconResolver->resolve($mediaType, 16),
                'icon32' => (bool) $iconResolver->resolve($mediaType, 32),
                'icon48' => (bool) $iconResolver->resolve($mediaType, 48),
                'icon256' => (bool) $iconResolver->resolve($mediaType, 256),
            ];
        }

        return new JsonResponse([
            'totalCount' => count($mediaTypes),
            'mediatypes' => $mediaTypes,
        ]);
    }