本文整理汇总了PHP中file_encode_url函数的典型用法代码示例。如果您正苦于以下问题:PHP file_encode_url函数的具体用法?PHP file_encode_url怎么用?PHP file_encode_url使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_encode_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: block_my_course_progress_get_course_image_url
/**
* Returns the url of the first image contained in the course summary file area
* @param int $id the course id
* @return string the url to the image
*/
function block_my_course_progress_get_course_image_url($id)
{
global $CFG;
require_once $CFG->libdir . "/filelib.php";
$course = get_course($id);
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
if ($isimage) {
return file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
}
}
return false;
}
示例2: coursecat_coursebox_content
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course)
{
global $CFG;
if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
return '';
}
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
$content = '';
// Display course overview files.
$contentimages = $contentfiles = '';
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
if ($isimage) {
$contentimages .= html_writer::start_tag('div', array('class' => 'imagebox'));
$images = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image ' . $course->fullname, 'class' => 'courseimage'));
$contentimages .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $images);
$contentimages .= html_writer::end_tag('div');
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
$contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
}
}
$content .= $contentimages . $contentfiles;
// Display course summary.
if ($course->has_summary()) {
$content .= $chelper->get_course_formatted_summary($course);
}
// Display course contacts. See course_in_list::get_course_contacts().
if ($course->has_course_contacts()) {
$content .= html_writer::start_tag('ul', array('class' => 'teachers'));
foreach ($course->get_course_contacts() as $userid => $coursecontact) {
$name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']);
$content .= html_writer::tag('li', $name);
}
$content .= html_writer::end_tag('ul');
// ...Teachers!.
}
return $content;
}
示例3: mycourses
protected function mycourses($CFG, $sidebar)
{
$mycourses = enrol_get_users_courses($_SESSION['USER']->id);
$courselist = array();
foreach ($mycourses as $key => $val) {
$courselist[] = $val->id;
}
$content = '';
for ($x = 1; $x <= sizeof($courselist); $x++) {
$course = get_course($courselist[$x - 1]);
$title = $course->fullname;
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
$url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg";
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
if (!$isimage) {
$url = $CFG->wwwroot . "/theme/keats/pix/coursenoimage.jpg";
}
}
$content .= '<div class="view view-second view-mycourse ' . ($x % 3 == 0 ? 'view-nomargin' : '') . '">
<img src="' . $url . '" />
<div class="mask">
<h2>' . $title . '</h2>
<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $courselist[$x - 1] . '" class="info">Enter</a>
</div>
</div>';
}
return $content;
}
示例4: htmllize_tree
/**
* Internal function - creates htmls structure suitable for YUI tree.
*/
protected function htmllize_tree($tree, $dir)
{
global $CFG;
$yuiconfig = array();
$yuiconfig['type'] = 'html';
if (empty($dir['subdirs']) and empty($dir['files'])) {
return '';
}
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$image = $this->output->pix_icon("f/folder", $subdir['dirname'], 'moodle', array('class' => 'icon'));
$result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'><div>' . $image . ' ' . s($subdir['dirname']) . '</div> ' . $this->htmllize_tree($tree, $subdir) . '</li>';
}
foreach ($dir['files'] as $file) {
$url = file_encode_url("{$CFG->wwwroot}/blocks/csv_enrol/getfile.php", '/' . $tree->context->id . '/user/csvenrol' . $file->get_filepath() . $file->get_filename(), true);
$filename = $file->get_filename();
$icon = mimeinfo("icon", $filename);
if (strlen($filename) > 10) {
$pi = pathinfo($filename);
$txt = $pi['filename'];
$ext = $pi['extension'];
$filename = substr($filename, 0, 14) . '...' . $ext;
}
$image = $this->output->pix_icon("f/{$icon}", $filename, 'moodle', array('class' => 'icon'));
$result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'><div>' . html_writer::link($url, $image . ' ' . $filename) . '</div></li>';
}
$result .= '</ul>';
return $result;
}
示例5: imscp_htmllize_item
/**
* Internal function - creates htmls structure suitable for YUI tree.
*/
function imscp_htmllize_item($item, $imscp, $cm)
{
global $CFG;
if ($item['href']) {
if (preg_match('|^https?://|', $item['href'])) {
$url = $item['href'];
} else {
$context = context_module::instance($cm->id);
$urlbase = "{$CFG->wwwroot}/pluginfile.php";
$path = '/' . $context->id . '/mod_imscp/content/' . $imscp->revision . '/' . $item['href'];
$url = file_encode_url($urlbase, $path, false);
}
$result = "<li><a href=\"{$url}\">" . $item['title'] . '</a>';
} else {
$result = '<li>' . $item['title'];
}
if ($item['subitems']) {
$result .= '<ul>';
foreach ($item['subitems'] as $subitem) {
$result .= imscp_htmllize_item($subitem, $imscp, $cm);
}
$result .= '</ul>';
}
$result .= '</li>';
return $result;
}
示例6: get_content
public function get_content()
{
global $CFG;
if ($this->content !== null) {
return $this->content;
}
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
$this->content->text = '';
// The user/index.php expect course context, so get one if page has module context.
$currentcontext = $this->page->context->get_course_context(false);
if (empty($currentcontext)) {
return $this->content;
}
if ($this->page->course->id == SITEID) {
$courses = self::get_featured_courses();
require_once $CFG->libdir . '/coursecatlib.php';
$chelper = new coursecat_helper();
foreach ($courses as $course) {
$course = new course_in_list($course);
$this->content->text .= '<div class="container-fluid coursebox">';
$content = '';
$coursename = $chelper->get_course_formatted_name($course);
$coursenamelink = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $coursename, array('class' => $course->visible ? '' : 'dimmed'));
$content .= html_writer::tag('div', $coursenamelink, array('class' => 'coursename'));
if ($course->has_summary()) {
$content .= html_writer::start_tag('div', array('class' => 'summary'));
$content .= $chelper->get_course_formatted_summary($course, array('overflowdiv' => true, 'noclean' => true, 'para' => false));
$content .= html_writer::end_tag('div');
}
// Display course overview files.
$contentimages = $contentfiles = '';
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
if ($isimage) {
$contentimages .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $url, 'style' => 'max-height: 150px')), array('class' => 'courseimage'));
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
$contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
}
}
$content .= $contentimages . $contentfiles;
$this->content->text .= $content . '</div>';
}
}
return $this->content;
}
示例7: folder_get_file_link
/**
* Returns file link
* @param object $file
* @param object $folder
* @param object $context
* @return string html link
*/
function folder_get_file_link($file, $folder, $context)
{
global $CFG;
$strfile = get_string('file');
$strdownload = get_string('download');
$icon = mimeinfo_from_type("icon", $file->get_mimetype());
$urlbase = "{$CFG->wwwroot}/pluginfile.php";
$path = '/' . $context->id . '/folder_content/' . $folder->revision . $file->get_filepath() . $file->get_filename();
$viewurl = file_encode_url($urlbase, $path, false);
$downloadurl = file_encode_url($urlbase, $path, true);
$downloadurl = " <a href=\"{$downloadurl}\" title=\"" . get_string('downloadfile') . "\"><img src=\"{$CFG->pixpath}/t/down.gif\" class=\"iconsmall\" alt=\"{$strdownload}\" /></a>";
return "<a href=\"{$viewurl}\" title=\"\"><img src=\"{$CFG->pixpath}/f/{$icon}\" class=\"icon\" alt=\"{$strfile}\" /> " . s($file->get_filename()) . '</a>' . $downloadurl;
}
示例8: get_url
/**
* Returns file download url
* @param bool $forcedownload
* @param bool $htts force https
* @return string url
*/
public function get_url($forcedownload = false, $https = false)
{
global $CFG;
if (!$this->is_readable()) {
return null;
}
if ($this->lf->is_directory()) {
return null;
}
$filepath = $this->lf->get_filepath();
$filename = $this->lf->get_filename();
$courseid = $this->context->instanceid;
$path = '/' . $courseid . $filepath . $filename;
return file_encode_url($this->urlbase, $path, $forcedownload, $https);
}
示例9: print_student_answer
function print_student_answer($userid, $return = false)
{
global $CFG, $USER, $OUTPUT;
$fs = get_file_storage();
$browser = get_file_browser();
$output = '';
if ($files = $fs->get_area_files($this->context->id, 'assignment_submission', $userid, "timemodified", false)) {
foreach ($files as $file) {
$filename = $file->get_filename();
$found = true;
$mimetype = $file->get_mimetype();
$path = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . $this->context->id . '/assignment_submission/' . $userid . '/' . $filename);
$output .= '<a href="' . $path . '" ><img class="icon" src="' . $OUTPUT->old_icon_url(file_mimetype_icon($mimetype)) . '" alt="' . $mimetype . '" />' . s($filename) . '</a><br />';
}
}
$output = '<div class="files">' . $output . '</div>';
return $output;
}
示例10: imscp_htmllize_item
/**
* Internal function - creates htmls structure suitable for YUI tree.
*/
function imscp_htmllize_item($item, $imscp, $cm)
{
global $CFG;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$urlbase = "{$CFG->wwwroot}/pluginfile.php";
$path = '/' . $context->id . '/mod_imscp/content/' . $imscp->revision . '/' . $item['href'];
$url = file_encode_url($urlbase, $path, false);
$result = "<li><a href=\"{$url}\">" . $item['title'] . '</a>';
if ($item['subitems']) {
$result .= '<ul>';
foreach ($item['subitems'] as $subitem) {
$result .= imscp_htmllize_item($subitem, $imscp, $cm);
}
$result .= '</ul>';
}
$result .= '</li>';
return $result;
}
示例11: htmllize_tree
/**
* Internal function - creates htmls structure suitable for YUI tree.
*/
protected function htmllize_tree($tree, $dir)
{
global $CFG;
if (empty($dir['subdirs']) and empty($dir['files'])) {
return '';
}
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$result .= '<li>' . s($subdir['dirname']) . ' ' . $this->htmllize_tree($tree, $subdir) . '</li>';
}
foreach ($dir['files'] as $file) {
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $tree->context->id . '/mod_ubikc/content/' . $tree->ubikc->kcrevision . $file->get_filepath() . $file->get_filename(), true);
$filename = $file->get_filename();
$result .= '<li><span>' . html_writer::link($url, $filename) . '</span></li>';
}
$result .= '</ul>';
return $result;
}
示例12: print_student_answer
function print_student_answer($userid, $return = false)
{
global $CFG, $USER, $OUTPUT;
$fs = get_file_storage();
$browser = get_file_browser();
$output = '';
if ($submission = $this->get_submission($userid)) {
if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false)) {
foreach ($files as $file) {
$filename = $file->get_filename();
$found = true;
$mimetype = $file->get_mimetype();
$path = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . $this->context->id . '/mod_assignment/submission/' . $submission->id . '/' . $filename);
$output .= '<a href="' . $path . '" >' . $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')) . s($filename) . '</a><br />';
$output .= plagiarism_get_links(array('userid' => $userid, 'file' => $file, 'cmid' => $this->cm->id, 'course' => $this->course, 'assignment' => $this->assignment));
$output .= '<br/>';
}
}
}
$output = '<div class="files">' . $output . '</div>';
return $output;
}
示例13: htmllize_tree
/**
* Internal function - creates htmls structure suitable for YUI tree.
* @param user_files_tree $tree
* @param array $dir
* @return string HTML
*/
protected function htmllize_tree($tree, $dir)
{
global $CFG;
$yuiconfig = array();
$yuiconfig['type'] = 'html';
if (empty($dir['subdirs']) and empty($dir['files'])) {
return '';
}
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$image = $this->output->pix_icon(file_folder_icon(), $subdir['dirname'], 'moodle', array('class' => 'icon'));
$result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'><div>' . $image . ' ' . s($subdir['dirname']) . '</div> ' . $this->htmllize_tree($tree, $subdir) . '</li>';
}
foreach ($dir['files'] as $file) {
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $tree->context->id . '/user/private' . $file->get_filepath() . $file->get_filename(), true);
$filename = $file->get_filename();
$image = $this->output->pix_icon(file_file_icon($file), $filename, 'moodle', array('class' => 'icon'));
$result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'><div>' . $image . ' ' . html_writer::link($url, $filename) . '</div></li>';
}
$result .= '</ul>';
return $result;
}
示例14: folder_export_contents
/**
* Export folder resource contents
*
* @return array of file content
*/
function folder_export_contents($cm, $baseurl)
{
global $CFG, $DB;
$contents = array();
$context = context_module::instance($cm->id);
$folder = $DB->get_record('folder', array('id' => $cm->instance), '*', MUST_EXIST);
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'mod_folder', 'content', 0, 'sortorder DESC, id ASC', false);
foreach ($files as $fileinfo) {
$file = array();
$file['type'] = 'file';
$file['filename'] = $fileinfo->get_filename();
$file['filepath'] = $fileinfo->get_filepath();
$file['filesize'] = $fileinfo->get_filesize();
$file['fileurl'] = file_encode_url("{$CFG->wwwroot}/" . $baseurl, '/' . $context->id . '/mod_folder/content/' . $folder->revision . $fileinfo->get_filepath() . $fileinfo->get_filename(), true);
$file['timecreated'] = $fileinfo->get_timecreated();
$file['timemodified'] = $fileinfo->get_timemodified();
$file['sortorder'] = $fileinfo->get_sortorder();
$file['userid'] = $fileinfo->get_userid();
$file['author'] = $fileinfo->get_author();
$file['license'] = $fileinfo->get_license();
$contents[] = $file;
}
return $contents;
}
示例15: top_promoted_courses
public function top_promoted_courses()
{
global $CFG, $OUTPUT, $DB, $PAGE;
$featuredcontent = '';
/* Get Featured courses id from DB */
$featuredids = theme_pioneer_get_setting('toppromotedcourses');
$rcourseids = !empty($featuredids) ? explode(",", $featuredids, 10) : array();
if (empty($rcourseids)) {
return false;
}
$hcourseids = theme_pioneer_hidden_courses_ids();
if (!empty($hcourseids)) {
foreach ($rcourseids as $key => $val) {
if (in_array($val, $hcourseids)) {
unset($rcourseids[$key]);
}
}
}
foreach ($rcourseids as $key => $val) {
$ccourse = $DB->get_record('course', array('id' => $val));
if (empty($ccourse)) {
unset($rcourseids[$key]);
continue;
}
}
if (empty($rcourseids)) {
return false;
}
$fcourseids = array_chunk($rcourseids, 10);
$totalfcourse = count($fcourseids);
$promotedtitle = theme_pioneer_get_setting('toppromotedtitle', 'format_text');
$promotedtitle = theme_pioneer_lang($promotedtitle);
$closelisting = theme_pioneer_get_setting('topclosefeatured', 'format_text');
$topshowfeatured = theme_pioneer_get_setting('topshowfeatured', 'format_text');
$featuredheader = '<div class="custom-courses-list" id="topPromoted-Courses">
<div class="container-fluid">
<div class="promoted_courses" data-crow="' . $totalfcourse . '">';
$featuredfooter = ' </div>
</div>
</div>';
if (!empty($fcourseids)) {
echo '<div id="featured-listing" class="collapse out">';
echo '<div data-toggle="collapse" data-target="#featured-listing" class="btn-link"style="text-align:center;">' . $closelisting . '</div>';
foreach ($fcourseids as $courseids) {
$rowcontent = '<div><div class="row-fluid topcarousel">';
foreach ($courseids as $courseid) {
$course = get_course($courseid);
$no = get_config('theme_pioneer', 'toppatternselect');
$nimgp = empty($no) || $no == "default" ? 'no-image' : 'cs0' . $no . '/no-image';
$noimgurl = $OUTPUT->pix_url($nimgp, 'theme');
$courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
$imgurl = '';
$summary = theme_pioneer_strip_html_tags($course->summary);
$summary = theme_pioneer_course_trim_char($summary, 125);
$trimtitle = theme_pioneer_course_trim_char($course->fullname, 90);
$context = context_course::instance($course->id);
$nostudents = count_role_users(5, $context);
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$imgurl = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
if (!$isimage) {
$imgurl = $noimgurl;
}
}
if (empty($imgurl)) {
$imgurl = $PAGE->theme->setting_file_url('headerbackgroundimage', 'headerbackgroundimage', true);
if (!$imgurl) {
$imgurl = $noimgurl;
}
}
$listitems = '
<div class="row-fluid">
<div class="span3">
<img src="' . $imgurl . '" width="100%" height="75px" alt="' . $course->fullname . '">
</div>
<div class="span5">
<h5><a href="' . $courseurl . '" >' . $trimtitle . '</a></h5>
</div>
<div class="span4">
<p>' . $summary . '</p>
</div>
</div>';
$coursehtml = '
<div style="background-image: url(' . $imgurl . ');background-repeat: no-repeat;background-size:cover; background-position:center;" class="promowrap">
<div class="fp-coursebox">
<div class="fp-courseinfo">
<p style="font-size:24px;font-weight:bold;"><a href="' . $courseurl . '" id="button" data-toggle="tooltip" data-placement="bottom"title="' . $summary . '" >' . $trimtitle . '</a></p>
<div class="titlebar"> <h5>' . $promotedtitle . '</h5> </div>
<div data-toggle="collapse" data-target="#featured-listing" class="btn-link">' . $topshowfeatured . '</div>
</div>
</div>
</div>';
$rowcontent .= $coursehtml;
echo $listitems;
}
$rowcontent .= '</div></div> ';
//.........这里部分代码省略.........