rtgx

Použitie modulu captcha vo vlastnom FE module

Premenná:

	var $captchaStr = -1;

Načítanie kódu zo SESSION:

	// Get captcha value from session
if( t3lib_extMgm::isLoaded( 'captcha' ) ) {
session_start();
$this->captchaStr = $_SESSION['tx_captcha_string'];
$_SESSION['tx_captcha_string'] = '';
}

Spracovanie kódu captcha (v premennej captchaResponse je kód opísaný užívateľom obrázku captcha, POST premenná formulára):

		// captcha
if( $this->captchaStr === -1 || ( $this->captchaStr && $this->GPvars['captchaResponse'] === $this->captchaStr ) ) {
; // OK
}
else {
$item['errors']['captcha'] = 'error';
}

Rendering HTML kódu podša šablóny pre captcha:

	// Capchta code
if( t3lib_extMgm::isLoaded( 'captcha' ) ) {
$marks['###CAPTCHA_IMAGE###'] = '<img src="'.$this->baseUrl.t3lib_extMgm::siteRelPath( 'captcha' ).'captcha/captcha.php" alt="Code" />';
$marks['###CAPTCHA_TITLE###'] = $this->pi_getLL( 'captcha_label' );
$marks['###CAPTCHA_ERROR###'] = $fields['errors']['captcha'] === 'error' ? str_replace( '|', $this->pi_getLL( 'captcha_error' ), $this->conf['errorWrap'] ) : '';
}

Nastavenie Typoscriptu pre wrapovanie chybového hlásenia:

plugin.tx_extname_pi1 {
errorWrap = <p class="error">|</p>
}

Samozrejme nesmieme zabudnúť pridať do jazykového súboru preklady pre captcha_label a captcha_error.

 
Žiadne dokumenty ani odkazy k tejto stránke.