From db0d813d05a93d13cc2acf5db6d42ac0700e2f7d Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 10 Dec 2011 15:25:28 +0000 Subject: [PATCH] * Group related functions * Expand functions that were all declared in one line for consistency * Removed big "Static functions" and "Other stuff" comments that are just confusing --- includes/Title.php | 127 +++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 62 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 26e7a91caa..b7360ebabc 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -442,10 +442,6 @@ class Title { return null; } -# ---------------------------------------------------------------------------- -# Static functions -# ---------------------------------------------------------------------------- - /** * Get the prefixed DB key associated with an ID * @@ -530,6 +526,20 @@ class Title { return $name; } + /** + * Escape a text fragment, say from a link, for a URL + * + * @param $fragment string containing a URL or link fragment (after the "#") + * @return String: escaped string + */ + static function escapeFragmentForURL( $fragment ) { + # Note that we don't urlencode the fragment. urlencoded Unicode + # fragments appear not to work in IE (at least up to 7) or in at least + # one version of Opera 9.x. The W3C validator, for one, doesn't seem + # to care if they aren't encoded. + return Sanitizer::escapeId( $fragment, 'noninitial' ); + } + /** * Determine whether the object refers to a page within * this project. @@ -544,6 +554,24 @@ class Title { } } + /** + * Is this Title interwiki? + * + * @return Bool + */ + public function isExternal() { + return ( $this->mInterwiki != '' ); + } + + /** + * Get the interwiki prefix (or null string) + * + * @return String Interwiki prefix + */ + public function getInterwiki() { + return $this->mInterwiki; + } + /** * Determine whether the object refers to a page within * this project and is transcludable. @@ -571,52 +599,41 @@ class Title { return Interwiki::fetch( $this->mInterwiki )->getWikiID(); } - /** - * Escape a text fragment, say from a link, for a URL - * - * @param $fragment string containing a URL or link fragment (after the "#") - * @return String: escaped string - */ - static function escapeFragmentForURL( $fragment ) { - # Note that we don't urlencode the fragment. urlencoded Unicode - # fragments appear not to work in IE (at least up to 7) or in at least - # one version of Opera 9.x. The W3C validator, for one, doesn't seem - # to care if they aren't encoded. - return Sanitizer::escapeId( $fragment, 'noninitial' ); - } - -# ---------------------------------------------------------------------------- -# Other stuff -# ---------------------------------------------------------------------------- - - /** Simple accessors */ /** * Get the text form (spaces not underscores) of the main part * * @return String Main part of the title */ - public function getText() { return $this->mTextform; } + public function getText() { + return $this->mTextform; + } /** * Get the URL-encoded form of the main part * * @return String Main part of the title, URL-encoded */ - public function getPartialURL() { return $this->mUrlform; } + public function getPartialURL() { + return $this->mUrlform; + } /** * Get the main part with underscores * * @return String: Main part of the title, with underscores */ - public function getDBkey() { return $this->mDbkeyform; } + public function getDBkey() { + return $this->mDbkeyform; + } /** * Get the namespace index, i.e. one of the NS_xxxx constants. * * @return Integer: Namespace index */ - public function getNamespace() { return $this->mNamespace; } + public function getNamespace() { + return $this->mNamespace; + } /** * Get the namespace text @@ -693,13 +710,6 @@ class Title { return( MWNamespace::canTalk( $this->mNamespace ) ); } - /** - * Get the interwiki prefix (or null string) - * - * @return String Interwiki prefix - */ - public function getInterwiki() { return $this->mInterwiki; } - /** * Get the Title fragment (i.e.\ the bit after the #) in text form * @@ -724,7 +734,9 @@ class Title { * * @return Int Default namespace index */ - public function getDefaultNamespace() { return $this->mDefaultNamespace; } + public function getDefaultNamespace() { + return $this->mDefaultNamespace; + } /** * Get title for search index @@ -810,6 +822,16 @@ class Title { return( $parts[count( $parts ) - 1] ); } + /** + * Get the HTML-escaped displayable text form. + * Used for the title field in tags. + * + * @return String the text, including any prefixes + */ + public function getEscapedText() { + return htmlspecialchars( $this->getPrefixedText() ); + } + /** * Get a URL-encoded form of the subpage text * @@ -994,14 +1016,6 @@ class Title { return htmlspecialchars( $this->getFullURL( $query ) ); } - /** - * HTML-escaped version of getCanonicalURL() - * @since 1.18 - */ - public function escapeCanonicalURL( $query = '', $variant = false ) { - return htmlspecialchars( $this->getCanonicalURL( $query, $variant ) ); - } - /** * Get the URL form for an internal link. * - Used in various Squid-related code, in case we have a different @@ -1041,6 +1055,14 @@ class Title { return $url; } + /** + * HTML-escaped version of getCanonicalURL() + * @since 1.18 + */ + public function escapeCanonicalURL( $query = '', $variant = false ) { + return htmlspecialchars( $this->getCanonicalURL( $query, $variant ) ); + } + /** * Get the edit URL for this Title * @@ -1056,25 +1078,6 @@ class Title { return $s; } - /** - * Get the HTML-escaped displayable text form. - * Used for the title field in tags. - * - * @return String the text, including any prefixes - */ - public function getEscapedText() { - return htmlspecialchars( $this->getPrefixedText() ); - } - - /** - * Is this Title interwiki? - * - * @return Bool - */ - public function isExternal() { - return ( $this->mInterwiki != '' ); - } - /** * Is this page "semi-protected" - the *only* protection is autoconfirm? * -- 2.20.1