Index: trunk/extensions/SemanticMediaWiki/includes/SMW_PropertyChanges.php |
— | — | @@ -135,8 +135,20 @@ |
136 | 136 | } |
137 | 137 | |
138 | 138 | $this->addPropertyObjectChange( $property, $change ); |
139 | | - } |
| 139 | + } |
140 | 140 | |
| 141 | + /** |
| 142 | + * Removes all changes for a certian property. |
| 143 | + * |
| 144 | + * @param SMWDIProperty $property |
| 145 | + */ |
| 146 | + public function removeChangesForProperty( SMWDIProperty $property ) { |
| 147 | + if ( array_key_exists( $property->getKey(), $this->changes ) ) { |
| 148 | + unset( $this->changes[$property->getKey()] ); |
| 149 | + unset( $this->properties[$property->getKey()] ); |
| 150 | + } |
| 151 | + } |
| 152 | + |
141 | 153 | function rewind() { |
142 | 154 | $this->pos = 0; |
143 | 155 | $this->currentRow = null; |
— | — | @@ -161,6 +173,6 @@ |
162 | 174 | |
163 | 175 | function valid() { |
164 | 176 | return $this->current() !== false; |
165 | | - } |
| 177 | + } |
166 | 178 | |
167 | 179 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php |
— | — | @@ -198,7 +198,8 @@ |
199 | 199 | * |
200 | 200 | * @return boolean |
201 | 201 | */ |
202 | | - public function hasVisibleProperties() { |
| 202 | + public function hasVisibleProperties( $refresh = false ) { |
| 203 | + if ( $refresh ) $this->findVisibleProperties(); |
203 | 204 | return $this->mHasVisibleProps; |
204 | 205 | } |
205 | 206 | |
— | — | @@ -212,7 +213,8 @@ |
213 | 214 | * |
214 | 215 | * @return boolean |
215 | 216 | */ |
216 | | - public function hasVisibleSpecialProperties() { |
| 217 | + public function hasVisibleSpecialProperties( $refresh = false ) { |
| 218 | + if ( $refresh ) $this->findVisibleProperties(); |
217 | 219 | return $this->mHasVisibleSpecs; |
218 | 220 | } |
219 | 221 | |
— | — | @@ -284,6 +286,47 @@ |
285 | 287 | } |
286 | 288 | |
287 | 289 | /** |
| 290 | + * Removes all DIs for the specified property. |
| 291 | + * NOTE: calling this method can lead to false positive mHasVisibleProps and mHasVisibleSpecs. |
| 292 | + * Call findVisibleProperties to fix this if needed. |
| 293 | + * |
| 294 | + * @since 1.6 |
| 295 | + * |
| 296 | + * @param SMWDIProperty $property |
| 297 | + */ |
| 298 | + public function removeDataForProperty( SMWDIProperty $property ) { |
| 299 | + var_dump($property);exit; |
| 300 | + if ( array_key_exists( $property->getKey(), $this->mPropVals ) ) { |
| 301 | + unset( $this->mPropVals[$property->getKey()] ); |
| 302 | + } |
| 303 | + if ( array_key_exists( $property->getKey(), $this->mProperties ) ) { |
| 304 | + unset( $this->mProperties[$property->getKey()] ); |
| 305 | + } |
| 306 | + } |
| 307 | + |
| 308 | + /** |
| 309 | + * Determine if there are visible properties and special properties. |
| 310 | + * |
| 311 | + * @since 1.6 |
| 312 | + */ |
| 313 | + public function findVisibleProperties() { |
| 314 | + $this->mHasVisibleSpecs = false; |
| 315 | + $this->mHasVisibleProps = false; |
| 316 | + |
| 317 | + foreach ( $this->mProperties as /* SMWDIProperty */ $property ) { |
| 318 | + if ( !$property->isUserDefined() ) { |
| 319 | + if ( $property->isShown() ) { |
| 320 | + $this->mHasVisibleSpecs = true; |
| 321 | + $this->mHasVisibleProps = true; |
| 322 | + break; |
| 323 | + } |
| 324 | + } else { |
| 325 | + $this->mHasVisibleProps = true; |
| 326 | + } |
| 327 | + } |
| 328 | + } |
| 329 | + |
| 330 | + /** |
288 | 331 | * Delete all data other than the subject. |
289 | 332 | */ |
290 | 333 | public function clear() { |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ChangeSet.php |
— | — | @@ -171,12 +171,14 @@ |
172 | 172 | /** |
173 | 173 | * Returns whether the set contains any changes. |
174 | 174 | * |
| 175 | + * @param boolean $refresh |
| 176 | + * |
175 | 177 | * @return boolean |
176 | 178 | */ |
177 | | - public function hasChanges() { |
| 179 | + public function hasChanges( $refresh = false ) { |
178 | 180 | return $this->changes->hasChanges() |
179 | | - || $this->insertions->hasVisibleProperties() |
180 | | - || $this->deletions->hasVisibleProperties(); |
| 181 | + || $this->insertions->hasVisibleProperties( $refresh ) |
| 182 | + || $this->deletions->hasVisibleProperties( $refresh ); |
181 | 183 | } |
182 | 184 | |
183 | 185 | /** |
— | — | @@ -236,8 +238,8 @@ |
237 | 239 | } |
238 | 240 | |
239 | 241 | /** |
| 242 | + * Returns a list of all properties. |
240 | 243 | * |
241 | | - * |
242 | 244 | * @return array of SMWDIProperty |
243 | 245 | */ |
244 | 246 | public function getAllProperties() { |
— | — | @@ -249,6 +251,17 @@ |
250 | 252 | } |
251 | 253 | |
252 | 254 | /** |
| 255 | + * Removes all changes for a certian property. |
| 256 | + * |
| 257 | + * @param SMWDIProperty $property |
| 258 | + */ |
| 259 | + public function removeChangesForProperty( SMWDIProperty $property ) { |
| 260 | + $this->getChanges()->removeChangesForProperty( $property ); |
| 261 | + $this->getInsertions()->removeDataForProperty( $property ); |
| 262 | + $this->getDeletions()->removeDataForProperty( $property ); |
| 263 | + } |
| 264 | + |
| 265 | + /** |
253 | 266 | * Returns a list of ALL changes, including isertions and deletions. |
254 | 267 | * |
255 | 268 | * @param SMWDIProperty $proprety |