$flexy->outputObject() (Previous) (Next) $flexy->getElements()

View this page in Last updated: Mon, 02 Jul 2007
English | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Plain HTML

$flexy->bufferedOutputObject()

$flexy->bufferedOutputObject() -- Merges a controller object with the template and returns the result

Opis

This maps the values of the supplied object and runs the compiled template, and returns the result.

This can be used in conjuction with PEAR::Cache, or in the example below, with a email template (note this still needs testing.. - the backend should eventually support a native tokenizer for email templates.)

Parametr

  • object $controllerObject - The object you want to use with the template, the values of the object will relate to the $controllerObject->tag will map to {tag} on the template

  • array $elements - This is an associative array of form, or dynamic elements names (or id's) which will be merged with the one defined in the template.

Zwracana wartość

string - the object variables overlayed on the template

Uwagi

Ta funkcja nie może być wywołana statycznie.

Przykład

Przykład 43-1. Person DataObject send_password method


<?php
class DataObjects_Person {
    var $id;
    var $name;
    var $password;
    var $cleartextPassword;
    var $email;
    
    function sendEmail($templateFile,$content) {
            
            $content = is_object($content) ? $content : (object) $content;
            foreach(get_object_vars($this) as $k=>$v) {
                $content->$k = $v;
            }
            /* use the regex compiler, as it doesnt parse <tags */
            $template = new HTML_Template_Flexy( array(
                    'compiler'    => 'Regex',
                     'filters' => array('SimpleTags','Mail'),
                ));
            
            /* compile a text file (email template) */
            $template->compile($templateFile);
            
            /* use variables from this object to ouput data. */
            $mailtext = $template->bufferedOutputObject($content);
            //echo "<PRE>";print_R($mailtext);
            
            /* With the output try and send an email, using a few tricks in Mail_MimeDecode. */
            require_once 'Mail/mimeDecode.php';
            require_once 'Mail.php';
            
            $decoder = new Mail_mimeDecode($mailtext);
            $parts = $decoder->getSendArray();
            if (PEAR::isError($parts)) {
                return $parts;
                
            } 
            list($recipents,$headers,$body) = $parts;
            
            $mailOptions = PEAR::getStaticProperty('Mail','options');
            $mail = Mail::factory("SMTP",$mailOptions);
            
            return PEAR::isError($mail) ? $mail : $mail->send($recipents,$headers,$body);
        
        
        }
    
       
}
?>

$flexy->outputObject() (Previous) (Next) $flexy->getElements()

Download Documentation Last updated: Mon, 02 Jul 2007
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.