Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Atto text editor integration version file.
  19   *
  20   * @package    atto_h5p
  21   * @copyright  2019 Bas Brands <bas@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  use core_h5p\local\library\autoloader;
  28  
  29  /**
  30   * Set params for this button.
  31   *
  32   * @param string $elementid
  33   * @param stdClass $options - the options for the editor, including the context.
  34   * @param stdClass $fpoptions - unused.
  35   */
  36  function atto_h5p_params_for_js($elementid, $options, $fpoptions) {
  37      $context = $options['context'];
  38      if (!$context) {
  39          $context = context_system::instance();
  40      }
  41  
  42      $addembed = has_capability('atto/h5p:addembed', $context);
  43      $upload = has_capability('moodle/h5p:deploy', $context);
  44  
  45      $allowedmethods = 'none';
  46      if ($addembed && $upload) {
  47          $allowedmethods = 'both';
  48      } else if ($addembed) {
  49          $allowedmethods = 'embed';
  50      } else if ($upload) {
  51          $allowedmethods = 'upload';
  52      }
  53  
  54      $params = [
  55          'allowedmethods' => $allowedmethods,
  56          'storeinrepo' => true
  57      ];
  58      return $params;
  59  }
  60  
  61  /**
  62   * Initialise the strings required for js
  63   */
  64  function atto_h5p_strings_for_js() {
  65      global $PAGE;
  66  
  67      $strings = array(
  68          'browserepositories',
  69          'copyrightbutton',
  70          'downloadbutton',
  71          'instructions',
  72          'embedbutton',
  73          'h5pfile',
  74          'h5poptions',
  75          'h5purl',
  76          'h5pfileorurl',
  77          'invalidh5purl',
  78          'noh5pcontent',
  79          'pluginname'
  80      );
  81  
  82      $PAGE->requires->strings_for_js($strings, 'atto_h5p');
  83      $PAGE->requires->js(autoloader::get_h5p_core_library_url('js/h5p-resizer.js'));
  84  }
  85  
  86