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]

   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   * Subplugin info class.
  19   *
  20   * @package   editor_tinymce
  21   * @copyright 2012 Petr Skoda {@link http://skodak.org}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace editor_tinymce\plugininfo;
  25  
  26  use core\plugininfo\base, moodle_url, part_of_admin_tree, admin_settingpage, core_component;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  
  31  class tinymce extends base {
  32      /**
  33       * Finds all enabled plugins, the result may include missing plugins.
  34       * @return array|null of enabled plugins $pluginname=>$pluginname, null means unknown
  35       */
  36      public static function get_enabled_plugins() {
  37          $disabledsubplugins = array();
  38          $config = get_config('editor_tinymce', 'disabledsubplugins');
  39          if ($config) {
  40              $config = explode(',', $config);
  41              foreach ($config as $sp) {
  42                  $sp = trim($sp);
  43                  if ($sp !== '') {
  44                      $disabledsubplugins[$sp] = $sp;
  45                  }
  46              }
  47          }
  48  
  49          $enabled = array();
  50          $installed = core_component::get_plugin_list('tinymce');
  51          foreach ($installed as $plugin => $fulldir) {
  52              if (isset($disabledsubplugins[$plugin])) {
  53                  continue;
  54              }
  55              $enabled[$plugin] = $plugin;
  56          }
  57  
  58          return $enabled;
  59      }
  60  
  61      public function is_uninstall_allowed() {
  62          return true;
  63      }
  64  
  65      /**
  66       * Return URL used for management of plugins of this type.
  67       * @return moodle_url
  68       */
  69      public static function get_manage_url() {
  70          return new moodle_url('/admin/settings.php', array('section'=>'editorsettingstinymce'));
  71      }
  72  
  73      public function get_settings_section_name() {
  74          return 'tinymce'.$this->name.'settings';
  75      }
  76  
  77      public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
  78          global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
  79          $ADMIN = $adminroot; // May be used in settings.php.
  80          $plugininfo = $this; // Also can be used inside settings.php.
  81  
  82          if (!$this->is_installed_and_upgraded()) {
  83              return;
  84          }
  85  
  86          if (!$hassiteconfig or !file_exists($this->full_path('settings.php'))) {
  87              return;
  88          }
  89  
  90          $section = $this->get_settings_section_name();
  91          $settings = new admin_settingpage($section, $this->displayname, 'moodle/site:config', $this->is_enabled() === false);
  92          include($this->full_path('settings.php')); // This may also set $settings to null.
  93  
  94          if ($settings) {
  95              $ADMIN->add($parentnodename, $settings);
  96          }
  97      }
  98  }