Index: trunk/phase3/includes/Interwiki.php |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | global $wgMemc, $wgInterwikiExpiry; |
145 | 145 | |
146 | 146 | $iwData = false; |
147 | | - if ( !wfRunHooks('InterwikiLoadPrefix', array( $prefix, &$iwData ) ) ) { |
| 147 | + if ( !wfRunHooks( 'InterwikiLoadPrefix', array( $prefix, &$iwData ) ) ) { |
148 | 148 | return Interwiki::loadFromArray( $iwData ); |
149 | 149 | } |
150 | 150 | |
Index: trunk/phase3/includes/PrefixSearch.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | * @param $namespaces Array: used if query is not explicitely prefixed |
17 | 17 | * @return Array of strings |
18 | 18 | */ |
19 | | - public static function titleSearch( $search, $limit, $namespaces=array() ) { |
| 19 | + public static function titleSearch( $search, $limit, $namespaces = array() ) { |
20 | 20 | $search = trim( $search ); |
21 | 21 | if( $search == '' ) { |
22 | 22 | return array(); // Return empty result |
— | — | @@ -26,8 +26,9 @@ |
27 | 27 | $title = Title::newFromText( $search ); |
28 | 28 | if( $title && $title->getInterwiki() == '' ) { |
29 | 29 | $ns = array($title->getNamespace()); |
30 | | - if($ns[0] == NS_MAIN) |
| 30 | + if( $ns[0] == NS_MAIN ) { |
31 | 31 | $ns = $namespaces; // no explicit prefix, use default namespaces |
| 32 | + } |
32 | 33 | return self::searchBackend( |
33 | 34 | $ns, $title->getText(), $limit ); |
34 | 35 | } |
— | — | @@ -38,13 +39,12 @@ |
39 | 40 | && $title->getNamespace() != NS_MAIN |
40 | 41 | && $title->getInterwiki() == '' ) { |
41 | 42 | return self::searchBackend( |
42 | | - array($title->getNamespace()), '', $limit ); |
| 43 | + array( $title->getNamespace() ), '', $limit ); |
43 | 44 | } |
44 | 45 | |
45 | 46 | return self::searchBackend( $namespaces, $search, $limit ); |
46 | 47 | } |
47 | 48 | |
48 | | - |
49 | 49 | /** |
50 | 50 | * Do a prefix search of titles and return a list of matching page names. |
51 | 51 | * @param $namespaces Array |
— | — | @@ -53,10 +53,10 @@ |
54 | 54 | * @return Array of strings |
55 | 55 | */ |
56 | 56 | protected static function searchBackend( $namespaces, $search, $limit ) { |
57 | | - if( count($namespaces) == 1 ){ |
| 57 | + if( count( $namespaces ) == 1 ) { |
58 | 58 | $ns = $namespaces[0]; |
59 | 59 | if( $ns == NS_MEDIA ) { |
60 | | - $namespaces = array(NS_FILE); |
| 60 | + $namespaces = array( NS_FILE ); |
61 | 61 | } elseif( $ns == NS_SPECIAL ) { |
62 | 62 | return self::specialSearch( $search, $limit ); |
63 | 63 | } |
— | — | @@ -135,12 +135,13 @@ |
136 | 136 | * @return Array of title strings |
137 | 137 | */ |
138 | 138 | protected static function defaultSearchBackend( $namespaces, $search, $limit ) { |
139 | | - $ns = array_shift($namespaces); // support only one namespace |
140 | | - if( in_array(NS_MAIN,$namespaces)) |
| 139 | + $ns = array_shift( $namespaces ); // support only one namespace |
| 140 | + if( in_array( NS_MAIN, $namespaces ) ) { |
141 | 141 | $ns = NS_MAIN; // if searching on many always default to main |
| 142 | + } |
142 | 143 | |
143 | 144 | // Prepare nested request |
144 | | - $req = new FauxRequest(array ( |
| 145 | + $req = new FauxRequest( array( |
145 | 146 | 'action' => 'query', |
146 | 147 | 'list' => 'allpages', |
147 | 148 | 'apnamespace' => $ns, |
— | — | @@ -149,7 +150,7 @@ |
150 | 151 | )); |
151 | 152 | |
152 | 153 | // Execute |
153 | | - $module = new ApiMain($req); |
| 154 | + $module = new ApiMain( $req ); |
154 | 155 | $module->execute(); |
155 | 156 | |
156 | 157 | // Get resulting data |
— | — | @@ -157,7 +158,7 @@ |
158 | 159 | |
159 | 160 | // Reformat useful data for future printing by JSON engine |
160 | 161 | $srchres = array (); |
161 | | - foreach ((array)$data['query']['allpages'] as $pageinfo) { |
| 162 | + foreach ( (array)$data['query']['allpages'] as $pageinfo ) { |
162 | 163 | // Note: this data will no be printable by the xml engine |
163 | 164 | // because it does not support lists of unnamed items |
164 | 165 | $srchres[] = $pageinfo['title']; |
— | — | @@ -172,18 +173,19 @@ |
173 | 174 | * @param $namespaces Array |
174 | 175 | * @return Array (default: contains only NS_MAIN) |
175 | 176 | */ |
176 | | - protected static function validateNamespaces($namespaces){ |
| 177 | + protected static function validateNamespaces( $namespaces ) { |
177 | 178 | global $wgContLang; |
178 | 179 | |
179 | 180 | // We will look at each given namespace against wgContLang namespaces |
180 | 181 | $validNamespaces = $wgContLang->getNamespaces(); |
181 | | - if( is_array($namespaces) && count($namespaces)>0 ){ |
| 182 | + if( is_array( $namespaces ) && count( $namespaces ) > 0 ) { |
182 | 183 | $valid = array(); |
183 | | - foreach ($namespaces as $ns){ |
184 | | - if( is_numeric($ns) && array_key_exists($ns, $validNamespaces) ) |
| 184 | + foreach ( $namespaces as $ns ) { |
| 185 | + if( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) { |
185 | 186 | $valid[] = $ns; |
| 187 | + } |
186 | 188 | } |
187 | | - if( count($valid) > 0 ) { |
| 189 | + if( count( $valid ) > 0 ) { |
188 | 190 | return $valid; |
189 | 191 | } |
190 | 192 | } |
Index: trunk/phase3/includes/MWFunction.php |
— | — | @@ -19,52 +19,46 @@ |
20 | 20 | */ |
21 | 21 | |
22 | 22 | class MWFunction { |
23 | | - |
| 23 | + |
24 | 24 | protected static function cleanCallback( $callback ) { |
25 | | - |
26 | 25 | if( is_string( $callback ) ) { |
27 | 26 | if ( strpos( $callback, '::' ) !== false ) { |
28 | | - //PHP 5.1 cannot use call_user_func( 'Class::Method' ) |
29 | | - //It can only handle only call_user_func( array( 'Class', 'Method' ) ) |
| 27 | + // PHP 5.1 cannot use call_user_func( 'Class::Method' ) |
| 28 | + // It can only handle only call_user_func( array( 'Class', 'Method' ) ) |
30 | 29 | $callback = explode( '::', $callback, 2); |
31 | 30 | } |
32 | 31 | } |
33 | | - |
| 32 | + |
34 | 33 | if( count( $callback ) == 2 && $callback[0] == 'self' || $callback[0] == 'parent' ) { |
35 | | - |
36 | 34 | throw new MWException( 'MWFunction cannot call self::method() or parent::method()' ); |
37 | | - |
38 | 35 | } |
39 | | - |
| 36 | + |
40 | 37 | // Run autoloader (workaround for call_user_func_array bug: http://bugs.php.net/bug.php?id=51329) |
41 | 38 | is_callable( $callback ); |
42 | | - |
| 39 | + |
43 | 40 | return $callback; |
44 | 41 | } |
45 | | - |
| 42 | + |
46 | 43 | public static function call( $callback ) { |
47 | 44 | $callback = self::cleanCallback( $callback ); |
48 | | - |
| 45 | + |
49 | 46 | $args = func_get_args(); |
50 | | - |
| 47 | + |
51 | 48 | return call_user_func_array( 'call_user_func', $args ); |
52 | | - |
53 | 49 | } |
54 | | - |
| 50 | + |
55 | 51 | public static function callArray( $callback, $argsarams ) { |
56 | | - |
57 | 52 | $callback = self::cleanCallback( $callback ); |
58 | 53 | return call_user_func_array( $callback, $argsarams ); |
59 | | - |
60 | 54 | } |
61 | | - |
| 55 | + |
62 | 56 | public static function newObj( $class, $args = array() ) { |
63 | 57 | if( !count( $args ) ) { |
64 | 58 | return new $class; |
65 | 59 | } |
66 | 60 | |
67 | | - $ref = new ReflectionClass($class); |
68 | | - return $ref->newInstanceArgs($args); |
| 61 | + $ref = new ReflectionClass( $class ); |
| 62 | + return $ref->newInstanceArgs( $args ); |
69 | 63 | } |
70 | 64 | |
71 | 65 | } |
Index: trunk/phase3/includes/ZhClient.php |
— | — | @@ -2,7 +2,6 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Client for querying zhdaemon |
6 | | - * |
7 | 6 | */ |
8 | 7 | class ZhClient { |
9 | 8 | var $mHost, $mPort, $mFP, $mConnected; |
— | — | @@ -12,7 +11,7 @@ |
13 | 12 | * |
14 | 13 | * @access private |
15 | 14 | */ |
16 | | - function __construct($host, $port) { |
| 15 | + function __construct( $host, $port ) { |
17 | 16 | $this->mHost = $host; |
18 | 17 | $this->mPort = $port; |
19 | 18 | $this->mConnected = $this->connect(); |
— | — | @@ -33,7 +32,7 @@ |
34 | 33 | function connect() { |
35 | 34 | wfSuppressWarnings(); |
36 | 35 | $errno = $errstr = ''; |
37 | | - $this->mFP = fsockopen($this->mHost, $this->mPort, $errno, $errstr, 30); |
| 36 | + $this->mFP = fsockopen( $this->mHost, $this->mPort, $errno, $errstr, 30 ); |
38 | 37 | wfRestoreWarnings(); |
39 | 38 | if ( !$this->mFP ) { |
40 | 39 | return false; |
— | — | @@ -46,30 +45,30 @@ |
47 | 46 | * |
48 | 47 | * @access private |
49 | 48 | */ |
50 | | - function query($request) { |
| 49 | + function query( $request ) { |
51 | 50 | if ( !$this->mConnected ) { |
52 | 51 | return false; |
53 | 52 | } |
54 | 53 | |
55 | | - fwrite($this->mFP, $request); |
| 54 | + fwrite( $this->mFP, $request ); |
56 | 55 | |
57 | | - $result=fgets($this->mFP, 1024); |
| 56 | + $result = fgets( $this->mFP, 1024 ); |
58 | 57 | |
59 | | - list($status, $len) = explode(" ", $result); |
60 | | - if($status == 'ERROR') { |
61 | | - //$len is actually the error code... |
| 58 | + list( $status, $len ) = explode( ' ', $result ); |
| 59 | + if( $status == 'ERROR' ) { |
| 60 | + // $len is actually the error code... |
62 | 61 | print "zhdaemon error $len<br />\n"; |
63 | 62 | return false; |
64 | 63 | } |
65 | | - $bytesread=0; |
66 | | - $data=''; |
67 | | - while(!feof($this->mFP) && $bytesread<$len) { |
68 | | - $str= fread($this->mFP, $len-$bytesread); |
69 | | - $bytesread += strlen($str); |
| 64 | + $bytesread = 0; |
| 65 | + $data = ''; |
| 66 | + while( !feof( $this->mFP ) && $bytesread < $len ) { |
| 67 | + $str = fread( $this->mFP, $len - $bytesread ); |
| 68 | + $bytesread += strlen( $str ); |
70 | 69 | $data .= $str; |
71 | 70 | } |
72 | | - //data should be of length $len. otherwise something is wrong |
73 | | - if ( strlen($data) != $len ) { |
| 71 | + // data should be of length $len. otherwise something is wrong |
| 72 | + if ( strlen( $data ) != $len ) { |
74 | 73 | return false; |
75 | 74 | } |
76 | 75 | return $data; |
— | — | @@ -78,14 +77,14 @@ |
79 | 78 | /** |
80 | 79 | * Convert the input to a different language variant |
81 | 80 | * |
82 | | - * @param $text string: input text |
83 | | - * @param $tolang string: language variant |
| 81 | + * @param $text String: input text |
| 82 | + * @param $tolang String: language variant |
84 | 83 | * @return string the converted text |
85 | 84 | */ |
86 | | - function convert($text, $tolang) { |
87 | | - $len = strlen($text); |
| 85 | + function convert( $text, $tolang ) { |
| 86 | + $len = strlen( $text ); |
88 | 87 | $q = "CONV $tolang $len\n$text"; |
89 | | - $result = $this->query($q); |
| 88 | + $result = $this->query( $q ); |
90 | 89 | if ( !$result ) { |
91 | 90 | $result = $text; |
92 | 91 | } |
— | — | @@ -95,39 +94,39 @@ |
96 | 95 | /** |
97 | 96 | * Convert the input to all possible variants |
98 | 97 | * |
99 | | - * @param $text string: input text |
| 98 | + * @param $text String: input text |
100 | 99 | * @return array langcode => converted_string |
101 | 100 | */ |
102 | | - function convertToAllVariants($text) { |
103 | | - $len = strlen($text); |
| 101 | + function convertToAllVariants( $text ) { |
| 102 | + $len = strlen( $text ); |
104 | 103 | $q = "CONV ALL $len\n$text"; |
105 | | - $result = $this->query($q); |
| 104 | + $result = $this->query( $q ); |
106 | 105 | if ( !$result ) { |
107 | 106 | return false; |
108 | 107 | } |
109 | | - list($infoline, $data) = explode('|', $result, 2); |
110 | | - $info = explode(";", $infoline); |
| 108 | + list( $infoline, $data ) = explode( '|', $result, 2 ); |
| 109 | + $info = explode( ';', $infoline ); |
111 | 110 | $ret = array(); |
112 | | - $i=0; |
113 | | - foreach($info as $variant) { |
114 | | - list($code, $len) = explode(' ', $variant); |
115 | | - $ret[strtolower($code)] = substr($data, $i, $len); |
116 | | - $i+=$len; |
| 111 | + $i = 0; |
| 112 | + foreach( $info as $variant ) { |
| 113 | + list( $code, $len ) = explode( ' ', $variant ); |
| 114 | + $ret[strtolower( $code )] = substr( $data, $i, $len ); |
| 115 | + $i += $len; |
117 | 116 | } |
118 | 117 | return $ret; |
119 | 118 | } |
120 | 119 | /** |
121 | 120 | * Perform word segmentation |
122 | 121 | * |
123 | | - * @param $text string: input text |
| 122 | + * @param $text String: input text |
124 | 123 | * @return string segmented text |
125 | 124 | */ |
126 | | - function segment($text) { |
127 | | - $len = strlen($text); |
| 125 | + function segment( $text ) { |
| 126 | + $len = strlen( $text ); |
128 | 127 | $q = "SEG $len\n$text"; |
129 | | - $result = $this->query($q); |
130 | | - if ( !$result ) {// fallback to character based segmentation |
131 | | - $result = $this->segment($text); |
| 128 | + $result = $this->query( $q ); |
| 129 | + if ( !$result ) { // fallback to character based segmentation |
| 130 | + $result = $this->segment( $text ); |
132 | 131 | } |
133 | 132 | return $result; |
134 | 133 | } |
— | — | @@ -136,6 +135,6 @@ |
137 | 136 | * Close the connection |
138 | 137 | */ |
139 | 138 | function close() { |
140 | | - fclose($this->mFP); |
| 139 | + fclose( $this->mFP ); |
141 | 140 | } |
142 | 141 | } |
Index: trunk/phase3/includes/specials/SpecialMergeHistory.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | |
39 | 39 | private function loadRequestParams( $request ) { |
40 | 40 | global $wgUser; |
| 41 | + |
41 | 42 | $this->mAction = $request->getVal( 'action' ); |
42 | 43 | $this->mTarget = $request->getVal( 'target' ); |
43 | 44 | $this->mDest = $request->getVal( 'dest' ); |
— | — | @@ -45,7 +46,7 @@ |
46 | 47 | $this->mTargetID = intval( $request->getVal( 'targetID' ) ); |
47 | 48 | $this->mDestID = intval( $request->getVal( 'destID' ) ); |
48 | 49 | $this->mTimestamp = $request->getVal( 'mergepoint' ); |
49 | | - if( !preg_match("/[0-9]{14}/",$this->mTimestamp) ) { |
| 50 | + if( !preg_match( '/[0-9]{14}/', $this->mTimestamp ) ) { |
50 | 51 | $this->mTimestamp = ''; |
51 | 52 | } |
52 | 53 | $this->mComment = $request->getText( 'wpComment' ); |
— | — | @@ -73,7 +74,7 @@ |
74 | 75 | } |
75 | 76 | } |
76 | 77 | |
77 | | - function execute( $par ) { |
| 78 | + public function execute( $par ) { |
78 | 79 | global $wgOut, $wgRequest, $wgUser; |
79 | 80 | |
80 | 81 | if ( wfReadOnly() ) { |
— | — | @@ -91,7 +92,7 @@ |
92 | 93 | $this->setHeaders(); |
93 | 94 | $this->outputHeader(); |
94 | 95 | |
95 | | - if( $this->mTargetID && $this->mDestID && $this->mAction=="submit" && $this->mMerge ) { |
| 96 | + if( $this->mTargetID && $this->mDestID && $this->mAction == 'submit' && $this->mMerge ) { |
96 | 97 | return $this->merge(); |
97 | 98 | } |
98 | 99 | |
— | — | @@ -109,7 +110,7 @@ |
110 | 111 | ); |
111 | 112 | } |
112 | 113 | |
113 | | - if ( !$this->mDestObj instanceof Title) { |
| 114 | + if ( !$this->mDestObj instanceof Title ) { |
114 | 115 | $errors[] = wfMsgExt( 'mergehistory-invalid-destination', array( 'parse' ) ); |
115 | 116 | } elseif( !$this->mDestObj->exists() ) { |
116 | 117 | $errors[] = wfMsgExt( 'mergehistory-no-destination', array( 'parse' ), |
— | — | @@ -146,18 +147,19 @@ |
147 | 148 | Html::hidden( 'submitted', '1' ) . |
148 | 149 | Html::hidden( 'mergepoint', $this->mTimestamp ) . |
149 | 150 | Xml::openElement( 'table' ) . |
150 | | - "<tr> |
151 | | - <td>".Xml::label( wfMsg( 'mergehistory-from' ), 'target' )."</td> |
152 | | - <td>".Xml::input( 'target', 30, $this->mTarget, array('id'=>'target') )."</td> |
| 151 | + '<tr> |
| 152 | + <td>' . Xml::label( wfMsg( 'mergehistory-from' ), 'target' ) . '</td> |
| 153 | + <td>' . Xml::input( 'target', 30, $this->mTarget, array( 'id' => 'target' ) ) . '</td> |
153 | 154 | </tr><tr> |
154 | | - <td>".Xml::label( wfMsg( 'mergehistory-into' ), 'dest' )."</td> |
155 | | - <td>".Xml::input( 'dest', 30, $this->mDest, array('id'=>'dest') )."</td> |
156 | | - </tr><tr><td>" . |
| 155 | + <td>' . Xml::label( wfMsg( 'mergehistory-into' ), 'dest' ) . '</td> |
| 156 | + <td>' . Xml::input( 'dest', 30, $this->mDest, array( 'id' => 'dest' ) ) . '</td> |
| 157 | + </tr><tr><td>' . |
157 | 158 | Xml::submitButton( wfMsg( 'mergehistory-go' ) ) . |
158 | | - "</td></tr>" . |
| 159 | + '</td></tr>' . |
159 | 160 | Xml::closeElement( 'table' ) . |
160 | 161 | '</fieldset>' . |
161 | | - '</form>' ); |
| 162 | + '</form>' |
| 163 | + ); |
162 | 164 | } |
163 | 165 | |
164 | 166 | private function showHistory() { |
— | — | @@ -165,18 +167,27 @@ |
166 | 168 | |
167 | 169 | $this->sk = $wgUser->getSkin(); |
168 | 170 | |
169 | | - $wgOut->setPagetitle( wfMsg( "mergehistory" ) ); |
| 171 | + $wgOut->setPageTitle( wfMsg( 'mergehistory' ) ); |
170 | 172 | |
171 | 173 | $this->showMergeForm(); |
172 | 174 | |
173 | 175 | # List all stored revisions |
174 | | - $revisions = new MergeHistoryPager( $this, array(), $this->mTargetObj, $this->mDestObj ); |
| 176 | + $revisions = new MergeHistoryPager( |
| 177 | + $this, array(), $this->mTargetObj, $this->mDestObj |
| 178 | + ); |
175 | 179 | $haveRevisions = $revisions && $revisions->getNumRows() > 0; |
176 | 180 | |
177 | 181 | $titleObj = $this->getTitle(); |
178 | 182 | $action = $titleObj->getLocalURL( array( 'action' => 'submit' ) ); |
179 | 183 | # Start the form here |
180 | | - $top = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'merge' ) ); |
| 184 | + $top = Xml::openElement( |
| 185 | + 'form', |
| 186 | + array( |
| 187 | + 'method' => 'post', |
| 188 | + 'action' => $action, |
| 189 | + 'id' => 'merge' |
| 190 | + ) |
| 191 | + ); |
181 | 192 | $wgOut->addHTML( $top ); |
182 | 193 | |
183 | 194 | if( $haveRevisions ) { |
— | — | @@ -184,43 +195,46 @@ |
185 | 196 | # in a nice little table |
186 | 197 | $table = |
187 | 198 | Xml::openElement( 'fieldset' ) . |
188 | | - wfMsgExt( 'mergehistory-merge', array('parseinline'), |
| 199 | + wfMsgExt( 'mergehistory-merge', array( 'parseinline' ), |
189 | 200 | $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText() ) . |
190 | 201 | Xml::openElement( 'table', array( 'id' => 'mw-mergehistory-table' ) ) . |
191 | | - "<tr> |
192 | | - <td class='mw-label'>" . |
| 202 | + '<tr> |
| 203 | + <td class="mw-label">' . |
193 | 204 | Xml::label( wfMsg( 'mergehistory-reason' ), 'wpComment' ) . |
194 | | - "</td> |
195 | | - <td class='mw-input'>" . |
196 | | - Xml::input( 'wpComment', 50, $this->mComment, array('id' => 'wpComment') ) . |
197 | | - "</td> |
| 205 | + '</td> |
| 206 | + <td class="mw-input">' . |
| 207 | + Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment' ) ) . |
| 208 | + '</td> |
198 | 209 | </tr> |
199 | 210 | <tr> |
200 | 211 | <td> </td> |
201 | | - <td class='mw-submit'>" . |
| 212 | + <td class="mw-submit">' . |
202 | 213 | Xml::submitButton( wfMsg( 'mergehistory-submit' ), array( 'name' => 'merge', 'id' => 'mw-merge-submit' ) ) . |
203 | | - "</td> |
204 | | - </tr>" . |
| 214 | + '</td> |
| 215 | + </tr>' . |
205 | 216 | Xml::closeElement( 'table' ) . |
206 | 217 | Xml::closeElement( 'fieldset' ); |
207 | 218 | |
208 | 219 | $wgOut->addHTML( $table ); |
209 | 220 | } |
210 | 221 | |
211 | | - $wgOut->addHTML( "<h2 id=\"mw-mergehistory\">" . wfMsgHtml( "mergehistory-list" ) . "</h2>\n" ); |
| 222 | + $wgOut->addHTML( |
| 223 | + '<h2 id="mw-mergehistory">' . |
| 224 | + wfMsgHtml( 'mergehistory-list' ) . "</h2>\n" |
| 225 | + ); |
212 | 226 | |
213 | 227 | if( $haveRevisions ) { |
214 | 228 | $wgOut->addHTML( $revisions->getNavigationBar() ); |
215 | | - $wgOut->addHTML( "<ul>" ); |
| 229 | + $wgOut->addHTML( '<ul>' ); |
216 | 230 | $wgOut->addHTML( $revisions->getBody() ); |
217 | | - $wgOut->addHTML( "</ul>" ); |
| 231 | + $wgOut->addHTML( '</ul>' ); |
218 | 232 | $wgOut->addHTML( $revisions->getNavigationBar() ); |
219 | 233 | } else { |
220 | | - $wgOut->addWikiMsg( "mergehistory-empty" ); |
| 234 | + $wgOut->addWikiMsg( 'mergehistory-empty' ); |
221 | 235 | } |
222 | 236 | |
223 | 237 | # Show relevant lines from the deletion log: |
224 | | - $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'merge' ) ) . "</h2>\n" ); |
| 238 | + $wgOut->addHTML( '<h2>' . htmlspecialchars( LogPage::logName( 'merge' ) ) . "</h2>\n" ); |
225 | 239 | LogEventsList::showLogExtract( $wgOut, 'merge', $this->mTargetObj->getPrefixedText() ); |
226 | 240 | |
227 | 241 | # When we submit, go by page ID to avoid some nasty but unlikely collisions. |
— | — | @@ -245,7 +259,7 @@ |
246 | 260 | $last = $this->message['last']; |
247 | 261 | |
248 | 262 | $ts = wfTimestamp( TS_MW, $row->rev_timestamp ); |
249 | | - $checkBox = Xml::radio( "mergepoint", $ts, false ); |
| 263 | + $checkBox = Xml::radio( 'mergepoint', $ts, false ); |
250 | 264 | |
251 | 265 | $pageLink = $this->sk->linkKnown( |
252 | 266 | $rev->getTitle(), |
— | — | @@ -258,9 +272,9 @@ |
259 | 273 | } |
260 | 274 | |
261 | 275 | # Last link |
262 | | - if( !$rev->userCan( Revision::DELETED_TEXT ) ) |
| 276 | + if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
263 | 277 | $last = $this->message['last']; |
264 | | - else if( isset($this->prevId[$row->rev_id]) ) |
| 278 | + } elseif( isset( $this->prevId[$row->rev_id] ) ) { |
265 | 279 | $last = $this->sk->linkKnown( |
266 | 280 | $rev->getTitle(), |
267 | 281 | $this->message['last'], |
— | — | @@ -270,10 +284,12 @@ |
271 | 285 | 'oldid' => $this->prevId[$row->rev_id] |
272 | 286 | ) |
273 | 287 | ); |
| 288 | + } |
274 | 289 | |
275 | 290 | $userLink = $this->sk->revUserTools( $rev ); |
276 | 291 | |
277 | | - if(!is_null($size = $row->rev_len)) { |
| 292 | + $size = $row->rev_len; |
| 293 | + if( !is_null( $size ) ) { |
278 | 294 | $stxt = $this->sk->formatRevisionSize( $size ); |
279 | 295 | } |
280 | 296 | $comment = $this->sk->revComment( $rev ); |
— | — | @@ -288,8 +304,9 @@ |
289 | 305 | function getPageLink( $row, $titleObj, $ts, $target ) { |
290 | 306 | global $wgLang; |
291 | 307 | |
292 | | - if( !$this->userCan($row, Revision::DELETED_TEXT) ) { |
293 | | - return '<span class="history-deleted">' . $wgLang->timeanddate( $ts, true ) . '</span>'; |
| 308 | + if( !$this->userCan( $row, Revision::DELETED_TEXT ) ) { |
| 309 | + return '<span class="history-deleted">' . |
| 310 | + $wgLang->timeanddate( $ts, true ) . '</span>'; |
294 | 311 | } else { |
295 | 312 | $link = $this->sk->linkKnown( |
296 | 313 | $titleObj, |
— | — | @@ -300,8 +317,9 @@ |
301 | 318 | 'timestamp' => $ts |
302 | 319 | ) |
303 | 320 | ); |
304 | | - if( $this->isDeleted($row, Revision::DELETED_TEXT) ) |
| 321 | + if( $this->isDeleted( $row, Revision::DELETED_TEXT ) ) { |
305 | 322 | $link = '<span class="history-deleted">' . $link . '</span>'; |
| 323 | + } |
306 | 324 | return $link; |
307 | 325 | } |
308 | 326 | } |
— | — | @@ -313,63 +331,80 @@ |
314 | 332 | # keep it consistent... |
315 | 333 | $targetTitle = Title::newFromID( $this->mTargetID ); |
316 | 334 | $destTitle = Title::newFromID( $this->mDestID ); |
317 | | - if( is_null($targetTitle) || is_null($destTitle) ) |
| 335 | + if( is_null( $targetTitle ) || is_null( $destTitle ) ) { |
318 | 336 | return false; // validate these |
319 | | - if( $targetTitle->getArticleId() == $destTitle->getArticleId() ) |
| 337 | + } |
| 338 | + if( $targetTitle->getArticleId() == $destTitle->getArticleId() ) { |
320 | 339 | return false; |
| 340 | + } |
321 | 341 | # Verify that this timestamp is valid |
322 | 342 | # Must be older than the destination page |
323 | 343 | $dbw = wfGetDB( DB_MASTER ); |
324 | 344 | # Get timestamp into DB format |
325 | | - $this->mTimestamp = $this->mTimestamp ? $dbw->timestamp($this->mTimestamp) : ''; |
| 345 | + $this->mTimestamp = $this->mTimestamp ? $dbw->timestamp( $this->mTimestamp ) : ''; |
326 | 346 | # Max timestamp should be min of destination page |
327 | | - $maxtimestamp = $dbw->selectField( 'revision', 'MIN(rev_timestamp)', |
328 | | - array('rev_page' => $this->mDestID ), |
329 | | - __METHOD__ ); |
| 347 | + $maxtimestamp = $dbw->selectField( |
| 348 | + 'revision', |
| 349 | + 'MIN(rev_timestamp)', |
| 350 | + array( 'rev_page' => $this->mDestID ), |
| 351 | + __METHOD__ |
| 352 | + ); |
330 | 353 | # Destination page must exist with revisions |
331 | 354 | if( !$maxtimestamp ) { |
332 | | - $wgOut->addWikiMsg('mergehistory-fail'); |
| 355 | + $wgOut->addWikiMsg( 'mergehistory-fail' ); |
333 | 356 | return false; |
334 | 357 | } |
335 | 358 | # Get the latest timestamp of the source |
336 | | - $lasttimestamp = $dbw->selectField( array('page','revision'), |
| 359 | + $lasttimestamp = $dbw->selectField( |
| 360 | + array( 'page', 'revision' ), |
337 | 361 | 'rev_timestamp', |
338 | | - array('page_id' => $this->mTargetID, 'page_latest = rev_id' ), |
339 | | - __METHOD__ ); |
| 362 | + array( 'page_id' => $this->mTargetID, 'page_latest = rev_id' ), |
| 363 | + __METHOD__ |
| 364 | + ); |
340 | 365 | # $this->mTimestamp must be older than $maxtimestamp |
341 | 366 | if( $this->mTimestamp >= $maxtimestamp ) { |
342 | | - $wgOut->addWikiMsg('mergehistory-fail'); |
| 367 | + $wgOut->addWikiMsg( 'mergehistory-fail' ); |
343 | 368 | return false; |
344 | 369 | } |
345 | 370 | # Update the revisions |
346 | 371 | if( $this->mTimestamp ) { |
347 | 372 | $timewhere = "rev_timestamp <= {$this->mTimestamp}"; |
348 | | - $TimestampLimit = wfTimestamp(TS_MW,$this->mTimestamp); |
| 373 | + $timestampLimit = wfTimestamp( TS_MW, $this->mTimestamp ); |
349 | 374 | } else { |
350 | 375 | $timewhere = "rev_timestamp <= {$maxtimestamp}"; |
351 | | - $TimestampLimit = wfTimestamp(TS_MW,$lasttimestamp); |
| 376 | + $timestampLimit = wfTimestamp( TS_MW, $lasttimestamp ); |
352 | 377 | } |
353 | 378 | # Do the moving... |
354 | | - $dbw->update( 'revision', |
| 379 | + $dbw->update( |
| 380 | + 'revision', |
355 | 381 | array( 'rev_page' => $this->mDestID ), |
356 | | - array( 'rev_page' => $this->mTargetID, |
357 | | - $timewhere ), |
358 | | - __METHOD__ ); |
| 382 | + array( 'rev_page' => $this->mTargetID, $timewhere ), |
| 383 | + __METHOD__ |
| 384 | + ); |
359 | 385 | |
360 | 386 | $count = $dbw->affectedRows(); |
361 | 387 | # Make the source page a redirect if no revisions are left |
362 | | - $haveRevisions = $dbw->selectField( 'revision', |
| 388 | + $haveRevisions = $dbw->selectField( |
| 389 | + 'revision', |
363 | 390 | 'rev_timestamp', |
364 | 391 | array( 'rev_page' => $this->mTargetID ), |
365 | 392 | __METHOD__, |
366 | | - array( 'FOR UPDATE' ) ); |
| 393 | + array( 'FOR UPDATE' ) |
| 394 | + ); |
367 | 395 | if( !$haveRevisions ) { |
368 | 396 | if( $this->mComment ) { |
369 | | - $comment = wfMsgForContent( 'mergehistory-comment', $targetTitle->getPrefixedText(), |
370 | | - $destTitle->getPrefixedText(), $this->mComment ); |
| 397 | + $comment = wfMsgForContent( |
| 398 | + 'mergehistory-comment', |
| 399 | + $targetTitle->getPrefixedText(), |
| 400 | + $destTitle->getPrefixedText(), |
| 401 | + $this->mComment |
| 402 | + ); |
371 | 403 | } else { |
372 | | - $comment = wfMsgForContent( 'mergehistory-autocomment', $targetTitle->getPrefixedText(), |
373 | | - $destTitle->getPrefixedText() ); |
| 404 | + $comment = wfMsgForContent( |
| 405 | + 'mergehistory-autocomment', |
| 406 | + $targetTitle->getPrefixedText(), |
| 407 | + $destTitle->getPrefixedText() |
| 408 | + ); |
374 | 409 | } |
375 | 410 | $mwRedir = MagicWord::get( 'redirect' ); |
376 | 411 | $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $destTitle->getPrefixedText() . "]]\n"; |
— | — | @@ -389,22 +424,26 @@ |
390 | 425 | 'pl_from' => $this->mDestID, |
391 | 426 | 'pl_namespace' => $destTitle->getNamespace(), |
392 | 427 | 'pl_title' => $destTitle->getDBkey() ), |
393 | | - __METHOD__ ); |
| 428 | + __METHOD__ |
| 429 | + ); |
394 | 430 | } else { |
395 | 431 | $targetTitle->invalidateCache(); // update histories |
396 | 432 | } |
397 | 433 | $destTitle->invalidateCache(); // update histories |
398 | 434 | # Check if this did anything |
399 | 435 | if( !$count ) { |
400 | | - $wgOut->addWikiMsg('mergehistory-fail'); |
| 436 | + $wgOut->addWikiMsg( 'mergehistory-fail' ); |
401 | 437 | return false; |
402 | 438 | } |
403 | 439 | # Update our logs |
404 | 440 | $log = new LogPage( 'merge' ); |
405 | | - $log->addEntry( 'merge', $targetTitle, $this->mComment, |
406 | | - array($destTitle->getPrefixedText(),$TimestampLimit) ); |
| 441 | + $log->addEntry( |
| 442 | + 'merge', $targetTitle, $this->mComment, |
| 443 | + array( $destTitle->getPrefixedText(), $timestampLimit ) |
| 444 | + ); |
407 | 445 | |
408 | | - $wgOut->addHTML( wfMsgExt( 'mergehistory-success', array('parseinline'), |
| 446 | + $wgOut->addHTML( |
| 447 | + wfMsgExt( 'mergehistory-success', array('parseinline'), |
409 | 448 | $targetTitle->getPrefixedText(), $destTitle->getPrefixedText(), $count ) ); |
410 | 449 | |
411 | 450 | wfRunHooks( 'ArticleMergeComplete', array( $targetTitle, $destTitle ) ); |
— | — | @@ -423,9 +462,12 @@ |
424 | 463 | $this->articleID = $source->getArticleID(); |
425 | 464 | |
426 | 465 | $dbr = wfGetDB( DB_SLAVE ); |
427 | | - $maxtimestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', |
428 | | - array('rev_page' => $dest->getArticleID() ), |
429 | | - __METHOD__ ); |
| 466 | + $maxtimestamp = $dbr->selectField( |
| 467 | + 'revision', |
| 468 | + 'MIN(rev_timestamp)', |
| 469 | + array( 'rev_page' => $dest->getArticleID() ), |
| 470 | + __METHOD__ |
| 471 | + ); |
430 | 472 | $this->maxTimestamp = $maxtimestamp; |
431 | 473 | |
432 | 474 | parent::__construct(); |
— | — | @@ -442,11 +484,12 @@ |
443 | 485 | $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_text ) ); |
444 | 486 | $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_text ) ); |
445 | 487 | |
446 | | - $rev_id = isset($rev_id) ? $rev_id : $row->rev_id; |
447 | | - if( $rev_id > $row->rev_id ) |
| 488 | + $rev_id = isset( $rev_id ) ? $rev_id : $row->rev_id; |
| 489 | + if( $rev_id > $row->rev_id ) { |
448 | 490 | $this->mForm->prevId[$rev_id] = $row->rev_id; |
449 | | - else if( $rev_id < $row->rev_id ) |
| 491 | + } elseif( $rev_id < $row->rev_id ) { |
450 | 492 | $this->mForm->prevId[$row->rev_id] = $rev_id; |
| 493 | + } |
451 | 494 | |
452 | 495 | $rev_id = $row->rev_id; |
453 | 496 | } |
— | — | @@ -468,9 +511,12 @@ |
469 | 512 | $conds[] = 'page_id = rev_page'; |
470 | 513 | $conds[] = "rev_timestamp < {$this->maxTimestamp}"; |
471 | 514 | return array( |
472 | | - 'tables' => array('revision','page'), |
473 | | - 'fields' => array( 'rev_minor_edit', 'rev_timestamp', 'rev_user', 'rev_user_text', 'rev_comment', |
474 | | - 'rev_id', 'rev_page', 'rev_parent_id', 'rev_text_id', 'rev_len', 'rev_deleted' ), |
| 515 | + 'tables' => array( 'revision', 'page' ), |
| 516 | + 'fields' => array( |
| 517 | + 'rev_minor_edit', 'rev_timestamp', 'rev_user', 'rev_user_text', |
| 518 | + 'rev_comment', 'rev_id', 'rev_page', 'rev_parent_id', |
| 519 | + 'rev_text_id', 'rev_len', 'rev_deleted' |
| 520 | + ), |
475 | 521 | 'conds' => $conds |
476 | 522 | ); |
477 | 523 | } |
Index: trunk/phase3/includes/Cookie.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | if ( isset( $attr['path'] ) ) { |
44 | 44 | $this->path = $attr['path']; |
45 | 45 | } else { |
46 | | - $this->path = "/"; |
| 46 | + $this->path = '/'; |
47 | 47 | } |
48 | 48 | |
49 | 49 | if ( isset( $attr['domain'] ) ) { |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | $this->domain = $attr['domain']; |
52 | 52 | } |
53 | 53 | } else { |
54 | | - throw new MWException( "You must specify a domain." ); |
| 54 | + throw new MWException( 'You must specify a domain.' ); |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | */ |
70 | 70 | public static function validateCookieDomain( $domain, $originDomain = null ) { |
71 | 71 | // Don't allow a trailing dot |
72 | | - if ( substr( $domain, -1 ) == "." ) { |
| 72 | + if ( substr( $domain, -1 ) == '.' ) { |
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | |
— | — | @@ -96,20 +96,20 @@ |
97 | 97 | || ( count( $dc ) == 3 && strlen( $dc[0] ) == "" && strlen( $dc[1] ) <= 2 ) ) { |
98 | 98 | return false; |
99 | 99 | } |
100 | | - if ( ( count( $dc ) == 2 || ( count( $dc ) == 3 && $dc[0] == "" ) ) |
| 100 | + if ( ( count( $dc ) == 2 || ( count( $dc ) == 3 && $dc[0] == '' ) ) |
101 | 101 | && preg_match( '/(com|net|org|gov|edu)\...$/', $domain ) ) { |
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | if ( $originDomain != null ) { |
107 | | - if ( substr( $domain, 0, 1 ) != "." && $domain != $originDomain ) { |
| 107 | + if ( substr( $domain, 0, 1 ) != '.' && $domain != $originDomain ) { |
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
111 | | - if ( substr( $domain, 0, 1 ) == "." |
| 111 | + if ( substr( $domain, 0, 1 ) == '.' |
112 | 112 | && substr_compare( $originDomain, $domain, -strlen( $domain ), |
113 | | - strlen( $domain ), TRUE ) != 0 ) { |
| 113 | + strlen( $domain ), true ) != 0 ) { |
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | } |
— | — | @@ -125,12 +125,12 @@ |
126 | 126 | * @return String |
127 | 127 | */ |
128 | 128 | public function serializeToHttpRequest( $path, $domain ) { |
129 | | - $ret = ""; |
| 129 | + $ret = ''; |
130 | 130 | |
131 | 131 | if ( $this->canServeDomain( $domain ) |
132 | 132 | && $this->canServePath( $path ) |
133 | 133 | && $this->isUnExpired() ) { |
134 | | - $ret = $this->name . "=" . $this->value; |
| 134 | + $ret = $this->name . '=' . $this->value; |
135 | 135 | } |
136 | 136 | |
137 | 137 | return $ret; |
— | — | @@ -139,9 +139,9 @@ |
140 | 140 | protected function canServeDomain( $domain ) { |
141 | 141 | if ( $domain == $this->domain |
142 | 142 | || ( strlen( $domain ) > strlen( $this->domain ) |
143 | | - && substr( $this->domain, 0, 1 ) == "." |
| 143 | + && substr( $this->domain, 0, 1 ) == '.' |
144 | 144 | && substr_compare( $domain, $this->domain, -strlen( $this->domain ), |
145 | | - strlen( $this->domain ), TRUE ) == 0 ) ) { |
| 145 | + strlen( $this->domain ), true ) == 0 ) ) { |
146 | 146 | return true; |
147 | 147 | } |
148 | 148 | |
— | — | @@ -199,7 +199,7 @@ |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | | - return implode( "; ", $cookies ); |
| 203 | + return implode( '; ', $cookies ); |
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
— | — | @@ -209,20 +209,20 @@ |
210 | 210 | * @param $domain String: cookie's domain |
211 | 211 | */ |
212 | 212 | public function parseCookieResponseHeader ( $cookie, $domain ) { |
213 | | - $len = strlen( "Set-Cookie:" ); |
| 213 | + $len = strlen( 'Set-Cookie:' ); |
214 | 214 | |
215 | | - if ( substr_compare( "Set-Cookie:", $cookie, 0, $len, TRUE ) === 0 ) { |
| 215 | + if ( substr_compare( 'Set-Cookie:', $cookie, 0, $len, true ) === 0 ) { |
216 | 216 | $cookie = substr( $cookie, $len ); |
217 | 217 | } |
218 | 218 | |
219 | | - $bit = array_map( 'trim', explode( ";", $cookie ) ); |
| 219 | + $bit = array_map( 'trim', explode( ';', $cookie ) ); |
220 | 220 | |
221 | 221 | if ( count( $bit ) >= 1 ) { |
222 | | - list( $name, $value ) = explode( "=", array_shift( $bit ), 2 ); |
| 222 | + list( $name, $value ) = explode( '=', array_shift( $bit ), 2 ); |
223 | 223 | $attr = array(); |
224 | 224 | |
225 | 225 | foreach ( $bit as $piece ) { |
226 | | - $parts = explode( "=", $piece ); |
| 226 | + $parts = explode( '=', $piece ); |
227 | 227 | if ( count( $parts ) > 1 ) { |
228 | 228 | $attr[strtolower( $parts[0] )] = $parts[1]; |
229 | 229 | } else { |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -35,7 +35,12 @@ |
36 | 36 | var $mTables; |
37 | 37 | // 'bidirectional' 'unidirectional' 'disable' for each variant |
38 | 38 | var $mManualLevel; |
| 39 | + |
| 40 | + /** |
| 41 | + * @var String: memcached key name |
| 42 | + */ |
39 | 43 | var $mCacheKey; |
| 44 | + |
40 | 45 | var $mLangObj; |
41 | 46 | var $mFlags; |
42 | 47 | var $mDescCodeSep = ':', $mDescVarSep = ';'; |
— | — | @@ -52,17 +57,15 @@ |
53 | 58 | /** |
54 | 59 | * Constructor |
55 | 60 | * |
56 | | - * @param $langobj Language The Language Object |
| 61 | + * @param $langobj Language: the Language Object |
57 | 62 | * @param $maincode String: the main language code of this language |
58 | 63 | * @param $variants Array: the supported variants of this language |
59 | 64 | * @param $variantfallbacks Array: the fallback language of each variant |
60 | 65 | * @param $flags Array: defining the custom strings that maps to the flags |
61 | 66 | * @param $manualLevel Array: limit for supported variants |
62 | 67 | */ |
63 | | - public function __construct( $langobj, $maincode, |
64 | | - $variants = array(), |
65 | | - $variantfallbacks = array(), |
66 | | - $flags = array(), |
| 68 | + public function __construct( $langobj, $maincode, $variants = array(), |
| 69 | + $variantfallbacks = array(), $flags = array(), |
67 | 70 | $manualLevel = array() ) { |
68 | 71 | global $wgDisabledVariants, $wgLanguageNames; |
69 | 72 | $this->mLangObj = $langobj; |
— | — | @@ -82,7 +85,7 @@ |
83 | 86 | 'D' => 'D', // convert description (subclass implement) |
84 | 87 | '-' => '-', // remove convert (not implement) |
85 | 88 | 'H' => 'H', // add rule for convert code |
86 | | - // (but no display in placed code ) |
| 89 | + // (but no display in placed code) |
87 | 90 | 'N' => 'N' // current variant name |
88 | 91 | ); |
89 | 92 | $this->mFlags = array_merge( $defaultflags, $flags ); |
— | — | @@ -143,9 +146,7 @@ |
144 | 147 | |
145 | 148 | if ( $wgUser->isLoggedIn() && !$req ) { |
146 | 149 | $req = $this->getUserVariant(); |
147 | | - } |
148 | | - |
149 | | - elseif ( !$req ) { |
| 150 | + } elseif ( !$req ) { |
150 | 151 | $req = $this->getHeaderVariant(); |
151 | 152 | } |
152 | 153 | |
— | — | @@ -189,8 +190,7 @@ |
190 | 191 | * @return Mixed: returns the variant if it is valid, null otherwise |
191 | 192 | */ |
192 | 193 | protected function validateVariant( $variant = null ) { |
193 | | - if ( $variant !== null && |
194 | | - in_array( $variant, $this->mVariants ) ) { |
| 194 | + if ( $variant !== null && in_array( $variant, $this->mVariants ) ) { |
195 | 195 | return $variant; |
196 | 196 | } |
197 | 197 | return null; |
— | — | @@ -227,17 +227,18 @@ |
228 | 228 | global $wgUser; |
229 | 229 | |
230 | 230 | // memoizing this function wreaks havoc on parserTest.php |
231 | | - /* if ( $this->mUserVariant ) { */ |
232 | | - /* return $this->mUserVariant; */ |
233 | | - /* } */ |
| 231 | + /* |
| 232 | + if ( $this->mUserVariant ) { |
| 233 | + return $this->mUserVariant; |
| 234 | + } |
| 235 | + */ |
234 | 236 | |
235 | | - // get language variant preference from logged in users |
| 237 | + // Get language variant preference from logged in users |
236 | 238 | // Don't call this on stub objects because that causes infinite |
237 | 239 | // recursion during initialisation |
238 | 240 | if ( $wgUser->isLoggedIn() ) { |
239 | 241 | $ret = $wgUser->getOption( 'variant' ); |
240 | | - } |
241 | | - else { |
| 242 | + } else { |
242 | 243 | // figure out user lang without constructing wgLang to avoid |
243 | 244 | // infinite recursion |
244 | 245 | $ret = $wgUser->getOption( 'language' ); |
— | — | @@ -259,13 +260,13 @@ |
260 | 261 | } |
261 | 262 | |
262 | 263 | // see if some supported language variant is set in the |
263 | | - // http header. |
| 264 | + // HTTP header. |
264 | 265 | $languages = array_keys( $wgRequest->getAcceptLang() ); |
265 | 266 | if ( empty( $languages ) ) { |
266 | 267 | return null; |
267 | 268 | } |
268 | 269 | |
269 | | - $fallback_languages = array(); |
| 270 | + $fallbackLanguages = array(); |
270 | 271 | foreach ( $languages as $language ) { |
271 | 272 | $this->mHeaderVariant = $this->validateVariant( $language ); |
272 | 273 | if ( $this->mHeaderVariant ) { |
— | — | @@ -277,18 +278,17 @@ |
278 | 279 | // them later. |
279 | 280 | $fallbacks = $this->getVariantFallbacks( $language ); |
280 | 281 | if ( is_string( $fallbacks ) ) { |
281 | | - $fallback_languages[] = $fallbacks; |
| 282 | + $fallbackLanguages[] = $fallbacks; |
282 | 283 | } elseif ( is_array( $fallbacks ) ) { |
283 | | - $fallback_languages = |
284 | | - array_merge( $fallback_languages, |
285 | | - $fallbacks ); |
| 284 | + $fallbackLanguages = |
| 285 | + array_merge( $fallbackLanguages, $fallbacks ); |
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | 289 | if ( !$this->mHeaderVariant ) { |
290 | 290 | // process fallback languages now |
291 | | - $fallback_languages = array_unique( $fallback_languages ); |
292 | | - foreach ( $fallback_languages as $language ) { |
| 291 | + $fallback_languages = array_unique( $fallbackLanguages ); |
| 292 | + foreach ( $fallbackLanguages as $language ) { |
293 | 293 | $this->mHeaderVariant = $this->validateVariant( $language ); |
294 | 294 | if ( $this->mHeaderVariant ) { |
295 | 295 | break; |
— | — | @@ -323,9 +323,9 @@ |
324 | 324 | } |
325 | 325 | |
326 | 326 | /* we convert everything except: |
327 | | - 1. html markups (anything between < and >) |
328 | | - 2. html entities |
329 | | - 3. place holders created by the parser |
| 327 | + 1. HTML markups (anything between < and >) |
| 328 | + 2. HTML entities |
| 329 | + 3. placeholders created by the parser |
330 | 330 | */ |
331 | 331 | global $wgParser; |
332 | 332 | if ( isset( $wgParser ) && $wgParser->UniqPrefix() != '' ) { |
— | — | @@ -334,7 +334,7 @@ |
335 | 335 | $marker = ''; |
336 | 336 | } |
337 | 337 | |
338 | | - // this one is needed when the text is inside an html markup |
| 338 | + // this one is needed when the text is inside an HTML markup |
339 | 339 | $htmlfix = '|<[^>]+$|^[^<>]*>'; |
340 | 340 | |
341 | 341 | // disable convert to variants between <code></code> tags |
— | — | @@ -372,7 +372,7 @@ |
373 | 373 | |
374 | 374 | // Translate any alt or title attributes inside the matched element |
375 | 375 | if ( $element !== '' && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element, |
376 | | - $elementMatches ) ) |
| 376 | + $elementMatches ) ) |
377 | 377 | { |
378 | 378 | $attrs = Sanitizer::decodeTagAttributes( $elementMatches[2] ); |
379 | 379 | $changed = false; |
— | — | @@ -517,8 +517,8 @@ |
518 | 518 | * Auto convert a Title object to a readable string in the |
519 | 519 | * preferred variant. |
520 | 520 | * |
521 | | - *@param $title Object: a object of Title |
522 | | - *@return String: converted title text |
| 521 | + * @param $title Object: a object of Title |
| 522 | + * @return String: converted title text |
523 | 523 | */ |
524 | 524 | public function convertTitle( $title ) { |
525 | 525 | $variant = $this->getPreferredVariant(); |
— | — | @@ -571,7 +571,9 @@ |
572 | 572 | */ |
573 | 573 | public function convertTo( $text, $variant ) { |
574 | 574 | global $wgDisableLangConversion; |
575 | | - if ( $wgDisableLangConversion ) return $text; |
| 575 | + if ( $wgDisableLangConversion ) { |
| 576 | + return $text; |
| 577 | + } |
576 | 578 | return $this->recursiveConvertTopLevel( $text, $variant ); |
577 | 579 | } |
578 | 580 | |
— | — | @@ -687,10 +689,9 @@ |
688 | 690 | } |
689 | 691 | |
690 | 692 | /** |
691 | | - * If a language supports multiple variants, it is |
692 | | - * possible that non-existing link in one variant |
693 | | - * actually exists in another variant. This function |
694 | | - * tries to find it. See e.g. LanguageZh.php |
| 693 | + * If a language supports multiple variants, it is possible that |
| 694 | + * non-existing link in one variant actually exists in another variant. |
| 695 | + * This function tries to find it. See e.g. LanguageZh.php |
695 | 696 | * |
696 | 697 | * @param $link String: the name of the link |
697 | 698 | * @param $nt Mixed: the title object of the link |
— | — | @@ -764,7 +765,7 @@ |
765 | 766 | */ |
766 | 767 | public function getExtraHashOptions() { |
767 | 768 | $variant = $this->getPreferredVariant(); |
768 | | - return '!' . $variant ; |
| 769 | + return '!' . $variant; |
769 | 770 | } |
770 | 771 | |
771 | 772 | /** |
— | — | @@ -781,8 +782,9 @@ |
782 | 783 | /** |
783 | 784 | * Load conversion tables either from the cache or the disk. |
784 | 785 | * @private |
| 786 | + * @param $fromCache Boolean: load from memcached? Defaults to true. |
785 | 787 | */ |
786 | | - function loadTables( $fromcache = true ) { |
| 788 | + function loadTables( $fromCache = true ) { |
787 | 789 | if ( $this->mTablesLoaded ) { |
788 | 790 | return; |
789 | 791 | } |
— | — | @@ -790,7 +792,7 @@ |
791 | 793 | wfProfileIn( __METHOD__ ); |
792 | 794 | $this->mTablesLoaded = true; |
793 | 795 | $this->mTables = false; |
794 | | - if ( $fromcache ) { |
| 796 | + if ( $fromCache ) { |
795 | 797 | wfProfileIn( __METHOD__ . '-cache' ); |
796 | 798 | $this->mTables = $wgMemc->get( $this->mCacheKey ); |
797 | 799 | wfProfileOut( __METHOD__ . '-cache' ); |
— | — | @@ -799,8 +801,8 @@ |
800 | 802 | || !array_key_exists( self::CACHE_VERSION_KEY, $this->mTables ) ) { |
801 | 803 | wfProfileIn( __METHOD__ . '-recache' ); |
802 | 804 | // not in cache, or we need a fresh reload. |
803 | | - // we will first load the default tables |
804 | | - // then update them using things in MediaWiki:Zhconversiontable/* |
| 805 | + // We will first load the default tables |
| 806 | + // then update them using things in MediaWiki:Conversiontable/* |
805 | 807 | $this->loadDefaultTables(); |
806 | 808 | foreach ( $this->mVariants as $var ) { |
807 | 809 | $cached = $this->parseCachedTable( $var ); |
— | — | @@ -817,8 +819,7 @@ |
818 | 820 | } |
819 | 821 | |
820 | 822 | /** |
821 | | - * Hook for post processig after conversion tables are loaded. |
822 | | - * |
| 823 | + * Hook for post processing after conversion tables are loaded. |
823 | 824 | */ |
824 | 825 | function postLoadTables() { } |
825 | 826 | |
— | — | @@ -835,7 +836,6 @@ |
836 | 837 | $this->loadTables( false ); |
837 | 838 | } |
838 | 839 | |
839 | | - |
840 | 840 | /** |
841 | 841 | * Parse the conversion table stored in the cache. |
842 | 842 | * |
— | — | @@ -846,9 +846,12 @@ |
847 | 847 | * ... |
848 | 848 | * }- |
849 | 849 | * |
850 | | - * To make the tables more manageable, subpages are allowed |
851 | | - * and will be parsed recursively if $recursive == true. |
| 850 | + * To make the tables more manageable, subpages are allowed |
| 851 | + * and will be parsed recursively if $recursive == true. |
852 | 852 | * |
| 853 | + * @param $code String: language code |
| 854 | + * @param $subpage String: subpage name |
| 855 | + * @param $recursive Boolean: parse subpages recursively? Defaults to true. |
853 | 856 | */ |
854 | 857 | function parseCachedTable( $code, $subpage = '', $recursive = true ) { |
855 | 858 | static $parsed = array(); |
— | — | @@ -869,8 +872,10 @@ |
870 | 873 | $txt = '<Conversiontable>'; |
871 | 874 | } |
872 | 875 | } else { |
873 | | - $title = Title::makeTitleSafe( NS_MEDIAWIKI, |
874 | | - "Conversiontable/$code" ); |
| 876 | + $title = Title::makeTitleSafe( |
| 877 | + NS_MEDIAWIKI, |
| 878 | + "Conversiontable/$code" |
| 879 | + ); |
875 | 880 | if ( $title && $title->exists() ) { |
876 | 881 | $article = new Article( $title ); |
877 | 882 | $txt = $article->getContents(); |
— | — | @@ -880,7 +885,7 @@ |
881 | 886 | } |
882 | 887 | |
883 | 888 | // get all subpage links of the form |
884 | | - // [[MediaWiki:conversiontable/zh-xx/...|...]] |
| 889 | + // [[MediaWiki:Conversiontable/zh-xx/...|...]] |
885 | 890 | $linkhead = $this->mLangObj->getNsText( NS_MEDIAWIKI ) . |
886 | 891 | ':Conversiontable'; |
887 | 892 | $subs = StringUtils::explode( '[[', $txt ); |
— | — | @@ -919,8 +924,9 @@ |
920 | 925 | $table = StringUtils::explode( ';', $stripped ); |
921 | 926 | foreach ( $table as $t ) { |
922 | 927 | $m = explode( '=>', $t, 3 ); |
923 | | - if ( count( $m ) != 2 ) |
| 928 | + if ( count( $m ) != 2 ) { |
924 | 929 | continue; |
| 930 | + } |
925 | 931 | // trim any trailling comments starting with '//' |
926 | 932 | $tt = explode( '//', $m[1], 2 ); |
927 | 933 | $ret[trim( $m[0] )] = trim( $tt[0] ); |
— | — | @@ -949,7 +955,7 @@ |
950 | 956 | * various functions in the Parser. |
951 | 957 | * |
952 | 958 | * @param $text String: text to be tagged for no conversion |
953 | | - * @param $noParse Unused (?) |
| 959 | + * @param $noParse Boolean: unused |
954 | 960 | * @return String: the tagged text |
955 | 961 | */ |
956 | 962 | public function markNoConversion( $text, $noParse = false ) { |
— | — | @@ -972,11 +978,22 @@ |
973 | 979 | |
974 | 980 | /** |
975 | 981 | * Hook to refresh the cache of conversion tables when |
976 | | - * MediaWiki:conversiontable* is updated. |
| 982 | + * MediaWiki:Conversiontable* is updated. |
977 | 983 | * @private |
| 984 | + * |
| 985 | + * @param $article Object: Article object |
| 986 | + * @param $user Object: User object for the current user |
| 987 | + * @param $text String: article text (?) |
| 988 | + * @param $summary String: edit summary of the edit |
| 989 | + * @param $isMinor Boolean: was the edit marked as minor? |
| 990 | + * @param $isWatch Boolean: did the user watch this page or not? |
| 991 | + * @param $section Unused |
| 992 | + * @param $flags Bitfield |
| 993 | + * @param $revision Object: new Revision object or null |
| 994 | + * @return Boolean: true |
978 | 995 | */ |
979 | | - function OnArticleSaveComplete( $article, $user, $text, $summary, $isminor, |
980 | | - $iswatch, $section, $flags, $revision ) { |
| 996 | + function OnArticleSaveComplete( $article, $user, $text, $summary, $isMinor, |
| 997 | + $isWatch, $section, $flags, $revision ) { |
981 | 998 | $titleobj = $article->getTitle(); |
982 | 999 | if ( $titleobj->getNamespace() == NS_MEDIAWIKI ) { |
983 | 1000 | $title = $titleobj->getDBkey(); |
— | — | @@ -993,7 +1010,11 @@ |
994 | 1011 | |
995 | 1012 | /** |
996 | 1013 | * Armour rendered math against conversion. |
997 | | - * Escape special chars in parsed math text.(in most cases are img elements) |
| 1014 | + * Escape special chars in parsed math text. (in most cases are img elements) |
| 1015 | + * |
| 1016 | + * @param $text String: text to armour against conversion |
| 1017 | + * @return String: armoured text where { and } have been converted to |
| 1018 | + * { and } |
998 | 1019 | */ |
999 | 1020 | public function armourMath( $text ) { |
1000 | 1021 | // convert '-{' and '}-' to '-{' and '}-' to prevent |
— | — | @@ -1295,7 +1316,7 @@ |
1296 | 1317 | } |
1297 | 1318 | $vmarked[] = $v; |
1298 | 1319 | } |
1299 | | - /*for unidirectional array fill to convert tables */ |
| 1320 | + /* for unidirectional array fill to convert tables */ |
1300 | 1321 | if ( ( $manLevel[$v] == 'bidirectional' || $manLevel[$v] == 'unidirectional' ) |
1301 | 1322 | && isset( $unidtable[$v] ) ) |
1302 | 1323 | { |
— | — | @@ -1310,9 +1331,9 @@ |
1311 | 1332 | |
1312 | 1333 | /** |
1313 | 1334 | * Parse rules and flags. |
1314 | | - * @public |
| 1335 | + * @param $variant String: variant language code |
1315 | 1336 | */ |
1316 | | - function parse( $variant = NULL ) { |
| 1337 | + public function parse( $variant = null ) { |
1317 | 1338 | if ( !$variant ) { |
1318 | 1339 | $variant = $this->mConverter->getPreferredVariant(); |
1319 | 1340 | } |
— | — | @@ -1415,58 +1436,52 @@ |
1416 | 1437 | } |
1417 | 1438 | |
1418 | 1439 | /** |
1419 | | - * @public |
| 1440 | + * @todo FIXME: code this function :) |
1420 | 1441 | */ |
1421 | | - function hasRules() { |
| 1442 | + public function hasRules() { |
1422 | 1443 | // TODO: |
1423 | 1444 | } |
1424 | 1445 | |
1425 | 1446 | /** |
1426 | 1447 | * Get display text on markup -{...}- |
1427 | | - * @public |
1428 | 1448 | */ |
1429 | | - function getDisplay() { |
| 1449 | + public function getDisplay() { |
1430 | 1450 | return $this->mRuleDisplay; |
1431 | 1451 | } |
1432 | 1452 | |
1433 | 1453 | /** |
1434 | 1454 | * Get converted title. |
1435 | | - * @public |
1436 | 1455 | */ |
1437 | | - function getTitle() { |
| 1456 | + public function getTitle() { |
1438 | 1457 | return $this->mRuleTitle; |
1439 | 1458 | } |
1440 | 1459 | |
1441 | 1460 | /** |
1442 | 1461 | * Return how deal with conversion rules. |
1443 | | - * @public |
1444 | 1462 | */ |
1445 | | - function getRulesAction() { |
| 1463 | + public function getRulesAction() { |
1446 | 1464 | return $this->mRulesAction; |
1447 | 1465 | } |
1448 | 1466 | |
1449 | 1467 | /** |
1450 | | - * Get conversion table. ( bidirectional and unidirectional |
1451 | | - * conversion table ) |
1452 | | - * @public |
| 1468 | + * Get conversion table. (bidirectional and unidirectional |
| 1469 | + * conversion table) |
1453 | 1470 | */ |
1454 | | - function getConvTable() { |
| 1471 | + public function getConvTable() { |
1455 | 1472 | return $this->mConvTable; |
1456 | 1473 | } |
1457 | 1474 | |
1458 | 1475 | /** |
1459 | 1476 | * Get conversion rules string. |
1460 | | - * @public |
1461 | 1477 | */ |
1462 | | - function getRules() { |
| 1478 | + public function getRules() { |
1463 | 1479 | return $this->mRules; |
1464 | 1480 | } |
1465 | 1481 | |
1466 | 1482 | /** |
1467 | 1483 | * Get conversion flags. |
1468 | | - * @public |
1469 | 1484 | */ |
1470 | | - function getFlags() { |
| 1485 | + public function getFlags() { |
1471 | 1486 | return $this->mFlags; |
1472 | 1487 | } |
1473 | 1488 | } |