SitePoint Sponsor

User Tag List

Page 7 of 16 FirstFirst ... 34567891011 ... LastLast
Results 151 to 175 of 384
  1. #151
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wdeboer
    Just a basic form generator, nothing shocking. The idea behind is that your register formElements instances into the formStorageModel wich will keep track of all the elements for the form. The form decorator will used to render all the controls, as you each formelement has it's own renderer. I am not really convinced it's good, but... should work for now.
    It's good but I don't think I need FormStorageModel or FormDecorator because the Form Controller will probably do that management.

    What I was looking for was some good: SelectFormElement, CheckboxFormElement, and RadioFormElement classes. Especially ones that accept arrays of options/values and mutiple selected/checked values. I can build hidden, textarea, submit, reset, etc. from the TextFormElement you did.
    Christopher

  2. #152
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, that won't be difficuilt to make, I just didn't make those. Because I would expect that you were able to fix that in minutes like I fixed this in minutes

  3. #153
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wdeboer
    Just a basic form generator, nothing shocking. The idea behind is that your register formElements instances into the formStorageModel wich will keep track of all the elements for the form. The form decorator will used to render all the controls, as you each formelement has it's own renderer. I am not really convinced it's good, but... should work for now.

    Keep in my mind that this is not tested.
    Sounds good to me. But I would go to this way:

    PHP Code:
    abstract class FormElement 
    {
        private 
    $aAttributes
        
        private function 
    __construct()
        {
            
    $this->aAttributes = array();
        }

        public function 
    setAttributes$aAttributes = array() )
        { 
            
    $this->aAttributes $aAttributes
        }

        public function 
    getAttributes()
        {
            return 
    $this->aAttributes
        }

        abstract function 
    render();



    PHP Code:
    class TextFormElement extends FormElement 
    {

        public function 
    __construct($aAttributes)
        { 
            
    $this->setAttributes($aAttributes);
        }

        public function 
    render() 
        {
            
    $s '';
            foreach (
    $this->getAttributes() as $sKey => $mValue)
            {
                
    $s .= $sKey.'="'.$mValue.'" ';
            }
            
    $s  '<input type="text" '.$s.' />';
            return 
    $s;
        }

    PHP Code:
    class Form
    {

        private 
    $aElements;

        public function 
    __construct()
        {
            
    $this->aElements = array();
        }

        public function 
    addElement($oFormElement
        {
            
    $this->aElements[] = $oFormElement;
        }

        public function 
    render()
        {
            
    $s '';
            foreach (
    $this->aElements as $oElement)
            {
                
    $s .= $oElement->render();
            }
            echo 
    '<form>'.$s.'</form>';
        }


    PHP Code:
    $oForm = new Form();
    $oForm->addElement
             new 
    TextFormElement
                      array(
                            
    'name' => 'bookTitle'
                            
    'value' => 'Lords Of The Rings'
                       

             ) 
    );
    $oForm->render(); 
    What do you think about the code ? Need some advices.
    I keep in mind that I want to set the form in a xml file with all default values, and for rendering I will use a xsl template. I don't want to developp my own template system. Why ? Everything is already done with xsl.
    The Idea is to do a xml structure (with form elements) which will be parse with a xsl template for displaying.
    Want to participate ?

  4. #154
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks better then my solution

  5. #155
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, I have been playing with the code found in this thread, only I am asking myself how to use it correctly. Only I have a question how I should use it correctly, I got a simple page that should show a page. The content of the page should be acquired from a MySQL database and be styled via a template mechanism. My idea was to make a class that returns a collection of elements ( i.e IRenderElement) and then a decorator that wraps around this collection that can convert/decorate it into XML. A seperate class for example XmlView will use a Template-class to output the xml into something cool i.e. xhtml through a xslt transformation.

    How should I do this? This way I am able to obtain content, and then "decorate" it into something that the View understands. After the View has convertede it into the wante d format I can set it to Response.

    This way I can support feeds, xhtml in one simple way. Anyone looking for some advice

    btw, Neither do I know how to use the Session, GET, Dataspace etc.

  6. #156
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do it like

    PHP Code:
    <?php

    // +---------------------------------------------------------------------------
    // | Author: Tim Van Wassenhove <timvw@users.sourceforge.net>
    // |
    // | This class represents a View. It provides:
    // | - method to output data to the user
    // +---------------------------------------------------------------------------
    // | $Id: std.view.php,v 1.3 2005/07/12 21:16:41 timvw Exp $
    // +---------------------------------------------------------------------------

    class view
    {
        var 
    $headers;
        
        function 
    setHeaders($headers)
        {
            
    $this->headers headers;
        }

        function 
    display($xml)
        {
            
    $this->output($xml$this->headers);
            return 
    true;
        }
        
        function 
    output($data$headers null)
        {
            if (!
    is_null($headers))
            {
                foreach(
    $headers as $name => $value)
                {
                    
    header("{$name}{$value}");
                }
            }

            echo 
    $data;
        }
    }

    ?>
    PHP Code:
    <?php

    // +---------------------------------------------------------------------------
    // | Author: Tim Van Wassenhove <timvw@users.sourceforge.net>
    // |
    // | This class represents a XSLView. It provides:
    // | - method to perform a XSL Transformation on an XML string
    // |
    // | Requirements: XSL or XSLT extension <http://www.php.net/xsl(t)>
    // +---------------------------------------------------------------------------
    // | $Id: std.xslview.php,v 1.3 2005/07/15 01:21:22 timvw Exp $
    // +---------------------------------------------------------------------------

    require_once('std.view.php');

    class 
    xslview extends view
    {
        var 
    $xml;
        var 
    $xsl;
        var 
    $base;
        var 
    $params;
        
        function 
    xslview($xsl$base null$params null)
        {
            
    $this->xsl $xsl;
            
    $this->base $base;
            
    $this->params $params;
        }
        
        function 
    display($xml)
        {
            if(!
    $this->transform($xml$this->xsl$this->base$this->params))
            {
                return 
    false;
            }
            return 
    parent::display($this->xml);
        }
        
        function 
    transform($xml$xsl$base null$params null)
        {
            if (
    version_compare(phpversion(), '5.0.0''<'))
            {
                
    $proc xslt_create();
                
    xslt_set_encoding($proc'UTF-8');

                if (!
    is_null($base))
                {
                    
    xslt_set_base($proc'file://' $base '/');
                }

                
    $result xslt_process($proc'arg:/xml'$xslNULL, array('/xml' => $xml), $params);
                if (!
    $result)
                {
                    
    trigger_error('XSLT: failed: ' xslt_error($proc), E_USER_ERROR);
                    return 
    false;
                }
                
    xslt_free($proc);
                
    $this->xml $result;
                return 
    true;
            }
            else
            {
                
    $xmldoc =& new DOMDocument;
                
    $xmldoc->loadXML($xml);

                
    $xsldoc =& new DOMDocument;
                
    $xsldoc->load($xsl);

                
    $proc =& new XSLTProcessor;
                
    $proc->importStyleSheet($xsldoc);
                
                if (!
    is_null($params))
                {
                    foreach(
    $params as $name => $value)
                    {
                        
    $proc->setParameter(''$name$value);
                    }
                }
                
                
    $result $proc->transformToXML($xmldoc);
                if (!
    $result)
                {
                    
    trigger_error('XSL: failed.'E_USER_ERROR);
                    return 
    false;
                }
                
    $this->xml $result;
                return 
    true;
            }
        }
    }

    ?>
    My Controller class accepts a View instance, and calls the display($xml) method when it's ready to output data...

  7. #157
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooh really, I thought the idea was that the Response() would output data? Ooh well, maybe I should alter the current design of the ApplicationController/FrontController here. Anyway I thought a View shouldn't output/echo his stuff itself.

  8. #158
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I went searching for a couple of explanations on MVC... I found for example http://www.phppatterns.com :


    It seems the author(s) of that site have the same opinion

  9. #159
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by timvw
    I went searching for a couple of explanations on MVC... I found for examples
    It seems the author(s) of that site have the same opinion
    I think in the current "skeleton" code the Response class deals with actually displaying the page and/ sending headers. But you could have the views do it as well. That would not allow you to have a heirarchy of views though.
    Christopher

  10. #160
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, their UML shows an output($string) method for the (Product)View...
    (In case their code is different, than you should blame them )

    I'm not sure what you mean with a "hierarchy":
    - The is-a relation, for example the xslview
    - The has-a relation, for example the multiview

    PHP Code:
    class multiview extends view
    {
      var 
    $views;

      function 
    display($xml)
      {
        foreach(
    $this->views as view)
        {
          foreach(
    $view->headers as $header)
          {
            
    $this->headers[] = $header;
          }
          
          
    ob_start();
          
    $view->display($xml);
          
    $xml ob_get_contents();
        }
        
    $this->output($xml$this->headers);
      }

    It's also possible that the views recieve the original XML... And that the different parts are concatenated and outputted..


    Untill now i have never felt the need for this multiview.. In my experience i've always been able to implement the "has-a" through <xsl:include>...

  11. #161
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by timvw
    Well, their UML shows an output($string) method for the (Product)View...
    (In case their code is different, than you should blame them )
    I'm not sure if we are agreeing or disagreeing at this point. The diagram and the "skeleton" code have he views returning a string that is echoed later (by the response).
    Quote Originally Posted by timvw
    I'm not sure what you mean with a "hierarchy":
    - The is-a relation, for example the xslview
    It's also possible that the views recieve the original XML... And that the different parts are concatenated and outputted..

    Untill now i have never felt the need for this multiview.. In my experience i've always been able to implement the "has-a" through <xsl:include>...
    As I recall <xsl:include> uses the same XML source. By heirarchical I mean that a view with it's own data source is used as part of a larger surrounding view that has a different set of data sources.
    Christopher

  12. #162
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    That would not allow you to have a heirarchy of views though.
    index.php
    PHP Code:
    <body><?php include 'foo.php'?></body>
    foo.php
    PHP Code:
    <h1><?php echo $foo['title']</h1>
    <?
    php include 'bar.php'?>
    <?php 
    echo $foo['body'?>
    <?php 
    include 'gamma.php'?>
    bar.php
    PHP Code:
    <div><?php echo $bar ?></div>
    gamma.php
    PHP Code:
    <div>No problem!</div
    Why do you say you can't use a heirarchy?

    There is no inherant reason that you can't. Just need a couple of functions to make it easier to read (instead of include 'foo', you might have render_partial('foo') so that you can do more processing on it.)

    Douglas
    Hello World

  13. #163
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, how would I integrate the View-idea in the current skeleton? Just make a View abstract class and create the apperiate Model, View-class. I.e. Or is it needed in the current skeleton? I happen to have a ApplicationController-singleton, who creates an instance of FrontController, which should deal with all the request. I have a basic RequestMapper (it's now: RequesTMapper_ServerPage) who instantiate a instance of ContentPage wich does $response->setContent( 'blablabla' );

    Everything returns back tot he frontControlller. The frontController does a echo:

    PHP Code:
    try {
        
    $frontController =& new FrontController( new Request(), $response = new Response() );
        
    $response->out();
    } catch ( 
    ApplicationException $e ) {
        
    header'500 Internal Server Error' );
        die( 
    '<h1>Internal Server Error Occured</h1>');

    This should go all nicely, not yet found a way to change the Content-type of the Response though, so you can change to text/xml.

    Beside of that I how should I use the DataSpace-class?

  14. #164
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Why do you say you can't use a heirarchy?

    There is no inherant reason that you can't. Just need a couple of functions to make it easier to read (instead of include 'foo', you might have render_partial('foo') so that you can do more processing on it.)
    Sorry, I maybe wasn't clear. I was assuming that each View would have and associated Model. Building a heirarchy is no problem. Building a heirarchy where each View has it's own data bindings and child views can be bound to elements in parent views is more difficult. That's what "skeleton" needs.

    Maybe kyberfabrikken has some ideas on this. Perhaps we need some sort of MVC Command thingy that controllers could dispatch. It would support separation and correct dependency. Here is some rough, not thought through pseudocode to show the idea:
    PHP Code:
    class HandlerMVC {

    fuction HandlerMVC ($basename) {
        include_once 
    'models/' $basename 'Model.php';
        
    $this->model =& new $basename 'Model' ();

        include_once  
    'views/' $basename 'View.php';
        
    $this->view =& new $basename 'View' ();
    }

    function 
    execute (&$request, &$response) {
        return 
    $this->view->execute($this->model($request), $response));
    }


    Christopher

  15. #165
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    As I recall <xsl:include> uses the same XML source. By heirarchical I mean that a view with it's own data source is used as part of a larger surrounding view that has a different set of data sources.
    I would still use 1 XML document as the binding between controller and view.

    The view could then pick things out from that document, and provide each subview the data it expects... But i don't like that approach.

    I prefer to feed all the subviews the complete document, and let them decide what they want from the document...

    For example, if i want to generate a html <head> section with headview, i could write the following XSL. (All this subview is interested in is the //root/page/title values, not caring about other data in the document)

    Code:
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
    <xsl:template name="head">
    
        <head>
            <title><xsl:value-of select="/root/page/title"/></title>
            <link rel="stylesheet" href="styles/style.css" type="text/css"/>
        </head>
    
    </xsl:template>
    
    </xsl:stylesheet>

  16. #166
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by timvw
    I would still use 1 XML document as the binding between controller and view.

    The view could then pick things out from that document, and provide each subview the data it expects... But i don't like that approach.

    I prefer to feed all the subviews the complete document, and let them decide what they want from the document...
    But what if you don't know what the page will look like a build time. How do you pre-assemble potential combinations of view.
    Christopher

  17. #167
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am just using templates with placeholder markers in it, an instance can have a placeholders definition in, the blocks will then be replace by output of the tree. Through PHP, XML/XSLT or a other template engine that's the idea. Each type of content has it's own default template assigned to each, but a instance of a ocntent type can also have a different template assigned to it. The idea of my is just to construct a tree of all instances associated to that page or "root object" and traverse through the tree and start decorating. The result should a page or something else, based on the templates.

  18. #168
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wdeboer
    This should go all nicely, not yet found a way to change the Content-type of the Response though, so you can change to text/xml.
    (Everywhere i used View you can replace it by Response to fit the skeleton)

    It is a tricky question, and depends from header to header... Let me give some examples:

    -) Generation of an RSS feed. Sometimes we need to retrieve complete data, sometimes we only need to send a 304 Not modified. In thise case it's obvious that this is a task for the controller (well, the actual logic belongs in the model) and not the view.

    -) a PDFView: pdf is generated from the xml and send to the user. I don't think the controller should know it's dealing with a PDFView (It only needs to know it's dealing with "a" View) So it is a task of the PDFView should to send Content-type: application/pdf headers

    So probably we end up with 2 types of headers:

    1) Those that are metadata for the xml (For example, a 304 Not modified as metadata for an empty XML document)

    2) Those that are specific to the view (For example content-type)

    It is the task of the View to generate an adequate representation for the data it's given.. Exactly as it can ignore data (it can decide to not use all the data in an XML document) it can ignore metadata hints (headers)

    An example: Our controller passes an XML document (data) and a content-length (metadata) to a ZipClass... The zipclass generates the zip file and ignores the provided content-length... Or the view could calculate the real (after zipping) content-length.

  19. #169
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    But what if you don't know what the page will look like a build time. How do you pre-assemble potential combinations of view.
    The only thing we need to know in advance is the format of the "glue" XML.. So if we end up with a DTD/XSD for that XML both the programmers and designers can start working... Usually we generate an example.xml file too so the designers can start Flashturbating or whatever they do..

  20. #170
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, I have to admit I haven't look into the status-stuff those feeds most of the time expect i.e. 304. Am also thinking that the controller or whatever shouldn't know what it's dealing with, it should just startin "decorating" the objects that are associated with the page or "space". I.e.:

    If you got a "render tree" like below, you should have a Collection which is traversable with Iterator.

    + page
    + article 1
    + article 2
    + page

    You could then do something like, this is some code that I made to test my idea out (== proof of concept).

    PHP Code:
    foreach ( $renderTree as $component ) {
    //
    // The items of the website should be stored in a Repository,
    // in such way that's it's easy to replace the Repository storage model.
    // Default could be storage into a MySQL database, but you could plugin
    // support for storing in flat files or cvs/subversion.
    //
    // IDEAS
    //
    //   * Repository Storage Model (this should handle the adidng/removing of the items int he "dictionary"/repository --- repository design pattenr usable?!?!)
    //   * Vesioning
    //   * Content Creation Automation(specific actions, i.e. user adds a Article, automation --> auto-conversion to PDF via backend)
    // 
    // 
         
    $decoratorClassName $component->objectName 'Dectorator';
         
    $objectName $component->objectName;
         if ( !
    class_exists$decoratorClassName ) ) {
               
    // when their isn't a special decorator/"view"-available for this object type
               // in the objects/[objectName]/ directory we should use the default
               // DefaultComponentDecorator-class. This class will try to decorate
               // the component with the associated template. The used template engine
               // is based on the extension of the template file or the "mappings" the config file of this domain:
               //        .php -> php template engine
               //        .xslt -> xslt transformation engine
               //        .tpl  -> simple replace engine (xml-ready, system only "xhtml"-compatible simple error checker via  xml schema.
               //
               
    $decorator = new DefaultComponentDecorator( &$component );
               
    $outputResult $decorator->render();
               
    // replace output into a resultRenderTree thingy
               
    $resultRenderTree$component->getPlaceholderId() ][ $component->getId() ] = $outputResult;
         } else {
               
    // use the decorator of the component, this way it's possible
               // generate PDF files dynamically based on the root node and his
               // parent childs which should be: !isPageObject. (really needed?)
               //
               
    $decorator = new $decoratorClassName( &$component );
               
    $outputResult $decorator->render();
               
    // replace output into a resultRenderTree thingy
               
    $resultRenderTree$component->getPlaceholderId() ][ $component->getId() ] = $outputResult;
         }

         
    $response->setContent$resultRenderTree->out();  );

    As you might see I want to support cotnent types which can be defined in the backend, the attributes of course. The idea was to let the backend auto-generated the PHP-class associated with this, but because I moved over to PHP I might be able to use the Reflection API. But still need to research that (just moved over to PHP5 )

    Anyone this are my ideas for framework, I have been working on now. I think this would be quite nice, I want some sort of solution whereby it's really easy to construct new content-types without the need to really dump into PHP. Only when you want to special stuff such generating files such as sound or images (haven't seen any xslt thing that could make images, only xslt-fo for pdf).

    If anyone have some nice class design ideas, don't hesitate to ask. I am currently revising it to integrate my storage model.

  21. #171
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wdeboer
    Ooh really, I thought the idea was that the Response() would output data? Ooh well, maybe I should alter the current design of the ApplicationController/FrontController here. Anyway I thought a View shouldn't output/echo his stuff itself.
    The point of the response object is to facilitate output filtering; the view sets the headers and the body of the response object, the output filters run, and finally the the front controller calls the out method to send the data to the browser. If the view outputs directly, that output will need to be captured for the filters to work, which IMO is less elegant than using the response object.

  22. #172
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What sort of filters do we need?
    Hello World

  23. #173
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's where I'm at now. Context, Session, PersistentDataSpace, input validation - all in a nice bunch with some examples. PHP5.
    Attached Files Attached Files
    Last edited by Ezku; Jul 23, 2005 at 02:43.

  24. #174
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, EzKe. It looks like that you need to implementate a Controller for everything, i.e. an FormController for forms etc. It's not possible to support Forms in the FrontController instead? Maybe I should use a a ApplicationController for that, that creates the correct (Front)Controller instance?

    p.s.s what did you guys think of my idea mentioned above?

  25. #175
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    Perhaps we need some sort of MVC Command thingy that controllers could dispatch. It would support separation and correct dependency.
    I think you're overcomplicating things a bit. Instead of thinking a hierarchy of views, we should think a hierarchy of controllers.
    For the simplest kind - ServerPage - composition could be done simply with an include(). DougBTX made that point already. I'd probably use a method instead of the statement directly. That way we could use a factory to allow including other types of handlers.

    I'm not a big fan of using xml/xslt for rendering the view as timw does it. I prefer simply using ServerPages (php-as-a-template-engine). There's no reason however why you couldn't choose to use a templateview (which xml/xslt is) for rendering, if you prefer it. The action-class (the Handler) would then use the template to render, and pass the result to the Response-object. Eg. :
    PHP Code:
    class MyAction
    {
        function 
    execute(&$request, &$response) {
            
    $t =& new Template();
            
    $m =& new Model();
            
    $t->set("foo"$m->get("foo"));
            
    $response->setContent($t->render());
        }

    Now, you can replace the above Template class with whatever templating-engine you wish. Including xml/xslt.

    Composition of views would be done at the controller-level (in the MyAction class). Something akin to this :
    PHP Code:
    class MyOtherAction
    {
        function 
    execute(&$request, &$response) {
            
    $inner =& new MyAction();
            
    $buffer =& new Response();
            
    $inner->execute($request$buffer);

            
    $t =& new Template();
            
    $m =& new Model();
            
    $t->set("bar"$m->get("bar"));
            
    $t->set("inner"$buffer);
            
    $response->setContent($t->render());
        }

    As wdeboer and timw have mentioned, headers are a bit tricky. I don't really have an answer to this, but having some pseudo-headers as timw suggested may be the best solution. The response would then have to translate theese into actual headers before rendering.


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
  •