Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Container.php |
— | — | @@ -59,6 +59,26 @@ |
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
| 63 | + * Change the object to become an exact copy of the given |
| 64 | + * SMWSemanticData object. Useful to convert arbitrary such |
| 65 | + * objects into SMWContainerSemanticData objects. |
| 66 | + * |
| 67 | + * @param $semanticData SMWSemanticData |
| 68 | + */ |
| 69 | + public function copyDataFrom( SMWSemanticData $semanticData ) { |
| 70 | + $this->throwImmutableException(); |
| 71 | + $this->mSubject = $semanticData->getSubject(); |
| 72 | + $this->mProperties = $semanticData->getProperties(); |
| 73 | + $this->mPropVals = array(); |
| 74 | + foreach ( $this->mProperties as $property ) { |
| 75 | + $this->mPropVals[$property->getKey()] = $semanticData->getPropertyValues( $property ); |
| 76 | + } |
| 77 | + $this->mHasVisibleProps = $semanticData->hasVisibleProperties(); |
| 78 | + $this->mHasVisibleSpecs = $semanticData->hasVisibleSpecialProperties(); |
| 79 | + $this->mNoDuplicates = $semanticData->mNoDuplicates; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
63 | 83 | * Store a value for a property identified by its SMWDataItem object, |
64 | 84 | * if the object was not set to immutable. |
65 | 85 | * |
— | — | @@ -146,6 +166,20 @@ |
147 | 167 | } |
148 | 168 | |
149 | 169 | /** |
| 170 | + * Get an internal object that can be used as a subject for this data. |
| 171 | + * This subject is not part of the data itself but makes the connection |
| 172 | + * to the wiki page for which this data will be stored. This allows to |
| 173 | + * encode a kind of provenance information when storing container data, |
| 174 | + * useful to find the source of the data, and to retrieve more data when |
| 175 | + * a structural (helper) node is found in a query etc. |
| 176 | + * |
| 177 | + * @return SMWDIWikiPage |
| 178 | + */ |
| 179 | + public function getSubjectPage( SMWDIWikiPage $masterPage ) { |
| 180 | + return new SMWDIWikiPage( $masterPage->getDBkey(), $masterPage->getNamespace(), $masterPage->getInterwiki(), $this->getHash() ); |
| 181 | + } |
| 182 | + |
| 183 | + /** |
150 | 184 | * Create a data item from the provided serialization string and type |
151 | 185 | * ID. |
152 | 186 | * @return SMWDIContainer |