r83694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83693‎ | r83694 | r83695 >
Date:12:54, 11 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
adress bug 27991 and doc improvements
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Data.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exp_Data.php
@@ -50,6 +50,8 @@
5151
5252 /**
5353 * Return subject to which the stored semantic annotation refer to.
 54+ *
 55+ * @return SMWExpElement
5456 */
5557 public function getSubject() {
5658 return $this->m_subject;
@@ -57,6 +59,8 @@
5860
5961 /**
6062 * Set the subject element.
 63+ *
 64+ * @param SMWExpResource $subject
6165 */
6266 public function setSubject( SMWExpResource $subject ) {
6367 $this->m_subject = $subject;
@@ -64,7 +68,10 @@
6569
6670 /**
6771 * Store a value for a property identified by its title object. No duplicate elimination as this
68 - * is usually done in SMWSemanticData already (which is typically used to generate this object)
 72+ * is usually done in SMWSemanticData already (which is typically used to generate this object).
 73+ *
 74+ * @param SMWExpResource $property
 75+ * @param SMWExpData $child
6976 */
7077 public function addPropertyObjectValue( SMWExpResource $property, SMWExpData $child ) {
7178 if ( !array_key_exists( $property->getName(), $this->m_edges ) ) {
@@ -76,13 +83,17 @@
7784
7885 /**
7986 * Return the list of SMWExpElements for all properties for which some values exist.
 87+ *
 88+ * @return array of SMWExpElements
8089 */
8190 public function getProperties() {
8291 return $this->m_edges;
8392 }
8493
8594 /**
86 - * Return the list of SMWExpData values associated to some property (element)
 95+ * Return the list of SMWExpData values associated to some property (element).
 96+ *
 97+ * @return array of SMWExpData
8798 */
8899 public function getValues( SMWExpResource $property ) {
89100 if ( array_key_exists( $property->getName(), $this->m_children ) ) {
@@ -95,6 +106,8 @@
96107 /**
97108 * Return the list of SMWExpData values associated to some property that is
98109 * specifed by a standard namespace id and local name.
 110+ *
 111+ * @return array of SMWExpData
99112 */
100113 public function getSpecialValues( $namespace, $localname ) {
101114 $pe = SMWExporter::getSpecialElement( $namespace, $localname );
@@ -175,23 +188,29 @@
176189 */
177190 public function getTripleList() {
178191 global $smwgBnodeCount;
 192+
179193 if ( !isset( $smwgBnodeCount ) ) {
180194 $smwgBnodeCount = 0;
181195 }
 196+
182197 $result = array();
 198+
183199 foreach ( $this->m_edges as $key => $edge ) {
184200 foreach ( $this->m_children[$key] as $child ) {
185201 $name = $child->getSubject()->getName();
186 - if ( ( $name == '' ) || ( $name[0] == '_' ) ) { // bnode, rename ID to avoid unifying bnodes of different contexts
 202+
 203+ if ( $name === '' || $name[0] === '_' ) { // bnode, rename ID to avoid unifying bnodes of different contexts
187204 // TODO: should we really rename bnodes of the form "_id" here?
188205 $child = clone $child;
189206 $subject = new SMWExpResource( '_' . $smwgBnodeCount++, $child->getSubject()->getDataValue() );
190207 $child->setSubject( $subject );
191208 }
 209+
192210 $result[] = array( $this->m_subject, $edge, $child->getSubject() );
193211 $result = array_merge( $result, $child->getTripleList() ); // recursively generate all children's triples
194212 }
195213 }
 214+
196215 return $result;
197216 }
198217

Status & tagging log