本文整理汇总了PHP中ParserOutput::addLink方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOutput::addLink方法的具体用法?PHP ParserOutput::addLink怎么用?PHP ParserOutput::addLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOutput
的用法示例。
在下文中一共展示了ParserOutput::addLink方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetOutgoingLinks
public function testGetOutgoingLinks()
{
$parserOutput = new ParserOutput();
$parserOutput->addLink(Title::makeTitle(NS_MAIN, 'Foo_bar'), 1);
$parserOutput->addLink(Title::makeTitle(NS_HELP, 'Contents'), 2);
$searchDataExtractor = new ParserOutputSearchDataExtractor();
// this indexes links with db key
$this->assertEquals(['Foo_bar', 'Help:Contents'], $searchDataExtractor->getOutgoingLinks($parserOutput));
}
示例2: testUpdate_pagelinks
/**
* @covers LinksUpdate::addLink
*/
public function testUpdate_pagelinks()
{
list($t, $po) = $this->makeTitleAndParserOutput("Testing", 111);
$po->addLink(Title::newFromText("Foo"));
$po->addLink(Title::newFromText("Special:Foo"));
// special namespace should be ignored
$po->addLink(Title::newFromText("linksupdatetest:Foo"));
// interwiki link should be ignored
$po->addLink(Title::newFromText("#Foo"));
// hash link should be ignored
$update = $this->assertLinksUpdate($t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(array(NS_MAIN, 'Foo')));
$this->assertArrayEquals(array(Title::makeTitle(NS_MAIN, 'Foo')), $update->getAddedLinks());
$po = new ParserOutput();
$po->setTitleText($t->getPrefixedText());
$po->addLink(Title::newFromText("Bar"));
$po->addLink(Title::newFromText("Talk:Bar"));
$update = $this->assertLinksUpdate($t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(array(NS_MAIN, 'Bar'), array(NS_TALK, 'Bar')));
$this->assertArrayEquals(array(Title::makeTitle(NS_MAIN, 'Bar'), Title::makeTitle(NS_TALK, 'Bar')), $update->getAddedLinks());
$this->assertArrayEquals(array(Title::makeTitle(NS_MAIN, 'Foo')), $update->getRemovedLinks());
}
示例3: testUpdate_pagelinks
/**
* @covers ParserOutput::addLink
*/
public function testUpdate_pagelinks()
{
/** @var Title $t */
/** @var ParserOutput $po */
list($t, $po) = $this->makeTitleAndParserOutput("Testing", self::$testingPageId);
$po->addLink(Title::newFromText("Foo"));
$po->addLink(Title::newFromText("Special:Foo"));
// special namespace should be ignored
$po->addLink(Title::newFromText("linksupdatetest:Foo"));
// interwiki link should be ignored
$po->addLink(Title::newFromText("#Foo"));
// hash link should be ignored
$update = $this->assertLinksUpdate($t, $po, 'pagelinks', 'pl_namespace,
pl_title', 'pl_from = ' . self::$testingPageId, [[NS_MAIN, 'Foo']]);
$this->assertArrayEquals([Title::makeTitle(NS_MAIN, 'Foo')], $update->getAddedLinks());
$po = new ParserOutput();
$po->setTitleText($t->getPrefixedText());
$po->addLink(Title::newFromText("Bar"));
$po->addLink(Title::newFromText("Talk:Bar"));
$update = $this->assertLinksUpdate($t, $po, 'pagelinks', 'pl_namespace,
pl_title', 'pl_from = ' . self::$testingPageId, [[NS_MAIN, 'Bar'], [NS_TALK, 'Bar']]);
$this->assertArrayEquals([Title::makeTitle(NS_MAIN, 'Bar'), Title::makeTitle(NS_TALK, 'Bar')], $update->getAddedLinks());
$this->assertArrayEquals([Title::makeTitle(NS_MAIN, 'Foo')], $update->getRemovedLinks());
}
示例4: makeImage
//.........这里部分代码省略.........
} else {
# Validate internal parameters
switch ($paramName) {
case 'manualthumb':
case 'alt':
case 'class':
# @todo FIXME: Possibly check validity here for
# manualthumb? downstream behavior seems odd with
# missing manual thumbs.
$validated = true;
$value = $this->stripAltText($value, $holders);
break;
case 'link':
$chars = self::EXT_LINK_URL_CLASS;
$prots = $this->mUrlProtocols;
if ($value === '') {
$paramName = 'no-link';
$value = true;
$validated = true;
} elseif (preg_match("/^(?i){$prots}/", $value)) {
if (preg_match("/^((?i){$prots}){$chars}+\$/u", $value, $m)) {
$paramName = 'link-url';
$this->mOutput->addExternalLink($value);
if ($this->mOptions->getExternalLinkTarget()) {
$params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
}
$validated = true;
}
} else {
$linkTitle = Title::newFromText($value);
if ($linkTitle) {
$paramName = 'link-title';
$value = $linkTitle;
$this->mOutput->addLink($linkTitle);
$validated = true;
}
}
break;
default:
# Most other things appear to be empty or numeric...
$validated = $value === false || is_numeric(trim($value));
}
}
if ($validated) {
$params[$type][$paramName] = $value;
}
}
}
if (!$validated) {
$caption = $part;
}
}
# Process alignment parameters
if ($params['horizAlign']) {
$params['frame']['align'] = key($params['horizAlign']);
}
if ($params['vertAlign']) {
$params['frame']['valign'] = key($params['vertAlign']);
}
$params['frame']['caption'] = $caption;
# Will the image be presented in a frame, with the caption below?
$imageIsFramed = isset($params['frame']['frame']) || isset($params['frame']['framed']) || isset($params['frame']['thumbnail']) || isset($params['frame']['manualthumb']);
# In the old days, [[Image:Foo|text...]] would set alt text. Later it
# came to also set the caption, ordinary text after the image -- which
# makes no sense, because that just repeats the text multiple times in
# screen readers. It *also* came to set the title attribute.