本文整理汇总了PHP中moodle_url::out_as_local_url方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url::out_as_local_url方法的具体用法?PHP moodle_url::out_as_local_url怎么用?PHP moodle_url::out_as_local_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodle_url
的用法示例。
在下文中一共展示了moodle_url::out_as_local_url方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
* @param question_edit_contexts $contexts
* @param moodle_url $pageurl
* @param object $course course settings
* @param object $cm (optional) activity settings.
*/
public function __construct($contexts, $pageurl, $course, $cm = null)
{
global $CFG, $PAGE;
$this->contexts = $contexts;
$this->baseurl = $pageurl;
$this->course = $course;
$this->cm = $cm;
if (!empty($cm) && $cm->modname == 'quiz') {
$this->quizorcourseid = '&quizid=' . $cm->instance;
} else {
$this->quizorcourseid = '&courseid=' . $this->course->id;
}
// Create the url of the new question page to forward to.
$returnurl = $pageurl->out_as_local_url(false);
$this->editquestionurl = new \moodle_url('/question/question.php', array('returnurl' => $returnurl));
if ($cm !== null) {
$this->editquestionurl->param('cmid', $cm->id);
} else {
$this->editquestionurl->param('courseid', $this->course->id);
}
$this->lastchangedid = optional_param('lastchanged', 0, PARAM_INT);
$this->init_columns($this->wanted_columns(), $this->heading_column());
$this->init_sort();
$this->init_search_conditions($this->contexts, $this->course, $this->cm);
}
示例2: commit
/**
* Commit new records.
*
* @return void
*/
public function commit()
{
$request = (object) array('pid' => getmypid(), 'threadid' => ZEND_THREAD_SAFE ? zend_thread_id() : null, 'uid' => getmyuid(), 'url' => $this->url->out_as_local_url(false), 'hostname' => gethostname(), 'memory' => memory_get_usage(), 'peakmemory' => memory_get_peak_usage());
// Not supported on Windows until PHP 7
if (function_exists('getrusage')) {
$resourceusage = getrusage();
$request->numswaps = $resourceusage['ru_nswap'];
$request->numpagefaults = $resourceusage['ru_majflt'];
$request->usertime = $resourceusage['ru_utime.tv_usec'];
}
$request->id = $this->db->insert_record('telemetry_request', $request);
foreach ($this->additionalstate as $collector) {
$table = $collector->get_table();
$records = $collector->get_records();
foreach ($records as $record) {
$record->requestid = $request->id;
}
$this->db->insert_records($table, $records);
}
}
示例3: get_matching_tourdata
/**
* Fetch all enabled tours matching the specified target.
*
* @param moodle_url $targetmatch The URL to match.
*/
public static function get_matching_tourdata(\moodle_url $targetmatch)
{
$tours = self::get_enabled_tourdata();
// Attempt to determine whether this is the front page.
// This is a special case because the frontpage uses a shortened page path making it difficult to detect exactly.
$isfrontpage = $targetmatch->compare(new \moodle_url('/'), URL_MATCH_BASE);
$target = $targetmatch->out_as_local_url();
return array_filter($tours, function ($tour) use($isfrontpage, $target) {
if ($isfrontpage && $tour->pathmatch === 'FRONTPAGE') {
return true;
}
$pattern = preg_quote($tour->pathmatch, '@');
$pattern = str_replace('%', '.*', $pattern);
return !!preg_match("@{$pattern}@", $target);
});
}
示例4: embed
/**
* Generates code required to embed the player.
*
* The url contained in $urls must be a local file.
*
* Unlike other core_media_players, the $urls array should only contain
* a single url and the $options array is ignored.
*
* On failure, the function returns an empty string
*
* @see core_media_player::embed
* @param array $urls URL of media file
* @param string $name Display name; '' to use default
* @param int $width Optional width; 0 to use default
* @param int $height Optional height; 0 to use default
* @param array $options Options array
* @return string HTML code for embed
*/
public function embed($urls, $name, $width, $height, $options)
{
global $CFG;
// don't expect alternative urls
if (count($urls) !== 1) {
return '';
}
$file_url = new moodle_url($urls[0]);
$viewerjs_player_url = new moodle_url('/filter/viewerjs/lib/viewerjs');
// we assume the filter/viewerjs/lib/viewerjs directory will be four directories away from the initial public directory
$viewerjs_player_url->set_anchor('../../../..' . $file_url->out_as_local_url());
if (!$width) {
$width = '100%';
}
if (!$height) {
$height = 500;
}
$output = html_writer::tag('iframe', '', array('src' => $viewerjs_player_url->out(), 'width' => $width, 'height' => $height, 'webkitallowfullscreen' => 'webkitallowfullscreen', 'mozallowfullscreen' => 'mozallowfullscreen', 'allowfullscreen' => 'allowfullscreen'));
return $output;
}
示例5: test_https_out_as_local_url_error
/**
* Try get local url from external https url and you should get error
*
* @expectedException coding_exception
*/
public function test_https_out_as_local_url_error()
{
$url4 = new moodle_url('https://www.google.com/lib/tests/weblib_test.php');
$url4->out_as_local_url();
}
示例6: calendar_filter_controls
/**
* Get the controls filter for calendar.
*
* Filter is used to hide calendar info from the display page
*
* @param moodle_url $returnurl return-url for filter controls
* @return string $content return filter controls in html
*/
function calendar_filter_controls(moodle_url $returnurl)
{
global $CFG, $USER, $OUTPUT;
$groupevents = true;
$id = optional_param('id', 0, PARAM_INT);
$seturl = new moodle_url('/calendar/set.php', array('return' => base64_encode($returnurl->out_as_local_url(false)), 'sesskey' => sesskey()));
$content = html_writer::start_tag('ul');
$seturl->param('var', 'showglobal');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_GLOBAL);
$seturl->param('var', 'showcourses');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_COURSE);
if (isloggedin() && !isguestuser()) {
if ($groupevents) {
// This course MIGHT have group events defined, so show the filter
$seturl->param('var', 'showgroups');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_GROUP);
} else {
// This course CANNOT have group events, so lose the filter
}
$seturl->param('var', 'showuser');
$content .= calendar_filter_controls_element($seturl, CALENDAR_EVENT_USER);
}
$content .= html_writer::end_tag('ul');
return $content;
}
示例7: print_badge_table_actions
public function print_badge_table_actions($badge, $context)
{
$actions = "";
if (has_capability('moodle/badges:configuredetails', $context) && $badge->has_criteria()) {
// Activate/deactivate badge.
if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) {
// "Activate" will go to another page and ask for confirmation.
$url = new moodle_url('/badges/action.php');
$url->param('id', $badge->id);
$url->param('activate', true);
$url->param('sesskey', sesskey());
$return = new moodle_url(qualified_me());
$url->param('return', $return->out_as_local_url(false));
$actions .= $this->output->action_icon($url, new pix_icon('t/show', get_string('activate', 'badges'))) . " ";
} else {
$url = new moodle_url(qualified_me());
$url->param('lock', $badge->id);
$url->param('sesskey', sesskey());
$actions .= $this->output->action_icon($url, new pix_icon('t/hide', get_string('deactivate', 'badges'))) . " ";
}
}
// Award badge manually.
if ($badge->has_manual_award_criteria() && has_capability('moodle/badges:awardbadge', $context) && $badge->is_active()) {
$url = new moodle_url('/badges/award.php', array('id' => $badge->id));
$actions .= $this->output->action_icon($url, new pix_icon('t/award', get_string('award', 'badges'))) . " ";
}
// Edit badge.
if (has_capability('moodle/badges:configuredetails', $context)) {
$url = new moodle_url('/badges/edit.php', array('id' => $badge->id, 'action' => 'details'));
$actions .= $this->output->action_icon($url, new pix_icon('t/edit', get_string('edit'))) . " ";
}
// Duplicate badge.
if (has_capability('moodle/badges:createbadge', $context)) {
$url = new moodle_url('/badges/action.php', array('copy' => '1', 'id' => $badge->id, 'sesskey' => sesskey()));
$actions .= $this->output->action_icon($url, new pix_icon('t/copy', get_string('copy'))) . " ";
}
// Delete badge.
if (has_capability('moodle/badges:deletebadge', $context)) {
$url = new moodle_url(qualified_me());
$url->param('delete', $badge->id);
$actions .= $this->output->action_icon($url, new pix_icon('t/delete', get_string('delete'))) . " ";
}
return $actions;
}
示例8:
/**
* @expectedException coding_exception
* @return void
*/
function test_out_as_local_url_error() {
$url2 = new moodle_url('http://www.google.com/lib/simpletest/testweblib.php');
$url2->out_as_local_url();
}
示例9: print_login
/**
* Print or return the login form.
*
* @return void|array for ajax.
*/
public function print_login()
{
$returnurl = new moodle_url('/repository/repository_callback.php');
$returnurl->param('callback', 'yes');
$returnurl->param('repo_id', $this->id);
$returnurl->param('sesskey', sesskey());
$url = new moodle_url($this->client->createAuthUrl());
$url->param('state', $returnurl->out_as_local_url(false));
if ($this->options['ajax']) {
$popup = new stdClass();
$popup->type = 'popup';
$popup->url = $url->out(false);
return array('login' => array($popup));
} else {
echo '<a target="_blank" href="' . $url->out(false) . '">' . get_string('login', 'repository') . '</a>';
}
}
示例10: initialize_oauth
private function initialize_oauth()
{
$redirecturi = new moodle_url(self::REDIRECTURL);
$returnurl = new moodle_url('/portfolio/add.php');
$returnurl->param('postcontrol', 1);
$returnurl->param('id', $this->exporter->get('id'));
$returnurl->param('sesskey', sesskey());
$clientid = $this->get_config('clientid');
$secret = $this->get_config('secret');
// Setup Google client.
$this->client = get_google_client();
$this->client->setClientId($clientid);
$this->client->setClientSecret($secret);
$this->client->setScopes(array(Google_Service_Drive::DRIVE_FILE));
$this->client->setRedirectUri($redirecturi->out(false));
// URL to be called when redirecting from authentication.
$this->client->setState($returnurl->out_as_local_url(false));
// Setup drive upload service.
$this->service = new Google_Service_Drive($this->client);
}
示例11: random_question_form
/**
* Return random question form.
* @param \moodle_url $thispageurl the canonical URL of this page.
* @param \question_edit_contexts $contexts the relevant question bank contexts.
* @param array $pagevars the variables from {@link \question_edit_setup()}.
* @return string HTML to output.
*/
protected function random_question_form(\moodle_url $thispageurl, \question_edit_contexts $contexts, array $pagevars)
{
if (!$contexts->have_cap('moodle/question:useall')) {
return '';
}
$randomform = new \quiz_add_random_form(new \moodle_url('/mod/quiz/addrandom.php'), array('contexts' => $contexts, 'cat' => $pagevars['cat']));
$randomform->set_data(array('category' => $pagevars['cat'], 'returnurl' => $thispageurl->out_as_local_url(true), 'randomnumber' => 1, 'cmid' => $thispageurl->param('cmid')));
return html_writer::div($randomform->render(), 'randomquestionformforpopup');
}
示例12: array
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
/////////////////////////////////////////////////////////////////////////////
require_once '../config.php';
require_once $CFG->dirroot . '/calendar/lib.php';
require_sesskey();
$var = required_param('var', PARAM_ALPHA);
$return = clean_param(base64_decode(required_param('return', PARAM_RAW)), PARAM_LOCALURL);
$courseid = optional_param('id', -1, PARAM_INT);
if ($courseid != -1) {
$return = new moodle_url($return, array('course' => $courseid));
} else {
$return = new moodle_url($return);
}
$url = new moodle_url('/calendar/set.php', array('return' => base64_encode($return->out_as_local_url(false)), 'course' => $courseid, 'var' => $var, 'sesskey' => sesskey()));
$PAGE->set_url($url);
$PAGE->set_context(context_system::instance());
switch ($var) {
case 'showgroups':
calendar_set_event_type_display(CALENDAR_EVENT_GROUP);
break;
case 'showcourses':
calendar_set_event_type_display(CALENDAR_EVENT_COURSE);
break;
case 'showglobal':
calendar_set_event_type_display(CALENDAR_EVENT_GLOBAL);
break;
case 'showuser':
calendar_set_event_type_display(CALENDAR_EVENT_USER);
break;
示例13: print_badge_criteria_courseset
/**
* Print details for course set criteria.
*
* Modelled after award_criteria_courseset::get_details().
*
* @param \award_criteria_courseset $criteria
* @param string $short
*
* @return string
*/
protected function print_badge_criteria_courseset($criteria, $short = '')
{
global $DB, $OUTPUT;
$output = array();
foreach ($criteria->params as $param) {
$coursename = $DB->get_field('course', 'fullname', array('id' => $param['course']));
$url = new moodle_url('/course/view.php', array('id' => $param['course']));
if (!$coursename) {
$str = $OUTPUT->error_text(get_string('error:nosuchcourse', 'badges'));
} else {
$str = html_writer::start_tag('a', array('href' => $url->out_as_local_url(false))) . html_writer::tag('b', '"' . $coursename . '"') . html_writer::end_tag('a');
if (isset($param['bydate'])) {
$str .= get_string('criteria_descr_bydate', 'badges', userdate($param['bydate'], get_string('strftimedate', 'core_langconfig')));
}
if (isset($param['grade'])) {
$str .= get_string('criteria_descr_grade', 'badges', $param['grade']);
}
}
$output[] = $str;
}
if ($short) {
return implode(', ', $output);
} else {
return html_writer::alist($output, array(), 'ul');
}
}
示例14: get_matching_tours
/**
* Get the first tour matching the specified URL.
*
* @param moodle_url $pageurl The URL to match.
* @return tour
*/
public static function get_matching_tours(\moodle_url $pageurl)
{
global $PAGE;
$tours = cache::get_matching_tourdata($pageurl->out_as_local_url());
foreach ($tours as $record) {
$tour = tour::load_from_record($record);
if ($tour->is_enabled() && $tour->matches_all_filters($PAGE->context)) {
return $tour;
}
}
return null;
}