r88079 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88078‎ | r88079 | r88080 >
Date:13:47, 14 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
implemented methods to loop over all properties and all changes for one property
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ChangeSet.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ChangeSet.php
@@ -207,15 +207,6 @@
208208 }
209209
210210 /**
211 - * Returns a list of ALL changes, including isertions and deletions.
212 - *
213 - * @return array of SMWPropertyChange
214 - */
215 - public function getAllChanges() {
216 - return array();
217 - }
218 -
219 - /**
220211 * Returns the subject these changes apply to.
221212 *
222213 * @return SMWDIWikiPage
@@ -225,23 +216,63 @@
226217 }
227218
228219 /**
 220+ * Adds a SMWPropertyChange to the set for the specified SMWDIProperty.
229221 *
230 - *
231 - * @param string $property
 222+ * @param SMWDIProperty $property
232223 * @param SMWPropertyChange $change
233224 */
234 - public function addChange( $property, SMWPropertyChange $change ) {
 225+ public function addChange( SMWDIProperty $property, SMWPropertyChange $change ) {
235226 switch ( $change->getType() ) {
236227 case SMWPropertyChange::TYPE_UPDATE:
237 - $this->changes->addPropertyChange( $property, $change );
 228+ $this->changes->addPropertyObjectChange( $property, $change );
238229 break;
239230 case SMWPropertyChange::TYPE_INSERT:
240 - $this->insertions->addPropertyValue( $property, $change->getNewValue() );
 231+ $this->insertions->addPropertyObjectValue( $property, $change->getNewValue() );
241232 break;
242233 case SMWPropertyChange::TYPE_DELETE:
243 - $this->deletions->addPropertyValue( $property, $change->getOldValue() );
 234+ $this->deletions->addPropertyObjectValue( $property, $change->getOldValue() );
244235 break;
245236 }
246237 }
247238
 239+ /**
 240+ *
 241+ *
 242+ * @return array of SMWDIProperty
 243+ */
 244+ public function getAllProperties() {
 245+ return array_merge(
 246+ $this->getChanges()->getProperties(),
 247+ $this->getInsertions()->getProperties(),
 248+ $this->getDeletions()->getProperties()
 249+ );
 250+ }
 251+
 252+ /**
 253+ * Returns a list of ALL changes, including isertions and deletions.
 254+ *
 255+ * @param SMWDIProperty $proprety
 256+ *
 257+ * @return array of SMWPropertyChange
 258+ */
 259+ public function getAllPropertyChanges( SMWDIProperty $proprety ) {
 260+ $changes = array();
 261+
 262+ foreach ( $this->getAllProperties() as /* SMWDIProperty */ $property ) {
 263+ foreach ( $this->changes->getPropertyChanges( $property ) as /* SMWPropertyChange */ $change ) {
 264+ $changes[] = $change;
 265+ }
 266+
 267+ foreach ( $this->insertions->getPropertyValues( $property ) as /* SMWDataItem */ $dataItem ) {
 268+ $changes[] = new SMWPropertyChange( null, $dataItem );
 269+ }
 270+
 271+ foreach ( $this->deletions->getPropertyValues( $property ) as /* SMWDataItem */ $dataItem ) {
 272+ $changes[] = new SMWPropertyChange( $dataItem, null );
 273+ }
 274+ }
 275+
 276+ return $changes;
 277+ }
 278+
248279 }

Status & tagging log