MediaWiki REL1_33
HTMLFancyCaptchaField.php
Go to the documentation of this file.
1<?php
2
9 protected $imageUrl;
10
12 protected $showCreateHelp;
13
14 protected $mClass = 'captcha';
15
22 public function __construct( array $params ) {
23 parent::__construct( $params );
24 $this->imageUrl = $params['imageUrl'];
25 $this->showCreateHelp = !empty( $params['showCreateHelp'] );
26 }
27
28 public function getInputHTML( $value ) {
29 $out = $this->mParent->getOutput();
30
31 // Uses addModuleStyles so it is loaded even when JS is disabled.
32 $out->addModuleStyles( 'ext.confirmEdit.fancyCaptcha.styles' );
33
34 // Loaded only for clients with JS enabled
35 $out->addModules( 'ext.confirmEdit.fancyCaptcha' );
36
37 $captchaReload = Html::element(
38 'small',
39 [ 'class' => 'confirmedit-captcha-reload fancycaptcha-reload' ],
40 $this->mParent->msg( 'fancycaptcha-reload-text' )->text()
41 );
42
43 $attribs = [
44 'type' => 'text',
45 'id' => $this->mID,
46 'name' => $this->mName,
47 'class' => 'mw-ui-input',
48 // max_length in captcha.py plus fudge factor
49 'size' => '12',
50 'dir' => $this->mDir,
51 'autocomplete' => 'off',
52 'autocorrect' => 'off',
53 'autocapitalize' => 'off',
54 'placeholder' => $this->mParent->msg( 'fancycaptcha-imgcaptcha-ph' )->text()
55 ];
56 $attribs += $this->getAttributes( [ 'tabindex', 'required', 'autofocus' ] );
57
58 $html = Html::openElement( 'div', [ 'class' => 'fancycaptcha-captcha-container' ] )
59 . Html::openElement( 'div', [ 'class' => 'fancycaptcha-captcha-and-reload' ] )
60 . Html::openElement( 'div', [ 'class' => 'fancycaptcha-image-container' ] )
61 . Html::element( 'img', [
62 'class' => 'fancycaptcha-image',
63 'src' => $this->imageUrl,
64 'alt' => ''
65 ] ) . $captchaReload . Html::closeElement( 'div' ) . Html::closeElement( 'div' ) . "\n"
66 . Html::element( 'input', $attribs );
67
68 if ( $this->showCreateHelp ) {
69 // use raw element, the message will contain a link
70 $html .= Html::rawElement( 'small', [
71 'class' => 'mw-createacct-captcha-assisted'
72 ], $this->mParent->msg( 'createacct-imgcaptcha-help' )->parse() );
73 }
74
75 $html .= Html::closeElement( 'div' );
76
77 return $html;
78 }
79
80 public function getLabel() {
81 // slight abuse of what getLabel() should mean; $mLabel is used for the pre-label text
82 // as the actual label is always the same
83 return $this->mParent->msg( 'captcha-label' )->text() . ' '
84 . $this->mParent->msg( 'fancycaptcha-captcha' )->text();
85 }
86
87 public function getLabelHtml( $cellAttributes = [] ) {
88 $labelHtml = parent::getLabelHtml( $cellAttributes );
89 if ( $this->mLabel ) {
90 // use raw element, the message will contain a link
91 $labelHtml = Html::rawElement( 'p', [], $this->mLabel ) . $labelHtml;
92 }
93 return $labelHtml;
94 }
95}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Captcha input field for FancyCaptcha that displays a question and returns the answer.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
__construct(array $params)
Apart from normal HTMLFormField parameters, recognizes the following keys:
getLabelHtml( $cellAttributes=[])
The parent class to generate form fields.
getAttributes(array $list)
Returns the given attributes from the parameters.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:855
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:2011
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:2012
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$params