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
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
<?php
+// Get helper instance for HTML forms. This will add the opening form-tag to
+// the helper's render cache which is simply a small variable in the class
+// BaseTemplateHelper.
$helper = HtmlFormHelper::createHtmlFormHelper($this, "register_form");
- $helper->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 (<span id=\"add_note\">*1</span>) 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();
?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when the form is still closed but input field shall be
+ * added to it. This should normally not happen, but well, who knows?
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 <u>%s</u> because form is closed.",
+ $classArray[0]->__toString(),
+ $this->getLine(),
+ $classArray[1]
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when the form is still opened but we e.g. shall flush
+ * the content.
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 <u>%s::addFormTag()</u> and add no parameters.",
+ $class->__toString(),
+ $this->getLine(),
+ $class->__toString()
+ );
+
+ // Call parent constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An exception thrown when the form name is invalid (set to false)
+ *
+ * @author Roland Haeder <webmaster@mxchange.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
// Output it
ApplicationEntryPoint::app_die("<strong>Debug output:</strong>".$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!<br />\n",
+ $methodName
+ ));
+ } else {
+ // Trigger an error
+ trigger_error(sprintf("[%s:] Partial stub!", $methodName));
+ }
+ }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ *
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
--- /dev/null
+<?php
+/**
+ * A generic helper class with generic methods
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A helper for constructing HTML forms
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 = "</form>";
+
+ // Check wether we shall open or close the form
+ if (!$this->formOpened) {
+ // Add HTML code
+ $formContent = sprintf("<form name=\"%s\" action=\"%s\" method=\"%s\" target=\"%s\"",
+ $formName,
+ $this->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("<input type=\"text\" id=\"%s\" name=\"%s\" size=\"%d\" maxlength=\"%d\" value=\"%s\" />",
+ $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]
+?>
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);
}
}
}
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, "<?") !== false) {
- // Get left part before "<?"
- $evalLeft = substr($eval, 0, strpos($eval, "<?"));
+ // Run the compilation twice to get content from helper classes in
+ $cnt = 0;
+ while ($cnt < 2) {
+ // Finalize the compilation of template variables
+ $this->finalizeVariableCompilation();
- // Get all from right of "<?"
- $evalRight = substr($eval, (strpos($eval, "<?") + 2));
+ // Prepare the eval() command for comiling the template
+ $eval = sprintf("\$result = \"%s\";",
+ addslashes($this->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, "<?") !== false) {
+ // Get left part before "<?"
+ $evalLeft = substr($eval, 0, strpos($eval, "<?"));
+
+ // Get all from right of "<?"
+ $evalRight = substr($eval, (strpos($eval, "<?") + 2));
+
+ // Is this a full PHP tag?
+ if (substr(strtolower($evalRight), 0, 3) == "php") {
+ // Remove "php" string from full PHP tag
+ $evalRight = substr($evalRight, 3);
+ } // END - if
+
+ // Cut middle part out and remove escapes
+ $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, "?>")));
+ $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: <pre><em>%s</em></pre><br />\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: <pre><em>%s</em></pre><br />\n",
- $this->__toString(),
- htmlentities($eval)
- ));
-
- // Run the constructed command. This will "compile" all variables in
- eval($eval);
-
// Set the new content
$this->setCompiledData($result);
}
*
* @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
// 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]
?>