Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ChangeSet.php |
— | — | @@ -207,15 +207,6 @@ |
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
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 | | - /** |
220 | 211 | * Returns the subject these changes apply to. |
221 | 212 | * |
222 | 213 | * @return SMWDIWikiPage |
— | — | @@ -225,23 +216,63 @@ |
226 | 217 | } |
227 | 218 | |
228 | 219 | /** |
| 220 | + * Adds a SMWPropertyChange to the set for the specified SMWDIProperty. |
229 | 221 | * |
230 | | - * |
231 | | - * @param string $property |
| 222 | + * @param SMWDIProperty $property |
232 | 223 | * @param SMWPropertyChange $change |
233 | 224 | */ |
234 | | - public function addChange( $property, SMWPropertyChange $change ) { |
| 225 | + public function addChange( SMWDIProperty $property, SMWPropertyChange $change ) { |
235 | 226 | switch ( $change->getType() ) { |
236 | 227 | case SMWPropertyChange::TYPE_UPDATE: |
237 | | - $this->changes->addPropertyChange( $property, $change ); |
| 228 | + $this->changes->addPropertyObjectChange( $property, $change ); |
238 | 229 | break; |
239 | 230 | case SMWPropertyChange::TYPE_INSERT: |
240 | | - $this->insertions->addPropertyValue( $property, $change->getNewValue() ); |
| 231 | + $this->insertions->addPropertyObjectValue( $property, $change->getNewValue() ); |
241 | 232 | break; |
242 | 233 | case SMWPropertyChange::TYPE_DELETE: |
243 | | - $this->deletions->addPropertyValue( $property, $change->getOldValue() ); |
| 234 | + $this->deletions->addPropertyObjectValue( $property, $change->getOldValue() ); |
244 | 235 | break; |
245 | 236 | } |
246 | 237 | } |
247 | 238 | |
| 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 | + |
248 | 279 | } |