Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 29... Línea 29...
29
 
29
 
30
/**
30
/**
31
 * Class for HTML editors
31
 * Class for HTML editors
32
 */
32
 */
33
class editor extends base {
-
 
-
 
33
class editor extends base {
34
 
34
    #[\Override]
35
    public static function plugintype_supports_disabling(): bool {
35
    public static function plugintype_supports_disabling(): bool {
36
        return true;
36
        return true;
Línea 37... Línea -...
37
    }
-
 
38
 
-
 
39
    /**
-
 
40
     * Finds all enabled plugins, the result may include missing plugins.
37
    }
41
     * @return array|null of enabled plugins $pluginname=>$pluginname, null means unknown
38
 
42
     */
39
    #[\Override]
Línea 43... Línea 40...
43
    public static function get_enabled_plugins() {
40
    public static function get_enabled_plugins() {
-
 
41
        global $CFG;
-
 
42
 
44
        global $CFG;
43
        if (empty($CFG->texteditors)) {
-
 
44
            return [
45
 
45
                'tiny' => 'tiny',
Línea 46... Línea 46...
46
        if (empty($CFG->texteditors)) {
46
                'textarea' => 'textarea',
47
            return array('atto'=>'atto', 'tinymce'=>'tinymce', 'textarea'=>'textarea');
47
            ];
48
        }
48
        }
49
 
49
 
Línea 50... Línea 50...
50
        $enabled = array();
50
        $enabled = [];
51
        foreach (explode(',', $CFG->texteditors) as $editor) {
51
        foreach (explode(',', $CFG->texteditors) as $editor) {
Línea -... Línea 52...
-
 
52
            $enabled[$editor] = $editor;
52
            $enabled[$editor] = $editor;
53
        }
53
        }
54
 
Línea 54... Línea 55...
54
 
55
        return $enabled;
55
        return $enabled;
56
    }
Línea 89... Línea 90...
89
        }
90
        }
Línea 90... Línea 91...
90
 
91
 
91
        return $haschanged;
92
        return $haschanged;
Línea -... Línea 93...
-
 
93
    }
92
    }
94
 
93
 
95
    #[\Override]
94
    public function get_settings_section_name() {
96
    public function get_settings_section_name() {
Línea -... Línea 97...
-
 
97
        return 'editorsettings' . $this->name;
95
        return 'editorsettings' . $this->name;
98
    }
96
    }
99
 
97
 
100
    #[\Override]
98
    public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
101
    public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
99
        global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
102
        global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
Línea 118... Línea 121...
118
        if ($settings) {
121
        if ($settings) {
119
            $ADMIN->add($parentnodename, $settings);
122
            $ADMIN->add($parentnodename, $settings);
120
        }
123
        }
121
    }
124
    }
Línea 122... Línea -...
122
 
-
 
123
    /**
-
 
124
     * Basic textarea editor can not be uninstalled.
125
 
125
     */
126
    #[\Override]
126
    public function is_uninstall_allowed() {
127
    public function is_uninstall_allowed() {
127
        if ($this->name === 'textarea') {
128
        if ($this->name === 'textarea') {
128
            return false;
129
            return false;
129
        } else {
130
        } else {
130
            return true;
131
            return true;
131
        }
132
        }
Línea 132... Línea 133...
132
    }
133
    }
-
 
134
 
-
 
135
    #[\Override]
-
 
136
    public function uninstall_cleanup(): void {
133
 
137
        global $DB;
-
 
138
 
134
    /**
139
        self::enable_plugin($this->name, 0);
-
 
140
        $DB->delete_records_select(
-
 
141
            'user_preferences',
-
 
142
            "name = :name AND " . $DB->sql_compare_text('value') . " = " . $DB->sql_compare_text(':value'),
-
 
143
            [
-
 
144
                'name' => 'htmleditor',
-
 
145
                'value' => $this->name,
135
     * Return URL used for management of plugins of this type.
146
            ],
-
 
147
        );
-
 
148
    }
136
     * @return moodle_url
149
 
137
     */
150
    #[\Override]
138
    public static function get_manage_url() {
151
    public static function get_manage_url() {
Línea -... Línea 152...
-
 
152
        return new moodle_url('/admin/settings.php', array('section'=>'manageeditors'));
139
        return new moodle_url('/admin/settings.php', array('section'=>'manageeditors'));
153
    }
140
    }
154
 
141
 
155
    #[\Override]
Línea -... Línea 156...
-
 
156
    public static function plugintype_supports_ordering(): bool {
142
    public static function plugintype_supports_ordering(): bool {
157
        return true;
143
        return true;
158
    }
Línea 144... Línea 159...
144
    }
159
 
145
 
160
    #[\Override]
Línea 173... Línea 188...
173
            $sortedplugins,
188
            $sortedplugins,
174
            $plugins,
189
            $plugins,
175
        );
190
        );
176
    }
191
    }
Línea -... Línea 192...
-
 
192
 
177
 
193
    #[\Override]
178
    public static function change_plugin_order(string $pluginname, int $direction): bool {
194
    public static function change_plugin_order(string $pluginname, int $direction): bool {
179
        $activeeditors = array_keys(self::get_sorted_plugins(true));
195
        $activeeditors = array_keys(self::get_sorted_plugins(true));
Línea 180... Línea 196...
180
        $key = array_search($pluginname, $activeeditors);
196
        $key = array_search($pluginname, $activeeditors);