r79058 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79057‎ | r79058 | r79059 >
Date:14:13, 27 December 2010
Author:mkroetzsch
Status:deferred
Tags:
Comment:
small extensions and fixes of comments, done when re-viewing this code (further code restructuring will follow later)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Data.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_OWLExport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_OWLExport.php
@@ -187,7 +187,7 @@
188188 $cur_queue = array();
189189
190190 if ( 1 == $recursion ) {
191 - $cur_queue = $this->element_queue + $cur_queue; // make sure the array is *dublicated* instead of copying its ref
 191+ $cur_queue = $this->element_queue + $cur_queue; // make sure the array is *duplicated* instead of copying its ref
192192 $this->element_queue = array();
193193 }
194194
@@ -612,7 +612,7 @@
613613 * Print the triples associated to a specific page, and references those needed.
614614 * They get printed in the printFooter-function.
615615 *
616 - * @param $st The SMWSmallTitle wrapping the page to be exported
 616+ * @param $st SMWSmallTitle wrapping the page to be exported
617617 * @param $fullexport Boolean to define whether all the data for the page should
618618 * be exported, or whether just a definition of the given title.
619619 * @param $backlinks Boolean specifying if properties linking to the exported title
@@ -752,7 +752,7 @@
753753 /**
754754 * Add an extra namespace that was encountered during output. The method
755755 * checks whether the required namespace is available globally and adds
756 - * it to the list of extra_namesapce otherwise.
 756+ * it to the list of extra_namespace otherwise.
757757 */
758758 public function addExtraNamespace( $nsshort, $nsuri ) {
759759 if ( !array_key_exists( $nsshort, $this->global_namespaces ) ) {
@@ -804,7 +804,7 @@
805805 * caching purposes elsewhere.
806806 */
807807 protected function getSemanticData( $pagevalue, $core_props_only ) {
808 - $semdata = smwfGetStore()->getSemanticData( $pagevalue, $core_props_only ? array( '__spu', '__typ', '__imp' ) : false ); // maybe advise Store to retrieve only core things
 808+ $semdata = smwfGetStore()->getSemanticData( $pagevalue, $core_props_only ? array( '__spu', '__typ', '__imp' ) : false ); // advise store to retrieve only core things
809809 if ( $core_props_only ) { // be sure to filter all non-relevant things that may still be present in the retrieved
810810 $result = new SMWSemanticData( $pagevalue );
811811 foreach ( array( '__spu', '__typ', '__imp' ) as $propid ) {
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Data.php
@@ -125,7 +125,7 @@
126126 }
127127
128128 /**
129 - * Check if this element can be serialised using parserType="Collection" and
 129+ * Check if this element can be serialised using parseType="Collection" and
130130 * if yes return an array of SMWExpElements corresponding to the collection
131131 * elements in the specified order. Otherwise return false.
132132 */
@@ -135,7 +135,7 @@
136136 $rdfrest = SMWExporter::getSpecialElement( 'rdf', 'rest' );
137137 $rdfnil = SMWExporter::getSpecialElement( 'rdf', 'nil' );
138138 $name = $this->getSubject()->getName();
139 - // first check if we are basically an rdf List:
 139+ // first check if we are basically an RDF List:
140140 if ( ( ( $name == '' ) || ( $name { 0 } == '_' ) ) && // bnode
141141 ( array_key_exists( $rdftype->getName(), $this->m_children ) ) &&
142142 ( count( $this->m_children[$rdftype->getName()] ) == 1 ) &&
@@ -182,13 +182,14 @@
183183 foreach ( $this->m_edges as $key => $edge ) {
184184 foreach ( $this->m_children[$key] as $child ) {
185185 $name = $child->getSubject()->getName();
186 - if ( ( $name == '' ) || ( $name[0] == '_' ) ) { // bnode, distribute ID
 186+ if ( ( $name == '' ) || ( $name[0] == '_' ) ) { // bnode, rename ID to avoid unifying bnodes of different contexts
 187+ // TODO: should we really rename bnodes of the form "_id" here?
187188 $child = clone $child;
188189 $subject = new SMWExpElement( '_' . $smwgBnodeCount++, $child->getSubject()->getDataValue() );
189190 $child->setSubject( $subject );
190191 }
191192 $result[] = array( $this->m_subject, $edge, $child->getSubject() );
192 - $result = array_merge( $result, $child->getTripleList() ); // recursively generate all children of childs.
 193+ $result = array_merge( $result, $child->getTripleList() ); // recursively generate all children's triples
193194 }
194195 }
195196 return $result;
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Element.php
@@ -16,7 +16,7 @@
1717 * This class can also be used to represent blank nodes: It is assumed that all objects
1818 * of class SMWExpElement or any of its subclasses do represent blank node if their name
1919 * is empty or of the form "_id" where "id" is any identifier string. IDs are local to the
20 - * current context, which such as a list of triples or an SMWExpData container.
 20+ * current context, such as a list of triples or an SMWExpData container.
2121 * @ingroup SMW
2222 */
2323 class SMWExpElement {
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php
@@ -42,8 +42,16 @@
4343 }
4444
4545 /**
46 - * Create exportable data from a given semantic data record. If given, the string $modifier is used
47 - * as a modifier to the URI of the subject (e.g. a unit for properties).
 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.
4856 */
4957 static public function makeExportData( /*SMWSemanticData*/ $semdata, $modifier = '' ) {
5058 SMWExporter::initBaseURIs();
@@ -105,8 +113,8 @@
106114 $pe = SMWExporter::getResourceElement( $property );
107115 foreach ( $semdata->getPropertyValues( $property ) as $dv ) {
108116 $ed = $dv->getExportData();
109 - $pem = ( $dv->getUnit() != false ) ? $pe->makeVariant( $dv->getUnit() ):$pe;
110117 if ( $ed !== null ) {
 118+ $pem = ( $dv->getUnit() != false ) ? $pe->makeVariant( $dv->getUnit() ):$pe;
111119 $result->addPropertyObjectValue( $pem, $ed );
112120 }
113121 }

Status & tagging log