From 84db68e59426190fdc5b8cd4b4525be88699f570 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 23 Jun 2008 21:00:47 +0000 Subject: [PATCH] Final fixes for variable inserting --- .../templates/de/code/captch_graphic_code.ctp | 12 +- .../templates/de/code/login_form.ctp | 4 +- .../templates/de/code/register_form.ctp | 2 +- .../main/class_BaseFrameworkSystem.php | 2 +- .../commands/web/class_WebDoFormCommand.php | 2 +- .../main/helper/captcha/class_BaseCaptcha.php | 24 +++ .../web/class_GraphicalCodeCaptcha.php | 27 +++- .../main/helper/web/class_WebFormHelper.php | 47 ++++-- .../action/class_BaseActionResolver.php | 2 +- .../command/class_BaseCommandResolver.php | 2 +- .../class_BaseControllerResolver.php | 2 +- .../web/class_WebControllerResolver.php | 2 +- .../template/class_BaseTemplateEngine.php | 143 ++++++++++-------- templates/de/code/emergency_exit.ctp | 44 +++--- 14 files changed, 192 insertions(+), 123 deletions(-) diff --git a/application/ship-simu/templates/de/code/captch_graphic_code.ctp b/application/ship-simu/templates/de/code/captch_graphic_code.ctp index de17efb..a134e30 100644 --- a/application/ship-simu/templates/de/code/captch_graphic_code.ctp +++ b/application/ship-simu/templates/de/code/captch_graphic_code.ctp @@ -1,11 +1,11 @@ addFormGroup('captcha_code', "Unser Spiel ist durch ein grafisches CAPTCHA gesichert. Du musst den angezeigten Code wiederholen, damit du unser Spiel nutzen kannst."); -$helper->addFieldText('captcha_code', "Bitte wiederhole den Code:"); -$helper->addInputTextField('captcha_code'); -$helper->addInputHiddenField('captcha_hash', $this->readVariable('captcha_hash')); -$helper->flushContent(); +$captchaHelper = WebFormHelper::createWebFormHelper($this, 'captcha_code', false, false); +$captchaHelper->addFormGroup('code', ""); +$captchaHelper->addFieldText('code', "Bitte wiederhole den Code:"); +$captchaHelper->addInputTextField('code'); +$captchaHelper->addInputHiddenField('hash', $this->readVariable('captcha_hash')); +$captchaHelper->flushContent(); // [EOF] ?> diff --git a/application/ship-simu/templates/de/code/login_form.ctp b/application/ship-simu/templates/de/code/login_form.ctp index 0a00ca5..4bdb82d 100644 --- a/application/ship-simu/templates/de/code/login_form.ctp +++ b/application/ship-simu/templates/de/code/login_form.ctp @@ -2,7 +2,7 @@ // Get helper instance for web forms. This will add the opening form-tag to // the helper's render cache which is simply a small variable in the class // BaseHelper. -$helper = WebFormHelper::createWebFormHelper($this, "shipsimu_user_login"); +$helper = WebFormHelper::createWebFormHelper($this, 'shipsimu_user_login'); // Formular deaktiviert? if ($helper->ifLoginIsEnabled()) { @@ -53,7 +53,7 @@ $helper->flushContent(); // Ist Gastlogin erlaubt? if ($helper->ifGuestLoginAllowed()) { // Neue Helper-Instanz holen - $helper = WebFormHelper::createWebFormHelper($this, "shipsimu_guest_login"); + $helper = WebFormHelper::createWebFormHelper($this, 'shipsimu_guest_login'); $helper->addInputHiddenConfiguredField('username', 'guest_login'); $helper->addInputHiddenConfiguredField('pass', 'guest_login'); diff --git a/application/ship-simu/templates/de/code/register_form.ctp b/application/ship-simu/templates/de/code/register_form.ctp index 4593e01..ceddb92 100644 --- a/application/ship-simu/templates/de/code/register_form.ctp +++ b/application/ship-simu/templates/de/code/register_form.ctp @@ -2,7 +2,7 @@ // Get helper instance for web forms. This will add the opening form-tag to // the helper's render cache which is simply a small variable in the class // BaseHelper. -$helper = WebFormHelper::createWebFormHelper($this, "shipsimu_register"); +$helper = WebFormHelper::createWebFormHelper($this, 'shipsimu_register'); // Always ask at least for nickname and password $helper->addFormGroup('login', "Bitte gebe hier gewünschten Nickname und dein Zugangspasswort ein."); diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index a4052ef..5c96b95 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -1022,7 +1022,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * * @return void */ - public function debugBacktrace () { + public function debugBackTrace () { // Sorry, there is no other way getting this nice backtrace print "
\n";
 		debug_print_backtrace();
diff --git a/inc/classes/main/commands/web/class_WebDoFormCommand.php b/inc/classes/main/commands/web/class_WebDoFormCommand.php
index 019ddd7..82f1c6f 100644
--- a/inc/classes/main/commands/web/class_WebDoFormCommand.php
+++ b/inc/classes/main/commands/web/class_WebDoFormCommand.php
@@ -67,7 +67,7 @@ class WebDoFormCommand extends BaseCommand implements Commandable {
 	 */
 	public function execute (Requestable $requestInstance, Responseable $responseInstance) {
 		// Should never be executed...
-		$this->debugBacktrace();
+		$this->debugBackTrace();
 	}
 
 	/**
diff --git a/inc/classes/main/helper/captcha/class_BaseCaptcha.php b/inc/classes/main/helper/captcha/class_BaseCaptcha.php
index 2da834e..09b3e91 100644
--- a/inc/classes/main/helper/captcha/class_BaseCaptcha.php
+++ b/inc/classes/main/helper/captcha/class_BaseCaptcha.php
@@ -22,6 +22,11 @@
  * along with this program.  If not, see .
  */
 class BaseCaptcha extends BaseHelper {
+	/**
+	 * A helper instance for the form
+	 */
+	private $helperInstance = null;
+
 	/**
 	 * Instance of an RNG
 	 */
@@ -61,6 +66,25 @@ class BaseCaptcha extends BaseHelper {
 	protected final function getRngInstance () {
 		return $this->rngInstance;
 	}
+
+	/**
+	 * Setter for helper instance
+	 *
+	 * @param	$helperInstance		An instance of a helper class
+	 * @return	void
+	 */
+	protected final function setHelperInstance (HelpableTemplate $helperInstance) {
+		$this->helperInstance = $helperInstance;
+	}
+
+	/**
+	 * Getter for helper instance
+	 *
+	 * @return	$helperInstance		An instance of a helper class
+	 */
+	public final function getHelperInstance () {
+		return $this->helperInstance;
+	}
 }
 
 // [EOF]
diff --git a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php
index 64f5788..3e57d24 100644
--- a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php
+++ b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php
@@ -51,16 +51,16 @@ class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha {
 	/**
 	 * Creates an instance of this captcha class
 	 *
-	 * @param	$templateInstance	An instance of a template engine
+	 * @param	$helperInstance		An instance of a helper class
 	 * @param	$extraInstance		An extra instance, just for better hash data
 	 * @return	$captchaInstance	An instance of this captcha class
 	 */
-	public final static function createGraphicalCodeCaptcha (CompileableTemplate $templateInstance, FrameworkInterface $extraInstance = null) {
+	public final static function createGraphicalCodeCaptcha (HelpableTemplate $helperInstance, FrameworkInterface $extraInstance = null) {
 		// Get a new instance
 		$captchaInstance = new GraphicalCodeCaptcha();
 
 		// Set template instance
-		$captchaInstance->setTemplateInstance($templateInstance);
+		$captchaInstance->setHelperInstance($helperInstance);
 
 		// Initialize the RNG
 		$captchaInstance->initializeRandomNumberGenerator($extraInstance);
@@ -133,18 +133,29 @@ class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha {
 	 * @return	void
 	 */
 	public function renderCode () {
+		// Get helper instance
+		$helperInstance = $this->getHelperInstance();
+
+		// Get template instance
+		$templateInstance = $helperInstance->getTemplateInstance();
+
 		// Load a template for this CAPTCHA
-		$this->getTemplateInstance()->loadCodeTemplate("captch_graphic_code");
+		$templateInstance->loadCodeTemplate("captch_graphic_code");
+
+		// Rename variable
+		$templateInstance->renameVariable('captcha_code', $helperInstance->getFormName().'_captcha');
+		$templateInstance->renameVariable('captcha_hash', $helperInstance->getFormName().'_hash');
+		$templateInstance->renameVariable('encrypted_code', $helperInstance->getFormName().'_encrypt');
 
 		// Assign variables
-		$this->getTemplateInstance()->assignVariable('encrypted_code', urlencode(base64_encode($this->encryptedString)));
-		$this->getTemplateInstance()->assignVariable('captcha_hash', $this->hashedString);
+		$templateInstance->assignVariable($helperInstance->getFormName().'_encrypt', urlencode(base64_encode($this->encryptedString)));
+		$templateInstance->assignVariable($helperInstance->getFormName().'_hash', $this->hashedString);
 
 		// Compile the template
-		$this->getTemplateInstance()->compileTemplate();
+		$templateInstance->compileTemplate();
 
 		// Get the content back
-		$this->addContent($this->getTemplateInstance()->getRawTemplateData());
+		$this->addContent($templateInstance->getRawTemplateData());
 	}
 }
 
diff --git a/inc/classes/main/helper/web/class_WebFormHelper.php b/inc/classes/main/helper/web/class_WebFormHelper.php
index 43ea978..1ec70bc 100644
--- a/inc/classes/main/helper/web/class_WebFormHelper.php
+++ b/inc/classes/main/helper/web/class_WebFormHelper.php
@@ -48,6 +48,11 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 	 */
 	private $subGroupOpened = false;
 
+	/**
+	 * Name of the group
+	 */
+	private $groupName = "";
+
 	/**
 	 * Name of the sub group
 	 */
@@ -182,7 +187,7 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 			// Is a group open?
 			if ($this->groupOpened === true) {
 				// Then automatically close it here
-				$this->addFormGroup("", "");
+				$this->addFormGroup();
 			} // END - if
 
 			// Simply close it
@@ -404,13 +409,13 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 	/**
 	 * Add a form group or close an already opened and open a new one
 	 *
-	 * @param	$groupName	Name of the group
+	 * @param	$groupName	Name of the group or last opened if empty
 	 * @param	$groupText	Text including HTML to show above this group
 	 * @return	void
 	 * @throws	FormClosedException		If no form has been opened before
 	 * @throws	EmptyVariableException	If $groupName is not set
 	 */
-	public function addFormGroup ($groupName, $groupText) {
+	public function addFormGroup ($groupName = "", $groupText = "") {
 		// Is a form opened?
 		if (($this->formOpened === false) && ($this->formEnabled === true)) {
 			// Throw exception here
@@ -421,6 +426,15 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 		if ((empty($groupName)) && ($this->groupOpened === false)) {
 			// Throw exception here
 			throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+		} elseif (empty($groupName)) {
+			// Close the last opened
+			$groupName = $this->groupName;
+		}
+
+		// Same group to open?
+		if (($this->groupOpened === false) && ($groupName == $this->groupName)) {
+			// Abort here silently
+			return false;
 		} // END - if
 
 		// Initialize content with closing div by default
@@ -446,12 +460,13 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 			$this->addContent($content);
 
 			// Switch the state
+			$this->groupName = $groupName;
 			$this->groupOpened = true;
 		} else {
 			// Is a sub group opened?
 			if ($this->subGroupOpened === true) {
 				// Close it here
-				$this->addFormSubGroup("", "");
+				$this->addFormSubGroup();
 			} // END - if
 
 			// Add the content
@@ -472,13 +487,13 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 	 * throws an exception if no group has been opened before or if the sub
 	 * group name is empty.
 	 *
-	 * @param	$subGroupName	Name of the group
+	 * @param	$subGroupName	Name of the group or last opened if empty
 	 * @param	$subGroupText	Text including HTML to show above this group
 	 * @return	void
 	 * @throws	FormGroupClosedException	If no group has been opened before
 	 * @throws	EmptyVariableException		If $subGroupName is not set
 	 */
-	public function addFormSubGroup ($subGroupName, $subGroupText) {
+	public function addFormSubGroup ($subGroupName = "", $subGroupText = "") {
 		// Is a group opened?
 		if ($this->groupOpened === false) {
 			// Throw exception here
@@ -489,7 +504,10 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 		if ((empty($subGroupName)) && ($this->subGroupOpened === false)) {
 			// Throw exception here
 			throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
-		} // END - if
+		} elseif (empty($subGroupName)) {
+			// Close the last opened
+			$subGroupName = $this->subGroupName;
+		}
 
 		// Initialize content with closing div by default
 		$content = "	\n";
@@ -582,7 +600,7 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 		// Is a group open?
 		if ($this->groupOpened === true) {
 			// Then automatically close it here
-			$this->addFormGroup("", "");
+			$this->addFormGroup();
 		} // END - if
 
 		// Generate the content
@@ -768,9 +786,18 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate {
 		if (($this->formOpened === true) && ($this->formEnabled === true)) {
 			// Close the form automatically
 			$this->addFormTag();
-		} // END - if
+		} elseif ($this->formEnabled === false) {
+			if ($this->subGroupOpened === true) {
+				// Close sub group
+				$this->addFormSubGroup();
+			} elseif ($this->groupOpened === true) {
+				// Close group
+				$this->addFormGroup();
+			}
+		}
 
 		// Send content to template engine
+		//* DEBUG: */ echo __METHOD__.": form=".$this->getFormName().", size=".strlen($this->getContent())."
\n"; $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->getContent()); } @@ -798,7 +825,7 @@ class WebFormHelper extends BaseHelper implements HelpableTemplate { $extraInstance = Registry::getRegistry()->getInstance('extra'); // Get a configured instance - $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName()."_captcha", array($this->getTemplateInstance(), $extraInstance)); + $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName()."_captcha", array($this, $extraInstance)); // Initiate the CAPTCHA $captchaInstance->initiateCaptcha(); diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php index 5c3aaa7..ceb10fe 100644 --- a/inc/classes/main/resolver/action/class_BaseActionResolver.php +++ b/inc/classes/main/resolver/action/class_BaseActionResolver.php @@ -102,7 +102,7 @@ class BaseActionResolver extends BaseResolver { } // END - if // Debug output - //* DEBUG: */ $this->debugBacktrace(); + //* DEBUG: */ $this->debugBackTrace(); // Set action name $this->setActionName($actionName); diff --git a/inc/classes/main/resolver/command/class_BaseCommandResolver.php b/inc/classes/main/resolver/command/class_BaseCommandResolver.php index 7493507..c184caf 100644 --- a/inc/classes/main/resolver/command/class_BaseCommandResolver.php +++ b/inc/classes/main/resolver/command/class_BaseCommandResolver.php @@ -126,7 +126,7 @@ class BaseCommandResolver extends BaseResolver { } // END - if // Debug output - //* DEBUG: */ $this->debugBacktrace(); + //* DEBUG: */ $this->debugBackTrace(); // Set command name $this->setCommandName($commandName); diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php index 7a7d026..1b5fa1c 100644 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php @@ -117,7 +117,7 @@ class BaseControllerResolver extends BaseResolver { } // END - while // Debug output - //* DEBUG: */ $this->debugBacktrace(); + //* DEBUG: */ $this->debugBackTrace(); // Return the result return $isValid; diff --git a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php index 2b0c17d..ca1aa92 100644 --- a/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php +++ b/inc/classes/main/resolver/controller/web/class_WebControllerResolver.php @@ -127,7 +127,7 @@ class WebControllerResolver extends BaseControllerResolver implements Controller */ private function loadController ($controllerName) { // Debug message - //* DEBUG: */ $this->debugBacktrace(); + //* DEBUG: */ $this->debugBackTrace(); // Cache default command $defaultController = $this->getConfigInstance()->readConfig('default_command'); diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index 8a53c46..c0b8899 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -295,11 +295,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ private final function setTemplateType ($templateType) { - // Cast it - $templateType = (string) $templateType; - - // And set it (only 2 letters) - $this->templateType = $templateType; + $this->templateType = (string) $templateType; } /** @@ -309,9 +305,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ private final function setLastTemplate ($template) { - // Cast it to string - $template = (string) $template; - $this->lastTemplate = $template; + $this->lastTemplate = (string) $template; } /** @@ -330,11 +324,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ public final function setBasePath ($basePath) { - // Cast it - $basePath = (string) $basePath; - // And set it - $this->basePath = $basePath; + $this->basePath = (string) $basePath; } /** @@ -355,11 +346,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ public final function setRawTemplateExtension ($templateExtension) { - // Cast it - $templateExtension = (string) $templateExtension; - // And set it - $this->templateExtension = $templateExtension; + $this->templateExtension = (string) $templateExtension; } /** @@ -370,11 +358,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ public final function setCodeTemplateExtension ($codeExtension) { - // Cast it - $codeExtension = (string) $codeExtension; - // And set it - $this->codeExtension = $codeExtension; + $this->codeExtension = (string) $codeExtension; } /** @@ -407,11 +392,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ public final function setCompileOutputPath ($compileOutputPath) { - // Cast it - $compileOutputPath = (string) $compileOutputPath; - // And set it - $this->compileOutputPath = $compileOutputPath; + $this->compileOutputPath = (string) $compileOutputPath; } /** @@ -480,11 +462,20 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ private final function setRawTemplateData ($rawTemplateData) { - // Cast it to string - $rawTemplateData = (string) $rawTemplateData; - // And store it in this class - $this->rawTemplateData = $rawTemplateData; + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($rawTemplateData)." Bytes set.
\n"; + //* DEBUG: */ echo $this->currGroup." variables: ".count($this->varStack[$this->currGroup]).", groups=".count($this->varStack)."
\n"; + $this->rawTemplateData = (string) $rawTemplateData; + } + + /** + * Getter for raw template data + * + * @return $rawTemplateData The raw data from the template + */ + public final function getRawTemplateData () { + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->rawTemplateData)." Bytes read.
\n"; + return $this->rawTemplateData; } /** @@ -493,11 +484,17 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ private final function setCompiledData ($compiledData) { - // Cast it to string - $compiledData = (string) $compiledData; - // And store it in this class - $this->compiledData = $compiledData; + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($compiledData)." Bytes set.
\n"; + $this->compiledData = (string) $compiledData; + } + + /** + * Getter for compiled templates + */ + public final function getCompiledData () { + //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->compiledData)." Bytes read.
\n"; + return $this->compiledData; } /** @@ -507,9 +504,6 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void */ private function loadTemplate ($template) { - // Cast it to string - $template = (string) $template; - // Get extension for the template $ext = $this->getRawTemplateExtension(); @@ -524,7 +518,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $this->getBasePath(), $this->getLanguageInstance()->getLanguageCode(), $this->getTemplateType(), - $template, + (string) $template, $ext ); @@ -872,41 +866,33 @@ class BaseTemplateEngine extends BaseFrameworkSystem { private function finalizeVariableCompilation () { // Get the content $content = $this->getRawTemplateData(); + //* DEBUG: */ echo __METHOD__.": content before=".strlen($content)." (".md5($content).")
\n"; // Walk through all variables foreach ($this->varStack['general'] as $currEntry) { + //* DEBUG: */ echo __METHOD__.": name=".$currEntry['name'].", value=
".htmlentities($currEntry['value'])."
\n"; // Replace all [$var] or {?$var?} with the content - //* DEBUG: */ echo "name=".$currEntry['name'].", value=
".htmlentities($currEntry['value'])."
\n"; + // Old behaviour, will become obsolete! $content = str_replace("\$content[".$currEntry['name']."]", $currEntry['value'], $content); + + // Yet another old way $content = str_replace("[".$currEntry['name']."]", $currEntry['value'], $content); + + // The new behaviour $content = str_replace("{?".$currEntry['name']."?}", $currEntry['value'], $content); } // END - for + //* DEBUG: */ echo __METHOD__.": content after=".strlen($content)." (".md5($content).")
\n"; + // Set the content back $this->setRawTemplateData($content); } - /** - * Getter for raw template data - * - * @return $rawTemplateData The raw data from the template - */ - public final function getRawTemplateData () { - return $this->rawTemplateData; - } - - /** - * Getter for compiled templates - */ - public final function getCompiledData () { - return $this->compiledData; - } - /** * Load a specified web template into the engine * - * @param $template The web template we shall load which is - * located in "html" by default + * @param $template The web template we shall load which is located in + * "html" by default * @return void */ public function loadWebTemplate ($template) { @@ -931,8 +917,8 @@ class BaseTemplateEngine extends BaseFrameworkSystem { /** * Load a specified email template into the engine * - * @param $template The email template we shall load which is - * located in "emails" by default + * @param $template The email template we shall load which is located in + * "emails" by default * @return void */ public function loadEmailTemplate ($template) { @@ -1023,8 +1009,10 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight); } // END - while - // Prepare PHP code for eval() command + // Get length for check if PHP code was found $evalLength = strlen($eval); + + // Prepare PHP code for eval() command $eval = str_replace( "<%php", "\";", str_replace( @@ -1032,10 +1020,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem { ) ); - // Did something change? + // Was PHP code found in template? if (strlen($eval) != $evalLength) { // Run the constructed command. This will "compile" all variables in @eval($eval); + //* DEBUG: */ print("
".htmlentities($eval)."
"); } // END - if // Goes something wrong? @@ -1044,16 +1033,19 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $this->debugOutput(sprintf("Failed eval() code:
%s
", $this->markupCode($eval, true)), true); // Output backtrace here - $this->debugBacktrace(); + $this->debugBackTrace(); } // END - if // Set raw template data $this->setRawTemplateData($result); $cnt++; - } + } // END - while + + // Final variable assignment + $this->finalizeVariableCompilation(); // Set the new content - $this->setCompiledData($result); + $this->setCompiledData($this->getRawTemplateData()); } /** @@ -1065,7 +1057,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @throws InvalidArrayCountException If an unexpected array * count has been found */ - public final function compileTemplate () { + public function compileTemplate () { // We will only work with template type "code" from configuration if ($this->getTemplateType() != $this->getConfigInstance()->readConfig('code_template_type')) { // Abort here @@ -1112,11 +1104,11 @@ class BaseTemplateEngine extends BaseFrameworkSystem { } /** - * Output the compiled page to the outside world. In case of web templates - * this would be vaild (X)HTML code. And in case of email templates this - * would store a prepared email body inside the template engine. + * A old deprecated method * * @return void + * @deprecated + * @see BaseTemplateEngine::transferToResponse */ public function output () { // Check which type of template we have @@ -1260,6 +1252,25 @@ class BaseTemplateEngine extends BaseFrameworkSystem { public final function getVariableGroups () { return $this->varGroups; } + + /** + * Renames a variable in code and in stack + * + * @param $oldName Old name of variable + * @param $newName New name of variable + * @return void + */ + public function renameVariable ($oldName, $newName) { + //* DEBUG: */ echo __METHOD__.": oldName={$oldName}, newName={$newName}
\n"; + // Get raw template code + $rawData = $this->getRawTemplateData(); + + // Replace it + $rawData = str_replace($oldName, $newName, $rawData); + + // Set the code back + $this->setRawTemplateData($rawData); + } } // [EOF] diff --git a/templates/de/code/emergency_exit.ctp b/templates/de/code/emergency_exit.ctp index 152a1bd..fdb0014 100644 --- a/templates/de/code/emergency_exit.ctp +++ b/templates/de/code/emergency_exit.ctp @@ -1,33 +1,29 @@ - - {?header:title="Problem in application framework detected!"?} -{?navigation?} +
+ $content[message] +
-
- $content[message] +
+
+ File inclusion backtrace:
- -
-
- File inclusion backtrace: -
-
- $content[backtrace] -
+
+ $content[backtrace]
+
-
-
- Statistics -
-
- Total objects: $content[total_objects] -
-
- Loaded class files: $content[total_includes] - (Including exception and interfaces.) -
+
+
+ Statistics +
+
+ Total objects: $content[total_objects] +
+
+ Loaded class files: $content[total_includes] + (Including exception and interfaces.)
+
{?footer_msg:footer_msg="Please contact the support and supply the full above message, if you think you are not qualified to fix this problem."?} -- 2.39.5