r15508 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r15507‎ | r15508 | r15509 >
Date:18:53, 10 July 2006
Author:hashar
Status:old
Tags:
Comment:
Adding some more static statements
Modified paths:
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/Xml.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Xml.php
@@ -16,7 +16,7 @@
1717 * @param $contents String: NULL to make an open tag only; '' for a contentless closed tag (default)
1818 * @return string
1919 */
20 - function element( $element, $attribs = null, $contents = '') {
 20+ public static function element( $element, $attribs = null, $contents = '') {
2121 $out = '<' . $element;
2222 if( !is_null( $attribs ) ) {
2323 foreach( $attribs as $name => $val ) {
@@ -45,7 +45,7 @@
4646 * @param $contents String: NULL to make an open tag only; '' for a contentless closed tag (default)
4747 * @return string
4848 */
49 - function elementClean( $element, $attribs = array(), $contents = '') {
 49+ public static function elementClean( $element, $attribs = array(), $contents = '') {
5050 if( $attribs ) {
5151 $attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs );
5252 }
@@ -67,7 +67,7 @@
6868 * @param $includehidden Bool: include hidden namespaces?
6969 * @return String: Html string containing the namespace selector
7070 */
71 - function &namespaceSelector($selected = '', $allnamespaces = null, $includehidden=false) {
 71+ public static function &namespaceSelector($selected = '', $allnamespaces = null, $includehidden=false) {
7272 global $wgContLang;
7373 if( $selected !== '' ) {
7474 if( is_null( $selected ) ) {
@@ -100,7 +100,7 @@
101101 return $s;
102102 }
103103
104 - function span( $text, $class, $attribs=array() ) {
 104+ public static function span( $text, $class, $attribs=array() ) {
105105 return self::element( 'span', array( 'class' => $class ) + $attribs, $text );
106106 }
107107
@@ -108,7 +108,7 @@
109109 * Convenience function to build an HTML text input field
110110 * @return string HTML
111111 */
112 - function input( $name, $size=false, $value=false, $attribs=array() ) {
 112+ public static function input( $name, $size=false, $value=false, $attribs=array() ) {
113113 return self::element( 'input', array(
114114 'name' => $name,
115115 'size' => $size,
@@ -119,7 +119,7 @@
120120 * Internal function for use in checkboxes and radio buttons and such.
121121 * @return array
122122 */
123 - function attrib( $name, $present = true ) {
 123+ public static function attrib( $name, $present = true ) {
124124 return $present ? array( $name => $name ) : array();
125125 }
126126
@@ -127,7 +127,7 @@
128128 * Convenience function to build an HTML checkbox
129129 * @return string HTML
130130 */
131 - function check( $name, $checked=false, $attribs=array() ) {
 131+ public static function check( $name, $checked=false, $attribs=array() ) {
132132 return self::element( 'input', array(
133133 'name' => $name,
134134 'type' => 'checkbox',
@@ -138,7 +138,7 @@
139139 * Convenience function to build an HTML radio button
140140 * @return string HTML
141141 */
142 - function radio( $name, $value, $checked=false, $attribs=array() ) {
 142+ public static function radio( $name, $value, $checked=false, $attribs=array() ) {
143143 return self::element( 'input', array(
144144 'name' => $name,
145145 'type' => 'radio',
@@ -149,7 +149,7 @@
150150 * Convenience function to build an HTML form label
151151 * @return string HTML
152152 */
153 - function label( $label, $id ) {
 153+ public static function label( $label, $id ) {
154154 return self::element( 'label', array( 'for' => $id ), $label );
155155 }
156156
@@ -157,7 +157,7 @@
158158 * Convenience function to build an HTML text input field with a label
159159 * @return string HTML
160160 */
161 - function inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=array() ) {
 161+ public static function inputLabel( $label, $name, $id, $size=false, $value=false, $attribs=array() ) {
162162 return Xml::label( $label, $id ) .
163163 '&nbsp;' .
164164 self::input( $name, $size, $value, array( 'id' => $id ) + $attribs );
@@ -167,7 +167,7 @@
168168 * Convenience function to build an HTML checkbox with a label
169169 * @return string HTML
170170 */
171 - function checkLabel( $label, $name, $id, $checked=false, $attribs=array() ) {
 171+ public static function checkLabel( $label, $name, $id, $checked=false, $attribs=array() ) {
172172 return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
173173 '&nbsp;' .
174174 self::label( $label, $id );
@@ -177,7 +177,7 @@
178178 * Convenience function to build an HTML radio button with a label
179179 * @return string HTML
180180 */
181 - function radioLabel( $label, $name, $value, $id, $checked=false, $attribs=array() ) {
 181+ public static function radioLabel( $label, $name, $value, $id, $checked=false, $attribs=array() ) {
182182 return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) .
183183 '&nbsp;' .
184184 self::label( $label, $id );
@@ -189,7 +189,7 @@
190190 * @param $attribs Array: optional custom attributes
191191 * @return string HTML
192192 */
193 - function submitButton( $value, $attribs=array() ) {
 193+ public static function submitButton( $value, $attribs=array() ) {
194194 return self::element( 'input', array( 'type' => 'submit', 'value' => $value ) + $attribs );
195195 }
196196
@@ -201,7 +201,7 @@
202202 * @param $attribs Array: optional custom attributes
203203 * @return string HTML
204204 */
205 - function hidden( $name, $value, $attribs=array() ) {
 205+ public static function hidden( $name, $value, $attribs=array() ) {
206206 return self::element( 'input', array(
207207 'name' => $name,
208208 'type' => 'hidden',
@@ -241,7 +241,7 @@
242242 *
243243 * @todo Error position reporting return
244244 */
245 - function isWellFormed( $text ) {
 245+ public static function isWellFormed( $text ) {
246246 $parser = xml_parser_create( "UTF-8" );
247247
248248 # case folding violates XML standard, turn it off
@@ -267,7 +267,7 @@
268268 * @param $text String:
269269 * @return bool
270270 */
271 - function isWellFormedXmlFragment( $text ) {
 271+ public static function isWellFormedXmlFragment( $text ) {
272272 $html =
273273 Sanitizer::hackDocType() .
274274 '<html>' .
Index: trunk/phase3/includes/Namespace.php
@@ -49,7 +49,7 @@
5050 * Check if the given namespace might be moved
5151 * @return bool
5252 */
53 - function isMovable( $index ) {
 53+ static function isMovable( $index ) {
5454 return !( $index < NS_MAIN || $index == NS_IMAGE || $index == NS_CATEGORY );
5555 }
5656
@@ -57,7 +57,7 @@
5858 * Check if the given namespace is not a talk page
5959 * @return bool
6060 */
61 - function isMain( $index ) {
 61+ static function isMain( $index ) {
6262 return ! Namespace::isTalk( $index );
6363 }
6464
@@ -73,7 +73,7 @@
7474 /**
7575 * Get the talk namespace corresponding to the given index
7676 */
77 - function getTalk( $index ) {
 77+ static function getTalk( $index ) {
7878 if ( Namespace::isTalk( $index ) ) {
7979 return $index;
8080 } else {
@@ -82,7 +82,7 @@
8383 }
8484 }
8585
86 - function getSubject( $index ) {
 86+ static function getSubject( $index ) {
8787 if ( Namespace::isTalk( $index ) ) {
8888 return $index - 1;
8989 } else {
@@ -93,7 +93,7 @@
9494 /**
9595 * Returns the canonical (English Wikipedia) name for a given index
9696 */
97 - function getCanonicalName( $index ) {
 97+ static function getCanonicalName( $index ) {
9898 global $wgCanonicalNamespaceNames;
9999 return $wgCanonicalNamespaceNames[$index];
100100 }
@@ -102,7 +102,7 @@
103103 * Returns the index for a given canonical name, or NULL
104104 * The input *must* be converted to lower case first
105105 */
106 - function getCanonicalIndex( $name ) {
 106+ static function getCanonicalIndex( $name ) {
107107 global $wgCanonicalNamespaceNames;
108108 static $xNamespaces = false;
109109 if ( $xNamespaces === false ) {
@@ -122,7 +122,7 @@
123123 * Can this namespace ever have a talk namespace?
124124 * @param $index Namespace index
125125 */
126 - function canTalk( $index ) {
 126+ static function canTalk( $index ) {
127127 return( $index >= NS_MAIN );
128128 }
129129 }