Skip to content
Snippets Groups Projects
Commit 60997dd5 authored by Laurent's avatar Laurent
Browse files

dev #86160 fix fetch premiere descriptionAuthor page: fix url replacements for...

dev #86160 fix fetch premiere descriptionAuthor page: fix url replacements for M. Get only first iframe of INA interviews
parent 8ee4d4af
Branches
Tags
3 merge requests!3297WIP: Master,!2995Sandbox author page ina,!2990Sandbox author page ina
Pipeline #6229 passed with stage
in 32 minutes and 51 seconds
......@@ -32,10 +32,9 @@ class AuthorController extends ZendAfi_Controller_Action {
public function renderYoutubeChannelAction() {
session_write_close();
$this->getHelper('ViewRenderer')->setNoRender();
if (!$author = $this->_findAuthor())
return;
return $this->_helper->HTMLAjaxResponse('');
$items = [];
foreach((new Class_WebService_Youtube())
......@@ -46,15 +45,11 @@ class AuthorController extends ZendAfi_Controller_Action {
'allowfullscreen' => 'true'])
.
$this->view->tag('h3', $video->getTitle()));
if (3 == count($items))
break;
}
$html = $this->view->tag('div', implode($items));
$html = $this->view->tag('div', implode(array_slice($items, 0, 3)));
$this->_response->setHeader('Content-Type', 'text/html;charset=utf-8');
$this->_response->setBody($html);
$this->_helper->HTMLAjaxResponse($html);
}
......
......@@ -34,12 +34,6 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
public function preDispatch() {
parent::preDispatch();
// Desactiver le view renderer normal pour tous les modes sauf notice
if ($this->_request->getParam("action") != "notice") {
$viewRenderer = $this->getHelper('ViewRenderer');
$viewRenderer->setNoRender();
}
$this->notice = $this->extractNoticeFromRequest();
$this->id_notice = $this->notice->getId();
}
......@@ -101,12 +95,8 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
public function renderExemplaires($notice_ids, $nb_notices_oeuvre, $display) {
session_write_close();
$this->getResponse()->setHeader('Content-Type', 'text/html;charset=utf-8');
if (!$this->notice->hasExemplaires()) {
$this->getResponse()->setBody('');
return;
}
if (!$this->notice->hasExemplaires())
return $this->_sendResponse('');
$exemplaires = $this->_loadExemplaire(["id_notice" => $notice_ids]);
foreach($exemplaires as $exemplaire)
......@@ -476,7 +466,6 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
protected function _sendResponse($data) {
$this->getResponse()->setHeader('Content-Type', 'text/html;charset=utf-8');
$this->getResponse()->setBody($data);
$this->_helper->HTMLAjaxResponse($data);
}
}
\ No newline at end of file
......@@ -241,7 +241,7 @@ class Class_CodifAuteur_Description {
'action' => 'view']) . '/id/';
foreach($associated_authors as $association) {
$author_label = $association['author']->getLibelle();
$search []= '%\b' . str_replace('%', '\%', preg_quote($author_label)) . '\b%i';
$search []= '%\b' . str_replace('%', '\%', preg_quote($author_label)) . '\b%u';
$replace []= $view->tag('a',
$author_label,
['href' => $base_url . $association['author']->getId(),
......
......@@ -21,12 +21,16 @@
class Class_WebService_Youtube extends Class_WebService_Abstract {
const
FEEDS_URL = 'https://www.youtube.com/feeds/videos.xml',
CHANNEL_URL = 'https://www.youtube.com/channel/',
EMBED_URL = 'https://www.youtube.com/embed/';
public function videosOfChannel($channel) {
if (!$channel)
return new Storm_Collection([]);
$rss = $this->httpGet('https://www.youtube.com/feeds/videos.xml?'
. http_build_query(['channel_id' => $channel]));
$rss = $this->httpGet(static::FEEDS_URL . '?' . http_build_query(['channel_id' => $channel]));
try {
$xml = new SimpleXMLElement($rss);
......@@ -49,6 +53,6 @@ class Class_WebService_Youtube extends Class_WebService_Abstract {
class Class_WebService_Youtube_Video extends Class_Entity {
public function getEmbedUrl() {
return 'https://www.youtube.com/embed/' . $this->getId();
return Class_WebService_Youtube::EMBED_URL . $this->getId();
}
}
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Controller_Action_Helper_HTMLAjaxResponse extends Zend_Controller_Action_Helper_Abstract {
public function direct($content) {
$viewRenderer = $this->getActionController()->getHelper('ViewRenderer');
$viewRenderer->setNoRender();
$this->getResponse()->setHeader('Content-Type', 'text/html;charset=utf-8');
$this->getResponse()->setBody($content);
}
}
\ No newline at end of file
......@@ -66,7 +66,7 @@ class ZendAfi_View_Helper_RenderAuthorDescription extends ZendAfi_View_Helper_Ba
$id = 'interviews-' . uniqid();
Class_ScriptLoader::getInstance()
->addJQueryReady(sprintf('$("#%s").load("%s iframe")',
->addJQueryReady(sprintf('$("#%s").load("%s #interview_1")',
$id,
$this->view->url(['controller' => 'noticeajax',
'action' => 'videos',
......
......@@ -38,7 +38,7 @@ class ZendAfi_View_Helper_renderAuthorMetadata extends ZendAfi_View_Helper_BaseH
if ($id = $attributes['youtube_channel_id'])
$attributes['youtube_channel_id'] = $this->_tag('a',
$id,
['href' => 'https://www.youtube.com/channel/' . $id]);
['href' => Class_WebService_Youtube::CHANNEL_URL . $id]);
return
$this->_tag('h2', $this->_('Auteur : %s',
......
......@@ -144,6 +144,25 @@ class AuthorPageViewIncompleteAuthor extends AuthorPageTestCase {
class AuthorPageViewAuthorWithoutRecordTest extends AuthorPageTestCase {
/** @test */
public function pageShouldHaveH1WithSuperCanard() {
$this->fixture('Class_CodifAuteur',
['id' => 666,
'libelle' => 'Super canard']);
$this->mock_sql->whenCalled('fetchAll')
->with('select id_notice, facettes from notices Where (MATCH(facettes) AGAINST(\'+A666\' IN BOOLEAN MODE)) and type=1', true, false)
->answers([]);
$this->dispatch('/author/view/id/666');
$this->assertXPathContentContains('//h1', 'Super canard');
}
}
class AuthorPageViewByIdTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
......@@ -356,10 +375,10 @@ class AuthorPagePhoneTest extends AuthorPageTestCase {
class AuthorPageViewByNameTest extends AuthorPageTestCase {
/** @test */
public function searchVictorHugoShouldShowVictorHugo() {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAuteur')
->whenCalled('findWithFullName')
->with('Victor Hugo')
->answers(Class_CodifAuteur::find(2408));
$this->onLoaderOfModel('Class_CodifAuteur')
->whenCalled('findWithFullName')
->with('Victor Hugo')
->answers(Class_CodifAuteur::find(2408));
$this->dispatch('/author/view/named/Victor+Hugo');
......@@ -369,7 +388,7 @@ class AuthorPageViewByNameTest extends AuthorPageTestCase {
/** @test */
public function searchUnknownShouldDisplay404() {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAuteur')
$this->onLoaderOfModel('Class_CodifAuteur')
->whenCalled('findWithFullName')
->answers(null);
......@@ -498,6 +517,13 @@ class AuteurPageNoticeAjaxRenderYoutubeChannelTest extends AuthorPageTestCase {
}
/** @test */
public function numberOfIframesShouldBeThree() {
$this->assertXPathCount('//iframe', 3);
}
/** @test */
public function playlist441TitleShouldBePresent() {
$this->assertXPathContentContains('//h3', 'David Guetta Playlist 441');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment