Loading h5p.routing.yml +24 −24 Original line number Diff line number Diff line Loading @@ -16,14 +16,14 @@ h5p.admin.content.h5p: requirements: _permission: 'administer site configuration' h5p.admin.content.h5p.libraries.details: path: '/admin/content/h5p/libraries/{library_id}' defaults: _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryDetails' _title: 'H5P Library Details' requirements: _permission: 'administer site configuration' id: \d+ #h5p.admin.content.h5p.libraries.details: # path: '/admin/content/h5p/libraries/{library_id}' # defaults: # _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryDetails' # _title: 'H5P Library Details' # requirements: # _permission: 'administer site configuration' # id: \d+ h5p.admin.content.h5p.libraries.upgrade: path: '/admin/content/h5p/libraries/{library_id}/upgrade' Loading @@ -43,14 +43,14 @@ h5p.admin.content.h5p.libraries.delete: _permission: 'administer site configuration' id: \d+ h5p.admin.content.h5p.libraries.restrict: path: '/admin/content/h5p/libraries/{library_id}/restrict' defaults: _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryRestrict' _title: 'Restrict H5P Library' requirements: _permission: 'administer site configuration' id: \d+ #h5p.admin.content.h5p.libraries.restrict: # path: '/admin/content/h5p/libraries/{library_id}/restrict' # defaults: # _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryRestrict' # _title: 'Restrict H5P Library' # requirements: # _permission: 'administer site configuration' # id: \d+ # TODO path requires 3 page arguments. See line 71 in D7's h5p.module h5p.admin.content.h5p.libraries.upgrade: Loading @@ -71,14 +71,14 @@ h5p.admin.content.h5p.rebuild_cache: _permission: 'administer site configuration' id: \d+ h5p.admin.content.h5p.embed: path: '/admin/content/h5p/embed' defaults: _controller: '\Drupal\h5p\Controller\H5PAdmin::embed' _title: 'H5P Embed' requirements: _permission: 'access content' id: \d+ #h5p.admin.content.h5p.embed: # path: '/admin/content/h5p/embed' # defaults: # _controller: '\Drupal\h5p\Controller\H5PAdmin::embed' # _title: 'H5P Embed' # requirements: # _permission: 'access content' # id: \d+ h5p.ajax.set_finished: path: '/h5p-ajax/set-finished.json' Loading modules/h5peditor/h5peditor.routing.yml +7 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,13 @@ h5peditor.library_install: requirements: _permission: 'h5peditor_access' h5peditor.library_upload: path: '/h5peditor/{token}/{content_id}/library-upload' defaults: _controller: 'Drupal\h5peditor\Controller\H5PEditorAJAXController::libraryUploadCallback' requirements: _permission: 'h5peditor_access' h5peditor.library: path: '/h5peditor/{token}/{content_id}/libraries/{machine_name}/{major_version}/{minor_version}' defaults: Loading modules/h5peditor/scripts/application.js +18 −11 Original line number Diff line number Diff line Loading @@ -8,16 +8,7 @@ var ns = H5PEditor; attach: function (context, settings) { ns.init = function () { var h5peditor; var $upload = $('input[name="files[h5p]"]').parents('.form-item'); var $editor = $('.h5p-editor'); var $create = $('#edit-h5p-editor').hide(); var $type = $('input[name="h5p_type"]'); // TODO: Make it possible to have multiple fields var $params = $('input[name="field_h5peditor[0][value][json_content]"]'); var $library = $('input[name="field_h5peditor[0][value][h5p_library]"]'); var library = $library.val(); // Setup ns.$ = H5P.jQuery; ns.basePath = drupalSettings.path.baseUrl + settings.h5p.drupal_h5p_editor.h5peditor.modulePath + '/h5p-editor'; ns.contentId = settings.h5p.drupal_h5p_editor.h5peditor.nodeVersionId; Loading @@ -28,6 +19,19 @@ var ns = H5PEditor; ns.contentRelUrl = settings.h5p.drupal_h5p_editor.h5peditor.contentRelUrl; ns.editorRelUrl = settings.h5p.drupal_h5p_editor.h5peditor.editorRelUrl; ns.apiVersion = settings.h5p.drupal_h5p_editor.h5peditor.apiVersion; var fieldName = settings.h5p.drupal_h5p_editor.h5peditor.fieldName; var fieldNumber = settings.h5p.drupal_h5p_editor.h5peditor.fieldNumber; // Elements var h5peditor; var $upload = $('input[name="files[h5p]"]').parents('.form-item'); var $editor = $('.h5p-editor'); var $create = $('#edit-h5p-editor').hide(); var $type = $('input[name="h5p_type"]'); var $params = $('input[name="' + fieldName + '[' + fieldNumber + '][value][json_content]"]'); var $library = $('input[name="' + fieldName + '[' + fieldNumber + '][value][h5p_library]"]'); var library = $library.val(); // Semantics describing what copyright information can be stored for media. ns.copyrightSemantics = settings.h5p.drupal_h5p_editor.h5peditor.copyrightSemantics; Loading @@ -50,7 +54,7 @@ var ns = H5PEditor; } $create.show(); } }).change(); }); // TODO: Use something more robust than mousedown. $('#edit-actions').find('input[type="submit"]').mousedown(function () { Loading @@ -71,6 +75,9 @@ var ns = H5PEditor; } } }); // Trigger editor load $type.change(); }; ns.getAjaxUrl = function (action, parameters) { Loading modules/h5peditor/src/Controller/H5PEditorAJAXController.php +13 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,19 @@ class H5PEditorAJAXController extends ControllerBase { exit(); } /** * Callback for uploading a library * * @param string $token Editor security token * @param int $content_id Id of content that is being edited */ function libraryUploadCallback($token, $content_id) { $editor = H5PEditorUtilities::getInstance(); $filePath = $_FILES['h5p']['tmp_name']; $editor->ajax->action(\H5PEditorEndpoints::LIBRARY_UPLOAD, $token, $filePath, $content_id); exit(); } /** * Callback that returns all library data * Loading modules/h5peditor/src/H5PEditor/H5PEditorDrupalStorage.php +4 −6 Original line number Diff line number Diff line Loading @@ -199,10 +199,10 @@ class H5PEditorDrupalStorage implements \H5peditorStorage { } // Set session variables necessary for finding the files $_SESSION['h5p_upload_folder'] = drupal_realpath($temporary_file_path); $_SESSION['h5p_upload'] = drupal_realpath($target); $dir = \Drupal::service('file_system')->realpath($temporary_file_path); $file_service = \Drupal::service('file_system'); $dir = $file_service->realpath($temporary_file_path); $interface->getUploadedH5pFolderPath($dir); $interface->getUploadedH5pPath("{$dir}/{$name}"); return (object) array( 'dir' => $dir, Loading Loading @@ -258,7 +258,5 @@ class H5PEditorDrupalStorage implements \H5peditorStorage { else { unlink($filePath); } // Maintain session variables unset($_SESSION['h5p_upload'], $_SESSION['h5p_upload_folder']); } } Loading
h5p.routing.yml +24 −24 Original line number Diff line number Diff line Loading @@ -16,14 +16,14 @@ h5p.admin.content.h5p: requirements: _permission: 'administer site configuration' h5p.admin.content.h5p.libraries.details: path: '/admin/content/h5p/libraries/{library_id}' defaults: _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryDetails' _title: 'H5P Library Details' requirements: _permission: 'administer site configuration' id: \d+ #h5p.admin.content.h5p.libraries.details: # path: '/admin/content/h5p/libraries/{library_id}' # defaults: # _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryDetails' # _title: 'H5P Library Details' # requirements: # _permission: 'administer site configuration' # id: \d+ h5p.admin.content.h5p.libraries.upgrade: path: '/admin/content/h5p/libraries/{library_id}/upgrade' Loading @@ -43,14 +43,14 @@ h5p.admin.content.h5p.libraries.delete: _permission: 'administer site configuration' id: \d+ h5p.admin.content.h5p.libraries.restrict: path: '/admin/content/h5p/libraries/{library_id}/restrict' defaults: _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryRestrict' _title: 'Restrict H5P Library' requirements: _permission: 'administer site configuration' id: \d+ #h5p.admin.content.h5p.libraries.restrict: # path: '/admin/content/h5p/libraries/{library_id}/restrict' # defaults: # _controller: '\Drupal\h5p\Controller\H5PAdmin::libraryRestrict' # _title: 'Restrict H5P Library' # requirements: # _permission: 'administer site configuration' # id: \d+ # TODO path requires 3 page arguments. See line 71 in D7's h5p.module h5p.admin.content.h5p.libraries.upgrade: Loading @@ -71,14 +71,14 @@ h5p.admin.content.h5p.rebuild_cache: _permission: 'administer site configuration' id: \d+ h5p.admin.content.h5p.embed: path: '/admin/content/h5p/embed' defaults: _controller: '\Drupal\h5p\Controller\H5PAdmin::embed' _title: 'H5P Embed' requirements: _permission: 'access content' id: \d+ #h5p.admin.content.h5p.embed: # path: '/admin/content/h5p/embed' # defaults: # _controller: '\Drupal\h5p\Controller\H5PAdmin::embed' # _title: 'H5P Embed' # requirements: # _permission: 'access content' # id: \d+ h5p.ajax.set_finished: path: '/h5p-ajax/set-finished.json' Loading
modules/h5peditor/h5peditor.routing.yml +7 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,13 @@ h5peditor.library_install: requirements: _permission: 'h5peditor_access' h5peditor.library_upload: path: '/h5peditor/{token}/{content_id}/library-upload' defaults: _controller: 'Drupal\h5peditor\Controller\H5PEditorAJAXController::libraryUploadCallback' requirements: _permission: 'h5peditor_access' h5peditor.library: path: '/h5peditor/{token}/{content_id}/libraries/{machine_name}/{major_version}/{minor_version}' defaults: Loading
modules/h5peditor/scripts/application.js +18 −11 Original line number Diff line number Diff line Loading @@ -8,16 +8,7 @@ var ns = H5PEditor; attach: function (context, settings) { ns.init = function () { var h5peditor; var $upload = $('input[name="files[h5p]"]').parents('.form-item'); var $editor = $('.h5p-editor'); var $create = $('#edit-h5p-editor').hide(); var $type = $('input[name="h5p_type"]'); // TODO: Make it possible to have multiple fields var $params = $('input[name="field_h5peditor[0][value][json_content]"]'); var $library = $('input[name="field_h5peditor[0][value][h5p_library]"]'); var library = $library.val(); // Setup ns.$ = H5P.jQuery; ns.basePath = drupalSettings.path.baseUrl + settings.h5p.drupal_h5p_editor.h5peditor.modulePath + '/h5p-editor'; ns.contentId = settings.h5p.drupal_h5p_editor.h5peditor.nodeVersionId; Loading @@ -28,6 +19,19 @@ var ns = H5PEditor; ns.contentRelUrl = settings.h5p.drupal_h5p_editor.h5peditor.contentRelUrl; ns.editorRelUrl = settings.h5p.drupal_h5p_editor.h5peditor.editorRelUrl; ns.apiVersion = settings.h5p.drupal_h5p_editor.h5peditor.apiVersion; var fieldName = settings.h5p.drupal_h5p_editor.h5peditor.fieldName; var fieldNumber = settings.h5p.drupal_h5p_editor.h5peditor.fieldNumber; // Elements var h5peditor; var $upload = $('input[name="files[h5p]"]').parents('.form-item'); var $editor = $('.h5p-editor'); var $create = $('#edit-h5p-editor').hide(); var $type = $('input[name="h5p_type"]'); var $params = $('input[name="' + fieldName + '[' + fieldNumber + '][value][json_content]"]'); var $library = $('input[name="' + fieldName + '[' + fieldNumber + '][value][h5p_library]"]'); var library = $library.val(); // Semantics describing what copyright information can be stored for media. ns.copyrightSemantics = settings.h5p.drupal_h5p_editor.h5peditor.copyrightSemantics; Loading @@ -50,7 +54,7 @@ var ns = H5PEditor; } $create.show(); } }).change(); }); // TODO: Use something more robust than mousedown. $('#edit-actions').find('input[type="submit"]').mousedown(function () { Loading @@ -71,6 +75,9 @@ var ns = H5PEditor; } } }); // Trigger editor load $type.change(); }; ns.getAjaxUrl = function (action, parameters) { Loading
modules/h5peditor/src/Controller/H5PEditorAJAXController.php +13 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,19 @@ class H5PEditorAJAXController extends ControllerBase { exit(); } /** * Callback for uploading a library * * @param string $token Editor security token * @param int $content_id Id of content that is being edited */ function libraryUploadCallback($token, $content_id) { $editor = H5PEditorUtilities::getInstance(); $filePath = $_FILES['h5p']['tmp_name']; $editor->ajax->action(\H5PEditorEndpoints::LIBRARY_UPLOAD, $token, $filePath, $content_id); exit(); } /** * Callback that returns all library data * Loading
modules/h5peditor/src/H5PEditor/H5PEditorDrupalStorage.php +4 −6 Original line number Diff line number Diff line Loading @@ -199,10 +199,10 @@ class H5PEditorDrupalStorage implements \H5peditorStorage { } // Set session variables necessary for finding the files $_SESSION['h5p_upload_folder'] = drupal_realpath($temporary_file_path); $_SESSION['h5p_upload'] = drupal_realpath($target); $dir = \Drupal::service('file_system')->realpath($temporary_file_path); $file_service = \Drupal::service('file_system'); $dir = $file_service->realpath($temporary_file_path); $interface->getUploadedH5pFolderPath($dir); $interface->getUploadedH5pPath("{$dir}/{$name}"); return (object) array( 'dir' => $dir, Loading Loading @@ -258,7 +258,5 @@ class H5PEditorDrupalStorage implements \H5peditorStorage { else { unlink($filePath); } // Maintain session variables unset($_SESSION['h5p_upload'], $_SESSION['h5p_upload_folder']); } }