本文整理汇总了PHP中moodle_url类的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url类的具体用法?PHP moodle_url怎么用?PHP moodle_url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了moodle_url类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:itamart,项目名称:moodle-dataformview_pdf,代码行数:31,代码来源:patterns.php
示例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());
}
开发者ID:netspotau,项目名称:moodle-mod_lightboxgallery,代码行数:17,代码来源:behat_mod_lightboxgallery.php
示例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);
}
}
开发者ID:keliix06,项目名称:moodle-local_loginas,代码行数:63,代码来源:lib.php
示例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());
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:33,代码来源:Command_Form.php
示例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);
}
开发者ID:kopohi,项目名称:memorybank,代码行数:27,代码来源:locallib.php
示例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;
}
开发者ID:nigeli,项目名称:moodle,代码行数:37,代码来源:renderer.php
示例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;
}
开发者ID:danielneis,项目名称:moodle-local_syncgroups,代码行数:26,代码来源:renderer.php
示例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 = '';
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:32,代码来源:lib.php
示例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;
}
开发者ID:NextEinstein,项目名称:riverhills,代码行数:31,代码来源:ajaxlib.php
示例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);
}
开发者ID:agarnav,项目名称:moodle-mod_activequiz,代码行数:42,代码来源:edit.php
示例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;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:37,代码来源:import_extensions.php
示例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;
}
开发者ID:hapaxapah,项目名称:moodle-mod_hotpot,代码行数:33,代码来源:renderer.php
示例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;
}
开发者ID:nadavkav,项目名称:moodle-theme_snap,代码行数:34,代码来源:message_badge_renderer.php
示例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>";
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:25,代码来源:cmsearchbox.class.php
示例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;
}
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:32,代码来源:block_feedback.php
示例16: url_is_blocked
/**
* Checks whether the given URL is blacklisted by checking its address and port number against the black/white lists.
* The behaviour of this function can be classified as strict, as it returns true for URLs which are invalid or
* could not be parsed, as well as those valid URLs which were found in the blacklist.
*
* @param string $urlstring the URL to check.
* @return bool true if the URL is blacklisted or invalid and false if the URL is not blacklisted.
*/
public function url_is_blocked($urlstring)
{
// If no config data is present, then all hosts/ports are allowed.
if (!$this->is_enabled()) {
return false;
}
// Try to parse the URL to get the 'host' and 'port' components.
try {
$url = new \moodle_url($urlstring);
$parsed['scheme'] = $url->get_scheme();
$parsed['host'] = $url->get_host();
$parsed['port'] = $url->get_port();
} catch (\moodle_exception $e) {
// Moodle exception is thrown if the $urlstring is invalid. Treat as blocked.
return true;
}
// The port will be empty unless explicitly set in the $url (uncommon), so try to infer it from the supported schemes.
if (!$parsed['port'] && $parsed['scheme'] && isset($this->transportschemes[$parsed['scheme']])) {
$parsed['port'] = $this->transportschemes[$parsed['scheme']];
}
if ($parsed['port'] && $parsed['host']) {
// Check the host and port against the blacklist/whitelist entries.
return $this->host_is_blocked($parsed['host']) || $this->port_is_blocked($parsed['port']);
}
return true;
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:34,代码来源:curl_security_helper.php
示例17: mform_autocomplete
/**
* Add autocomplete to a form text field
*
* @param MoodleQuickForm $mform Moodle form
* @param array|moodle_url $options Array of autocomplete options, if $hiddenfieldname is
* passed, array indexes are considered record IDs
* @param string $textfieldname The text field's name
* @param string $hiddenfieldname The hidden field's name. If passed,
* the option index will be set to this hidden
* value when its option value is selected in
* the text field
* @param string $width The pixel width of the text field (Due to YUI, must
* use width instead of size)
* @return void
* @link http://developer.yahoo.com/yui/examples/autocomplete/ac_basic_array.html What you get with no $hiddenfieldname
* @link http://developer.yahoo.com/yui/examples/autocomplete/ac_itemselect.html What you get with $hiddenfieldname
*/
public function mform_autocomplete($mform, $options, $textfieldname, $hiddenfieldname = '', $width = '300')
{
global $PAGE;
$url = NULL;
$data = NULL;
// Generate data source
if ($options instanceof moodle_url) {
$url = $options->out(false);
} else {
$data = array();
foreach ($options as $optionid => $option) {
if (empty($hiddenfieldname)) {
$data[] = $option;
} else {
$data[] = (object) array('text' => $option, 'id' => $optionid);
}
}
}
$fields = array('text');
if (!empty($hiddenfieldname)) {
$fields[] = 'id';
}
$module = array('name' => 'local_mr_framework', 'fullpath' => '/local/mr/framework/assets/javascript.js', 'requires' => array('yui2-yahoo', 'yui2-dom', 'yui2-event', 'yui2-datasource', 'yui2-json', 'yui2-connection', 'yui2-get', 'yui2-animation', 'yui2-autocomplete'));
$arguments = array((object) array('fieldname' => $textfieldname, 'hiddenfieldname' => $hiddenfieldname, 'width' => $width, 'url' => $url, 'data' => $data, 'fields' => $fields));
$PAGE->requires->js_init_call('M.local_mr.init_mr_html_autocomplete', $arguments, true, $module);
// $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/autocomplete-core.css');
// $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/skins/sam/autocomplete.css');
// Update form - need to force some attributes and add the javascript
$mform->updateElementAttr($textfieldname, array('autocomplete' => 'off', 'style' => "width: {$width}px;"));
// Add ID to hidden field so javascript can find it
if (!empty($hiddenfieldname)) {
$mform->updateElementAttr($hiddenfieldname, array('id' => "id_{$hiddenfieldname}"));
}
}
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:51,代码来源:html.php
示例18: question_setup
/**
* Set up the columns and headers and other properties of the table and then
* call flexible_table::setup() method.
*
* @param moodle_url $reporturl the URL to redisplay this report.
* @param object $question a question with a _stats field
* @param bool $hassubqs
*/
public function question_setup($reporturl, $questiondata, offlinequiz_statistics_response_analyser $responsestats)
{
$this->questiondata = $questiondata;
$this->define_baseurl($reporturl->out());
$this->collapsible(false);
$this->set_attribute('class', 'generaltable generalbox boxaligncenter');
// Define the table columns.
$columns = array();
$headers = array();
$columns[] = 'part';
$headers[] = '';
$columns[] = 'response';
$headers[] = get_string('response', 'offlinequiz_statistics');
$columns[] = 'fraction';
$headers[] = get_string('optiongrade', 'offlinequiz_statistics');
$columns[] = 'count';
$headers[] = get_string('count', 'offlinequiz_statistics');
$columns[] = 'frequency';
$headers[] = get_string('frequency', 'offlinequiz_statistics');
$this->define_columns($columns);
$this->define_headers($headers);
$this->sortable(false);
$this->column_class('fraction', 'numcol');
$this->column_class('count', 'numcol');
$this->column_class('frequency', 'numcol');
$this->column_suppress('part');
$this->column_suppress('responseclass');
parent::setup();
}
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:37,代码来源:statistics_question_table.php
示例19: 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);
}
开发者ID:Burick,项目名称:moodle,代码行数:38,代码来源:renderer.php
示例20: __construct
/**
* Constructor of dropbox plugin
*
* @param int $repositoryid
* @param stdClass $context
* @param array $options
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
{
global $CFG;
$options['page'] = optional_param('p', 1, PARAM_INT);
parent::__construct($repositoryid, $context, $options);
$this->setting = 'dropbox_';
$this->dropbox_key = $this->get_option('dropbox_key');
$this->dropbox_secret = $this->get_option('dropbox_secret');
// one day
$this->cachedfilettl = 60 * 60 * 24;
if (isset($options['access_key'])) {
$this->access_key = $options['access_key'];
} else {
$this->access_key = get_user_preferences($this->setting . '_access_key', '');
}
if (isset($options['access_secret'])) {
$this->access_secret = $options['access_secret'];
} else {
$this->access_secret = get_user_preferences($this->setting . '_access_secret', '');
}
if (!empty($this->access_key) && !empty($this->access_secret)) {
$this->logged = true;
}
$callbackurl = new moodle_url($CFG->wwwroot . '/repository/repository_callback.php', array('callback' => 'yes', 'repo_id' => $repositoryid));
$args = array('oauth_consumer_key' => $this->dropbox_key, 'oauth_consumer_secret' => $this->dropbox_secret, 'oauth_callback' => $callbackurl->out(false), 'api_root' => 'https://www.dropbox.com/1/oauth');
$this->dropbox = new dropbox($args);
}
开发者ID:nmicha,项目名称:moodle,代码行数:34,代码来源:lib.php
注:本文中的moodle_url类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论