Пример #1
0
 /**
  * Insert the captcha prompt into the edit form.
  */
 function getForm()
 {
     $info = $this->pickImage();
     if (!$info) {
         throw new MWException("Ran out of captcha images");
     }
     // Generate a random key for use of this captcha image in this session.
     // This is needed so multiple edits in separate tabs or windows can
     // go through without extra pain.
     $index = $this->storeCaptcha($info);
     wfDebug("Captcha id {$index} using hash {$info['hash']}, salt {$info['salt']}.\n");
     $title = SpecialPage::getTitleFor('Captcha', 'image');
     return "<p>" . Html::element('img', array('src' => $title->getLocalUrl('wpCaptchaId=' . urlencode($index)), 'width' => $info['width'], 'height' => $info['height'], 'alt' => '')) . "</p>\n" . Html::element('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index)) . '<p>' . Html::element('label', array('for' => 'wpCaptchaWord'), parent::getMessage('label') . wfMsg('colon-separator')) . Html::element('input', array('name' => 'wpCaptchaWord', 'id' => 'wpCaptchaWord', 'type' => 'text', 'autocorrect' => 'off', 'autocapitalize' => 'off', 'required' => 'required', 'tabindex' => 1)) . "</p>\n";
 }
 /**
  * Insert the captcha prompt into the edit form.
  */
 function getForm()
 {
     global $wgOut, $wgExtensionAssetsPath, $wgEnableAPI;
     // Uses addModuleStyles so it is loaded when JS is disabled.
     $wgOut->addModuleStyles('ext.confirmEdit.fancyCaptcha.styles');
     $title = SpecialPage::getTitleFor('Captcha', 'image');
     $index = $this->getCaptchaIndex();
     if ($wgEnableAPI) {
         // Loaded only if JS is enabled
         $wgOut->addModules('ext.confirmEdit.fancyCaptcha');
         $captchaReload = Html::element('small', array('class' => 'confirmedit-captcha-reload fancycaptcha-reload'), wfMessage('fancycaptcha-reload-text')->text());
     } else {
         $captchaReload = '';
     }
     return "<div class='fancycaptcha-wrapper'><div class='fancycaptcha-image-container'>" . Html::element('img', array('class' => 'fancycaptcha-image', 'src' => $title->getLocalUrl('wpCaptchaId=' . urlencode($index)), 'alt' => '')) . $captchaReload . "</div>\n" . '<p>' . Html::element('label', array('for' => 'wpCaptchaWord'), parent::getMessage('label') . wfMessage('colon-separator')->text()) . Html::element('input', array('name' => 'wpCaptchaWord', 'id' => 'wpCaptchaWord', 'type' => 'text', 'size' => '12', 'autocomplete' => 'off', 'autocorrect' => 'off', 'autocapitalize' => 'off', 'required' => 'required', 'tabindex' => 1)) . Html::element('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index)) . "</p>\n" . "</div>\n";
 }
 /**
  * Insert the captcha prompt into the edit form.
  * @param OutputPage $out
  */
 function getForm(OutputPage $out)
 {
     global $wgOut, $wgEnableAPI;
     // Uses addModuleStyles so it is loaded when JS is disabled.
     $out->addModuleStyles('ext.confirmEdit.fancyCaptcha.styles');
     $title = SpecialPage::getTitleFor('Captcha', 'image');
     $index = $this->getCaptchaIndex();
     if ($wgEnableAPI) {
         // Loaded only if JS is enabled
         $out->addModules('ext.confirmEdit.fancyCaptcha');
         $captchaReload = Html::element('small', array('class' => 'confirmedit-captcha-reload fancycaptcha-reload'), wfMessage('fancycaptcha-reload-text')->text());
     } else {
         $captchaReload = '';
     }
     $form = Html::openElement('div') . Html::element('label', array('for' => 'wpCaptchaWord'), parent::getMessage('label') . ' ' . wfMessage('createacct-captcha')->text()) . Html::openElement('div', array('class' => 'mw-createacct-captcha-container')) . Html::openElement('div', array('class' => 'mw-createacct-captcha-and-reload')) . Html::openElement('div', array('class' => 'fancycaptcha-image-container')) . Html::element('img', array('class' => 'fancycaptcha-image', 'src' => $title->getLocalUrl('wpCaptchaId=' . urlencode($index)), 'alt' => '')) . $captchaReload . Html::closeElement('div') . Html::closeElement('div') . "\n" . Html::element('input', array('name' => 'wpCaptchaWord', 'class' => 'mw-ui-input', 'id' => 'wpCaptchaWord', 'type' => 'text', 'size' => '12', 'autocomplete' => 'off', 'autocorrect' => 'off', 'autocapitalize' => 'off', 'required' => 'required', 'tabindex' => 1, 'placeholder' => wfMessage('createacct-imgcaptcha-ph')));
     // tab in before the edit textarea
     if ($this->action == 'usercreate') {
         // use raw element, because the message can contain links or some other html
         $form .= HTML::rawelement('small', array('class' => 'mw-createacct-captcha-assisted'), wfMessage('createacct-imgcaptcha-help')->parse());
     }
     $form .= Html::element('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index)) . Html::closeElement('div') . Html::closeElement('div') . "\n";
     return $form;
 }