本文整理汇总了PHP中get_module_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP get_module_metadata函数的具体用法?PHP get_module_metadata怎么用?PHP get_module_metadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_module_metadata函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: stdClass
if (!($sections = $modinfo->get_section_info_all())) {
// No sections found
$section = new stdClass();
$section->course = $course->id;
// Create a default section.
$section->section = 0;
$section->visible = 1;
$section->summaryformat = FORMAT_HTML;
$section->id = $DB->insert_record('course_sections', $section);
rebuild_course_cache($course->id);
$modinfo = get_fast_modinfo($COURSE);
if (!($sections = $modinfo->get_section_info_all())) {
// Try again
print_error('cannotcreateorfindstructs', 'error');
}
}
// CAUTION, hacky fundamental variable defintion to follow!
// Note that because of the way course fromats are constructed though
// inclusion we pass parameters around this way..
$displaysection = $section;
// Include the actual course format.
require $CFG->dirroot . '/course/format/' . $course->format . '/format.php';
// Content wrapper end.
echo html_writer::end_tag('div');
// Include course AJAX
if (include_course_ajax($course, $modnamesused)) {
// Add the module chooser
$renderer = $PAGE->get_renderer('core', 'course');
echo $renderer->course_modchooser(get_module_metadata($course, $modnames), $course);
}
echo $OUTPUT->footer();
开发者ID:nicusX,项目名称:moodle,代码行数:31,代码来源:view.php
示例2: print_section_add_menus
/**
* Prints the menus to add activities and resources.
*/
function print_section_add_menus($course, $section, $modnames, $vertical = false, $return = false)
{
global $CFG, $OUTPUT;
// check to see if user can add menus
if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
return false;
}
// Retrieve all modules with associated metadata
$modules = get_module_metadata($course, $modnames);
// We'll sort resources and activities into two lists
$resources = array();
$activities = array();
// We need to add the section section to the link for each module
$sectionlink = '§ion=' . $section;
foreach ($modules as $module) {
if (isset($module->types)) {
// This module has a subtype
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
$subtypes = array();
foreach ($module->types as $subtype) {
$subtypes[$subtype->link . $sectionlink] = $subtype->title;
}
// Sort module subtypes into the list
if (!empty($module->title)) {
// This grouping has a name
if ($module->archetype == MOD_CLASS_RESOURCE) {
$resources[] = array($module->title => $subtypes);
} else {
$activities[] = array($module->title => $subtypes);
}
} else {
// This grouping does not have a name
if ($module->archetype == MOD_CLASS_RESOURCE) {
$resources = array_merge($resources, $subtypes);
} else {
$activities = array_merge($activities, $subtypes);
}
}
} else {
// This module has no subtypes
if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
$resources[$module->link . $sectionlink] = $module->title;
} else {
if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
// System modules cannot be added by user, do not add to dropdown
} else {
$activities[$module->link . $sectionlink] = $module->title;
}
}
}
}
$straddactivity = get_string('addactivity');
$straddresource = get_string('addresource');
$output = '<div class="section_add_menus">';
if (!$vertical) {
$output .= '<div class="horizontal">';
}
if (!empty($resources)) {
$select = new url_select($resources, '', array('' => $straddresource), "ressection{$section}");
$select->set_help_icon('resources');
$output .= $OUTPUT->render($select);
}
if (!empty($activities)) {
$select = new url_select($activities, '', array('' => $straddactivity), "section{$section}");
$select->set_help_icon('activities');
$output .= $OUTPUT->render($select);
}
if (!$vertical) {
$output .= '</div>';
}
$output .= '</div>';
if ($return) {
return $output;
} else {
echo $output;
}
}
开发者ID:numbas,项目名称:moodle,代码行数:80,代码来源:lib.php
示例3: print_section
" class=\"iconsmall\" alt=\"$streditsummary\" /></a><br /><br />";
}
print_section($SITE, $section, $mods, $modnamesused, true);
if ($editing) {
print_section_add_menus($SITE, $section->section, $modnames);
}
echo $OUTPUT->box_end();
}
}
// Include course AJAX
if (include_course_ajax($SITE, $modnamesused)) {
// Add the module chooser
$renderer = $PAGE->get_renderer('core', 'course');
echo $renderer->course_modchooser(get_module_metadata($SITE, $modnames), $SITE);
}
if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) {
$frontpagelayout = $CFG->frontpageloggedin;
} else {
$frontpagelayout = $CFG->frontpage;
}
foreach (explode(',',$frontpagelayout) as $v) {
switch ($v) { /// Display the main part of the front page.
case FRONTPAGENEWS:
if ($SITE->newsitems) { // Print forums only when needed
require_once($CFG->dirroot .'/mod/forum/lib.php');
if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) {
开发者ID:ncsu-delta,项目名称:moodle,代码行数:31,代码来源:index.php
示例4: course_section_add_cm_control
/**
* Renders HTML for the menus to add activities and resources to the current course
*
* Note, if theme overwrites this function and it does not use modchooser,
* see also {@link core_course_renderer::add_modchoosertoggle()}
*
* @param stdClass $course
* @param int $section relative section number (field course_sections.section)
* @param int $sectionreturn The section to link back to
* @param array $displayoptions additional display options, for example blocks add
* option 'inblock' => true, suggesting to display controls vertically
* @return string
*/
function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = array())
{
global $CFG;
$vertical = !empty($displayoptions['inblock']);
// check to see if user can add menus and there are modules to add
if (!has_capability('moodle/course:manageactivities', context_course::instance($course->id)) || !$this->page->user_is_editing() || !($modnames = get_module_types_names()) || empty($modnames)) {
return '';
}
// Retrieve all modules with associated metadata
$modules = get_module_metadata($course, $modnames, $sectionreturn);
$urlparams = array('section' => $section);
// We'll sort resources and activities into two lists
$activities = array(MOD_CLASS_ACTIVITY => array(), MOD_CLASS_RESOURCE => array());
foreach ($modules as $module) {
if (isset($module->types)) {
// This module has a subtype
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
$subtypes = array();
foreach ($module->types as $subtype) {
$link = $subtype->link->out(true, $urlparams);
$subtypes[$link] = $subtype->title;
}
// Sort module subtypes into the list
$activityclass = MOD_CLASS_ACTIVITY;
if ($module->archetype == MOD_CLASS_RESOURCE) {
$activityclass = MOD_CLASS_RESOURCE;
}
if (!empty($module->title)) {
// This grouping has a name
$activities[$activityclass][] = array($module->title => $subtypes);
} else {
// This grouping does not have a name
$activities[$activityclass] = array_merge($activities[$activityclass], $subtypes);
}
} else {
// This module has no subtypes
$activityclass = MOD_CLASS_ACTIVITY;
if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
$activityclass = MOD_CLASS_RESOURCE;
} else {
if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
// System modules cannot be added by user, do not add to dropdown
continue;
}
}
$link = $module->link->out(true, $urlparams);
$activities[$activityclass][$link] = $module->title;
}
}
$straddactivity = get_string('addactivity');
$straddresource = get_string('addresource');
$sectionname = get_section_name($course, $section);
$strresourcelabel = get_string('addresourcetosection', null, $sectionname);
$stractivitylabel = get_string('addactivitytosection', null, $sectionname);
$output = html_writer::start_tag('div', array('class' => 'section_add_menus', 'id' => 'add_menus-section-' . $section));
if (!$vertical) {
$output .= html_writer::start_tag('div', array('class' => 'horizontal'));
}
if (!empty($activities[MOD_CLASS_RESOURCE])) {
$select = new url_select($activities[MOD_CLASS_RESOURCE], '', array('' => $straddresource), "ressection{$section}");
$select->set_help_icon('resources');
$select->set_label($strresourcelabel, array('class' => 'accesshide'));
$output .= $this->output->render($select);
}
if (!empty($activities[MOD_CLASS_ACTIVITY])) {
$select = new url_select($activities[MOD_CLASS_ACTIVITY], '', array('' => $straddactivity), "section{$section}");
$select->set_help_icon('activities');
$select->set_label($stractivitylabel, array('class' => 'accesshide'));
$output .= $this->output->render($select);
}
if (!$vertical) {
$output .= html_writer::end_tag('div');
}
$output .= html_writer::end_tag('div');
if (course_ajax_enabled($course) && $course->id == $this->page->course->id) {
// modchooser can be added only for the current course set on the page!
$straddeither = get_string('addresourceoractivity');
// The module chooser link
$modchooser = html_writer::start_tag('div', array('class' => 'mdl-right'));
$modchooser .= html_writer::start_tag('div', array('class' => 'section-modchooser'));
$icon = $this->output->pix_icon('t/add', '');
$span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));
$modchooser .= html_writer::tag('span', $icon . $span, array('class' => 'section-modchooser-link'));
$modchooser .= html_writer::end_tag('div');
$modchooser .= html_writer::end_tag('div');
// Wrap the normal output in a noscript div
$usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault);
//.........这里部分代码省略.........
开发者ID:rushi963,项目名称:moodle,代码行数:101,代码来源:renderer.php
示例5: rebuild_course_cache
$section->section = 0;
$section->visible = 1;
$section->summaryformat = FORMAT_HTML;
$section->id = $DB->insert_record('course_sections', $section);
rebuild_course_cache($course->id);
$modinfo = get_fast_modinfo($COURSE);
if (!$sections = $modinfo->get_section_info_all()) { // Try again
print_error('cannotcreateorfindstructs', 'error');
}
}
// CAUTION, hacky fundamental variable defintion to follow!
// Note that because of the way course fromats are constructed though
// inclusion we pass parameters around this way..
$displaysection = $section;
// Include the actual course format.
require($CFG->dirroot .'/course/format/'. $course->format .'/format.php');
// Content wrapper end.
echo html_writer::end_tag('div');
// Include course AJAX
if (include_course_ajax($course, $modnamesused)) {
// Add the module chooser
$renderer = $PAGE->get_renderer('core', 'course');
echo $renderer->course_modchooser(get_module_metadata($course, $modnames, $displaysection), $course);
}
echo $OUTPUT->footer();
开发者ID:ncsu-delta,项目名称:moodle,代码行数:30,代码来源:view.php
示例6: print_section_add_menus
/**
* Prints the menus to add activities and resources.
*/
function print_section_add_menus($course, $section, $modnames, $vertical = false, $return = false)
{
global $CFG, $OUTPUT;
// check to see if user can add menus
if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
return false;
}
// Retrieve all modules with associated metadata
$modules = get_module_metadata($course, $modnames);
// We'll sort resources and activities into two lists
$resources = array();
$activities = array();
// We need to add the section section to the link for each module
$sectionlink = '§ion=' . $section;
foreach ($modules as $module) {
if (isset($module->types)) {
// This module has a subtype
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
$subtypes = array();
foreach ($module->types as $subtype) {
$subtypes[$subtype->link . $sectionlink] = $subtype->title;
}
// Sort module subtypes into the list
if (!empty($module->title)) {
// This grouping has a name
if ($module->archetype == MOD_CLASS_RESOURCE) {
$resources[] = array($module->title => $subtypes);
} else {
$activities[] = array($module->title => $subtypes);
}
} else {
// This grouping does not have a name
if ($module->archetype == MOD_CLASS_RESOURCE) {
$resources = array_merge($resources, $subtypes);
} else {
$activities = array_merge($activities, $subtypes);
}
}
} else {
// This module has no subtypes
if ($module->archetype == MOD_ARCHETYPE_RESOURCE) {
$resources[$module->link . $sectionlink] = $module->title;
} else {
if ($module->archetype === MOD_ARCHETYPE_SYSTEM) {
// System modules cannot be added by user, do not add to dropdown
} else {
$activities[$module->link . $sectionlink] = $module->title;
}
}
}
}
$straddactivity = get_string('addactivity');
$straddresource = get_string('addresource');
$output = html_writer::start_tag('div', array('class' => 'section_add_menus', 'id' => 'add_menus-section-' . $section));
if (!$vertical) {
$output .= html_writer::start_tag('div', array('class' => 'horizontal'));
}
if (!empty($resources)) {
$select = new url_select($resources, '', array('' => $straddresource), "ressection{$section}");
$select->set_help_icon('resources');
$output .= $OUTPUT->render($select);
}
if (!empty($activities)) {
$select = new url_select($activities, '', array('' => $straddactivity), "section{$section}");
$select->set_help_icon('activities');
$output .= $OUTPUT->render($select);
}
if (!$vertical) {
$output .= html_writer::end_tag('div');
}
$output .= html_writer::end_tag('div');
if (course_ajax_enabled($course)) {
$straddeither = get_string('addresourceoractivity');
// The module chooser link
$modchooser = html_writer::start_tag('div', array('class' => 'mdl-right'));
$modchooser .= html_writer::start_tag('div', array('class' => 'section-modchooser'));
$icon = $OUTPUT->pix_icon('t/add', $straddeither);
$span = html_writer::tag('span', $straddeither, array('class' => 'section-modchooser-text'));
$modchooser .= html_writer::link('#', $icon . $span, array('class' => 'section-modchooser-link'));
$modchooser .= html_writer::end_tag('div');
$modchooser .= html_writer::end_tag('div');
// Wrap the normal output in a noscript div
$usemodchooser = get_user_preferences('usemodchooser', 1);
if ($usemodchooser) {
$output = html_writer::tag('div', $output, array('class' => 'hiddenifjs addresourcedropdown'));
$modchooser = html_writer::tag('div', $modchooser, array('class' => 'visibleifjs addresourcemodchooser'));
} else {
$output = html_writer::tag('div', $output, array('class' => 'visibleifjs addresourcedropdown'));
$modchooser = html_writer::tag('div', $modchooser, array('class' => 'hiddenifjs addresourcemodchooser'));
}
$output = $modchooser . $output;
}
if ($return) {
return $output;
} else {
echo $output;
}
//.........这里部分代码省略.........
开发者ID:nmicha,项目名称:moodle,代码行数:101,代码来源:lib.php
示例7: course_section_add_cm_control
/**
* Renders HTML for the menus to add activities and resources to the current course
*
* Note, if theme overwrites this function and it does not use modchooser,
* see also {@link core_course_renderer::add_modchoosertoggle()}
*
* @param stdClass $course
* @param int $section relative section number (field course_sections.section)
* @param int $sectionreturn The section to link back to
* @param array $displayoptions additional display options, for example blocks add
* option 'inblock' => true, suggesting to display controls vertically
* @return string
*/
public function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = array())
{
// Check to see if user can add menus and there are modules to add.
if (!has_capability('moodle/course:manageactivities', context_course::instance($course->id)) || !($modnames = get_module_types_names()) || empty($modnames)) {
return '';
}
// Retrieve all modules with associated metadata.
$modules = get_module_metadata($course, $modnames, $sectionreturn);
$urlparams = array('section' => $section);
// S Lamour Aug 2015 - show activity picker
// moodle is adding a link around the span in a span with js - yay!! go moodle...
$modchooser = "<div class='snap-modchooser btn btn-default section_add_menus'>\n <span class='section-modchooser-link'><span>" . get_string('addresourceoractivity', 'theme_snap') . "</span></span>\n </div>";
$output = $this->courserenderer->course_modchooser($modules, $course) . $modchooser;
// Add zone for quick uploading of files.
$upload = '<form class="snap-dropzone">
<label for="snap-drop-file-' . $section . '" class="snap-dropzone-label h6">' . get_string('dropzonelabel', 'theme_snap') . '</label>
<input type="file" multiple name="snap-drop-file-' . $section . '" id="snap-drop-file-' . $section . '" class="js-snap-drop-file sr-only"/>
</form>';
return $output . $upload;
}
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:33,代码来源:format_section_trait.php
示例8: activity_has_subtypes
/**
* Checks if the activity type has multiple items in the activity chooser.
* This may happen as a result of defining callback modulename_get_shortcuts()
* or [deprecated] modulename_get_types() - TODO MDL-53697 remove this line.
*
* @return bool|null (null if the check is not possible)
*/
public function activity_has_subtypes()
{
if (!($modname = $this->get_activitytype())) {
return null;
}
$metadata = get_module_metadata($this->get_course(), self::get_supported_activities());
foreach ($metadata as $key => $moduledata) {
if (preg_match('/^' . $modname . ':/', $key)) {
return true;
}
}
return false;
}
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:lib.php
注:本文中的get_module_metadata函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论