public function render($type = null, $refresh = false) { //first select the type if (!$this->data) { if (!$this->make($type)) { return false; } } if ($this->data['type'] == 'recaptcha' || $this->data['type'] == 'nocaptcha') { return $this->data['question']['content']; } //create a theme object of specified theme name for the given captcha type $themeName = $this->data['theme']; if ($themeName && class_exists($themeName)) { $themeObj = new $themeName($this->data['themeOptions']); } else { $themeObj = new Themes\DefaultTheme($this->data['themeOptions']); } //now render the captcha by calling the render function of the theme if ($refresh) { return $themeObj->refresh($this->data); } return $themeObj->render($this->data); }
public function render($type = null, $refresh = false) { //first select the type if (count($this->enabledTypeOptions) == 0) { return false; } if (!$type) { //no type specified, use random captcha from enabled types $type = array_rand($this->enabledTypeOptions); } elseif (!isset($this->enabledTypeOptions[$type])) { //selected type of captcha does not exist or is not enabled return false; } //create question data for the selected type $data = $this->data($type); if ($type == 'recaptcha' || $type == 'nocaptcha') { return $data['question']['content']; } //create a theme object of specified theme name for the given captcha type $themeName = $data['theme']; if ($themeName && class_exists($themeName)) { $themeObj = new $themeName($data['themeOptions']); } else { $themeObj = new Themes\DefaultTheme($data['themeOptions']); } //now render the captcha by calling the render function of the theme if ($refresh) { return $themeObj->refresh($data); } return $themeObj->render($data); }