r102395 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102394‎ | r102395 | r102396 >
Date:12:39, 8 November 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added support for containers
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Distributable.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_Distributable.php
@@ -164,10 +164,8 @@
165165 $name = $row[0]->getNextDataValue()->getShortWikiText();
166166
167167 foreach ( $row as $field ) {
168 - while ( ( $object = $field->getNextDataValue() ) !== false ) {
169 - if ( $object->isNumeric() ) { // use numeric sortkey
170 - $values[$name] = $object->getDataItem()->getNumber();
171 - }
 168+ while ( ( /* SMWDataItem */ $dataItem = $field->getNextDataItem() ) !== false ) {
 169+ $this->addNumbersForDataItem( $dataItem, $values, $name );
172170 }
173171 }
174172 }
@@ -176,6 +174,29 @@
177175 }
178176
179177 /**
 178+ * Adds all numbers contained in a dataitem to the list.
 179+ *
 180+ * @since 1.7
 181+ *
 182+ * @param SMWDataItem $dataItem
 183+ * @param array $values
 184+ * @param string $name
 185+ */
 186+ protected function addNumbersForDataItem( SMWDataItem $dataItem, array &$values, $name ) {
 187+ switch ( $dataItem->getDIType() ) {
 188+ case SMWDataItem::TYPE_NUMBER:
 189+ $values[$name] = $dataItem->getNumber();
 190+ break;
 191+ case SMWDataItem::TYPE_CONTAINER:
 192+ foreach ( $dataItem->getDataItems() as $di ) {
 193+ $this->addNumbersForDataItem( $di, $values, $name );
 194+ }
 195+ break;
 196+ default:
 197+ }
 198+ }
 199+
 200+ /**
180201 * @see SMWResultPrinter::getParameters
181202 * @since 1.7
182203 */
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_WikiPage.php
@@ -48,6 +48,7 @@
4949 if ( !is_numeric( $namespace ) ) {
5050 throw new SMWDataItemException( "Given namespace '$namespace' is not an integer." );
5151 }
 52+
5253 $this->m_dbkey = $dbkey;
5354 $this->m_namespace = (int)$namespace; // really make this an integer
5455 $this->m_interwiki = $interwiki;