當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。