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


PHP Net_URL2::getNormalizedURL方法代码示例

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


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

示例1: array

$cc = new \Console_CommandLine();
$cc->description = 'phinde URL processor';
$cc->version = '0.0.1';
$cc->addOption('force', array('short_name' => '-f', 'long_name' => '--force', 'description' => 'Always process URL, even when it did not change', 'action' => 'StoreTrue', 'default' => false));
$cc->addOption('showLinksOnly', array('short_name' => '-s', 'long_name' => '--show-links', 'description' => 'Only show which URLs were found', 'action' => 'StoreTrue', 'default' => false));
$cc->addArgument('url', array('description' => 'URL to process', 'multiple' => false));
$cc->addArgument('actions', array('description' => 'Actions to take', 'multiple' => true, 'optional' => true, 'choices' => array('index', 'crawl'), 'default' => array('index', 'crawl')));
try {
    $res = $cc->parse();
} catch (\Exception $e) {
    $cc->displayError($e->getMessage());
}
$url = $res->args['url'];
$url = Helper::addSchema($url);
$urlObj = new \Net_URL2($url);
$url = $urlObj->getNormalizedURL();
if (!Helper::isUrlAllowed($url)) {
    Log::error("Domain is not allowed; not crawling");
    exit(2);
}
try {
    $actions = array();
    foreach ($res->args['actions'] as $action) {
        if ($action == 'crawl') {
            $crawler = new Crawler();
            $crawler->setShowLinksOnly($res->options['showLinksOnly']);
            $actions[$action] = $crawler;
        } else {
            if ($action == 'index') {
                $actions[$action] = new Indexer();
            }
开发者ID:cweiske,项目名称:phinde,代码行数:31,代码来源:process.php

示例2: getNormalizedFileInfo

 /**
  * @param $path
  * @param null $document
  * @return array
  * @throws \Exception
  */
 public static function getNormalizedFileInfo($path, $document = null)
 {
     if ($document && $document instanceof Model\Document == false) {
         throw new \Exception('$document has to be an instance of Document');
     }
     $fileInfo = array();
     $hostUrl = Tool::getHostUrl();
     if ($path[0] != '/') {
         $fileInfo['fileUrl'] = $hostUrl . $document . "/{$path}";
         //relative eg. ../file.css
     } else {
         $fileInfo['fileUrl'] = $hostUrl . $path;
     }
     $fileInfo['fileExtension'] = substr($path, strrpos($path, '.') + 1);
     $netUrl = new \Net_URL2($fileInfo['fileUrl']);
     $fileInfo['fileUrlNormalized'] = $netUrl->getNormalizedURL();
     $fileInfo['filePathNormalized'] = PIMCORE_DOCUMENT_ROOT . str_replace($hostUrl, '', $fileInfo['fileUrlNormalized']);
     return $fileInfo;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:25,代码来源:Mail.php

示例3: testNoUserinfoAndNormalize

 /**
  * Tests an URL with no userinfo and normalization
  *
  * Also: Regression test for Bug #20385
  *
  * @covers Net_URL2::getUserinfo
  * @covers Net_URL2::normalize
  * @covers Net_URL2::getNormalizedURL
  * @return void
  * @link https://pear.php.net/bugs/bug.php?id=20385
  */
 public function testNoUserinfoAndNormalize()
 {
     $testUrl = 'http://www.example.com/';
     $url = new Net_URL2($testUrl);
     $this->assertFalse($url->getUserinfo());
     $url->normalize();
     $this->assertFalse($url->getUserinfo());
     $this->assertEquals($testUrl, $url->getURL());
     $this->assertEquals($testUrl, $url->getNormalizedURL());
 }
开发者ID:rafalwojciechowski,项目名称:news,代码行数:21,代码来源:URL2Test.php


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