Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Defines class used for orphaned subplugins.
19
 *
20
 * @package    core
21
 * @copyright  2013 Petr Skoda {@link http://skodak.org}
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
namespace core\plugininfo;
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
 
29
/**
30
 * Orphaned subplugins class.
31
 */
32
class orphaned extends base {
33
    public function is_uninstall_allowed() {
34
        return true;
35
    }
36
 
37
    /**
38
     * We do not know if orphaned subplugins are enabled.
39
     * @return bool
40
     */
41
    public function is_enabled() {
42
        return null;
43
    }
44
 
45
    /**
46
     * No lang strings are present.
47
     */
48
    public function init_display_name() {
49
        $this->displayname = $this->component;
50
    }
51
 
52
    /**
53
     * Oprhaned plugins can not be enabled.
54
     * @return array|null of enabled plugins $pluginname=>$pluginname, null means unknown
55
     */
56
    public static function get_enabled_plugins() {
57
        return null;
58
    }
59
 
60
    /**
61
     * Gathers and returns the information about all plugins of the given type,
62
     * either on disk or previously installed.
63
     *
64
     * @param string $type the name of the plugintype, eg. mod, auth or workshopform
65
     * @param string $typerootdir full path to the location of the plugin dir
66
     * @param string $typeclass the name of the actually called class
67
     * @param \core_plugin_manager $pluginman the plugin manager calling this method
68
     * @return array of plugintype classes, indexed by the plugin name
69
     */
70
    public static function get_plugins($type, $typerootdir, $typeclass, $pluginman) {
71
        $return = array();
72
        $plugins = $pluginman->get_installed_plugins($type);
73
 
74
        foreach ($plugins as $name => $version) {
75
            $plugin              = new $typeclass();
76
            $plugin->type        = $type;
77
            $plugin->typerootdir = $typerootdir;
78
            $plugin->name        = $name;
79
            $plugin->rootdir     = null;
80
            $plugin->displayname = $name;
81
            $plugin->versiondb   = $version;
82
            $plugin->pluginman   = $pluginman;
83
            $plugin->init_is_standard();
84
 
85
            $return[$name] = $plugin;
86
        }
87
 
88
        return $return;
89
    }
90
}