Merge branch 'MDL-29945' of git://github.com/timhunt/moodle
This commit is contained in:
+60
-13
@@ -229,6 +229,24 @@ class plugin_manager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of any other pluings that require this one.
|
||||
* @param string $component frankenstyle component name.
|
||||
* @return array of frankensyle component names that require this one.
|
||||
*/
|
||||
public function other_plugins_that_require($component) {
|
||||
$others = array();
|
||||
foreach ($this->get_plugins() as $type => $plugins) {
|
||||
foreach ($plugins as $plugin) {
|
||||
$required = $plugin->get_other_required_plugins();
|
||||
if (isset($required[$component])) {
|
||||
$others[] = $plugin->component;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $others;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a dependencies list against the list of installed plugins.
|
||||
* @param array $dependencies compenent name to required version or ANY_VERSION.
|
||||
@@ -469,6 +487,8 @@ class plugin_manager {
|
||||
* Note that most of the useful information is made available in pubic fields,
|
||||
* which cannot be documented in this interface. See the field definitions on
|
||||
* {@link plugintype_base} to find out what information is available.
|
||||
*
|
||||
* @property-read string component the component name, type_name
|
||||
*/
|
||||
interface plugin_information {
|
||||
|
||||
@@ -614,6 +634,8 @@ interface plugin_information {
|
||||
/**
|
||||
* Defines public properties that all plugintype classes must have
|
||||
* and provides default implementation of required methods.
|
||||
*
|
||||
* @property-read string component the component name, type_name
|
||||
*/
|
||||
abstract class plugintype_base {
|
||||
|
||||
@@ -673,10 +695,25 @@ abstract class plugintype_base {
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function init_display_name() {
|
||||
if (! get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = '[pluginname,' . $this->type . '_' . $this->name . ']';
|
||||
if (!get_string_manager()->string_exists('pluginname', $this->component)) {
|
||||
$this->displayname = '[pluginname,' . $this->component . ']';
|
||||
} else {
|
||||
$this->displayname = get_string('pluginname', $this->type . '_' . $this->name);
|
||||
$this->displayname = get_string('pluginname', $this->component);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method getter, redirects to read only values.
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name) {
|
||||
switch ($name) {
|
||||
case 'component': return $this->type . '_' . $this->name;
|
||||
|
||||
default:
|
||||
debugging('Invalid plugin property accessed! '.$name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -752,7 +789,7 @@ abstract class plugintype_base {
|
||||
*/
|
||||
public function load_db_version() {
|
||||
|
||||
if ($ver = self::get_version_from_config_plugins($this->type . '_' . $this->name)) {
|
||||
if ($ver = self::get_version_from_config_plugins($this->component)) {
|
||||
$this->versiondb = $ver;
|
||||
}
|
||||
}
|
||||
@@ -1244,10 +1281,10 @@ class plugintype_mod extends plugintype_base implements plugin_information {
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function init_display_name() {
|
||||
if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = get_string('pluginname', $this->type . '_' . $this->name);
|
||||
if (get_string_manager()->string_exists('pluginname', $this->component)) {
|
||||
$this->displayname = get_string('pluginname', $this->component);
|
||||
} else {
|
||||
$this->displayname = get_string('modulename', $this->type . '_' . $this->name);
|
||||
$this->displayname = get_string('modulename', $this->component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1364,6 +1401,11 @@ class plugintype_qbehaviour extends plugintype_base implements plugin_informatio
|
||||
$this->dependencies['qbehaviour_' . $other] = ANY_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_uninstall_url() {
|
||||
return new moodle_url('/admin/qbehaviours.php',
|
||||
array('delete' => $this->name, 'sesskey' => sesskey()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1376,10 +1418,10 @@ class plugintype_qtype extends plugintype_base implements plugin_information {
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function init_display_name() {
|
||||
if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = get_string('pluginname', $this->type . '_' . $this->name);
|
||||
if (get_string_manager()->string_exists('pluginname', $this->component)) {
|
||||
$this->displayname = get_string('pluginname', $this->component);
|
||||
} else {
|
||||
$this->displayname = get_string($this->name, 'qtype_' . $this->name);
|
||||
$this->displayname = get_string($this->name, $this->component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1400,6 +1442,11 @@ class plugintype_qtype extends plugintype_base implements plugin_information {
|
||||
$this->dependencies['qtype_' . $other] = ANY_VERSION;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_uninstall_url() {
|
||||
return new moodle_url('/admin/qtypes.php',
|
||||
array('delete' => $this->name, 'sesskey' => sesskey()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1411,10 +1458,10 @@ class plugintype_qformat extends plugintype_base implements plugin_information {
|
||||
* @see plugin_information::init_display_name()
|
||||
*/
|
||||
public function init_display_name() {
|
||||
if (get_string_manager()->string_exists('pluginname', $this->type . '_' . $this->name)) {
|
||||
$this->displayname = get_string('pluginname', $this->type . '_' . $this->name);
|
||||
if (get_string_manager()->string_exists('pluginname', $this->component)) {
|
||||
$this->displayname = get_string('pluginname', $this->component);
|
||||
} else {
|
||||
$this->displayname = get_string($this->name, 'qformat_' . $this->name);
|
||||
$this->displayname = get_string($this->name, $this->component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user