SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: dom no dom ?

  1. #1
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dom no dom ?

    Hi I am trying to emulate the php-gtk method of

    $widget->add($nother_widget); //think domxml append_child()
    etc so that I can build up a heirarchy/representation of an objects structure eg

    $window = new window_widget( ) ;
    $box = new box_widget( ) ;
    $window->add( $box ) ;

    $inner_box = new box_widget( ) ;
    $box->add( $inner_box );

    etc etc , to a point where I would be able to reference
    $window[ 'children' ][$box][ 'children' ][ $inner_box ]->get_value($whatever) ;

    or in dom speak so I can use eg get_element_by_id() & get_first_child() etc

    but however I try I run into a brick wall of some description pretty early on.

    I thought about utilising the dom xml functions to build this representation but it seems to be changing too fast at the moment to rely on + I still have to turn it back into an object anyway & I am sure there is a way to wrap this all up in an object somehow, I just cant grasp it ATM.

    So I think I want basically a pure php version of domxml like functions ?
    any ideas , pointers ?

    [the point BTW is to build an object that can then be passed to a 'build'
    script which could generate (a simple) either php-gtk or HTML interface from the same source object to save me rewriting the same script for GUI & web-browser versions. (& nope gladeXML is not an option ]

  2. #2
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    eZpublish has had a pretty good DOM XML parser written in PHP for a while now - it's part of the v3 library.

    Thing is though, if I understand what you're doing correctly, you've got some classes which are effectively "wrappers" for PHP-GTK right? It shouldn't be too hard to write some methods of your own for dealing with this in the base class, e.g. $widget->hasChildren(), $widget->getChildren(), $widget->getChildByType('button') etc.

    Reading the bottom line, perhaps it would be worth considering XUL? I played with XUL to PHP-GTK here. An alternative approach to mine would have been to parse XUL with XSLT to transform it into a PHP script with fires up a GTK app on execution. On the HTML side, you might then get in touch with these guys and see if they've got anything to show.

  3. #3
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Harry , at the moment I am back to playing with the domxml functions despite my initial resistance to thier use , its just making it so much easier that I can't ignore it , especially with the built in get_element_by_whatever & add_child etc type stuff.

    I am not creating wrappers as such at this point more a clone of the php-gtk object heirarchy
    The basic idea is to 'build' a representation of an interface via this class , then connect various bits of it to another class which provides the app logic.

    Instead of parsing this interface at runtime there will be another class/parser which builds both valid php-gtk and HTML code from the XML source or DOM object produced above , at the same time mapping signals and callbacks as appropriate to the individual elements of the interface (`signals` for HTML version will be poorly represented by javascript).

    so basically creating a php version of glade but one which can produce both php-gtk and browser-based interfaces + mapping the application logic at the same time ~

    .. at least thats the plan

    I read your XUL article before and can see exactly where your enthusiasm for it comes , but I am on the php-gtk course full steam ahead (perhaps blindfolded .. or is that blinkered ) .

    In fact didnt you do a HTML widget class at some point , I am sure I saw it here on sitepoint somewhere , that sort of thing but with its roots closer to the gtk side of things.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •