本文整理汇总了PHP中moodle_url类的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url类的具体用法?PHP moodle_url怎么用?PHP moodle_url使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了moodle_url类的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: i_view_the_lightboxgallery_with_idnumber
/**
* Allow a gallery to be viewed just by knowing its idnumber.
* This is a helper function to jump to a gallery without going throught
* the course page, simulating the case where the user knows the URL but
* can't go through the course (ispublic flag is set).
*
* @Given /^I view the lightboxgallery with idnumber "(?P<lightboxgallery_idnumber>(?:[^"]|\\")*)"$/
* @param string $idnumber
*/
public function i_view_the_lightboxgallery_with_idnumber($idnumber)
{
global $DB;
$sql = "SELECT cm.id\n FROM {course_modules} cm\n JOIN {modules} m ON m.id = cm.module\n WHERE m.name = 'lightboxgallery' AND cm.idnumber = ?";
$cm = $DB->get_record_sql($sql, [$idnumber]);
$href = new moodle_url('/mod/lightboxgallery/view.php', ['id' => $cm->id]);
$this->getSession()->visit($href->out());
}
示例3: 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);
}
}
示例4: __construct
/**
* Constructor.
* @param Command $command The Command to link to the form.
* @param int $mode The form mode.
*/
public function __construct(Command $command, $mode)
{
// Checking command.
if (is_null($command)) {
throw new Command_Exception('commandformnotlinked');
}
// Linking the command and her category.
$this->command = $command;
// Setting configuration.
$this->mode = $mode;
// Setting form action.
switch ($mode) {
case self::MODE_COMMAND_CHOICE:
$url = new moodle_url('/local/vmoodle/view.php', array('view' => 'sadmin', 'what' => 'validateassistedcommand'));
break;
case self::MODE_RETRIEVE_PLATFORM:
$url = new moodle_url('/local/vmoodle/view.php', array('view' => 'sadmin', 'what' => 'gettargetbyvalue'));
break;
case self::MODE_DISPLAY_COMMAND:
$url = new moodle_url('/local/vmoodle/view.php', array('view' => 'targetchoice'));
break;
default:
throw new Command_Exception('badformmode');
break;
}
// Calling parent's constructor.
parent::__construct($url->out());
}
示例5: 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);
}
示例6: 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 '';
}
$browser = get_file_browser();
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle');
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename'));
$filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon'));
$result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir));
}
foreach ($dir['files'] as $file) {
$fileinfo = $browser->get_file_info($tree->context, $file->get_component(),
$file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
$url = $fileinfo->get_url(true);
$filename = $file->get_filename();
if ($imageinfo = $fileinfo->get_imageinfo()) {
$fileurl = new moodle_url($fileinfo->get_url());
$image = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $fileinfo->get_timemodified()));
$image = html_writer::empty_tag('img', array('src' => $image));
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle');
}
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $filename, array('class' => 'fp-filename'));
$filename = html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'fp-filename-icon'));
$result .= html_writer::tag('li', $filename);
}
$result .= '</ul>';
return $result;
}
示例7: destination_courses_selector
public function destination_courses_selector(moodle_url $nextstageurl, destination_courses_search $courses = null, $courseid)
{
$html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore'));
$html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring()));
foreach ($nextstageurl->params() as $key => $value) {
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
$html .= html_writer::start_tag('div', array('class' => 'ics-existing-group backup-section'));
$html .= $this->output->heading(get_string('selectgroups', 'local_syncgroups'), 2, array('class' => 'header'));
$html .= html_writer::start_tag('ul');
$groups = groups_get_all_groups($courseid, 0, 0, 'g.id, g.name');
foreach ($groups as $group) {
$html .= html_writer::start_tag('li') . html_writer::checkbox('groups[]', $group->id, false, $group->name) . html_writer::end_tag('li');
}
$html .= html_writer::end_tag('ul');
$html .= html_writer::end_tag('div');
// We only allow import adding for now. Enforce it here.
$html .= html_writer::start_tag('div', array('class' => 'ics-existing-course backup-section'));
$html .= $this->output->heading(get_string('syncgroupsto', 'local_syncgroups'), 2, array('class' => 'header'));
$html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
$html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue'))));
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('form');
$html .= html_writer::end_tag('div');
return $html;
}
示例8: build_editform
function build_editform($item, $feedback, $cm)
{
global $DB;
$editurl = new moodle_url('/mod/feedback/edit.php', array('id' => $cm->id));
//ther are no settings for recaptcha
if (isset($item->id) and $item->id > 0) {
notice(get_string('there_are_no_settings_for_recaptcha', 'feedback'), $editurl->out());
exit;
}
//only one recaptcha can be in a feedback
if ($DB->record_exists('feedback_item', array('feedback' => $feedback->id, 'typ' => $this->type))) {
notice(get_string('only_one_captcha_allowed', 'feedback'), $editurl->out());
exit;
}
$this->item = $item;
$this->feedback = $feedback;
$this->item_form = true;
//dummy
$lastposition = $DB->count_records('feedback_item', array('feedback' => $feedback->id));
$this->item->feedback = $feedback->id;
$this->item->template = 0;
$this->item->name = get_string('captcha', 'feedback');
$this->item->label = get_string('captcha', 'feedback');
$this->item->presentation = '';
$this->item->typ = $this->type;
$this->item->hasvalue = $this->get_hasvalue();
$this->item->position = $lastposition + 1;
$this->item->required = 1;
$this->item->dependitem = 0;
$this->item->dependvalue = '';
$this->item->options = '';
}
示例9: ajax_get_lib
/**
* Get the path to a JavaScript library.
* @param $libname - the name of the library whose path we need.
* @return string
*/
function ajax_get_lib($libname)
{
global $CFG, $HTTPSPAGEREQUIRED;
$libpath = '';
$translatelist = array('yui_yahoo' => '/lib/yui/yahoo/yahoo-min.js', 'yui_animation' => '/lib/yui/animation/animation-min.js', 'yui_autocomplete' => '/lib/yui/autocomplete/autocomplete-min.js', 'yui_button' => '/lib/yui/button/button-min.js', 'yui_calendar' => '/lib/yui/calendar/calendar-min.js', 'yui_charts' => '/lib/yui/charts/charts-experimental-min.js', 'yui_colorpicker' => '/lib/yui/colorpicker/colorpicker-min.js', 'yui_connection' => '/lib/yui/connection/connection-min.js', 'yui_container' => '/lib/yui/container/container-min.js', 'yui_cookie' => '/lib/yui/cookie/cookie-min.js', 'yui_datasource' => '/lib/yui/datasource/datasource-min.js', 'yui_datatable' => '/lib/yui/datatable/datatable-min.js', 'yui_dom' => '/lib/yui/dom/dom-min.js', 'yui_dom-event' => '/lib/yui/yahoo-dom-event/yahoo-dom-event.js', 'yui_dragdrop' => '/lib/yui/dragdrop/dragdrop-min.js', 'yui_editor' => '/lib/yui/editor/editor-min.js', 'yui_element' => '/lib/yui/element/element-beta-min.js', 'yui_event' => '/lib/yui/event/event-min.js', 'yui_get' => '/lib/yui/get/get-min.js', 'yui_history' => '/lib/yui/history/history-min.js', 'yui_imagecropper' => '/lib/yui/imagecropper/imagecropper-beta-min.js', 'yui_imageloader' => '/lib/yui/imageloader/imageloader-min.js', 'yui_json' => '/lib/yui/json/json-min.js', 'yui_layout' => '/lib/yui/layout/layout-min.js', 'yui_logger' => '/lib/yui/logger/logger-min.js', 'yui_menu' => '/lib/yui/menu/menu-min.js', 'yui_profiler' => '/lib/yui/profiler/profiler-min.js', 'yui_profilerviewer' => '/lib/yui/profilerviewer/profilerviewer-beta-min.js', 'yui_resize' => '/lib/yui/resize/resize-min.js', 'yui_selector' => '/lib/yui/selector/selector-beta-min.js', 'yui_simpleeditor' => '/lib/yui/editor/simpleeditor-min.js', 'yui_slider' => '/lib/yui/slider/slider-min.js', 'yui_tabview' => '/lib/yui/tabview/tabview-min.js', 'yui_treeview' => '/lib/yui/treeview/treeview-min.js', 'yui_uploader' => '/lib/yui/uploader/uploader-experimental-min.js', 'yui_utilities' => '/lib/yui/utilities/utilities.js', 'yui_yuiloader' => '/lib/yui/yuiloader/yuiloader-min.js', 'yui_yuitest' => '/lib/yui/yuitest/yuitest-min.js', 'ajaxcourse_blocks' => '/lib/ajax/block_classes.js', 'ajaxcourse_sections' => '/lib/ajax/section_classes.js', 'ajaxcourse' => '/lib/ajax/ajaxcourse.js');
if (!empty($HTTPSPAGEREQUIRED)) {
$wwwroot = $CFG->httpswwwroot;
} else {
$wwwroot = $CFG->wwwroot;
}
if (array_key_exists($libname, $translatelist)) {
$libpath = $wwwroot . $translatelist[$libname];
} else {
$libpath = $libname;
}
// query strings break file_exists so remove it
$url = new moodle_url($libpath);
$modifiedlibpath = $url->out(true);
$testpath = str_replace($wwwroot, $CFG->dirroot, $modifiedlibpath);
if (stripos($libpath, $CFG->wwwroot) === false && stripos($libpath, $CFG->dirroot) === false) {
// offsite so just link it
} elseif (!file_exists($testpath)) {
error('require_js: ' . $libpath . ' - file not found.');
}
return $libpath;
}
示例10: setup_page
/**
* Sets up the edit page
*
* @param string $baseurl the base url of the
*
* @return array Array of variables that the page is set up with
*/
public function setup_page($baseurl)
{
global $PAGE, $CFG, $DB;
$this->pagevars = array();
$pageurl = new \moodle_url($baseurl);
$pageurl->remove_all_params();
$id = optional_param('cmid', false, PARAM_INT);
$quizid = optional_param('quizid', false, PARAM_INT);
// get necessary records from the DB
if ($id) {
$cm = get_coursemodule_from_id('activequiz', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$quiz = $DB->get_record('activequiz', array('id' => $cm->instance), '*', MUST_EXIST);
} else {
$quiz = $DB->get_record('activequiz', array('id' => $quizid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('activequiz', $quiz->id, $course->id, false, MUST_EXIST);
}
$this->get_parameters();
// get the rest of the parameters and set them in the class
if ($CFG->version < 2011120100) {
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
} else {
$this->context = \context_module::instance($cm->id);
}
// set up question lib
list($this->pageurl, $this->contexts, $cmid, $cm, $quiz, $this->pagevars) = question_edit_setup('editq', '/mod/activequiz/edit.php', true);
$PAGE->set_url($this->pageurl);
$this->pagevars['pageurl'] = $this->pageurl;
$PAGE->set_title(strip_tags($course->shortname . ': ' . get_string("modulename", "activequiz") . ': ' . format_string($quiz->name, true)));
$PAGE->set_heading($course->fullname);
// setup classes needed for the edit page
$this->RTQ = new \mod_activequiz\activequiz($cm, $course, $quiz, $this->pagevars);
$this->RTQ->get_renderer()->init($this->RTQ, $this->pageurl, $this->pagevars);
}
示例11: get_progress_bar
/**
* Customises the backup progress bar
*
* @global moodle_page $PAGE
* @return array
*/
public function get_progress_bar()
{
global $PAGE;
$stage = self::STAGE_COMPLETE;
$currentstage = $this->stage->get_stage();
$items = array();
while ($stage > 0) {
$classes = array('backup_stage');
if (floor($stage / 2) == $currentstage) {
$classes[] = 'backup_stage_next';
} else {
if ($stage == $currentstage) {
$classes[] = 'backup_stage_current';
} else {
if ($stage < $currentstage) {
$classes[] = 'backup_stage_complete';
}
}
}
$item = array('text' => strlen(decbin($stage * 2)) . '. ' . get_string('importcurrentstage' . $stage, 'backup'), 'class' => join(' ', $classes));
if ($stage < $currentstage && $currentstage < self::STAGE_COMPLETE && (!self::$skipcurrentstage || $stage * 2 != $currentstage)) {
$item['link'] = new moodle_url($PAGE->url, $this->stage->get_params() + array('backup' => $this->get_backupid(), 'stage' => $stage));
}
array_unshift($items, $item);
$stage = floor($stage / 2);
}
$selectorlink = new moodle_url($PAGE->url, $this->stage->get_params());
$selectorlink->remove_params('importid');
array_unshift($items, array('text' => '1. ' . get_string('importcurrentstage0', 'backup'), 'class' => join(' ', $classes), 'link' => $selectorlink));
return $items;
}
示例12: form_start
/**
* form_start
*
* @param xxx $hotpotscriptname
* @param xxx $params
* @param xxx $attributes (optional, default=array)
* @return xxx
*/
function form_start($hotpotscriptname, $params, $attributes = array())
{
$output = '';
if (empty($attributes['method'])) {
$attributes['method'] = 'post';
}
if (empty($attributes['action'])) {
$url = new moodle_url('/mod/hotpot/' . $hotpotscriptname);
$attributes['action'] = $url->out();
}
$output .= html_writer::start_tag('form', $attributes) . "\n";
$hiddenfields = '';
foreach ($params as $name => $value) {
$hiddenfields .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value)) . "\n";
}
if ($hiddenfields) {
// xhtml strict requires a container for the hidden input elements
$output .= html_writer::start_tag('fieldset', array('style' => 'display:none')) . "\n";
$output .= $hiddenfields;
$output .= html_writer::end_tag('fieldset') . "\n";
}
// xhtml strict requires a container for the contents of the <form>
$output .= html_writer::start_tag('div') . "\n";
return $output;
}
示例13: badge
/**
* Render the badge element (message count)
*
* @param null $userid
* @return string
*/
public function badge($userid = null)
{
global $USER, $DB, $COURSE, $PAGE;
// Only for logged in folks and when we are enabled.
if (!isset($USER->message_badge_disabled)) {
if (mr_off('badge', 'message') or !isloggedin() or isguestuser()) {
$USER->message_badge_disabled = true;
} else {
$USER->message_badge_disabled = $DB->record_exists('message_processors', array('name' => 'badge', 'enabled' => 0));
}
}
if ($USER->message_badge_disabled) {
return '';
}
if ($this->is_mobile()) {
return $this->mobile($userid);
}
$repo = new message_output_badge_repository_message();
$forwardurl = new moodle_url('/message/output/badge/view.php', array('action' => 'forward', 'courseid' => $COURSE->id));
$total = $repo->count_user_unread_messages($userid);
$PAGE->requires->js_init_call('M.snap_message_badge.init_badge', array($forwardurl->out(false), $COURSE->id), false, $this->get_js_module());
if (!empty($total)) {
$countdiv = html_writer::tag('span', $total, array('id' => html_writer::random_id(), 'class' => 'message_badge_count'));
} else {
$countdiv = '';
}
return $countdiv;
}
示例14: display
function display()
{
$search = trim(optional_param('search', '', PARAM_TEXT));
$alpha = optional_param('alpha', '', PARAM_ALPHA);
// TODO: with a little more work, we could keep the previously selected sort here
$params = $_GET;
unset($params['page']);
// We want to go back to the first page
unset($params['search']);
// And clear the search
$target = $this->page->get_new_page($params);
echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>";
echo "<form action=\"" . $target->get_url() . "\" method=\"post\">";
echo "<fieldset class=\"invisiblefieldset\">";
echo "<input type=\"text\" name=\"search\" value=\"" . s($search, true) . "\" size=\"20\" />";
echo '<input type="submit" value="' . get_string('search') . '" />';
//remove the "bare" parameter to prevent from loading only part of the page
$moodleurl = new moodle_url($target->get_url());
$moodleurl->remove_params('mode');
if ($search) {
echo "<input type=\"button\" onclick=\"document.location='" . $moodleurl->out() . "';\" " . "value=\"Show all items\" />";
}
echo "</fieldset></form>";
echo "</td></tr></table>";
}
示例15: get_content
function get_content()
{
global $CFG, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) {
$this->content->items = array(get_string('missing_feedback_module', 'block_feedback'));
return $this->content;
}
$courseid = $this->page->course->id;
if ($courseid <= 0) {
$courseid = SITEID;
}
$icon = '<img src="' . $OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />';
if (empty($this->instance->pageid)) {
$this->instance->pageid = SITEID;
}
if ($feedbacks = feedback_get_feedbacks_from_sitecourse_map($courseid)) {
$baseurl = new moodle_url('/mod/feedback/view.php');
foreach ($feedbacks as $feedback) {
$url = new moodle_url($baseurl);
$url->params(array('id' => $feedback->cmid, 'courseid' => $courseid));
$this->content->items[] = '<a href="' . $url->out() . '">' . $icon . $feedback->name . '</a>';
}
}
return $this->content;
}