本文整理汇总了PHP中moodle_url::make_file_url方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url::make_file_url方法的具体用法?PHP moodle_url::make_file_url怎么用?PHP moodle_url::make_file_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodle_url
的用法示例。
在下文中一共展示了moodle_url::make_file_url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_csswww
public function get_csswww()
{
global $CFG;
if (!$this->theme_essential_lte_ie9()) {
if (right_to_left()) {
$moodlecss = 'essential-rtl.css';
} else {
$moodlecss = 'essential.css';
}
$syscontext = context_system::instance();
$itemid = theme_get_revision();
$url = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$syscontext->id}/theme_essential/style/{$itemid}/{$moodlecss}");
$url = preg_replace('|^https?://|i', '//', $url->out(false));
return '<link rel="stylesheet" href="' . $url . '">';
} else {
if (right_to_left()) {
$moodlecssone = 'essential-rtl_ie9-blessed1.css';
$moodlecsstwo = 'essential-rtl_ie9.css';
} else {
$moodlecssone = 'essential_ie9-blessed1.css';
$moodlecsstwo = 'essential_ie9.css';
}
$syscontext = context_system::instance();
$itemid = theme_get_revision();
$urlone = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$syscontext->id}/theme_essential/style/{$itemid}/{$moodlecssone}");
$urlone = preg_replace('|^https?://|i', '//', $urlone->out(false));
$urltwo = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$syscontext->id}/theme_essential/style/{$itemid}/{$moodlecsstwo}");
$urltwo = preg_replace('|^https?://|i', '//', $urltwo->out(false));
return '<link rel="stylesheet" href="' . $urlone . '"><link rel="stylesheet" href="' . $urltwo . '">';
}
}
示例2: process_display_castext
/**
* Do the necessary processing on content that came from the user, for example
* the question text or general feedback. The result of calling this method is
* then passed to Moodle's {@link format_text()} function.
* @param string $text the content to process.
* @param qtype_stack_renderer $renderer (options) the STACK renderer, if you have one.
* @return string the content ready to pass to format_text.
*/
public function process_display_castext($text, $replacedollars, qtype_stack_renderer $renderer = null)
{
if ($replacedollars) {
$text = $this->replace_dollars($text);
}
$text = str_replace('!ploturl!', moodle_url::make_file_url('/question/type/stack/plot.php', '/'), $text);
$text = stack_fact_sheets::display($text, $renderer);
return $text;
}
示例3: rss_get_url
/**
* This function returns the URL for the RSS XML file.
*
* @param int $contextid the course id
* @param int $userid the current user id
* @param string $componentname the name of the current component. For example "forum"
* @param string $additionalargs For modules, module instance id
* @return string the url of the RSS feed
*/
function rss_get_url($contextid, $userid, $componentname, $additionalargs)
{
global $CFG;
if (empty($userid)) {
$userid = guest_user()->id;
}
$usertoken = rss_get_token($userid);
$url = '/rss/file.php';
return moodle_url::make_file_url($url, '/' . $contextid . '/' . $usertoken . '/' . $componentname . '/' . $additionalargs . '/rss.xml');
}
示例4: setting_file_url
/**
* Returns URL to the stored file via pluginfile.php.
*
* Note the theme must also implement pluginfile.php handler,
* theme revision is used instead of the itemid.
*
* @param string $setting
* @param string $filearea
* @return string protocol relative URL or null if not present
*/
public function setting_file_url($setting, $filearea)
{
global $CFG;
if (empty($this->settings->{$setting})) {
return null;
}
$component = 'theme_' . $this->name;
$itemid = theme_get_revision();
$filepath = $this->settings->{$setting};
$syscontext = context_system::instance();
$url = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$syscontext->id}/{$component}/{$filearea}/{$itemid}" . $filepath);
// Now this is tricky because the we can not hardcode http or https here, lets use the relative link.
// Note: unfortunately moodle_url does not support //urls yet.
$url = preg_replace('|^https?://|i', '//', $url->out(false));
return $url;
}
示例5: get_csswww
static public function get_csswww() {
global $CFG;
if (!self::lte_ie9()) {
if (\right_to_left()) {
$moodlecss = 'essential-rtl.css';
} else {
$moodlecss = 'essential.css';
}
$syscontext = \context_system::instance();
$itemid = \theme_get_revision();
$url = \moodle_url::make_file_url("$CFG->wwwroot/pluginfile.php",
"/$syscontext->id/theme_essential/style/$itemid/$moodlecss");
$url = preg_replace('|^https?://|i', '//', $url->out(false));
return '<link rel="stylesheet" href="' . $url . '">';
} else {
if (\right_to_left()) {
$moodlecssone = 'essential-rtl_ie9-blessed1.css';
$moodlecsstwo = 'essential-rtl_ie9.css';
} else {
$moodlecssone = 'essential_ie9-blessed1.css';
$moodlecsstwo = 'essential_ie9.css';
}
$syscontext = \context_system::instance();
$itemid = \theme_get_revision();
$urlone = \moodle_url::make_file_url("$CFG->wwwroot/pluginfile.php",
"/$syscontext->id/theme_essential/style/$itemid/$moodlecssone");
$urlone = preg_replace('|^https?://|i', '//', $urlone->out(false));
$urltwo = \moodle_url::make_file_url("$CFG->wwwroot/pluginfile.php",
"/$syscontext->id/theme_essential/style/$itemid/$moodlecsstwo");
$urltwo = preg_replace('|^https?://|i', '//', $urltwo->out(false));
return '<link rel="stylesheet" href="'.$urlone . '"><link rel="stylesheet" href="'.$urltwo.'">';
}
}
示例6: dataform_get_custom_icon_url
/**
* Gets the instance custom icon if exists.
* Filearea: activityicon
* Itemid: 0
*
* @param int cm id
* @return moodle_url
*/
function dataform_get_custom_icon_url($cmid)
{
$fs = get_file_storage();
$context = context_module::instance($cmid);
if ($files = $fs->get_area_files($context->id, 'mod_dataform', 'activityicon', 0, 'sortorder', false)) {
$file = reset($files);
$filename = $file->get_filename();
$path = "/{$context->id}/mod_dataform/activityicon/0";
return moodle_url::make_file_url('/pluginfile.php', "{$path}/{$filename}");
}
return null;
}
示例7: reset
$file = reset($files);
unset($files);
}
$resource->mainfile = $file->get_filename();
$displaytype = resource_get_final_display_type($resource);
if ($displaytype == RESOURCELIB_DISPLAY_OPEN || $displaytype == RESOURCELIB_DISPLAY_DOWNLOAD) {
// For 'open' and 'download' links, we always redirect to the content - except
// if the user just chose 'save and display' from the form then that would be
// confusing
if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], 'modedit.php') === false) {
$redirect = true;
}
}
if ($redirect) {
// coming from course page or url index page
// this redirect trick solves caching problems when tracking views ;-)
$path = '/' . $context->id . '/mod_resource/content/' . $resource->revision . $file->get_filepath() . $file->get_filename();
$fullurl = moodle_url::make_file_url('/pluginfile.php', $path, $displaytype == RESOURCELIB_DISPLAY_DOWNLOAD);
redirect($fullurl);
}
switch ($displaytype) {
case RESOURCELIB_DISPLAY_EMBED:
resource_display_embed($resource, $cm, $course, $file);
break;
case RESOURCELIB_DISPLAY_FRAME:
resource_display_frame($resource, $cm, $course, $file);
break;
default:
resource_print_workaround($resource, $cm, $course, $file);
break;
}
示例8: get_action_icon_download
/**
*
*/
protected function get_action_icon_download($preset, $area)
{
global $OUTPUT;
static $icon;
if (!$icon) {
$icon = new pix_icon('t/download', $this->get_strings()->download);
}
$url = moodle_url::make_file_url("/pluginfile.php", "/{$preset->contextid}/mod_dataform/{$area}/{$preset->itemid}/{$preset->name}");
return $OUTPUT->action_icon($url, $icon);
}
示例9: display_file
/**
*
*/
protected function display_file($file, $path, $altname, $params = null)
{
$field = $this->_field;
if ($file->is_valid_image()) {
$filename = $file->get_filename();
$imgattr = array('style' => array());
if (!empty($params['tn'])) {
// Decline if the file is not really a thumbnail.
if (strpos($filename, 'thumb_') === false) {
return '';
}
} else {
// Decline if the file is a thumbnail.
if (strpos($filename, 'thumb_') !== false) {
return '';
}
// The picture's display dimension may be set in the field.
if ($field->appearance->dispw) {
$imgattr['style'][] = 'width:' . s($field->appearance->dispw) . s($field->appearance->dispu);
}
if ($field->appearance->disph) {
$imgattr['style'][] = 'height:' . s($field->appearance->disph) . s($field->appearance->dispu);
}
}
// Calculate src: either moodle url or base64.
if (!empty($params['download'])) {
return $this->display_link($file, $path, $altname, $params);
} else {
if (!empty($params['base64'])) {
$src = 'data:' . $file->get_mimetype() . ';base64,' . base64_encode($file->get_content());
} else {
$pluginfileurl = new moodle_url('/pluginfile.php');
$src = moodle_url::make_file_url($pluginfileurl, "{$path}/{$filename}");
// For url request return it here.
if (!empty($params['url'])) {
return $src;
}
}
}
$imgattr['src'] = $src;
$imgattr['style'] = implode(';', $imgattr['style']);
$str = html_writer::empty_tag('img', $imgattr);
if (!empty($params['linked'])) {
return html_writer::link($src, $str);
} else {
return $str;
}
} else {
return '';
}
}
示例10: display_link
/**
*
*/
protected function display_link($file, $path, $altname, $params = null)
{
global $OUTPUT;
$filename = $file->get_filename();
$displayname = $altname ? $altname : $filename;
$fileicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url(file_mimetype_icon($file->get_mimetype())), 'alt' => $file->get_mimetype(), 'height' => 16, 'width' => 16));
if (!empty($params['download'])) {
list(, $context, , , $contentid) = explode('/', $path);
$url = new moodle_url("/mod/dataform/field/file/download.php", array('cid' => $contentid, 'context' => $context, 'file' => $filename));
} else {
$url = moodle_url::make_file_url('/pluginfile.php', "{$path}/{$filename}");
}
return html_writer::link($url, "{$fileicon} {$displayname}");
}
示例11: get_entries_display
/**
* Returns the html for entries displays. Assumes that {@link mod_dataform_entry_manager::set_content()}
* has been called for this view and its entries property is set in accordance with the display mode
* of the view submission settings.
*
* @return string HTML fragment
*/
public function get_entries_display(array $options = null)
{
$html = '';
$entryman = $this->entry_manager;
$editing = $this->user_is_editing();
if ($editing) {
if ($this->in_edit_display_mode(self::EDIT_SEPARATE)) {
// Extract the edited and non-edited entries from the set.
$editentries = explode(',', $this->editentries);
$edited = array();
$nonedited = array();
foreach ($entryman->entries as $entryid => $entry) {
if (in_array($entryid, $editentries)) {
$edited[$entryid] = $entry;
} else {
$nonedited[$entryid] = $entry;
}
}
// Get the form html for the edited entries.
if ($elements = $this->get_entries_definition($edited)) {
if ($this->editentries) {
$entriesform = $this->get_entries_form(array('elements' => $elements));
$html .= $entriesform->render();
} else {
// Turns out that all requested edits are not allowed.
$html .= implode('', $elements);
}
}
// Add the rest.
$elements = $this->get_entries_definition($nonedited, false);
$html .= implode('', $elements);
} else {
// Get the form html for all entries.
if ($elements = $this->get_entries_definition($entryman->entries)) {
if ($this->editentries) {
$entriesform = $this->get_entries_form(array('elements' => $elements));
$html .= $entriesform->render();
} else {
// Turns out that all requested edits are not allowed.
$html .= implode('', $elements);
}
}
}
return $html;
}
// Not editing so fetch the entries and display html.
$elements = $this->get_entries_definition($entryman->entries, false);
$html .= implode('', $elements);
// RM ??? Replace pluginfile urls if needed (e.g. in export).
$pluginfileurl = isset($options['pluginfileurl']) ? $options['pluginfileurl'] : null;
if ($pluginfileurl) {
$pluginfilepath = \moodle_url::make_file_url("/pluginfile.php", "/{$this->df->context->id}/mod_dataform/content");
$pattern = str_replace('/', '\\/', $pluginfilepath);
$pattern = "/{$pattern}\\/\\d+\\//";
$html = preg_replace($pattern, $pluginfileurl, $html);
}
return $html;
}
示例12: tur_get_course_intro_image
function tur_get_course_intro_image($contextid)
{
$fs = get_file_storage();
$files = $fs->get_area_files($contextid, 'mod_resource', 'content', 0);
if ($file = end($files)) {
$filename = $file->get_filename();
if ($filename != '.') {
return moodle_url::make_file_url('/pluginfile.php', "/{$contextid}/mod_resource/content/0/{$filename}");
}
}
}
示例13: render_user_participation_list
/**
* Print single user participation for display
*
* @param object $cm current course module object
* @param object $course current course object
* @param object $oublog current oublog object
* @param int $userid user id of user to view participation for
* @param int $groupid optional group id, no group = 0
* @param string $download download type (csv only, default '')
* @param int $page flexible_table pagination page
* @param array $participation mixed array of user participation values
* @param object $context current context
* @param bool $viewfullnames flag for global users fullnames capability
* @param string groupname group name for display, default ''
*/
public function render_user_participation_list($cm, $course, $oublog, $participation, $groupid, $download, $page, $context, $viewfullnames, $groupname, $start, $end)
{
global $DB, $CFG;
$user = $participation->user;
$fullname = fullname($user, $viewfullnames);
// Setup the table.
require_once $CFG->dirroot . '/mod/oublog/participation_table.php';
$filename = "{$course->shortname}-" . format_string($oublog->name, true);
if ($groupname !== '') {
$filename .= '-' . format_string($groupname, true);
}
$filename .= '-' . format_string($fullname, true);
$table = new oublog_user_participation_table($cm->id, $course, $oublog, $user->id, $fullname, $groupname, $groupid, $start, $end);
$table->setup($download);
$table->is_downloading($download, $filename, get_string('participation', 'oublog'));
// Print standard output.
$output = '';
$modcontext = context_module::instance($cm->id);
if (!$table->is_downloading()) {
$output .= html_writer::tag('h2', get_string('postsby', 'oublog', $fullname));
if (!$participation->posts) {
$output .= html_writer::tag('p', get_string('nouserposts', 'oublog'));
} else {
$counter = 0;
foreach ($participation->posts as $post) {
$row = $counter % 2 ? 'oublog-odd' : 'oublog-even';
$counter++;
$output .= html_writer::start_tag('div', array('class' => 'oublog-post ' . $row));
$output .= html_writer::start_tag('div', array('class' => 'oublog-post-top'));
// Post attachments.
$fs = get_file_storage();
if ($files = $fs->get_area_files($modcontext->id, 'mod_oublog', 'attachment', $post->id, 'timemodified', false)) {
$output .= html_writer::start_tag('div', array('class' => 'oublog-post-attachments'));
foreach ($files as $file) {
$filename = $file->get_filename();
$mimetype = $file->get_mimetype();
$iconimage = html_writer::empty_tag('img', array('src' => $this->output->pix_url(file_mimetype_icon($mimetype)), 'alt' => $mimetype, 'class' => 'icon'));
$fileurlbase = $CFG->wwwroot . '/pluginfile.php';
$filepath = '/' . $modcontext->id . '/mod_oublog/attachment/' . $post->id . '/' . $filename;
$path = moodle_url::make_file_url($fileurlbase, $filepath);
$output .= html_writer::tag('a', $iconimage, array('href' => $path));
$output .= html_writer::tag('a', s($filename), array('href' => $path));
}
$output .= html_writer::end_tag('div');
}
// Post title and date.
if (isset($post->title) && !empty($post->title)) {
$viewposturl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
$viewpost = html_writer::link($viewposturl, s($post->title));
$output .= html_writer::tag('h3', $viewpost, array('class' => 'oublog-post-title'));
$output .= html_writer::start_tag('div', array('class' => 'oublog-post-date'));
$output .= oublog_date($post->timeposted);
$output .= html_writer::end_tag('div');
} else {
$viewposturl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
$viewpost = html_writer::link($viewposturl, oublog_date($post->timeposted));
$output .= html_writer::tag('h3', $viewpost, array('class' => 'oublog-post-title'));
}
$output .= html_writer::end_tag('div');
// Post content.
$output .= html_writer::start_tag('div', array('class' => 'oublog-post-content'));
$post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_oublog', 'message', $post->id);
$output .= format_text($post->message, FORMAT_HTML);
$output .= html_writer::end_tag('div');
// End display box.
$output .= html_writer::end_tag('div');
}
}
$output .= html_writer::tag('h2', get_string('commentsby', 'oublog', $fullname));
if (!$participation->comments) {
$output .= html_writer::tag('p', get_string('nousercomments', 'oublog'));
} else {
$output .= html_writer::start_tag('div', array('id' => 'oublogcomments', 'class' => 'oublog-post-comments oublogpartcomments'));
foreach ($participation->comments as $comment) {
$output .= html_writer::start_tag('div', array('class' => 'oublog-comment'));
$author = new StdClass();
$author->id = $comment->authorid;
$userfields = get_all_user_name_fields();
foreach ($userfields as $field) {
$author->{$field} = $comment->{$field};
}
$authorurl = new moodle_url('/user/view.php', array('id' => $author->id));
$authorlink = html_writer::link($authorurl, fullname($author, $viewfullnames));
if (isset($comment->posttitle) && !empty($comment->posttitle)) {
$viewposturl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $comment->postid));
//.........这里部分代码省略.........
示例14: foreach
// Loop through columns and create tag for each one
// Only print the capabilities if they're associated with one of our roles
if (in_array($cap->roleid, $role_ids)) {
$xml->begin_tag('ROLE_CAPABILITY');
foreach ($cap_array as $field => $value) {
$xml->full_tag(strtoupper($field), $value);
}
$xml->end_tag('ROLE_CAPABILITY');
}
}
}
$xml->end_tag('ROLE_CAPABILITIES');
$xml->end_tag('ROLE');
}
}
$xml->end_tag('ROLES');
$xml->end_tag('MOODLE_ROLES_MIGRATION');
$xml->stop();
// Create the XML file from the XML object stored in memory
if ($fs->create_file_from_string($fileinfo, $xml_output->get_allcontents())) {
if ($file = $fs->get_file($fileinfo['contextid'], $fileinfo['component'], $fileinfo['filearea'], $fileinfo['itemid'], $fileinfo['filepath'], $fileinfo['filename'])) {
$path = "/" . $fileinfo['contextid'] . "/" . $fileinfo['component'] . "/" . $fileinfo['filearea'] . "/" . $fileinfo['itemid'] . $fileinfo['filepath'] . $fileinfo['filename'];
$url = moodle_url::make_file_url($CFG->wwwroot . "/pluginfile.php", $path);
redirect($url);
} else {
send_file_not_found();
}
} else {
send_file_not_found();
}
die;
示例15: set_page_js
/**
* Sets the dataform page js.
*
* @return void
*/
protected function set_page_js()
{
global $PAGE;
$jsurls = array();
// Js includes from the js template.
if ($this->jsincludes) {
foreach (explode("\n", $this->jsincludes) as $jsinclude) {
$jsinclude = trim($jsinclude);
if ($jsinclude) {
$jsurls[] = new moodle_url($jsinclude);
}
}
}
// Uploaded js files.
$fs = get_file_storage();
if ($files = $fs->get_area_files($this->context->id, 'mod_dataform', 'js', 0, 'sortorder', false)) {
$path = "/{$this->context->id}/mod_dataform/js/0";
foreach ($files as $file) {
$filename = $file->get_filename();
$jsurls[] = moodle_url::make_file_url('/pluginfile.php', "{$path}/{$filename}");
}
}
// Js code from the js template.
if ($this->js) {
$jsurls[] = new moodle_url('/mod/dataform/js.php', array('d' => $this->id));
}
foreach ($jsurls as $jsurl) {
$PAGE->requires->js($jsurl);
}
}