/** * @covers Alchemy\Phrasea\Controller\Admin\Bas::deleteLogo */ public function testDeleteMiniLogo() { if (count(\collection::getLogo(self::$DI['collection']->get_base_id(), self::$DI['app'])) === 0) { $this->markTestSkipped('No logo setted'); } $this->setAdmin(true); $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/mini-logo/delete/'); $json = $this->getJson(self::$DI['client']->getResponse()); $this->assertTrue($json->success); }
/** * * @return String */ public function get_title($highlight = '', SearchEngineInterface $search_engine = null) { if ($this->title) { return $this->title; } $this->title = collection::getLogo($this->get_base_id(), $this->app) . ' '; switch ($this->env) { case "RESULT": $this->title .= $this->app->trans('preview:: resultat numero %number%', ['%number%' => '<span id="current_result_n">' . ($this->number + 1) . '</span> : ']); $this->title .= parent::get_title($highlight, $search_engine); break; case "BASK": $this->title .= $this->name . ' - ' . parent::get_title($highlight, $search_engine) . ' (' . $this->get_number() . '/' . $this->total . ') '; break; case "REG": $title = parent::get_title(); if ($this->get_number() == 0) { $this->title .= $title; } else { $this->title .= sprintf('%s %s', $title, $this->get_number() . '/' . $this->total); } break; default: $this->title .= parent::get_title($highlight, $search_engine); break; } return $this->title; }
/** * * @return string */ public function get_collection_logo() { return collection::getLogo($this->base_id, $this->app, true); }
/** * Queries database to fetch documents * * @param Application $app * @param Request $request * @return Response */ public function query(Application $app, Request $request) { $query = $this->buildQueryFromRequest($request); $displayMode = explode('X', $request->request->get('mod', '3X6')); if (count($displayMode) === 1) { $modRow = (int) $displayMode[0]; $modCol = 1; } else { $modRow = (int) $displayMode[0]; $modCol = (int) $displayMode[1]; } $perPage = $modCol * $modRow; $options = SearchEngineOptions::fromRequest($app, $request); $currentPage = (int) $request->request->get('pag', 0); if ($currentPage < 1) { $app['phraseanet.SE']->resetCache(); $currentPage = 1; } $result = $app['phraseanet.SE']->query($query, ($currentPage - 1) * $perPage, $perPage, $options); $userQuery = new UserQuery(); $userQuery->setUser($app['authentication']->getUser()); $userQuery->setQuery($query); $app['EM']->persist($userQuery); $app['EM']->flush(); if ($app['settings']->getUserSetting($app['authentication']->getUser(), 'start_page') === 'LAST_QUERY') { $app['manipulator.user']->setUserSetting($app['authentication']->getUser(), 'start_page_query', $query); } foreach ($options->getDataboxes() as $databox) { $colls = array_map(function (\collection $collection) { return $collection->get_coll_id(); }, array_filter($options->getCollections(), function (\collection $collection) use($databox) { return $collection->get_databox()->get_sbas_id() == $databox->get_sbas_id(); })); $app['phraseanet.SE.logger']->log($databox, $result->getQuery(), $result->getTotal(), $colls); } $searchData = $result->getResults(); if (count($searchData) === 0) { return new Response($app['twig']->render("client/help.html.twig")); } $resultData = []; foreach ($searchData as $record) { try { $record->get_subdef('document'); $lightInfo = $app['twig']->render('common/technical_datas.html.twig', ['record' => $record]); } catch (\Exception $e) { $lightInfo = ''; } $caption = $app['twig']->render('common/caption.html.twig', ['view' => 'answer', 'record' => $record]); $docType = $record->get_type(); $isVideo = $docType == 'video'; $isAudio = $docType == 'audio'; $isImage = $docType == 'image'; $isDocument = $docType == 'document'; if (!$isVideo && !$isAudio) { $isImage = true; } $canDownload = $app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'candwnldpreview') || $app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'candwnldhd') || $app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'cancmd'); try { $previewExists = $record->get_preview()->is_physically_present(); } catch (\Exception $e) { $previewExists = false; } $resultData[] = ['record' => $record, 'mini_logo' => \collection::getLogo($record->get_base_id(), $app), 'preview_exists' => $previewExists, 'light_info' => $lightInfo, 'caption' => $caption, 'is_video' => $isVideo, 'is_audio' => $isAudio, 'is_image' => $isImage, 'is_document' => $isDocument, 'can_download' => $canDownload, 'can_add_to_basket' => $app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'canputinalbum')]; } return new Response($app['twig']->render("client/answers.html.twig", ['mod_col' => $modCol, 'mod_row' => $modRow, 'result_data' => $resultData, 'per_page' => $perPage, 'search_engine' => $app['phraseanet.SE'], 'search_engine_option' => $options->serialize(), 'history' => \queries::history($app, $app['authentication']->getUser()->getId()), 'result' => $result, 'proposals' => $currentPage === 1 ? $result->getProposals() : null, 'help' => count($resultData) === 0 ? $this->getHelpStartPage($app) : ''])); }