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


PHP moodle_url::get_path方法代码示例

本文整理汇总了PHP中moodle_url::get_path方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_url::get_path方法的具体用法?PHP moodle_url::get_path怎么用?PHP moodle_url::get_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moodle_url的用法示例。


在下文中一共展示了moodle_url::get_path方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_filename

 /**
  * Obtains the filename from the moodle_url.
  * @param moodle_url $url URL
  * @return string Filename only (not escaped)
  */
 public function get_filename(moodle_url $url)
 {
     // Use the 'file' parameter if provided (for links created when
     // slasharguments was off). If not present, just use URL path.
     $path = $url->get_param('file');
     if (!$path) {
         $path = $url->get_path();
     }
     // Remove everything before last / if present. Does not use textlib as / is UTF8-safe.
     $slash = strrpos($path, '/');
     if ($slash !== false) {
         $path = substr($path, $slash + 1);
     }
     return $path;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:20,代码来源:manager.php

示例2: hsuforum_go_back_to

/**
 * @global object
 * @param string $default
 * @return string
 */
function hsuforum_go_back_to($default)
{
    global $SESSION;
    if (!empty($SESSION->fromdiscussion) && (!defined(AJAX_SCRIPT) || !AJAX_SCRIPT)) {
        // If we have an ajax fromdiscussion session variable then we need to get rid of it because this is not an
        // ajax page and we will end up redirecting incorrectly to route.php.
        $murl = new moodle_url($SESSION->fromdiscussion);
        $path = $murl->get_path();
        if (strpos($path, '/mod/hsuforum/route.php') === 0) {
            // OK - this is bad, we are not using AJAX but the redirect url is an AJAX url, so kill it.
            unset($SESSION->fromdiscussion);
        }
    }
    if (!empty($SESSION->fromdiscussion)) {
        $returnto = $SESSION->fromdiscussion;
        unset($SESSION->fromdiscussion);
        return $returnto;
    } else {
        return $default;
    }
}
开发者ID:cdsmith-umn,项目名称:moodle-mod_hsuforum,代码行数:26,代码来源:lib.php

示例3: test_moodle_url_get_path

 /**
  * Tests moodle_url::get_path().
  */
 public function test_moodle_url_get_path()
 {
     $url = new moodle_url('http://www.example.org:447/my/file/is/here.txt?really=1');
     $this->assertSame('/my/file/is/here.txt', $url->get_path());
     $url = new moodle_url('http://www.example.org/');
     $this->assertSame('/', $url->get_path());
     $url = new moodle_url('http://www.example.org/pluginfile.php/slash/arguments');
     $this->assertSame('/pluginfile.php/slash/arguments', $url->get_path());
     $this->assertSame('/pluginfile.php', $url->get_path(false));
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:13,代码来源:weblib_test.php

示例4: cohort_edit_controls

/**
 * Returns navigation controls (tabtree) to be displayed on cohort management pages
 *
 * @param context $context system or category context where cohorts controls are about to be displayed
 * @param moodle_url $currenturl
 * @return null|renderable
 */
function cohort_edit_controls(context $context, moodle_url $currenturl)
{
    $tabs = array();
    $currenttab = 'view';
    $viewurl = new moodle_url('/cohort/index.php', array('contextid' => $context->id));
    if ($searchquery = $currenturl->get_param('search')) {
        $viewurl->param('search', $searchquery);
    }
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        $tabs[] = new tabobject('view', new moodle_url($viewurl, array('showall' => 0)), get_string('systemcohorts', 'cohort'));
        $tabs[] = new tabobject('viewall', new moodle_url($viewurl, array('showall' => 1)), get_string('allcohorts', 'cohort'));
        if ($currenturl->get_param('showall')) {
            $currenttab = 'viewall';
        }
    } else {
        $tabs[] = new tabobject('view', $viewurl, get_string('cohorts', 'cohort'));
    }
    if (has_capability('moodle/cohort:manage', $context)) {
        $addurl = new moodle_url('/cohort/edit.php', array('contextid' => $context->id));
        $tabs[] = new tabobject('addcohort', $addurl, get_string('addcohort', 'cohort'));
        if ($currenturl->get_path() === $addurl->get_path() && !$currenturl->param('id')) {
            $currenttab = 'addcohort';
        }
        $uploadurl = new moodle_url('/cohort/upload.php', array('contextid' => $context->id));
        $tabs[] = new tabobject('uploadcohorts', $uploadurl, get_string('uploadcohorts', 'cohort'));
        if ($currenturl->get_path() === $uploadurl->get_path()) {
            $currenttab = 'uploadcohorts';
        }
    }
    if (count($tabs) > 1) {
        return new tabtree($tabs, $currenttab);
    }
    return null;
}
开发者ID:evltuma,项目名称:moodle,代码行数:41,代码来源:lib.php


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