Changeset 4744 in subversion


Ignore:
Timestamp:
May 9, 2011 7:47:33 AM (2 years ago)
Author:
alec
Message:
  • Extend parse() method so it can be used to parse templates without printing to stdout
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_template.php

    r4672 r4744  
    110110    } 
    111111 
    112  
    113112    /** 
    114113     * Set page title variable 
     
    118117        $this->pagetitle = $title; 
    119118    } 
    120  
    121119 
    122120    /** 
     
    139137        return $title; 
    140138    } 
    141  
    142139 
    143140    /** 
     
    223220    } 
    224221 
    225  
    226222    /** 
    227223     * Add a localized label to the client environment 
     
    237233        } 
    238234    } 
    239  
    240235 
    241236    /** 
     
    256251        } 
    257252    } 
    258  
    259253 
    260254    /** 
     
    277271    } 
    278272 
    279  
    280273    /** 
    281274     * Redirect to a certain url 
     
    290283        exit; 
    291284    } 
    292  
    293285 
    294286    /** 
     
    360352 
    361353    /** 
    362      * Parse a specific skin template and deliver to stdout 
    363      * 
    364      * Either returns nothing, or exists hard (exit();) 
     354     * Parse a specific skin template and deliver to stdout (or return) 
    365355     * 
    366356     * @param  string  Template name 
    367357     * @param  boolean Exit script 
    368      * @return void 
     358     * @param  boolean Don't write to stdout, return parsed content instead 
     359     * 
    369360     * @link   http://php.net/manual/en/function.exit.php 
    370361     */ 
    371     private function parse($name = 'main', $exit = true) 
     362    function parse($name = 'main', $exit = true, $write = true) 
    372363    { 
    373364        $skin_path = $this->config['skin_path']; 
     
    427418        $hook = $this->app->plugins->exec_hook("render_page", array('template' => $realname, 'content' => $output)); 
    428419 
    429         // add debug console 
    430         if ($this->config['debug_level'] & 8) { 
    431             $this->add_footer('<div id="console" style="position:absolute;top:5px;left:5px;width:405px;padding:2px;background:white;z-index:9000;"> 
    432                 <a href="#toggle" onclick="con=$(\'#dbgconsole\');con[con.is(\':visible\')?\'hide\':\'show\']();return false">console</a> 
    433                 <textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:10px" spellcheck="false"></textarea></div>' 
    434             ); 
    435         } 
    436  
    437420        $output = $this->parse_with_globals($hook['content']); 
    438         $this->write(trim($output)); 
     421 
     422        if ($write) { 
     423            // add debug console 
     424            if ($this->config['debug_level'] & 8) { 
     425                $this->add_footer('<div id="console" style="position:absolute;top:5px;left:5px;width:405px;padding:2px;background:white;z-index:9000;"> 
     426                    <a href="#toggle" onclick="con=$(\'#dbgconsole\');con[con.is(\':visible\')?\'hide\':\'show\']();return false">console</a> 
     427                    <textarea name="console" id="dbgconsole" rows="20" cols="40" wrap="off" style="display:none;width:400px;border:none;font-size:10px" spellcheck="false"></textarea></div>' 
     428                ); 
     429            } 
     430            $this->write(trim($output)); 
     431        } 
     432        else { 
     433            return $output; 
     434        } 
     435 
    439436        if ($exit) { 
    440437            exit; 
    441438        } 
    442439    } 
    443  
    444440 
    445441    /** 
Note: See TracChangeset for help on using the changeset viewer.