UserFieldsCreateTemplate   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 153
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 23.53%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
dl 0
loc 153
rs 10
c 5
b 0
f 0
ccs 8
cts 34
cp 0.2353
wmc 20
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addInputItem() 0 8 1
D execute() 0 141 19
1
<?php
2
3
namespace SES;
4
5
use QuickTemplate;
6
7
/**
8
 * Borrowed from standard UsercreateTemplate. Some minor changes have been made
9
 *
10
 * @license GNU GPL v3+
11
 * @since 1.0
12
 *
13
 * @author Serhii Kutnii
14
 */
15
class UserFieldsCreateTemplate extends QuickTemplate {
16
17
	function addInputItem( $name, $value, $type, $msg ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for addInputItem.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
18
		$this->data['extraInput'][] = array(
19
			'name' => $name,
20
			'value' => $value,
21
			'type' => $type,
22
			'msg' => $msg,
23
		);
24
	}
25
26 2
	function execute() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for execute.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
27 2
		global $sfgTabIndex;
28
29 2
		if ( $this->data === array() ) {
30 1
			return '';
31
		}
32
33
		/* We should find way to deprecate :( http://www.mediawiki.org/wiki/Manual:$wgOut */
34 1
		global $wgOut;
35
36 1
		$wgOut->addModules( 'ext.semanticforms.main' );
37
38
	?>
39
<div id="userlogin" style="float:none;">
40
41
	<h2><?php $this->msg( 'createaccount' ) ?></h2>
42
	<p id="userloginlink"><?php $this->html( 'link' ) ?></p>
43
	<?php if ( @$this->haveData( 'languages' ) ) { ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php } ?>
44
	<table>
45
		<tr>
46
			<td class="mw-label"><label for='wpName2'><?php $this->msg( 'yourname' ) ?></label></td>
47
			<td class="mw-input">
48
				<input type='text' class='loginText' name="wpName" id="wpName2"
49
					tabindex="<?php echo $sfgTabIndex++; ?>"
50
					size='20' />
51
			</td>
52
		</tr>
53
		<tr>
54
			<td class="mw-label"><label for='wpPassword2'><?php $this->msg( 'yourpassword' ) ?></label></td>
55
			<td class="mw-input">
56
				<input type='password' class='loginPassword' name="wpPassword" id="wpPassword2"
57
					tabindex="<?php echo $sfgTabIndex++; ?>"
58
					value="" size='20' />
59
			</td>
60
		</tr>
61
	<?php if ( $this->data['usedomain'] ) {
62
		$doms = "";
63
		foreach ( $this->data['domainnames'] as $dom ) {
64
			$doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
65
		}
66
	?>
67
		<tr>
68
			<td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
69
			<td class="mw-input">
70
				<select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
71
					tabindex="<?php echo $sfgTabIndex++; ?>">
72
					<?php echo $doms ?>
73
				</select>
74
			</td>
75
		</tr>
76
	<?php } ?>
77
		<tr>
78
			<td class="mw-label"><label for='wpRetype'><?php $this->msg( 'yourpasswordagain' ) ?></label></td>
79
			<td class="mw-input">
80
				<input type='password' class='loginPassword' name="wpRetype" id="wpRetype"
81
					tabindex="<?php echo $sfgTabIndex++; ?>"
82
					value=""
83
					size='20' />
84
			</td>
85
		</tr>
86
		<tr>
87
			<?php if ( $this->data['useemail'] ) { ?>
88
				<td class="mw-label"><label for='wpEmail'><?php $this->msg( 'youremail' ) ?></label></td>
89
				<td class="mw-input">
90
					<input type='text' class='loginText' name="wpEmail" id="wpEmail"
91
						tabindex="<?php echo $sfgTabIndex++; ?>"
92
						value="<?php $this->text( 'email' ) ?>" size='20' />
93
					<div class="prefsectiontip">
94
						<?php if ( $this->data['emailrequired'] ) {
95
									$this->msgWiki( 'prefs-help-email-required' );
96
						      } else {
97
									$this->msgWiki( 'prefs-help-email' );
98
						      } ?>
99
					</div>
100
				</td>
101
			<?php } ?>
102
			<?php if ( $this->data['userealname'] ) { ?>
103
				</tr>
104
				<tr>
105
					<td class="mw-label"><label for='wpRealName'><?php $this->msg( 'yourrealname' ) ?></label></td>
106
					<td class="mw-input">
107
						<input type='text' class='loginText' name="wpRealName" id="wpRealName"
108
							tabindex="<?php echo $sfgTabIndex++; ?>"
109
							size='20' />
110
					</td>
111
			<?php } ?>
112
		</tr>
113
		<tr>
114
			<td></td>
115
		</tr>
116
<?php
117 1
		if ( isset( $this->data['extraInput'] ) && is_array( $this->data['extraInput'] ) ) {
118
			foreach ( $this->data['extraInput'] as $inputItem ) { ?>
119
		<tr>
120
			<?php
121
				if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
122
					?><td class="mw-label"><label for="<?php
123
					echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
124
					$this->msgWiki( $inputItem['msg'] ) ?></label><?php
125
				} else {
126
					?><td><?php
127
				}
128
			?></td>
129
			<td class="mw-input">
130
				<input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
131
				echo htmlspecialchars( $inputItem['name'] ); ?>"
132
					tabindex="<?php echo $sfgTabIndex++; ?>"
133
					value="<?php
134
				if ( $inputItem['type'] != 'checkbox' ) {
135
					echo htmlspecialchars( $inputItem['value'] );
136
				} else {
137
					echo '1';
138
				}
139
					?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
140
					<?php
141
				if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
142
					echo 'checked="checked"';
143
					?> /> <?php
144
					if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
145
						?>
146
				<label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
147
					$this->msg( $inputItem['msg'] ) ?></label><?php
148
					}
149
				?>
150
			</td>
151
		</tr>
152
<?php
153
154
			}
155
		}
156
?>
157
		<tr>
158
			<td></td>
159
		</tr>
160
	</table>
161
<?php if ( @$this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
162
</div>
163
<div id="signupend"><?php $this->msgWiki( 'signupend' ); ?></div>
164
<?php
165
166 1
	}
167
}
168