r87959 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87958‎ | r87959 | r87960 >
Date:10:09, 13 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
some work on property diff code
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ChangeSet.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_PropertyChanges.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PropertyChanges.php
@@ -73,9 +73,9 @@
7474 *
7575 * @return array of SMWPropertyChange
7676 */
77 - public function getPropertyValues( SMWDIProperty $property ) {
 77+ public function getPropertyChanges( SMWDIProperty $property ) {
7878 if ( array_key_exists( $property->getKey(), $this->changes ) ) {
79 - return $this->mPropVals[$property->getKey()];
 79+ return $this->changes[$property->getKey()];
8080 } else {
8181 return array();
8282 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ChangeSet.php
@@ -155,12 +155,12 @@
156156 * Create a new instance of a change set.
157157 *
158158 * @param SMWDIWikiPage $subject
159 - * @param array $changes Can be null
 159+ * @param SMWPropertyChanges $changes Can be null
160160 * @param SMWSemanticData $insertions Can be null
161161 * @param SMWSemanticData $deletions Can be null
162162 */
163 - public function __construct( SMWDIWikiPage $subject,
164 - /* SMWSemanticData */ SMWPropertyChanges $changes = null, $insertions = null, /* SMWSemanticData */ $deletions = null ) {
 163+ public function __construct( SMWDIWikiPage $subject, /* SMWPropertyChanges */ $changes = null,
 164+ /* SMWSemanticData */ $insertions = null, /* SMWSemanticData */ $deletions = null ) {
165165
166166 $this->subject = $subject;
167167 $this->changes = is_null( $changes ) ? new SMWPropertyChanges() : $changes;
@@ -180,6 +180,33 @@
181181 }
182182
183183 /**
 184+ * Returns a SMWSemanticData object holding all inserted SMWDataItem objects.
 185+ *
 186+ * @return SMWSemanticData
 187+ */
 188+ public function getInsertions() {
 189+ return $this->insertions;
 190+ }
 191+
 192+ /**
 193+ * Returns a SMWSemanticData object holding all deleted SMWDataItem objects.
 194+ *
 195+ * @return SMWSemanticData
 196+ */
 197+ public function getDeletions() {
 198+ return $this->deletions;
 199+ }
 200+
 201+ /**
 202+ * Returns a SMWPropertyChanges object holding all SMWPropertyChange objects.
 203+ *
 204+ * @return SMWPropertyChanges
 205+ */
 206+ public function getChanges() {
 207+ return $this->changes;
 208+ }
 209+
 210+ /**
184211 * Returns a list of ALL changes, including isertions and deletions.
185212 *
186213 * @return array of SMWPropertyChange
@@ -197,4 +224,24 @@
198225 return $this->subject;
199226 }
200227
 228+ /**
 229+ *
 230+ *
 231+ * @param string $property
 232+ * @param SMWPropertyChange $change
 233+ */
 234+ public function addChange( $property, SMWPropertyChange $change ) {
 235+ switch ( $change->getType() ) {
 236+ case SMWPropertyChange::TYPE_UPDATE:
 237+ $this->changes->addPropertyChange( $property, $change );
 238+ break;
 239+ case SMWPropertyChange::TYPE_INSERT:
 240+ $this->insertions->addPropertyValue( $property, $change->getNewValue() );
 241+ break;
 242+ case SMWPropertyChange::TYPE_DELETE:
 243+ $this->deletions->addPropertyValue( $property, $change->getOldValue() );
 244+ break;
 245+ }
 246+ }
 247+
201248 }

Status & tagging log