本文整理汇总了PHP中moodle_url::set_slashargument方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url::set_slashargument方法的具体用法?PHP moodle_url::set_slashargument怎么用?PHP moodle_url::set_slashargument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodle_url
的用法示例。
在下文中一共展示了moodle_url::set_slashargument方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_file_url
/**
* General moodle file url.
* @param string $urlbase the script serving the file
* @param string $path
* @param bool $forcedownload
* @return moodle_url
*/
public static function make_file_url($urlbase, $path, $forcedownload = false)
{
global $CFG;
$params = array();
if ($forcedownload) {
$params['forcedownload'] = 1;
}
$url = new moodle_url($urlbase, $params);
$url->set_slashargument($path);
return $url;
}
示例2: js_fix_url
/**
* Returns the actual url through which a script is served.
*
* @param moodle_url|string $url full moodle url, or shortened path to script
* @return moodle_url
*/
protected function js_fix_url($url)
{
global $CFG;
if ($url instanceof moodle_url) {
return $url;
} else {
if (strpos($url, '/') === 0) {
// Fix the admin links if needed.
if ($CFG->admin !== 'admin') {
if (strpos($url, "/admin/") === 0) {
$url = preg_replace("|^/admin/|", "/{$CFG->admin}/", $url);
}
}
if (debugging()) {
// Check file existence only when in debug mode.
if (!file_exists($CFG->dirroot . strtok($url, '?'))) {
throw new coding_exception('Attempt to require a JavaScript file that does not exist.', $url);
}
}
if (!empty($CFG->cachejs) and !empty($CFG->jsrev) and $CFG->jsrev > 0 and substr($url, -3) === '.js') {
if (empty($CFG->slasharguments)) {
return new moodle_url($CFG->httpswwwroot . '/lib/javascript.php', array('rev' => $CFG->jsrev, 'jsfile' => $url));
} else {
$returnurl = new moodle_url($CFG->httpswwwroot . '/lib/javascript.php');
$returnurl->set_slashargument('/' . $CFG->jsrev . $url);
return $returnurl;
}
} else {
return new moodle_url($CFG->httpswwwroot . $url);
}
} else {
throw new coding_exception('Invalid JS url, it has to be shortened url starting with / or moodle_url instance.', $url);
}
}
}
示例3: get_amd_footercode
/**
* Returns js code to load amd module loader, then insert inline script tags
* that contain require() calls using RequireJS.
* @return string
*/
protected function get_amd_footercode()
{
global $CFG;
$output = '';
$jsrev = $this->get_jsrev();
$jsloader = new moodle_url($CFG->httpswwwroot . '/lib/javascript.php');
$jsloader->set_slashargument('/' . $jsrev . '/');
$requirejsloader = new moodle_url($CFG->httpswwwroot . '/lib/requirejs.php');
$requirejsloader->set_slashargument('/' . $jsrev . '/');
$requirejsconfig = file_get_contents($CFG->dirroot . '/lib/requirejs/moodle-config.js');
// No extension required unless slash args is disabled.
$jsextension = '.js';
if (!empty($CFG->slasharguments)) {
$jsextension = '';
}
$requirejsconfig = str_replace('[BASEURL]', $requirejsloader, $requirejsconfig);
$requirejsconfig = str_replace('[JSURL]', $jsloader, $requirejsconfig);
$requirejsconfig = str_replace('[JSEXT]', $jsextension, $requirejsconfig);
$output .= html_writer::script($requirejsconfig);
if ($CFG->debugdeveloper) {
$output .= html_writer::script('', $this->js_fix_url('/lib/requirejs/require.js'));
} else {
$output .= html_writer::script('', $this->js_fix_url('/lib/requirejs/require.min.js'));
}
// First include must be to a module with no dependencies, this prevents multiple requests.
$prefix = "require(['core/first'], function() {\n";
$suffix = "\n});";
$output .= html_writer::script($prefix . implode(";\n", $this->amdjscode) . $suffix);
return $output;
}
示例4: font_url
/**
* Return the URL for a font
*
* @param string $font the name of the font (including extension).
* @param string $component specification of one plugin like in get_string()
* @return moodle_url
*/
public function font_url($font, $component)
{
global $CFG;
$params = array('theme' => $this->name);
if (empty($component) or $component === 'moodle' or $component === 'core') {
$params['component'] = 'core';
} else {
$params['component'] = $component;
}
$rev = theme_get_revision();
if ($rev != -1) {
$params['rev'] = $rev;
}
$params['font'] = $font;
$url = new moodle_url("{$CFG->httpswwwroot}/theme/font.php");
if (!empty($CFG->slasharguments) and $rev > 0) {
$path = '/' . $params['theme'] . '/' . $params['component'] . '/' . $params['rev'] . '/' . $params['font'];
$url->set_slashargument($path, 'noparam', true);
} else {
$url->params($params);
}
return $url;
}
示例5: pix_url
/**
* Return the URL for an image
*
* @param string $imagename the name of the icon.
* @param string $component specification of one plugin like in get_string()
* @return moodle_url
*/
public function pix_url($imagename, $component)
{
global $CFG;
$params = array('theme' => $this->name);
$svg = $this->use_svg_icons();
if (empty($component) or $component === 'moodle' or $component === 'core') {
$params['component'] = 'core';
} else {
$params['component'] = $component;
}
$rev = theme_get_revision();
if ($rev != -1) {
$params['rev'] = $rev;
}
$params['image'] = $imagename;
$url = new moodle_url("{$CFG->httpswwwroot}/theme/image.php");
if (!empty($CFG->slasharguments) and $rev > 0) {
$path = '/' . $params['theme'] . '/' . $params['component'] . '/' . $params['rev'] . '/' . $params['image'];
if (!$svg) {
// We add a simple /_s to the start of the path.
// The underscore is used to ensure that it isn't a valid theme name.
$path = '/_s' . $path;
}
$url->set_slashargument($path, 'noparam', true);
} else {
if (!$svg) {
// We add an SVG param so that we know not to serve SVG images.
// We do this because all modern browsers support SVG and this param will one day be removed.
$params['svg'] = '0';
}
$url->params($params);
}
return $url;
}
示例6: dirname
* @subpackage tinymce
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require dirname(__FILE__) . '/../../../../../../../config.php';
require_once $CFG->libdir . '/filelib.php';
require_once $CFG->libdir . '/editorlib.php';
require_once $CFG->libdir . '/editor/tinymce/lib.php';
// Must be logged in
require_login();
// Require path to draftfile.php file
$path = required_param('path', PARAM_PATH);
$editor = new tinymce_texteditor();
// Now output this file which is super-simple
$PAGE->set_pagelayout('embedded');
$PAGE->set_url(new moodle_url('/lib/editor/tinymce/tiny_mce/' . $editor->version . '/plugins/moodlemedia/preview.php', array('path' => $path)));
$PAGE->set_context(context_system::instance());
$PAGE->add_body_class('core_media_preview');
echo $OUTPUT->header();
$mediarenderer = $PAGE->get_renderer('core', 'media');
$path = '/' . trim($path, '/');
if (empty($CFG->slasharguments)) {
$url = new moodle_url('/draftfile.php', array('file' => $path));
} else {
$url = new moodle_url('/draftfile.php');
$url->set_slashargument($path);
}
if ($mediarenderer->can_embed_url($url)) {
echo $mediarenderer->embed_url($url);
}
echo $OUTPUT->footer();