本文整理汇总了PHP中core_component::normalize_component方法的典型用法代码示例。如果您正苦于以下问题:PHP core_component::normalize_component方法的具体用法?PHP core_component::normalize_component怎么用?PHP core_component::normalize_component使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_component
的用法示例。
在下文中一共展示了core_component::normalize_component方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Do not instantinate this directly, use {@link grading_manager::get_controller()}
*
* @param stdClass $context the context of the form
* @param string $component the frankenstyle name of the component
* @param string $area the name of the gradable area
* @param int $areaid the id of the gradable area record
*/
public function __construct(stdClass $context, $component, $area, $areaid)
{
global $DB;
$this->context = $context;
list($type, $name) = core_component::normalize_component($component);
$this->component = $type . '_' . $name;
$this->area = $area;
$this->areaid = $areaid;
$this->load_definition();
}
示例2: scheduled_tasks_table
/**
* This function will render one beautiful table with all the scheduled tasks.
*
* @param \core\task\scheduled_task[] $tasks - list of all scheduled tasks.
* @return string HTML to output.
*/
public function scheduled_tasks_table($tasks)
{
global $CFG;
$table = new html_table();
$table->head = array(get_string('name'), get_string('component', 'tool_task'), get_string('edit'), get_string('lastruntime', 'tool_task'), get_string('nextruntime', 'tool_task'), get_string('taskscheduleminute', 'tool_task'), get_string('taskschedulehour', 'tool_task'), get_string('taskscheduleday', 'tool_task'), get_string('taskscheduledayofweek', 'tool_task'), get_string('taskschedulemonth', 'tool_task'), get_string('faildelay', 'tool_task'), get_string('default', 'tool_task'));
$table->attributes['class'] = 'admintable generaltable';
$data = array();
$yes = get_string('yes');
$no = get_string('no');
$never = get_string('never');
$asap = get_string('asap', 'tool_task');
$disabled = get_string('disabled', 'tool_task');
foreach ($tasks as $task) {
$customised = $task->is_customised() ? $no : $yes;
$lastrun = $task->get_last_run_time() ? userdate($task->get_last_run_time()) : $never;
$nextrun = $task->get_next_run_time();
if ($task->get_disabled()) {
$nextrun = $disabled;
} else {
if ($nextrun > time()) {
$nextrun = userdate($nextrun);
} else {
$nextrun = $asap;
}
}
if (empty($CFG->preventscheduledtaskchanges)) {
$configureurl = new moodle_url('/admin/tool/task/scheduledtasks.php', array('action' => 'edit', 'task' => get_class($task)));
$editlink = $this->action_icon($configureurl, new pix_icon('t/edit', get_string('edittaskschedule', 'tool_task', $task->get_name())));
} else {
$editlink = $this->render(new pix_icon('t/locked', get_string('scheduledtaskchangesdisabled', 'tool_task')));
}
$namecell = new html_table_cell($task->get_name() . "\n" . html_writer::tag('span', '\\' . get_class($task), array('class' => 'task-class')));
$namecell->header = true;
$component = $task->get_component();
list($type, $plugin) = core_component::normalize_component($component);
if ($type === 'core') {
$componentcell = new html_table_cell(get_string('corecomponent', 'tool_task'));
} else {
if ($plugininfo = core_plugin_manager::instance()->get_plugin_info($component)) {
$plugininfo->init_display_name();
$componentcell = new html_table_cell($plugininfo->displayname);
} else {
$componentcell = new html_table_cell($component);
}
}
$row = new html_table_row(array($namecell, $componentcell, new html_table_cell($editlink), new html_table_cell($lastrun), new html_table_cell($nextrun), new html_table_cell($task->get_minute()), new html_table_cell($task->get_hour()), new html_table_cell($task->get_day()), new html_table_cell($task->get_day_of_week()), new html_table_cell($task->get_month()), new html_table_cell($task->get_fail_delay()), new html_table_cell($customised)));
if ($task->get_disabled()) {
$row->attributes['class'] = 'disabled';
}
$data[] = $row;
}
$table->data = $data;
return html_writer::table($table);
}
示例3: getComponentInstallDirectory
/**
* Get the absolute install directory path within Moodle.
*
* @param string $component Moodle component, EG: mod_forum
*
* @return string Absolute path, EG: /path/to/mod/forum
*/
public function getComponentInstallDirectory($component)
{
$this->requireConfig();
/* @noinspection PhpUndefinedClassInspection */
list($type, $name) = \core_component::normalize_component($component);
/* @noinspection PhpUndefinedClassInspection */
$types = \core_component::get_plugin_types();
if (!array_key_exists($type, $types)) {
throw new \InvalidArgumentException(sprintf('The component %s has an unknown plugin type of %s', $component, $type));
}
return $types[$type] . '/' . $name;
}
示例4: get_plugin_generator
/**
* Return generator for given plugin or component.
* @param string $component the component name, e.g. 'mod_forum' or 'core_question'.
* @return component_generator_base or rather an instance of the appropriate subclass.
*/
public function get_plugin_generator($component)
{
list($type, $plugin) = core_component::normalize_component($component);
$cleancomponent = $type . '_' . $plugin;
if ($cleancomponent != $component) {
debugging("Please specify the component you want a generator for as " . "{$cleancomponent}, not {$component}.", DEBUG_DEVELOPER);
$component = $cleancomponent;
}
if (isset($this->generators[$component])) {
return $this->generators[$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 " . "generators yet. Missing tests/generator/lib.php.");
}
include_once $lib;
$classname = $component . '_generator';
if (!class_exists($classname)) {
throw new coding_exception("Component {$component} does not support " . "data generators yet. Class {$classname} not found.");
}
$this->generators[$component] = new $classname($this);
return $this->generators[$component];
}
示例5: definition
function definition()
{
$mform = $this->_form;
$current = $this->_customdata['current'];
$mform->addElement('header', 'filtersettings', get_string('filter', 'tool_customlang'));
// Component
$options = array();
foreach (tool_customlang_utils::list_components() as $component => $normalized) {
list($type, $plugin) = core_component::normalize_component($normalized);
if ($type == 'core' and is_null($plugin)) {
$plugin = 'moodle';
}
$options[$type][$normalized] = $component . '.php';
}
$mform->addElement('selectgroups', 'component', get_string('filtercomponent', 'tool_customlang'), $options, array('multiple' => 'multiple', 'size' => 7));
// Customized only
$mform->addElement('advcheckbox', 'customized', get_string('filtercustomized', 'tool_customlang'));
$mform->setType('customized', PARAM_BOOL);
$mform->setDefault('customized', 0);
// Only helps
$mform->addElement('advcheckbox', 'helps', get_string('filteronlyhelps', 'tool_customlang'));
$mform->setType('helps', PARAM_BOOL);
$mform->setDefault('helps', 0);
// Modified only
$mform->addElement('advcheckbox', 'modified', get_string('filtermodified', 'tool_customlang'));
$mform->setType('modified', PARAM_BOOL);
$mform->setDefault('modified', 0);
// Substring
$mform->addElement('text', 'substring', get_string('filtersubstring', 'tool_customlang'));
$mform->setType('substring', PARAM_RAW);
// String identifier
$mform->addElement('text', 'stringid', get_string('filterstringid', 'tool_customlang'));
$mform->setType('stringid', PARAM_STRINGID);
// Show strings - submit button
$mform->addElement('submit', 'submit', get_string('filtershowstrings', 'tool_customlang'));
}
示例6: upgrade_plugin_mnet_functions
/**
* upgrades the mnet rpc definitions for the given component.
* this method doesn't return status, an exception will be thrown in the case of an error
*
* @param string $component the plugin to upgrade, eg auth_mnet
*/
function upgrade_plugin_mnet_functions($component)
{
global $DB, $CFG;
list($type, $plugin) = core_component::normalize_component($component);
$path = core_component::get_plugin_directory($type, $plugin);
$publishes = array();
$subscribes = array();
if (file_exists($path . '/db/mnet.php')) {
require_once $path . '/db/mnet.php';
// $publishes comes from this file
}
if (empty($publishes)) {
$publishes = array();
// still need this to be able to disable stuff later
}
if (empty($subscribes)) {
$subscribes = array();
// still need this to be able to disable stuff later
}
static $servicecache = array();
// rekey an array based on the rpc method for easy lookups later
$publishmethodservices = array();
$subscribemethodservices = array();
foreach ($publishes as $servicename => $service) {
if (is_array($service['methods'])) {
foreach ($service['methods'] as $methodname) {
$service['servicename'] = $servicename;
$publishmethodservices[$methodname][] = $service;
}
}
}
// Disable functions that don't exist (any more) in the source
// Should these be deleted? What about their permissions records?
foreach ($DB->get_records('mnet_rpc', array('pluginname' => $plugin, 'plugintype' => $type), 'functionname ASC ') as $rpc) {
if (!array_key_exists($rpc->functionname, $publishmethodservices) && $rpc->enabled) {
$DB->set_field('mnet_rpc', 'enabled', 0, array('id' => $rpc->id));
} else {
if (array_key_exists($rpc->functionname, $publishmethodservices) && !$rpc->enabled) {
$DB->set_field('mnet_rpc', 'enabled', 1, array('id' => $rpc->id));
}
}
}
// reflect all the services we're publishing and save them
require_once $CFG->dirroot . '/lib/zend/Zend/Server/Reflection.php';
static $cachedclasses = array();
// to store reflection information in
foreach ($publishes as $service => $data) {
$f = $data['filename'];
$c = $data['classname'];
foreach ($data['methods'] as $method) {
$dataobject = new stdClass();
$dataobject->plugintype = $type;
$dataobject->pluginname = $plugin;
$dataobject->enabled = 1;
$dataobject->classname = $c;
$dataobject->filename = $f;
if (is_string($method)) {
$dataobject->functionname = $method;
} else {
if (is_array($method)) {
// wants to override file or class
$dataobject->functionname = $method['method'];
$dataobject->classname = $method['classname'];
$dataobject->filename = $method['filename'];
}
}
$dataobject->xmlrpcpath = $type . '/' . $plugin . '/' . $dataobject->filename . '/' . $method;
$dataobject->static = false;
require_once $path . '/' . $dataobject->filename;
$functionreflect = null;
// slightly different ways to get this depending on whether it's a class method or a function
if (!empty($dataobject->classname)) {
if (!class_exists($dataobject->classname)) {
throw new moodle_exception('installnosuchmethod', 'mnet', '', (object) array('method' => $dataobject->functionname, 'class' => $dataobject->classname));
}
$key = $dataobject->filename . '|' . $dataobject->classname;
if (!array_key_exists($key, $cachedclasses)) {
// look to see if we've already got a reflection object
try {
$cachedclasses[$key] = Zend_Server_Reflection::reflectClass($dataobject->classname);
} catch (Zend_Server_Reflection_Exception $e) {
// catch these and rethrow them to something more helpful
throw new moodle_exception('installreflectionclasserror', 'mnet', '', (object) array('method' => $dataobject->functionname, 'class' => $dataobject->classname, 'error' => $e->getMessage()));
}
}
$r =& $cachedclasses[$key];
if (!$r->hasMethod($dataobject->functionname)) {
throw new moodle_exception('installnosuchmethod', 'mnet', '', (object) array('method' => $dataobject->functionname, 'class' => $dataobject->classname));
}
// stupid workaround for zend not having a getMethod($name) function
$ms = $r->getMethods();
foreach ($ms as $m) {
if ($m->getName() == $dataobject->functionname) {
$functionreflect = $m;
//.........这里部分代码省略.........
示例7: standard_renderer_classnames
/**
* For a given module name, return the possible class names
* that defines the renderer interface for that module.
*
* Newer auto-loaded class names are returned as well as the old style _renderable classnames.
*
* Also, if it exists, include the renderer.php file for that module, so
* the class definition of the default renderer has been loaded.
*
* @param string $component name such as 'core', 'mod_forum' or 'qtype_multichoice'.
* @param string $subtype optional subtype such as 'news' resulting to:
* '\mod_forum\output\news_renderer'
* or '\mod_forum\output\news\renderer'
* or non-autoloaded 'mod_forum_news'
* @return array[] Each element of the array is an array with keys:
* classname - The class name to search
* autoloaded - Does this classname assume autoloading?
* validwithprefix - Is this class name valid when a prefix is added to it?
* validwithoutprefix - Is this class name valid when no prefix is added to it?
* @throws coding_exception
*/
protected function standard_renderer_classnames($component, $subtype = null)
{
global $CFG;
// Needed in included files.
$classnames = array();
// Standardize component name ala frankenstyle.
list($plugin, $type) = core_component::normalize_component($component);
if ($type === null) {
$component = $plugin;
} else {
$component = $plugin . '_' . $type;
}
if ($component !== 'core') {
// Renderers are stored in renderer.php files.
if (!($compdirectory = core_component::get_component_directory($component))) {
throw new coding_exception('Invalid component specified in renderer request', $component);
}
$rendererfile = $compdirectory . '/renderer.php';
if (file_exists($rendererfile)) {
include_once $rendererfile;
}
} else {
if (!empty($subtype)) {
$coresubsystems = core_component::get_core_subsystems();
if (!array_key_exists($subtype, $coresubsystems)) {
// There may be nulls.
throw new coding_exception('Invalid core subtype "' . $subtype . '" in renderer request', $subtype);
}
if ($coresubsystems[$subtype]) {
$rendererfile = $coresubsystems[$subtype] . '/renderer.php';
if (file_exists($rendererfile)) {
include_once $rendererfile;
}
}
}
}
if (empty($subtype)) {
// Theme specific auto-loaded name (only valid when prefixed with the theme name).
$classnames[] = array('validwithprefix' => true, 'validwithoutprefix' => false, 'autoloaded' => true, 'classname' => '\\output\\' . $component . '_renderer');
// Standard autoloaded plugin name (not valid with a prefix).
$classnames[] = array('validwithprefix' => false, 'validwithoutprefix' => true, 'autoloaded' => true, 'classname' => '\\' . $component . '\\output\\renderer');
// Legacy class name - (valid with or without a prefix).
$classnames[] = array('validwithprefix' => true, 'validwithoutprefix' => true, 'autoloaded' => false, 'classname' => $component . '_renderer');
} else {
// Theme specific auto-loaded name (only valid when prefixed with the theme name).
$classnames[] = array('validwithprefix' => true, 'validwithoutprefix' => false, 'autoloaded' => true, 'classname' => '\\output\\' . $component . '\\' . $subtype . '_renderer');
// Version of the above with subtype being a namespace level on it's own.
$classnames[] = array('validwithprefix' => true, 'validwithoutprefix' => false, 'autoloaded' => true, 'classname' => '\\output\\' . $component . '\\' . $subtype . '\\renderer');
// Standard autoloaded plugin name (not valid with a prefix).
$classnames[] = array('validwithprefix' => false, 'validwithoutprefix' => true, 'autoloaded' => true, 'classname' => '\\' . $component . '\\output\\' . $subtype . '_renderer');
// Version of the above with subtype being a namespace level on it's own.
$classnames[] = array('validwithprefix' => false, 'validwithoutprefix' => true, 'autoloaded' => true, 'classname' => '\\' . $component . '\\output\\' . $subtype . '\\renderer');
// Legacy class name - (valid with or without a prefix).
$classnames[] = array('validwithprefix' => true, 'validwithoutprefix' => true, 'autoloaded' => false, 'classname' => $component . '_' . $subtype . '_renderer');
}
return $classnames;
}
示例8: get_module_from_component
protected static function get_module_from_component($component)
{
list($type, $name) = \core_component::normalize_component($component);
if ($type == 'mod') {
return $name;
}
if ($type == 'assignsubmission') {
return 'assign';
}
return null;
}
示例9: get_plugin_info
/**
* Returns information about the known plugin, or null
*
* @param string $component frankenstyle component name.
* @return \core\plugininfo\base|null the corresponding plugin information.
*/
public function get_plugin_info($component)
{
list($type, $name) = core_component::normalize_component($component);
$plugins = $this->get_plugins_of_type($type);
if (isset($plugins[$name])) {
return $plugins[$name];
} else {
return null;
}
}
示例10: message_get_providers_for_user
/**
* Returns the active providers for the user specified, based on capability
*
* @param int $userid id of user
* @return array An array of message providers
*/
function message_get_providers_for_user($userid) {
global $DB, $CFG;
$providers = get_message_providers();
// Ensure user is not allowed to configure instantmessage if it is globally disabled.
if (!$CFG->messaging) {
foreach ($providers as $providerid => $provider) {
if ($provider->name == 'instantmessage') {
unset($providers[$providerid]);
break;
}
}
}
// If the component is an enrolment plugin, check it is enabled
foreach ($providers as $providerid => $provider) {
list($type, $name) = core_component::normalize_component($provider->component);
if ($type == 'enrol' && !enrol_is_enabled($name)) {
unset($providers[$providerid]);
}
}
// Now we need to check capabilities. We need to eliminate the providers
// where the user does not have the corresponding capability anywhere.
// Here we deal with the common simple case of the user having the
// capability in the system context. That handles $CFG->defaultuserroleid.
// For the remaining providers/capabilities, we need to do a more complex
// query involving all overrides everywhere.
$unsureproviders = array();
$unsurecapabilities = array();
$systemcontext = context_system::instance();
foreach ($providers as $providerid => $provider) {
if (empty($provider->capability) || has_capability($provider->capability, $systemcontext, $userid)) {
// The provider is relevant to this user.
continue;
}
$unsureproviders[$providerid] = $provider;
$unsurecapabilities[$provider->capability] = 1;
unset($providers[$providerid]);
}
if (empty($unsureproviders)) {
// More complex checks are not required.
return $providers;
}
// Now check the unsure capabilities.
list($capcondition, $params) = $DB->get_in_or_equal(
array_keys($unsurecapabilities), SQL_PARAMS_NAMED);
$params['userid'] = $userid;
$sql = "SELECT DISTINCT rc.capability, 1
FROM {role_assignments} ra
JOIN {context} actx ON actx.id = ra.contextid
JOIN {role_capabilities} rc ON rc.roleid = ra.roleid
JOIN {context} cctx ON cctx.id = rc.contextid
WHERE ra.userid = :userid
AND rc.capability $capcondition
AND rc.permission > 0
AND (".$DB->sql_concat('actx.path', "'/'")." LIKE ".$DB->sql_concat('cctx.path', "'/%'").
" OR ".$DB->sql_concat('cctx.path', "'/'")." LIKE ".$DB->sql_concat('actx.path', "'/%'").")";
if (!empty($CFG->defaultfrontpageroleid)) {
$frontpagecontext = context_course::instance(SITEID);
list($capcondition2, $params2) = $DB->get_in_or_equal(
array_keys($unsurecapabilities), SQL_PARAMS_NAMED);
$params = array_merge($params, $params2);
$params['frontpageroleid'] = $CFG->defaultfrontpageroleid;
$params['frontpagepathpattern'] = $frontpagecontext->path . '/';
$sql .= "
UNION
SELECT DISTINCT rc.capability, 1
FROM {role_capabilities} rc
JOIN {context} cctx ON cctx.id = rc.contextid
WHERE rc.roleid = :frontpageroleid
AND rc.capability $capcondition2
AND rc.permission > 0
AND ".$DB->sql_concat('cctx.path', "'/'")." LIKE :frontpagepathpattern";
}
$relevantcapabilities = $DB->get_records_sql_menu($sql, $params);
// Add back any providers based on the detailed capability check.
foreach ($unsureproviders as $providerid => $provider) {
if (array_key_exists($provider->capability, $relevantcapabilities)) {
//.........这里部分代码省略.........
示例11: get_component_string
/**
* This gets the mod/block/course/core etc strings.
*
* @param string $component
* @param int $contextlevel
* @return string|bool String is success, false if failed
*/
function get_component_string($component, $contextlevel) {
if ($component === 'moodle' or $component === 'core') {
switch ($contextlevel) {
// TODO: this should probably use context level names instead
case CONTEXT_SYSTEM: return get_string('coresystem');
case CONTEXT_USER: return get_string('users');
case CONTEXT_COURSECAT: return get_string('categories');
case CONTEXT_COURSE: return get_string('course');
case CONTEXT_MODULE: return get_string('activities');
case CONTEXT_BLOCK: return get_string('block');
default: print_error('unknowncontext');
}
}
list($type, $name) = core_component::normalize_component($component);
$dir = core_component::get_plugin_directory($type, $name);
if (!file_exists($dir)) {
// plugin not installed, bad luck, there is no way to find the name
return $component.' ???';
}
switch ($type) {
// TODO: this is really hacky, anyway it should be probably moved to lib/pluginlib.php
case 'quiz': return get_string($name.':componentname', $component);// insane hack!!!
case 'repository': return get_string('repository', 'repository').': '.get_string('pluginname', $component);
case 'gradeimport': return get_string('gradeimport', 'grades').': '.get_string('pluginname', $component);
case 'gradeexport': return get_string('gradeexport', 'grades').': '.get_string('pluginname', $component);
case 'gradereport': return get_string('gradereport', 'grades').': '.get_string('pluginname', $component);
case 'webservice': return get_string('webservice', 'webservice').': '.get_string('pluginname', $component);
case 'block': return get_string('block').': '.get_string('pluginname', basename($component));
case 'mod':
if (get_string_manager()->string_exists('pluginname', $component)) {
return get_string('activity').': '.get_string('pluginname', $component);
} else {
return get_string('activity').': '.get_string('modulename', $component);
}
default: return get_string('pluginname', $component);
}
}
示例12: test_normalize_component
public function test_normalize_component()
{
// Moodle core.
$this->assertSame(array('core', null), core_component::normalize_component('core'));
$this->assertSame(array('core', null), core_component::normalize_component('moodle'));
$this->assertSame(array('core', null), core_component::normalize_component(''));
// Moodle core subsystems.
$this->assertSame(array('core', 'admin'), core_component::normalize_component('admin'));
$this->assertSame(array('core', 'admin'), core_component::normalize_component('core_admin'));
$this->assertSame(array('core', 'admin'), core_component::normalize_component('moodle_admin'));
// Activity modules and their subplugins.
$this->assertSame(array('mod', 'workshop'), core_component::normalize_component('workshop'));
$this->assertSame(array('mod', 'workshop'), core_component::normalize_component('mod_workshop'));
$this->assertSame(array('workshopform', 'accumulative'), core_component::normalize_component('workshopform_accumulative'));
$this->assertSame(array('mod', 'quiz'), core_component::normalize_component('quiz'));
$this->assertSame(array('quiz', 'grading'), core_component::normalize_component('quiz_grading'));
$this->assertSame(array('mod', 'data'), core_component::normalize_component('data'));
$this->assertSame(array('datafield', 'checkbox'), core_component::normalize_component('datafield_checkbox'));
// Other plugin types.
$this->assertSame(array('auth', 'mnet'), core_component::normalize_component('auth_mnet'));
$this->assertSame(array('enrol', 'self'), core_component::normalize_component('enrol_self'));
$this->assertSame(array('block', 'html'), core_component::normalize_component('block_html'));
$this->assertSame(array('block', 'mnet_hosts'), core_component::normalize_component('block_mnet_hosts'));
$this->assertSame(array('local', 'amos'), core_component::normalize_component('local_amos'));
$this->assertSame(array('local', 'admin'), core_component::normalize_component('local_admin'));
// Unknown words without underscore are supposed to be activity modules.
$this->assertSame(array('mod', 'whoonearthwouldcomewithsuchastupidnameofcomponent'), core_component::normalize_component('whoonearthwouldcomewithsuchastupidnameofcomponent'));
// Module names can not contain underscores, this must be a subplugin.
$this->assertSame(array('whoonearth', 'wouldcomewithsuchastupidnameofcomponent'), core_component::normalize_component('whoonearth_wouldcomewithsuchastupidnameofcomponent'));
$this->assertSame(array('whoonearth', 'would_come_withsuchastupidnameofcomponent'), core_component::normalize_component('whoonearth_would_come_withsuchastupidnameofcomponent'));
}
示例13: require_login
//for login and capability checks
try {
$autologinguest = true;
$setwantsurltome = true;
$preventredirect = true;
require_login($course, $autologinguest, $cm, $setwantsurltome, $preventredirect);
} catch (Exception $e) {
if (isguestuser()) {
rss_error('rsserrorguest');
} else {
rss_error('rsserrorauth');
}
}
// Work out which component in Moodle we want (from the frankenstyle name)
$componentdir = core_component::get_component_directory($componentname);
list($type, $plugin) = core_component::normalize_component($componentname);
// Call the component to check/update the feed and tell us the path to the cached file
$pathname = null;
if (file_exists($componentdir)) {
require_once "{$componentdir}/rsslib.php";
$functionname = $plugin . '_rss_get_feed';
if (function_exists($functionname)) {
// $pathname will be null if there was a problem (eg user doesn't have the necessary capabilities)
// NOTE:the component providing the feed must do its own capability checks and security
try {
$pathname = $functionname($context, $args);
} catch (Exception $e) {
rss_error('rsserror');
}
}
}
示例14: upgrade_log
/**
* Adds log entry into upgrade_log table
*
* @param int $type UPGRADE_LOG_NORMAL, UPGRADE_LOG_NOTICE or UPGRADE_LOG_ERROR
* @param string $plugin frankenstyle component name
* @param string $info short description text of log entry
* @param string $details long problem description
* @param string $backtrace string used for errors only
* @return void
*/
function upgrade_log($type, $plugin, $info, $details = null, $backtrace = null)
{
global $DB, $USER, $CFG;
if (empty($plugin)) {
$plugin = 'core';
}
list($plugintype, $pluginname) = core_component::normalize_component($plugin);
$component = is_null($pluginname) ? $plugintype : $plugintype . '_' . $pluginname;
$backtrace = format_backtrace($backtrace, true);
$currentversion = null;
$targetversion = null;
//first try to find out current version number
if ($plugintype === 'core') {
//main
$currentversion = $CFG->version;
$version = null;
include "{$CFG->dirroot}/version.php";
$targetversion = $version;
} else {
$pluginversion = get_config($component, 'version');
if (!empty($pluginversion)) {
$currentversion = $pluginversion;
}
$cd = core_component::get_component_directory($component);
if (file_exists("{$cd}/version.php")) {
$plugin = new stdClass();
$plugin->version = null;
$module = $plugin;
include "{$cd}/version.php";
$targetversion = $plugin->version;
}
}
$log = new stdClass();
$log->type = $type;
$log->plugin = $component;
$log->version = $currentversion;
$log->targetversion = $targetversion;
$log->info = $info;
$log->details = $details;
$log->backtrace = $backtrace;
$log->userid = $USER->id;
$log->timemodified = time();
try {
$DB->insert_record('upgrade_log', $log);
} catch (Exception $ignored) {
// possible during install or 2.0 upgrade
}
}
示例15: uninstall
/**
* Deletes all tag areas, collections and instances associated with the plugin.
*
* @param string $pluginname
*/
public static function uninstall($pluginname)
{
global $DB;
list($a, $b) = core_component::normalize_component($pluginname);
if (empty($b) || $a === 'core') {
throw new coding_exception('Core component can not be uninstalled');
}
$component = $a . '_' . $b;
core_tag_tag::delete_instances($component);
$DB->delete_records('tag_area', array('component' => $component));
$DB->delete_records('tag_coll', array('component' => $component));
cache::make('core', 'tags')->delete_many(array('tag_area', 'tag_coll'));
}