[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][FIX] Plugin MediaPlayer: Resolve multiple issues leading to false...
"luci \(@luciash\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <69839230af06f_3b1843185659@gitlab-sidekiq-low-urgency-cpu-bound-v2-7d899c995b-qfsfk.mail> |
luci pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki
Commits:
2c9fa595 by Alfred Syatsukwa at 2026-02-04T18:32:08+00:00
[BP][FIX] Plugin MediaPlayer: Resolve multiple issues leading to false positive errors for unsupported media formats
---
* [FIX] Plugin MediaPlayer: Resolve multiple issues leading to false positive...
---
* [FIX] Plugin MediaPlayer: Resolve multiple issues leading to false positive errors for unsupported media formats
---
* [FIX] Plugin MediaPlayer: Resolve multiple issues leading to false positive errors for unsupported media formats
See merge request tikiwiki/tiki!7122
(cherry picked from commit 649b84ae992c32fcf53f316086f794f20895a7c1)
See merge request tikiwiki/tiki!7158
(cherry picked from commit 7deba14a4ca6a69af3e0d9cc152bb3177cf6e5ab)
See merge request tikiwiki/tiki!9483
- - - - -
2 changed files:
- lang/fr/language.php
- lib/wiki-plugins/wikiplugin_mediaplayer.php
Changes:
=====================================
lang/fr/language.php
=====================================
@@ -4973,6 +4973,16 @@ $lang_current = array(
// "Create a slideshow (like an image carousel) for file galleries. Used in Plugin Carousel" => "Create a slideshow (like an image carousel) for file galleries. Used in Plugin Carousel",
// "jQuery sortable tables" => "jQuery sortable tables",
// "Provides an interactive way to sort and filter data in tables produced with Plugin FancyTable and Plugin TrackerList, as well as administrative tables" => "Provides an interactive way to sort and filter data in tables produced with Plugin FancyTable and Plugin TrackerList, as well as administrative tables",
+// "jQuery media" => "jQuery media",
+// "Provides a media player via Plugin MediaPlayer that can be used in wiki pages or other wiki text area to play media files including .flv, .mp3, .mp4, .swf, .avi, .wmv, .ram, .mov, .mpeg, and .pdf. A Flash-based open source media player is used" => "Provides a media player via Plugin MediaPlayer that can be used in wiki pages or other wiki text area to play media files including .flv, .mp3, .mp4, .swf, .avi, .wmv, .ram, .mov, .mpeg, and .pdf. A Flash-based open source media player is used",
+"PluginMediaPlayer: src and mp3 cannot both be empty" => "PluginMediaPlayer: src et mp3 ne peuvent pas être vides tous les deux",
+"PluginMediaPlayer: Media format not supported. Here are the supported formats: " => "PluginMediaPlayer: Format multimédia non pris en charge. Voici les formats supportés: ",
+"PluginMediaPlayer: Media format not supported. Here are the audio supported formats: " => "PluginMediaPlayer: Format multimédia non pris en charge. Voici les formats audio pris en charge: ",
+"File type for source URL, e.g. %0mp4%1, %0pdf%1 or %0odp%1 . Specify one of the supported file types when\nthe URL of the file is missing the file extension. This is the case for File Gallery files which\nhave a URL such as %0tiki-download_file.php?fileId=4&display%1 or %0display4%1 if you have Clean URLs\nenabled." => "Type de fichier pour l'URL source, par ex. %0mp4%1, %0pdf%1 ou %0odp%1 . Spécifiez l'un des types de fichiers pris en charge lorsque\nl'URL du fichier ne contient pas l'extension de fichier. C'est le cas des fichiers de la galerie de fichiers qui\nont une URL telle que %0tiki-download_file.php?fileId=4&display%1 ou %0display4%1 si les URL propres sont activées.",
+"PluginMediaPlayer: File %0 not found." => "PluginMediaPlayer: Fichier %0 introuvable.",
+"PluginMediaPlayer: File %0 not found on the remote server." => "PluginMediaPlayer: Fichier %0 introuvable sur le serveur distant.",
+"PluginMediaPlayer: Unable to open the file %0. It may not exist or is inaccessible." => "PluginMediaPlayer: Impossible d'ouvrir le fichier %0. Il peut ne pas exister ou il est inaccessible.",
+"PluginMediaPlayer: The file is not a text file." => "PluginMediaPlayer: Le fichier n'est pas un fichier texte.",
// "TagCanvas" => "TagCanvas",
// "TagCanvas is a Javascript class which will draw and animate an HTML5 canvas-based tag cloud" => "TagCanvas is a Javascript class which will draw and animate an HTML5 canvas-based tag cloud",
// "jQuery zoom" => "jQuery zoom",
=====================================
lib/wiki-plugins/wikiplugin_mediaplayer.php
=====================================
@@ -7,8 +7,8 @@
use Tiki\Package\VendorHelper;
const AUDIO_ACCEPTED_FORMATS = ['mp3', 'ogg', 'wav', 'aac', 'flac', 'opus'];
-const VIDEO_ACCEPTED_FORMATS = ['mp4', 'ogv', 'webm', '3gp', '3g2', 'mov', 'avi', 'mpg', 'mpeg', 'wmv', 'flv'];
-const DOCUMENT_ACCEPTED_FORMATS = ['pdf', 'odt', 'ods', 'odp'];
+const VIDEO_ACCEPTED_FORMATS = ['mp4', 'ogv', 'webm', '3gp', '3g2', 'mov', 'avi', 'mpg', 'mpeg', 'wmv'];
+const DOCUMENT_ACCEPTED_FORMATS = ['pdf', 'txt'];
$ALL_ACCEPTED_FORMATS = array_merge(AUDIO_ACCEPTED_FORMATS, VIDEO_ACCEPTED_FORMATS, DOCUMENT_ACCEPTED_FORMATS);
define('ALL_ACCEPTED_FORMATS', $ALL_ACCEPTED_FORMATS);
@@ -117,13 +117,13 @@ function wikiplugin_mediaplayer($data, $params)
// Ideally, URL parsing should be handled by the routing system (route.php) instead of using a regex in a plugin.
// However, since the necessary abstractions are not currently available, this regex is applied here as a temporary solution.
- preg_match('/(?:dl|display|attId=|fileId=)(\d+)(?:$|&|\?)/', $params['src'], $matches);
-
+ preg_match('/(?:dl|display|attId=|fileId=)(\d+)(?:$|&|\?|#)/', $params['src'], $matches);
+ $file = '';
if (! empty($matches[1])) { // fileId 0 is also invalid
$fileId = $matches[1];
$filegallib = TikiLib::lib('filegal');
global $base_url;
- $sourceLink = TikiLib::lib('access')->absoluteUrl($params['src']);
+ $sourceLink = $access->absoluteUrl($params['src']);
// Internal link.
if (strrpos($sourceLink, $base_url) !== false) {
@@ -131,10 +131,22 @@ function wikiplugin_mediaplayer($data, $params)
if (! empty($file['filetype']) && $file['fileId'] == $fileId) {
$extension = pathinfo($file['filename'], PATHINFO_EXTENSION);
$params['type'] = $file['filetype'];
+ $sourceLink = smarty_modifier_sefurl($fileId, 'display');
+ $fileUrl = $access->absoluteUrl($sourceLink);
+ $params['src'] = $fileUrl;
+ } else {
+ Feedback::error(tr("PluginMediaPlayer: File %0 not found.", $params['src']));
+ return '';
}
} else {
// External link.
$headers = get_headers($sourceLink, 1);
+
+ // Check if the file exists on the remote server.
+ if ($headers === false || ! isset($headers['Content-Disposition'])) {
+ Feedback::error(tr("PluginMediaPlayer: File %0 not found on the remote server.", $params['src']));
+ return '';
+ }
if (isset($headers['Content-Disposition'])) {
$disposition = $headers['Content-Disposition'];
if (preg_match('/filename="(.+)"/', $disposition, $matches)) {
@@ -180,7 +192,7 @@ function wikiplugin_mediaplayer($data, $params)
//checking if pdf generation request
if (in_array($params['type'], ['pdf']) && isset($_GET['display']) && strstr($_GET['display'], 'pdf') != '') {
- return "<pdfpage>.<pdfinclude src='" . TikiLib::lib('access')->absoluteUrl($params['src']) . "' /></pdfpage>";
+ return "<pdfpage>.<pdfinclude src='" . $access->absoluteUrl($params['src']) . "' /></pdfpage>";
}
$defaults_html5 = [
'width' => '',
@@ -199,7 +211,7 @@ function wikiplugin_mediaplayer($data, $params)
if ($prefs['fgal_pdfjs_feature'] === 'y') {
$smarty = TikiLib::lib('smarty');
- $url = TikiLib::lib('access')->absoluteUrl($params['src']);
+ $url = $access->absoluteUrl($params['src']);
$smarty->assign('url', $url);
$smarty->assign('mediaplayerId', $iMEDIAPLAYER);
$oldPdfJsFile = VendorHelper::getAvailableVendorPath('pdfjs', 'npm-asset/pdfjs-dist/build/pdf.js');
@@ -267,7 +279,7 @@ function wikiplugin_mediaplayer($data, $params)
$sourceLink = smarty_modifier_sefurl($fileId, 'display');
} else {
global $base_url;
- $sourceLink = TikiLib::lib('access')->absoluteUrl($params['src']);
+ $sourceLink = $access->absoluteUrl($params['src']);
// Not an internal link, lets set a security token.
if (strrpos($sourceLink, $base_url) === false) {
@@ -279,8 +291,100 @@ function wikiplugin_mediaplayer($data, $params)
}
if (! empty($sourceLink)) {
- $htmlViewFile = VendorHelper::getAvailableVendorPath('pdfjsviewer', 'npm-asset/pdfjs-dist-viewer-min/build/minified/web/viewer.html') . '?file=';
- $sourceLink = $htmlViewFile . urlencode(TikiLib::lib('access')->absoluteUrl($sourceLink));
+ $htmlViewFile = VendorHelper::getAvailableVendorPath('pdfjsviewer', '/npm-asset/pdfjs-dist-viewer-min/build/minified/web/viewer.html') . '?file=';
+ $sourceLink = $htmlViewFile . urlencode($access->absoluteUrl($sourceLink));
+ }
+
+ if (strtolower($params['type']) === 'txt') {
+ if (! empty($fileId)) {
+ $sourceLink = smarty_modifier_sefurl($fileId, 'display');
+
+ $filegallib = TikiLib::lib('filegal');
+ $file = $filegallib->get_file_info($fileId);
+
+ $filename = $file['filename'];
+ $filetype = $file['filetype'];
+
+ if ($filetype != 'text/plain' || (strtolower(substr($filename, -4)) != '.txt')) {
+ Feedback::error(tr("PluginMediaPlayer: The file is not a text file."));
+ return;
+ }
+
+ $fileUrl = $access->absoluteUrl($sourceLink);
+ } else {
+ $fileUrl = $access->absoluteUrl($params['src']);
+ }
+
+ if (! file_get_contents($fileUrl)) {
+ Feedback::error(tr("PluginMediaPlayer: Unable to open the file %0. It may not exist or is inaccessible.", $fileUrl));
+ return;
+ }
+
+ $text = file_get_contents($fileUrl);
+ $text = html_entity_decode($text);
+
+ if (! empty($text)) {
+ $headerlibs = TikiLib::lib('header');
+ $widthValue = ! empty($params['width']) ? $params['width'] : '100%';
+ $heightValue = ! empty($params['height']) ? $params['height'] : '100%';
+
+ $headerlibs->add_css('
+ .iframe-media-wrapper {
+ width: ' . $widthValue . ';
+ height: ' . $heightValue . ';
+ min-width: 480px;
+ min-height: 420px;
+ display: flex;
+ flex-direction: column;
+ }
+ .iframe-media-wrapper .iframe-text-container {
+ width: 100%;
+ height: 100vh;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: #f1f1f1;
+ padding: 20px;
+ box-sizing: border-box;
+ overflow: hidden;
+ }
+
+ .iframe-media-wrapper iframe.word-page {
+ width: 90%;
+ height: 100%;
+ margin-top: auto;
+ border: 1px solid #ccc;
+ background-color: white;
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+ overflow: hidden;
+ font-family: "Calibri", sans-serif;
+ font-size: 12pt;
+ line-height: 1.5;
+ padding: 40px;
+ }
+
+ @media (max-width: 768px) {
+ .iframe-media-wrapper {
+ width: 100%;
+ height: auto;
+ min-width: unset;
+ padding: 10px;
+ }
+ .iframe-media-wrapper .iframe-text-container {
+ padding: 10px 10px;
+ }
+ .iframe-media-wrapper iframe.word-page {
+ padding: 20px;
+ }
+ }
+ ');
+
+ $smarty->assign('content', $text);
+
+ return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_mediaplayer_text.tpl') . '~/np~';
+ } else {
+ return "<p>" . tr("Error: No text found.") . "</p>";
+ }
}
$smarty->assign('source_link', $sourceLink);
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2c9fa5959bd74fa1a6013fe4e816347557ef3dc4
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2c9fa5959bd74fa1a6013fe4e816347557ef3dc4
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs