http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88159

Revision: 88159
Author:   mkroetzsch
Date:     2011-05-15 12:24:09 +0000 (Sun, 15 May 2011)
Log Message:
-----------
move support for Title generation to the WikiPage data item

Modified Paths:
--------------
    trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php
    trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php

Modified: 
trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php   
2011-05-15 12:09:59 UTC (rev 88158)
+++ trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php   
2011-05-15 12:24:09 UTC (rev 88159)
@@ -74,6 +74,25 @@
                return $this->m_dbkey;
        }
 
+       /**
+        * Create a MediaWiki Title object for this SMWDIWikiPage. The result
+        * can be null if an error occurred.
+        *
+        * @todo From MW 1.17 on, makeTitleSafe supports interwiki prefixes.
+        * This function can be simplified when compatibility to MW 1.16 is
+        * dropped.
+        * @return mixed Title or null
+        */
+       public function getTitle() {
+               if ( $this->m_interwiki == '' ) {
+                       return Title::makeTitleSafe( $this->m_namespace, 
$this->m_dbkey, '' );
+               } else {
+                       $datavalue = new SMWWikiPageValue( '_wpg' );
+                       $datavalue->setDataItem( $this );
+                       return Title::newFromText( 
$datavalue->getPrefixedText() );
+               }
+       }
+
        public function getSerialization() {
                return strval( $this->m_dbkey . '#' . strval( 
$this->m_namespace ) . '#' . $this->m_interwiki );
        }

Modified: 
trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php
===================================================================
--- trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php  
2011-05-15 12:09:59 UTC (rev 88158)
+++ trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php  
2011-05-15 12:24:09 UTC (rev 88159)
@@ -276,11 +276,7 @@
         */
        public function getTitle() {
                if ( ( $this->isValid() ) && ( $this->m_title === null ) ) {
-                       if ( $this->m_dataitem->getInterwiki() == '' ) {
-                               $this->m_title = Title::makeTitleSafe( 
$this->m_dataitem->getNamespace(), $this->m_dataitem->getDBkey() );
-                       } else { // interwiki title objects must be built from 
full input texts
-                               $this->m_title = Title::newFromText( 
$this->getPrefixedText() );
-                       }
+                       $this->m_title = $this->m_dataitem->getTitle();
                }
 
                if ( $this->m_title === null ) { // should not normally happen, 
but anyway ...


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to