r88159 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88158‎ | r88159 | r88160 >
Date:12:24, 15 May 2011
Author:mkroetzsch
Status:ok
Tags:
Comment:
move support for Title generation to the WikiPage data item
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php
@@ -276,11 +276,7 @@
277277 */
278278 public function getTitle() {
279279 if ( ( $this->isValid() ) && ( $this->m_title === null ) ) {
280 - if ( $this->m_dataitem->getInterwiki() == '' ) {
281 - $this->m_title = Title::makeTitleSafe( $this->m_dataitem->getNamespace(), $this->m_dataitem->getDBkey() );
282 - } else { // interwiki title objects must be built from full input texts
283 - $this->m_title = Title::newFromText( $this->getPrefixedText() );
284 - }
 280+ $this->m_title = $this->m_dataitem->getTitle();
285281 }
286282
287283 if ( $this->m_title === null ) { // should not normally happen, but anyway ...
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php
@@ -74,6 +74,25 @@
7575 return $this->m_dbkey;
7676 }
7777
 78+ /**
 79+ * Create a MediaWiki Title object for this SMWDIWikiPage. The result
 80+ * can be null if an error occurred.
 81+ *
 82+ * @todo From MW 1.17 on, makeTitleSafe supports interwiki prefixes.
 83+ * This function can be simplified when compatibility to MW 1.16 is
 84+ * dropped.
 85+ * @return mixed Title or null
 86+ */
 87+ public function getTitle() {
 88+ if ( $this->m_interwiki == '' ) {
 89+ return Title::makeTitleSafe( $this->m_namespace, $this->m_dbkey, '' );
 90+ } else {
 91+ $datavalue = new SMWWikiPageValue( '_wpg' );
 92+ $datavalue->setDataItem( $this );
 93+ return Title::newFromText( $datavalue->getPrefixedText() );
 94+ }
 95+ }
 96+
7897 public function getSerialization() {
7998 return strval( $this->m_dbkey . '#' . strval( $this->m_namespace ) . '#' . $this->m_interwiki );
8099 }

Status & tagging log