本文整理汇总了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}");
}
}
示例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;
}
示例3: testMakeUrlIndexes
/**
* @dataProvider provideMakeUrlIndexes()
* @covers ::wfMakeUrlIndexes
*/
public function testMakeUrlIndexes($url, $expected)
{
$index = wfMakeUrlIndexes($url);
$this->assertEquals($expected, $index, "wfMakeUrlIndexes(\"{$url}\")");
}
示例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;
}