X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fhelper%2Fcaptcha%2Fweb%2Fclass_GraphicalCodeCaptcha.php;fp=inc%2Fclasses%2Fmain%2Fhelper%2Fcaptcha%2Fweb%2Fclass_GraphicalCodeCaptcha.php;h=3e57d241e65dddf8c1fba3773db2b3f679f9ad61;hb=84db68e59426190fdc5b8cd4b4525be88699f570;hp=64f5788575939bdf584bfb48fc74a0c21722f1f0;hpb=cc75d90baeef97069f2285757b9fbb610e9dfcc5;p=shipsimu.git diff --git a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php index 64f5788..3e57d24 100644 --- a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php +++ b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php @@ -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()); } }