Open Source Content Management Framework

PHP: getting properties of an MgdSchema in correct order

  1. PHP: getting properties of an MgdSchema in correct order

    Wed November 11 2009 10:25:09 UTC
    Hi,

    I'm working on creating forms and object browsing views in MidCOM3
    based on MgdSchema reflection.

    One problem I have right now is that if I list the properties of an
    MgdSchema class using the following I get the in a random order:

    $dummy = new $type();
    $type_properties = get_object_vars($dummy);

    ...which is obviously confusing as the properties will be shown in
    very weird order.

    Asgard in Ragnaroek has some quite complex heuristics for this, but in
    reality when users design their MgdSchemas they usually place the
    properties in a sensible order that is better than the one we can
    create by heuristics.

    Is there, or can we have some way for listing the properties of an
    MgdSchema type in PHP in the order they appear in the original
    MgdSchema XML?

    --
    Henri Bergius
    Motorcycle Adventures and Free Software
    http://bergie.iki.fi/

    Skype: henribergius
    Jabber: henri.bergius@gmail.com
    Microblog: http://www.qaiku.com/home/bergie/

    My Royal Enfield Bullet 500 is for sale, see http://www.nettimoto.com/844397
    _______________________________________________
    dev mailing list
    dev@lists.midgard-project.org
    http://lists.midgard-project.org/mailman/listinfo/dev
    •  Reply
  2. Re: [midgard-dev] PHP: getting properties of an MgdSchema in correct order

    Wed November 11 2009 10:50:07 UTC
    I know this has been discussed before, but this question reminds me that
    I still haven't really understood why configuring form layout and
    behavior in the database schema is a good idea. On the plus side, I can
    see that this might offer reduced complexity and should probably be
    faster, but there are a lot of open questions, f.x.:

    - If I set some property to be hidden, required or readonly in the
    schema, does this apply only to the form view or also to PHP objects?

    - How do I implement a settings form (i.e. where form input is saved as
    parameters to f.x. a topic) or a preferences dialog (where form input is
    saved as parameters to a person)

    - What happens to null storage (i.e. some input field I want to have in
    the form, but process manually afterwards) and m:n relations (i.e.
    chooser widgets).

    - Will all fields defined in the schema be automatically be loaded when
    the object is instantiated (f.x. when loading a group object where a
    members chooser widget is defined in the schema, will all membership
    objects be loaded as well)?

    - Will it be necessary to restart Apache (and grant shell access to
    everone who wants to modify form layout) when you make changes?

    - How would you define callbacks to populate f.x. select lists?

    - What happens to constructs like 'readonly' => !$_MIDCOM->auth->admin ?

    - Will there be a way to define fieldsets?


    Bye,

    Andreas

    Henri Bergius schrieb:
    > Hi,
    >
    > I'm working on creating forms and object browsing views in MidCOM3
    > based on MgdSchema reflection.
    >
    > One problem I have right now is that if I list the properties of an
    > MgdSchema class using the following I get the in a random order:
    >
    > $dummy = new $type();
    > $type_properties = get_object_vars($dummy);
    >
    > ...which is obviously confusing as the properties will be shown in
    > very weird order.
    >
    > Asgard in Ragnaroek has some quite complex heuristics for this, but in
    > reality when users design their MgdSchemas they usually place the
    > properties in a sensible order that is better than the one we can
    > create by heuristics.
    >
    > Is there, or can we have some way for listing the properties of an
    > MgdSchema type in PHP in the order they appear in the original
    > MgdSchema XML?
    >
    _______________________________________________
    dev mailing list
    dev@lists.midgard-project.org
    http://lists.midgard-project.org/mailman/listinfo/dev
    •  Reply
  3. Re: [midgard-dev] PHP: getting properties of an MgdSchema in correct order

    Wed November 11 2009 11:15:08 UTC
    On 11.11.2009, at 13:17, Henri Bergius wrote:

    > Hi,
    >
    > I'm working on creating forms and object browsing views in MidCOM3
    > based on MgdSchema reflection.
    >
    > One problem I have right now is that if I list the properties of an
    > MgdSchema class using the following I get the in a random order:
    >
    > $dummy = new $type();
    > $type_properties = get_object_vars($dummy);
    >
    > ...which is obviously confusing as the properties will be shown in
    > very weird order.
    >
    > Asgard in Ragnaroek has some quite complex heuristics for this, but in
    > reality when users design their MgdSchemas they usually place the
    > properties in a sensible order that is better than the one we can
    > create by heuristics.
    >
    > Is there, or can we have some way for listing the properties of an
    > MgdSchema type in PHP in the order they appear in the original
    > MgdSchema XML?

    I don't think that it is a good idea to rely on order of fields in DB.
    Probably it would be a better idea to use midgard_reflection_property
    class for getting ordering info

    There isn't relevant method for that now, but it can be added
    _______________________________________________
    dev mailing list
    dev@lists.midgard-project.org
    http://lists.midgard-project.org/mailman/listinfo/dev
    •  Reply
  4. Re: [midgard-dev] PHP: getting properties of an MgdSchema in correct order

    Wed November 11 2009 11:40:06 UTC
    Hi,

    On Wed, Nov 11, 2009 at 1:11 PM, Alexey Zakhlestin <indeyets@gmail.com> wrote:
    > I don't think that it is a good idea to rely on order of fields in DB.
    > Probably it would be a better idea to use midgard_reflection_property
    > class for getting ordering info

    Yep, I'm not interested in the order of database columns, but instead
    in the order of <property /> elements in the MgdSchema XML files.

    > There isn't relevant method for that now, but it can be added

    Would make the stuff I'm hacking this week a lot easier :-)


    --
    Henri Bergius
    Motorcycle Adventures and Free Software
    http://bergie.iki.fi/

    Skype: henribergius
    Jabber: henri.bergius@gmail.com
    Microblog: http://www.qaiku.com/home/bergie/

    My Royal Enfield Bullet 500 is for sale, see http://www.nettimoto.com/844397
    _______________________________________________
    dev mailing list
    dev@lists.midgard-project.org
    http://lists.midgard-project.org/mailman/listinfo/dev
    •  Reply
  5. Re: [midgard-dev] PHP: getting properties of an MgdSchema in correct order

    Wed November 11 2009 12:20:10 UTC
    Alexey Zakhlestin pisze:

    Hi!

    > I don't think that it is a good idea to rely on order of fields in DB.
    > Probably it would be a better idea to use midgard_reflection_property
    > class for getting ordering info
    >
    > There isn't relevant method for that now, but it can be added

    This is not trivial task.
    When reading/parsing schema we add properties to internal storage in the
    same order they are declared in schema file.

    First problem is GHashTable which returns our properties in different
    order. This order, is however kept the same when properties are
    registered for GObjectClass and returned from list_properties particular
    routine.

    The latter works "as is" right now, but may work different in a future.
    Proper implementation requires many computation to be made and simply we
    should invent our own class inheritance introspection for this.

    Piotras
    _______________________________________________
    dev mailing list
    dev@lists.midgard-project.org
    http://lists.midgard-project.org/mailman/listinfo/dev
    •  Reply
  6. Re: [midgard-dev] PHP: getting properties of an MgdSchema in correct order

    Tue November 17 2009 11:55:06 UTC
    Henri Bergius pisze:
    > Hi,

    Hi!

    > One problem I have right now is that if I list the properties of an
    > MgdSchema class using the following I get the in a random order:
    >
    > $dummy = new $type();
    > $type_properties = get_object_vars($dummy);
    >
    > ...which is obviously confusing as the properties will be shown in
    > very weird order.

    Added workaround for this problem.
    Should be available in binary packages @OBS soon.

    Piotras
    _______________________________________________
    dev mailing list
    dev@lists.midgard-project.org
    http://lists.midgard-project.org/mailman/listinfo/dev
    •  Reply
Designed by Nemein, hosted by Kafit