Merge branch 'w39_MDL-41208_m26_yui312' of https://github.com/skodak/moodle
[moodle.git] / admin / localplugins.php
blob8286e96fee5fde28dfab95b6fe7ca36de88bccad
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Provides an overview of installed local plugins
21 * Displays the list of found local plugins, their version (if found) and
22 * a link to delete the local plugin.
24 * @see http://docs.moodle.org/dev/Local_customisation
25 * @package admin
26 * @copyright 2010 David Mudrak <david.mudrak@gmail.com>
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 require_once(dirname(dirname(__FILE__)) . '/config.php');
31 require_once($CFG->libdir.'/adminlib.php');
32 require_once($CFG->libdir.'/tablelib.php');
33 require_once($CFG->libdir.'/pluginlib.php');
35 admin_externalpage_setup('managelocalplugins');
37 echo $OUTPUT->header();
38 echo $OUTPUT->heading(get_string('localplugins'));
40 /// Print the table of all installed local plugins
42 $table = new flexible_table('localplugins_administration_table');
43 $table->define_columns(array('name', 'version', 'uninstall'));
44 $table->define_headers(array(get_string('plugin'), get_string('version'), get_string('uninstallplugin', 'core_admin')));
45 $table->define_baseurl($PAGE->url);
46 $table->set_attribute('id', 'localplugins');
47 $table->set_attribute('class', 'admintable generaltable');
48 $table->setup();
50 $plugins = array();
51 foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
52 if (get_string_manager()->string_exists('pluginname', 'local_' . $plugin)) {
53 $strpluginname = get_string('pluginname', 'local_' . $plugin);
54 } else {
55 $strpluginname = $plugin;
57 $plugins[$plugin] = $strpluginname;
59 core_collator::asort($plugins);
61 foreach ($plugins as $plugin => $name) {
62 $uninstall = '';
63 if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('local_'.$plugin)) {
64 $uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
67 $version = get_config('local_' . $plugin);
68 if (!empty($version->version)) {
69 $version = $version->version;
70 } else {
71 $version = '?';
74 $table->add_data(array($name, $version, $uninstall));
77 $table->print_html();
79 echo $OUTPUT->footer();