X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FTitle.php;h=5dececee8e5fe4cdc9c68070a10ba77c29d586d2;hp=edfdacacc0bd9a43bfb421f5e572725df7b17d38;hb=fb79f30319b9ad2a7eb0f5f4d1668143ec8f963e;hpb=54afdcb8975c8e1672800355bfc2a19609eb9ec4 diff --git a/includes/Title.php b/includes/Title.php index edfdacacc0..5dececee8e 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -748,6 +748,8 @@ class Title implements LinkTarget { /** * Escape a text fragment, say from a link, for a URL * + * @deprecated since 1.30, use Sanitizer::escapeIdForLink() or escapeIdForExternalInterwiki() + * * @param string $fragment Containing a URL or link fragment (after the "#") * @return string Escaped string */ @@ -1316,6 +1318,23 @@ class Title implements LinkTarget { return self::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() ); } + /** + * Get a Title object associated with the talk page of this article, + * if such a talk page can exist. + * + * @since 1.30 + * + * @return Title The object for the talk page, + * or null if no associated talk page can exist, according to canHaveTalkPage(). + */ + public function getTalkPageIfDefined() { + if ( !$this->canHaveTalkPage() ) { + return null; + } + + return $this->getTalkPage(); + } + /** * Get a title object associated with the subject page of this * talk page @@ -1382,14 +1401,16 @@ class Title implements LinkTarget { /** * Get the fragment in URL form, including the "#" character if there is one + * * @return string Fragment in URL form */ public function getFragmentForURL() { if ( !$this->hasFragment() ) { return ''; - } else { - return '#' . self::escapeFragmentForURL( $this->getFragment() ); + } elseif ( $this->isExternal() && !$this->getTransWikiID() ) { + return '#' . Sanitizer::escapeIdForExternalInterwiki( $this->getFragment() ); } + return '#' . Sanitizer::escapeIdForLink( $this->getFragment() ); } /**