本文整理汇总了PHP中Title::isRedirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::isRedirect方法的具体用法?PHP Title::isRedirect怎么用?PHP Title::isRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::isRedirect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRedirectTarget
/**
* If this page is a redirect, get its target
*
* The target will be fetched from the redirect table if possible.
* If this page doesn't have an entry there, call insertRedirect()
* @return Title|mixed object, or null if this page is not a redirect
*/
public function getRedirectTarget() {
if ( !$this->mTitle->isRedirect() ) {
return null;
}
if ( $this->mRedirectTarget !== null ) {
return $this->mRedirectTarget;
}
// Query the redirect table
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'redirect',
array( 'rd_namespace', 'rd_title', 'rd_fragment', 'rd_interwiki' ),
array( 'rd_from' => $this->getId() ),
__METHOD__
);
// rd_fragment and rd_interwiki were added later, populate them if empty
if ( $row && !is_null( $row->rd_fragment ) && !is_null( $row->rd_interwiki ) ) {
return $this->mRedirectTarget = Title::makeTitle(
$row->rd_namespace, $row->rd_title,
$row->rd_fragment, $row->rd_interwiki );
}
// This page doesn't have an entry in the redirect table
return $this->mRedirectTarget = $this->insertRedirect();
}
示例2: followRedirect
/**
* Function to follow redirects
*
* @param $title Title
* @return Title|null null if the page is an interwiki redirect
*/
public static function followRedirect(Title $title)
{
if (!$title->isRedirect()) {
return $title;
}
$wikipage = WikiPage::factory($title);
$target = $wikipage->followRedirect();
if ($target instanceof Title) {
return $target;
} else {
return null;
// Interwiki redirect
}
}
示例3: buildBacklinkSubtitle
/**
* Build message object for a subtitle containing a backlink to a page
*
* @param Title $title Title to link to
* @param array $query Array of additional parameters to include in the link
* @return Message
* @since 1.25
*/
public static function buildBacklinkSubtitle(Title $title, $query = array())
{
if ($title->isRedirect()) {
$query['redirect'] = 'no';
}
return wfMessage('backlinksubtitle')->rawParams(Linker::link($title, null, array(), $query));
}
示例4: addBacklinkSubtitle
/**
* Add a subtitle containing a backlink to a page
*
* @param Title $title Title to link to
*/
public function addBacklinkSubtitle(Title $title)
{
$query = array();
if ($title->isRedirect()) {
$query['redirect'] = 'no';
}
$this->addSubtitle($this->msg('backlinksubtitle')->rawParams(Linker::link($title, null, array(), $query)));
}
示例5: getLinkColour
/**
* Return the CSS colour of a known link
*
* @param Title $t
* @param int $threshold User defined threshold
* @return string CSS class
*/
public static function getLinkColour($t, $threshold)
{
$colour = '';
if ($t->isRedirect()) {
# Page is a redirect
$colour = 'mw-redirect';
} elseif ($threshold > 0 && $t->isContentPage() && $t->exists() && $t->getLength() < $threshold) {
# Page is a stub
$colour = 'stub';
}
return $colour;
}
示例6: isMainPage
/**
* Check if page is the main page after follow redirect when followRedirects is true.
*
* @param Title $title Title object to check
* @return boolean
*/
protected function isMainPage($title)
{
if ($title->isRedirect() && $this->followRedirects) {
$wp = $this->makeWikiPage($title);
$target = $wp->getRedirectTarget();
if ($target) {
return $target->isMainPage();
}
}
return $title->isMainPage();
}
示例7: getLinkColour
/**
* Return the CSS colour of a known link
*
* @param Title $t
* @param integer $threshold user defined threshold
* @return string CSS class
*/
function getLinkColour($t, $threshold)
{
$colour = '';
if ($t->isRedirect()) {
# Page is a redirect
$colour = 'mw-redirect';
} elseif ($threshold > 0 && $t->exists() && $t->getLength() < $threshold && MWNamespace::isContent($t->getNamespace())) {
# Page is a stub
$colour = 'stub';
}
return $colour;
}