Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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   * Tiny Link plugin.
  19   *
  20   * @package    tiny_link
  21   * @copyright  2022 Huong Nguyen <huongnv13@gmail.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace tiny_link;
  26  
  27  use context;
  28  use context_system;
  29  use editor_tiny\editor;
  30  use editor_tiny\plugin;
  31  use editor_tiny\plugin_with_buttons;
  32  use editor_tiny\plugin_with_configuration;
  33  use editor_tiny\plugin_with_menuitems;
  34  
  35  /**
  36   * Tiny link plugin.
  37   *
  38   * @package    tiny_link
  39   * @copyright  2023 Huong Nguyen <huongnv13@gmail.com>
  40   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  41   */
  42  class plugininfo extends plugin implements plugin_with_buttons, plugin_with_menuitems, plugin_with_configuration {
  43  
  44      /**
  45       * Get a list of the buttons provided by this plugin.
  46       *
  47       * @return string[]
  48       */
  49      public static function get_available_buttons(): array {
  50          return [
  51              'tiny_link/tiny_link_link',
  52              'tiny_link/tiny_link_unlink',
  53          ];
  54      }
  55  
  56      /**
  57       * Get a list of the menu items provided by this plugin.
  58       *
  59       * @return string[]
  60       */
  61      public static function get_available_menuitems(): array {
  62          return [
  63              'tiny_link/tiny_link_link',
  64          ];
  65      }
  66  
  67      /**
  68       * Get a list of the menu items provided by this plugin.
  69       *
  70       * @param context $context The context that the editor is used within
  71       * @param array $options The options passed in when requesting the editor
  72       * @param array $fpoptions The filepicker options passed in when requesting the editor
  73       * @param editor $editor The editor instance in which the plugin is initialised
  74       * @return array
  75       */
  76      public static function get_plugin_configuration_for_context(
  77          context $context,
  78          array $options,
  79          array $fpoptions,
  80          ?editor $editor = null
  81      ): array {
  82          // TODO Fetch the actual permissions.
  83          $permissions['filepicker'] = true;
  84  
  85          return [
  86              'permissions' => $permissions,
  87          ];
  88      }
  89  }