* @author Daniel Kinzler
*/
class MalformedTitleException extends Exception {
-
}
* @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
*/
class MediaWikiPageLinkRenderer implements PageLinkRenderer {
-
/**
* @var TitleFormatter
*/
// re-implement Linker to use a HtmlPageLinkRenderer.
$title = Title::newFromTitleValue( $page );
$link = Linker::link( $title, htmlspecialchars( $text ) );
+
return $link;
}
* @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
*/
class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
-
/**
* @var Language
*/
*/
public function getNamespaceName( $namespace, $text ) {
if ( $this->language->needsGenderDistinction() &&
- MWNamespace::hasGenderDistinction( $namespace ) ) {
+ MWNamespace::hasGenderDistinction( $namespace )
+ ) {
//NOTE: we are assuming here that the title text is a user name!
$gender = $this->genderCache->getGenderOf( $text, __METHOD__ );
# Fill fields
$parts['dbkey'] = $dbkey;
+
return $parts;
}
-
}
* @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
*/
interface PageLinkRenderer {
-
/**
* Returns the URL for the given page.
*
* @return string
*/
public function renderWikitextLink( TitleValue $page, $text = null );
-
}
* @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
*/
interface TitleFormatter {
-
/**
* Returns the title formatted for display.
* Per default, this includes the namespace but not the fragment.
* @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
*/
interface TitleParser {
-
/**
* Parses the given text and constructs a TitleValue. Normalization
* is applied according to the rules appropriate for the form specified by $form.
* @see https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue
*/
class TitleValue {
-
/**
* @var int
*/
public function __toString() {
$name = $this->namespace . ':' . $this->dbkey;
- if ( $this->fragment !== '' ) {
+ if ( $this->fragment !== '' ) {
$name .= '#' . $this->fragment;
}