(v3.2) このイベントは、プラグインがコメント、メンバー間メール、認証フォームのいずれかのフォーム内に追加フィールドを挿入するときに使います。フォーム処理の際に発生する ValidateForm イベントに対応します。
NP_Captcha.php (自動投稿スクリプトに読みとられにくいランダム文字列画像を表示、正しい文字列の入力がない場合は、投稿の受入処理を中断させるプラグイン。)
function event_FormExtra(&$data) { switch ($data['type']) { case 'commentform-notloggedin': // anonymous comments case 'membermailform-notloggedin': // anonymous message to site member case 'activation': // activation or re-activation of member account break; default: return; } // initialize on first call if (!$this->inited) $this->init_captcha(); // don't do anything when no GD libraries are available if (!$this->isAvailable()) return; // create captcha key. This key is required to // // 1. create the captcha image // 2. check the validity of the entered solution $key = $this->generateKey(); $aVars = array( 'imgHtml' => $this->generateImgHtml($key), 'key' => htmlspecialchars($key) ); switch ($data['type']) { case 'activation': echo TEMPLATE::fill($this->getOption('ActivationHtml'), $aVars); break; case 'commentform-notloggedin': echo TEMPLATE::fill($this->getOption('CommentFormHtml'), $aVars); break; case 'membermailform-notloggedin': echo TEMPLATE::fill($this->getOption('MemberMailHtml'), $aVars); break; } }
コメント受付フォームに追加echoしているフォームのテンプレートはデフォルトで次のように定義されている。
$commentFormHtml =
'<br />' . "\n"
.'<label for="nucleus_cf_verif"><%imgHtml%></label>' . "\n"
.'<br />' . "\n"
.'<label for="nucleus_cf_verif">Enter the string of characters appearing in the picture:</label><input name="ver_sol" size="6" maxlength="6" value="" class="formfield" id="nucleus_cf_verif" />' . "\n"
.'<input name="ver_key" type="hidden" value="<%key%>" />';