本文整理汇总了PHP中moodle_url::param方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url::param方法的具体用法?PHP moodle_url::param怎么用?PHP moodle_url::param使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodle_url
的用法示例。
在下文中一共展示了moodle_url::param方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_replacements
/**
*
*/
public function get_replacements(array $patterns, $entry = null, array $options = array())
{
global $CFG, $OUTPUT;
$replacements = parent::get_replacements($patterns, $entry, $options);
$view = $this->_view;
$df = $view->get_df();
$filter = $view->get_filter();
$baseurl = new moodle_url($view->get_baseurl());
$baseurl->param('sesskey', sesskey());
foreach ($patterns as $pattern) {
switch ($pattern) {
case '##exportall##':
$actionurl = new moodle_url($baseurl, array('pdfexportall' => true));
$label = html_writer::tag('span', get_string('exportall', 'dataformview_pdf'));
$replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportall'));
break;
case '##exportpage##':
$actionurl = new moodle_url($baseurl, array('pdfexportpage' => true));
$label = html_writer::tag('span', get_string('exportpage', 'dataformview_pdf'));
$replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportpage'));
break;
case '##pagebreak##':
$replacements[$pattern] = $view::PAGE_BREAK;
break;
}
}
return $replacements;
}
示例2: local_loginas_extends_settings_navigation
/**
* Adds module specific settings to the settings block.
*
* @param settings_navigation $settings The settings navigation object
* @param stdClass $context The node context
*/
function local_loginas_extends_settings_navigation(settings_navigation $settings, $context)
{
global $DB, $CFG, $PAGE, $USER;
// Course id and context.
$courseid = !empty($PAGE->course->id) ? $PAGE->course->id : SITEID;
$coursecontext = context_course::instance($courseid);
// Must have the loginas capability.
if (!has_capability('moodle/user:loginas', $coursecontext)) {
return;
}
// Set the settings category.
$loginas = $settings->add(get_string('loginas'));
// Login as list by admin setting.
if (is_siteadmin($USER)) {
// Admin settings page.
$url = new moodle_url('/admin/settings.php', array('section' => 'localsettingloginas'));
$loginas->add(get_string('settings'), $url, $settings::TYPE_SETTING);
// Users list.
$loginasusers = array();
// Since 2.6, use all the required fields.
$ufields = 'id, ' . get_all_user_name_fields(true);
// Get users by id.
if ($configuserids = get_config('local_loginas', 'loginasusers')) {
$userids = explode(',', $configuserids);
if ($users = $DB->get_records_list('user', 'id', $userids, '', $ufields)) {
$loginasusers = $users;
}
}
// Get users by username.
if ($configusernames = get_config('local_loginas', 'loginasusernames')) {
$usernames = explode(',', $configusernames);
if ($users = $DB->get_records_list('user', 'username', $usernames, '', $ufields)) {
$loginasusers = $loginasusers + $users;
}
}
// Add action links for specified users.
if ($loginasusers) {
$params = array('id' => $courseid, 'sesskey' => sesskey());
foreach ($loginasusers as $userid => $lauser) {
$url = new moodle_url('/course/loginas.php', $params);
$url->param('user', $userid);
$loginas->add(fullname($lauser, true), $url, $settings::TYPE_SETTING);
}
}
}
// Course users login as.
if (!($configcourseusers = get_config('local_loginas', 'courseusers'))) {
return;
}
$loggedinas = \core\session\manager::is_loggedinas();
if (!$loggedinas) {
// Ajax link.
$node = $loginas->add(get_string('courseusers', 'local_loginas'), 'javascript:void();', $settings::TYPE_SETTING);
$node->add_class('local_loginas_setting_link');
local_loginas_require_js($PAGE);
}
}
示例3: add_modchoosertoggle
/**
* Adds the item in course settings navigation to toggle modchooser
*
* Theme can overwrite as an empty function to exclude it (for example if theme does not
* use modchooser at all)
*/
protected function add_modchoosertoggle()
{
global $CFG;
static $modchoosertoggleadded = false;
// Add the module chooser toggle to the course page
if ($modchoosertoggleadded || $this->page->state > moodle_page::STATE_PRINTING_HEADER || $this->page->course->id == SITEID || !$this->page->user_is_editing() || !($context = context_course::instance($this->page->course->id)) || !has_capability('moodle/course:update', $context) || !course_ajax_enabled($this->page->course) || !($coursenode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) || !$coursenode->get('editsettings')) {
// too late or we are on site page or we could not find the course settings node
// or we are not allowed to edit
return;
}
$modchoosertoggleadded = true;
if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
// We are on the course page, retain the current page params e.g. section.
$modchoosertoggleurl = clone $this->page->url;
} else {
// Edit on the main course page.
$modchoosertoggleurl = new moodle_url('/course/view.php', array('id' => $this->page->course->id, 'return' => $this->page->url->out_as_local_url(false)));
}
$modchoosertoggleurl->param('sesskey', sesskey());
if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
$modchoosertogglestring = get_string('modchooserdisable', 'moodle');
$modchoosertoggleurl->param('modchooser', 'off');
} else {
$modchoosertogglestring = get_string('modchooserenable', 'moodle');
$modchoosertoggleurl->param('modchooser', 'on');
}
$modchoosertoggle = navigation_node::create($modchoosertogglestring, $modchoosertoggleurl, navigation_node::TYPE_SETTING);
$coursenode->add_node($modchoosertoggle, 'editsettings');
$modchoosertoggle->add_class('modchoosertoggle');
$modchoosertoggle->add_class('visibleifjs');
user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
}
示例4: run_all_tests_for_context
/**
* Run all the question tests for all variants of all questions belonging to
* a given context.
*
* Does output as we go along.
*
* @param context $context the context to run the tests for.
* @return array with two elements:
* bool true if all the tests passed, else false.
* array of messages relating to the questions with failures.
*/
public function run_all_tests_for_context(context $context)
{
global $DB, $OUTPUT;
// Load the necessary data.
$categories = question_category_options(array($context));
$categories = reset($categories);
$questiontestsurl = new moodle_url('/question/type/stack/questiontestrun.php');
if ($context->contextlevel == CONTEXT_COURSE) {
$questiontestsurl->param('courseid', $context->instanceid);
} else {
if ($context->contextlevel == CONTEXT_MODULE) {
$questiontestsurl->param('cmid', $context->instanceid);
}
}
$allpassed = true;
$failingtests = array();
foreach ($categories as $key => $category) {
list($categoryid) = explode(',', $key);
echo $OUTPUT->heading($category, 3);
$questionids = $DB->get_records_menu('question', array('category' => $categoryid, 'qtype' => 'stack'), 'name', 'id,name');
if (!$questionids) {
continue;
}
echo html_writer::tag('p', stack_string('replacedollarscount', count($questionids)));
foreach ($questionids as $questionid => $name) {
$tests = question_bank::get_qtype('stack')->load_question_tests($questionid);
if (!$tests) {
echo $OUTPUT->heading(html_writer::link(new moodle_url($questiontestsurl, array('questionid' => $questionid)), format_string($name)), 4);
echo html_writer::tag('p', stack_string('bulktestnotests'));
continue;
}
$question = question_bank::load_question($questionid);
$questionname = format_string($name);
$previewurl = new moodle_url($questiontestsurl, array('questionid' => $questionid));
if (empty($question->deployedseeds)) {
$questionnamelink = html_writer::link($previewurl, $questionname);
echo $OUTPUT->heading($questionnamelink, 4);
list($ok, $message) = $this->qtype_stack_test_question($question, $tests);
if (!$ok) {
$allpassed = false;
$failingtests[] = $questionnamelink . ': ' . $message;
}
} else {
echo $OUTPUT->heading(format_string($name), 4);
foreach ($question->deployedseeds as $seed) {
$previewurl->param('seed', $seed);
$questionnamelink = html_writer::link($previewurl, stack_string('seedx', $seed));
echo $OUTPUT->heading($questionnamelink, 4);
list($ok, $message) = $this->qtype_stack_test_question($question, $tests, $seed);
if (!$ok) {
$allpassed = false;
$failingtests[] = $questionname . ' ' . $questionnamelink . ': ' . $message;
}
}
}
}
}
return array($allpassed, $failingtests);
}
示例5: get_url
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url()
{
$url = new \moodle_url("/mod/treasurehunt/view.php", array('id' => $this->contextinstanceid));
if (!empty($this->other['groupid'])) {
$url->param('groupid', $this->other['groupid']);
} else {
$url->param('userid', $this->userid);
}
return $url;
}
示例6: __construct
/**
* Constructor
*
* @param int $repositoryid
* @param stdClass $context
* @param array $options
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
{
parent::__construct($repositoryid, $context, $options);
$clientid = get_config('boxnet', 'clientid');
$clientsecret = get_config('boxnet', 'clientsecret');
$returnurl = new moodle_url('/repository/repository_callback.php');
$returnurl->param('callback', 'yes');
$returnurl->param('repo_id', $this->id);
$returnurl->param('sesskey', sesskey());
$this->boxnetclient = new boxnet_client($clientid, $clientsecret, $returnurl, '');
}
示例7: __construct
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
{
parent::__construct($repositoryid, $context, $options);
$returnurl = new moodle_url('/repository/repository_callback.php');
$returnurl->param('callback', 'yes');
$returnurl->param('repo_id', $this->id);
$returnurl->param('sesskey', sesskey());
$clientid = get_config('googledocs', 'clientid');
$secret = get_config('googledocs', 'secret');
$this->googleoauth = new google_oauth($clientid, $secret, $returnurl, google_docs::REALM);
$this->check_login();
}
示例8: __construct
/**
* Constructor
*
* @param int $repositoryid repository instance id.
* @param int|stdClass $context a context id or context object.
* @param array $options repository options.
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
{
parent::__construct($repositoryid, $context, $options);
$clientid = get_config('skydrive', 'clientid');
$secret = get_config('skydrive', 'secret');
$returnurl = new moodle_url('/repository/repository_callback.php');
$returnurl->param('callback', 'yes');
$returnurl->param('repo_id', $this->id);
$returnurl->param('sesskey', sesskey());
$this->skydrive = new microsoft_skydrive($clientid, $secret, $returnurl);
$this->check_login();
}
示例9: definition
public function definition()
{
global $USER, $OUTPUT, $CFG;
$mform = $this->_form;
$instance = $this->_customdata;
$this->instance = $instance;
$plugin = enrol_get_plugin('boleto');
$heading = $plugin->get_instance_name($instance);
$mform->addElement('header', 'boletoheader', $heading);
if ($instance->password) {
// Change the id of boleto enrolment key input as there can be multiple boleto enrolment methods.
$mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_boleto'), array('id' => 'enrolpassword_' . $instance->id));
$context = context_course::instance($this->instance->courseid);
$keyholders = get_users_by_capability($context, 'enrol/boleto:holdkey', user_picture::fields('u'));
$keyholdercount = 0;
foreach ($keyholders as $keyholder) {
$keyholdercount++;
if ($keyholdercount === 1) {
$mform->addElement('static', 'keyholder', '', get_string('keyholder', 'enrol_boleto'));
}
$keyholdercontext = context_user::instance($keyholder->id);
if ($USER->id == $keyholder->id || has_capability('moodle/user:viewdetails', context_system::instance()) || has_coursecontact_role($keyholder->id)) {
$profilelink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $keyholder->id . '&course=' . $this->instance->courseid . '">' . fullname($keyholder) . '</a>';
} else {
$profilelink = fullname($keyholder);
}
$profilepic = $OUTPUT->user_picture($keyholder, array('size' => 35, 'courseid' => $this->instance->courseid));
$mform->addElement('static', 'keyholder' . $keyholdercount, '', $profilepic . $profilelink);
}
}
$boletourl = new moodle_url('/enrol/boleto/boleto.php', array('instanceid' => $this->instance->id));
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfo', 'enrol_boleto'));
// customint8 == avista.
if ($this->instance->customint8) {
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfodirectlinks', 'enrol_boleto', $boletourl->out(false)));
} else {
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink0', 'enrol_boleto', $boletourl->out(false)));
$boletourl->param('parcela', 1);
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink1', 'enrol_boleto', $boletourl->out(false)));
$boletourl->param('parcela', 2);
$mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink2', 'enrol_boleto', $boletourl->out(false)));
}
$this->add_action_buttons(false, get_string('enrolme', 'enrol_boleto'));
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->setDefault('id', $instance->courseid);
$mform->addElement('hidden', 'instance');
$mform->setType('instance', PARAM_INT);
$mform->setDefault('instance', $instance->id);
}
示例10: edit_button
/**
* Returns HTML to display a "Turn editing on/off" button in a form.
*
* @param moodle_url $url The URL + params to send through when clicking the button
* @return string HTML the button
* Written by G J Barnard
*/
public function edit_button(moodle_url $url)
{
$url->param('sesskey', sesskey());
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
$btn = 'btn-danger';
$title = get_string('turneditingoff');
$icon = 'fa-power-off';
} else {
$url->param('edit', 'on');
$btn = 'btn-success';
$title = get_string('turneditingon');
$icon = 'fa-edit';
}
return html_writer::tag('a', html_writer::start_tag('i', array('class' => $icon . ' fa fa-fw')) . html_writer::end_tag('i') . $title, array('href' => $url, 'class' => 'btn ' . $btn, 'title' => $title));
}
示例11: update_questionbank
function update_questionbank()
{
global $USER, $FULLME;
$myurl = new moodle_url($FULLME);
$myurl->param('first', 'second');
//print_object($myurl->get_query_string());
//notice('die please');
$qid = optional_param('qid', null);
$theQuestion = optional_param('question', null);
if (empty($theQuestion)) {
return;
}
$question = get_record('memorybank_bank', 'id', $qid);
print_object($question);
$question->question = optional_param('question', null);
$question->answer = optional_param('answer', null);
$question->reference = optional_param('reference', null);
$question->initialgrade = optional_param('initialgrade', 4);
$question->category = optional_param('category', 0);
$question->visible = optional_param('visible', 0);
$initviewtime = optional_param('initviewtime', 0);
$question->initviewtime = make_timestamp($initviewtime['year'], $initviewtime['month'], $initviewtime['day'], $initviewtime['hour'], $initviewtime['minute']);
$question->modifiedby = $USER->id;
$question->timemodified = time();
print_object($question);
update_record('memorybank_bank', $question);
}
示例12: get_url
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url()
{
$url = new \moodle_url('/mod/twf/user.php', array('id' => $this->relateduserid, 'mode' => $this->other['reportmode']));
if ($this->courseid != SITEID) {
$url->param('course', $this->courseid);
}
return $url;
}
示例13: redirect
/**
* Add question-type specific form fields.
*
* @param object $mform the form being built.
*/
function definition_inner($mform)
{
global $CFG;
//redirct to the new ordering question type
$orderingurl = new moodle_url($CFG->wwwroot . '/question/question.php', $_GET);
$orderingurl->param('qtype', 'ordering');
redirect($orderingurl, 'This question type is deprecated. Redirection to new question ordering', 3);
}
示例14: list_boletos
public function list_boletos($boletos, $course)
{
$boletourl = new moodle_url('/enrol/boleto/boleto.php');
$content = html_writer::tag('h2', get_string('viewboleto', 'enrol_boleto'));
$content .= html_writer::tag('p', get_string('viewandprintinfo', 'enrol_boleto'));
if (count($boletos) > 1) {
foreach ($boletos as $boleto) {
$boletourl->param('id', $boleto->id);
$content .= html_writer::tag('p', get_string('boletoprintandpayinfoparceladolink' . $boleto->parcela, 'enrol_boleto', $boletourl->out(false)));
}
} else {
$boleto = array_pop($boletos);
$boletourl->param('id', $boleto->id);
$content .= html_writer::tag('p', get_string('boletoprintandpayinfodirectlink', 'enrol_boleto', $boletourl->out(false)));
}
return $content;
}
示例15: set_permalink
/**
* Prepare permanent link for the given filter data
*
* @param moodle_url $baseurl
* @param stdClass $fdata as returned by {@see self::get_data()}
* @return moodle_url $permalink
*/
public function set_permalink(moodle_url $baseurl, stdClass $fdata)
{
$this->permalink = new moodle_url($baseurl, array('t' => time()));
$this->permalink->param('v', implode(',', $fdata->version));
// list of languages or '*' if all are selected
$all = mlang_tools::list_languages(false);
foreach ($fdata->language as $selected) {
unset($all[$selected]);
}
if (empty($all)) {
$this->permalink->param('l', '*');
} else {
$this->permalink->param('l', implode(',', $fdata->language));
}
unset($all);
// list of components or '*' if all are selected
$all = mlang_tools::list_components();
foreach ($fdata->component as $selected) {
unset($all[$selected]);
}
if (empty($all)) {
$this->permalink->param('c', '*');
} else {
$this->permalink->param('c', implode(',', $fdata->component));
}
unset($all);
// substring and stringid
$this->permalink->param('s', $fdata->substring);
$this->permalink->param('d', $fdata->stringid);
// checkboxes
if ($fdata->missing) {
$this->permalink->param('m', 1);
}
if ($fdata->helps) {
$this->permalink->param('h', 1);
}
if ($fdata->substringregex) {
$this->permalink->param('r', 1);
}
if ($fdata->substringcs) {
$this->permalink->param('i', 1);
}
if ($fdata->stringidpartial) {
$this->permalink->param('p', 1);
}
if ($fdata->stagedonly) {
$this->permalink->param('g', 1);
}
if ($fdata->greylistedonly) {
$this->permalink->param('o', 1);
}
if ($fdata->withoutgreylisted) {
$this->permalink->param('w', 1);
}
return $this->permalink;
}