r84867 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84866‎ | r84867 | r84868 >
Date:18:00, 27 March 2011
Author:mkroetzsch
Status:deferred
Tags:
Comment:
removed all traces of "modifiers" in the export code (were only needed for properties with units of measurement, which have now been simplified)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_ExportController.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php
@@ -65,8 +65,6 @@
6666 protected $m_namespace = false;
6767 protected $m_namespaceid = false;
6868 protected $m_localname = false;
69 - protected $m_modifier = ''; // "modifier" string: resources might refer to a wiki page,
70 - // but many resources may refer to the same page, using different modifiers (e.g.: unit strings)
7169
7270 /**
7371 * Constructor. $dv is the SMWDataValue from which this object was created,
@@ -93,37 +91,6 @@
9492 }
9593
9694 /**
97 - * SMW uses URI-Refs (#) to make "variants" of some base URI, e.g. to create multiple
98 - * versions of a property to store values with multiple units of measurement. This function
99 - * creates such a variant based on a given string label (e.g. unit) and returns a stuitable
100 - * SMWExpResource.
101 - */
102 - public function makeVariant( $modifier ) {
103 - if ( $this->m_namespace != false ) {
104 - $result = new SMWExpResource( $this->m_localname . SMWExporter::encodeURI( urlencode( str_replace( ' ', '_', '#' . $modifier ) ) ),
105 - $this->m_dv, $this->m_namespace, $this->m_namespaceid );
106 - } else {
107 - $result = new SMWExpResource( $this->m_name . SMWExporter::encodeURI( urlencode( str_replace( ' ', '_', '#' . $modifier ) ) ), $this->m_dv );
108 - }
109 - $result->setModifier( $modifier );
110 - return $result;
111 - }
112 -
113 - /**
114 - * See comment for SMWExpResource::m_modifier and SMWExpResource::makeVariant().
115 - */
116 - public function setModifier( $modifier ) {
117 - $this->m_modifier = $modifier;
118 - }
119 -
120 - /**
121 - * See comment for SMWExpResource::m_modifier and SMWExpResource::makeVariant().
122 - */
123 - public function getModifier() {
124 - return $this->m_modifier;
125 - }
126 -
127 - /**
12895 * Return a qualitifed name for the element, or false if no such name could be found.
12996 */
13097 public function getQName() {
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_ExportController.php
@@ -162,7 +162,6 @@
163163
164164 foreach ( $data->getProperties() as $property ) {
165165 if ( $property->getDataValue() instanceof SMWWikiPageValue ) {
166 - // TODO This currently drops modifiers (units of measurement)
167166 $this->queuePage( $property->getDataValue(), 0 ); // no real recursion along properties
168167 }
169168 $wikipagevalues = false;
@@ -455,7 +454,7 @@
456455 $this->serializeSmallTitle( reset( $this->element_queue ) );
457456 // resolve dependencies that will otherwise not be printed
458457 foreach ( $this->element_queue as $key => $staux ) {
459 - if ( !smwfIsSemanticsProcessed( $staux->namespace ) || //( $staux->modifier !== '' ) ||
 458+ if ( !smwfIsSemanticsProcessed( $staux->namespace ) ||
460459 !SMWExportController::fitsNsRestriction( $ns_restriction, $staux->namespace ) ) {
461460 // Note: we do not need to check the cache to guess if an element was already
462461 // printed. If so, it would not be included in the queue in the first place.
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php
@@ -42,18 +42,9 @@
4343 }
4444
4545 /**
46 - * Create exportable data from a given semantic data record. If given, the
47 - * string $modifier is used as a modifier to the URI of the subject (e.g. a
48 - * unit for properties). The function itself introduces modifiers for the
49 - * SMWResourceElement objects that it creates to represent properties with
50 - * units. When exporting further data for such properties recursively,
51 - * these modifiers should be provided (they are not part of the
52 - * SMWPageValue that is part of the SMWSemanticData object, since units are
53 - * part of data values in SMW, but part of property names in the RDF export
54 - * for better tool compatibility). This is the origin of all modifier
55 - * strings that are used with this method.
 46+ * Create exportable data from a given semantic data record.
5647 */
57 - static public function makeExportData( /*SMWSemanticData*/ $semdata, $modifier = '' ) {
 48+ static public function makeExportData( /*SMWSemanticData*/ $semdata ) {
5849 SMWExporter::initBaseURIs();
5950 $subject = $semdata->getSubject();
6051 if ( $subject->getNamespace() == SMW_NS_PROPERTY ) {
@@ -61,7 +52,7 @@
6253 } else {
6354 $types = array();
6455 }
65 - $result = SMWExporter::makeExportDataForSubject( $subject, $modifier, end( $types ) );
 56+ $result = SMWExporter::makeExportDataForSubject( $subject, end( $types ) );
6657 foreach ( $semdata->getProperties() as $property ) {
6758 SMWExporter::addPropertyValues( $property, $semdata->getPropertyValues( $property ), $result );
6859 }
@@ -71,17 +62,14 @@
7263 /**
7364 * Make an SMWExpData object for the given page, and include the basic
7465 * properties about this subject that are not directly represented by
75 - * SMW property values. If given, the string $modifier is used as a
76 - * modifier to the URI of the subject (e.g. a unit for properties).
77 - * See also the documentation of makeExportData(). The optional parameter
78 - * $typevalueforproperty can be used to pass a particular SMWTypesValue
79 - * object that is used for determining the OWL type for property pages.
 66+ * SMW property values. The optional parameter $typevalueforproperty
 67+ * can be used to pass a particular SMWTypesValue object that is used
 68+ * for determining the OWL type for property pages.
8069 *
8170 * @param SMWWikiPageValue $subject
82 - * @param string $modifier
8371 * @param mixed $typesvalueforproperty either an SMWTypesValue or null
8472 */
85 - static public function makeExportDataForSubject( SMWWikiPageValue $subject, $modifier = '', $typesvalueforproperty = null ) {
 73+ static public function makeExportDataForSubject( SMWWikiPageValue $subject, $typesvalueforproperty = null ) {
8674 $result = $subject->getExportData();
8775 switch ( $subject->getNamespace() ) {
8876 case NS_CATEGORY: case SMW_NS_CONCEPT:
@@ -100,10 +88,6 @@
10189 $label = $subject->getWikiValue();
10290 $maintype_pe = SMWExporter::getSpecialElement( 'swivt', 'Subject' );
10391 }
104 - if ( $modifier != '' ) {
105 - $modifier = smwfHTMLtoUTF8( $modifier ); ///TODO: check if this is still needed
106 - $label .= ' (' . $modifier . ')';
107 - }
10892 $ed = new SMWExpData( new SMWExpLiteral( $label ) );
10993 $subj_title = $subject->getTitle();
11094 $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdfs', 'label' ), $ed );
@@ -114,14 +98,6 @@
11599 $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'rdf', 'type' ), new SMWExpData( $maintype_pe ) );
116100 $ed = new SMWExpData( new SMWExpLiteral( $subject->getNamespace(), null, 'http://www.w3.org/2001/XMLSchema#integer' ) );
117101 $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'wikiNamespace' ), $ed );
118 - if ( $modifier != '' ) { // make variant and possibly add meta data on base properties
119 - if ( $subject->getNamespace() == SMW_NS_PROPERTY ) {
120 - $ed = new SMWExpData( new SMWExpLiteral( $modifier, null, 'http://www.w3.org/2001/XMLSchema#string' ) );
121 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'modifier' ), $ed );
122 - $result->addPropertyObjectValue( SMWExporter::getSpecialElement( 'swivt', 'baseProperty' ), new SMWExpData( $result->getSubject() ) );
123 - }
124 - $result->setSubject( $result->getSubject()->makeVariant( $modifier ) );
125 - }
126102 return $result;
127103 }
128104
@@ -140,12 +116,7 @@
141117 foreach ( $values as $dv ) {
142118 $ed = $dv->getExportData();
143119 if ( $ed !== null ) {
144 - if ( ( $dv instanceof SMWNumberValue ) && ( $dv->getUnit() != '' ) ) {
145 - $pem = $pe->makeVariant( $dv->getUnit() );
146 - } else {
147 - $pem = $pe;
148 - }
149 - $data->addPropertyObjectValue( $pem, $ed );
 120+ $data->addPropertyObjectValue( $pe, $ed );
150121 }
151122 }
152123 } else { // pre-defined property, only exported if known
@@ -355,4 +326,5 @@
356327 return $data;
357328 }
358329
 330+
359331 }

Status & tagging log