本文整理汇总了PHP中file_rewrite_pluginfile_urls函数的典型用法代码示例。如果您正苦于以下问题:PHP file_rewrite_pluginfile_urls函数的具体用法?PHP file_rewrite_pluginfile_urls怎么用?PHP file_rewrite_pluginfile_urls使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_rewrite_pluginfile_urls函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
if ($this->content !== NULL) {
return $this->content;
}
$filteropt = new stdClass();
$filteropt->overflowdiv = true;
if ($this->content_is_trusted()) {
// fancy html allowed only on course, category and system blocks.
$filteropt->noclean = true;
}
$this->content = new stdClass();
$this->content->footer = '';
if (isset($this->config->text)) {
// rewrite url
$this->config->text = file_rewrite_pluginfile_urls($this->config->text, 'pluginfile.php', $this->context->id, 'block_html', 'content', NULL);
// Default to FORMAT_HTML which is what will have been used before the
// editor was properly implemented for the block.
$format = FORMAT_HTML;
// Check to see if the format has been properly set on the config
if (isset($this->config->format)) {
$format = $this->config->format;
}
$this->content->text = format_text($this->config->text, $format, $filteropt);
} else {
$this->content->text = '';
}
unset($filteropt);
// memory footprint
return $this->content;
}
示例2: course_info_box
/**
* Renders course info box.
*
* @param stdClass $course
* @return string
*/
public function course_info_box(stdClass $course)
{
global $CFG;
$context = context_course::instance($course->id);
$content = '';
$content .= $this->output->box_start('generalbox info');
$summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
$content .= format_text($summary, $course->summaryformat, array('overflowdiv' => true), $course->id);
if (!empty($CFG->coursecontact)) {
$coursecontactroles = explode(',', $CFG->coursecontact);
foreach ($coursecontactroles as $roleid) {
if ($users = get_role_users($roleid, $context, true)) {
foreach ($users as $teacher) {
$role = new stdClass();
$role->id = $teacher->roleid;
$role->name = $teacher->rolename;
$role->shortname = $teacher->roleshortname;
$role->coursealias = $teacher->rolecoursealias;
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
$namesarray[] = role_get_name($role, $context) . ': <a href="' . $CFG->wwwroot . '/user/view.php?id=' . $teacher->id . '&course=' . SITEID . '">' . $fullname . '</a>';
}
}
}
if (!empty($namesarray)) {
$content .= "<ul class=\"teachers\">\n<li>";
$content .= implode('</li><li>', $namesarray);
$content .= "</li></ul>";
}
}
$content .= $this->output->box_end();
return $content;
}
示例3: available_courses
/**
* Returns list of courses that we offer to the caller for remote enrolment of their users
*
* Since Moodle 2.0, courses are made available for MNet peers by creating an instance
* of enrol_mnet plugin for the course. Hidden courses are not returned. If there are two
* instances - one specific for the host and one for 'All hosts', the setting of the specific
* one is used. The id of the peer is kept in customint1, no other custom fields are used.
*
* @uses mnet_remote_client Callable via XML-RPC only
* @return array
*/
public function available_courses()
{
global $CFG, $DB;
require_once $CFG->libdir . '/filelib.php';
if (!($client = get_mnet_remote_client())) {
die('Callable via XML-RPC only');
}
// we call our id as 'remoteid' because it will be sent to the peer
// the column aliases are required by MNet protocol API for clients 1.x and 2.0
$sql = "SELECT c.id AS remoteid, c.fullname, c.shortname, c.idnumber, c.summary, c.summaryformat,\n c.sortorder, c.startdate, cat.id AS cat_id, cat.name AS cat_name,\n cat.description AS cat_description, cat.descriptionformat AS cat_descriptionformat,\n e.cost, e.currency, e.roleid AS defaultroleid, r.name AS defaultrolename,\n e.customint1\n FROM {enrol} e\n INNER JOIN {course} c ON c.id = e.courseid\n INNER JOIN {course_categories} cat ON cat.id = c.category\n INNER JOIN {role} r ON r.id = e.roleid\n WHERE e.enrol = 'mnet'\n AND (e.customint1 = 0 OR e.customint1 = ?)\n AND c.visible = 1\n ORDER BY cat.sortorder, c.sortorder, c.shortname";
$rs = $DB->get_recordset_sql($sql, array($client->id));
$courses = array();
foreach ($rs as $course) {
// use the record if it does not exist yet or is host-specific
if (empty($courses[$course->remoteid]) or $course->customint1 > 0) {
unset($course->customint1);
// the client does not need to know this
$context = get_context_instance(CONTEXT_COURSE, $course->remoteid);
// Rewrite file URLs so that they are correct
$course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', false);
$courses[$course->remoteid] = $course;
}
}
$rs->close();
return array_values($courses);
// can not use keys for backward compatibility
}
示例4: get_content
function get_content()
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
if ($this->content !== NULL) {
return $this->content;
}
$filteropt = new stdClass();
$filteropt->overflowdiv = true;
if ($this->content_is_trusted()) {
// fancy html allowed only on course, category and system blocks.
$filteropt->noclean = true;
}
$this->content = new stdClass();
$this->content->footer = '';
if (isset($this->config->text)) {
// rewrite url
$this->config->text = file_rewrite_pluginfile_urls($this->config->text, 'pluginfile.php', $this->context->id, 'block_html', 'content', NULL);
$this->content->text = format_text($this->config->text, $this->config->format, $filteropt);
} else {
$this->content->text = '';
}
unset($filteropt);
// memory footprint
return $this->content;
}
示例5: format_message_text
/**
* The HTML version of the e-mail message.
*
* @param \stdClass $cm
* @param \stdClass $post
* @return string
*/
public function format_message_text($cm, $post)
{
$message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', \context_module::instance($cm->id)->id, 'mod_forum', 'post', $post->id);
$options = new \stdClass();
$options->para = true;
return format_text($message, $post->messageformat, $options);
}
示例6: get_content
function get_content()
{
global $CFG, $OUTPUT;
require_once $CFG->libdir . '/filelib.php';
if ($this->content !== NULL) {
return $this->content;
}
if (empty($this->instance)) {
return '';
}
$this->content = new stdClass();
$options = new stdClass();
$options->noclean = true;
// Don't clean Javascripts etc
$options->overflowdiv = true;
$context = context_course::instance($this->page->course->id);
$this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
$this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
if ($this->page->user_is_editing()) {
if ($this->page->course->id == SITEID) {
$editpage = $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=frontpagesettings';
} else {
$editpage = $CFG->wwwroot . '/course/edit.php?id=' . $this->page->course->id;
}
$this->content->text .= "<div class=\"editbutton\"><a href=\"{$editpage}\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"" . get_string('edit') . "\" /></a></div>";
}
$this->content->footer = '';
return $this->content;
}
示例7: format_summary_text
/**
* Generate html for a section summary text
*
* @param stdClass $section The course_section entry from DB
* @return string HTML to output.
*/
protected function format_summary_text($section)
{
$context = context_course::instance($section->course);
$summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course', 'section', $section->id);
$options = new stdClass();
$options->noclean = true;
$options->overflowdiv = true;
return format_text($summarytext, $section->summaryformat, $options);
}
示例8: groupselect_get_group_info
function groupselect_get_group_info($group)
{
$group = clone $group;
$context = context_course::instance($group->courseid);
$group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'group', 'description', $group->id);
if (!isset($group->descriptionformat)) {
$group->descriptionformat = FORMAT_MOODLE;
}
$options = new stdClass();
$options->overflowdiv = true;
return format_text($group->description, $group->descriptionformat, array('filter' => false, 'overflowdiv' => true, 'context' => $context));
}
示例9: realtimequiz_send_question
function realtimequiz_send_question($quizid, $context, $preview = false)
{
global $DB;
if (!($quiz = $DB->get_record('realtimequiz', array('id' => $quizid)))) {
realtimequiz_send_error(get_string('badquizid', 'realtimequiz') . $quizid);
} else {
$questionid = $quiz->currentquestion;
if (!($question = $DB->get_record('realtimequiz_question', array('id' => $questionid)))) {
realtimequiz_send_error(get_string('badcurrentquestion', 'realtimequiz') . $questionid);
} else {
$answers = $DB->get_records('realtimequiz_answer', array('questionid' => $questionid), 'id');
$questioncount = $DB->count_records('realtimequiz_question', array('quizid' => $quizid));
echo '<status>showquestion</status>';
echo "<question><questionnumber>{$question->questionnum}</questionnumber>";
echo "<questioncount>{$questioncount}</questioncount>";
$questiontext = format_text($question->questiontext, $question->questiontextformat);
$questiontext = file_rewrite_pluginfile_urls($questiontext, 'pluginfile.php', $context->id, 'mod_realtimequiz', 'question', $questionid);
echo "<questiontext><![CDATA[{$questiontext}]]></questiontext>";
if ($preview) {
$previewtime = $quiz->nextendtime - time();
if ($previewtime > 0) {
echo "<delay>{$previewtime}</delay>";
}
$questiontime = $question->questiontime;
if ($questiontime == 0) {
$questiontime = $quiz->questiontime;
}
echo "<questiontime>{$questiontime}</questiontime>";
} else {
$questiontime = $quiz->nextendtime - time();
if ($questiontime < 0) {
$questiontime = 0;
}
echo "<questiontime>{$questiontime}</questiontime>";
}
echo '<answers>';
foreach ($answers as $answer) {
$answertext = $answer->answertext;
echo "<answer id='{$answer->id}'><![CDATA[{$answertext}]]></answer>";
}
echo '</answers>';
echo '</question>';
}
}
}
示例10: search_result
public function search_result($records, $subwiki) {
global $CFG, $PAGE;
$table = new html_table();
$context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
$strsearchresults = get_string('searchresult', 'wiki');
$totalcount = count($records);
$html = $this->output->heading("$strsearchresults $totalcount");
foreach ($records as $page) {
$table->head = array('title' => format_string($page->title) . ' (' . html_writer::link($CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $page->id, get_string('view', 'wiki')) . ')');
$table->align = array('title' => 'left');
$table->width = '100%';
$table->data = array(array(file_rewrite_pluginfile_urls(format_text($page->cachedcontent, FORMAT_HTML), 'pluginfile.php', $context->id, 'mod_wiki', 'attachments', $subwiki->id)));
$table->colclasses = array('wikisearchresults');
$html .= html_writer::table($table);
}
$html = html_writer::tag('div', $html, array('class'=>'no-overflow'));
return $this->output->container($html);
}
示例11: get_content
function get_content()
{
global $CFG, $OUTPUT;
require_once $CFG->libdir . '/filelib.php';
if ($this->content !== NULL) {
return $this->content;
}
if (empty($this->instance)) {
return '';
}
$this->content = new stdClass();
$options = new stdClass();
$options->noclean = true;
// Don't clean Javascripts etc
$options->overflowdiv = true;
$context = context_course::instance($this->page->course->id);
$this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
$this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
$this->content->footer = '';
return $this->content;
}
示例12: customlabel_set_instance
/**
* implements a hook for the page_module block to add
* the link allowing live refreshing of the content
*
*
*/
function customlabel_set_instance(&$block)
{
global $USER, $CFG, $COURSE, $DB;
// Transfer content from title to content.
$block->title = '';
// Fake unpacks object's load.
$data = json_decode(base64_decode($block->moduleinstance->content));
// If failed in getting content. It happens sometimes, ... do nothing to let content be safed manually
if (is_null($data) || !is_object($data)) {
return false;
}
// Realize a pseudo update.
$data->title = $block->moduleinstance->title;
$data->content = $block->moduleinstance->content;
$data->labelclass = $block->moduleinstance->labelclass;
// fixes broken serialized contents
$context = context_module::instance($block->cm->id);
if (!has_capability('customlabeltype/' . $data->labelclass . ':view', $context)) {
return false;
}
if (!isset($block->moduleinstance->title)) {
// Fixes broken serialized contents.
$block->moduleinstance->title = '';
}
$instance = customlabel_load_class($data);
$block->moduleinstance->processedcontent = $instance->make_content();
$block->moduleinstance->name = $instance->title;
// this realizes the template
$block->moduleinstance->timemodified = time();
$block->content->text = $block->moduleinstance->processedcontent;
$block->moduleinstance->title = str_replace("'", "''", $block->moduleinstance->title);
$result = $DB->update_record('customlabel', $block->moduleinstance);
$context = context_module::instance($block->cm->id);
$block->content->text = file_rewrite_pluginfile_urls($block->content->text, 'pluginfile.php', $context->id, 'mod_customlabel', 'contentfiles', 0);
return true;
}
示例13: forum_print_post
/**
* Print a forum post
*
* @global object
* @global object
* @uses FORUM_MODE_THREADED
* @uses PORTFOLIO_FORMAT_PLAINHTML
* @uses PORTFOLIO_FORMAT_FILE
* @uses PORTFOLIO_FORMAT_RICHHTML
* @uses PORTFOLIO_ADD_TEXT_LINK
* @uses CONTEXT_MODULE
* @param object $post The post to print.
* @param object $discussion
* @param object $forum
* @param object $cm
* @param object $course
* @param boolean $ownpost Whether this post belongs to the current user.
* @param boolean $reply Whether to print a 'reply' link at the bottom of the message.
* @param boolean $link Just print a shortened version of the post as a link to the full post.
* @param string $footer Extra stuff to print after the message.
* @param string $highlight Space-separated list of terms to highlight.
* @param int $post_read true, false or -99. If we already know whether this user
* has read this post, pass that in, otherwise, pass in -99, and this
* function will work it out.
* @param boolean $dummyifcantsee When forum_user_can_see_post says that
* the current user can't see this post, if this argument is true
* (the default) then print a dummy 'you can't see this post' post.
* If false, don't output anything at all.
* @param bool|null $istracked
* @return void
*/
function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=false, $reply=false, $link=false,
$footer="", $highlight="", $postisread=null, $dummyifcantsee=true, $istracked=null, $return=false) {
global $USER, $CFG, $OUTPUT;
require_once($CFG->libdir . '/filelib.php');
// String cache
static $str;
$modcontext = context_module::instance($cm->id);
$post->course = $course->id;
$post->forum = $forum->id;
$post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id);
if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir.'/plagiarismlib.php');
$post->message .= plagiarism_get_links(array('userid' => $post->userid,
'content' => $post->message,
'cmid' => $cm->id,
'course' => $post->course,
'forum' => $post->forum));
}
// caching
if (!isset($cm->cache)) {
$cm->cache = new stdClass;
}
if (!isset($cm->cache->caps)) {
$cm->cache->caps = array();
$cm->cache->caps['mod/forum:viewdiscussion'] = has_capability('mod/forum:viewdiscussion', $modcontext);
$cm->cache->caps['moodle/site:viewfullnames'] = has_capability('moodle/site:viewfullnames', $modcontext);
$cm->cache->caps['mod/forum:editanypost'] = has_capability('mod/forum:editanypost', $modcontext);
$cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext);
$cm->cache->caps['mod/forum:deleteownpost'] = has_capability('mod/forum:deleteownpost', $modcontext);
$cm->cache->caps['mod/forum:deleteanypost'] = has_capability('mod/forum:deleteanypost', $modcontext);
$cm->cache->caps['mod/forum:viewanyrating'] = has_capability('mod/forum:viewanyrating', $modcontext);
$cm->cache->caps['mod/forum:exportpost'] = has_capability('mod/forum:exportpost', $modcontext);
$cm->cache->caps['mod/forum:exportownpost'] = has_capability('mod/forum:exportownpost', $modcontext);
}
if (!isset($cm->uservisible)) {
$cm->uservisible = coursemodule_visible_for_user($cm);
}
if ($istracked && is_null($postisread)) {
$postisread = forum_tp_is_post_read($USER->id, $post);
}
if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) {
$output = '';
if (!$dummyifcantsee) {
if ($return) {
return $output;
}
echo $output;
return;
}
$output .= html_writer::tag('a', '', array('id'=>'p'.$post->id));
$output .= html_writer::start_tag('div', array('class'=>'forumpost clearfix'));
$output .= html_writer::start_tag('div', array('class'=>'row header'));
$output .= html_writer::tag('div', '', array('class'=>'left picture')); // Picture
if ($post->parent) {
$output .= html_writer::start_tag('div', array('class'=>'topic'));
} else {
$output .= html_writer::start_tag('div', array('class'=>'topic starter'));
}
$output .= html_writer::tag('div', get_string('forumsubjecthidden','forum'), array('class'=>'subject')); // Subject
$output .= html_writer::tag('div', get_string('forumauthorhidden','forum'), array('class'=>'author')); // author
//.........这里部分代码省略.........
示例14: format_module_intro
/**
* Formats activity intro text
*
* @global object
* @uses CONTEXT_MODULE
* @param string $module name of module
* @param object $activity instance of activity
* @param int $cmid course module id
* @param bool $filter filter resulting html text
* @return text
*/
function format_module_intro($module, $activity, $cmid, $filter = true)
{
global $CFG;
require_once "{$CFG->libdir}/filelib.php";
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$options = array('noclean' => true, 'para' => false, 'filter' => $filter, 'context' => $context, 'overflowdiv' => true);
$intro = file_rewrite_pluginfile_urls($activity->intro, 'pluginfile.php', $context->id, 'mod_' . $module, 'intro', null);
return trim(format_text($intro, $activity->introformat, $options, null));
}
示例15: print_version_view
/**
* Given an old page version, output the version content
*
* @global object $CFG
* @global object $OUTPUT
* @global object $PAGE
*/
private function print_version_view() {
global $CFG, $OUTPUT, $PAGE;
$pageversion = wiki_get_version($this->version->id);
if ($pageversion) {
$restorelink = new moodle_url('/mod/wiki/restoreversion.php', array('pageid' => $this->page->id, 'versionid' => $this->version->id));
echo $OUTPUT->heading(get_string('viewversion', 'wiki', $pageversion->version) . '<br />' . html_writer::link($restorelink->out(false), '(' . get_string('restorethis', 'wiki') . ')', array('class' => 'wiki_restore')) . ' ', 4);
$userinfo = wiki_get_user_info($pageversion->userid);
$heading = '<p><strong>' . get_string('modified', 'wiki') . ':</strong> ' . userdate($pageversion->timecreated, get_string('strftimedatetime', 'langconfig'));
$viewlink = new moodle_url('/user/view.php', array('id' => $userinfo->id));
$heading .= ' <strong>' . get_string('user') . ':</strong> ' . html_writer::link($viewlink->out(false), fullname($userinfo));
$heading .= ' → ' . $OUTPUT->user_picture(wiki_get_user_info($pageversion->userid), array('popup' => true)) . '</p>';
print_container($heading, false, 'mdl-align wiki_modifieduser wiki_headingtime');
$options = array('swid' => $this->subwiki->id, 'pretty_print' => true, 'pageid' => $this->page->id);
$pageversion->content = file_rewrite_pluginfile_urls($pageversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
$parseroutput = wiki_parse_content($pageversion->contentformat, $pageversion->content, $options);
$content = print_container(format_text($parseroutput['parsed_text'], FORMAT_HTML, array('overflowdiv'=>true)), false, '', '', true);
echo $OUTPUT->box($content, 'generalbox wiki_contentbox');
} else {
print_error('versionerror', 'wiki');
}
}