From 94240845008b8c70b252cdb41f21aecdc613fba7 Mon Sep 17 00:00:00 2001 From: ptsavdar Date: Tue, 25 Oct 2016 11:49:10 +0200 Subject: [PATCH 1/2] Fixed plugin for v8 --- Controller/MediaController.php | 9 ++--- Controller/MediacenterController.php | 6 ++-- Listener/AdministrationToolListener.php | 35 +++++++++++++++++++ Listener/ClarolinePluginListener.php | 18 ---------- Resources/config/config.yml | 7 ++-- Resources/translations/tools.en.yml | 3 +- Resources/translations/tools.es.yml | 3 +- Resources/translations/tools.fr.yml | 3 +- Resources/translations/widget.en.yml | 3 +- Resources/translations/widget.es.yml | 3 +- Resources/translations/widget.fr.yml | 3 +- Resources/views/Media/videosList.html.twig | 13 ++----- .../views/Media/videosListTinymce.html.twig | 3 +- Resources/views/Media/videosListTpl.html.twig | 4 +-- Resources/views/Mediacenter/form.html.twig | 2 +- Resources/views/Mediacenter/success.html.twig | 6 ++-- composer.json | 2 +- 17 files changed, 70 insertions(+), 53 deletions(-) create mode 100644 Listener/AdministrationToolListener.php diff --git a/Controller/MediaController.php b/Controller/MediaController.php index 53745a8..4c40f08 100644 --- a/Controller/MediaController.php +++ b/Controller/MediaController.php @@ -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") @@ -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"}) */ @@ -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); } /** diff --git a/Controller/MediacenterController.php b/Controller/MediacenterController.php index 33b81be..59dbb68 100644 --- a/Controller/MediacenterController.php +++ b/Controller/MediacenterController.php @@ -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(); @@ -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() * diff --git a/Listener/AdministrationToolListener.php b/Listener/AdministrationToolListener.php new file mode 100644 index 0000000..27b9166 --- /dev/null +++ b/Listener/AdministrationToolListener.php @@ -0,0 +1,35 @@ + + * + * 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); + } +} \ No newline at end of file diff --git a/Listener/ClarolinePluginListener.php b/Listener/ClarolinePluginListener.php index cab5e90..12bbb12 100644 --- a/Listener/ClarolinePluginListener.php +++ b/Listener/ClarolinePluginListener.php @@ -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 //------------------------------- diff --git a/Resources/config/config.yml b/Resources/config/config.yml index 8c830a0..4061e8e 100644 --- a/Resources/config/config.yml +++ b/Resources/config/config.yml @@ -1,5 +1,5 @@ plugin: - has_options: true + has_options: false icon: res_inwicast.png # Widgets declared by your plugin. @@ -14,4 +14,7 @@ plugin: - name: inwicast_portal class: play-circle is_displayable_in_workspace: false - is_displayable_in_desktop: true \ No newline at end of file + is_displayable_in_desktop: true + admin_tools: + - name: inwicast_configuration + class: play-circle \ No newline at end of file diff --git a/Resources/translations/tools.en.yml b/Resources/translations/tools.en.yml index 4d4b10e..5ca1159 100644 --- a/Resources/translations/tools.en.yml +++ b/Resources/translations/tools.en.yml @@ -1 +1,2 @@ -inwicast_portal: 'Mediacenter' \ No newline at end of file +inwicast_portal: 'Mediacenter' +inwicast_configuration: 'Inwicast configuration' \ No newline at end of file diff --git a/Resources/translations/tools.es.yml b/Resources/translations/tools.es.yml index 4d4b10e..3f41006 100644 --- a/Resources/translations/tools.es.yml +++ b/Resources/translations/tools.es.yml @@ -1 +1,2 @@ -inwicast_portal: 'Mediacenter' \ No newline at end of file +inwicast_portal: 'Mediacenter' +inwicast_configuration: 'Configuración Inwicast' \ No newline at end of file diff --git a/Resources/translations/tools.fr.yml b/Resources/translations/tools.fr.yml index c2f7df9..b439f13 100644 --- a/Resources/translations/tools.fr.yml +++ b/Resources/translations/tools.fr.yml @@ -1 +1,2 @@ -inwicast_portal: 'Accès Mediacenter' \ No newline at end of file +inwicast_portal: 'Accès Mediacenter' +inwicast_configuration: 'Configuration inwicast' \ No newline at end of file diff --git a/Resources/translations/widget.en.yml b/Resources/translations/widget.en.yml index efcc37f..cd1964c 100644 --- a/Resources/translations/widget.en.yml +++ b/Resources/translations/widget.en.yml @@ -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' diff --git a/Resources/translations/widget.es.yml b/Resources/translations/widget.es.yml index ffa40fb..52a79c7 100644 --- a/Resources/translations/widget.es.yml +++ b/Resources/translations/widget.es.yml @@ -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' diff --git a/Resources/translations/widget.fr.yml b/Resources/translations/widget.fr.yml index 10f6878..0d3dd04 100644 --- a/Resources/translations/widget.fr.yml +++ b/Resources/translations/widget.fr.yml @@ -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' diff --git a/Resources/views/Media/videosList.html.twig b/Resources/views/Media/videosList.html.twig index 23c21c0..31e8309 100644 --- a/Resources/views/Media/videosList.html.twig +++ b/Resources/views/Media/videosList.html.twig @@ -11,25 +11,16 @@ {{ "warning"|trans({}, 'widget') }} {{ "error_empty_mediacenter"|trans({}, 'widget') }} {% else %} -
+ id="inwicast_claroline_plugin_diplay" class="widget-content-config-form"> {% include 'InwicastClarolinePluginBundle:Media:videosListTpl.html.twig' with {'medialist' : medialist} %}
-
+
-
- -
-
- -
{% endif %} diff --git a/Resources/views/Media/videosListTinymce.html.twig b/Resources/views/Media/videosListTinymce.html.twig index 72afa6b..2a6d15f 100644 --- a/Resources/views/Media/videosListTinymce.html.twig +++ b/Resources/views/Media/videosListTinymce.html.twig @@ -7,7 +7,7 @@ {% block javascripts_header %} {{ parent() }} - {% include 'ClarolineCoreBundle:Layout:javascripts.html.twig' %} + {% endblock %} {% block layout %} @@ -24,5 +24,6 @@ {% endblock %} {% block javascripts %} + {{ parent() }} {% endblock %} \ No newline at end of file diff --git a/Resources/views/Media/videosListTpl.html.twig b/Resources/views/Media/videosListTpl.html.twig index daf5b40..a2320c3 100644 --- a/Resources/views/Media/videosListTpl.html.twig +++ b/Resources/views/Media/videosListTpl.html.twig @@ -1,4 +1,4 @@ -
+
{# Search bar #}
@@ -23,7 +23,7 @@

-
+
{% for media in medialist %} {% if loop.index0 != 0 and loop.index0 % 4 == 0 %} diff --git a/Resources/views/Mediacenter/form.html.twig b/Resources/views/Mediacenter/form.html.twig index 8a83c78..96bb031 100644 --- a/Resources/views/Mediacenter/form.html.twig +++ b/Resources/views/Mediacenter/form.html.twig @@ -34,7 +34,7 @@

{{ 'inwicastclarolineplugin' | trans({}, 'plugin_description') }}

-
+
{{ form_errors(form) }}
diff --git a/Resources/views/Mediacenter/success.html.twig b/Resources/views/Mediacenter/success.html.twig index 5c09086..ec9a129 100644 --- a/Resources/views/Mediacenter/success.html.twig +++ b/Resources/views/Mediacenter/success.html.twig @@ -40,7 +40,9 @@
{% endblock %} \ No newline at end of file diff --git a/composer.json b/composer.json index 0ea769e..c13d55f 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,6 @@ "target-dir": "Inwicast/ClarolinePluginBundle", "require": { "php": ">=5.4.1", - "claroline/distribution": "~7.0" + "claroline/distribution": ">=8.0.*" } } From a917daa9f0bad0c7a1ecc5bb71584f64b7070b52 Mon Sep 17 00:00:00 2001 From: ptsavdar Date: Tue, 25 Oct 2016 16:15:03 +0200 Subject: [PATCH 2/2] Loaded js with webpack --- Resources/modules/list/app.js | 78 +++++++++++++++++++ .../views/Media/videosListTinymce.html.twig | 3 + Resources/views/Media/videosListTpl.html.twig | 76 +----------------- assets.json | 7 ++ 4 files changed, 91 insertions(+), 73 deletions(-) create mode 100644 Resources/modules/list/app.js create mode 100644 assets.json diff --git a/Resources/modules/list/app.js b/Resources/modules/list/app.js new file mode 100644 index 0000000..306894b --- /dev/null +++ b/Resources/modules/list/app.js @@ -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 "" + } + + 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() + } + }) + +})($) \ No newline at end of file diff --git a/Resources/views/Media/videosListTinymce.html.twig b/Resources/views/Media/videosListTinymce.html.twig index 2a6d15f..2e78183 100644 --- a/Resources/views/Media/videosListTinymce.html.twig +++ b/Resources/views/Media/videosListTinymce.html.twig @@ -8,6 +8,9 @@ {% block javascripts_header %} {{ parent() }} + {% if app.environment == 'prod' %} + + {% endif %} {% endblock %} {% block layout %} diff --git a/Resources/views/Media/videosListTpl.html.twig b/Resources/views/Media/videosListTpl.html.twig index a2320c3..9b6f881 100644 --- a/Resources/views/Media/videosListTpl.html.twig +++ b/Resources/views/Media/videosListTpl.html.twig @@ -67,76 +67,6 @@
\ No newline at end of file + window.inwicastMediaViewPath = '{{ path('inwicast_mediacenter_media_view',{"mediaRef":"_mediaRef_"}) }}'; + + \ No newline at end of file diff --git a/assets.json b/assets.json new file mode 100644 index 0000000..bfb7115 --- /dev/null +++ b/assets.json @@ -0,0 +1,7 @@ +{ + "webpack": { + "entry": { + "list": "list/app" + } + } +} \ No newline at end of file