本文整理汇总了PHP中moodle_url::make_pluginfile_url方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url::make_pluginfile_url方法的具体用法?PHP moodle_url::make_pluginfile_url怎么用?PHP moodle_url::make_pluginfile_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodle_url
的用法示例。
在下文中一共展示了moodle_url::make_pluginfile_url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_badges_list
public function print_badges_list($badges, $userid, $profile = false, $external = false) {
global $USER, $CFG;
foreach ($badges as $badge) {
if (!$external) {
$context = ($badge->type == BADGE_TYPE_SITE) ? context_system::instance() : context_course::instance($badge->courseid);
$bname = $badge->name;
$imageurl = moodle_url::make_pluginfile_url($context->id, 'badges', 'badgeimage', $badge->id, '/', 'f1', false);
} else {
$bname = $badge->assertion->badge->name;
$imageurl = $badge->imageUrl;
}
$name = html_writer::tag('span', $bname, array('class' => 'badge-name'));
$image = html_writer::empty_tag('img', array('src' => $imageurl, 'class' => 'badge-image'));
if (!empty($badge->dateexpire) && $badge->dateexpire < time()) {
$image .= $this->output->pix_icon('i/expired',
get_string('expireddate', 'badges', userdate($badge->dateexpire)),
'moodle',
array('class' => 'expireimage'));
$name .= '(' . get_string('expired', 'badges') . ')';
}
$download = $status = $push = '';
if (($userid == $USER->id) && !$profile) {
$url = new moodle_url('mybadges.php', array('download' => $badge->id, 'hash' => $badge->uniquehash, 'sesskey' => sesskey()));
$notexpiredbadge = (empty($badge->dateexpire) || $badge->dateexpire > time());
$backpackexists = badges_user_has_backpack($USER->id);
if (!empty($CFG->badges_allowexternalbackpack) && $notexpiredbadge && $backpackexists) {
$assertion = new moodle_url('/badges/assertion.php', array('b' => $badge->uniquehash));
$action = new component_action('click', 'addtobackpack', array('assertion' => $assertion->out(false)));
$push = $this->output->action_icon(new moodle_url('#'), new pix_icon('t/backpack', get_string('addtobackpack', 'badges')), $action);
}
$download = $this->output->action_icon($url, new pix_icon('t/download', get_string('download')));
if ($badge->visible) {
$url = new moodle_url('mybadges.php', array('hide' => $badge->issuedid, 'sesskey' => sesskey()));
$status = $this->output->action_icon($url, new pix_icon('t/hide', get_string('makeprivate', 'badges')));
} else {
$url = new moodle_url('mybadges.php', array('show' => $badge->issuedid, 'sesskey' => sesskey()));
$status = $this->output->action_icon($url, new pix_icon('t/show', get_string('makepublic', 'badges')));
}
}
if (!$profile) {
$url = new moodle_url('badge.php', array('hash' => $badge->uniquehash));
} else {
if (!$external) {
$url = new moodle_url('/badges/badge.php', array('hash' => $badge->uniquehash));
} else {
$hash = hash('md5', $badge->hostedUrl);
$url = new moodle_url('/badges/external.php', array('hash' => $hash, 'user' => $userid));
}
}
$actions = html_writer::tag('div', $push . $download . $status, array('class' => 'badge-actions'));
$items[] = html_writer::link($url, $image . $actions . $name, array('title' => $bname));
}
return html_writer::alist($items, array('class' => 'badges'));
}
示例2: output_testimonials
/**
* Construct contents of testimonials block
*
* @param array $products The list of products to be output
* @return string html to be displayed in testimonials block
*/
public function output_testimonials($config, $context)
{
$html = '';
$html = sprintf('<ul class="testimonial__list %s">', (int) $config->enable_rotation === 1 ? 'autoplay' : '');
for ($i = 1; $i <= (int) $config->testimonials_shown; $i++) {
$quote = 'testimonial_quote_' . $i;
$image = 'testimonial_photo_' . $i;
$name = 'testimonial_name_' . $i;
$position = 'testimonial_position_' . $i;
$html .= sprintf('<li class="testimonial__item %s" data-id="%d">', $i === 1 ? 'active' : '', $i);
// Output quote
if (0 < strlen($config->{$quote})) {
$html .= sprintf('<div class="testimonial__quote">%s</div>', $config->{$quote});
}
$html .= '<div class="testimonial__person">';
// Output image
if ((bool) $config->show_image) {
$fs = get_file_storage();
$files = $fs->get_area_files($context->id, 'block_testimonials', 'photo', $config->{$image});
foreach ($files as $file) {
$filename = $file->get_filename();
if ($filename !== '.') {
$url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $filename);
if (!!$url) {
$html .= sprintf('<img class="testimonial__photo" src="%s" alt="%s">', $url, $config->{$name});
}
}
}
}
$html .= '<div class="testimonial__info">';
// Output title
if ((bool) $config->show_name) {
$html .= sprintf('<h3 class="testimonial__name">%s</h3>', $config->{$name});
}
// Output description
if ((bool) $config->show_position) {
$html .= sprintf('<h4 class="testimonial__position">%s</h4>', $config->{$position});
}
$html .= '</div>';
$html .= '</div>';
$html .= '</li>';
}
$html .= '</ul>';
// output pagination
if ((bool) $config->show_pagination) {
$html .= '<ul class="pagination">';
for ($i = 1; $i <= (int) $config->testimonials_shown; $i++) {
$html .= sprintf('<li class="pagination__item %1$s"><a class="pagination__link" data-id="%2$d">%2$d</a></li>', $i === 1 ? 'active' : '', $i);
}
$html .= '</ul>';
}
return $html;
}
示例3: get_site_info
/**
* Return user information including profile picture + basic site information
* Note:
* - no capability checking because we return just known information by logged user
* @param array $serviceshortnames of service shortnames - the functions of these services will be returned
* @return array
*/
public function get_site_info($serviceshortnames = array())
{
global $USER, $SITE, $CFG;
$params = self::validate_parameters(self::get_site_info_parameters(), array('serviceshortnames' => $serviceshortnames));
$profileimageurl = moodle_url::make_pluginfile_url(get_context_instance(CONTEXT_USER, $USER->id)->id, 'user', 'icon', NULL, '/', 'f1');
require_once $CFG->dirroot . "/webservice/lib.php";
$webservice = new webservice();
//If no service listed always return the mobile one by default
if (empty($params['serviceshortnames']) and $CFG->enablewebservices) {
$mobileservice = $webservice->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
if ($mobileservice->enabled) {
$params['serviceshortnames'] = array(MOODLE_OFFICIAL_MOBILE_SERVICE);
//return mobile service by default
}
}
//retrieve the functions related to the services
$functions = $webservice->get_external_functions_by_enabled_services($params['serviceshortnames']);
//built up the returned values of the list of functions
$componentversions = array();
$avalaiblefunctions = array();
foreach ($functions as $function) {
$functioninfo = array();
$functioninfo['name'] = $function->name;
if ($function->component == 'moodle') {
$version = $CFG->version;
//moodle version
} else {
$versionpath = get_component_directory($function->component) . '/version.php';
if (is_readable($versionpath)) {
//we store the component version once retrieved (so we don't load twice the version.php)
if (!isset($componentversions[$function->component])) {
include $versionpath;
$componentversions[$function->component] = $plugin->version;
$version = $plugin->version;
} else {
$version = $componentversions[$function->component];
}
} else {
//function component should always have a version.php,
//otherwise the function should have been described with component => 'moodle'
throw new moodle_exception('missingversionfile', 'webservice', '', $function->component);
}
}
$functioninfo['version'] = $version;
$avalaiblefunctions[] = $functioninfo;
}
return array('sitename' => $SITE->fullname, 'siteurl' => $CFG->wwwroot, 'username' => $USER->username, 'firstname' => $USER->firstname, 'lastname' => $USER->lastname, 'fullname' => fullname($USER), 'userid' => $USER->id, 'userpictureurl' => $profileimageurl->out(false), 'functions' => $avalaiblefunctions);
}
示例4: setInitilizationFile
public function setInitilizationFile($CFG, $DB, $context, $fromform, $incremental, $maxbytes, $folderpath)
{
$this->setSimulationFilePath("");
file_save_draft_area_files($fromform->recordingfile, $context->id, 'atto_ejsapp', 'recordingfiles', $incremental, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1, 'accepted_types' => '.rec'));
$fs = get_file_storage();
if ($files = $fs->get_area_files($context->id, 'atto_ejsapp', 'recordingfiles', $incremental, 'sortorder', false)) {
foreach ($files as $file) {
$fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
$this->setSimulationFilePath($fileurl);
}
}
/*$file_records = $DB->get_records('files', array('contextid'=>$context->id, 'component'=>'atto_ejsapp', 'filearea'=>'recordingfiles', 'itemid'=>$incremental), 'filesize DESC');
$file_record = reset($file_records);
if($file_record) {
$fs = get_file_storage();
$file_state = $fs->get_file_by_id($file_record->id);
$file_state->copy_content_to($folderpath . "simfiles/".$file_record->filename);
$this->setSimulationFilePath($CFG->wwwroot . '/lib/editor/atto/plugins/ejsapp/jarfiles/' . $incremental . "/simfiles/".$file_record->filename);
}*/
}
示例5: get_string
$speakerimg = $whiteboardpath . "images/speakerpressingactive.png";
$audio_tooltip = get_string('disableAudio','virtualclass');
} else {
$dap = "false";
$classes = "audioTool deactive";
//$isplay = false;
$speakermsg = get_string('enablespeaker', 'virtualclass');
$pressingimg = $whiteboardpath . "images/speakerpressing.png";
$audio_tooltip = get_string('enableAudio','virtualclass');
}
// Output starts here.
echo $OUTPUT->header();
// Default image if webcam disable.
if ($USER->id) {
$userpicture = moodle_url::make_pluginfile_url(context_user::instance($USER->id)->id, 'user', 'icon', null, '/', 'f2');
$src = $userpicture->out(false);
} else {
$src = 'bundle/virtualclass/images/quality-support.png';
}
// Javascript variables.
?> <script type="text/javascript">
wbUser.virtualclassPlay = '<?php echo $isplay; ?>';
wbUser.vcSid = '<?php echo $vcSid; ?>';
wbUser.imageurl = '<?php echo $src; ?>';
wbUser.id = '<?php echo $USER->id; ?>';
wbUser.socketOn = '<?php echo $info; ?>';
wbUser.dataInfo = 0; //layout and all inofrmation is not validated since long time
wbUser.room = '<?php echo $course->id . "_" . $cm->id; ?>';
wbUser.sid = '<?php echo $sid; ?>';
示例6: get_enrolled_users
/**
* Get list of course participants.
*
* @param int $courseid
* @param text $withcapability
* @param int $groupid
* @param bool $onlyactive
* @return array of course participants
* @since Moodle 2.0
* @deprecated Moodle 2.2 MDL-29106 - Please do not call this function any more.
* @todo MDL-31194 This will be deleted in Moodle 2.5.
* @see core_enrol_external::get_enrolled_users()
*/
public static function get_enrolled_users($courseid, $withcapability = null, $groupid = null, $onlyactive = false)
{
global $DB, $CFG, $USER;
// Do basic automatic PARAM checks on incoming data, using params description
// If any problems are found then exceptions are thrown with helpful error messages
$params = self::validate_parameters(self::get_enrolled_users_parameters(), array('courseid' => $courseid, 'withcapability' => $withcapability, 'groupid' => $groupid, 'onlyactive' => $onlyactive));
$coursecontext = context_course::instance($params['courseid'], IGNORE_MISSING);
if ($courseid == SITEID) {
$context = context_system::instance();
} else {
$context = $coursecontext;
}
try {
self::validate_context($context);
} catch (Exception $e) {
$exceptionparam = new stdClass();
$exceptionparam->message = $e->getMessage();
$exceptionparam->courseid = $params['courseid'];
throw new moodle_exception('errorcoursecontextnotvalid', 'webservice', '', $exceptionparam);
}
if ($courseid == SITEID) {
require_capability('moodle/site:viewparticipants', $context);
} else {
require_capability('moodle/course:viewparticipants', $context);
}
if ($withcapability) {
require_capability('moodle/role:review', $coursecontext);
}
if ($groupid && groups_is_member($groupid)) {
require_capability('moodle/site:accessallgroups', $coursecontext);
}
if ($onlyactive) {
require_capability('moodle/course:enrolreview', $coursecontext);
}
list($sqlparams, $params) = get_enrolled_sql($coursecontext, $withcapability, $groupid, $onlyactive);
$sql = "SELECT ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id as usercontextid\n FROM {user_enrolments} ue\n JOIN {enrol} e ON (e.id = ue.enrolid)\n JOIN {user} u ON (ue.userid = u.id)\n JOIN {context} c ON (u.id = c.instanceid AND contextlevel = " . CONTEXT_USER . ")\n WHERE e.courseid = :courseid AND ue.userid IN ({$sqlparams})\n GROUP BY ue.userid, e.courseid, u.firstname, u.lastname, u.username, c.id";
$params['courseid'] = $courseid;
$enrolledusers = $DB->get_records_sql($sql, $params);
$result = array();
$isadmin = is_siteadmin($USER);
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($enrolledusers as $enrolleduser) {
$profilimgurl = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f1');
$profilimgurlsmall = moodle_url::make_pluginfile_url($enrolleduser->usercontextid, 'user', 'icon', NULL, '/', 'f2');
$resultuser = array('courseid' => $enrolleduser->courseid, 'userid' => $enrolleduser->userid, 'fullname' => fullname($enrolleduser), 'profileimgurl' => $profilimgurl->out(false), 'profileimgurlsmall' => $profilimgurlsmall->out(false));
// check if we can return username
if ($isadmin) {
$resultuser['username'] = $enrolleduser->username;
}
// check if we can return first and last name
if ($isadmin or $canviewfullnames) {
$resultuser['firstname'] = $enrolleduser->firstname;
$resultuser['lastname'] = $enrolleduser->lastname;
}
$result[] = $resultuser;
}
return $result;
}
示例7: extend_settings_navigation
function extend_settings_navigation($node)
{
global $CFG, $USER, $OUTPUT;
// get users submission if there is one
$submission = $this->get_submission();
if (is_enrolled($this->context, $USER, 'mod/assignment:submit')) {
$editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
} else {
$editable = false;
}
// If the user has submitted something add some related links and data
if (isset($submission->numfiles) and $submission->numfiles) {
// Add a view link to the settings nav
$link = new moodle_url('/mod/assignment/view.php', array('id' => $this->cm->id));
$node->add(get_string('viewmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
if (!empty($submission->timemodified)) {
$submissionnode = $node->add(get_string('submitted', 'assignment') . ' ' . userdate($submission->timemodified));
$submissionnode->text = preg_replace('#([^,])\\s#', '$1 ', $submissionnode->text);
$submissionnode->add_class('note');
if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
$submissionnode->add_class('early');
} else {
$submissionnode->add_class('late');
}
}
}
// Check if the user has uploaded any files, if so we can add some more stuff to the settings nav
if ($submission && is_enrolled($this->context, $USER, 'mod/assignment:submit') && $this->count_user_files($submission->id)) {
$fs = get_file_storage();
if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false)) {
$filenode = $node->add(get_string('submission', 'assignment'));
foreach ($files as $file) {
$filename = $file->get_filename();
$mimetype = $file->get_mimetype();
$link = moodle_url::make_pluginfile_url($this->context->id, 'mod_assignment', 'submission', $submission->id, $file->get_filepath(), $filename);
$filenode->add($filename, $link, navigation_node::TYPE_SETTING, null, null, new pix_icon(file_file_icon($file), ''));
}
}
}
}
示例8: define
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* BC user image location
*
* @package core
* @subpackage file
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('NO_DEBUG_DISPLAY', true);
define('NOMOODLECOOKIE', 1);
require '../config.php';
$PAGE->set_url('/user/pix.php');
$PAGE->set_context(null);
$relativepath = get_file_argument('pix.php');
$args = explode('/', trim($relativepath, '/'));
if (count($args) == 2) {
$userid = (int) $args[0];
if ($args[1] === 'f1.jpg') {
$image = 'f1';
} else {
$image = 'f2';
}
if ($usercontext = get_context_instance(CONTEXT_USER, $userid)) {
$url = moodle_url::make_pluginfile_url($usercontext->id, 'user', 'icon', NULL, '/', $image);
redirect($url);
}
}
redirect($OUTPUT->pix_url('u/f1'));
示例9: admin_externalpage_setup
admin_externalpage_setup('toolgeneratortestplan');
// Start page.
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('maketestplan', 'tool_generator'));
// Information message.
$context = context_system::instance();
$markdownlink = '[' . tool_generator_testplan_backend::get_repourl() . '](' . tool_generator_testplan_backend::get_repourl() . ')';
echo $OUTPUT->box(format_text(get_string('testplanexplanation', 'tool_generator', $markdownlink), FORMAT_MARKDOWN, array('context' => $context)));
// Check debugging is set to DEVELOPER.
if (!debugging('', DEBUG_DEVELOPER)) {
echo $OUTPUT->notification(get_string('error_notdebugging', 'tool_generator'));
echo $OUTPUT->footer();
exit;
}
// Set up the form.
$mform = new tool_generator_make_testplan_form('maketestplan.php');
if ($data = $mform->get_data()) {
// Creating both test plan and users files.
$testplanfile = tool_generator_testplan_backend::create_testplan_file($data->courseid, $data->size);
$usersfile = tool_generator_testplan_backend::create_users_file($data->courseid, $data->updateuserspassword);
// Test plan link.
$testplanurl = moodle_url::make_pluginfile_url($testplanfile->get_contextid(), $testplanfile->get_component(), $testplanfile->get_filearea(), $testplanfile->get_itemid(), $testplanfile->get_filepath(), $testplanfile->get_filename());
echo html_writer::div(html_writer::link($testplanurl, get_string('downloadtestplan', 'tool_generator')));
// Users file link.
$usersfileurl = moodle_url::make_pluginfile_url($usersfile->get_contextid(), $usersfile->get_component(), $usersfile->get_filearea(), $usersfile->get_itemid(), $usersfile->get_filepath(), $usersfile->get_filename());
echo html_writer::div(html_writer::link($usersfileurl, get_string('downloadusersfile', 'tool_generator')));
} else {
// Display form.
$mform->display();
}
echo $OUTPUT->footer();
示例10: get_url
/**
* Works out the URL for the users picture.
*
* This method is recommended as it avoids costly redirects of user pictures
* if requests are made for non-existent files etc.
*
* @param renderer_base $renderer
* @return moodle_url
*/
public function get_url(moodle_page $page, renderer_base $renderer = null)
{
global $CFG, $FULLME;
if (is_null($renderer)) {
$renderer = $page->get_renderer('core');
}
if (!empty($CFG->forcelogin) and !isloggedin()) {
// protect images if login required and not logged in;
// do not use require_login() because it is expensive and not suitable here anyway
return $renderer->pix_url('u/f1');
}
// Sort out the filename and size. Size is only required for the gravatar
// implementation presently.
if (empty($this->size)) {
$filename = 'f2';
$size = 35;
} else {
if ($this->size === true or $this->size == 1) {
$filename = 'f1';
$size = 100;
} else {
if ($this->size >= 50) {
$filename = 'f1';
$size = (int) $this->size;
} else {
$filename = 'f2';
$size = (int) $this->size;
}
}
}
// First we need to determine whether the user has uploaded a profile
// picture of not.
$fs = get_file_storage();
$context = get_context_instance(CONTEXT_USER, $this->user->id);
$hasuploadedfile = $fs->file_exists($context->id, 'user', 'icon', 0, '/', $filename . '/.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', $filename . '/.jpg');
$imageurl = $renderer->pix_url('u/' . $filename);
if ($hasuploadedfile && $this->user->picture == 1) {
$path = '/';
if (clean_param($page->theme->name, PARAM_THEME) == $page->theme->name) {
// We append the theme name to the file path if we have it so that
// in the circumstance that the profile picture is not available
// when the user actually requests it they still get the profile
// picture for the correct theme.
$path .= $page->theme->name . '/';
}
// Set the image URL to the URL for the uploaded file.
$imageurl = moodle_url::make_pluginfile_url($context->id, 'user', 'icon', NULL, $path, $filename);
} else {
if (!empty($CFG->enablegravatar)) {
// Normalise the size variable to acceptable bounds
if ($size < 1 || $size > 512) {
$size = 35;
}
// Hash the users email address
$md5 = md5(strtolower(trim($this->user->email)));
// Build a gravatar URL with what we know.
// If the currently requested page is https then we'll return an
// https gravatar page.
if (strpos($FULLME, 'https://') === 0) {
$imageurl = new moodle_url("https://secure.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $imageurl->out(false)));
} else {
$imageurl = new moodle_url("http://www.gravatar.com/avatar/{$md5}", array('s' => $size, 'd' => $imageurl->out(false)));
}
}
}
// Return the URL that has been generated.
return $imageurl;
}
示例11: my_badges
function my_badges($username, $n = 10)
{
global $CFG;
require_once $CFG->libdir . "/badgeslib.php";
$username = utf8_decode($username);
$username = strtolower($username);
$user = get_complete_user_data('username', $username);
if (!$user) {
return array();
}
$badges = badges_get_user_badges($user->id, NULL, 0, $n);
$bs = array();
foreach ($badges as $badge) {
$b = array();
$b['name'] = $badge->name;
$b['hash'] = $badge->uniquehash;
$context = $badge->type == BADGE_TYPE_SITE ? context_system::instance() : context_course::instance($badge->courseid);
$image_url = moodle_url::make_pluginfile_url($context->id, 'badges', 'badgeimage', $badge->id, '/', 'f1', false);
$b['image_url'] = (string) $image_url;
$bs[] = $b;
}
return $bs;
}
示例12: block_referentiel_get_manage_block_files
function block_referentiel_get_manage_block_files($contextid, $filearea, $docid, $titre, $appli)
{
// retourne la liste des liens vers des fichiers stockes dans le filearea
// propose la suppression
global $CFG;
global $OUTPUT;
$total_size = 0;
$nfile = 0;
// fileareas autorisees
$fileareas = array('referentiel');
if (!in_array($filearea, $fileareas)) {
return false;
}
$strfilepath = 'filepath';
$strfilename = get_string('filename', 'referentiel');
$strfilesize = get_string('filesize', 'referentiel');
$strtimecreated = get_string('timecreated', 'referentiel');
$strtimemodified = get_string('timemodified', 'referentiel');
$strmimetype = get_string('mimetype', 'referentiel');
$strmenu = get_string('delete');
$strurl = get_string('url');
$fs = get_file_storage();
if ($files = $fs->get_area_files($contextid, 'block_referentiel', $filearea, $docid, "timemodified", false)) {
// DEBUG
//print_object($files);
//exit;
$table = new html_table();
$table->head = array($strfilename, $strfilesize, $strtimecreated, $strtimemodified, $strmimetype, $strmenu);
$table->align = array("center", "left", "left", "left", "center");
foreach ($files as $file) {
// print_object($file);
$filesize = $file->get_filesize();
$filename = $file->get_filename();
$mimetype = $file->get_mimetype();
$filepath = $file->get_filepath();
$timecreated = userdate($file->get_timecreated(), "%Y/%m/%d-%H:%M", 99, false);
$timemodified = userdate($file->get_timemodified(), "%Y/%m/%d-%H:%M", 99, false);
$fullpath = '/' . $contextid . '/block_referentiel/' . $filearea . '/' . $docid . $filepath . $filename;
//echo "<br />FULLPATH : ".$fullpath."\n";
//$link1 = new moodle_url($CFG->wwwroot.'/pluginfile.php'.$fullpath);
//echo "<br />LINK1 : ".$link1."\n";
$link = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
// echo "<br />LINK : ".$link."\n";
$url = '<a href="' . $link . '">' . $filename . '</a><br />' . "\n";
$delete_link = '<input type="checkbox" name="deletefile[]" value="' . $fullpath . '" />' . "\n";
$table->data[] = array($url, display_size($filesize), $timecreated, $timemodified, $mimetype, $delete_link);
$total_size += $filesize;
$nfile++;
}
$table->data[] = array(get_string('nbfile', 'referentiel', $nfile), get_string('totalsize', 'referentiel', display_size($total_size)), '', '', '', '');
echo $OUTPUT->box_start('generalbox boxaligncenter');
echo '<div align="center">' . "\n";
echo '<h3>' . $titre . '</h3>' . "\n";
echo '<form method="post" action="' . $appli . '">' . "\n";
echo html_writer::table($table);
echo "\n" . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . "\n";
echo '<input type="submit" value="' . get_string('delete') . '" />' . "\n";
echo '</form>' . "\n";
echo '</div>' . "\n";
echo $OUTPUT->box_end();
}
}
示例13: array
$shown++;
if (floor($shown / $perpage) != $page) {
continue;
}
$actions = array();
$deleteurl = new moodle_url('/mod/emarking/print/orphanpages.php', array('id' => $cm->id, 'delete' => $file->get_id()));
$rotateurl = new moodle_url('/mod/emarking/print/orphanpages.php', array('id' => $cm->id, 'file' => $file->get_id(), 'rotate' => true));
if ($usercanupload) {
$actions[] = $OUTPUT->action_icon($rotateurl, new pix_icon('i/return', get_string('rotatepage', 'mod_emarking')));
$actions[] = $OUTPUT->pix_icon('i/edit', get_string('rotatepage', 'mod_emarking'), '', array('style' => 'cursor:pointer;', 'onclick' => 'showfixform(' . $file->get_id() . ')'));
}
if (isset($file->anonymous)) {
$actions[] = $OUTPUT->action_icon(moodle_url::make_pluginfile_url($context->id, 'mod_emarking', 'orphanpages', $emarking->id, '/', $file->anonymous->get_filename()), new pix_icon('i/show', get_string('anonymousfile', 'mod_emarking')));
}
$actions[] = html_writer::div(html_writer::div(get_string('student', 'grades'), NULL, array('id' => 'error-student-' . $file->get_id())) . html_writer::tag('input', NULL, array('name' => 'student-' . $file->get_id(), 'type' => 'text', 'class' => 'studentname', 'tabindex' => $shown * 2, 'fileid' => $file->get_id())) . '<br/>' . html_writer::div(get_string('page', 'mod_emarking'), NULL, array('id' => 'error-pagenumber-' . $file->get_id())) . html_writer::select($options, 'page-' . $file->get_id(), '', false, array('tabindex' => $shown * 2 + 1, 'id' => 'page-' . $file->get_id())) . '<br/>' . html_writer::tag('button', get_string('cancel'), array('class' => 'btn', 'onclick' => 'return cancelchanges(' . $file->get_id() . ');')) . html_writer::tag('button', get_string('submit'), array('class' => 'btn', 'onclick' => 'return savechanges(' . $file->get_id() . ');')) . html_writer::tag('input', NULL, array('type' => 'hidden', 'name' => 'studentid-' . $file->get_id(), 'id' => 's' . $file->get_id())), 'fixorphanpage', array('id' => 'fix-' . $file->get_id())) . html_writer::div('', '', array('id' => 'content-' . $file->get_id()));
$imgurl = moodle_url::make_pluginfile_url($context->id, 'mod_emarking', 'orphanpages', $emarking->id, '/', $file->get_filename());
$imgurl .= '?r=' . random_string();
$data = array($OUTPUT->action_link($imgurl, html_writer::div(html_writer::img($imgurl, $file->get_filename()), '', array('style' => 'height:100px; overflow:hidden; max-width:600px;'))), implode(' ', $actions));
if ($usercanupload) {
$data[] = html_writer::checkbox('d[]', $file->get_id(), false, '');
}
$table->data[] = $data;
}
echo html_writer::table($table);
echo $OUTPUT->paging_bar($numorphanpages, $page, $perpage, $url);
if ($usercanupload) {
echo html_writer::start_tag('input', array('type' => 'submit', 'value' => get_string('deleteselectedpages', 'mod_emarking'), 'style' => 'float:right;'));
echo "</form>";
}
}
$students = get_enrolled_users($context, 'mod/emarking:submit');
示例14: __construct
/**
* Constructor.
*
* @param array $params The fields to initialise the renderable.
*/
public function __construct(array $params)
{
global $OUTPUT;
$diff = array_diff_key($params, array_flip(self::$required));
if (count($diff) > 0) {
throw new coding_exception('Missing, or unexpected, properties');
}
// Assigning the properties.
foreach ($params as $key => $value) {
if (in_array($key, self::$required)) {
$this->{$key} = $value;
}
}
// Has next level.
if (!empty($this->nextlevelxp) && $this->nextlevelxp > $this->xp) {
$this->hasnextlevel = true;
$this->nextlevel = $this->level + 1;
// Percentage.
$this->xpinlevel = $this->xp - $this->levelxp;
$this->xpforlevel = $this->nextlevelxp - $this->levelxp;
$this->percentage = round($this->xpinlevel / $this->xpforlevel * 100);
} else {
$this->nextlevel = null;
$this->hasnextlevel = true;
$this->xpforlevel = $this->xp;
$this->xpinlevel = $this->xp;
$this->percentage = 100;
}
// Image URL.
$this->levelimgsrc = moodle_url::make_pluginfile_url(context_course::instance($this->courseid)->id, 'block_xp', 'badges', 0, '/', $this->level);
}
示例15: get_url
/**
* Works out the URL for the users picture.
*
* This method is recommended as it avoids costly redirects of user pictures
* if requests are made for non-existent files etc.
*
* @param moodle_page $page
* @param renderer_base $renderer
* @return moodle_url
*/
public function get_url(moodle_page $page, renderer_base $renderer = null)
{
global $CFG;
if (is_null($renderer)) {
$renderer = $page->get_renderer('core');
}
// Sort out the filename and size. Size is only required for the gravatar
// implementation presently.
if (empty($this->size)) {
$filename = 'f2';
$size = 35;
} else {
if ($this->size === true or $this->size == 1) {
$filename = 'f1';
$size = 100;
} else {
if ($this->size > 100) {
$filename = 'f3';
$size = (int) $this->size;
} else {
if ($this->size >= 50) {
$filename = 'f1';
$size = (int) $this->size;
} else {
$filename = 'f2';
$size = (int) $this->size;
}
}
}
}
$defaulturl = $renderer->pix_url('u/' . $filename);
// default image
if ((!empty($CFG->forcelogin) and !isloggedin()) || !empty($CFG->forceloginforprofileimage) && (!isloggedin() || isguestuser())) {
// Protect images if login required and not logged in;
// also if login is required for profile images and is not logged in or guest
// do not use require_login() because it is expensive and not suitable here anyway.
return $defaulturl;
}
// First try to detect deleted users - but do not read from database for performance reasons!
if (!empty($this->user->deleted) or strpos($this->user->email, '@') === false) {
// All deleted users should have email replaced by md5 hash,
// all active users are expected to have valid email.
return $defaulturl;
}
// Did the user upload a picture?
if ($this->user->picture > 0) {
if (!empty($this->user->contextid)) {
$contextid = $this->user->contextid;
} else {
$context = context_user::instance($this->user->id, IGNORE_MISSING);
if (!$context) {
// This must be an incorrectly deleted user, all other users have context.
return $defaulturl;
}
$contextid = $context->id;
}
$path = '/';
if (clean_param($page->theme->name, PARAM_THEME) == $page->theme->name) {
// We append the theme name to the file path if we have it so that
// in the circumstance that the profile picture is not available
// when the user actually requests it they still get the profile
// picture for the correct theme.
$path .= $page->theme->name . '/';
}
// Set the image URL to the URL for the uploaded file and return.
$url = moodle_url::make_pluginfile_url($contextid, 'user', 'icon', NULL, $path, $filename);
$url->param('rev', $this->user->picture);
return $url;
}
if ($this->user->picture == 0 and !empty($CFG->enablegravatar)) {
// Normalise the size variable to acceptable bounds
if ($size < 1 || $size > 512) {
$size = 35;
}
// Hash the users email address
$md5 = md5(strtolower(trim($this->user->email)));
// Build a gravatar URL with what we know.
// Find the best default image URL we can (MDL-35669)
if (empty($CFG->gravatardefaulturl)) {
$absoluteimagepath = $page->theme->resolve_image_location('u/' . $filename, 'core');
if (strpos($absoluteimagepath, $CFG->dirroot) === 0) {
$gravatardefault = $CFG->wwwroot . substr($absoluteimagepath, strlen($CFG->dirroot));
} else {
$gravatardefault = $CFG->wwwroot . '/pix/u/' . $filename . '.png';
}
} else {
$gravatardefault = $CFG->gravatardefaulturl;
}
// If the currently requested page is https then we'll return an
// https gravatar page.
//.........这里部分代码省略.........