* @return Title
*/
public static function newFromTitleValue( TitleValue $titleValue ) {
+ return self::newFromLinkTarget( $titleValue );
+ }
+
+ /**
+ * Create a new Title from a LinkTarget
+ *
+ * @param LinkTarget $linkTarget Assumed to be safe.
+ *
+ * @return Title
+ */
+ public static function newFromLinkTarget( LinkTarget $linkTarget ) {
return self::makeTitle(
- $titleValue->getNamespace(),
- $titleValue->getText(),
- $titleValue->getFragment() );
+ $linkTarget->getNamespace(),
+ $linkTarget->getText(),
+ $linkTarget->getFragment() );
}
/**
/**
* Returns the (partial) URL for the given page (including any section identifier).
*
- * @param TitleValue $page The link's target
+ * @param LinkTarget $page The link's target
* @param array $params Any additional URL parameters.
*
* @return string
*/
- public function getPageUrl( TitleValue $page, $params = array() ) {
+ public function getPageUrl( LinkTarget $page, $params = array() ) {
// TODO: move the code from Linker::linkUrl here!
// The below is just a rough estimation!
/**
* Returns an HTML link to the given page, using the given surface text.
*
- * @param TitleValue $page The link's target
+ * @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( TitleValue $page, $text = null ) {
+ public function renderHtmlLink( LinkTarget $linkTarget, $text = null ) {
if ( $text === null ) {
- $text = $this->formatter->getFullText( $page );
+ $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.
- $title = Title::newFromTitleValue( $page );
+ if ( $linkTarget instanceof Title ) {
+ $title = $linkTarget;
+ } else {
+ $title = Title::newFromLinkTarget( $linkTarget );
+ }
$link = Linker::link( $title, htmlspecialchars( $text ) );
return $link;
/**
* Returns a wikitext link to the given page, using the given surface text.
*
- * @param TitleValue $page The link's target
+ * @param LinkTarget $page The link's target
* @param string $text The link's surface text (will be derived from $page if not given).
*
* @return string
*/
- public function renderWikitextLink( TitleValue $page, $text = null ) {
+ public function renderWikitextLink( LinkTarget $page, $text = null ) {
if ( $text === null ) {
$text = $this->formatter->getFullText( $page );
}
/**
* @see TitleFormatter::getText()
*
- * @param TitleValue $title
+ * @param LinkTarget $title
*
* @return string $title->getText()
*/
- public function getText( TitleValue $title ) {
+ public function getText( LinkTarget $title ) {
return $this->formatTitle( false, $title->getText(), '' );
}
/**
* @see TitleFormatter::getText()
*
- * @param TitleValue $title
+ * @param LinkTarget $title
*
* @return string
*/
- public function getPrefixedText( TitleValue $title ) {
+ public function getPrefixedText( LinkTarget $title ) {
return $this->formatTitle( $title->getNamespace(), $title->getText(), '' );
}
/**
* @see TitleFormatter::getText()
*
- * @param TitleValue $title
+ * @param LinkTarget $title
*
* @return string
*/
- public function getFullText( TitleValue $title ) {
+ public function getFullText( LinkTarget $title ) {
return $this->formatTitle( $title->getNamespace(), $title->getText(), $title->getFragment() );
}
*
* @todo expand this to cover the functionality of Linker::linkUrl
*
- * @param TitleValue $page The link's target
+ * @param LinkTarget $page The link's target
* @param array $params Any additional URL parameters.
*
* @return string
*/
- public function getPageUrl( TitleValue $page, $params = array() );
+ public function getPageUrl( LinkTarget $page, $params = array() );
/**
* Returns an HTML link to the given page, using the given surface text.
*
* @todo expand this to cover the functionality of Linker::link
*
- * @param TitleValue $page The link's target
+ * @param LinkTarget $page 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( TitleValue $page, $text = null );
+ public function renderHtmlLink( LinkTarget $page, $text = null );
/**
* Returns a wikitext link to the given page, using the given surface text.
*
- * @param TitleValue $page The link's target
+ * @param LinkTarget $page The link's target
* @param string $text The link's surface text (will be derived from $page if not given).
*
* @return string
*/
- public function renderWikitextLink( TitleValue $page, $text = null );
+ public function renderWikitextLink( LinkTarget $page, $text = null );
}
*
* @note Only minimal normalization is applied. Consider using TitleValue::getText() directly.
*
- * @param TitleValue $title The title to format
+ * @param LinkTarget $title The title to format
*
* @return string
*/
- public function getText( TitleValue $title );
+ public function getText( LinkTarget $title );
/**
* Returns the title formatted for display, including the namespace name.
*
- * @param TitleValue $title The title to format
+ * @param LinkTarget $title The title to format
*
* @return string
*/
- public function getPrefixedText( TitleValue $title );
+ public function getPrefixedText( LinkTarget $title );
/**
* Returns the title formatted for display, with namespace and fragment.
*
- * @param TitleValue $title The title to format
+ * @param LinkTarget $title The title to format
*
* @return string
*/
- public function getFullText( TitleValue $title );
+ public function getFullText( LinkTarget $title );
/**
* Returns the name of the namespace for the given title.