本文整理汇总了PHP中cm_info::get_content方法的典型用法代码示例。如果您正苦于以下问题:PHP cm_info::get_content方法的具体用法?PHP cm_info::get_content怎么用?PHP cm_info::get_content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cm_info
的用法示例。
在下文中一共展示了cm_info::get_content方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_print_section_cm_text
/**
* Obtains shared data that is used in print_section when displaying a
* course-module entry.
*
* Calls format_text or format_string as appropriate, and obtains the correct icon.
*
* This data is also used in other areas of the code.
* @param cm_info $cm Course-module data (must come from get_fast_modinfo)
* @param object $course Moodle course object
* @return array An array with the following values in this order:
* $content (optional extra content for after link),
* $instancename (text of link)
*/
function get_print_section_cm_text(cm_info $cm, $course)
{
global $OUTPUT;
// Get course context
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
// Get content from modinfo if specified. Content displays either
// in addition to the standard link (below), or replaces it if
// the link is turned off by setting ->url to null.
if (($content = $cm->get_content()) !== '') {
$labelformatoptions = new stdClass();
$labelformatoptions->noclean = true;
$labelformatoptions->overflowdiv = true;
$labelformatoptions->context = $coursecontext;
$content = format_text($content, FORMAT_HTML, $labelformatoptions);
} else {
$content = '';
}
$stringoptions = new stdClass();
$stringoptions->context = $coursecontext;
$instancename = format_string($cm->name, true, $stringoptions);
return array($content, $instancename);
}
示例2: get_print_section_cm_text
/**
* Obtains shared data that is used in print_section when displaying a
* course-module entry.
*
* Calls format_text or format_string as appropriate, and obtains the correct icon.
*
* This data is also used in other areas of the code.
* @param cm_info $cm Course-module data (must come from get_fast_modinfo)
* @param object $course Moodle course object
* @return array An array with the following values in this order:
* $content (optional extra content for after link),
* $instancename (text of link)
*/
function get_print_section_cm_text(cm_info $cm, $course)
{
global $OUTPUT;
// Get content from modinfo if specified. Content displays either
// in addition to the standard link (below), or replaces it if
// the link is turned off by setting ->url to null.
if (($content = $cm->get_content()) !== '') {
// Improve filter performance by preloading filter setttings for all
// activities on the course (this does nothing if called multiple
// times)
filter_preload_activities($cm->get_modinfo());
// Get module context
$modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$labelformatoptions = new stdClass();
$labelformatoptions->noclean = true;
$labelformatoptions->overflowdiv = true;
$labelformatoptions->context = $modulecontext;
$content = format_text($content, FORMAT_HTML, $labelformatoptions);
} else {
$content = '';
}
// Get course context
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$stringoptions = new stdClass();
$stringoptions->context = $coursecontext;
$instancename = format_string($cm->name, true, $stringoptions);
return array($content, $instancename);
}
示例3: send_response
/**
* Send the details of the newly created activity back to the client browser
*
* @param cm_info $mod details of the mod just created
*/
protected function send_response($mod)
{
global $OUTPUT, $PAGE;
$courserenderer = $PAGE->get_renderer('core', 'course');
$resp = new stdClass();
$resp->error = self::ERROR_OK;
$resp->icon = $mod->get_icon_url()->out();
$resp->name = $mod->name;
if ($mod->has_view()) {
$resp->link = $mod->get_url()->out();
} else {
$resp->link = null;
}
$resp->content = $mod->get_content();
$resp->elementid = 'module-' . $mod->id;
$actions = course_get_cm_edit_actions($mod, 0, $mod->sectionnum);
$resp->commands = ' ' . $courserenderer->course_section_cm_edit_actions($actions);
$resp->onclick = $mod->get_on_click();
$resp->visible = $mod->visible;
// if using groupings, then display grouping name
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', $this->context)) {
$groupings = groups_get_all_groupings($this->course->id);
$resp->groupingname = format_string($groupings[$mod->groupingid]->name);
}
echo $OUTPUT->header();
echo json_encode($resp);
die;
}