r64583 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64582‎ | r64583 | r64584 >
Date:23:03, 3 April 2010
Author:siebrand
Status:deferred
Tags:
Comment:
stylize.php, trailing whitespace removed, superfluous newlines removed, indentation updated
Modified paths:
  • /trunk/extensions/APC/APCCacheMode.php (modified) (history)
  • /trunk/extensions/APC/APCHostMode.php (modified) (history)
  • /trunk/extensions/APC/APCImages.php (modified) (history)
  • /trunk/extensions/APC/APCUtils.php (modified) (history)
  • /trunk/extensions/APC/SpecialAPC.php (modified) (history)
  • /trunk/extensions/APC/ViewAPC.php (modified) (history)
  • /trunk/extensions/APC/apc.css (modified) (history)

Diff [purge]

Index: trunk/extensions/APC/APCImages.php
@@ -1,7 +1,6 @@
22 <?php
33
44 class APCImages {
5 -
65 const IMG_NONE = 0;
76 const IMG_MEM_USAGE = 1;
87 const IMG_HITS = 2;
@@ -12,85 +11,84 @@
1312 // create graphics
1413 //
1514 public static function graphics_avail() {
16 - return extension_loaded('gd');
 15+ return extension_loaded( 'gd' );
1716 }
1817
19 - public static function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$color2,$text='',$placeindex=0) {
20 - $r=$diameter/2;
21 - $w=deg2rad((360+$start+($end-$start)/2)%360);
 18+ public static function fill_arc( $im, $centerX, $centerY, $diameter, $start, $end, $color1, $color2, $text = '', $placeindex = 0 ) {
 19+ $r = $diameter / 2;
 20+ $w = deg2rad( ( 360 + $start + ( $end - $start ) / 2 ) % 360 );
2221
23 -
24 - if (function_exists("imagefilledarc")) {
 22+ if ( function_exists( "imagefilledarc" ) ) {
2523 // exists only if GD 2.0.1 is avaliable
26 - imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
27 - imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
28 - imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED);
 24+ imagefilledarc( $im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE );
 25+ imagefilledarc( $im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE );
 26+ imagefilledarc( $im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL | IMG_ARC_EDGED );
2927 } else {
30 - imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
31 - imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
32 - imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
33 - imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
34 - imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
35 - imagefill($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2, $color2);
 28+ imagearc( $im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2 );
 29+ imageline( $im, $centerX, $centerY, $centerX + cos( deg2rad( $start ) ) * $r, $centerY + sin( deg2rad( $start ) ) * $r, $color2 );
 30+ imageline( $im, $centerX, $centerY, $centerX + cos( deg2rad( $start + 1 ) ) * $r, $centerY + sin( deg2rad( $start ) ) * $r, $color2 );
 31+ imageline( $im, $centerX, $centerY, $centerX + cos( deg2rad( $end - 1 ) ) * $r, $centerY + sin( deg2rad( $end ) ) * $r, $color2 );
 32+ imageline( $im, $centerX, $centerY, $centerX + cos( deg2rad( $end ) ) * $r, $centerY + sin( deg2rad( $end ) ) * $r, $color2 );
 33+ imagefill( $im, $centerX + $r * cos( $w ) / 2, $centerY + $r * sin( $w ) / 2, $color2 );
3634 }
37 - if ($text) {
38 - if ($placeindex>0) {
39 - imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
40 - imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
 35+ if ( $text ) {
 36+ if ( $placeindex > 0 ) {
 37+ imageline( $im, $centerX + $r * cos( $w ) / 2, $centerY + $r * sin( $w ) / 2, $diameter, $placeindex * 12, $color1 );
 38+ imagestring( $im, 4, $diameter, $placeindex * 12, $text, $color1 );
4139
4240 } else {
43 - imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
 41+ imagestring( $im, 4, $centerX + $r * cos( $w ) / 2, $centerY + $r * sin( $w ) / 2, $text, $color1 );
4442 }
4543 }
4644 }
4745
48 - public static function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$text,$placeindex=0) {
49 - $r=$diameter/2;
50 - $w=deg2rad((360+$start+($end-$start)/2)%360);
 46+ public static function text_arc( $im, $centerX, $centerY, $diameter, $start, $end, $color1, $text, $placeindex = 0 ) {
 47+ $r = $diameter / 2;
 48+ $w = deg2rad( ( 360 + $start + ( $end - $start ) / 2 ) % 360 );
5149
52 - if ($placeindex>0) {
53 - imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
54 - imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
 50+ if ( $placeindex > 0 ) {
 51+ imageline( $im, $centerX + $r * cos( $w ) / 2, $centerY + $r * sin( $w ) / 2, $diameter, $placeindex * 12, $color1 );
 52+ imagestring( $im, 4, $diameter, $placeindex * 12, $text, $color1 );
5553
5654 } else {
57 - imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
 55+ imagestring( $im, 4, $centerX + $r * cos( $w ) / 2, $centerY + $r * sin( $w ) / 2, $text, $color1 );
5856 }
5957 }
6058
61 - public static function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
 59+ public static function fill_box( $im, $x, $y, $w, $h, $color1, $color2, $text = '', $placeindex = '' ) {
6260 global $col_black;
63 - $x1=$x+$w-1;
64 - $y1=$y+$h-1;
 61+ $x1 = $x + $w - 1;
 62+ $y1 = $y + $h - 1;
6563
66 - imagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black);
67 - if($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);
68 - else imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);
69 - imagerectangle($im, $x, $y1, $x1, $y, $color1);
70 - if ($text) {
71 - if ($placeindex>0) {
 64+ imagerectangle( $im, $x, $y1, $x1 + 1, $y + 1, $col_black );
 65+ if ( $y1 > $y ) imagefilledrectangle( $im, $x, $y, $x1, $y1, $color2 );
 66+ else imagefilledrectangle( $im, $x, $y1, $x1, $y, $color2 );
 67+ imagerectangle( $im, $x, $y1, $x1, $y, $color1 );
 68+ if ( $text ) {
 69+ if ( $placeindex > 0 ) {
7270
73 - if ($placeindex<16)
 71+ if ( $placeindex < 16 )
7472 {
75 - $px=5;
76 - $py=$placeindex*12+6;
77 - imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);
78 - imageline($im,$x,$y+$h/2,$px+90,$py,$color2);
79 - imagestring($im,2,$px,$py-6,$text,$color1);
 73+ $px = 5;
 74+ $py = $placeindex * 12 + 6;
 75+ imagefilledrectangle( $im, $px + 90, $py + 3, $px + 90 - 4, $py - 3, $color2 );
 76+ imageline( $im, $x, $y + $h / 2, $px + 90, $py, $color2 );
 77+ imagestring( $im, 2, $px, $py - 6, $text, $color1 );
8078
8179 } else {
82 - if ($placeindex<31) {
83 - $px=$x+40*2;
84 - $py=($placeindex-15)*12+6;
 80+ if ( $placeindex < 31 ) {
 81+ $px = $x + 40 * 2;
 82+ $py = ( $placeindex - 15 ) * 12 + 6;
8583 } else {
86 - $px=$x+40*2+100*intval(($placeindex-15)/15);
87 - $py=($placeindex%15)*12+6;
 84+ $px = $x + 40 * 2 + 100 * intval( ( $placeindex - 15 ) / 15 );
 85+ $py = ( $placeindex % 15 ) * 12 + 6;
8886 }
89 - imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);
90 - imageline($im,$x+$w,$y+$h/2,$px,$py,$color2);
91 - imagestring($im,2,$px+2,$py-6,$text,$color1);
 87+ imagefilledrectangle( $im, $px, $py + 3, $px - 4, $py - 3, $color2 );
 88+ imageline( $im, $x + $w, $y + $h / 2, $px, $py, $color2 );
 89+ imagestring( $im, 2, $px + 2, $py - 6, $text, $color1 );
9290 }
9391 } else {
94 - imagestring($im,4,$x+5,$y1-16,$text,$color1);
 92+ imagestring( $im, 4, $x + 5, $y1 - 16, $text, $color1 );
9593 }
9694 }
9795 }
@@ -102,118 +100,118 @@
103101 $cache = apc_cache_info( 'opcode' );
104102
105103 $size = self::GRAPH_SIZE; // image size
106 - if ($type==self::IMG_FRAGMENTATION)
107 - $image = imagecreate(2*$size+150, $size+10);
 104+ if ( $type == self::IMG_FRAGMENTATION )
 105+ $image = imagecreate( 2 * $size + 150, $size + 10 );
108106 else
109 - $image = imagecreate($size+10, $size+10);
 107+ $image = imagecreate( $size + 10, $size + 10 );
110108
111 - $col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
112 - $col_red = imagecolorallocate($image, 0xD0, 0x60, 0x30);
113 - $col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);
114 - $col_black = imagecolorallocate($image, 0, 0, 0);
115 - imagecolortransparent($image,$col_white);
 109+ $col_white = imagecolorallocate( $image, 0xFF, 0xFF, 0xFF );
 110+ $col_red = imagecolorallocate( $image, 0xD0, 0x60, 0x30 );
 111+ $col_green = imagecolorallocate( $image, 0x60, 0xF0, 0x60 );
 112+ $col_black = imagecolorallocate( $image, 0, 0, 0 );
 113+ imagecolortransparent( $image, $col_white );
116114
117 - switch ($type) {
 115+ switch ( $type ) {
118116
119117 case 1:
120 - $s=$mem['num_seg']*$mem['seg_size'];
121 - $a=$mem['avail_mem'];
122 - $x=$y=$size/2;
 118+ $s = $mem['num_seg'] * $mem['seg_size'];
 119+ $a = $mem['avail_mem'];
 120+ $x = $y = $size / 2;
123121 $fuzz = 0.000001;
124122
125123 // This block of code creates the pie chart. It is a lot more complex than you
126124 // would expect because we try to visualize any memory fragmentation as well.
127125 $angle_from = 0;
128 - $string_placement=array();
129 - for($i=0; $i<$mem['num_seg']; $i++) {
 126+ $string_placement = array();
 127+ for ( $i = 0; $i < $mem['num_seg']; $i++ ) {
130128 $ptr = 0;
131129 $free = $mem['block_lists'][$i];
132 - foreach($free as $block) {
133 - if($block['offset']!=$ptr) { // Used block
134 - $angle_to = $angle_from+($block['offset']-$ptr)/$s;
135 - if(($angle_to+$fuzz)>1) $angle_to = 1;
136 - self::fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
137 - if (($angle_to-$angle_from)>0.05) {
138 - array_push($string_placement, array($angle_from,$angle_to));
 130+ foreach ( $free as $block ) {
 131+ if ( $block['offset'] != $ptr ) { // Used block
 132+ $angle_to = $angle_from + ( $block['offset'] - $ptr ) / $s;
 133+ if ( ( $angle_to + $fuzz ) > 1 ) $angle_to = 1;
 134+ self::fill_arc( $image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red );
 135+ if ( ( $angle_to - $angle_from ) > 0.05 ) {
 136+ array_push( $string_placement, array( $angle_from, $angle_to ) );
139137 }
140138 $angle_from = $angle_to;
141139 }
142 - $angle_to = $angle_from+($block['size'])/$s;
143 - if(($angle_to+$fuzz)>1) $angle_to = 1;
144 - self::fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_green);
145 - if (($angle_to-$angle_from)>0.05) {
146 - array_push($string_placement, array($angle_from,$angle_to));
 140+ $angle_to = $angle_from + ( $block['size'] ) / $s;
 141+ if ( ( $angle_to + $fuzz ) > 1 ) $angle_to = 1;
 142+ self::fill_arc( $image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_green );
 143+ if ( ( $angle_to - $angle_from ) > 0.05 ) {
 144+ array_push( $string_placement, array( $angle_from, $angle_to ) );
147145 }
148146 $angle_from = $angle_to;
149 - $ptr = $block['offset']+$block['size'];
 147+ $ptr = $block['offset'] + $block['size'];
150148 }
151 - if ($ptr < $mem['seg_size']) { // memory at the end
152 - $angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s;
153 - if(($angle_to+$fuzz)>1) $angle_to = 1;
154 - self::fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
155 - if (($angle_to-$angle_from)>0.05) {
156 - array_push($string_placement, array($angle_from,$angle_to));
 149+ if ( $ptr < $mem['seg_size'] ) { // memory at the end
 150+ $angle_to = $angle_from + ( $mem['seg_size'] - $ptr ) / $s;
 151+ if ( ( $angle_to + $fuzz ) > 1 ) $angle_to = 1;
 152+ self::fill_arc( $image, $x, $y, $size, $angle_from * 360, $angle_to * 360, $col_black, $col_red );
 153+ if ( ( $angle_to - $angle_from ) > 0.05 ) {
 154+ array_push( $string_placement, array( $angle_from, $angle_to ) );
157155 }
158156 }
159157 }
160 - foreach ($string_placement as $angle) {
161 - self::text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,$wgLang->formatSize($s*($angle[1]-$angle[0])));
 158+ foreach ( $string_placement as $angle ) {
 159+ self::text_arc( $image, $x, $y, $size, $angle[0] * 360, $angle[1] * 360, $col_black, $wgLang->formatSize( $s * ( $angle[1] - $angle[0] ) ) );
162160 }
163161 break;
164162
165163 case 2:
166 - $s=$cache['num_hits']+$cache['num_misses'];
167 - $a=$cache['num_hits'];
 164+ $s = $cache['num_hits'] + $cache['num_misses'];
 165+ $a = $cache['num_hits'];
168166
169 - self::fill_box($image, 30,$size,50,-$a*($size-21)/$s,$col_black,$col_green,sprintf("%.1f%%",$cache['num_hits']*100/$s));
170 - self::fill_box($image,130,$size,50,-max(4,($s-$a)*($size-21)/$s),$col_black,$col_red,sprintf("%.1f%%",$cache['num_misses']*100/$s));
 167+ self::fill_box( $image, 30, $size, 50, - $a * ( $size - 21 ) / $s, $col_black, $col_green, sprintf( "%.1f%%", $cache['num_hits'] * 100 / $s ) );
 168+ self::fill_box( $image, 130, $size, 50, - max( 4, ( $s - $a ) * ( $size - 21 ) / $s ), $col_black, $col_red, sprintf( "%.1f%%", $cache['num_misses'] * 100 / $s ) );
171169 break;
172170
173171 case 3:
174 - $s=$mem['num_seg']*$mem['seg_size'];
175 - $a=$mem['avail_mem'];
176 - $x=130;
177 - $y=1;
178 - $j=1;
 172+ $s = $mem['num_seg'] * $mem['seg_size'];
 173+ $a = $mem['avail_mem'];
 174+ $x = 130;
 175+ $y = 1;
 176+ $j = 1;
179177
180178 // This block of code creates the bar chart. It is a lot more complex than you
181179 // would expect because we try to visualize any memory fragmentation as well.
182 - for($i=0; $i<$mem['num_seg']; $i++) {
 180+ for ( $i = 0; $i < $mem['num_seg']; $i++ ) {
183181 $ptr = 0;
184182 $free = $mem['block_lists'][$i];
185 - foreach($free as $block) {
186 - if($block['offset']!=$ptr) { // Used block
187 - $h=(self::GRAPH_SIZE-5)*($block['offset']-$ptr)/$s;
188 - if ($h>0) {
 183+ foreach ( $free as $block ) {
 184+ if ( $block['offset'] != $ptr ) { // Used block
 185+ $h = ( self::GRAPH_SIZE - 5 ) * ( $block['offset'] - $ptr ) / $s;
 186+ if ( $h > 0 ) {
189187 $j++;
190 - if($j<75) self::fill_box($image,$x,$y,50,$h,$col_black,$col_red,$wgLang->formatSize($block['offset']-$ptr),$j);
191 - else self::fill_box($image,$x,$y,50,$h,$col_black,$col_red);
 188+ if ( $j < 75 ) self::fill_box( $image, $x, $y, 50, $h, $col_black, $col_red, $wgLang->formatSize( $block['offset'] - $ptr ), $j );
 189+ else self::fill_box( $image, $x, $y, 50, $h, $col_black, $col_red );
192190 }
193 - $y+=$h;
 191+ $y += $h;
194192 }
195 - $h=(self::GRAPH_SIZE-5)*($block['size'])/$s;
196 - if ($h>0) {
 193+ $h = ( self::GRAPH_SIZE - 5 ) * ( $block['size'] ) / $s;
 194+ if ( $h > 0 ) {
197195 $j++;
198 - if($j<75) self::fill_box($image,$x,$y,50,$h,$col_black,$col_green,$wgLang->formatSize($block['size']),$j);
199 - else self::fill_box($image,$x,$y,50,$h,$col_black,$col_green);
 196+ if ( $j < 75 ) self::fill_box( $image, $x, $y, 50, $h, $col_black, $col_green, $wgLang->formatSize( $block['size'] ), $j );
 197+ else self::fill_box( $image, $x, $y, 50, $h, $col_black, $col_green );
200198 }
201 - $y+=$h;
202 - $ptr = $block['offset']+$block['size'];
 199+ $y += $h;
 200+ $ptr = $block['offset'] + $block['size'];
203201 }
204 - if ($ptr < $mem['seg_size']) { // memory at the end
205 - $h = (self::GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s;
206 - if ($h > 0) {
207 - self::fill_box($image,$x,$y,50,$h,$col_black,$col_red,$wgLang->formatSize($mem['seg_size']-$ptr),$j++);
 202+ if ( $ptr < $mem['seg_size'] ) { // memory at the end
 203+ $h = ( self::GRAPH_SIZE - 5 ) * ( $mem['seg_size'] - $ptr ) / $s;
 204+ if ( $h > 0 ) {
 205+ self::fill_box( $image, $x, $y, 50, $h, $col_black, $col_red, $wgLang->formatSize( $mem['seg_size'] - $ptr ), $j++ );
208206 }
209207 }
210208 }
211209 break;
212210 case 4:
213 - $s=$cache['num_hits']+$cache['num_misses'];
214 - $a=$cache['num_hits'];
 211+ $s = $cache['num_hits'] + $cache['num_misses'];
 212+ $a = $cache['num_hits'];
215213
216 - self::fill_box($image, 30,$size,50,-$a*($size-21)/$s,$col_black,$col_green,sprintf("%.1f%%",$cache['num_hits']*100/$s));
217 - self::fill_box($image,130,$size,50,-max(4,($s-$a)*($size-21)/$s),$col_black,$col_red,sprintf("%.1f%%",$cache['num_misses']*100/$s));
 214+ self::fill_box( $image, 30, $size, 50, - $a * ( $size - 21 ) / $s, $col_black, $col_green, sprintf( "%.1f%%", $cache['num_hits'] * 100 / $s ) );
 215+ self::fill_box( $image, 130, $size, 50, - max( 4, ( $s - $a ) * ( $size - 21 ) / $s ), $col_black, $col_red, sprintf( "%.1f%%", $cache['num_misses'] * 100 / $s ) );
218216 break;
219217
220218 }
Index: trunk/extensions/APC/APCCacheMode.php
@@ -1,9 +1,7 @@
22 <?php
33
44 class APCCacheMode {
5 -
65 protected $opts, $title;
7 -
86 protected $userMode = false;
97 protected $fieldKey;
108
@@ -11,7 +9,7 @@
1210 $this->opts = $opts;
1311 $this->title = $title;
1412 $this->userMode = $opts->getValue( 'mode' ) === SpecialAPC::MODE_USER_CACHE;
15 - $this->fieldKey = $this->userMode ? 'info' : (ini_get('apc.stat') ? 'inode' : 'filename');
 13+ $this->fieldKey = $this->userMode ? 'info' : ( ini_get( 'apc.stat' ) ? 'inode' : 'filename' );
1614 }
1715
1816 protected $scopes = array(
@@ -27,22 +25,22 @@
2826 $s =
2927 Xml::openElement( 'div', array( 'class' => 'mw-apc-listing' ) ) .
3028 Xml::openElement( 'table' ) . Xml::openElement( 'tbody' ) .
31 - Xml::openElement( 'tr' ).
 29+ Xml::openElement( 'tr' ) .
3230 Xml::element( 'th', null, wfMsg( 'viewapc-display-attribute' ) ) .
3331 Xml::element( 'th', null, wfMsg( 'viewapc-display-value' ) ) .
3432 Xml::closeElement( 'tr' );
3533
3634 $r = 1;
37 - foreach( $this->scopes as $list ) {
38 - foreach( $cache[$list] as $entry ) {
39 - if (md5($entry[$this->fieldKey]) !== $object) continue;
 35+ foreach ( $this->scopes as $list ) {
 36+ foreach ( $cache[$list] as $entry ) {
 37+ if ( md5( $entry[$this->fieldKey] ) !== $object ) continue;
4038
4139 $size = 0;
42 - foreach($entry as $key => $value) {
43 - switch ($key) {
 40+ foreach ( $entry as $key => $value ) {
 41+ switch ( $key ) {
4442 case 'num_hits':
4543 $value = $wgLang->formatNum( $value ) .
46 - $wgLang->formatNum( sprintf(" (%.2f%%)", $value*100/$cache['num_hits'] ) );
 44+ $wgLang->formatNum( sprintf( " (%.2f%%)", $value * 100 / $cache['num_hits'] ) );
4745 break;
4846 case 'deletion_time':
4947 $value = $this->formatValue( $key, $value );
@@ -56,20 +54,20 @@
5755 $value = $this->formatValue( $key, $value );
5856 }
5957
60 - $s .= APCUtils::tableRow( $r=1-$r,
 58+ $s .= APCUtils::tableRow( $r = 1 - $r,
6159 wfMsgHtml( 'viewapc-display-' . $key ),
6260 htmlspecialchars( $value ) );
6361
6462 }
6563
6664 if ( $this->userMode ) {
67 - if ( $size > 1024*1024 ) {
68 - $s .= APCUtils::tableRow( $r=1-$r,
 65+ if ( $size > 1024 * 1024 ) {
 66+ $s .= APCUtils::tableRow( $r = 1 - $r,
6967 wfMsgHtml( 'viewapc-display-stored-value' ),
7068 wfMsgExt( 'viewapc-display-too-big', 'parseinline' ) );
7169 } else {
72 - $value = var_export(apc_fetch($entry[$this->fieldKey]),true);
73 - $s .= APCUtils::tableRow( $r=1-$r,
 70+ $value = var_export( apc_fetch( $entry[$this->fieldKey] ), true );
 71+ $s .= APCUtils::tableRow( $r = 1 - $r,
7472 wfMsgHtml( 'viewapc-display-stored-value' ),
7573 Xml::element( 'pre', null, $value ) );
7674 }
@@ -115,7 +113,7 @@
116114 break;
117115 }
118116 return $value;
119 -}
 117+ }
120118
121119 public function cacheView() {
122120 global $wgOut, $wgLang;
@@ -154,7 +152,7 @@
155153 foreach ( $fields as $field ) {
156154 $extra = array();
157155 if ( $sort === $field ) {
158 - $extra = array( 'sortdir' => 1-$sortdir );
 156+ $extra = array( 'sortdir' => 1 - $sortdir );
159157 }
160158
161159 $wgOut->addHTML(
@@ -171,7 +169,7 @@
172170 if ( $scope === 'active' || $scope === 'both' ) {
173171 foreach ( $cache['cache_list'] as $entry ) {
174172 if ( $search && stripos( $entry[$fieldKeys['name']], $search ) === false ) continue;
175 - $sortValue = sprintf('%015d-', $entry[$fieldKeys[$sort]]);
 173+ $sortValue = sprintf( '%015d-', $entry[$fieldKeys[$sort]] );
176174 $list[$sortValue . $entry[$fieldKeys['name']]] = $entry;
177175 }
178176 }
@@ -179,7 +177,7 @@
180178 if ( $scope === 'deleted' || $scope === 'both' ) {
181179 foreach ( $cache['deleted_list'] as $entry ) {
182180 if ( $search && stripos( $entry[$fieldKeys['name']], $search ) === false ) continue;
183 - $sortValue = sprintf('%015d-', $entry[$fieldKeys[$sort]]);
 181+ $sortValue = sprintf( '%015d-', $entry[$fieldKeys[$sort]] );
184182 $list[$sortValue . $entry[$fieldKeys['name']]] = $entry;
185183 }
186184 }
@@ -187,13 +185,13 @@
188186 $sortdir ? krsort( $list ) : ksort( $list );
189187
190188 $i = 0;
191 - if ( count($list) ) {
 189+ if ( count( $list ) ) {
192190 $r = 1;
193191
194192 foreach ( $list as $name => $entry ) {
195193 if ( $limit === $i++ ) break;
196194 $wgOut->addHTML(
197 - Xml::openElement( 'tr', array( 'class' => 'mw-apc-tr-' . ($r=1-$r) ) )
 195+ Xml::openElement( 'tr', array( 'class' => 'mw-apc-tr-' . ( $r = 1 - $r ) ) )
198196 );
199197
200198 foreach ( $fields as $field ) {
@@ -201,12 +199,12 @@
202200 if ( $field === 'name' ) {
203201 if ( !$this->userMode ) {
204202 $pos = strrpos( $entry[$index], '/' );
205 - if ( $pos !== false ) $value = substr( $entry[$index], $pos+1 );
 203+ if ( $pos !== false ) $value = substr( $entry[$index], $pos + 1 );
206204 } else {
207205 $value = $entry[$index];
208206 }
209 - $value = $this->sortHeader( htmlspecialchars($value), array( 'display' => md5($entry[$this->fieldKey]) ) );
210 - } elseif( $field === 'deleted' && $this->userMode && !$entry[$index] ) {
 207+ $value = $this->sortHeader( htmlspecialchars( $value ), array( 'display' => md5( $entry[$this->fieldKey] ) ) );
 208+ } elseif ( $field === 'deleted' && $this->userMode && !$entry[$index] ) {
211209 $value = $this->sortHeader(
212210 wfMsgHtml( 'viewapc-ls-delete' ),
213211 array( 'delete' => $entry[$this->fieldKey] )
@@ -222,15 +220,15 @@
223221 }
224222 }
225223
226 - if ( $i < count($list) ) {
227 - $left = $wgLang->formatNum( count($list) - ($i+$offset) );
 224+ if ( $i < count( $list ) ) {
 225+ $left = $wgLang->formatNum( count( $list ) - ( $i + $offset ) );
228226 $wgOut->addHTML(
229227 Xml::tags( 'tr', array( 'colspan' => count( $fields ) ),
230228 Xml::tags( 'td', null, $this->sortHeader(
231229 wfMsgExt( 'viewapc-ls-more', 'parseinline', $left ),
232 - array( 'offset' => $offset+$limit ) ) ) )
 230+ array( 'offset' => $offset + $limit ) ) ) )
233231 );
234 - } elseif ( !count($list) ) {
 232+ } elseif ( !count( $list ) ) {
235233 $wgOut->addHTML(
236234 Xml::tags( 'tr', array( 'colspan' => count( $fields ) ),
237235 Xml::tags( 'td', null, wfMsgExt( 'viewapc-ls-nodata', 'parseinline' ) ) )
Index: trunk/extensions/APC/ViewAPC.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44 /**
55 * An extension to allow access to APC status with MediaWiki rights
66 *
@@ -18,7 +18,7 @@
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:APC',
2020 );
2121
22 -$dir = dirname(__FILE__) . '/';
 22+$dir = dirname( __FILE__ ) . '/';
2323 $wgAutoloadClasses['SpecialAPC'] = $dir . 'SpecialAPC.php';
2424 $wgAutoloadClasses['APCImages'] = $dir . 'APCImages.php';
2525 $wgAutoloadClasses['APCUtils'] = $dir . 'APCUtils.php';
Index: trunk/extensions/APC/APCUtils.php
@@ -1,7 +1,6 @@
22 <?php
33
44 class APCUtils {
5 -
65 public static function tableRow( $class, $first, $second = null ) {
76 $class = $class !== null ? array( 'class' => 'mw-apc-tr-' . $class ) : null;
87
Index: trunk/extensions/APC/SpecialAPC.php
@@ -1,7 +1,6 @@
22 <?php
33
44 class SpecialAPC extends SpecialPage {
5 -
65 const GRAPH_SIZE = 200;
76
87 // Stored objects
@@ -25,7 +24,6 @@
2625 // Bind to the member variable
2726 $this->opts = $opts;
2827
29 -
3028 $opts->add( 'mode', self::MODE_STATS );
3129 $opts->add( 'image', APCImages::IMG_NONE );
3230 $opts->add( 'clearcache', false );
@@ -36,7 +34,7 @@
3735 $opts->add( 'sort', 'hits' );
3836 $opts->add( 'sortdir', 0 );
3937 $opts->add( 'scope', 'active' );
40 - $opts->add( 'searchi', ''); // MediaWiki captures search, ARGH!
 38+ $opts->add( 'searchi', '' ); // MediaWiki captures search, ARGH!
4139
4240 $opts->fetchValuesFromRequest( $wgRequest );
4341 $opts->validateIntBounds( 'limit', 0, 5000 );
@@ -51,31 +49,28 @@
5250 $this->setHeaders();
5351 $this->setup();
5452
55 -
56 - if( !function_exists('apc_cache_info')) {
 53+ if ( !function_exists( 'apc_cache_info' ) ) {
5754 $wgOut->addWikiMsg( 'viewapc-apc-not-available' );
5855 return;
5956 }
6057
61 - if ( $this->opts->getValue('image') ) {
 58+ if ( $this->opts->getValue( 'image' ) ) {
6259 $wgOut->disable();
63 - header('Content-type: image/png');
64 - echo APCImages::generateImage( $this->opts->getValue('image') );
 60+ header( 'Content-type: image/png' );
 61+ echo APCImages::generateImage( $this->opts->getValue( 'image' ) );
6562 return;
6663 }
6764
68 - if ( $this->opts->getValue('mode') !== self::MODE_STATS ) {
 65+ if ( $this->opts->getValue( 'mode' ) !== self::MODE_STATS ) {
6966 if ( !$wgUser->isAllowed( 'apc' ) ) {
7067 $wgOut->permissionRequired( 'apc' );
7168 return;
7269 }
7370 }
7471
75 -
76 -
7772 // clear cache
7873 if ( $this->opts->getValue( 'clearcache' ) ) {
79 - $this->opts->setValue( 'clearcache', '' ); //TODO: reset
 74+ $this->opts->setValue( 'clearcache', '' ); // TODO: reset
8075 if ( !$wgUser->isAllowed( 'apc' ) ) {
8176 $wgOut->permissionRequired( 'apc' );
8277 return;
@@ -92,7 +87,7 @@
9388
9489 $delete = $this->opts->getValue( 'delete' );
9590 if ( $delete ) {
96 - $this->opts->setValue( 'delete', '' ); //TODO: reset
 91+ $this->opts->setValue( 'delete', '' ); // TODO: reset
9792 if ( !$wgUser->isAllowed( 'apc' ) ) {
9893 $wgOut->permissionRequired( 'apc' );
9994 return;
@@ -105,7 +100,6 @@
106101 }
107102 }
108103
109 -
110104 $dir = dirname( __FILE__ );
111105 $wgOut->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css',
112106 'href' => "$wgScriptPath/extensions/APC/apc.css?$wgStyleVersion", )
@@ -144,7 +138,7 @@
145139 global $wgOut;
146140
147141 $logo =
148 - Xml::wrapClass( Xml::element( 'a', array( 'href' => self::APCURL) , 'APC' ), 'mw-apc-logo' ) .
 142+ Xml::wrapClass( Xml::element( 'a', array( 'href' => self::APCURL ) , 'APC' ), 'mw-apc-logo' ) .
149143 Xml::wrapClass( 'Opcode Cache', 'mw-apc-nameinfo' );
150144
151145 $wgOut->addHTML(
@@ -177,17 +171,15 @@
178172 Xml::openElement( 'ol', array( 'class' => 'mw-apc-menu' ) ) .
179173 $this->menuItem( self::MODE_STATS, wfMsgExt( 'viewapc-mode-stats', 'escape' ) ) .
180174 $this->menuItem( self::MODE_SYSTEM_CACHE, wfMsgExt( 'viewapc-mode-system-cache', 'escape' ) ) .
181 - //$this->menuItem( self::MODE_SYSTEM_CACHE_DIR, wfMsgExt( 'viewapc-mode-system-cache-dir', 'escape' )) .
182 - $this->menuItem( self::MODE_USER_CACHE, wfMsgExt( 'viewapc-mode-user-cache', 'escape' )).
183 - $this->menuItem( self::MODE_VERSION_CHECK, wfMsgExt( 'viewapc-mode-version-check', 'escape' )) .
 175+ // $this->menuItem( self::MODE_SYSTEM_CACHE_DIR, wfMsgExt( 'viewapc-mode-system-cache-dir', 'escape' )) .
 176+ $this->menuItem( self::MODE_USER_CACHE, wfMsgExt( 'viewapc-mode-user-cache', 'escape' ) ) .
 177+ $this->menuItem( self::MODE_VERSION_CHECK, wfMsgExt( 'viewapc-mode-version-check', 'escape' ) ) .
184178 Xml::tags( 'li', null,
185179 $this->selfLink2( $clearText, $clearParams ) ) .
186180 Xml::closeElement( 'ol' )
187181 );
188182 }
189183
190 -
191 -
192184 protected function doObHostStats() {
193185 global $wgOut, $wgLang;
194186
@@ -203,21 +195,20 @@
204196 APCHostMode::doGeneralInfoTable( $cache, $mem ) .
205197 APCHostMode::doMemoryInfoTable( $cache, $mem, $this->title ) . $clear .
206198 APCHostMode::doCacheTable( $cache ) .
207 - APCHostMode::doCacheTable( apc_cache_info('user', 1), true ) . $clear .
 199+ APCHostMode::doCacheTable( apc_cache_info( 'user', 1 ), true ) . $clear .
208200 APCHostMode::doRuntimeInfoTable( $mem ) .
209201 APCHostMode::doFragmentationTable( $mem, $this->title ) . $clear
210202 );
211203
212204 }
213205
214 -
215206 protected function doPage() {
216207 global $wgOut;
217208 $wgOut->addHTML(
218209 Xml::openElement( 'div', array( 'class' => 'mw-apc-content' ) )
219210 );
220211
221 - switch ( $this->opts->getValue('mode') ) {
 212+ switch ( $this->opts->getValue( 'mode' ) ) {
222213 case self::MODE_STATS:
223214 $this->doObHostStats();
224215 break;
@@ -243,13 +234,13 @@
244235 );
245236
246237 $rss = Http::get( 'http://pecl.php.net/feeds/pkg_apc.rss' );
247 - if (!$rss) {
 238+ if ( !$rss ) {
248239 $wgOut->addWikiMsg( 'viewapc-version-failed' );
249240 } else {
250 - $apcversion = phpversion('apc');
 241+ $apcversion = phpversion( 'apc' );
251242
252 - preg_match('!<title>APC ([0-9.]+)</title>!', $rss, $match);
253 - if (version_compare($apcversion, $match[1], '>=')) {
 243+ preg_match( '!<title>APC ([0-9.]+)</title>!', $rss, $match );
 244+ if ( version_compare( $apcversion, $match[1], '>=' ) ) {
254245 $wgOut->addWikiMsg( 'viewapc-version-ok', $apcversion );
255246 $i = 3;
256247 } else {
@@ -262,19 +253,19 @@
263254 );
264255
265256
266 - preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match);
267 - next($match[2]); next($match[2]);
 257+ preg_match_all( '!<(title|description)>([^<]+)</\\1>!', $rss, $match );
 258+ next( $match[2] ); next( $match[2] );
268259
269 - while (list(,$v) = each($match[2])) {
270 - list(,$ver) = explode(' ', $v, 2);
271 - if ($i < 0 && version_compare($apcversion, $ver, '>=')) {
 260+ while ( list( , $v ) = each( $match[2] ) ) {
 261+ list( , $ver ) = explode( ' ', $v, 2 );
 262+ if ( $i < 0 && version_compare( $apcversion, $ver, '>=' ) ) {
272263 break;
273 - } else if (!$i--) {
 264+ } else if ( !$i-- ) {
274265 break;
275266 }
276 - $data = current($match[2]);
 267+ $data = current( $match[2] );
277268 $wgOut->addWikiText( "''[http://pecl.php.net/package/APC/$ver $v]''<br /><pre>$data</pre>" );
278 - next($match[2]);
 269+ next( $match[2] );
279270 }
280271 }
281272 }
Index: trunk/extensions/APC/apc.css
@@ -87,4 +87,4 @@
8888 margin-right:1em;
8989 }
9090 span.green { background:#60F060; padding:0 0.5em 0 0.5em}
91 -span.red { background:#D06030; padding:0 0.5em 0 0.5em }
\ No newline at end of file
 91+span.red { background:#D06030; padding:0 0.5em 0 0.5em }
Index: trunk/extensions/APC/APCHostMode.php
@@ -1,28 +1,27 @@
22 <?php
33
44 class APCHostMode {
5 -
65 public static function doGeneralInfoTable( $c, $mem ) {
76 global $wgLang;
87 $r = 1;
98 return
109 APCUtils::tableHeader( wfMsg( 'viewapc-info-general' ) ) .
11 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-apc-version' ), phpversion('apc') ) .
12 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-php-version' ), phpversion() ) .
 10+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-apc-version' ), phpversion( 'apc' ) ) .
 11+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-php-version' ), phpversion() ) .
1312
14 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-shared-memory' ),
 13+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-shared-memory' ),
1514 wfMsgExt( 'viewapc-shared-memory-details', 'parsemag',
1615 $wgLang->formatNum( $mem['num_seg'] ),
1716 $wgLang->formatSize( $mem['seg_size'] ),
1817 $c['memory_type'], $c['locking_type'] ) ) .
1918
20 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-start-time' ),
 19+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-start-time' ),
2120 $wgLang->timeanddate( $c['start_time'] ) ) .
2221
23 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-uptime' ),
 22+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-uptime' ),
2423 $wgLang->formatTimePeriod( time() - $c['start_time'] ) ) .
2524
26 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-upload-support' ), $c['file_upload_progress'] ) .
 25+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-upload-support' ), $c['file_upload_progress'] ) .
2726 APCUtils::tableFooter();
2827 }
2928
@@ -32,13 +31,13 @@
3332 // Calculate rates
3433 $numHits = $wgLang->formatNum( $c['num_hits'] );
3534 $numMiss = $wgLang->formatNum( $c['num_misses'] );
36 - $numReqs = $c['num_hits']+$c['num_misses'];
37 - $cPeriod = time()-$c['start_time'];
 35+ $numReqs = $c['num_hits'] + $c['num_misses'];
 36+ $cPeriod = time() - $c['start_time'];
3837 if ( !$cPeriod ) $cPeriod = 1;
3938 $rateReqs = APCUtils::formatReqPerS( $numReqs / $cPeriod );
4039 $rateHits = APCUtils::formatReqPerS( $c['num_hits'] / $cPeriod );
4140 $rateMiss = APCUtils::formatReqPerS( $c['num_misses'] / $cPeriod );
42 - $rateInsert= APCUtils::formatReqPerS( $c['num_inserts'] / $cPeriod );
 41+ $rateInsert = APCUtils::formatReqPerS( $c['num_inserts'] / $cPeriod );
4342
4443 $cachedFiles = wfMsgExt( 'viewapc-cached-files-d', 'parsemag',
4544 $wgLang->formatNum( $c['num_entries'] ),
@@ -49,14 +48,14 @@
5049
5150 return
5251 APCUtils::tableHeader( $contentType ) .
53 - APCUtils::tableRow( $r=0, wfMsgHtml( 'viewapc-cached-files' ), $cachedFiles ) .
54 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-hits' ), $numHits ) .
55 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-misses' ), $numMiss ) .
56 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-requests' ), $rateReqs ) .
57 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-hitrate' ), $rateHits ) .
58 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-missrate' ), $rateMiss ) .
59 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-insertrate' ), $rateInsert ) .
60 - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-cachefull' ), $cacheFullCount ) .
 52+ APCUtils::tableRow( $r = 0, wfMsgHtml( 'viewapc-cached-files' ), $cachedFiles ) .
 53+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-hits' ), $numHits ) .
 54+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-misses' ), $numMiss ) .
 55+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-requests' ), $rateReqs ) .
 56+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-hitrate' ), $rateHits ) .
 57+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-missrate' ), $rateMiss ) .
 58+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-insertrate' ), $rateInsert ) .
 59+ APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-cachefull' ), $cacheFullCount ) .
6160 APCUtils::tableFooter();
6261 }
6362
@@ -64,10 +63,10 @@
6564 $s = APCUtils::tableHeader( wfMsg( 'viewapc-info-runtime' ) );
6665
6766 $r = 1;
68 - foreach (ini_get_all('apc') as $k => $v) {
69 - $s .= APCUtils::tableRow( $r=1-$r,
 67+ foreach ( ini_get_all( 'apc' ) as $k => $v ) {
 68+ $s .= APCUtils::tableRow( $r = 1 - $r,
7069 htmlspecialchars( $k ),
71 - str_replace(',',',<br />', htmlspecialchars($v['local_value']) ) );
 70+ str_replace( ',', ',<br />', htmlspecialchars( $v['local_value'] ) ) );
7271 }
7372
7473 $s .= APCUtils::tableFooter();
@@ -79,7 +78,7 @@
8079
8180 $s = APCUtils::tableHeader( wfMsg( 'viewapc-info-memory' ), 'mw-apc-img-table' );
8281
83 - if ( $mem['num_seg'] > 1 || $mem['num_seg'] == 1 && count($mem['block_lists'][0]) > 1 ) {
 82+ if ( $mem['num_seg'] > 1 || $mem['num_seg'] == 1 && count( $mem['block_lists'][0] ) > 1 ) {
8483 $memHeader = wfMsgExt( 'viewapc-memory-usage-detailed', 'parseinline' );
8584 } else {
8685 $memHeader = wfMsgExt( 'viewapc-memory-usage', 'parseinline' );
@@ -92,8 +91,8 @@
9392 if ( APCImages::graphics_avail() ) {
9493 $attribs = array(
9594 'alt' => '',
96 - 'width' => APCImages::GRAPH_SIZE+10,
97 - 'height' => APCImages::GRAPH_SIZE+10,
 95+ 'width' => APCImages::GRAPH_SIZE + 10,
 96+ 'height' => APCImages::GRAPH_SIZE + 10,
9897 );
9998
10099 $param1 = wfArrayToCGI( array( 'image' => APCImages::IMG_MEM_USAGE ) );
@@ -111,11 +110,11 @@
112111
113112 $freeMem = wfMsgExt( 'viewapc-memory-free', 'parseinline',
114113 $wgLang->formatSize( $free ),
115 - $wgLang->formatNum( sprintf('%.1f%%', $free*100/$size) ) );
 114+ $wgLang->formatNum( sprintf( '%.1f%%', $free * 100 / $size ) ) );
116115
117116 $usedMem = wfMsgExt( 'viewapc-memory-used', 'parseinline',
118117 $wgLang->formatSize( $used ),
119 - $wgLang->formatNum( sprintf('%.1f%%', $used*100/$size) ) );
 118+ $wgLang->formatNum( sprintf( '%.1f%%', $used * 100 / $size ) ) );
120119
121120 $hits = $c['num_hits'];
122121 $miss = $c['num_misses'];
@@ -126,11 +125,11 @@
127126
128127 $memHits = wfMsgExt( 'viewapc-memory-hits', 'parseinline',
129128 $wgLang->formatNum( $hits ),
130 - $wgLang->formatNum( @sprintf('%.1f%%', $hits*100/$reqs) ) );
 129+ $wgLang->formatNum( @sprintf( '%.1f%%', $hits * 100 / $reqs ) ) );
131130
132131 $memMiss = wfMsgExt( 'viewapc-memory-miss', 'parseinline',
133132 $wgLang->formatNum( $miss ),
134 - $wgLang->formatNum( @sprintf('%.1f%%', $miss*100/$reqs) ) );
 133+ $wgLang->formatNum( @sprintf( '%.1f%%', $miss * 100 / $reqs ) ) );
135134
136135 $s .= APCUtils::tableRow( null, $greenbox . $freeMem, $greenbox . $memHits );
137136 $s .= APCUtils::tableRow( null, $redbox . $usedMem, $redbox . $memMiss );
@@ -146,35 +145,35 @@
147146
148147 // Fragementation: (freeseg - 1) / total_seg
149148 $nseg = $freeseg = $fragsize = $freetotal = 0;
150 - for( $i = 0; $i < $mem['num_seg']; $i++ ) {
 149+ for ( $i = 0; $i < $mem['num_seg']; $i++ ) {
151150 $ptr = 0;
152 - foreach( $mem['block_lists'][$i] as $block ) {
 151+ foreach ( $mem['block_lists'][$i] as $block ) {
153152 if ( $block['offset'] != $ptr ) {
154153 ++$nseg;
155154 }
156155 $ptr = $block['offset'] + $block['size'];
157156 /* Only consider blocks <5M for the fragmentation % */
158 - if( $block['size'] < (5*1024*1024) ) $fragsize += $block['size'];
 157+ if ( $block['size'] < ( 5 * 1024 * 1024 ) ) $fragsize += $block['size'];
159158 $freetotal += $block['size'];
160159 }
161 - $freeseg += count($mem['block_lists'][$i]);
 160+ $freeseg += count( $mem['block_lists'][$i] );
162161 }
163162
164163
165 - if (APCImages::graphics_avail()) {
 164+ if ( APCImages::graphics_avail() ) {
166165 $attribs = array(
167166 'alt' => '',
168 - 'width' => 2*APCImages::GRAPH_SIZE+150,
169 - 'height' => APCImages::GRAPH_SIZE+10,
170 - 'src' => $title->getLocalURL( 'image=' . APCImages::IMG_FRAGMENTATION)
 167+ 'width' => 2 * APCImages::GRAPH_SIZE + 150,
 168+ 'height' => APCImages::GRAPH_SIZE + 10,
 169+ 'src' => $title->getLocalURL( 'image=' . APCImages::IMG_FRAGMENTATION )
171170 );
172171 $s .= Xml::element( 'img', $attribs );
173172 }
174173
175 - if ($freeseg > 1) {
176 - $fragPercent = sprintf( '%.2f%%', ($fragsize/$freetotal)*100 );
 174+ if ( $freeseg > 1 ) {
 175+ $fragPercent = sprintf( '%.2f%%', ( $fragsize / $freetotal ) * 100 );
177176 $s .= wfMsgExt( 'viewapc-fragmentation-info', 'parse',
178 - $wgLang->formatNum( $fragPercent, true),
 177+ $wgLang->formatNum( $fragPercent, true ),
179178 $wgLang->formatSize( $fragsize ),
180179 $wgLang->formatSize( $freetotal ),
181180 $wgLang->formatNum( $freeseg )
@@ -185,10 +184,10 @@
186185
187186 $s .= Xml::closeElement( 'td' ) . Xml::closeElement( 'tr' );
188187
189 - if(isset($mem['adist'])) {
190 - foreach($mem['adist'] as $i=>$v) {
191 - $cur = pow(2,$i); $nxt = pow(2,$i+1)-1;
192 - if($i==0) $range = "1";
 188+ if ( isset( $mem['adist'] ) ) {
 189+ foreach ( $mem['adist'] as $i => $v ) {
 190+ $cur = pow( 2, $i ); $nxt = pow( 2, $i + 1 ) - 1;
 191+ if ( $i == 0 ) $range = "1";
193192 else $range = "$cur - $nxt";
194193 $s .= Xml::tags( 'tr', null,
195194 Xml::tags( 'th', array( 'align' => 'right' ), $range ) .

Status & tagging log