Differences in the male & female orgasm

You’ll need Javascript to view this page that describes the differences between male and female orgasms. Safe for work! (via Dave)
The Sunday Times has a great article describing the male orgasm. Girls.. if you ever wanted to know what t’s like, Jonathan Margolis describes it very well! Although I do disagree that women have better ones than men!

Using Smarty to implement the MVC design pattern in PHP

Here’s my first go trying to create a registration page using the Model View Controller design.
Before you delve into the code, here’s some background not included in the code:

  1. You’ll need to know something about Smarty before reading this. Their crash course is useful for this.
  2. Here’s a Google Search to find more MVC information and tutorials.
  3. My template dir is “./templates” and for every template file I also have a php file which defines information used by the template. In my example, that includes a list of fields for the registration page. (so I use a Smarty foreach loop to create the form)
  4. I only have one model and view despite the fact a registration page could be two pages: initial registration page, and a thank you page. The one “view” class displays both by using different Smarty templates.
  5. I haven’t included the HTML templates as they’re not as interesting as the code.
  6. In Java land they tend to use page redirects to load alternate pages (ie. send a “Location” HTTP header or use meta tags) but I’ve hijacked the view controller by redefining the view template so it points at “thankyou.tpl” instead of “registration.tpl”. See the switch statement in RegistrationController::main()

I posted some more information to the webdev mailing list too.
I’d appreciate any comments and feedback!

<?php
require_once( “Smarty.class.php” );

class registrationView
{
    var $smarty;
    var $model;

    function registrationView( &$model, $template )
    {
        $this->smarty = new Smarty;
        $this->model =& $model;
        $this->setTemplate( $template );
    }

    function setTemplate( $formTplName = ‘registration’ )
    {
        $this->formTplName = $formTplName . “.tpl”;
        if( is_file( “templates/” . $formTplName . “.php” ) )
        {
            include_once( “templates/” . $formTplName . “.php” );
            $this->fields = $fields;
        }
        else
        {
            $this->fields = array();
        }

    }

    function display()
    {
        $this->smarty->assign( “fields”, $this->fields );
        $this->smarty->assign( “form”, $this->model->getFormValues() );
        $this->smarty->assign( “error”, $this->model->getErrorValues() );
        $this->smarty->display( $this->formTplName );
    }

}
class registrationModel
{
    var $form;
    var $db;

    function registrationModel( &$form )
    {
        $this->db = new DB_Tsc;
        $this->form = $form;
    }

    function getFormValues()
    {
        return $this->form;
    }

    function getErrorValues()
    {
        return $this->error;
    }

    function validateForm()
    {
        $ret = true;
        if( is_array( $this->form ) )
        {
            reset( $this->form );
            foreach( $this->form as $key => $val )
            {
                if( $val == ” )
                {
                    $this->error[ $key ] = true;
                    $ret = false;
                }
            }
        }
        else
        {
            $this->error[ ‘warning’ ] = “Please complete the form”;
            $ret = false;
        }
        return $ret;
    }

    function saveForm()
    {
    }
}

class RegistrationController
{
    var $view;
    var $model;
    var $page;

    function RegistrationController( $page, &$form )
    {
        $this->page = $page;
        $this->model = new registrationModel( $form );
        $this->view = new registrationView( $this->model, “registration” );
    }

    function main()
    {
        switch( $this->page )
        {
            case “validate”:
                if( $this->model->validateForm() )
                {
                    $this->model->saveForm();
                    $this->view->setTemplate( ‘thankyou’ );
                }
                $this->view->display();
                break;
            default:
                $this->view->display();
                break;
        }
    }
}

$t = new RegistrationController( $page, $form );
$t->main();
?>