/** * Will execute the passed .tp FilePath, and extract the variables as references (or overwrites). Assigning the variables is * not enough. You need to make a CALL to TPL::tpExe ($tpF) to execute the specified $tpF file; * * @param string $tpFileName The path to the .tp file to be executed * @param boolean $tpAsAJAXResponse Set to TRUE when echo'ing the .tp as an AJAX response * @return boolean Will return true if the file has been executed properly * @author Catalin Z. Alexandru <*****@*****.**> * @copyright Under the terms of the GNU General Public License v3 * @version $Id: 10_TPL.php 315 2009-10-11 07:11:31Z catalin.zamfir $ * @since Version 1.0 * @access public * @static * @final */ public static final function tpExe(FilePath $tpFileName, B $tpAsAJAXResponse = NULL) { // Set some requirements ... if ($tpAsAJAXResponse == NULL) { $tpAsAJAXResponse = new B(FALSE); } // Make sure we're actually there ... if ($tpFileName->checkPathExists()) { self::$objFilePathArray[$tpFileName]['dummy_' . $_SERVER['REQUEST_TIME']] = new S('do_not_cache'); if (extract(self::$objFilePathArray[$tpFileName]->toArray(), EXTR_REFS)) { // If it's an AJAX request for HTML, CLEAN it; if ($tpAsAJAXResponse->toBoolean() == TRUE) { TPL::discardOutputStream(new B(TRUE)); TPL::switchHTML(); } // Require the template file ... require $tpFileName->toString(); // Unset all predefined variables, for a memory clean-up; unset(self::$objFilePathArray[$tpFileName]); // Do me a favor and STOP right here ... if ($tpAsAJAXResponse->toBoolean() == TRUE) { // DIE; TPL::disableFurtherOutput(); } // Return the status; return new B(TRUE); } else { self::renderScreenOfDeath(new S(__CLASS__), new S(CANNOT_EXTRACT_VARS), new S(CANNOT_EXTRACT_VARS_FIX)); } } else { self::renderScreenOfDeath(new S(__CLASS__), new S(FILE_DOESNT_EXIST), new S(FILE_DOESNT_EXIST_FIX)); } }