Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 28... Línea 28...
28
use core_plugin_manager;
28
use core_plugin_manager;
29
use moodle_url;
29
use moodle_url;
Línea 30... Línea 30...
30
 
30
 
31
/**
31
/**
32
 * Base class providing access to the information about a plugin
-
 
33
 *
-
 
34
 * @property-read string component the component name, type_name
32
 * Base class providing access to the information about a plugin
35
 */
33
 */
Línea 36... Línea 34...
36
abstract class base {
34
abstract class base {
37
 
35
 
Línea 84... Línea 82...
84
    public $incompatible;
82
    public $incompatible;
Línea 85... Línea 83...
85
 
83
 
86
    /** @var string Name of the plugin */
84
    /** @var string Name of the plugin */
Línea -... Línea 85...
-
 
85
    public $component = '';
-
 
86
 
-
 
87
    /** @var bool whether the plugin is that of a phase 1 deprecated type or subplugin type. */
-
 
88
    public $deprecatedtype = false;
-
 
89
 
-
 
90
    /** @var bool whether the plugin is that of a phase 2 deprecated (deleted) type or subplugin type. */
87
    public $component = '';
91
    public $deletedtype = false;
88
 
92
 
89
    /**
93
    /**
90
     * Whether this plugintype supports its plugins being disabled.
94
     * Whether this plugintype supports its plugins being disabled.
91
     *
95
     *
Línea 141... Línea 145...
141
     * @param string $typeclass the name of the actually called class
145
     * @param string $typeclass the name of the actually called class
142
     * @param core_plugin_manager $pluginman the plugin manager calling this method
146
     * @param core_plugin_manager $pluginman the plugin manager calling this method
143
     * @return array of plugintype classes, indexed by the plugin name
147
     * @return array of plugintype classes, indexed by the plugin name
144
     */
148
     */
145
    public static function get_plugins($type, $typerootdir, $typeclass, $pluginman) {
149
    public static function get_plugins($type, $typerootdir, $typeclass, $pluginman) {
146
        // Get the information about plugins at the disk.
150
        // Get the information about plugins at the disk, including deprecated plugins.
147
        $plugins = core_component::get_plugin_list($type);
151
        $plugins = core_component::get_all_plugins_list($type);
-
 
152
 
-
 
153
        // Also included deleted plugins.
-
 
154
 
148
        $return = array();
155
        $return = array();
149
        foreach ($plugins as $pluginname => $pluginrootdir) {
156
        foreach ($plugins as $pluginname => $pluginrootdir) {
150
            $return[$pluginname] = self::make_plugin_instance($type, $typerootdir,
157
            $return[$pluginname] = self::make_plugin_instance($type, $typerootdir,
151
                $pluginname, $pluginrootdir, $typeclass, $pluginman);
158
                $pluginname, $pluginrootdir, $typeclass, $pluginman);
152
        }
159
        }
Línea 153... Línea 160...
153
 
160
 
154
        // Fetch missing incorrectly uninstalled plugins.
161
        // Fetch missing incorrectly uninstalled plugins, including deprecated plugins which are not included above.
Línea 155... Línea 162...
155
        $plugins = $pluginman->get_installed_plugins($type);
162
        $plugins = $pluginman->get_installed_plugins($type);
156
 
163
 
157
        foreach ($plugins as $name => $version) {
164
        foreach ($plugins as $name => $version) {
Línea 166... Línea 173...
166
            $plugin->rootdir     = null;
173
            $plugin->rootdir     = null;
167
            $plugin->displayname = $name;
174
            $plugin->displayname = $name;
168
            $plugin->versiondb   = $version;
175
            $plugin->versiondb   = $version;
169
            $plugin->pluginman   = $pluginman;
176
            $plugin->pluginman   = $pluginman;
170
            $plugin->init_is_standard();
177
            $plugin->init_is_standard();
-
 
178
            $plugin->init_is_deprecated();
Línea 171... Línea 179...
171
 
179
 
172
            $return[$name] = $plugin;
180
            $return[$name] = $plugin;
Línea 173... Línea 181...
173
        }
181
        }
Línea 197... Línea 205...
197
 
205
 
198
        $plugin->init_display_name();
206
        $plugin->init_display_name();
199
        $plugin->load_disk_version();
207
        $plugin->load_disk_version();
200
        $plugin->load_db_version();
208
        $plugin->load_db_version();
-
 
209
        $plugin->init_is_standard();
Línea 201... Línea 210...
201
        $plugin->init_is_standard();
210
        $plugin->init_is_deprecated();
202
 
211
 
Línea 203... Línea 212...
203
        return $plugin;
212
        return $plugin;
Línea 268... Línea 277...
268
     * If the value is null after calling this method, either the plugin
277
     * If the value is null after calling this method, either the plugin
269
     * does not use versioning (typically does not have any database
278
     * does not use versioning (typically does not have any database
270
     * data) or is missing from disk.
279
     * data) or is missing from disk.
271
     */
280
     */
272
    public function load_disk_version() {
281
    public function load_disk_version() {
-
 
282
        // Note: this includes deprecated plugins.
273
        $versions = $this->pluginman->get_present_plugins($this->type);
283
        $versions = $this->pluginman->get_present_plugins($this->type);
Línea 274... Línea 284...
274
 
284
 
275
        $this->versiondisk = null;
285
        $this->versiondisk = null;
276
        $this->versionrequires = null;
286
        $this->versionrequires = null;
Línea 347... Línea 357...
347
     * If I am a subplugin, return the name of my parent plugin.
357
     * If I am a subplugin, return the name of my parent plugin.
348
     *
358
     *
349
     * @return string|bool false if not a subplugin, name of the parent otherwise
359
     * @return string|bool false if not a subplugin, name of the parent otherwise
350
     */
360
     */
351
    public function get_parent_plugin() {
361
    public function get_parent_plugin() {
352
        return $this->pluginman->get_parent_of_subplugin($this->type);
362
        return $this->pluginman->get_parent_of_subplugin($this->type, true);
353
    }
363
    }
Línea 354... Línea 364...
354
 
364
 
355
    /**
365
    /**
356
     * Sets {@link $versiondb} property to a numerical value representing the
366
     * Sets {@link $versiondb} property to a numerical value representing the
Línea 395... Línea 405...
395
            }
405
            }
396
        }
406
        }
397
    }
407
    }
Línea 398... Línea 408...
398
 
408
 
-
 
409
    /**
-
 
410
     * Init some instance props denoting the deprecation state of the plugin.
-
 
411
     *
-
 
412
     * Sets {@see $deprecatedtype} property, indicating whether the plugintype is phase 1 deprecated.
-
 
413
     * Sets {@see $deletedtype} property, indicating whether the plugintype is phase 2 deprecated.
-
 
414
     * Sets {@see $displayname} property to the plugin name phase 2 deprecated plugins since lang string support has then ended.
-
 
415
     *
-
 
416
     * @return void
-
 
417
     */
-
 
418
    final public function init_is_deprecated(): void {
-
 
419
        $this->deprecatedtype = \core_component::is_deprecated_plugin_type($this->type);
-
 
420
        $this->deletedtype = \core_component::is_deleted_plugin_type($this->type);
-
 
421
        $this->displayname = $this->deletedtype ? $this->name : $this->displayname;
-
 
422
    }
-
 
423
 
399
    /**
424
    /**
400
     * Returns true if the plugin is shipped with the official distribution
425
     * Returns true if the plugin is shipped with the official distribution
401
     * of the current Moodle version, false otherwise.
426
     * of the current Moodle version, false otherwise.
402
     *
427
     *
403
     * @return bool
428
     * @return bool
Línea 499... Línea 524...
499
 
524
 
500
        return isset($enabled[$this->name]);
525
        return isset($enabled[$this->name]);
Línea 501... Línea 526...
501
    }
526
    }
-
 
527
 
-
 
528
    /**
-
 
529
     * Return whether this plugin is deprecated (i.e. the plugin type to which it belongs is deprecated).
-
 
530
     *
-
 
531
     * @return bool
-
 
532
     */
-
 
533
    public function is_deprecated(): bool {
-
 
534
        return $this->deprecatedtype;
-
 
535
    }
-
 
536
 
-
 
537
    /**
-
 
538
     * Return whether this plugin is deleted (i.e. the plugin type to which it belongs is deleted).
-
 
539
     *
-
 
540
     * @return bool
-
 
541
     */
-
 
542
    public function is_deleted(): bool {
-
 
543
        return $this->deletedtype;
-
 
544
    }
502
 
545
 
503
    /**
546
    /**
504
     * If there are updates for this plugin available, returns them.
547
     * If there are updates for this plugin available, returns them.
505
     *
548
     *
506
     * Returns array of {@link \core\update\info} objects, if some update
549
     * Returns array of {@link \core\update\info} objects, if some update