Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PropertyChanges.php |
— | — | @@ -73,9 +73,9 @@ |
74 | 74 | * |
75 | 75 | * @return array of SMWPropertyChange |
76 | 76 | */ |
77 | | - public function getPropertyValues( SMWDIProperty $property ) { |
| 77 | + public function getPropertyChanges( SMWDIProperty $property ) { |
78 | 78 | if ( array_key_exists( $property->getKey(), $this->changes ) ) { |
79 | | - return $this->mPropVals[$property->getKey()]; |
| 79 | + return $this->changes[$property->getKey()]; |
80 | 80 | } else { |
81 | 81 | return array(); |
82 | 82 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ChangeSet.php |
— | — | @@ -155,12 +155,12 @@ |
156 | 156 | * Create a new instance of a change set. |
157 | 157 | * |
158 | 158 | * @param SMWDIWikiPage $subject |
159 | | - * @param array $changes Can be null |
| 159 | + * @param SMWPropertyChanges $changes Can be null |
160 | 160 | * @param SMWSemanticData $insertions Can be null |
161 | 161 | * @param SMWSemanticData $deletions Can be null |
162 | 162 | */ |
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 ) { |
165 | 165 | |
166 | 166 | $this->subject = $subject; |
167 | 167 | $this->changes = is_null( $changes ) ? new SMWPropertyChanges() : $changes; |
— | — | @@ -180,6 +180,33 @@ |
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
| 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 | + /** |
184 | 211 | * Returns a list of ALL changes, including isertions and deletions. |
185 | 212 | * |
186 | 213 | * @return array of SMWPropertyChange |
— | — | @@ -197,4 +224,24 @@ |
198 | 225 | return $this->subject; |
199 | 226 | } |
200 | 227 | |
| 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 | + |
201 | 248 | } |