当前位置: 首页>>代码示例>>PHP>>正文


PHP core_component类代码示例

本文整理汇总了PHP中core_component的典型用法代码示例。如果您正苦于以下问题:PHP core_component类的具体用法?PHP core_component怎么用?PHP core_component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了core_component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build_tree

 /**
  * Parse all callbacks and builds the tree.
  *
  * @param integer   $user ID of the user for which the profile is displayed.
  * @param bool      $iscurrentuser true if the profile being viewed is of current user, else false.
  * @param \stdClass $course Course object
  *
  * @return tree Fully build tree to be rendered on my profile page.
  */
 public static function build_tree($user, $iscurrentuser, $course = null)
 {
     global $CFG;
     $tree = new tree();
     // Add core nodes.
     require_once $CFG->libdir . "/myprofilelib.php";
     core_myprofile_navigation($tree, $user, $iscurrentuser, $course);
     // Core components.
     $components = \core_component::get_core_subsystems();
     foreach ($components as $component => $directory) {
         if (empty($directory)) {
             continue;
         }
         $file = $directory . "/lib.php";
         if (is_readable($file)) {
             require_once $file;
             $function = "core_" . $component . "_myprofile_navigation";
             if (function_exists($function)) {
                 $function($tree, $user, $iscurrentuser, $course);
             }
         }
     }
     // Plugins.
     $types = \core_component::get_plugin_types();
     foreach ($types as $type => $dir) {
         $pluginlist = get_plugin_list_with_function($type, "myprofile_navigation", "lib.php");
         foreach ($pluginlist as $function) {
             $function($tree, $user, $iscurrentuser, $course);
         }
     }
     $tree->sort_categories();
     return $tree;
 }
开发者ID:educakanchay,项目名称:campus,代码行数:42,代码来源:manager.php

示例2: definition

 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     //$mform->addElement('html', get_string('unplagexplain', 'plagiarism_unplag'));
     $mform->addElement('checkbox', 'unplag_use', get_string('useunplag', 'plagiarism_unplag'));
     $mform->addElement('text', 'unplag_client_id', get_string('unplag_client_id', 'plagiarism_unplag'));
     $mform->addHelpButton('unplag_client_id', 'unplag_client_id', 'plagiarism_unplag');
     $mform->addRule('unplag_client_id', null, 'required', null, 'client');
     $mform->setType('unplag_client_id', PARAM_TEXT);
     $mform->addElement('text', 'unplag_api_secret', get_string('unplag_api_secret', 'plagiarism_unplag'));
     $mform->addHelpButton('unplag_api_secret', 'unplag_api_secret', 'plagiarism_unplag');
     $mform->addRule('unplag_api_secret', null, 'required', null, 'client');
     $mform->setType('unplag_api_secret', PARAM_TEXT);
     $mform->addElement('text', 'unplag_lang', get_string('unplag_lang', 'plagiarism_unplag'));
     $mform->addHelpButton('unplag_lang', 'unplag_lang', 'plagiarism_unplag');
     $mform->addRule('unplag_lang', null, 'required', null, 'client');
     $mform->setDefault('unplag_lang', 'en-US');
     $mform->setType('unplag_lang', PARAM_TEXT);
     $mform->addElement('textarea', 'unplag_student_disclosure', get_string('studentdisclosure', 'plagiarism_unplag'), 'wrap="virtual" rows="6" cols="50"');
     $mform->addHelpButton('unplag_student_disclosure', 'studentdisclosure', 'plagiarism_unplag');
     $mform->setDefault('unplag_student_disclosure', get_string('studentdisclosuredefault', 'plagiarism_unplag'));
     $mform->setType('unplag_student_disclosure', PARAM_TEXT);
     $mods = core_component::get_plugin_list('mod');
     foreach ($mods as $mod => $modname) {
         if (plugin_supports('mod', $mod, FEATURE_PLAGIARISM)) {
             $modstring = 'unplag_enable_mod_' . $mod;
             $mform->addElement('checkbox', $modstring, get_string('unplag_enableplugin', 'plagiarism_unplag', $mod));
         }
     }
     $this->add_action_buttons(true);
 }
开发者ID:POETGroup,项目名称:moodle-plagiarism_unplag,代码行数:32,代码来源:unplag_form.php

示例3: build_tree

 /**
  * Parse all callbacks and builds the tree.
  *
  * @param integer   $user ID of the user for which the profile is displayed.
  * @param bool      $iscurrentuser true if the profile being viewed is of current user, else false.
  * @param \stdClass $course Course object
  *
  * @return tree Fully build tree to be rendered on my profile page.
  */
 public static function build_tree($user, $iscurrentuser, $course = null)
 {
     global $CFG;
     $tree = new tree();
     //print_r($user);
     // Add core nodes.
     require_once $CFG->libdir . "/myprofilelib.php";
     core_myprofile_navigation($tree, $user, $iscurrentuser, $course);
     // Core components.
     $components = \core_component::get_core_subsystems();
     foreach ($components as $component => $directory) {
         if (empty($directory)) {
             continue;
         }
         $file = $directory . "/lib.php";
         if (is_readable($file)) {
             require_once $file;
             $function = "core_" . $component . "_myprofile_navigation";
             //print_r($function);
             if (function_exists($function)) {
                 //echo "Current function: ".$function."<br>";
                 $function($tree, $user, $iscurrentuser, $course);
             }
         }
     }
     // Plugins.
     $pluginswithfunction = get_plugins_with_function('myprofile_navigation', 'lib.php');
     foreach ($pluginswithfunction as $plugins) {
         foreach ($plugins as $function) {
             $function($tree, $user, $iscurrentuser, $course);
         }
     }
     $tree->sort_categories();
     return $tree;
 }
开发者ID:sirromas,项目名称:medical,代码行数:44,代码来源:manager.php

示例4: enrol_get_plugins

/**
 * Returns instances of enrol plugins
 * @param bool $enabled return enabled only
 * @return array of enrol plugins name=>instance
 */
function enrol_get_plugins($enabled)
{
    global $CFG;
    $result = array();
    if ($enabled) {
        // sorted by enabled plugin order
        $enabled = explode(',', $CFG->enrol_plugins_enabled);
        $plugins = array();
        foreach ($enabled as $plugin) {
            $plugins[$plugin] = "{$CFG->dirroot}/enrol/{$plugin}";
        }
    } else {
        // sorted alphabetically
        $plugins = core_component::get_plugin_list('enrol');
        ksort($plugins);
    }
    foreach ($plugins as $plugin => $location) {
        if (!file_exists("{$location}/lib.php")) {
            continue;
        }
        include_once "{$location}/lib.php";
        $class = "enrol_{$plugin}_plugin";
        if (!class_exists($class)) {
            continue;
        }
        $result[$plugin] = new $class();
    }
    return $result;
}
开发者ID:helenagarcia90,项目名称:moodle,代码行数:34,代码来源:enrollib.php

示例5: scorm_report_list

function scorm_report_list($context)
{
    global $CFG;
    static $reportlist;
    if (!empty($reportlist)) {
        return $reportlist;
    }
    $installed = core_component::get_plugin_list('scormreport');
    foreach ($installed as $reportname => $notused) {
        // Moodle 2.8+ style of autoloaded classes.
        $classname = "scormreport_{$reportname}\\report";
        if (class_exists($classname)) {
            $report = new $classname();
            if ($report->canview($context)) {
                $reportlist[] = $reportname;
            }
            continue;
        }
        // Legacy style of naming classes.
        $pluginfile = $CFG->dirroot . '/mod/scorm/report/' . $reportname . '/report.php';
        if (is_readable($pluginfile)) {
            debugging("Please use autoloaded classnames for your plugin. Refer MDL-46469 for details", DEBUG_DEVELOPER);
            include_once $pluginfile;
            $reportclassname = "scorm_{$reportname}_report";
            if (class_exists($reportclassname)) {
                $report = new $reportclassname();
                if ($report->canview($context)) {
                    $reportlist[] = $reportname;
                }
            }
        }
    }
    return $reportlist;
}
开发者ID:evltuma,项目名称:moodle,代码行数:34,代码来源:reportlib.php

示例6: test_get_course_formats

 public function test_get_course_formats()
 {
     $result = tool_uploadcourse_helper::get_course_formats();
     $this->assertSame(array_keys(core_component::get_plugin_list('format')), $result);
     // Should be similar as first result, as cached.
     $this->assertSame($result, tool_uploadcourse_helper::get_course_formats());
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:7,代码来源:helper_test.php

示例7: load_default_scheduled_tasks_for_component

 /**
  * Given a component name, will load the list of tasks in the db/tasks.php file for that component.
  *
  * @param string $componentname - The name of the component to fetch the tasks for.
  * @return \core\task\scheduled_task[] - List of scheduled tasks for this component.
  */
 public static function load_default_scheduled_tasks_for_component($componentname)
 {
     $dir = \core_component::get_component_directory($componentname);
     if (!$dir) {
         return array();
     }
     $file = $dir . '/' . CORE_TASK_TASKS_FILENAME;
     if (!file_exists($file)) {
         return array();
     }
     $tasks = null;
     include $file;
     if (!isset($tasks)) {
         return array();
     }
     $scheduledtasks = array();
     foreach ($tasks as $task) {
         $record = (object) $task;
         $scheduledtask = self::scheduled_task_from_record($record);
         // Safety check in case the task in the DB does not match a real class (maybe something was uninstalled).
         if ($scheduledtask) {
             $scheduledtask->set_component($componentname);
             $scheduledtasks[] = $scheduledtask;
         }
     }
     return $scheduledtasks;
 }
开发者ID:educakanchay,项目名称:campus,代码行数:33,代码来源:manager.php

示例8: get_install_path

 /**
  * Get the relative path for a plugin given it's type
  * 
  * @param string $type
  *   The plugin type (example: 'auth', 'block')
  * @param string $moodleversion
  *   The version of moodle we are running (example: '1.9', '2.9')
  * @return string
  *   The installation path relative to dirroot (example: 'auth', 'blocks', 
  *   'course/format')
  */
 private function get_install_path($type, $moodleversion)
 {
     global $CFG;
     // Convert moodle version to a float for more acurate comparison
     if (!is_float($moodleversion)) {
         $moodleversion = floatval($moodleversion);
     }
     if ($moodleversion >= 2.6) {
         $types = \core_component::get_plugin_types();
     } else {
         if ($moodleversion >= 2.0) {
             $types = get_plugin_types();
         } else {
             // Moodle 1.9 does not give us a way to determine plugin
             // installation paths.
             $types = array();
         }
     }
     if (empty($types) || !array_key_exists($type, $types)) {
         // Either the moodle version is lower than 2.0, in which case we
         // don't have a reliable way of determining the install path, or the
         // plugin is of an unknown type.
         //
         // Let's fall back to make our best guess.
         return $CFG->dirroot . '/' . $type;
     }
     return $types[$type];
 }
开发者ID:janeklb,项目名称:moosh,代码行数:39,代码来源:PluginInstall.php

示例9: test_duplicate

 /**
  * Tests the backup and restore of single activity to same course (duplicate)
  * when it contains fields and views.
  */
 public function test_duplicate()
 {
     global $DB, $CFG;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $generator = $this->getDataGenerator();
     $dataformgenerator = $generator->get_plugin_generator('mod_dataform');
     // Create a course.
     $course = $generator->create_course();
     // DATAFORM 1.
     $params = array('course' => $course->id, 'grade' => 100);
     $dataform1 = $dataformgenerator->create_instance($params);
     $df1 = mod_dataform_dataform::instance($dataform1->id);
     // Add fields.
     $fieldtypes = array_keys(core_component::get_plugin_list('dataformfield'));
     $fieldtypescount = count($fieldtypes);
     foreach ($fieldtypes as $type) {
         $df1->field_manager->add_field($type);
     }
     // Add views.
     $viewtypes = array_keys(core_component::get_plugin_list('dataformview'));
     $viewtypescount = count($viewtypes);
     foreach ($viewtypes as $type) {
         $df1->view_manager->add_view($type);
     }
     // Fetch the grade item.
     $params = array('itemtype' => 'mod', 'itemmodule' => 'dataform', 'iteminstance' => $dataform1->id, 'courseid' => $course->id, 'itemnumber' => 0);
     $gradeitem1 = grade_item::fetch($params);
     // Check number of dataforms.
     $this->assertEquals(1, $DB->count_records('dataform'));
     // Check number of fields.
     $this->assertEquals($fieldtypescount, $DB->count_records('dataform_fields'));
     $this->assertEquals($fieldtypescount, $DB->count_records('dataform_fields', array('dataid' => $dataform1->id)));
     // Check number of views.
     $this->assertEquals($viewtypescount, $DB->count_records('dataform_views'));
     $this->assertEquals($viewtypescount, $DB->count_records('dataform_views', array('dataid' => $dataform1->id)));
     // Check number of filters.
     // $this->assertEquals(2, $DB->count_records('dataform_filters'));
     // $this->assertEquals(2, $DB->count_records('dataform_filters', array('dataid' => $dataform1->id)));.
     // DUPLICATE the dataform instance.
     $dataform2 = $dataformgenerator->duplicate_instance($course, $dataform1->cmid);
     // Check number of dataforms.
     $this->assertEquals(2, $DB->count_records('dataform'));
     // Check duplication of fields.
     $this->assertEquals($fieldtypescount * 2, $DB->count_records('dataform_fields'));
     $this->assertEquals($fieldtypescount, $DB->count_records('dataform_fields', array('dataid' => $dataform1->id)));
     $this->assertEquals($fieldtypescount, $DB->count_records('dataform_fields', array('dataid' => $dataform2->id)));
     // Check duplication of views.
     $this->assertEquals($viewtypescount * 2, $DB->count_records('dataform_views'));
     $this->assertEquals($viewtypescount, $DB->count_records('dataform_views', array('dataid' => $dataform1->id)));
     $this->assertEquals($viewtypescount, $DB->count_records('dataform_views', array('dataid' => $dataform2->id)));
     // Check number of filters.
     // $this->assertEquals(4, $DB->count_records('dataform_filters');
     // $this->assertEquals(2, $DB->count_records('dataform_filters', array('dataid' => $dataform1->id));
     // $this->assertEquals(2, $DB->count_records('dataform_filters', array('dataid' => $dataform2->id));.
     // Dataform cleanup.
     $dataformgenerator->delete_all_instances();
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:62,代码来源:backup_restore_test.php

示例10: test_get_submission_plugins

 public function test_get_submission_plugins()
 {
     $this->setUser($this->editingteachers[0]);
     $assign = $this->create_instance();
     $installedplugins = array_keys(core_component::get_plugin_list('assignsubmission'));
     foreach ($assign->get_submission_plugins() as $plugin) {
         $this->assertContains($plugin->get_type(), $installedplugins, 'Submission plugin not in list of installed plugins');
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:9,代码来源:locallib_test.php

示例11: test_field_events

 /**
  * Test field events for standard types.
  */
 public function test_field_events()
 {
     $this->setAdminUser();
     $df = $this->get_a_dataform();
     $fieldtypes = array_keys(core_component::get_plugin_list('dataformfield'));
     foreach ($fieldtypes as $type) {
         $this->try_crud_field($type, $df);
     }
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:12,代码来源:events_test.php

示例12: is_last

 /**
  * Is this the last plugin in the list?
  *
  * @return bool
  */
 public final function is_last()
 {
     $lastindex = count(core_component::get_plugin_list($this->get_subtype())) - 1;
     $currentindex = get_config($this->get_subtype() . '_' . $this->get_type(), 'sortorder');
     if ($lastindex == $currentindex) {
         return true;
     }
     return false;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:14,代码来源:assignmentplugin.php

示例13: get_list_of_calendar_types

 /**
  * Returns a list of calendar typess available for use.
  *
  * @return array the list of calendar types
  */
 public static function get_list_of_calendar_types()
 {
     $calendars = array();
     $calendardirs = \core_component::get_plugin_list('calendartype');
     foreach ($calendardirs as $name => $location) {
         $calendars[$name] = get_string('name', "calendartype_{$name}");
     }
     return $calendars;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:14,代码来源:type_factory.php

示例14: external_function_info

/**
 * Returns detailed function information
 *
 * @param string|object $function name of external function or record from external_function
 * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
 *                        MUST_EXIST means throw exception if no record or multiple records found
 * @return stdClass description or false if not found or exception thrown
 * @since Moodle 2.0
 */
function external_function_info($function, $strictness = MUST_EXIST)
{
    global $DB, $CFG;
    if (!is_object($function)) {
        if (!($function = $DB->get_record('external_functions', array('name' => $function), '*', $strictness))) {
            return false;
        }
    }
    //first find and include the ext implementation class
    $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');
    }
    require_once $function->classpath;
    $function->parameters_method = $function->methodname . '_parameters';
    $function->returns_method = $function->methodname . '_returns';
    // make sure the implementaion class is ok
    if (!method_exists($function->classname, $function->methodname)) {
        throw new coding_exception('Missing implementation method of ' . $function->classname . '::' . $function->methodname);
    }
    if (!method_exists($function->classname, $function->parameters_method)) {
        throw new coding_exception('Missing parameters description');
    }
    if (!method_exists($function->classname, $function->returns_method)) {
        throw new coding_exception('Missing returned values description');
    }
    // fetch the parameters description
    $function->parameters_desc = call_user_func(array($function->classname, $function->parameters_method));
    if (!$function->parameters_desc instanceof external_function_parameters) {
        throw new coding_exception('Invalid parameters description');
    }
    // fetch the return values description
    $function->returns_desc = call_user_func(array($function->classname, $function->returns_method));
    // null means void result or result is ignored
    if (!is_null($function->returns_desc) and !$function->returns_desc instanceof external_description) {
        throw new coding_exception('Invalid return description');
    }
    //now get the function description
    //TODO MDL-31115 use localised lang pack descriptions, it would be nice to have
    //      easy to understand descriptions in admin UI,
    //      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 = core_component::get_component_directory($function->component) . '/db/services.php';
    if (file_exists($servicesfile)) {
        $functions = null;
        include $servicesfile;
        if (isset($functions[$function->name]['description'])) {
            $function->description = $functions[$function->name]['description'];
        }
        if (isset($functions[$function->name]['testclientpath'])) {
            $function->testclientpath = $functions[$function->name]['testclientpath'];
        }
    }
    return $function;
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:65,代码来源:externallib.php

示例15: __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();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:18,代码来源:lib.php


注:本文中的core_component类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。