function testSubstitutionInSubtemplate() { $tText = 'Hello World.' . '<!-- BEGIN subtemplate -->' . " I love 'you'!" . '<!-- END subtemplate -->'; $expText = 'Hello World.'; $t = new Template($tText); $t->assign('you', 'bugs'); $this->assertEquals($expText, $t->result()); }
$res = $myReportObj->startDataProcessing(); if ($res != SUCCESS) { $content['error_occured'] = true; $content['error_details'] = GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetErrorMessage($res)); if (isset($extraErrorDescription)) { $content['error_details'] .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription); } } else { // --- Perform report output // Init template Parser $page = new Template(); $page->set_path($reportIncludePath); // Parse template $page->parser($content, $myReportObj->GetBaseFileName()); // Output the result $res = $myReportObj->OutputReport($page->result(), $szErrorStr); if ($res == SUCCESS && $myReportObj->GetOutputTarget() != REPORT_TARGET_STDOUT) { // Output wasn't STDOUT, so we need to display what happened to the user $content['report_success'] = true; $content['error_details'] = GetAndReplaceLangStr($content["LN_GEN_SUCCESS_REPORTWASGENERATED_DETAILS"], $szErrorStr); } else { if ($res == ERROR) { // Output failed, display what happened to the user $content['error_occured'] = true; $content['error_details'] = GetAndReplaceLangStr($content["LN_GEN_ERROR_REPORTFAILEDTOGENERATE"], $szErrorStr); if (isset($extraErrorDescription)) { $content['error_details'] .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription); } } } // ---
/** * Helper function using the template parser to create the report */ public function CreateReportFromData() { // Create new template parser $page = new Template(); $page->set_path($gl_root_path . "classes/reports/"); // Run Parser $page->parser($this->_reportcontent, $this->_baseFileName); // Return result! return $page->result(); }
* the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * This script connects to the database or exits by sending an error message. * If a connection is etablished, old database entries will be deleted. */ require_once 'tools/MyDatabase.php'; require_once 'tools/Output.php'; require_once 'text/Template.php'; $templateText = <<<EOT <h2>Störung</h2> <div class="text"> Leider besteht zur Zeit keine Verbindung zur Datenbank. :-( </div> EOT; MyDatabase::connect(); if (!MyDatabase::getConnection()) { $tmpl = new Template($templateText); $output = new Output(); $output->send($tmpl->result()); exit; }
function RunReport() { global $content, $gl_root_path; // Get Reference to report! $myReport = $content['REPORTS'][$content['reportid']]; // Get reference to savedreport $mySavedReport = $myReport['SAVEDREPORTS'][$content['savedreportid']]; // Get Objectreference to report $myReportObj = $myReport["ObjRef"]; // Set SavedReport Settings! $myReportObj->InitFromSavedReport($mySavedReport); //Debug Output PrintHTMLDebugInfo(DEBUG_INFO, "RunReport", GetAndReplaceLangStr($content["LN_CMD_RUNREPORT"], $mySavedReport['customTitle'])); // Perform check $res = $myReportObj->verifyDataSource(); if ($res != SUCCESS) { // Print error and die! $szError = GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetAndReplaceLangStr(GetErrorMessage($res), $mySavedReport['sourceid'])); if (isset($extraErrorDescription)) { $szError .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription); } DieWithErrorMsg($szError); } else { // Call processing part now! $res = $myReportObj->startDataProcessing(); if ($res != SUCCESS) { DieWithErrorMsg(GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetErrorMessage($res))); } else { // --- Perform report output // Init IncludePath $reportIncludePath = $myReportObj->GetReportIncludePath(); // Include Custom language file if available $myReportObj->InitReportLanguageFile($reportIncludePath); // Init template Parser $page = new Template(); $page->set_path($reportIncludePath); // Parse template $page->parser($content, $myReportObj->GetBaseFileName()); // Output the result $res = $myReportObj->OutputReport($page->result(), $szErrorStr); if ($res == SUCCESS && $myReportObj->GetOutputTarget() != REPORT_TARGET_STDOUT) { //Debug Output PrintHTMLDebugInfo(DEBUG_INFO, "RunReport", GetAndReplaceLangStr($content["LN_GEN_SUCCESS_REPORTWASGENERATED_DETAILS"], $szErrorStr)); } else { if ($res == ERROR) { // Debug Error PrintHTMLDebugInfo(DEBUG_ERROR, "RunReport", GetAndReplaceLangStr($content["LN_GEN_ERROR_REPORTFAILEDTOGENERATE"], $szErrorStr)); } } // --- } } }