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
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Semediawiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel