MDL-40220 use new core_component::get_component_directory()

This commit is contained in:
Petr Škoda 2013-07-16 22:42:37 +02:00
parent 56da374e1e
commit b0d1d941c9
17 changed files with 30 additions and 30 deletions

View File

@ -918,7 +918,7 @@ class restore_groups_members_structure_step extends restore_structure_step {
}
} else {
$dir = get_component_directory($data->component);
$dir = core_component::get_component_directory($data->component);
if ($dir and is_dir($dir)) {
if (component_callback($data->component, 'restore_group_member', array($this, $data), true)) {
return;
@ -1597,7 +1597,7 @@ class restore_ras_and_caps_structure_step extends restore_structure_step {
$data->roleid = $newroleid;
$data->userid = $newuserid;
$data->contextid = $contextid;
$dir = get_component_directory($data->component);
$dir = core_component::get_component_directory($data->component);
if ($dir and is_dir($dir)) {
if (component_callback($data->component, 'restore_role_assignment', array($this, $data), true)) {
return;

View File

@ -82,7 +82,7 @@ function groups_add_member($grouporid, $userorid, $component=null, $itemid=0) {
// Check the component exists if specified
if (!empty($component)) {
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
if ($dir && is_dir($dir)) {
// Component exists and can be used
$member->component = $component;

View File

@ -2387,7 +2387,7 @@ function count_enrolled_users(context $context, $withcapability = '', $groupid =
* @return array array of capabilities
*/
function load_capability_def($component) {
$defpath = get_component_directory($component).'/db/access.php';
$defpath = core_component::get_component_directory($component).'/db/access.php';
$capabilities = array();
if (file_exists($defpath)) {
@ -2863,7 +2863,7 @@ function get_capability_string($capabilityname) {
return get_string($stringname, $component);
}
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
if (!file_exists($dir)) {
// plugin broken or does not exist, do not bother with printing of debug message
return $capabilityname.' ???';

View File

@ -532,7 +532,7 @@ function cron_execute_plugin_type($plugintype, $description = null) {
}
foreach ($plugins as $component=>$cronfunction) {
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
// Get cron period if specified in version.php, otherwise assume every cron
$cronperiod = 0;

View File

@ -418,7 +418,7 @@ abstract class editor_tinymce_plugin {
* @return editor_tinymce_plugin Plugin object
*/
public static function get($plugin) {
$dir = get_component_directory('tinymce_' . $plugin);
$dir = core_component::get_component_directory('tinymce_' . $plugin);
require_once($dir . '/lib.php');
$classname = 'tinymce_' . $plugin;
return new $classname($plugin);

View File

@ -40,7 +40,7 @@ function events_load_def($component) {
if ($component === 'unittest') {
$defpath = $CFG->dirroot.'/lib/tests/fixtures/events.php';
} else {
$defpath = get_component_directory($component).'/db/events.php';
$defpath = core_component::get_component_directory($component).'/db/events.php';
}
$handlers = array();

View File

@ -44,7 +44,7 @@ function external_function_info($function, $strictness=MUST_EXIST) {
}
//first find and include the ext implementation class
$function->classpath = empty($function->classpath) ? get_component_directory($function->component).'/externallib.php' : $CFG->dirroot.'/'.$function->classpath;
$function->classpath = empty($function->classpath) ? core_component::get_component_directory($function->component).'/externallib.php' : $CFG->dirroot.'/'.$function->classpath;
if (!file_exists($function->classpath)) {
throw new coding_exception('Can not find file with external function implementation');
}
@ -83,7 +83,7 @@ function external_function_info($function, $strictness=MUST_EXIST) {
// on the other hand this is still a bit in a flux and we need to find some new naming
// conventions for these descriptions in lang packs
$function->description = null;
$servicesfile = get_component_directory($function->component).'/db/services.php';
$servicesfile = core_component::get_component_directory($function->component).'/db/services.php';
if (file_exists($servicesfile)) {
$functions = null;
include($servicesfile);

View File

@ -4543,7 +4543,7 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {
} else {
// try to serve general plugin file in arbitrary context
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
if (!file_exists("$dir/lib.php")) {
send_file_not_found();
}

View File

@ -116,7 +116,7 @@ function message_send($eventdata) {
if (PHPUNIT_TEST and class_exists('phpunit_util')) {
// Add some more tests to make sure the normal code can actually work.
$componentdir = get_component_directory($eventdata->component);
$componentdir = core_component::get_component_directory($eventdata->component);
if (!$componentdir or !is_dir($componentdir)) {
throw new coding_exception('Invalid component specified in message-send(): '.$eventdata->component);
}
@ -525,7 +525,7 @@ function message_get_providers_from_db($component) {
* @return array An array of message providers or empty array if not exists
*/
function message_get_providers_from_file($component) {
$defpath = get_component_directory($component).'/db/messages.php';
$defpath = core_component::get_component_directory($component).'/db/messages.php';
$messageproviders = array();

View File

@ -174,7 +174,7 @@ abstract class renderer_factory_base implements renderer_factory {
if ($component !== 'core') {
// renderers are stored in renderer.php files
if (!$compdirectory = get_component_directory($component)) {
if (!$compdirectory = core_component::get_component_directory($component)) {
throw new coding_exception('Invalid component specified in renderer request');
}
$rendererfile = $compdirectory . '/renderer.php';

View File

@ -416,7 +416,7 @@ class page_requirements_manager {
return true;
}
$componentdir = get_component_directory($component);
$componentdir = core_component::get_component_directory($component);
if (!file_exists($componentdir) or !file_exists("$componentdir/jquery/plugins.php")) {
debugging("Can not load jQuery plugin '$plugin', missing plugins.php in component '$component'.", DEBUG_DEVELOPER);
return false;
@ -704,7 +704,7 @@ class page_requirements_manager {
}
} else {
if ($dir = get_component_directory($component)) {
if ($dir = core_component::get_component_directory($component)) {
if (file_exists("$dir/module.js")) {
if (strpos($dir, $CFG->dirroot.'/') === 0) {
$dir = substr($dir, strlen($CFG->dirroot));
@ -1647,7 +1647,7 @@ class YUI_config {
private function get_moodle_metadata() {
$moodlemodules = array();
// Core isn't a plugin type or subsystem - handle it seperately.
if ($module = $this->get_moodle_path_metadata(get_component_directory('core'))) {
if ($module = $this->get_moodle_path_metadata(core_component::get_component_directory('core'))) {
$moodlemodules = array_merge($moodlemodules, $module);
}

View File

@ -1313,7 +1313,7 @@ function portfolio_include_callback_file($component, $class = null) {
}
// Obtain the component's location.
if (!$componentloc = get_component_directory($component)) {
if (!$componentloc = core_component::get_component_directory($component)) {
throw new portfolio_button_exception('nocallbackcomponent', 'portfolio', '', $component);
}

View File

@ -1880,7 +1880,7 @@ function question_pluginfile($course, $context, $component, $filearea, $args, $f
$component, $filearea, $qubaid, $slot, $args, $forcedownload, $options);
} else {
$dir = get_component_directory($module);
$dir = core_component::get_component_directory($module);
if (!file_exists("$dir/lib.php")) {
send_file_not_found();
}

View File

@ -107,7 +107,7 @@ EOD;
return $this->generators[$component];
}
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
$lib = $dir . '/tests/generator/lib.php';
if (!$dir || !is_readable($lib)) {
throw new coding_exception("Component {$component} does not support " .

View File

@ -413,7 +413,7 @@ function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
if (isset($plugin->component)) {
if ($plugin->component !== $component) {
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullplug);
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($plugin->component));
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', core_component::get_component_directory($plugin->component));
throw new plugin_misplaced_exception($component, $expected, $current);
}
}
@ -571,7 +571,7 @@ function upgrade_plugins_modules($startcallback, $endcallback, $verbose) {
if (isset($module->component)) {
if ($module->component !== $component) {
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullmod);
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($module->component));
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', core_component::get_component_directory($module->component));
throw new plugin_misplaced_exception($component, $expected, $current);
}
}
@ -751,7 +751,7 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
if (isset($block->component)) {
if ($block->component !== $component) {
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullblock);
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($block->component));
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', core_component::get_component_directory($block->component));
throw new plugin_misplaced_exception($component, $expected, $current);
}
}
@ -909,7 +909,7 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
function log_update_descriptions($component) {
global $DB;
$defpath = get_component_directory($component).'/db/log.php';
$defpath = core_component::get_component_directory($component).'/db/log.php';
if (!file_exists($defpath)) {
$DB->delete_records('log_display', array('component'=>$component));
@ -966,7 +966,7 @@ function log_update_descriptions($component) {
function external_update_descriptions($component) {
global $DB, $CFG;
$defpath = get_component_directory($component).'/db/services.php';
$defpath = core_component::get_component_directory($component).'/db/services.php';
if (!file_exists($defpath)) {
require_once($CFG->dirroot.'/lib/externallib.php');
@ -1187,7 +1187,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
$currentversion = ($currentversion === false) ? null : $currentversion;
} catch (Exception $ignored) {
}
$cd = get_component_directory($component);
$cd = core_component::get_component_directory($component);
if (file_exists("$cd/version.php")) {
$module = new stdClass();
$module->version = null;
@ -1202,7 +1202,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
}
} catch (Exception $ignored) {
}
$cd = get_component_directory($component);
$cd = core_component::get_component_directory($component);
if (file_exists("$cd/version.php")) {
$plugin = new stdClass();
$plugin->version = null;
@ -1215,7 +1215,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
if (!empty($pluginversion)) {
$currentversion = $pluginversion;
}
$cd = get_component_directory($component);
$cd = core_component::get_component_directory($component);
if (file_exists("$cd/version.php")) {
$plugin = new stdClass();
$plugin->version = null;

View File

@ -148,7 +148,7 @@ try {
}
// Work out which component in Moodle we want (from the frankenstyle name)
$componentdir = get_component_directory($componentname);
$componentdir = core_component::get_component_directory($componentname);
list($type, $plugin) = core_component::normalize_component($componentname);

View File

@ -134,7 +134,7 @@ class core_webservice_external extends external_api {
if ($function->component == 'moodle' || $function->component == 'core') {
$version = $CFG->version; // Moodle version.
} else {
$versionpath = get_component_directory($function->component).'/version.php';
$versionpath = core_component::get_component_directory($function->component).'/version.php';
if (is_readable($versionpath)) {
// We store the component version once retrieved (so we don't load twice the version.php).
if (!isset($componentversions[$function->component])) {