From: Markus K. <ma...@se...> - 2011-06-12 11:40:18
|
On 09/06/11 14:48, zehetner wrote: > Hi, > > I have another question. I use > > $addpropa = > $store->getPropertyValues($this->subject->getTitle(),SMWPropertyValue::makeUserProperty($propertyname)); > > > in SMW 1.6 I assume I need to use > > SMWPropertyValue::makeProperty($propertyid) > > instead of > > SMWPropertyValue::makeUserProperty($propertyname) > > in order to pass now a SMWDIProperty object instead of a SMWPropertyValue > object to $store->getPropertyValues() > > > How to I get the propertyid from the propertyname or > get a SMWDIProperty object if I have the propertyname or > how do I convert a SMWPropertyValue object to a SMWDIProperty object? All DV objects give you the according DI by calling getDataItem(). This is in general what you do in places where you might have called getDBkeys() in the past; it is the main way of accessing the actual data (as opposed to formatting the data for various outputs, which is not done by DIs). If you have messy inputs (user-written text etc.) then the only way of getting a proper DI is to invoke the DV with setUserValue() as usual (or use one of the static methods of SMWPropertyValue as before). But if you have reasonably clean property names/keys at hand, then you can use SMWDIProperty::newFromUserLabel() to get the right property immediately. If you do not have a label but even an internal key ("My_user_property" or "_MDAT"; but never a user-labelish key like "Modification_date" for a special property like "_MDAT") then you can also just create the property yourself: "new SMWDIProperty( $key );" This is mainly useful when creating special properties from their internal keys. Cheers, Markus |