From: Roland Häder Date: Mon, 26 May 2008 21:02:07 +0000 (+0000) Subject: Registration form nearly done, partial stub support added X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=923cc8def522617b72be511b5d14c843189e88cf;p=shipsimu.git Registration form nearly done, partial stub support added --- diff --git a/.gitattributes b/.gitattributes index ee51bff..7c2e327 100644 --- a/.gitattributes +++ b/.gitattributes @@ -197,7 +197,10 @@ inc/classes/exceptions/template/.htaccess -text inc/classes/exceptions/template/class_BasePathIsEmptyException.php -text inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php -text inc/classes/exceptions/template/class_BasePathReadProtectedException.php -text +inc/classes/exceptions/template/class_FormClosedException.php -text +inc/classes/exceptions/template/class_FormOpenedException.php -text inc/classes/exceptions/template/class_InvalidBasePathStringException.php -text +inc/classes/exceptions/template/class_InvalidFormNameException.php -text inc/classes/exceptions/template/class_InvalidTemplateVariableNameException.php -text inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php -text inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php -text @@ -283,6 +286,11 @@ inc/classes/main/factories/objects/.htaccess -text inc/classes/main/factories/objects/class_ObjectFactory.php -text inc/classes/main/factories/web/.htaccess -text inc/classes/main/factories/web/class_NewsFactory.php -text +inc/classes/main/helper/.htaccess -text +inc/classes/main/helper/class_ -text +inc/classes/main/helper/class_BaseTemplateHelper.php -text +inc/classes/main/helper/web/.htaccess -text +inc/classes/main/helper/web/class_HtmlFormHelper.php -text inc/classes/main/io/.htaccess -text inc/classes/main/io/class_FileIoStream.php -text inc/classes/main/io/class_FrameworkDirectoryPointer.php -text diff --git a/application/ship-simu/templates/de/code/register.ctp b/application/ship-simu/templates/de/code/register.ctp index a246672..cfdbf8c 100644 --- a/application/ship-simu/templates/de/code/register.ctp +++ b/application/ship-simu/templates/de/code/register.ctp @@ -1,28 +1,87 @@ addFormGroup("login", "Bitte gebe hier gewünschten Nickname und dein Zugangspasswort ein."); - $helper->addInputGroup("username", "Nickname im Spiel:"); - $helper->addInputTextField("username", 10, 255); - $helper->addInputGroup("pass1", "Passwort:"); - $helper->addInputPasswordField("pass1", 5, 255); - $helper->addInputGroup("pass2", "Passwortwiederholung:"); - $helper->addInputPasswordField("pass2", 5, 255); -if ($helper->registrationRequiresEmailVerification()) { + +// Nickname und Passwort sollten immer abgefragt werden, die Email als Loginname +// wuerde aber auch gehen. +$helper->addFormGroup("login", "Bitte gebe hier gewünschten Nickname und dein Zugangspasswort ein."); +$helper->addFormSubGroup("username", "Dein Nickname wird nach Absenden des Formulares erst geprüft. Später bauen wir dann einen automatischen Test ein, der dir sofort zeigt, ob der Nickname bereits vergeben ist."); +$helper->addFieldText("username", "Nickname im Spiel:"); +$helper->addInputTextField("username", 10, 255); +$helper->addFormSubGroup("password", "Dein Passwort sollte nicht zu leicht erratbar sein. Später bauen wir hier noch einen automatischen Test ein, der dir sofort die Passwortstärke anzeigt."); +$helper->addFieldText("pass1", "Passwort:"); +$helper->addInputPasswordField("pass1", 5, 255); +$helper->addFieldText("pass2", "Passwortwiederholung:"); +$helper->addInputPasswordField("pass2", 5, 255); + +if ($helper->ifRegistrationRequiresEmailVerification()) { $helper->addFormGroup("email", "Bitte gebe deine Email zweimal (ein zweites Mal zur Bestätigung) ein, damit wir dir deinen Freischaltlink zusenden können."); - $helper->addInputGroup("email1", "Email-Adresse:"); - $helper->addInputTextField("email1", 15, 255); - $helper->addInputGroup("email2", "Wiederholung Email-Adresse:"); - $helper->addInputTextField("email2", 15, 255); -} + $helper->addFieldText("email1", "Email-Adresse:"); + $helper->addInputTextField("email1", 15, 255); + $helper->addFieldText("email2", "Wiederholung Email-Adresse:"); + $helper->addInputTextField("email2", 15, 255); +} // END - email verification + +if ($helper->ifRegistrationIncludesProfile()) { $helper->addFormGroup("profile", "Hier kannst du zusätzlich deine Profildaten vorweg eingeben, du kannst sie aber auch nach dem Login vervollständigen!"); -if (!$helper->registrationRequiresEmailVerification()) { - $helper->addInputGroup("email1", "Email-Adresse:"); + if (!$helper->ifRegistrationRequiresEmailVerification()) { + $helper->addFormSubGroup("email", "Die Angabe deiner Email-Adresse ist nur dann nötig, wenn du auch Email-Benachrichtigungen (*1) haben möchtest."); + $helper->addFieldText("email1", "Email-Adresse:"); $helper->addInputTextField("email1", 15, 255); -} - $helper->addInputGroup("surname", "Dein Vorname:"); + } // END - No email verification + + // Persoenliche Daten mit in der Anmeldung abfragen? + if ($helper->ifRegistrationIncludesPersonaData()) { + $helper->addFormSubGroup("persona", "Wenn du magst, dann vervollständige deine komplette Adresse mit deinem Namen."); + $helper->addFieldText("surname", "Dein Vorname:"); $helper->addInputTextField("surname", 10, 255); - $helper->addInputGroup("family", "Dein Nachname:"); + $helper->addFieldText("family", "Dein Nachname:"); $helper->addInputTextField("family", 10, 255); + $helper->addFieldText("street", "Strasse und Hausnummer:"); + $helper->addInputTextField("street", 10, 255); + $helper->addFieldText("city", "Wohnort:"); + $helper->addInputTextField("city", 10, 255); + } // END - Persona data + + $helper->addFormSubGroup("zip", "Magst du uns auch deine Postleitzahl verraten?"); + $helper->addFieldText("zip", "Postleitzahl:"); + $helper->addInputTextField("zip", 10, 255); + + $helper->addFormSubGroup("chat", "Gebe hier deine Nicknames bzw. Nummern an:"); + if ($helper->ifChatEnabled("icq")) { + $helper->addFieldText("icq", "ICQ-Nummer:"); + $helper->addInputTextField("icq", 10, 15); + } + if ($helper->ifChatEnabled("jabber")) { + $helper->addFieldText("jabber", "Jabber:"); + $helper->addInputTextField("jabber", 10, 15); + } + if ($helper->ifChatEnabled("yahoo")) { + $helper->addFieldText("yahoo", "Yahoo!:"); + $helper->addInputTextField("yahoo", 10, 15); + } + if ($helper->ifChatEnabled("aol")) { + $helper->addFieldText("aol", "AOL-Screenname:"); + $helper->addInputTextField("aol", 10, 15); + } + if ($helper->ifChatEnabled("msn")) { + $helper->addFieldText("msn", "MSN:"); + $helper->addInputTextField("msn", 10, 15); + } + + if (!$helper->ifRegistrationRequiresEmailVerification()) { + $helper->addFormExtraNote(1, "Die Benachrichtigungen per sind im Loginbereich verfeinerbar, welche du genau haben willst."); + } // END - Extra note +} // END - ask profile data + +// Spielregeln abfragen +$helper->addFormGroup("rules", "Bitte lese dir die Spieleregeln gut durch und kreuze dann "Ja, ich akzeptiere die aktuellen Spielregeln" an."); +$helper->addInputCheckboxField("rules", false); + +// Abschliessender Hinweis und Abschluss des Formulars +$helper->addFormNote("Deine Daten werden nach den gültigen Datenschutzgesetzten gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link "Datenschutz"."); $helper->addFormTag(); $helper->flushContent(); ?> diff --git a/inc/classes/exceptions/template/class_FormClosedException.php b/inc/classes/exceptions/template/class_FormClosedException.php new file mode 100644 index 0000000..9390911 --- /dev/null +++ b/inc/classes/exceptions/template/class_FormClosedException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 . + */ +class FormClosedException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Could not add form element %s because form is closed.", + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_FormOpenedException.php b/inc/classes/exceptions/template/class_FormOpenedException.php new file mode 100644 index 0000000..e964c7c --- /dev/null +++ b/inc/classes/exceptions/template/class_FormOpenedException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 . + */ +class FormOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (BaseFrameworkSystem $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Form is not yet closed. Close it with method %s::addFormTag() and add no parameters.", + $class->__toString(), + $this->getLine(), + $class->__toString() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/exceptions/template/class_InvalidFormNameException.php b/inc/classes/exceptions/template/class_InvalidFormNameException.php new file mode 100644 index 0000000..85b5137 --- /dev/null +++ b/inc/classes/exceptions/template/class_InvalidFormNameException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 . + */ +class InvalidFormNameException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (BaseFrameworkSystem $class, $code) { + // Add a message around the missing class + $message = sprintf("[%s:%d] Form name not set.", + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index c1f216e..5e923ad 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -901,6 +901,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Output it ApplicationEntryPoint::app_die("Debug output:".$content); } + + /** + * Output a partial stub message for the given method name + * + * @param $methodName Name of the partially finished method + * @return void + */ + protected function partialStub ($methodName) { + // Debug instance is there? + if (!is_null($this->getDebugInstance())) { + // Output stub message + $this->getDebugInstance()->output(sprintf("[%s:] Partial stub!
\n", + $methodName + )); + } else { + // Trigger an error + trigger_error(sprintf("[%s:] Partial stub!", $methodName)); + } + } } // [EOF] diff --git a/inc/classes/main/helper/.htaccess b/inc/classes/main/helper/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/class_ b/inc/classes/main/helper/class_ new file mode 100644 index 0000000..dff09f7 --- /dev/null +++ b/inc/classes/main/helper/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 . + */ +class extends BaseTemplateHelper { + /** + * Private constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + } + + /** + * Creates the helper class + * + * @return $helperInstance A preparedf instance of this class + */ + public final static function createHelper () { + // Get new instance + $helperInstance = new Helper(); + + // Return the prepared instance + return $helperInstance; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/class_BaseTemplateHelper.php b/inc/classes/main/helper/class_BaseTemplateHelper.php new file mode 100644 index 0000000..8558386 --- /dev/null +++ b/inc/classes/main/helper/class_BaseTemplateHelper.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 . + */ +class BaseTemplateHelper extends BaseFrameworkSystem { + /** + * Template engine instance + */ + private $templateInstance = null; + + /** + * Rendered content created by the helper class + */ + private $content = ""; + + /** + * Private constructor + * + * @param $className Real name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Create unique ID number + $this->createUniqueID(); + + // Clean up a little + $this->removeNumberFormaters(); + $this->removeSystemArray(); + } + + /** + * Setter for template engine instances + * + * @param $templateInstance An instance of a template engine class + * @return void + */ + public final function setTemplateInstance (CompileableTemplate $templateInstance) { + $this->templateInstance = $templateInstance; + } + + /** + * Getter for template engine instances + * + * @return $templateInstance An instance of a template engine class + */ + public final function getTemplateInstance () { + return $this->templateInstance; + } + + /** + * Add content + * + * @param $newContent New content to add + * @return void + */ + public final function addContent ($newContent) { + $this->content .= (string) trim($newContent)."\r\n"; + } + + /** + * Getter for content + * + * @return $content The rendered content by this helper + */ + public final function getContent () { + return $this->content; + } +} + +// [EOF] +?> diff --git a/inc/classes/main/helper/web/.htaccess b/inc/classes/main/helper/web/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/inc/classes/main/helper/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/classes/main/helper/web/class_HtmlFormHelper.php b/inc/classes/main/helper/web/class_HtmlFormHelper.php new file mode 100644 index 0000000..281f4d4 --- /dev/null +++ b/inc/classes/main/helper/web/class_HtmlFormHelper.php @@ -0,0 +1,224 @@ + + * @version 0.0.0 + * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 . + */ +class HtmlFormHelper extends BaseTemplateHelper { + /** + * Wether the form tag is opened (keep at false or else your forms will + * never work!) + */ + private $formOpened = false; + + /** + * Name of the form + */ + private $formName = ""; + + /** + * Wether the group is opened or not + */ + private $groupOpened = false; + + /** + * Wether the sub group is opened or not + */ + private $subGroupOpened = false; + + // Class Constants + const EXCEPTION_FORM_NAME_INVALID = 0xb00; + const EXCEPTION_CLOSED_FORM = 0xb01; + const EXCEPTION_OPENED_FORM = 0xb02; + + /** + * Private constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription("HTML-Formularhilfsklasse"); + } + + /** + * Creates the helper class with the given template engine instance and form name + * + * @param $templateInstance An instance of a valid template engine + * @param $formName Name of the form + * @param $formId Value for "id" attribute (default: $formName) + * @return $helperInstance A preparedf instance of this class + */ + public final static function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = false) { + // Get new instance + $helperInstance = new HtmlFormHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Is the form id not set? + if ($formId === false) { + // Use form id from form name + $formId = $formName; + } + + // Create the form + $helperInstance->addFormTag($formName, $formId); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Add the form tag or close it an already opened form tag + * + * @param $formName Name of the form (default: false) + * @param $formId Id of the form (attribute "id"; default: false) + * @return void + * @throws InvalidFormNameException If the form name is invalid (=false) + */ + public function addFormTag ($formName = false, $formId = false) { + // When the form is not yet opened at least form name must be valid + if ((!$this->formOpened) && ($formName === false)) { + // Thrown an exception + throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID); + } + + // Close the form is default + $formContent = ""; + + // Check wether we shall open or close the form + if (!$this->formOpened) { + // Add HTML code + $formContent = sprintf("
getConfigInstance()->readConfig("form_action"), + $this->getConfigInstance()->readConfig("form_method"), + $this->getConfigInstance()->readConfig("form_target") + ); + + // Is the form id set? + if ($formId !== false) { + // Then add it as well + $formContent .= sprintf(" id=\"%s\"", + $formId + ); + } + + // Add close bracket + $formContent .= ">"; + + // Open the form and remeber the form name + $this->formOpened = true; + $this->formName = $formName; + } else { + // Add the hidden field required to identify safely this form + $this->addInputHiddenField("form", $this->formName); + + // @TODO Add some unique PIN here to bypass problems with some browser and/or extensions + // Simply close it + $this->formOpened = false; + } + + // Add it to the content + $this->addContent($formContent); + } + + /** + * Add an input tag to the form or throw an exception if it is not yet + * opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldSize Input size + * @param $fieldMaxLength Input max length + * @param $fieldValue Input default value (default: empty) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputTextField ($fieldName, $fieldSize, $fieldMaxLength, $fieldValue = "") { + // Is the form opened? + if (!$this->formOpened) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } + + // Generate the content + $inputContent = sprintf("", + $fieldName, $fieldName, $fieldSize, $fieldMaxLength, $fieldValue); + + // And add it + $this->addContent($inputContent); + } + + /** + * Flushs the content out (not yet secured against open forms, etc.!) or + * throw an exception if it is not yet closed + * + * @return void + * @throws FormOpenedException If the form is still open + */ + public function flushContent () { + // Is the form opened? + if ($this->formOpened) { + // Throw an exception + throw new FormOpenedException ($this, self::EXCEPTION_OPENED_FORM); + } + + // Send content to template engine + $this->getTemplateInstance()->assignVariable($this->formName, $this->getContent()); + } + + /** + * Add a form group or close an already opened and open a new one + * + * @param $groupName Name of the group + * @param $groupText Text including HTML to show above this group + * @return void + * @throws EmptyVariableException If $groupName is not set + */ + public function addFormGroup ($groupName, $groupText) { + // At least the group name should be set + if (empty($groupName)) { + // Throw exception here + throw new EmptyVariableException(array($this, 'groupName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } + + // Not fully finished! + $this->partialStub(__METHOD__); + + // Is this group opened? + if (!$this->groupOpened) { + // Switch the state + $this->groupOpened = true; + } else { + // Switch the state + $this->groupOpened = false; + + // All call it again + $this->addFormGroup($groupName, $groupText); + } + } +} + +// [EOF] +?> diff --git a/inc/classes/main/template/class_TemplateEngine.php b/inc/classes/main/template/class_TemplateEngine.php index f929b8a..a8e478b 100644 --- a/inc/classes/main/template/class_TemplateEngine.php +++ b/inc/classes/main/template/class_TemplateEngine.php @@ -611,15 +611,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) { // Initialize all missing variables foreach ($variableMatches[3] as $key=>$var) { - // Is the variable name valid? - // @TODO Find a better way than ignoring our instance variable $this - if (($variableMatches[1][$key] != $this->getConfigInstance()->readConfig("tpl_valid_var")) && ($variableMatches[1][$key] != "config") && ($variableMatches[1][$key] != "this")) { - // Invalid variable name - throw new InvalidTemplateVariableNameException(array($this, $this->getLastTemplate(), $variableMatches[1][$key], $this->getConfigInstance()), self::EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR); - } elseif ($variableMatches[1][$key] != "this") { - // Try to assign it, empty strings are being ignored - $this->assignTemplateVariable($variableMatches[1][$key], $var); - } + // Try to assign it, empty strings are being ignored + $this->assignTemplateVariable($variableMatches[1][$key], $var); } } } @@ -983,57 +976,65 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate unset($idx); unset($currVariable); - // Finalize the compilation of template variables - $this->finalizeVariableCompilation(); - - // Prepare the eval() command for comiling the template - $eval = sprintf("\$result = \"%s\";", - addslashes($this->getRawTemplateData()) - ); - - // This loop does remove the backslashes (\) in PHP parameters - // @TODO Make this some nicer... - while (strpos($eval, "finalizeVariableCompilation(); - // Get all from right of "getRawTemplateData()) + ); - // Is this a full PHP tag? - if (substr(strtolower($evalRight), 0, 3) == "php") { - // Remove "php" string from full PHP tag - $evalRight = substr($evalRight, 3); - } + // This loop does remove the backslashes (\) in PHP parameters + // @TODO Make this some nicer... + while (strpos($eval, ""))); + $evalMiddle = stripslashes($evalMiddle); + + // Remove the middle part from right one + $evalRight = substr($evalRight, (strpos($evalRight, "?>") + 2)); + + // And put all together + $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight); + } // END - while + + // Prepare PHP code for eval() command + $eval = str_replace( + "<%php", "\";", + str_replace( + "%>", "\$result .= \"", $eval + ) + ); - // Cut middle part out and remove escapes - $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, "?>"))); - $evalMiddle = stripslashes($evalMiddle); + // Debug message + if ((defined('DEBUG_EVAL')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command:
%s

\n", + $this->__toString(), + htmlentities($eval) + )); - // Remove the middle part from right one - $evalRight = substr($evalRight, (strpos($evalRight, "?>") + 2)); + // Run the constructed command. This will "compile" all variables in + eval($eval); - // And put all together - $eval = sprintf("%s<%%php %s %%>%s", $evalLeft, $evalMiddle, $evalRight); + // Set raw template data + $this->setRawTemplateData($result); + $cnt++; } - // Prepare PHP code for eval() command - $eval = str_replace( - "<%php", "\";", - str_replace( - "%>", "\$result = \"", $eval - ) - ); - - // Debug message - if ((defined('DEBUG_EVAL')) && (is_object($this->getDebugInstance()))) $this->getDebugInstance()->output(sprintf("[%s:] Constructed PHP command:
%s

\n", - $this->__toString(), - htmlentities($eval) - )); - - // Run the constructed command. This will "compile" all variables in - eval($eval); - // Set the new content $this->setCompiledData($result); } @@ -1043,9 +1044,9 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate * * @return void * @throws UnexpectedTemplateTypeException If the template type is - * not "code" + * not "code" * @throws InvalidArrayCountException If an unexpected array - * count has been found + * count has been found */ public final function compileTemplate () { // We will only work with template type "code" from configuration diff --git a/inc/config.php b/inc/config.php index 9b307c0..536a89d 100644 --- a/inc/config.php +++ b/inc/config.php @@ -144,5 +144,14 @@ $cfg->setConfigEntry("verbose_level", 0); // CFG: COMMAND-PARAMETER $cfg->setConfigEntry("command_parameter", "page"); +// CFG: FORM-ACTION +$cfg->setConfigEntry("form_action", "index.php?app={?app_short_name?}&{?command_parameter?}=do_form"); + +// CFG: FORM-METHOD +$cfg->setConfigEntry("form_method", "POST"); + +// CFG: FORM-TARGET +$cfg->setConfigEntry("form_target", "_self"); + // [EOF] ?>