当前位置: 首页>>代码示例>>PHP>>正文


PHP moodle_url::set_slashargument方法代码示例

本文整理汇总了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;
 }
开发者ID:hatone,项目名称:moodle,代码行数:18,代码来源:weblib.php

示例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);
         }
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:41,代码来源:outputrequirementslib.php

示例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;
 }
开发者ID:rsturley,项目名称:moodle,代码行数:35,代码来源:outputrequirementslib.php

示例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;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:30,代码来源:outputlib.php

示例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;
 }
开发者ID:Burick,项目名称:moodle,代码行数:41,代码来源:outputlib.php

示例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();
开发者ID:nicusX,项目名称:moodle,代码行数:31,代码来源:preview.php


注:本文中的moodle_url::set_slashargument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。