]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/helper/web/class_WebFormHelper.php
Graphical code CAPTCHA partly finished, crypto class supports encryption/decryption...
[shipsimu.git] / inc / classes / main / helper / web / class_WebFormHelper.php
index 32d635a698f4a30add1dd2703b9c5293268fa9a1..7ba0343549b88189ed76b414f3526b8353a61cc9 100644 (file)
@@ -218,7 +218,7 @@ class WebFormHelper extends BaseHelper {
         */
        public function addInputTextFieldWithDefault ($fieldName) {
                // Get the value from instance
-               $fieldValue = call_user_func_array(array($this->valueInstance, "getField"), array($fieldName));
+               $fieldValue = $this->getField($fieldName);
                //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."<br />\n";
 
                // Add the text field
@@ -286,7 +286,7 @@ class WebFormHelper extends BaseHelper {
         */
        public function addInputHiddenFieldWithDefault ($fieldName) {
                // Get the value from instance
-               $fieldValue = call_user_func_array(array($this->valueInstance, "getField"), array($fieldName));
+               $fieldValue = $this->getField($fieldName);
                //* DEBUG: */ echo __METHOD__.":".$fieldName."=".$fieldValue."<br />\n";
 
                // Add the text field
@@ -746,11 +746,33 @@ class WebFormHelper extends BaseHelper {
         */
        public function getField ($fieldName) {
                // Get the field value
-               $fieldValue = call_user_func_array(array($this->valueInstance, "getField"), array($fieldName));
+               $fieldValue = call_user_func_array(array($this->valueInstance, 'getField'), array($fieldName));
 
                // Return it
                return $fieldValue;
        }
+
+       /**
+        * Adds a pre-configured CAPTCHA
+        *
+        * @return      void
+        */
+       public function addCaptcha () {
+               // Get last executed pre filter
+               $extraInstance = Registry::getRegistry()->getInstance('extra');
+
+               // Get a configured instance
+               $captchaInstance = ObjectFactory::createObjectByConfiguredName("{$this->formName}_captcha", array($this->getTemplateInstance(), $extraInstance));
+
+               // Initiate the CAPTCHA
+               $captchaInstance->initiateCaptcha();
+
+               // Render the CAPTCHA code
+               $captchaInstance->renderCode();
+
+               // Get the content and add it to the helper
+               $this->addContent($captchaInstance->getContent());
+       }
 }
 
 // [EOF]