本文整理汇总了PHP中Title::newFromLinkTarget方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::newFromLinkTarget方法的具体用法?PHP Title::newFromLinkTarget怎么用?PHP Title::newFromLinkTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::newFromLinkTarget方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTitle
/**
* @return Title
* @deprecated Internal class use only
*/
public function getTitle()
{
if (!$this->title) {
$this->title = Title::newFromLinkTarget($this->linkTarget);
}
return $this->title;
}
示例2: renderHtmlLink
/**
* Returns an HTML link to the given page, using the given surface text.
*
* @param LinkTarget $linkTarget The link's target
* @param string $text The link's surface text (will be derived from $page if not given).
*
* @return string
*/
public function renderHtmlLink(LinkTarget $linkTarget, $text = null)
{
if ($text === null) {
$text = $this->formatter->getFullText($linkTarget);
}
// TODO: move the logic implemented by Linker here,
// using $this->formatter and $this->baseUrl, and
// re-implement Linker to use a HtmlPageLinkRenderer.
if ($linkTarget instanceof Title) {
$title = $linkTarget;
} else {
$title = Title::newFromLinkTarget($linkTarget);
}
$link = Linker::link($title, htmlspecialchars($text));
return $link;
}
示例3: testCategorizeTypeParameter
public function testCategorizeTypeParameter()
{
$user = $this->getLoggedInTestUser();
$subjectTarget = new TitleValue(0, 'ApiQueryWatchlistIntegrationTestPage');
$categoryTarget = new TitleValue(NS_CATEGORY, 'ApiQueryWatchlistIntegrationTestCategory');
$this->doPageEdits($user, [['target' => $categoryTarget, 'content' => 'Some Content', 'summary' => 'Create the category'], ['target' => $subjectTarget, 'content' => 'Some Content [[Category:ApiQueryWatchlistIntegrationTestCategory]]t', 'summary' => 'Create the page and add it to the category']]);
$title = Title::newFromLinkTarget($subjectTarget);
$revision = Revision::newFromTitle($title);
$rc = RecentChange::newForCategorization($revision->getTimestamp(), Title::newFromLinkTarget($categoryTarget), $user, $revision->getComment(), $title, 0, $revision->getId(), null, false);
$rc->save();
$this->watchPages($user, [$subjectTarget, $categoryTarget]);
$result = $this->doListWatchlistRequest(['wlprop' => 'title', 'wltype' => 'categorize']);
$this->assertEquals([['type' => 'categorize', 'ns' => $categoryTarget->getNamespace(), 'title' => $this->getPrefixedText($categoryTarget)]], $this->getItemsFromApiResponse($result));
}
示例4: formatTemplate
/**
* Builds an <li> item for an individual template
*
* @param LinkTarget $target
* @return string
*/
private function formatTemplate(LinkTarget $target)
{
// TODO Would be nice if we didn't have to use Title here
$titleObj = Title::newFromLinkTarget($target);
$protected = $this->getRestrictionsText($titleObj->getRestrictions('edit'));
$editLink = $this->buildEditLink($titleObj);
return '<li>' . $this->linkRenderer->makeLink($target) . $this->context->msg('word-separator')->escaped() . $this->context->msg('parentheses')->rawParams($editLink)->escaped() . $this->context->msg('word-separator')->escaped() . $protected . '</li>';
}
示例5: duplicateAllAssociatedEntries
/**
* Check if the given title already is watched by the user, and if so
* add a watch for the new title.
*
* To be used for page renames and such.
*
* @param LinkTarget $oldTarget
* @param LinkTarget $newTarget
*/
public function duplicateAllAssociatedEntries(LinkTarget $oldTarget, LinkTarget $newTarget)
{
$oldTarget = Title::newFromLinkTarget($oldTarget);
$newTarget = Title::newFromLinkTarget($newTarget);
$this->duplicateEntry($oldTarget->getSubjectPage(), $newTarget->getSubjectPage());
$this->duplicateEntry($oldTarget->getTalkPage(), $newTarget->getTalkPage());
}
示例6: getImageLinkMTOParams
/**
* Get the link parameters for MediaTransformOutput::toHtml() from given
* frame parameters supplied by the Parser.
* @param array $frameParams The frame parameters
* @param string $query An optional query string to add to description page links
* @param Parser|null $parser
* @return array
*/
private static function getImageLinkMTOParams($frameParams, $query = '', $parser = null)
{
$mtoParams = [];
if (isset($frameParams['link-url']) && $frameParams['link-url'] !== '') {
$mtoParams['custom-url-link'] = $frameParams['link-url'];
if (isset($frameParams['link-target'])) {
$mtoParams['custom-target-link'] = $frameParams['link-target'];
}
if ($parser) {
$extLinkAttrs = $parser->getExternalLinkAttribs($frameParams['link-url']);
foreach ($extLinkAttrs as $name => $val) {
// Currently could include 'rel' and 'target'
$mtoParams['parser-extlink-' . $name] = $val;
}
}
} elseif (isset($frameParams['link-title']) && $frameParams['link-title'] !== '') {
$mtoParams['custom-title-link'] = Title::newFromLinkTarget(self::normaliseSpecialPage($frameParams['link-title']));
} elseif (!empty($frameParams['no-link'])) {
// No link
} else {
$mtoParams['desc-link'] = true;
$mtoParams['desc-query'] = $query;
}
return $mtoParams;
}