r86264 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86263‎ | r86264 | r86265 >
Date:15:20, 17 April 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
do not make Titles just for getting a URL encoded title string
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php
@@ -70,12 +70,19 @@
7171 * @param mixed $typesvalueforproperty either an SMWTypesValue or null
7272 */
7373 static public function makeExportDataForSubject( SMWDIWikiPage $subject, $typesvalueforproperty = null ) {
 74+ global $wgContLang;
7475 $result = new SMWExpData( self::getDataItemExpData( $subject ) );
75 - $subj_title = Title::makeTitle( $subject->getNamespace(), $subject->getDBkey() );
 76+ $subjectTitle = str_replace( '_', ' ', $subject->getDBkey() );
 77+ if ( $subject->getNamespace() !== 0 ) {
 78+ $prefixedSubjectTitle = $wgContLang->getNsText( $subject->getNamespace()) . ":" . $subjectTitle;
 79+ } else {
 80+ $prefixedSubjectTitle = $subjectTitle;
 81+ }
 82+ $prefixedSubjectUrl = wfUrlencode( str_replace( ' ', '_', $prefixedSubjectTitle ) );
7683 switch ( $subject->getNamespace() ) {
7784 case NS_CATEGORY: case SMW_NS_CONCEPT:
7885 $maintype_pe = SMWExporter::getSpecialNsResource( 'owl', 'Class' );
79 - $label = $subj_title->getText();
 86+ $label = $subjectTitle;
8087 break;
8188 case SMW_NS_PROPERTY:
8289 if ( $typesvalueforproperty == null ) {
@@ -83,17 +90,17 @@
8491 $typesvalueforproperty = end( $types );
8592 }
8693 $maintype_pe = SMWExporter::getSpecialNsResource( 'owl', SMWExporter::getOWLPropertyType( $typesvalueforproperty ) );
87 - $label = $subj_title->getText();
 94+ $label = $subjectTitle;
8895 break;
8996 default:
90 - $label = $subj_title->getPrefixedText();
 97+ $label = $prefixedSubjectTitle;
9198 $maintype_pe = SMWExporter::getSpecialNsResource( 'swivt', 'Subject' );
9299 }
93100 $ed = new SMWExpLiteral( $label );
94101 $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'label' ), $ed );
95 - $ed = new SMWExpResource( '&wikiurl;' . $subj_title->getPrefixedURL() );
 102+ $ed = new SMWExpResource( '&wikiurl;' . $prefixedSubjectUrl );
96103 $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'swivt', 'page' ), $ed );
97 - $ed = new SMWExpResource( SMWExporter::$m_exporturl . '/' . $subj_title->getPrefixedURL() );
 104+ $ed = new SMWExpResource( SMWExporter::$m_exporturl . '/' . $prefixedSubjectUrl );
98105 $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdfs', 'isDefinedBy' ), $ed );
99106 $result->addPropertyObjectValue( SMWExporter::getSpecialNsResource( 'rdf', 'type' ), $maintype_pe );
100107 $ed = new SMWExpLiteral( $subject->getNamespace(), 'http://www.w3.org/2001/XMLSchema#integer' );

Status & tagging log