]> git.mxchange.org Git - shipsimu.git/commitdiff
Account status page partly implemented, backtrace now without own saveBacktrace(...
authorRoland Häder <roland@mxchange.org>
Sat, 21 Jun 2008 13:58:21 +0000 (13:58 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 21 Jun 2008 13:58:21 +0000 (13:58 +0000)
12 files changed:
.gitattributes
application/ship-simu/config.php
application/ship-simu/templates/de/code/login_form.ctp
application/ship-simu/templates/de/code/login_profile.ctp
application/ship-simu/templates/de/code/login_status_problem.ctp [new file with mode: 0644]
application/ship-simu/templates/de/code/register_form.ctp
inc/classes/exceptions/class_FrameworkException.php
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/debug/class_DebugWebOutput.php
inc/classes/main/helper/web/class_WebFormHelper.php
inc/classes/main/template/class_TemplateEngine.php
inc/classes/middleware/debug/class_DebugMiddleware.php

index 090307aaa528767cc9e2ca85cacd879221b55e5e..dba150ed88679440baebc56d92bb006ed4856355 100644 (file)
@@ -142,6 +142,7 @@ application/ship-simu/templates/de/code/login_form.ctp -text
 application/ship-simu/templates/de/code/login_logout.ctp -text
 application/ship-simu/templates/de/code/login_main.ctp -text
 application/ship-simu/templates/de/code/login_profile.ctp -text
+application/ship-simu/templates/de/code/login_status_problem.ctp -text
 application/ship-simu/templates/de/code/login_welcome.ctp -text
 application/ship-simu/templates/de/code/logout_done.ctp -text
 application/ship-simu/templates/de/code/register_form.ctp -text
index 26e173d6b65441b91f80bb0f8e6f3f5d15e64dd2..b373a1b109fe350958f1a380a29c8b4a3b3a9d29 100644 (file)
@@ -101,7 +101,7 @@ $cfg->setConfigEntry('login_failed_url', "index.php?app=ship-simu&page=login_fai
 $cfg->setConfigEntry('logout_done_url', "index.php?app=ship-simu&page=logout_done");
 
 // CFG: LOGIN-USER-STATUS-URL
-$cfg->setConfigEntry('login_user_status_url', "index.php?app=ship-simu&page=login_area&action=login_status_problem");
+$cfg->setConfigEntry('login_user_status_url', "index.php?app=ship-simu&page=login_area&action=status_problem");
 
 // CFG: LOGIN-DEFAULT-ACTION
 $cfg->setConfigEntry('login_default_action', "welcome");
index d890f183126d92e176cdb6fda7ca381a1d00f35c..31688ccc3d0bc22abb0543fdf3e4acf1637c9df5 100644 (file)
@@ -40,7 +40,6 @@ if ($helper->ifLoginIsEnabled()) {
 }
 
 // Formular schliessen
-$helper->addFormTag();
 $helper->flushContent();
 
 // Ist Gastlogin erlaubt?
@@ -51,7 +50,6 @@ if ($helper->ifGuestLoginAllowed()) {
        $helper->addInputHiddenField("pass", $this->getConfigInstance()->readConfig('guest_login_password'));
        $helper->addFormGroup("buttons", "Gastlogins sind in der Funkionsweise eingeschr&auml;nkt. Mehr dazu unter &quot;Gastlogin&quot;.");
        $helper->addInputSubmitButton("Als Gast einloggen");
-       $helper->addFormTag();
        $helper->flushContent();
 }
 
index c74c74915ff461ea14963abc7423b451a2df7c44..f79bbaa5ee85b20fc6dd326bc8e0f9b2dfd12596 100644 (file)
@@ -106,11 +106,10 @@ $helper->addFormGroup("buttons", "Sind alle Daten nun korrekt eingegeben? Dann s
 $helper->addInputResetButton("Alles nochmal eingeben");
 $helper->addInputSubmitButton("Accountdaten aktualisieren");
 $helper->addFormNote("Deine Daten werden nach den g&uuml;ltigen Datenschutzgesetzten gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link &quot;Datenschutz&quot;.");
-$helper->addFormTag();
 $helper->flushContent();
 ?>
 <div id="content_header">
-       Ihre Profildaten bearbeiten
+       Deine Profildaten bearbeiten
 </div>
 
 <div id="profile_box">
diff --git a/application/ship-simu/templates/de/code/login_status_problem.ctp b/application/ship-simu/templates/de/code/login_status_problem.ctp
new file mode 100644 (file)
index 0000000..9738a23
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+// 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, "resend_link");
+
+// Pre-fetch field data with a given registry key
+$helper->prefetchFieldValues('user');
+
+// Add submit button or notice
+if ($helper->ifUserAccountUnconfirmed()) {
+       $helper->addInputSubmitButton("Best&auml;tigungslink erneut aussenden");
+} elseif ($helper->ifUserAccountLocked()) {
+       $helper->addFormNote("Dein Account wurde gesperrt! Grund der Sperre:
+               <span id=\"lock_reason\">".$helper->getField('lock_reason')."</span>
+               Bitte melde dich beim Support, damit dieser dir weiterhelfen kann."
+       );
+} elseif ($helper->ifUserAccountGuest()) {
+       $helper->addFormNote("G&auml;steaccounts sind in der Funktionalit&auml;t
+               leicht eingeschr&auml;nkt. Bitte melde dich an, damit du ein
+               vollwertiges Account bekommst."
+       );
+}
+
+// Flush content and automatically close the form
+$helper->flushContent();
+
+if ($helper->ifUserAccountUnconfirmed()) {
+       // Build the form for confirmation
+       $helper = WebFormHelper::createWebFormHelper($this, "confirm_code");
+
+       // Add code box
+       $helper->addFormGroup("code", "Bitte gebe hier den Best&auml;tigungscode aus der Willkommensemail ein. Solltest du diese nicht erhalten haben, kannst du dir diesen jetzt zusenden lassen.");
+       $helper->addFieldText("code", "Best&auml;tigungscode aus der Mail:");
+       $helper->addInputTextField("code");
+
+       // Add submit button
+       $helper->addFormGroup("submit", "Bitte einmal abschicken und das Ergebnis abwarten!");
+       $helper->addInputResetButton("Nochmal eingeben");
+       $helper->addInputSubmitButton("Best&auml;tigungscode zusenden");
+
+       // Flush content and automatically close the form
+       $helper->flushContent();
+} // END - if
+?>
+<div id="content_header">
+       Problem mit deinem Account gefunden:
+</div>
+
+<div id="status_box">
+       Du bist m&ouml;glicherweise f&uuml;r deine ausgew&auml;hlte Aktion nicht
+       berechtigt oder du hast noch deine Email-Adresse nicht best&auml;tigt. Du
+       kannst dir nun den Best&auml;tigungslink erneut aussenden lassen, oder den
+       Best&auml;tigungscode unten eingeben.
+
+       <div id="resend_link_box">
+               {?resend_link?}
+       </div>
+
+       <div id="confirm_code_box">
+               {?confirm_code?}
+       </div>
+</div>
index 9f427c23734fa22ee5734a58a94076afb9abaf8b..a2221fa30a8a4a05ef93fee8b3c4e6310ddd3825 100644 (file)
@@ -97,7 +97,6 @@ $helper->addFormGroup("buttons", "Wenn du alle ben&ouml;tigten Felder korrekt au
 $helper->addInputResetButton("Alles nochmal eingeben");
 $helper->addInputSubmitButton("Anmeldung zum Spiel abschliessen");
 $helper->addFormNote("Deine Daten werden nach den g&uuml;ltigen Datenschutzgesetzten gespeichert und werden nicht an Dritte weitergegeben. Weiteres dazu siehe Link &quot;Datenschutz&quot;.");
-$helper->addFormTag();
 $helper->flushContent();
 ?>
 <div id="content_header">
index e74dd5a442e0d2593db00cf463fd2a7eec0fef99..34e48023f10574ef46ed46bae26509f22e941384 100644 (file)
@@ -54,7 +54,14 @@ abstract class FrameworkException extends ReflectionException {
         * @return      void
         */
        private final function saveBackTrace () {
+               // Get full backtrace
                $this->backTrace = debug_backtrace();
+
+               // Remove this call
+               $dummy = array_shift($this->backTrace);
+
+               // resort the array
+               ksort($this->backTrace);
        }
 
        /**
index a828dc7deee1be148fca3f1c390309cf2153d06a..48d9e3a0eb405c0de8d70e00b42799270ac5e1ca 100644 (file)
@@ -33,6 +33,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        private static $langInstance = null;
 
+       /**
+        * Debug instance
+        */
+       private static $debugInstance = null;
+
        /**
         * Instance of a request class
         */
@@ -307,6 +312,44 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                }
        }
 
+       /**
+        * Setter for search instance
+        *
+        * @param       $searchInstance         Searchable criteria instance
+        * @return      void
+        */
+       public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
+               $this->searchInstance = $searchInstance;
+       }
+
+       /**
+        * Getter for search instance
+        *
+        * @return      $searchInstance         Searchable criteria instance
+        */
+       public final function getSearchInstance () {
+               return $this->searchInstance;
+       }
+
+       /**
+        * Setter for resolver instance
+        *
+        * @param       $resolverInstance               Instance of a command resolver class
+        * @return      void
+        */
+       public final function setResolverInstance (Resolver $resolverInstance) {
+               $this->resolverInstance = $resolverInstance;
+       }
+
+       /**
+        * Getter for resolver instance
+        *
+        * @return      $resolverInstance               Instance of a command resolver class
+        */
+       public final function getResolverInstance () {
+               return $this->resolverInstance;
+       }
+
        /**
         * Setter for language instance
         *
@@ -321,29 +364,30 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        /**
         * Getter for configuration instance
         *
-        * @return      $cfhInstance - Configuration instance
+        * @return      $cfgInstance    Configuration instance
         */
        protected final function getConfigInstance () {
-               return Registry::getRegistry()->getInstance('config');
+               $cfgInstance = Registry::getRegistry()->getInstance('config');
+               return $cfgInstance;
        }
 
        /**
         * Setter for debug instance
         *
-        * @param               $debugInstance  The instance for debug output class
+        * @param       $debugInstance  The instance for debug output class
         * @return      void
         */
        public final function setDebugInstance (DebugMiddleware $debugInstance) {
-               Registry::getRegistry()->addInstance('debug', $debugInstance);
+               self::$debugInstance = $debugInstance;
        }
 
        /**
         * Getter for debug instance
         *
-        * @return      $debug - Instance to class DebugConsoleOutput or DebugWebOutput
+        * @return      $debugInstance  Instance to class DebugConsoleOutput or DebugWebOutput
         */
        public final function getDebugInstance () {
-               return Registry::getRegistry()->getInstance('debug');
+               return self::$debugInstance;
        }
 
        /**
@@ -941,29 +985,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                }
        }
 
-       /**
-        * Converts e.g. a command from URL to a valid class by keeping out bad characters
-        *
-        * @param       $str            The string, what ever it is needs to be converted
-        * @return      $className      Generated class name
-        */
-       public function convertToClassName ($str) {
-               // Init class name
-               $className = "";
-
-               // Convert all dashes in underscores
-               $str = str_replace("-", "_", $str);
-
-               // Now use that underscores to get classname parts for hungarian style
-               foreach (explode("_", $str) as $strPart) {
-                       // Make the class name part lower case and first upper case
-                       $className .= ucfirst(strtolower($strPart));
-               } // END - foreach
-
-               // Return class name
-               return $className;
-       }
-
        /**
         * Outputs a debug backtrace and stops further script execution
         *
@@ -978,41 +999,88 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Setter for search instance
+        * Outputs a debug message wether to debug instance (should be set!) or dies with or pints the message
         *
-        * @param       $searchInstance         Searchable criteria instance
+        * @param       $message        Message we shall send out...
+        * @param       $doPrint        Wether we shall print or die here which last is the default
         * @return      void
         */
-       public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
-               $this->searchInstance = $searchInstance;
-       }
+       public function debugOutput ($message, $doPrint = false) {
+               // Get debug instance
+               $debugInstance = $this->getDebugInstance();
 
-       /**
-        * Getter for search instance
-        *
-        * @return      $searchInstance         Searchable criteria instance
-        */
-       public final function getSearchInstance () {
-               return $this->searchInstance;
+               // Is the debug instance there?
+               if (is_object($debugInstance)) {
+                       // Use debug output handler
+                       $debugInstance->output($message);
+                       if (!$doPrint) die(); // Die here if not printed
+               } else {
+                       // Put directly out
+                       // DO NOT REWRITE THIS TO app_die() !!!
+                       if ($doPrint) {
+                               print($message);
+                       } else {
+                               die($message);
+                       }
+               }
        }
 
        /**
-        * Setter for resolver instance
+        * Converts e.g. a command from URL to a valid class by keeping out bad characters
         *
-        * @param       $resolverInstance               Instance of a command resolver class
-        * @return      void
+        * @param       $str            The string, what ever it is needs to be converted
+        * @return      $className      Generated class name
         */
-       public final function setResolverInstance (Resolver $resolverInstance) {
-               $this->resolverInstance = $resolverInstance;
+       public function convertToClassName ($str) {
+               // Init class name
+               $className = "";
+
+               // Convert all dashes in underscores
+               $str = str_replace("-", "_", $str);
+
+               // Now use that underscores to get classname parts for hungarian style
+               foreach (explode("_", $str) as $strPart) {
+                       // Make the class name part lower case and first upper case
+                       $className .= ucfirst(strtolower($strPart));
+               } // END - foreach
+
+               // Return class name
+               return $className;
        }
 
        /**
-        * Getter for resolver instance
+        * Marks up the code by adding e.g. line numbers
         *
-        * @return      $resolverInstance               Instance of a command resolver class
-        */
-       public final function getResolverInstance () {
-               return $this->resolverInstance;
+        * @param       $phpCode                Unmarked PHP code
+        * @return      $markedCode             Marked PHP code
+        */
+       public function markupCode ($phpCode) {
+               // Get last error
+               $errorArray = error_get_last();
+
+               // Init the code with error message
+               $markedCode = "";
+               if (is_array($errorArray)) {
+                       // Get error infos
+                       $markedCode = sprintf("<div id=\"error_header\">File: <span id=\"error_data\">%s</span>, Line: <span id=\"error_data\">%s</span>, Message: <span id=\"error_data\">%s</span>, Type: <span id=\"error_data\">%s</span></div>",
+                               basename($errorArray['file']),
+                               $errorArray['line'],
+                               $errorArray['message'],
+                               $errorArray['type']
+                       );
+               } // END - if
+
+               // Add line number to the code
+               foreach (explode("\n", $phpCode) as $lineNo=>$code) {
+                       // Add line numbers
+                       $markedCode .= sprintf("<span id=\"code_line\">%s</span>: %s\n",
+                               ($lineNo+1),
+                               htmlentities($code, ENT_QUOTES)
+                       );
+               } // END - foreach
+
+               // Return the code
+               return $markedCode;
        }
 }
 
index 81dd64dc9a21fec6ce1fe77282ac9bc7cc6e359d..48c9aade9deee131ad4bb1aca0b42b005c96a93b 100644 (file)
@@ -58,7 +58,7 @@ class DebugWebOutput extends BaseFrameworkSystem implements Debugger, OutputStre
         * @return      void
         */
        public final function outputStream ($output) {
-               trigger_error($output);
+               print($output);
        }
 
        /**
index 1369fe4595cbc3b3c33633d551df363f64088986..645740938148c1c736e49b81adf3c82210961829 100644 (file)
@@ -200,7 +200,7 @@ class WebFormHelper extends BaseHelper {
                } // END - if
 
                // Generate the content
-               $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+               $inputContent = sprintf("<input type=\"text\" class=\"textfield\" id=\"%s_field\" name=\"%s\" value=\"%s\" />",
                        $fieldName,
                        $fieldName,
                        $fieldValue
@@ -242,7 +242,7 @@ class WebFormHelper extends BaseHelper {
                } // END - if
 
                // Generate the content
-               $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s\" name=\"%s\" value=\"%s\" />",
+               $inputContent = sprintf("<input type=\"password\" class=\"password\" id=\"%s_field\" name=\"%s\" value=\"%s\" />",
                        $fieldName,
                        $fieldName,
                        $fieldValue
@@ -299,7 +299,7 @@ class WebFormHelper extends BaseHelper {
                if ($fieldChecked === false) $checked = " ";
 
                // Generate the content
-               $inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox\" id=\"%s\" value=\"1\"%s/>",
+               $inputContent = sprintf("<input type=\"checkbox\" name=\"%s\" class=\"checkbox\" id=\"%s_field\" value=\"1\"%s/>",
                        $fieldName,
                        $fieldName,
                        $checked
@@ -675,9 +675,39 @@ class WebFormHelper extends BaseHelper {
                return $emailChange;
        }
 
+       /**
+        * Checks wether the user account is unconfirmed
+        *
+        * @return      $isUnconfirmed  Wether the user account is unconfirmed
+        */
+       public function ifUserAccountUnconfirmed () {
+               $isUnconfirmed = ($this->getField('user_status') === $this->getConfigInstance()->readConfig('user_status_unconfirmed'));
+               return $isUnconfirmed;
+       }
+
+       /**
+        * Checks wether the user account is locked
+        *
+        * @return      $isUnconfirmed  Wether the user account is locked
+        */
+       public function ifUserAccountLocked () {
+               $isUnconfirmed = ($this->getField('user_status') === $this->getConfigInstance()->readConfig('user_status_locked'));
+               return $isUnconfirmed;
+       }
+
+       /**
+        * Checks wether the user account is a guest
+        *
+        * @return      $isUnconfirmed  Wether the user account is a guest
+        */
+       public function ifUserAccountGuest () {
+               $isUnconfirmed = ($this->getField('user_status') === $this->getConfigInstance()->readConfig('user_status_guest'));
+               return $isUnconfirmed;
+       }
+
        /**
         * Flushs the content out (not yet secured against open forms, etc.!) or
-        * throw an exception if it is not yet closed
+        * close the form automatically
         *
         * @return      void
         * @throws      FormOpenedException             If the form is still open
@@ -685,8 +715,8 @@ class WebFormHelper extends BaseHelper {
        public function flushContent () {
                // Is the form still open?
                if ($this->formOpened === true) {
-                       // Throw an exception
-                       throw new FormOpenedException ($this, self::EXCEPTION_OPENED_FORM);
+                       // Close the form automatically
+                       $this->addFormTag();
                } // END - if
 
                // Send content to template engine
index 2a828c0f1d62c6c3efc890e8d46a1d5a8bb47c2f..a9b45743e2a25578dcc671d7ea1a79a4e2bbe7ff 100644 (file)
@@ -1022,14 +1022,23 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                        $eval = str_replace(
                                "<%php", "\";",
                                str_replace(
-                                       "%>", "\$result .= \"", $eval
+                                       "%>", "\n\$result .= \"", $eval
                                )
                        );
 
                        // Did something change?
                        if (strlen($eval) != $eval) {
                                // Run the constructed command. This will "compile" all variables in
-                               eval($eval);
+                               @eval($eval);
+                       } // END - if
+
+                       // Goes something wrong?
+                       if (!isset($result)) {
+                               // Output eval command
+                               $this->debugOutput(sprintf("Failed eval() code: <pre>%s</pre>", $this->markupCode($eval, true)), true);
+
+                               // Output backtrace here
+                               $this->debugBacktrace();
                        } // END - if
 
                        // Set raw template data
@@ -1118,15 +1127,8 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                                $this->getTemplateType()
                        );
 
-                       if ((is_object($this->getDebugInstance())) && (method_exists($this->getDebugInstance(), 'output'))) {
-                               // Use debug output handler
-                               $this->getDebugInstance()->output($msg);
-                               die();
-                       } else {
-                               // Put directly out
-                               // DO NOT REWRITE THIS TO app_die() !!!
-                               die($msg);
-                       }
+                       // Write the problem to the world...
+                       $this->debugOutput($msg);
                        break;
                }
        }
index 1f5e6e0e64ca44ab7e00a486b7820f136f88320e..ed1f8d03d636f4500e957c4d42a3a8328ac22c22 100644 (file)
@@ -117,7 +117,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
                } elseif (!is_object($this->outputInstance)) {
                        // The debug output instance is not an object
                        throw new NoObjectException($this->ouputInstance, self::EXCEPTION_IS_NO_OBJECT);
-               } elseif (!method_exists($this->outputInstance, 'outputStream')) {
+               } elseif (!$this->outputInstance instanceof Debugger) {
                        // The required method outputStream() is missing
                        throw new MissingMethodException(array($this->outputInstance, 'outputStream'), self::EXCEPTION_MISSING_METHOD);
                }
@@ -126,7 +126,7 @@ class DebugMiddleware extends BaseMiddleware implements Registerable {
                if (empty($outStream)) {
                        // Initialization phase
                        return;
-               }
+               } // END - if
 
                // Use the output instance
                $this->outputInstance->outputStream($outStream);