Commit 728bb364 authored by Laurent's avatar Laurent
Browse files

dev #65267 add upload trailer

parent a5a1b9ea
'65267' =>
['Label' => $this->_('[Bonus] Modération des vidéos'),
'Desc' => '',
'Image' => '',
'Video' => '',
'Category' => '',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => '',
'Test' => '',
'Date' => '2017-11-27'],
\ No newline at end of file
- ticket #65267 : [Bonus] Modération des vidéos
\ No newline at end of file
......@@ -77,4 +77,23 @@ class Admin_RecordsController extends ZendAfi_Controller_Action {
$this->view->form = $form;
}
public function trailerAction() {
$this->view->titre = $this->_('Modifier la bande-annonce');
$form = new ZendAfi_Form_RecordTrailer(['action' => $this->view->url()]);
if ($this->_request->isPost()
&& $form->isValid($this->_request->getPost())) {
if (!$this->view->error = Class_WebService_AllServices::uploadTrailerForRecord($this->_getParam('trailer_url'),
$this->_getParam('id'))) {
$this->_helper->notify($this->_('La bande-annonce a bien été mise à jour'));
$this->_redirectClose($this->_getReferer());
return;
}
}
$this->view->form = $form;
}
}
<?php
if ($this->error)
echo $this->tag('p', $this->error, ['class' => 'error']);
echo $this->renderForm($this->form);
......@@ -227,6 +227,8 @@ class NoticeAjaxController extends Zend_Controller_Action {
$args= ['titre' => $this->notice->getRecordTitle(),
'auteur' => $this->notice->getAuteurPrincipal(),
'clef_oeuvre' => $this->notice->getClefOeuvre(),
'type_doc' => $this->notice->getFamilleId(),
'width' => $width,
'height' => $height];
......@@ -235,9 +237,22 @@ class NoticeAjaxController extends Zend_Controller_Action {
$bo=$data["player"];
$html=$this->notice_html->getBandeAnnonce($source,$bo);
}
else
$html= $html=$this->notice_html->getNonTrouve($this->view->_("Service non disponible"),true);
else {
$html = $this->notice_html->getNonTrouve($this->view->_("Service non disponible"),true);
}
if (Class_Users::isCurrentUserCanAccesBackend()) {
$url = $this->view->url(['module' => 'admin',
'controller' => 'records',
'action' => 'trailer',
'id' => $this->notice->getId()]);
$html = $html . $this->view->tag('a', $this->_('Modifier la bande-annonce'),
['href' => $url, 'data-popup' => 'true']);
}
$this->_sendResponseWithScripts($html);
}
......
......@@ -97,6 +97,11 @@ class Class_WebService_AllServices {
}
public static function runServiceAfiUploadTrailer($args) {
return self::runServiceAfi(14, $args);
}
public static function runServiceGetUrlVignette($args) {
return self::runServiceAfi(10, $args);
}
......@@ -138,6 +143,19 @@ class Class_WebService_AllServices {
}
public static function uploadTrailerForRecord($url, $id) {
$notice = Class_Notice::find($id);
$result = static::runServiceAfiUploadTrailer(array_filter(['trailer_url' => $url,
'clef_oeuvre' => $notice->getClefOeuvre(),
'type_doc' => $notice->getFamilleId()]));
if (self::RETOUR_SERVICE_OK != $result['statut_recherche'])
return $result['message'];
}
public static function httpGet($url, $args) {
if (!isset(self::$_http_client))
self::$_http_client = new Class_WebService_SimpleWebClient();
......
<?php
/**
* Copyright (c) 2012, 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_Form_RecordTrailer extends ZendAfi_Form {
public function init() {
parent::init();
$this
->addElement('url',
'trailer_url',
['label' => $this->_('URL de la bande-annonce'),
'size' => 80,
'required' => true,
'placeholder' => 'ex: https://youtu.be/AUI12X'])
->addElement('submit',
'envoyer',
['label' => 'Envoyer']);
}
}
?>
\ No newline at end of file
......@@ -467,6 +467,8 @@ class NoticeAjaxControllerBandeAnnonceTest extends AbstractControllerTestCase {
Storm_Test_ObjectWrapper::mock()
->whenCalled('open_url')
->answers(json_encode(['source' => 'Testing', 'player' => 'toto'])));
$admin = Class_Users::newInstanceWithId(15,['login'=>'admin'])->beAdminPortail();
Zend_Auth::getInstance()->logUser($admin);
$this->dispatch('noticeajax/bandeannonce', true);
$this->assertXPathContentContains('//h3', 'Source : Testing', $this->_response->getBody());
}
......
Markdown is supported
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