[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [BP][REF] Plugin Mediaplayer: Refactor Template rendering, dimensions...
"Bruno Kambere \(@kambereBr\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68c6d01ed1793_2cde74c96393@gitlab-sidekiq-low-urgency-cpu-bound-v2-669574cd86-8vzmq.mail> |
Bruno Kambere pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki
Commits:
7258bb44 by Bruno Kambere at 2025-09-14T17:17:53+03:00
[BP][REF] Plugin Mediaplayer: Refactor Template rendering, dimensions handling, and file content retrieval
---
* [REF] Plugin Mediaplayer: Refactor Template rendering, dimensions handling, and file content retrieval
---
* [FIX] Enhance wikiplugin_mediaplayer_text.tpl to enforce minimum dimensions for content display
* [FIX] Refactor wikiplugin_mediaplayer to template rendering
* [ENH] Update wikiplugin_mediaplayer to use Tiki file handling for content retrieval
See merge request tikiwiki/tiki!8576
See merge request tikiwiki/tiki!8577
- - - - -
2 changed files:
- lib/wiki-plugins/wikiplugin_mediaplayer.php
- templates/wiki-plugins/wikiplugin_mediaplayer_text.tpl
Changes:
=====================================
lib/wiki-plugins/wikiplugin_mediaplayer.php
=====================================
@@ -315,76 +315,19 @@ function wikiplugin_mediaplayer($data, $params)
$fileUrl = $access->absoluteUrl($params['src']);
}
- if (! file_get_contents($fileUrl)) {
+ $file = Tiki\FileGallery\File::id($fileId);
+ $filecontent = $file->getContents() ?? '';
+
+ if (! $filecontent) {
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('width', $params['width'] ?? '');
+ $smarty->assign('height', $params['height'] ?? '');
+ $smarty->assign('content', $filecontent);
+
+ return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_mediaplayer_text.tpl') . '~/np~';
}
$smarty->assign('source_link', $sourceLink);
=====================================
templates/wiki-plugins/wikiplugin_mediaplayer_text.tpl
=====================================
@@ -4,9 +4,9 @@
{tr}Please check whether the file you are trying to display exists{/tr}
{/remarksbox}
{else}
- <div class="iframe-media-wrapper">
- <div class="iframe-text-container">
- <iframe srcdoc="{$content|escape:'html'}" class="word-page"></iframe>
+ <div class="viewtextfile-content-wrapper" style="width: {$width}; height: {$height}; min-width: 480px; min-height: 420px;">
+ <div class="viewtextfile-content">
+ <pre>{$content|escape:'html'}</pre>
</div>
</div>
{/if}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7258bb44336b4ae84c5a2ddf34559ceb9f469aa6
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7258bb44336b4ae84c5a2ddf34559ceb9f469aa6
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