1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8function wikiplugin_h5p_info() 9{ 10 return [ 11 'name' => tra('H5P'), 12 'documentation' => 'PluginH5P', 13 'description' => tra('Enable the creation, sharing and reuse of interactive HTML5 content.'), 14 'prefs' => ['wikiplugin_h5p', 'h5p_enabled'], 15 'iconname' => 'html', 16 'format' => 'html', 17 'introduced' => 17, 18 'params' => [ 19 'fileId' => [ 20 'required' => false, 21 'name' => tra('File ID'), 22 'description' => tr('The H5P file in a file gallery'), 23 'since' => '17.0', 24 'filter' => 'digits', 25 'default' => '', 26 'profile_reference' => 'file', 27 'area' => 'fgal_picker_id', 28 'type' => 'fileId', 29 ], 30 ], 31 ]; 32} 33 34function wikiplugin_h5p($data, $params) 35{ 36 global $page, $prefs; 37 static $instance = 0; 38 $instance++; 39 40 // temporary issue in 17.x with annotatorjs 1.2 (we hope) 41 if ($prefs['comments_inline_annotator'] === 'y') { 42 if ($instance === 1) { 43 Feedback::warning(tr('H5P is not compatible with the Inline comments (annotations) feature')); 44 } 45 return ''; 46 } 47 48 $smarty = TikiLib::lib('smarty'); 49 50 $smarty->loadPlugin('smarty_function_service_inline'); 51 52 $params['controller'] = 'h5p'; 53 $params['action'] = 'embed'; 54 55 if (! empty($page)) { // only wiki pages for now 56 $params['page'] = $page; 57 $params['index'] = $instance; 58 } 59 60 return smarty_function_service_inline($params, $smarty->getEmptyInternalTemplate()); 61} 62 63function wikiplugin_h5p_rewrite($data, $params, $context) 64{ 65 if (! empty($params['fileId'])) { 66 return "{h5p fileId=\"{$params['fileId']}\"}"; 67 } else { 68 return "{h5p}"; 69 } 70} 71