本文整理汇总了PHP中filter_preload_activities函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_preload_activities函数的具体用法?PHP filter_preload_activities怎么用?PHP filter_preload_activities使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_preload_activities函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 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);
}
示例2: get_formatted_content
/**
* Returns the content to display on course/overview page, formatted and passed through filters
*
* if $options['context'] is not specified, the module context is used
*
* @param array|stdClass $options formatting options, see {@link format_text()}
* @return string
*/
public function get_formatted_content($options = array()) {
$this->obtain_view_data();
if (empty($this->content)) {
return '';
}
// Improve filter performance by preloading filter setttings for all
// activities on the course (this does nothing if called multiple
// times)
filter_preload_activities($this->get_modinfo());
$options = (array)$options;
if (!isset($options['context'])) {
$options['context'] = $this->get_context();
}
return format_text($this->content, FORMAT_HTML, $options);
}
示例3: get_formatted_name
/**
* Returns the name to display on course/overview page, formatted and passed through filters
*
* if $options['context'] is not specified, the module context is used
*
* @param array|stdClass $options formatting options, see {@link format_string()}
* @return string
*/
public function get_formatted_name($options = array())
{
global $CFG;
$options = (array) $options;
if (!isset($options['context'])) {
$options['context'] = $this->get_context();
}
// Improve filter performance by preloading filter setttings for all
// activities on the course (this does nothing if called multiple
// times).
if (!empty($CFG->filterall)) {
filter_preload_activities($this->get_modinfo());
}
return format_string($this->get_name(), true, $options);
}
示例4: assert_matches
private function assert_matches($modinfo)
{
global $FILTERLIB_PRIVATE;
// Use preload cache...
$FILTERLIB_PRIVATE = new stdClass();
filter_preload_activities($modinfo);
// Get data and check no queries are made
$before = $this->testdb->perf_get_reads();
$plfilters1 = filter_get_active_in_context($this->activity1context);
$plfilters2 = filter_get_active_in_context($this->activity2context);
$after = $this->testdb->perf_get_reads();
$this->assertEqual($before, $after);
// Repeat without cache and check it makes queries now
$FILTERLIB_PRIVATE = new stdClass();
$before = $this->testdb->perf_get_reads();
$filters1 = filter_get_active_in_context($this->activity1context);
$filters2 = filter_get_active_in_context($this->activity2context);
$after = $this->testdb->perf_get_reads();
$this->assertTrue($after > $before);
// Check they match
$this->assertEqual($plfilters1, $filters1);
$this->assertEqual($plfilters2, $filters2);
}
示例5: print_course_section
/**
* Prints a section full of activity modules
*
* @author Steve Beaudry
* date 2011-06-03
* @global object $CFG The Moodle configuration object
* @param object course information
* @param array section information
* @param array mod modules of the course
* @return string section table
*/
function print_course_section($course, $section, $mods)
{
global $CFG;
$sectiontable = '<div>';
$modinfo = get_fast_modinfo($course);
filter_preload_activities($modinfo);
if (!empty($section->sequence)) {
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
// Is this course-module available to the user?
if (!$mod->uservisible && empty($mod->availableinfo)) {
continue;
// Not available, do not list.
}
if ($mod->visible) {
$content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
$instancename = $mod->get_formatted_name(array('overflowdiv' => true, 'noclean' => true));
if (strlen($content) > 0) {
$instancename = strip_tags($content);
}
$fullinstancename = urldecode($instancename);
$cm = $modinfo->get_cm($modnumber);
if (!empty($cm->extra)) {
$extra = urldecode($cm->extra);
} else {
$extra = '';
}
// Normal activity.
$compilable = get_config("local_compile", $mod->modname);
if ($compilable && $mod->visible) {
if (!strlen(trim($instancename))) {
$instancename = $mod->modfullname;
}
if ($mod->modname != 'resource') {
$sectiontable .= '<tr>';
$sectiontable .= '<td class="compile-select-spacer"></td>';
$sectiontable .= '<td class="compile-select-checkcell">' . "<input type=checkbox checked onclick=\"setparent(" . $modnumber . "," . $section->id . ")\" class=\"section-{$section->id}\" id=\"{$modnumber}\" name=checkboxlist[] value=\"{$modnumber}\" />" . '</td>';
$sectiontable .= '<td class="compile-select-desccell">' . "<a href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">" . "<img src=\"{$CFG->wwwroot}/mod/{$mod->modname}/pix/icon.png\">{$fullinstancename}</a>" . '</td>';
$sectiontable .= '</tr>';
} else {
require_once $CFG->dirroot . '/mod/resource/lib.php';
$info = resource_get_coursemodule_info($mod);
if ($info->icon) {
$sectiontable .= '<tr>';
$sectiontable .= '<td class="compile-select-spacer"></td>';
$sectiontable .= '<td class="compile-select-checkcell">' . "<input type=checkbox onclick=\"setparent(" . $modnumber . "," . $section->id . ")\" checked class=\"section-{$section->id}\" " . "id={$modnumber} name=checkboxlist[] value={$modnumber} />" . '</td>';
$sectiontable .= '<td class="compile-select-desccell">' . "<a href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">" . "<img src=\"{$CFG->wwwroot}/pix/{$info->icon}.png\">{$fullinstancename}</a>" . '</td>';
$sectiontable .= '</tr>';
} else {
if (!$info->icon) {
$sectiontable .= '<tr>';
$sectiontable .= '<td class="compile-select-spacer"></td>';
$sectiontable .= '<td class="compile-select-checkcell">' . "<input type=checkbox onclick=\"setparent(" . $modnumber . "," . $section->id . ")\" checked class=\"section-{$section->id}\" " . "id=\"{$modnumber}\" name=checkboxlist[] value=\"{$modnumber}\" />" . '</td>';
$sectiontable .= '<td class="compile-select-desccell">' . "<a href=\"{$CFG->wwwroot}/mod/{$mod->modname}/view.php?id={$mod->id}\">" . "<img src=\"{$CFG->modpixpath}/{$mod->modname}/icon.gif\">{$fullinstancename}</a>" . '</td>';
$sectiontable .= '</tr>';
}
}
}
}
}
}
}
$sectiontable .= '</div>';
if ($sectiontable == "<div></div>") {
$sectiontable = '';
}
return $sectiontable;
}