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


PHP wfMakeUrlIndexes函数代码示例

本文整理汇总了PHP中wfMakeUrlIndexes函数的典型用法代码示例。如果您正苦于以下问题:PHP wfMakeUrlIndexes函数的具体用法?PHP wfMakeUrlIndexes怎么用?PHP wfMakeUrlIndexes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testMakeLikeArrayWithValidPatterns

 /**
  * testMakeLikeArrayWithValidPatterns()
  *
  * Tests whether the LIKE clause produced by LinkFilter::makeLikeArray($pattern, $protocol)
  * will find one of the URL indexes produced by wfMakeUrlIndexes($url)
  *
  * @dataProvider provideValidPatterns
  *
  * @param string $protocol Protocol, e.g. 'http://' or 'mailto:'
  * @param string $pattern Search pattern to feed to LinkFilter::makeLikeArray
  * @param string $url URL to feed to wfMakeUrlIndexes
  * @param bool $shouldBeFound Should the URL be found? (defaults true)
  */
 function testMakeLikeArrayWithValidPatterns($protocol, $pattern, $url, $shouldBeFound = true)
 {
     $indexes = wfMakeUrlIndexes($url);
     $likeArray = LinkFilter::makeLikeArray($pattern, $protocol);
     $this->assertTrue($likeArray !== false, "LinkFilter::makeLikeArray('{$pattern}', '{$protocol}') returned false on a valid pattern");
     $regex = $this->createRegexFromLIKE($likeArray);
     $debugmsg = "Regex: '" . $regex . "'\n";
     $debugmsg .= count($indexes) . " index(es) created by wfMakeUrlIndexes():\n";
     $matches = 0;
     foreach ($indexes as $index) {
         $matches += preg_match($regex, $index);
         $debugmsg .= "\t'{$index}'\n";
     }
     if ($shouldBeFound) {
         $this->assertTrue($matches > 0, "Search pattern '{$protocol}{$pattern}' does not find url '{$url}' \n{$debugmsg}");
     } else {
         $this->assertFalse($matches > 0, "Search pattern '{$protocol}{$pattern}' should not find url '{$url}' \n{$debugmsg}");
     }
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:32,代码来源:LinkFilterTest.php

示例2: getExternalInsertions

 /**
  * Get an array of externallinks insertions. Skips the names specified in $existing
  * @param array $existing
  * @return array
  */
 private function getExternalInsertions($existing = array())
 {
     $arr = array();
     $diffs = array_diff_key($this->mExternals, $existing);
     foreach ($diffs as $url => $dummy) {
         foreach (wfMakeUrlIndexes($url) as $index) {
             $arr[] = array('el_id' => $this->mDb->nextSequenceValue('externallinks_el_id_seq'), 'el_from' => $this->mId, 'el_to' => $url, 'el_index' => $index);
         }
     }
     return $arr;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:16,代码来源:LinksUpdate.php

示例3: testMakeUrlIndexes

 /**
  * @dataProvider provideMakeUrlIndexes()
  * @covers ::wfMakeUrlIndexes
  */
 public function testMakeUrlIndexes($url, $expected)
 {
     $index = wfMakeUrlIndexes($url);
     $this->assertEquals($expected, $index, "wfMakeUrlIndexes(\"{$url}\")");
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:9,代码来源:GlobalTest.php

示例4: getExternalInsertions

 /**
  * Get an array of externallinks insertions. Skips the names specified in $existing
  * @private
  */
 function getExternalInsertions($existing = array())
 {
     $arr = array();
     $diffs = array_diff_key($this->mExternals, $existing);
     foreach ($diffs as $url => $dummy) {
         foreach (wfMakeUrlIndexes($url) as $index) {
             $arr[] = array('el_from' => $this->mId, 'el_to' => $url, 'el_index' => $index);
         }
     }
     return $arr;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:15,代码来源:LinksUpdate.php


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