Skip to content

Commit

Permalink
Bugfix 27389 show images and docs (#62)
Browse files Browse the repository at this point in the history
* TTK-27389: Show images and docs

* TTK-27389: Remove app_dev clean

* TTK-27389: Show images, docs and external videos from the search tab
  • Loading branch information
albacodina authored Dec 16, 2024
1 parent fbb184d commit 1a578c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Controller/LmsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;

/**
* @Route("/openedx/openedx")
Expand All @@ -37,20 +38,23 @@ class LmsController extends AbstractController
private $configurationService;
private $playerService;
private $pumukitInfo;
private $router;

public function __construct(
DocumentManager $documentManager,
MultimediaObjectService $multimediaObjectService,
ProfileService $profileService,
ConfigurationService $configurationService,
PlayerService $playerService,
RouterInterface $router,
array $pumukitInfo
) {
$this->documentManager = $documentManager;
$this->multimediaObjectService = $multimediaObjectService;
$this->profileService = $profileService;
$this->configurationService = $configurationService;
$this->playerService = $playerService;
$this->router = $router;
$this->pumukitInfo = $pumukitInfo;
}

Expand Down Expand Up @@ -133,6 +137,10 @@ protected function renderIframe(Request $request, MultimediaObject $multimediaOb
{
$playerController = $this->playerService->getPublicControllerPlayer($multimediaObject);

if ($multimediaObject->isImageType() || $multimediaObject->isDocumentType() || $multimediaObject->isExternalType()) {
$playerController = $this->getPublicImageDocControllerPlayer($multimediaObject);
}

return $this->forward($playerController, ['request' => $request, 'multimediaObject' => $multimediaObject]);
}

Expand All @@ -147,6 +155,14 @@ protected function renderPlaylistIframe(Request $request, Series $series)
);
}

private function getPublicImageDocControllerPlayer(MultimediaObject $multimediaObject)
{
$url = $this->router->generate('pumukit_player_index', ['id' => $multimediaObject->getId()]);
$endpoint = $this->router->match($url);

return $endpoint['_controller'];
}

private function getOptionsParameters(Request $request): array
{
return [
Expand Down
6 changes: 6 additions & 0 deletions Resources/views/Search/template.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
e.preventDefault();
if (window.parent && e.currentTarget.href) {
var url = e.currentTarget.href.replace('/video/', '/iframe/');
const checkClasses = ['image', 'document', 'external'];
if (checkClasses.some(classes => e.currentTarget.classList.contains(classes))) {
url = e.currentTarget.href.replace('/video/', '/iframe/player/');
}
$('.modal-body-shared-videos').html(
'<div class="embed-responsive embed-responsive-16by9">' +
'<iframe id="pmk-iframe" src="' + url + '" frameborder="0" width="100%" class="embed-responsive-item" scrolling="no" allowfullscreen=""/></iframe>' +
Expand Down

0 comments on commit 1a578c6

Please sign in to comment.