Final fixes for variable inserting
authorRoland Häder <roland@mxchange.org>
Mon, 23 Jun 2008 21:00:47 +0000 (21:00 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 23 Jun 2008 21:00:47 +0000 (21:00 +0000)
14 files changed:
application/ship-simu/templates/de/code/captch_graphic_code.ctp
application/ship-simu/templates/de/code/login_form.ctp
application/ship-simu/templates/de/code/register_form.ctp
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/commands/web/class_WebDoFormCommand.php
inc/classes/main/helper/captcha/class_BaseCaptcha.php
inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php
inc/classes/main/helper/web/class_WebFormHelper.php
inc/classes/main/resolver/action/class_BaseActionResolver.php
inc/classes/main/resolver/command/class_BaseCommandResolver.php
inc/classes/main/resolver/controller/class_BaseControllerResolver.php
inc/classes/main/resolver/controller/web/class_WebControllerResolver.php
inc/classes/main/template/class_BaseTemplateEngine.php
templates/de/code/emergency_exit.ctp

index de17efba62079bbbe5acc4505232f857c245a499..a134e303b1b7f93e567dd3c62c9de7cba4216b52 100644 (file)
@@ -1,11 +1,11 @@
 <?php
 // Get a helper instance without a form tag
-$helper = WebFormHelper::createWebFormHelper($this, "captcha_code", false, false);
-$helper->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]
 ?>
index 0a00ca5c9afc44c0ee7bd29f6afcb108477f17f0..4bdb82dd573116dcb34817ce1a2e0ff4bca2caa6 100644 (file)
@@ -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');
 
index 4593e01bbab6efbe975bc55517cbf1b36d495503..ceddb92a3a5af1d7656488eee218244b65ea3772 100644 (file)
@@ -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&uuml;nschten Nickname und dein Zugangspasswort ein.");
index a4052ef3056ae17f1bbd949b9a0b9a4982631de4..5c96b95c0d0ecf5377999fa27ea49b41b259ecce 100644 (file)
@@ -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 "<pre>\n";
                debug_print_backtrace();
index 019ddd7b213dcb6d84e65410f28cb781f68d7ab3..82f1c6ffe474968ab19f11fb7d17f58d2065bcea 100644 (file)
@@ -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();
        }
 
        /**
index 2da834e9fe681dc38bb1f6f199d747f5c2a101df..09b3e911701e33cf5133fff2be9e92ac202734d9 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 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]
index 64f5788575939bdf584bfb48fc74a0c21722f1f0..3e57d241e65dddf8c1fba3773db2b3f679f9ad61 100644 (file)
@@ -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());
        }
 }
 
index 43ea97822218276adde87a38717d69b8046a878f..1ec70bca8d5e36c56b75e3030bb2153f6997a80b 100644 (file)
@@ -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 = "    </div>\n</div><!-- Sub group- CLOSE //-->";
@@ -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())."<br />\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();
index 5c3aaa7b1b2e115cab9fcaaffc4514cf2d94b2c5..ceb10fef481b9ef6662d0ec7befba446c77c1bd2 100644 (file)
@@ -102,7 +102,7 @@ class BaseActionResolver extends BaseResolver {
                } // END - if
 
                // Debug output
-               //* DEBUG: */ $this->debugBacktrace();
+               //* DEBUG: */ $this->debugBackTrace();
 
                // Set action name
                $this->setActionName($actionName);
index 7493507a5fef56fefb931faa127a86f40b75bba3..c184caf541d1dab6b1afdbc15dbc7da15be51b2e 100644 (file)
@@ -126,7 +126,7 @@ class BaseCommandResolver extends BaseResolver {
                } // END - if
 
                // Debug output
-               //* DEBUG: */ $this->debugBacktrace();
+               //* DEBUG: */ $this->debugBackTrace();
 
                // Set command name
                $this->setCommandName($commandName);
index 7a7d0268c5ba15fcdbd978932771b6617258e39a..1b5fa1c42c2789647ca278e56ec3c122e3225f58 100644 (file)
@@ -117,7 +117,7 @@ class BaseControllerResolver extends BaseResolver {
                } // END - while
 
                // Debug output
-               //* DEBUG: */ $this->debugBacktrace();
+               //* DEBUG: */ $this->debugBackTrace();
 
                // Return the result
                return $isValid;
index 2b0c17dd8d00ef686abc2616ca869a073f2985e9..ca1aa9204b529a4294a6c243424cda5ebbd90c01 100644 (file)
@@ -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');
index 8a53c46859771174e3df40bd82c16e922b868da2..c0b8899b1a9d4f4f9aab0142380d2cdca3d178bf 100644 (file)
@@ -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.<br />\n";
+               //* DEBUG: */ echo $this->currGroup." variables: ".count($this->varStack[$this->currGroup]).", groups=".count($this->varStack)."<br />\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.<br />\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.<br />\n";
+               $this->compiledData = (string) $compiledData;
+       }
+
+       /**
+        * Getter for compiled templates
+        */
+       public final function getCompiledData () {
+               //* DEBUG: */ echo __METHOD__.":".$this->getUniqueId().": ".strlen($this->compiledData)." Bytes read.<br />\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).")<br />\n";
 
                // Walk through all variables
                foreach ($this->varStack['general'] as $currEntry) {
+                       //* DEBUG: */ echo __METHOD__.": name=".$currEntry['name'].", value=<pre>".htmlentities($currEntry['value'])."</pre>\n";
                        // Replace all [$var] or {?$var?} with the content
-                       //* DEBUG: */ echo "name=".$currEntry['name'].", value=<pre>".htmlentities($currEntry['value'])."</pre>\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).")<br />\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("<pre>".htmlentities($eval)."</pre>");
                        } // END - if
 
                        // Goes something wrong?
@@ -1044,16 +1033,19 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                $this->debugOutput(sprintf("Failed eval() code: <pre>%s</pre>", $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}<br />\n";
+               // Get raw template code
+               $rawData = $this->getRawTemplateData();
+
+               // Replace it
+               $rawData = str_replace($oldName, $newName, $rawData);
+
+               // Set the code back
+               $this->setRawTemplateData($rawData);
+       }
 }
 
 // [EOF]
index 152a1bde1c1cf832cbe5e14f10f68acf3dd17fb2..fdb0014ed28d14325abc020a293e13745adc6e24 100644 (file)
@@ -1,33 +1,29 @@
-<!-- A compileable template for emergency messages //-->
-
 {?header:title="Problem in application framework detected!"?}
 
-{?navigation?}
+<div id="emergency_exit message_box">
+       $content[message]
+</div>
 
-       <div id="emergency_exit message_box">
-               $content[message]
+<div id="emergency_exit backtrace_box">
+       <div id="backtrace_header">
+               File inclusion backtrace:
        </div>
-
-       <div id="emergency_exit backtrace_box">
-               <div id="backtrace_header">
-                       File inclusion backtrace:
-               </div>
-               <div id="backtrace_content">
-                       $content[backtrace]
-               </div>
+       <div id="backtrace_content">
+               $content[backtrace]
        </div>
+</div>
 
-       <div id="stats_box">
-               <div id="stats_header">
-                       Statistics
-               </div>
-               <div id="stats_objects">
-                       Total objects: $content[total_objects]
-               </div>
-               <div id="stats_includes">
-                       Loaded class files: $content[total_includes]
-                       <span class="hint">(Including exception and interfaces.)</span>
-               </div>
+<div id="stats_box">
+       <div id="stats_header">
+               Statistics
+       </div>
+       <div id="stats_objects">
+               Total objects: $content[total_objects]
+       </div>
+       <div id="stats_includes">
+               Loaded class files: $content[total_includes]
+               <span class="hint">(Including exception and interfaces.)</span>
        </div>
+</div>
 
 {?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."?}