Skip to content

Commit

Permalink
Merge pull request #3 from iCAPLyon1/master
Browse files Browse the repository at this point in the history
Fixed plugin for Claroline's v8
  • Loading branch information
ptsavdar authored Oct 25, 2016
2 parents fd26ed2 + a917daa commit 1800d87
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 126 deletions.
9 changes: 3 additions & 6 deletions Controller/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* @Route("/inwicast/mediacenter/media")
Expand Down Expand Up @@ -51,7 +52,6 @@ public function viewAction(Request $request, $mediaRef)
/**
* @Route("/post/{widgetId}", requirements={"widgetId" = "\d+"}, name="inwicast_mediacenter_media_post")
* @Method({"POST"})
* @Template("InwicastClarolinePluginBundle:Media:view.html.twig")
* @ParamConverter("user", options={"authenticatedUser" = true})
* @ParamConverter("widget", class="ClarolineCoreBundle:Widget\WidgetInstance", options={"id" = "widgetId"})
*/
Expand All @@ -65,12 +65,9 @@ public function postAction(Request $request, WidgetInstance $widget, User $user)

$mediaRef = $request->get("media_ref");
$mediaManager = $this->getMediaManager();
$media = $mediaManager->processPost($mediaRef, $widget, $mediacenter, $user);
$mediaManager->processPost($mediaRef, $widget, $mediacenter, $user);

return array(
'media' => $media,
'mediacenter' => $mediacenter
);
return new Response('success', 204);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Controller/MediacenterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
class MediacenterController extends Controller
{
/**
* @Route("/update", name="inwicast_mediacenter_update")
* @Route("/admin/configure", name="inwicast_mediacenter_configure")
* @Method({"GET", "POST"})
* @Template("InwicastClarolinePluginBundle:Mediacenter:form.html.twig")
* @param Request $request
* @return array
*/
public function updateAction(Request $request)
public function configureAction(Request $request)
{
$this->checkAdmin();
$mediacenterManager = $this->getMediacenterManager();
Expand All @@ -55,7 +55,7 @@ public function updateAction(Request $request)
}

/**
* @Route("/update/success", name="inwicast_mediacenter_update_success")
* @Route("/admin/configure/success", name="inwicast_mediacenter_configure_success")
* @Method({"GET"})
* @Template()
*
Expand Down
35 changes: 35 additions & 0 deletions Listener/AdministrationToolListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* This file is part of the Claroline Connect package
*
* (c) Claroline Consortium <[email protected]>
*
* Author: Panagiotis TSAVDARIS
*
* Date: 10/24/16
*/

namespace Inwicast\ClarolinePluginBundle\Listener;

use JMS\DiExtraBundle\Annotation as DI;
use Claroline\CoreBundle\Event\OpenAdministrationToolEvent;
use Claroline\CoreBundle\Listener\AdministrationToolListener as BaseAdministrationToolListener;

/**
* Class AdministrationToolListener
* @package Inwicast\ClarolinePluginBundle\Listener
*
* @DI\Service()
*/
class AdministrationToolListener extends BaseAdministrationToolListener
{
/**
* @DI\Observe("administration_tool_inwicast_configuration")
*
* @param OpenAdministrationToolEvent $event
*/
public function onOpenInwicastConfiguration(OpenAdministrationToolEvent $event)
{
$this->redirect(['_controller' => 'InwicastClarolinePluginBundle:Mediacenter:configure'], $event);
}
}
18 changes: 0 additions & 18 deletions Listener/ClarolinePluginListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,6 @@ public function __construct(
$this->templating = $container->get('templating');
}

/**
* @DI\Observe("plugin_options_clarolinepluginbundle")
*/
public function onPluginConfigure(PluginOptionsEvent $event)
{
$mediacenterManager = $this->getMediacenterManager();
$form = $mediacenterManager->getMediacenterForm();
$content = $this->templating->render(
'InwicastClarolinePluginBundle:Mediacenter:form.html.twig',
array(
'form' => $form->createView()
)
);

$event->setResponse(new Response($content));
$event->stopPropagation();
}

//-------------------------------
// WIDGET SERVICES
//-------------------------------
Expand Down
7 changes: 5 additions & 2 deletions Resources/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugin:
has_options: true
has_options: false
icon: res_inwicast.png

# Widgets declared by your plugin.
Expand All @@ -14,4 +14,7 @@ plugin:
- name: inwicast_portal
class: play-circle
is_displayable_in_workspace: false
is_displayable_in_desktop: true
is_displayable_in_desktop: true
admin_tools:
- name: inwicast_configuration
class: play-circle
78 changes: 78 additions & 0 deletions Resources/modules/list/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import $ from 'jquery'

(function($){
window.select = function(mediaTitle, mediaNb, mediaRef) {
$('#inwicast_widget_name').val(mediaTitle)
$('#inwicast_widget_submit').prop("disabled", false)
var items = $('#inwicast-items .thumbnail.item-selected')
$(items).each(function (index, element) {
$(element).removeClass('item-selected')
})
$('#inwicast-items .thumbnail').eq(mediaNb).addClass('item-selected')
}

window.setDisplay = function(type) {
if (type == 'grid') {
$(".list-media").css("display", "none")
$(".media").css("display", "block")
$("#setList").removeClass("active")
$("#setGrid").addClass("active")
searchForMedia(null)
}
else if (type == 'list') {
$(".media").css("display", "none")
$(".list-media").css("display", "block")
$("#setList").addClass("active")
$("#setGrid").removeClass("active")
searchForMedia(null)
}
}

window.getSelectedMediaIframe = function()
{
var selectedMedia = $("input:radio[name='media_ref']:checked")
if (selectedMedia.length > 0) {
var path = window.inwicastMediaViewPath
path = path.replace("_mediaRef_", selectedMedia.val())
return "<iframe src='"+path+"' width='"+selectedMedia.data('width')+"' height='"+selectedMedia.data('height')+"' frameborder='0' scrolling='no' marginwidth='0' marginheight='0'></iframe>"
}

return ""
}

function searchForMedia(event) {
if (event!=null) event.preventDefault();
// Get value from input
var value = $("#search-inwicast").val();

// Don't search if input is empty...
if (value != '') {
// AJAX request
$.ajax({
url: "{{ path('inwicast_mediacenter_user_videos_search') }}?keywords=" + value,
cache: false
})
.done(function (json) {
// Hide all items
$(".thumbnail").css("display", "none");
$(json.videos).each(function (index, element) {
// Display element matching with search
$("#thumb-"+element.mediaRef).css("display", "block")
});
});
}
// But display all items!
else {
$(".thumbnail").css("display", "block");
}
}

$("#search-inwicast").on("keypress", function(ev){
var keycode = (ev.keyCode ? ev.keyCode : ev.which)
if (keycode == 13) {
searchForMedia(ev)
ev.preventDefault()
}
})

})($)
3 changes: 2 additions & 1 deletion Resources/translations/tools.en.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
inwicast_portal: 'Mediacenter'
inwicast_portal: 'Mediacenter'
inwicast_configuration: 'Inwicast configuration'
3 changes: 2 additions & 1 deletion Resources/translations/tools.es.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
inwicast_portal: 'Mediacenter'
inwicast_portal: 'Mediacenter'
inwicast_configuration: 'Configuración Inwicast'
3 changes: 2 additions & 1 deletion Resources/translations/tools.fr.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
inwicast_portal: 'Accès Mediacenter'
inwicast_portal: 'Accès Mediacenter'
inwicast_configuration: 'Configuration inwicast'
3 changes: 2 additions & 1 deletion Resources/translations/widget.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ error_get_medialist: 'An error as occurded while consulting mediacenter.'
error_empty_mediacenter: 'No video available in mediacenter.'
error_loading_media: 'Failed to load the selected video.'
no_mediacenter: 'Platform mediacenter is not set. Ask your administrator to set it by the plugins parameters panel.'
back_to_packages: 'Back to plugin packages'
back_to_parameters: 'Back to plugin packages'
reconfigure: 'Reconfigure'
mediacenter_url_updated: 'The mediacenter URL was updated successfully.'
error_bad_url: 'The URL you entered is not valid.'
connected_as: 'Logged in as'
Expand Down
3 changes: 2 additions & 1 deletion Resources/translations/widget.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ error_get_medialist: 'Se ha producido un error durante el MediaCenter consulta.'
error_empty_mediacenter: 'Ningún vídeo disponible en el MediaCenter.'
error_loading_media: 'No se pudo cargar el vídeo seleccionado.'
no_mediacenter: 'Mediacenter Plataforma no está establecida. Pregunte al administrador para configurarlo a través del panel de control de los plugins.'
back_to_packages: 'Volver a los plugin packages'
back_to_parameters: 'Volver a los parámetros'
reconfigure: 'Reconfigurar'
mediacenter_url_updated: 'El MediaCenter URL ha cambiado correctamente.'
error_bad_url: 'La URL que has introducido no es válido'
connected_as: 'Conectado como'
Expand Down
3 changes: 2 additions & 1 deletion Resources/translations/widget.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ error_get_medialist: 'Une erreur s''est produite lors de la consultation du medi
error_empty_mediacenter: 'Aucune vidéo n''est disponible sur le médiacenter.'
error_loading_media: 'Impossible de charger la vidéo sélectionnée.'
no_mediacenter: 'Le médiacenter de la plateforme n''a pas été configuré. Demandez à votre administrateur de le modifier via le panneau des paramètres des plugins.'
back_to_packages: 'Retour aux paquets des plugins'
back_to_parameters: 'Retour aux paramètres'
reconfigure: 'Reconfigurer'
mediacenter_url_updated: 'L''URL du médiacenter a été modifiée avec succès.'
error_bad_url: 'L''URL saisie n''est pas valide.'
connected_as: 'Connecté en tant que'
Expand Down
13 changes: 2 additions & 11 deletions Resources/views/Media/videosList.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,16 @@
<strong>{{ "warning"|trans({}, 'widget') }}</strong> {{ "error_empty_mediacenter"|trans({}, 'widget') }}
</div>
{% else %}

<form action="{{ path('inwicast_mediacenter_media_post', {'widgetId': widget.getId()}) }}" method="post"
id="inwicast_claroline_plugin_diplay">
id="inwicast_claroline_plugin_diplay" class="widget-content-config-form">
<link href="{{ asset('bundles/inwicastclarolineplugin/css/design.css') }}" type="text/css" rel="stylesheet"/>
{% include 'InwicastClarolinePluginBundle:Media:videosListTpl.html.twig' with {'medialist' : medialist} %}
<br/>

<div class="row container">
<div class="row container-fluid">
<div class="col-md-6">
<input class="form-control" type="text" id="inwicast_widget_name" name="inwicast_widget_link" disabled/>
</div>
<div class="col-md-3">
<input class="btn btn-block btn-success" type="submit" id="inwicast_widget_submit"
value="{{ 'validate'|trans({}, 'widget') }}" disabled/>
</div>
<div class="col-md-3">
<input class="btn btn-block btn-danger claro-widget-form-cancel" type="button"
value="{{ 'cancel'|trans({}, 'platform') }}"/>
</div>
</div>
</form>
{% endif %}
6 changes: 5 additions & 1 deletion Resources/views/Media/videosListTinymce.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

{% block javascripts_header %}
{{ parent() }}
{% include 'ClarolineCoreBundle:Layout:javascripts.html.twig' %}
<script type="text/javascript" src='{{ asset('packages/jquery/dist/jquery.min.js') }}'></script>
{% if app.environment == 'prod' %}
<script src="{{ hotAsset('dist/commons.js') }}"></script>
{% endif %}
{% endblock %}

{% block layout %}
Expand All @@ -24,5 +27,6 @@
{% endblock %}

{% block javascripts %}
{{ parent() }}
<script type="text/javascript" src='{{ asset('bundles/clarolinecore/js/iframe/iframe.js') }}'></script>
{% endblock %}
Loading

0 comments on commit 1800d87

Please sign in to comment.