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


PHP Url::getPath方法代码示例

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


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

示例1: hashBang

 /**
  * Resolve an url with hashbang.
  *
  * @param Url $url
  *
  * @return string
  */
 protected static function hashBang(Url $url)
 {
     if ($path = preg_replace('|^(/?!)|', '', $url->getFragment())) {
         return $url->withPath($url->getPath() . $path)->getUrl();
     }
     return $url->getUrl();
 }
开发者ID:cienciastar,项目名称:Embed,代码行数:14,代码来源:UrlRedirect.php

示例2: checkMenu

 private function checkMenu()
 {
     // 根据Router::$CLASS_DIR确定菜单
     if (empty(Router::$CLASS_DIR)) {
         throw new ControllerException('无法确定菜单!');
     }
     $arr = explode('/', Router::$CLASS_DIR);
     $menuFile = __DIR__ . '/menu/' . $arr[0] . '.menu.inc.php';
     if (!is_file($menuFile)) {
         throw new ControllerException("菜单{$menuFile}不存在!");
     }
     $this->backendMenuList = (include $menuFile);
     // 计算当前菜单
     $currentPath = Url::getPath();
     foreach ($this->backendMenuList as $menuInfo) {
         foreach ($menuInfo['menu'] as $menuItem) {
             if ($currentPath == $menuItem['url']) {
                 $this->backendMenuInfo = $menuItem;
                 $this->backendMenuInfo['parent_title'] = $menuInfo['title'];
                 $this->backendMenuInfo['parent_code'] = Arr::get('code', $menuInfo, '');
                 break;
             }
         }
         if (!empty($this->backendMenuInfo)) {
             break;
         }
     }
     // assign
     $this->view->assign(array('backendMenuList' => $this->backendMenuList, 'backendMenuInfo' => $this->backendMenuInfo));
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:30,代码来源:ProjectBackendController.class.php

示例3: dispatch

 public static function dispatch()
 {
     $url = new Url();
     $uri = $url->getPath();
     foreach (array_reverse(self::$routes, true) as $route => $class) {
         if (preg_match("~^{$route}\$~", $uri, $params)) {
             Router::$current = $class;
             $return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1)));
             if (!(false === $return)) {
                 $vars = get_class_vars($class);
                 $type = 'text/html';
                 if (isset($vars['type'])) {
                     $type = $vars['type'];
                 }
                 # PHP >= 5.3
                 # if ( isset($class::$type) )
                 #     $type = $class::$type;
                 //Response::setHeader('Content-Type', 'application/xhtml+xml');
                 Response::setHeader('Content-Type', "{$type};charset=UTF-8");
                 Response::setBody($class, $return);
                 return;
             }
             Router::$current = null;
         }
     }
     if (Response::getHttpResponseCode() == 200) {
         $class = 'Error404';
         $return = Controller::dispatch($class);
         Response::setHeader('Content-Type', 'text/html;charset=UTF-8');
         Response::setBody($class, $return);
         //Response::setHeader('HTTP/1.0 404 Not Found');
         //Response::setHttpResponseCode(404);
         //Response::setBody('404', 'Error 404');
     }
 }
开发者ID:joksnet,项目名称:php-old,代码行数:35,代码来源:Router.php

示例4: isSourcePathSubtringOfComparatorPath

 /**
  *
  * @return boolean 
  */
 private function isSourcePathSubtringOfComparatorPath()
 {
     if (!$this->sourceUrl->hasPath() && $this->comparatorUrl->hasPath()) {
         return true;
     }
     $sourcePath = (string) $this->sourceUrl->getPath();
     $comparatorpath = (string) $this->comparatorUrl->getPath();
     if ($sourcePath == $comparatorpath) {
         return true;
     }
     return substr($comparatorpath, 0, strlen($sourcePath)) == $sourcePath;
 }
开发者ID:webignition,项目名称:url,代码行数:16,代码来源:ScopeComparer.php

示例5: setSessionCookiePath

 /**
  * @private
  * @static
  * Sets the session cookie path to the right path
  * @return nothing
  */
 function setSessionCookiePath()
 {
     // get the right url for the script... somehow $_SERVER["REQUEST_URI"]
     // is returning things like "http://83.102.183.10.in-addr.arpa/plog/test.php"
     // in my case which are correct but probably not what we're expecting!
     $scriptUrl = HttpVars::getBaseUrl();
     $url = new Url($scriptUrl);
     $path = dirname($url->getPath());
     if ($path == "" || $path == "\\") {
         $path = "/";
     }
     return $path;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:19,代码来源:sessionmanager.class.php

示例6: baseString

 /**
  * Generate a base string for a RSA-SHA1 signature
  * based on the given a url, method, and any parameters.
  *
  * @param Url    $url
  * @param string $method
  * @param array  $parameters
  *
  * @return string
  */
 protected function baseString(Url $url, $method = 'POST', array $parameters = [])
 {
     $baseString = rawurlencode($method) . '&';
     $schemeHostPath = $url->getScheme() . '://' . $url->getHost();
     if ($url->getPort() != '') {
         $schemeHostPath .= ':' . $url->getPort();
     }
     if ($url->getPath() != '') {
         $schemeHostPath .= $url->getPath();
     }
     $baseString .= rawurlencode($schemeHostPath) . '&';
     $data = [];
     parse_str($url->getQuery(), $query);
     foreach (array_merge($query, $parameters) as $key => $value) {
         $data[rawurlencode($key)] = rawurlencode($value);
     }
     ksort($data);
     array_walk($data, function (&$value, $key) {
         $value = $key . '=' . $value;
     });
     $baseString .= rawurlencode(implode('&', $data));
     return $baseString;
 }
开发者ID:socialiteproviders,项目名称:jira,代码行数:33,代码来源:RsaSha1Signature.php

示例7: __construct

 public function __construct()
 {
     parent::__construct();
     $menuArr = array();
     foreach (DocVars::$CATEGORY as $i => $title) {
         $menuItem = array('title' => $title, 'url' => '/list/' . $i . '/');
         $menuArr[] = $menuItem;
         if ($menuItem['url'] == Url::getPath()) {
             $this->backendMenuInfo = $menuItem;
             $this->backendMenuInfo['parent_title'] = $this->backendMenuList['category']['title'];
             $this->backendMenuInfo['parent_code'] = Arr::get('code', $this->backendMenuList['category'], '');
         }
     }
     $this->backendMenuList['category']['menu'] = $menuArr;
     $this->view->assign(array('backendMenuList' => $this->backendMenuList, 'backendMenuInfo' => $this->backendMenuInfo));
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:16,代码来源:ProjectController.class.php

示例8: testUrl

 function testUrl()
 {
     $url = new Url(self::TEST_URL);
     $this->assertEquals($url->getFull(), self::TEST_URL);
     $this->assertEquals($url->getScheme(), 'https');
     $this->assertEquals($url->getHost(), 'www.google.com');
     $this->assertEquals($url->getPort(), '80');
     $this->assertEquals($url->getPath(), '/some_path');
     // The HTML entities remain intact
     $this->assertEquals($url->getQuery(), 'some=query&something=%20weird');
     // The HTML entities are resolved
     $this->assertEquals($url->getParam('some'), 'query');
     $this->assertEquals($url->getParam('something'), ' weird');
     $this->assertEquals($url->getParams(), ['some' => 'query', 'something' => ' weird']);
     $this->assertEquals($url->getFragment(), 'some_fragment');
     $this->assertEquals($url->getUser(), 'user');
     $this->assertEquals($url->getPass(), 'pass');
 }
开发者ID:inad9300,项目名称:bed.php,代码行数:18,代码来源:UrlTest.php

示例9: uploadRemoteFile

 /**
  * @biref       将网络文件上传到CDN源,非UTF-8的文本页面可能会出现乱码
  * @param       string  $url        网络文件的url
  * @param       int     $id         标识用户id,默认0
  * @param       string  $ext        文件的扩展名,$ext = 'jpg',如果不指定的话,会从url的扩展名中获取
  * @return      string  cdnKey      cdnKey
  * @exception   Exception
  */
 public static function uploadRemoteFile($url, $id = 0, $ext = '')
 {
     // 获取扩展名
     $path = Url::getPath($url);
     if (empty($ext) && strpos($path, '.')) {
         $arr = explode('.', $path);
         $ext = end($arr);
     }
     $ossClient = self::getOssClient();
     $cdnKey = self::makeKey($id, $ext);
     // 获取content type
     $contentType = '';
     if (!empty($ext)) {
         $mimeTypes = Response::getMimeTypes();
         $contentType = $mimeTypes[$ext];
     }
     $curl = new Curl();
     $ossClient->putObject(array('Bucket' => CdnConfig::BUCKET_NAME, 'Key' => $cdnKey, 'Content' => $curl->get($url), 'ContentEncoding' => GlobalConfig::CONTENT_CHARSET, 'ContentType' => $contentType));
     return $cdnKey;
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:28,代码来源:Cdn.class.php

示例10: handleRawUrl

 /**
  * 处理原生url
  * @param $rawUrl
  * @return Url
  */
 protected function handleRawUrl($rawUrl)
 {
     if (strpos($rawUrl, 'http') !== false || substr($rawUrl, 0, 2) == '//') {
         $newRawUrl = $rawUrl;
     } else {
         if ($rawUrl[0] !== '/') {
             if ($this->url->getParameter('extension') == '') {
                 $pathname = rtrim($this->url->getPath(), '/') . '/' . $rawUrl;
             } else {
                 $pathname = dirname($this->url->getPath()) . '/' . $rawUrl;
             }
         } else {
             $pathname = $rawUrl;
         }
         $newRawUrl = $this->url->getOrigin() . $pathname;
     }
     $url = Url::createFromUrl($newRawUrl);
     $url->setRawUrl($rawUrl);
     //将链接所属的repository记录下来
     $url->setParameter('repository', $this);
     return $url;
 }
开发者ID:slince,项目名称:template-collector,代码行数:27,代码来源:Repository.php

示例11: dispatch

 public function dispatch()
 {
     $response = Response::getInstance();
     $url = new Url();
     $uri = $url->getPath();
     foreach (array_reverse($this->routes, true) as $route => $class) {
         if (preg_match("~^{$route}\$~", $uri, $params)) {
             $return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1)));
             if (!(false === $return)) {
                 //$response->setHeader('Content-Type', 'application/xhtml+xml');
                 $response->setHeader('Content-Type', 'text/html;charset=UTF-8');
                 $response->setBody($class, $return);
                 return true;
             }
         }
     }
     if ($response->getHttpResponseCode() == 200) {
         //$response->setHeader('HTTP/1.0 404 Not Found');
         $response->setHttpResponseCode(404);
         $response->setBody('404', 'Error 404');
     }
     return false;
 }
开发者ID:joksnet,项目名称:php-old,代码行数:23,代码来源:Router.php

示例12: CustomUrlHandler

 function CustomUrlHandler()
 {
     $this->Object();
     // we need to figure out the full server path so that we can generate proper
     // regexps for the url parsing. This should get rid of issues like
     // http://bugs.plogworld.net/view.php?id=369
     // The base url will be one or another depending
     $config =& Config::getConfig();
     if ($config->getValue("subdomains_enabled")) {
         $url = new Url($config->getValue("subdomains_base_url"));
     } else {
         $url = new Url($config->getValue("base_url"));
     }
     $path = $url->getPath();
     // intialize the array we're going to use
     $config =& Config::getConfig();
     $this->_indexName = $config->getValue("script_name");
     $this->_formats = array("permalink_format" => $path . $config->getValue("permalink_format"), "category_link_format" => $path . $config->getValue("category_link_format"), "blog_link_format" => $path . $config->getValue("blog_link_format"), "archive_link_format" => $path . $config->getValue("archive_link_format"), "user_posts_link_format" => $path . $config->getValue("user_posts_link_format"), "post_trackbacks_link_format" => $path . $config->getValue("post_trackbacks_link_format"), "template_link_format" => $path . $config->getValue("template_link_format"), "album_link_format" => $path . $config->getValue("album_link_format"), "resource_link_format" => $path . $config->getValue("resource_link_format"), "resource_download_link_format" => $path . $config->getValue("resource_download_link_format"), "resource_preview_link_format" => $path . $config->getValue("resource_preview_link_format"), "resource_medium_size_preview_link_format" => $path . $config->getValue("resource_medium_size_preview_link_format"));
     // if the url did not match any of the current settings, then let's try to parse it as an old
     // "search engine friendly" url
     $this->_fallback = array("permalink_format" => $path . "/post/{blogid}/{postid}", "category_link_format" => $path . "/category/{blogid}/{catid}", "blog_link_format" => $path . "/{blogid}", "archive_link_format" => $path . "/archives/{blogid}/{year}/{month}/{day}", "user_posts_link_format" => $path . "/user/{blogid}/{userid}", "post_trackbacks_link_format" => $path . "/trackbacks/{blogid}/{postid}", "template_link_format" => $path . "/static/{blogid}/{templatename}", "album_link_format" => $path . "/album/{blogid}/{albumid}", "resource_link_format" => $path . "/resource/{blogid}/{resourceid}", "resource_download_link_format" => $path . "/get/{blogid}/{resourceid}", "resource_preview_link_format" => "", "resource_medium_size_preview_link_format" => "");
     // this one does not exist either
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:23,代码来源:customurlhandler.class.php

示例13: test1

 public function test1()
 {
     // test url manipulation
     $url = new Url();
     $url->set('http://www.test.com/');
     $this->assertEquals($url->getPath(), '/');
     $url->setParam('cat', 1);
     $this->assertEquals($url->get(), 'http://www.test.com/?cat=1');
     $this->assertEquals($url->getPath(), '/?cat=1');
     $url->removeParam('cat');
     $url->setParam('t', 'kalas');
     $url->setParam('f', 'bas');
     $this->assertEquals($url->get(), 'http://www.test.com/?t=kalas&f=bas');
     $this->assertEquals($url->getPath(), '/?t=kalas&f=bas');
     $url = new Url('http://test.com/?param');
     $this->assertEquals($url->get(), 'http://test.com/?param');
     $this->assertEquals($url->getPath(), '/?param');
     $url = new Url('http://test.com/?p=n;hb=HEAD');
     $this->assertEquals($url->get(), 'http://test.com/?p=n;hb=HEAD');
     $this->assertEquals($url->getPath(), '/?p=n;hb=HEAD');
     $url = new Url('http://test.com/?q=minuter+p%E5+skoj');
     $this->assertEquals($url->get(), 'http://test.com/?q=minuter+p%E5+skoj');
     $this->assertEquals($url->getPath(), '/?q=minuter+p%E5+skoj');
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:24,代码来源:UrlTest.php

示例14: constructUrl

 /**
  * Constructs absolute URL from Request object.
  * @return string|NULL
  */
 public function constructUrl(PresenterRequest $appRequest, Url $refUrl)
 {
     if ($this->flags & self::ONE_WAY) {
         return NULL;
     }
     $params = $appRequest->getParameters();
     // presenter name
     $presenter = $appRequest->getPresenterName();
     if (strncasecmp($presenter, $this->module, strlen($this->module)) === 0) {
         $params[self::PRESENTER_KEY] = substr($presenter, strlen($this->module));
     } else {
         return NULL;
     }
     // remove default values; NULL values are retain
     foreach ($this->defaults as $key => $value) {
         if (isset($params[$key]) && $params[$key] == $value) {
             // intentionally ==
             unset($params[$key]);
         }
     }
     $url = ($this->flags & self::SECURED ? 'https://' : 'http://') . $refUrl->getAuthority() . $refUrl->getPath();
     $sep = ini_get('arg_separator.input');
     $query = http_build_query($params, '', $sep ? $sep[0] : '&');
     if ($query != '') {
         // intentionally ==
         $url .= '?' . $query;
     }
     return $url;
 }
开发者ID:riskatlas,项目名称:micka,代码行数:33,代码来源:SimpleRouter.php

示例15:

<form class="mt10 mb10 bg-gray widget-form widget-form-toolbar" method="get">
    <div class="fl">
        <label class="label">比赛标题</label>
        <input class="w250 input" type="text" name="title" value="<?php 
echo Request::getGET('title');
?>
" />
        <input type="hidden" name="uri" value="<?php 
echo Url::getPath();
?>
" />
        <input class="w80 btn" type="submit" value="查找" />
    </div>
    <div class="fr">
        <?php 
if (Url::getPath() == '/diy_list/') {
    ?>
            <a href="/setup_contest_list/" class="f12" style="display: inline-block; padding-top: 6px;" >&lt;&lt; 我要创建DIY比赛<span class="fw red">【HOT】</span></a>&nbsp;
        <?php 
}
?>
        <label class="label">比赛进行状态</label>
        <select class="select" name="passed">
            <option <?php 
echo (int) Request::getGET('passed', 0) == 0 ? 'selected' : '';
?>
 value="0">当前</option>
            <option <?php 
echo (int) Request::getGET('passed', 0) == 1 ? 'selected' : '';
?>
 value="1">已结束</option>
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:31,代码来源:list.php


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