From e6fbc1787932f779d981b14e205dafc1f6081c99 Mon Sep 17 00:00:00 2001 From: fluxms Date: Fri, 1 Apr 2022 21:35:05 +0200 Subject: [PATCH 1/3] Update class.xvmpGUI.php https://git.fluxlabs.ch/fluxlabs/ilias/plugins/RepositoryObjects/ViMP/-/issues/2#note_15178 --- classes/GUI/Abstract/class.xvmpGUI.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/classes/GUI/Abstract/class.xvmpGUI.php b/classes/GUI/Abstract/class.xvmpGUI.php index da48ea0..89db1ba 100644 --- a/classes/GUI/Abstract/class.xvmpGUI.php +++ b/classes/GUI/Abstract/class.xvmpGUI.php @@ -72,12 +72,7 @@ protected function getAccessDeniedModal() : ilModalGUI $modal = ilModalGUI::getInstance(); $modal->setId('xvmp_modal_player'); $modal->setType(ilModalGUI::TYPE_LARGE); - if (xvmp::is54()) { - $modal->setBody($this->dic->ui()->renderer()->render($this->dic->ui()->factory()->messageBox()->failure($this->pl->txt('access_denied')))); - } else { - $modal->setBody($this->dic->ui()->mainTemplate()->getMessageHTML($this->pl->txt('access_denied'), - "failure")); - } + $modal->setBody($this->dic->ui()->renderer()->render($this->dic->ui()->factory()->messageBox()->failure($this->pl->txt('access_denied')))); return $modal; } From dd432ca603f0294ee36c2954d4a594aaa3386cbc Mon Sep 17 00:00:00 2001 From: "Martin Studer, fluxlabs ag" Date: Fri, 1 Apr 2022 16:07:37 -0400 Subject: [PATCH 2/3] fixes for issue #1 AND #2 --- classes/GUI/Abstract/class.xvmpGUI.php | 8 ++++++-- templates/js/xvmp_content.js | 4 +++- templates/js/xvmp_content.min.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/classes/GUI/Abstract/class.xvmpGUI.php b/classes/GUI/Abstract/class.xvmpGUI.php index 89db1ba..8315730 100644 --- a/classes/GUI/Abstract/class.xvmpGUI.php +++ b/classes/GUI/Abstract/class.xvmpGUI.php @@ -306,8 +306,12 @@ public function fillModalPlayer($play_video_id = null, bool $async = true) { $playModalDto = $this->buildPlayerContainerDTO($video); $response = new stdClass(); - $response->html = $this->renderer_factory->playerModal()->render($playModalDto, $async, ($this instanceof xvmpVideosGUI)); // TODO: change! - $response->video_title = $video->getTitle(); + // TODO: Abstract classes MUST NOT know their children. this is a cognitive overload + // Refactoring Issue: https://git.fluxlabs.ch/fluxlabs/ilias/plugins/RepositoryObjects/ViMP/-/issues/3 + $show_unavailable = ($this instanceof xvmpVideosGUI) || ($this instanceof xvmpContentGUI); + $response->html = $this->renderer_factory->playerModal()->render($playModalDto, $async, $show_unavailable); + + $response->video_title = $video->getTitle(); /** @var xvmpUserProgress $progress */ $progress = xvmpUserProgress::where(array(xvmpUserProgress::F_USR_ID => $this->dic->user()->getId(), xvmpMedium::F_MID => $mid))->first(); if ($progress) { diff --git a/templates/js/xvmp_content.js b/templates/js/xvmp_content.js index cef8dc4..64aab42 100644 --- a/templates/js/xvmp_content.js +++ b/templates/js/xvmp_content.js @@ -106,7 +106,9 @@ var VimpContent = { }, copyDirectLinkWithTime: function (link_tpl) { - this.copyToClipboard(link_tpl.replace('_0.', '_' + Math.floor(player.currentTime()) + '.')); + let currentTime = '_' + Math.floor(player.currentTime()); + let link = link_tpl.replace('_0.', currentTime + '.').replace('_0&', currentTime + '&'); + this.copyToClipboard(link); }, copyToClipboard: function (textToCopy) { diff --git a/templates/js/xvmp_content.min.js b/templates/js/xvmp_content.min.js index 135fc5f..651e83c 100644 --- a/templates/js/xvmp_content.min.js +++ b/templates/js/xvmp_content.min.js @@ -1 +1 @@ -var VimpContent={selected_media:[],ajax_base_url:"",template:"",copy_link_template:"",init:function(){addEventListener("xvmp_copy_direct_link",function(){this.copyDirectLink()}),addEventListener("xvmp_copy_direct_link_with_time",function(){this.copyDirectLinkWithTime()})},loadTiles:function(){$(VimpContent.selected_media).each(function(a,b){$.get({url:VimpContent.ajax_base_url,data:{cmd:"renderItem"+VimpContent.template,mid:b}}).always(function(a){"deleted"===a?$("div#box_"+b).hide():($("div#xvmp_tile_"+b).html(a),$("div#xvmp_tile_"+b).removeClass("waiting"))})})},loadTilesInOrder:function(a){var b=VimpContent.selected_media[a];$.get({url:VimpContent.ajax_base_url,data:{cmd:"render"+VimpContent.template,mid:b}}).always(function(c){"deleted"===c?$("div#box_"+b).hide():($("div#xvmp_tile_"+b).html(c),$("div#xvmp_tile_"+b).removeClass("waiting")),"undefined"!=typeof VimpContent.selected_media[a+1]&&VimpContent.loadTilesInOrder(a+1)})},playVideo:function(a){console.log("playVideo "+a);var b=$("#xvmp_modal_player");b.find("h4.modal-title").html(""),b.find("div#xvmp_video_container").html(""),b.modal("show"),$.get({url:this.ajax_base_url,data:{cmd:"fillModalPlayer",mid:a}}).always(function(c){response_object=JSON.parse(c),b.find("div#xvmp_video_container").html(response_object.html),b.find("h4.modal-title").html(response_object.video_title),"undefined"!=typeof VimpObserver&&VimpObserver.init(a,response_object.time_ranges),b.on("hidden",function(){$video=$("video")[0],"undefined"!=typeof $video&&$video.pause(),$iframe=$("iframe"),"undefined"!=typeof $iframe&&$iframe.attr("src","")}),b.on("hidden.bs.modal",function(){$video=$("video")[0],"undefined"!=typeof $video&&$video.pause(),$iframe=$("iframe"),"undefined"!=typeof $iframe&&$iframe.attr("src","")})})},copyDirectLink:function(a){this.copyToClipboard(a)},copyDirectLinkWithTime:function(a){this.copyToClipboard(a.replace("_0.","_"+Math.floor(player.currentTime())+"."))},copyToClipboard:function(a){if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(a);else{let b=document.createElement("textarea");return b.value=a,b.style.position="fixed",b.style.left="-999999px",b.style.top="-999999px",document.body.appendChild(b),b.focus(),b.select(),new Promise((a,c)=>{document.execCommand("copy")?a():c(),b.remove()})}}}; \ No newline at end of file +var VimpContent={selected_media:[],ajax_base_url:"",template:"",copy_link_template:"",init:function(){addEventListener("xvmp_copy_direct_link",function(event){this.copyDirectLink()});addEventListener("xvmp_copy_direct_link_with_time",function(event){this.copyDirectLinkWithTime()})},loadTiles:function(){$(VimpContent.selected_media).each(function(key,mid){$.get({url:VimpContent.ajax_base_url,data:{cmd:"renderItem"+VimpContent.template,mid:mid}}).always(function(response){if(response==="deleted"){$("div#box_"+mid).hide()}else{$("div#xvmp_tile_"+mid).html(response);$("div#xvmp_tile_"+mid).removeClass("waiting")}})})},loadTilesInOrder:function(key){var mid=VimpContent.selected_media[key];$.get({url:VimpContent.ajax_base_url,data:{cmd:"render"+VimpContent.template,mid:mid}}).always(function(response){if(response==="deleted"){$("div#box_"+mid).hide()}else{$("div#xvmp_tile_"+mid).html(response);$("div#xvmp_tile_"+mid).removeClass("waiting")}if(typeof VimpContent.selected_media[key+1]!=="undefined"){VimpContent.loadTilesInOrder(key+1)}})},playVideo:function(mid){console.log("playVideo "+mid);var $modal=$("#xvmp_modal_player");$modal.find("h4.modal-title").html("");$modal.find("div#xvmp_video_container").html("");$modal.modal("show");$.get({url:this.ajax_base_url,data:{cmd:"fillModalPlayer",mid:mid}}).always(function(response){response_object=JSON.parse(response);$modal.find("div#xvmp_video_container").html(response_object.html);$modal.find("h4.modal-title").html(response_object.video_title);if(typeof VimpObserver!="undefined"){VimpObserver.init(mid,response_object.time_ranges)}$modal.on("hidden",function(){$video=$("video")[0];if(typeof $video!="undefined"){$video.pause()}$iframe=$("iframe");if(typeof $iframe!="undefined"){$iframe.attr("src","")}});$modal.on("hidden.bs.modal",function(){$video=$("video")[0];if(typeof $video!="undefined"){$video.pause()}$iframe=$("iframe");if(typeof $iframe!="undefined"){$iframe.attr("src","")}})})},copyDirectLink:function(link_tpl){this.copyToClipboard(link_tpl)},copyDirectLinkWithTime:function(link_tpl){let currentTime="_"+Math.floor(player.currentTime());let link=link_tpl.replace("_0.",currentTime+".").replace("_0&",currentTime+"&");this.copyToClipboard(link)},copyToClipboard:function(textToCopy){if(navigator.clipboard&&window.isSecureContext){return navigator.clipboard.writeText(textToCopy)}else{let textArea=document.createElement("textarea");textArea.value=textToCopy;textArea.style.position="fixed";textArea.style.left="-999999px";textArea.style.top="-999999px";document.body.appendChild(textArea);textArea.focus();textArea.select();return new Promise((res,rej)=>{document.execCommand("copy")?res():rej();textArea.remove()})}}}; \ No newline at end of file From 29141ecf9b73bd2225298c66fde2df9848b43de1 Mon Sep 17 00:00:00 2001 From: "Martin Studer, fluxlabs ag" Date: Fri, 1 Apr 2022 16:11:19 -0400 Subject: [PATCH 3/3] changed version and changelog --- CHANGELOG.md | 4 ++++ classes/GUI/Abstract/class.xvmpGUI.php | 2 +- plugin.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8265c1..0bb177b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [1.8.2] +- fix: time link in modal - additional fix: https://git.fluxlabs.ch/fluxlabs/ilias/plugins/RepositoryObjects/ViMP/-/issues/2 +- fix: wrong not available hint - additional fix: https://git.fluxlabs.ch/fluxlabs/ilias/plugins/RepositoryObjects/ViMP/-/issues/1 + ## [1.8.1] - fix: time link in modal: https://git.fluxlabs.ch/fluxlabs/ilias/plugins/RepositoryObjects/ViMP/-/issues/2 - fix: wrong not available hint: https://git.fluxlabs.ch/fluxlabs/ilias/plugins/RepositoryObjects/ViMP/-/issues/1 diff --git a/classes/GUI/Abstract/class.xvmpGUI.php b/classes/GUI/Abstract/class.xvmpGUI.php index 8315730..07b8b7f 100644 --- a/classes/GUI/Abstract/class.xvmpGUI.php +++ b/classes/GUI/Abstract/class.xvmpGUI.php @@ -310,7 +310,7 @@ public function fillModalPlayer($play_video_id = null, bool $async = true) { // Refactoring Issue: https://git.fluxlabs.ch/fluxlabs/ilias/plugins/RepositoryObjects/ViMP/-/issues/3 $show_unavailable = ($this instanceof xvmpVideosGUI) || ($this instanceof xvmpContentGUI); $response->html = $this->renderer_factory->playerModal()->render($playModalDto, $async, $show_unavailable); - + $response->video_title = $video->getTitle(); /** @var xvmpUserProgress $progress */ $progress = xvmpUserProgress::where(array(xvmpUserProgress::F_USR_ID => $this->dic->user()->getId(), xvmpMedium::F_MID => $mid))->first(); diff --git a/plugin.php b/plugin.php index d0d05cf..bbff944 100644 --- a/plugin.php +++ b/plugin.php @@ -1,6 +1,6 @@