Index: trunk/extensions/APC/APCImages.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class APCImages { |
5 | | - |
6 | 5 | const IMG_NONE = 0; |
7 | 6 | const IMG_MEM_USAGE = 1; |
8 | 7 | const IMG_HITS = 2; |
— | — | @@ -12,85 +11,84 @@ |
13 | 12 | // create graphics |
14 | 13 | // |
15 | 14 | public static function graphics_avail() { |
16 | | - return extension_loaded('gd'); |
| 15 | + return extension_loaded( 'gd' ); |
17 | 16 | } |
18 | 17 | |
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 ); |
22 | 21 | |
23 | | - |
24 | | - if (function_exists("imagefilledarc")) { |
| 22 | + if ( function_exists( "imagefilledarc" ) ) { |
25 | 23 | // 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 ); |
29 | 27 | } 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 ); |
36 | 34 | } |
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 ); |
41 | 39 | |
42 | 40 | } 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 ); |
44 | 42 | } |
45 | 43 | } |
46 | 44 | } |
47 | 45 | |
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 ); |
51 | 49 | |
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 ); |
55 | 53 | |
56 | 54 | } 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 ); |
58 | 56 | } |
59 | 57 | } |
60 | 58 | |
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 = '' ) { |
62 | 60 | global $col_black; |
63 | | - $x1=$x+$w-1; |
64 | | - $y1=$y+$h-1; |
| 61 | + $x1 = $x + $w - 1; |
| 62 | + $y1 = $y + $h - 1; |
65 | 63 | |
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 ) { |
72 | 70 | |
73 | | - if ($placeindex<16) |
| 71 | + if ( $placeindex < 16 ) |
74 | 72 | { |
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 ); |
80 | 78 | |
81 | 79 | } 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; |
85 | 83 | } 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; |
88 | 86 | } |
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 ); |
92 | 90 | } |
93 | 91 | } else { |
94 | | - imagestring($im,4,$x+5,$y1-16,$text,$color1); |
| 92 | + imagestring( $im, 4, $x + 5, $y1 - 16, $text, $color1 ); |
95 | 93 | } |
96 | 94 | } |
97 | 95 | } |
— | — | @@ -102,118 +100,118 @@ |
103 | 101 | $cache = apc_cache_info( 'opcode' ); |
104 | 102 | |
105 | 103 | $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 ); |
108 | 106 | else |
109 | | - $image = imagecreate($size+10, $size+10); |
| 107 | + $image = imagecreate( $size + 10, $size + 10 ); |
110 | 108 | |
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 ); |
116 | 114 | |
117 | | - switch ($type) { |
| 115 | + switch ( $type ) { |
118 | 116 | |
119 | 117 | 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; |
123 | 121 | $fuzz = 0.000001; |
124 | 122 | |
125 | 123 | // This block of code creates the pie chart. It is a lot more complex than you |
126 | 124 | // would expect because we try to visualize any memory fragmentation as well. |
127 | 125 | $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++ ) { |
130 | 128 | $ptr = 0; |
131 | 129 | $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 ) ); |
139 | 137 | } |
140 | 138 | $angle_from = $angle_to; |
141 | 139 | } |
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 ) ); |
147 | 145 | } |
148 | 146 | $angle_from = $angle_to; |
149 | | - $ptr = $block['offset']+$block['size']; |
| 147 | + $ptr = $block['offset'] + $block['size']; |
150 | 148 | } |
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 ) ); |
157 | 155 | } |
158 | 156 | } |
159 | 157 | } |
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] ) ) ); |
162 | 160 | } |
163 | 161 | break; |
164 | 162 | |
165 | 163 | 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']; |
168 | 166 | |
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 ) ); |
171 | 169 | break; |
172 | 170 | |
173 | 171 | 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; |
179 | 177 | |
180 | 178 | // This block of code creates the bar chart. It is a lot more complex than you |
181 | 179 | // 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++ ) { |
183 | 181 | $ptr = 0; |
184 | 182 | $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 ) { |
189 | 187 | $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 ); |
192 | 190 | } |
193 | | - $y+=$h; |
| 191 | + $y += $h; |
194 | 192 | } |
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 ) { |
197 | 195 | $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 ); |
200 | 198 | } |
201 | | - $y+=$h; |
202 | | - $ptr = $block['offset']+$block['size']; |
| 199 | + $y += $h; |
| 200 | + $ptr = $block['offset'] + $block['size']; |
203 | 201 | } |
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++ ); |
208 | 206 | } |
209 | 207 | } |
210 | 208 | } |
211 | 209 | break; |
212 | 210 | 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']; |
215 | 213 | |
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 ) ); |
218 | 216 | break; |
219 | 217 | |
220 | 218 | } |
Index: trunk/extensions/APC/APCCacheMode.php |
— | — | @@ -1,9 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class APCCacheMode { |
5 | | - |
6 | 5 | protected $opts, $title; |
7 | | - |
8 | 6 | protected $userMode = false; |
9 | 7 | protected $fieldKey; |
10 | 8 | |
— | — | @@ -11,7 +9,7 @@ |
12 | 10 | $this->opts = $opts; |
13 | 11 | $this->title = $title; |
14 | 12 | $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' ); |
16 | 14 | } |
17 | 15 | |
18 | 16 | protected $scopes = array( |
— | — | @@ -27,22 +25,22 @@ |
28 | 26 | $s = |
29 | 27 | Xml::openElement( 'div', array( 'class' => 'mw-apc-listing' ) ) . |
30 | 28 | Xml::openElement( 'table' ) . Xml::openElement( 'tbody' ) . |
31 | | - Xml::openElement( 'tr' ). |
| 29 | + Xml::openElement( 'tr' ) . |
32 | 30 | Xml::element( 'th', null, wfMsg( 'viewapc-display-attribute' ) ) . |
33 | 31 | Xml::element( 'th', null, wfMsg( 'viewapc-display-value' ) ) . |
34 | 32 | Xml::closeElement( 'tr' ); |
35 | 33 | |
36 | 34 | $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; |
40 | 38 | |
41 | 39 | $size = 0; |
42 | | - foreach($entry as $key => $value) { |
43 | | - switch ($key) { |
| 40 | + foreach ( $entry as $key => $value ) { |
| 41 | + switch ( $key ) { |
44 | 42 | case 'num_hits': |
45 | 43 | $value = $wgLang->formatNum( $value ) . |
46 | | - $wgLang->formatNum( sprintf(" (%.2f%%)", $value*100/$cache['num_hits'] ) ); |
| 44 | + $wgLang->formatNum( sprintf( " (%.2f%%)", $value * 100 / $cache['num_hits'] ) ); |
47 | 45 | break; |
48 | 46 | case 'deletion_time': |
49 | 47 | $value = $this->formatValue( $key, $value ); |
— | — | @@ -56,20 +54,20 @@ |
57 | 55 | $value = $this->formatValue( $key, $value ); |
58 | 56 | } |
59 | 57 | |
60 | | - $s .= APCUtils::tableRow( $r=1-$r, |
| 58 | + $s .= APCUtils::tableRow( $r = 1 - $r, |
61 | 59 | wfMsgHtml( 'viewapc-display-' . $key ), |
62 | 60 | htmlspecialchars( $value ) ); |
63 | 61 | |
64 | 62 | } |
65 | 63 | |
66 | 64 | 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, |
69 | 67 | wfMsgHtml( 'viewapc-display-stored-value' ), |
70 | 68 | wfMsgExt( 'viewapc-display-too-big', 'parseinline' ) ); |
71 | 69 | } 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, |
74 | 72 | wfMsgHtml( 'viewapc-display-stored-value' ), |
75 | 73 | Xml::element( 'pre', null, $value ) ); |
76 | 74 | } |
— | — | @@ -115,7 +113,7 @@ |
116 | 114 | break; |
117 | 115 | } |
118 | 116 | return $value; |
119 | | -} |
| 117 | + } |
120 | 118 | |
121 | 119 | public function cacheView() { |
122 | 120 | global $wgOut, $wgLang; |
— | — | @@ -154,7 +152,7 @@ |
155 | 153 | foreach ( $fields as $field ) { |
156 | 154 | $extra = array(); |
157 | 155 | if ( $sort === $field ) { |
158 | | - $extra = array( 'sortdir' => 1-$sortdir ); |
| 156 | + $extra = array( 'sortdir' => 1 - $sortdir ); |
159 | 157 | } |
160 | 158 | |
161 | 159 | $wgOut->addHTML( |
— | — | @@ -171,7 +169,7 @@ |
172 | 170 | if ( $scope === 'active' || $scope === 'both' ) { |
173 | 171 | foreach ( $cache['cache_list'] as $entry ) { |
174 | 172 | if ( $search && stripos( $entry[$fieldKeys['name']], $search ) === false ) continue; |
175 | | - $sortValue = sprintf('%015d-', $entry[$fieldKeys[$sort]]); |
| 173 | + $sortValue = sprintf( '%015d-', $entry[$fieldKeys[$sort]] ); |
176 | 174 | $list[$sortValue . $entry[$fieldKeys['name']]] = $entry; |
177 | 175 | } |
178 | 176 | } |
— | — | @@ -179,7 +177,7 @@ |
180 | 178 | if ( $scope === 'deleted' || $scope === 'both' ) { |
181 | 179 | foreach ( $cache['deleted_list'] as $entry ) { |
182 | 180 | if ( $search && stripos( $entry[$fieldKeys['name']], $search ) === false ) continue; |
183 | | - $sortValue = sprintf('%015d-', $entry[$fieldKeys[$sort]]); |
| 181 | + $sortValue = sprintf( '%015d-', $entry[$fieldKeys[$sort]] ); |
184 | 182 | $list[$sortValue . $entry[$fieldKeys['name']]] = $entry; |
185 | 183 | } |
186 | 184 | } |
— | — | @@ -187,13 +185,13 @@ |
188 | 186 | $sortdir ? krsort( $list ) : ksort( $list ); |
189 | 187 | |
190 | 188 | $i = 0; |
191 | | - if ( count($list) ) { |
| 189 | + if ( count( $list ) ) { |
192 | 190 | $r = 1; |
193 | 191 | |
194 | 192 | foreach ( $list as $name => $entry ) { |
195 | 193 | if ( $limit === $i++ ) break; |
196 | 194 | $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 ) ) ) |
198 | 196 | ); |
199 | 197 | |
200 | 198 | foreach ( $fields as $field ) { |
— | — | @@ -201,12 +199,12 @@ |
202 | 200 | if ( $field === 'name' ) { |
203 | 201 | if ( !$this->userMode ) { |
204 | 202 | $pos = strrpos( $entry[$index], '/' ); |
205 | | - if ( $pos !== false ) $value = substr( $entry[$index], $pos+1 ); |
| 203 | + if ( $pos !== false ) $value = substr( $entry[$index], $pos + 1 ); |
206 | 204 | } else { |
207 | 205 | $value = $entry[$index]; |
208 | 206 | } |
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] ) { |
211 | 209 | $value = $this->sortHeader( |
212 | 210 | wfMsgHtml( 'viewapc-ls-delete' ), |
213 | 211 | array( 'delete' => $entry[$this->fieldKey] ) |
— | — | @@ -222,15 +220,15 @@ |
223 | 221 | } |
224 | 222 | } |
225 | 223 | |
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 ) ); |
228 | 226 | $wgOut->addHTML( |
229 | 227 | Xml::tags( 'tr', array( 'colspan' => count( $fields ) ), |
230 | 228 | Xml::tags( 'td', null, $this->sortHeader( |
231 | 229 | wfMsgExt( 'viewapc-ls-more', 'parseinline', $left ), |
232 | | - array( 'offset' => $offset+$limit ) ) ) ) |
| 230 | + array( 'offset' => $offset + $limit ) ) ) ) |
233 | 231 | ); |
234 | | - } elseif ( !count($list) ) { |
| 232 | + } elseif ( !count( $list ) ) { |
235 | 233 | $wgOut->addHTML( |
236 | 234 | Xml::tags( 'tr', array( 'colspan' => count( $fields ) ), |
237 | 235 | Xml::tags( 'td', null, wfMsgExt( 'viewapc-ls-nodata', 'parseinline' ) ) ) |
Index: trunk/extensions/APC/ViewAPC.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | /** |
5 | 5 | * An extension to allow access to APC status with MediaWiki rights |
6 | 6 | * |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | 'url' => 'http://www.mediawiki.org/wiki/Extension:APC', |
20 | 20 | ); |
21 | 21 | |
22 | | -$dir = dirname(__FILE__) . '/'; |
| 22 | +$dir = dirname( __FILE__ ) . '/'; |
23 | 23 | $wgAutoloadClasses['SpecialAPC'] = $dir . 'SpecialAPC.php'; |
24 | 24 | $wgAutoloadClasses['APCImages'] = $dir . 'APCImages.php'; |
25 | 25 | $wgAutoloadClasses['APCUtils'] = $dir . 'APCUtils.php'; |
Index: trunk/extensions/APC/APCUtils.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class APCUtils { |
5 | | - |
6 | 5 | public static function tableRow( $class, $first, $second = null ) { |
7 | 6 | $class = $class !== null ? array( 'class' => 'mw-apc-tr-' . $class ) : null; |
8 | 7 | |
Index: trunk/extensions/APC/SpecialAPC.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class SpecialAPC extends SpecialPage { |
5 | | - |
6 | 5 | const GRAPH_SIZE = 200; |
7 | 6 | |
8 | 7 | // Stored objects |
— | — | @@ -25,7 +24,6 @@ |
26 | 25 | // Bind to the member variable |
27 | 26 | $this->opts = $opts; |
28 | 27 | |
29 | | - |
30 | 28 | $opts->add( 'mode', self::MODE_STATS ); |
31 | 29 | $opts->add( 'image', APCImages::IMG_NONE ); |
32 | 30 | $opts->add( 'clearcache', false ); |
— | — | @@ -36,7 +34,7 @@ |
37 | 35 | $opts->add( 'sort', 'hits' ); |
38 | 36 | $opts->add( 'sortdir', 0 ); |
39 | 37 | $opts->add( 'scope', 'active' ); |
40 | | - $opts->add( 'searchi', ''); // MediaWiki captures search, ARGH! |
| 38 | + $opts->add( 'searchi', '' ); // MediaWiki captures search, ARGH! |
41 | 39 | |
42 | 40 | $opts->fetchValuesFromRequest( $wgRequest ); |
43 | 41 | $opts->validateIntBounds( 'limit', 0, 5000 ); |
— | — | @@ -51,31 +49,28 @@ |
52 | 50 | $this->setHeaders(); |
53 | 51 | $this->setup(); |
54 | 52 | |
55 | | - |
56 | | - if( !function_exists('apc_cache_info')) { |
| 53 | + if ( !function_exists( 'apc_cache_info' ) ) { |
57 | 54 | $wgOut->addWikiMsg( 'viewapc-apc-not-available' ); |
58 | 55 | return; |
59 | 56 | } |
60 | 57 | |
61 | | - if ( $this->opts->getValue('image') ) { |
| 58 | + if ( $this->opts->getValue( 'image' ) ) { |
62 | 59 | $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' ) ); |
65 | 62 | return; |
66 | 63 | } |
67 | 64 | |
68 | | - if ( $this->opts->getValue('mode') !== self::MODE_STATS ) { |
| 65 | + if ( $this->opts->getValue( 'mode' ) !== self::MODE_STATS ) { |
69 | 66 | if ( !$wgUser->isAllowed( 'apc' ) ) { |
70 | 67 | $wgOut->permissionRequired( 'apc' ); |
71 | 68 | return; |
72 | 69 | } |
73 | 70 | } |
74 | 71 | |
75 | | - |
76 | | - |
77 | 72 | // clear cache |
78 | 73 | if ( $this->opts->getValue( 'clearcache' ) ) { |
79 | | - $this->opts->setValue( 'clearcache', '' ); //TODO: reset |
| 74 | + $this->opts->setValue( 'clearcache', '' ); // TODO: reset |
80 | 75 | if ( !$wgUser->isAllowed( 'apc' ) ) { |
81 | 76 | $wgOut->permissionRequired( 'apc' ); |
82 | 77 | return; |
— | — | @@ -92,7 +87,7 @@ |
93 | 88 | |
94 | 89 | $delete = $this->opts->getValue( 'delete' ); |
95 | 90 | if ( $delete ) { |
96 | | - $this->opts->setValue( 'delete', '' ); //TODO: reset |
| 91 | + $this->opts->setValue( 'delete', '' ); // TODO: reset |
97 | 92 | if ( !$wgUser->isAllowed( 'apc' ) ) { |
98 | 93 | $wgOut->permissionRequired( 'apc' ); |
99 | 94 | return; |
— | — | @@ -105,7 +100,6 @@ |
106 | 101 | } |
107 | 102 | } |
108 | 103 | |
109 | | - |
110 | 104 | $dir = dirname( __FILE__ ); |
111 | 105 | $wgOut->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', |
112 | 106 | 'href' => "$wgScriptPath/extensions/APC/apc.css?$wgStyleVersion", ) |
— | — | @@ -144,7 +138,7 @@ |
145 | 139 | global $wgOut; |
146 | 140 | |
147 | 141 | $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' ) . |
149 | 143 | Xml::wrapClass( 'Opcode Cache', 'mw-apc-nameinfo' ); |
150 | 144 | |
151 | 145 | $wgOut->addHTML( |
— | — | @@ -177,17 +171,15 @@ |
178 | 172 | Xml::openElement( 'ol', array( 'class' => 'mw-apc-menu' ) ) . |
179 | 173 | $this->menuItem( self::MODE_STATS, wfMsgExt( 'viewapc-mode-stats', 'escape' ) ) . |
180 | 174 | $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' ) ) . |
184 | 178 | Xml::tags( 'li', null, |
185 | 179 | $this->selfLink2( $clearText, $clearParams ) ) . |
186 | 180 | Xml::closeElement( 'ol' ) |
187 | 181 | ); |
188 | 182 | } |
189 | 183 | |
190 | | - |
191 | | - |
192 | 184 | protected function doObHostStats() { |
193 | 185 | global $wgOut, $wgLang; |
194 | 186 | |
— | — | @@ -203,21 +195,20 @@ |
204 | 196 | APCHostMode::doGeneralInfoTable( $cache, $mem ) . |
205 | 197 | APCHostMode::doMemoryInfoTable( $cache, $mem, $this->title ) . $clear . |
206 | 198 | APCHostMode::doCacheTable( $cache ) . |
207 | | - APCHostMode::doCacheTable( apc_cache_info('user', 1), true ) . $clear . |
| 199 | + APCHostMode::doCacheTable( apc_cache_info( 'user', 1 ), true ) . $clear . |
208 | 200 | APCHostMode::doRuntimeInfoTable( $mem ) . |
209 | 201 | APCHostMode::doFragmentationTable( $mem, $this->title ) . $clear |
210 | 202 | ); |
211 | 203 | |
212 | 204 | } |
213 | 205 | |
214 | | - |
215 | 206 | protected function doPage() { |
216 | 207 | global $wgOut; |
217 | 208 | $wgOut->addHTML( |
218 | 209 | Xml::openElement( 'div', array( 'class' => 'mw-apc-content' ) ) |
219 | 210 | ); |
220 | 211 | |
221 | | - switch ( $this->opts->getValue('mode') ) { |
| 212 | + switch ( $this->opts->getValue( 'mode' ) ) { |
222 | 213 | case self::MODE_STATS: |
223 | 214 | $this->doObHostStats(); |
224 | 215 | break; |
— | — | @@ -243,13 +234,13 @@ |
244 | 235 | ); |
245 | 236 | |
246 | 237 | $rss = Http::get( 'http://pecl.php.net/feeds/pkg_apc.rss' ); |
247 | | - if (!$rss) { |
| 238 | + if ( !$rss ) { |
248 | 239 | $wgOut->addWikiMsg( 'viewapc-version-failed' ); |
249 | 240 | } else { |
250 | | - $apcversion = phpversion('apc'); |
| 241 | + $apcversion = phpversion( 'apc' ); |
251 | 242 | |
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], '>=' ) ) { |
254 | 245 | $wgOut->addWikiMsg( 'viewapc-version-ok', $apcversion ); |
255 | 246 | $i = 3; |
256 | 247 | } else { |
— | — | @@ -262,19 +253,19 @@ |
263 | 254 | ); |
264 | 255 | |
265 | 256 | |
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] ); |
268 | 259 | |
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, '>=' ) ) { |
272 | 263 | break; |
273 | | - } else if (!$i--) { |
| 264 | + } else if ( !$i-- ) { |
274 | 265 | break; |
275 | 266 | } |
276 | | - $data = current($match[2]); |
| 267 | + $data = current( $match[2] ); |
277 | 268 | $wgOut->addWikiText( "''[http://pecl.php.net/package/APC/$ver $v]''<br /><pre>$data</pre>" ); |
278 | | - next($match[2]); |
| 269 | + next( $match[2] ); |
279 | 270 | } |
280 | 271 | } |
281 | 272 | } |
Index: trunk/extensions/APC/apc.css |
— | — | @@ -87,4 +87,4 @@ |
88 | 88 | margin-right:1em; |
89 | 89 | } |
90 | 90 | 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 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class APCHostMode { |
5 | | - |
6 | 5 | public static function doGeneralInfoTable( $c, $mem ) { |
7 | 6 | global $wgLang; |
8 | 7 | $r = 1; |
9 | 8 | return |
10 | 9 | 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() ) . |
13 | 12 | |
14 | | - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-shared-memory' ), |
| 13 | + APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-shared-memory' ), |
15 | 14 | wfMsgExt( 'viewapc-shared-memory-details', 'parsemag', |
16 | 15 | $wgLang->formatNum( $mem['num_seg'] ), |
17 | 16 | $wgLang->formatSize( $mem['seg_size'] ), |
18 | 17 | $c['memory_type'], $c['locking_type'] ) ) . |
19 | 18 | |
20 | | - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-start-time' ), |
| 19 | + APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-start-time' ), |
21 | 20 | $wgLang->timeanddate( $c['start_time'] ) ) . |
22 | 21 | |
23 | | - APCUtils::tableRow( $r=1-$r, wfMsgHtml( 'viewapc-uptime' ), |
| 22 | + APCUtils::tableRow( $r = 1 - $r, wfMsgHtml( 'viewapc-uptime' ), |
24 | 23 | $wgLang->formatTimePeriod( time() - $c['start_time'] ) ) . |
25 | 24 | |
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'] ) . |
27 | 26 | APCUtils::tableFooter(); |
28 | 27 | } |
29 | 28 | |
— | — | @@ -32,13 +31,13 @@ |
33 | 32 | // Calculate rates |
34 | 33 | $numHits = $wgLang->formatNum( $c['num_hits'] ); |
35 | 34 | $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']; |
38 | 37 | if ( !$cPeriod ) $cPeriod = 1; |
39 | 38 | $rateReqs = APCUtils::formatReqPerS( $numReqs / $cPeriod ); |
40 | 39 | $rateHits = APCUtils::formatReqPerS( $c['num_hits'] / $cPeriod ); |
41 | 40 | $rateMiss = APCUtils::formatReqPerS( $c['num_misses'] / $cPeriod ); |
42 | | - $rateInsert= APCUtils::formatReqPerS( $c['num_inserts'] / $cPeriod ); |
| 41 | + $rateInsert = APCUtils::formatReqPerS( $c['num_inserts'] / $cPeriod ); |
43 | 42 | |
44 | 43 | $cachedFiles = wfMsgExt( 'viewapc-cached-files-d', 'parsemag', |
45 | 44 | $wgLang->formatNum( $c['num_entries'] ), |
— | — | @@ -49,14 +48,14 @@ |
50 | 49 | |
51 | 50 | return |
52 | 51 | 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 ) . |
61 | 60 | APCUtils::tableFooter(); |
62 | 61 | } |
63 | 62 | |
— | — | @@ -64,10 +63,10 @@ |
65 | 64 | $s = APCUtils::tableHeader( wfMsg( 'viewapc-info-runtime' ) ); |
66 | 65 | |
67 | 66 | $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, |
70 | 69 | htmlspecialchars( $k ), |
71 | | - str_replace(',',',<br />', htmlspecialchars($v['local_value']) ) ); |
| 70 | + str_replace( ',', ',<br />', htmlspecialchars( $v['local_value'] ) ) ); |
72 | 71 | } |
73 | 72 | |
74 | 73 | $s .= APCUtils::tableFooter(); |
— | — | @@ -79,7 +78,7 @@ |
80 | 79 | |
81 | 80 | $s = APCUtils::tableHeader( wfMsg( 'viewapc-info-memory' ), 'mw-apc-img-table' ); |
82 | 81 | |
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 ) { |
84 | 83 | $memHeader = wfMsgExt( 'viewapc-memory-usage-detailed', 'parseinline' ); |
85 | 84 | } else { |
86 | 85 | $memHeader = wfMsgExt( 'viewapc-memory-usage', 'parseinline' ); |
— | — | @@ -92,8 +91,8 @@ |
93 | 92 | if ( APCImages::graphics_avail() ) { |
94 | 93 | $attribs = array( |
95 | 94 | '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, |
98 | 97 | ); |
99 | 98 | |
100 | 99 | $param1 = wfArrayToCGI( array( 'image' => APCImages::IMG_MEM_USAGE ) ); |
— | — | @@ -111,11 +110,11 @@ |
112 | 111 | |
113 | 112 | $freeMem = wfMsgExt( 'viewapc-memory-free', 'parseinline', |
114 | 113 | $wgLang->formatSize( $free ), |
115 | | - $wgLang->formatNum( sprintf('%.1f%%', $free*100/$size) ) ); |
| 114 | + $wgLang->formatNum( sprintf( '%.1f%%', $free * 100 / $size ) ) ); |
116 | 115 | |
117 | 116 | $usedMem = wfMsgExt( 'viewapc-memory-used', 'parseinline', |
118 | 117 | $wgLang->formatSize( $used ), |
119 | | - $wgLang->formatNum( sprintf('%.1f%%', $used*100/$size) ) ); |
| 118 | + $wgLang->formatNum( sprintf( '%.1f%%', $used * 100 / $size ) ) ); |
120 | 119 | |
121 | 120 | $hits = $c['num_hits']; |
122 | 121 | $miss = $c['num_misses']; |
— | — | @@ -126,11 +125,11 @@ |
127 | 126 | |
128 | 127 | $memHits = wfMsgExt( 'viewapc-memory-hits', 'parseinline', |
129 | 128 | $wgLang->formatNum( $hits ), |
130 | | - $wgLang->formatNum( @sprintf('%.1f%%', $hits*100/$reqs) ) ); |
| 129 | + $wgLang->formatNum( @sprintf( '%.1f%%', $hits * 100 / $reqs ) ) ); |
131 | 130 | |
132 | 131 | $memMiss = wfMsgExt( 'viewapc-memory-miss', 'parseinline', |
133 | 132 | $wgLang->formatNum( $miss ), |
134 | | - $wgLang->formatNum( @sprintf('%.1f%%', $miss*100/$reqs) ) ); |
| 133 | + $wgLang->formatNum( @sprintf( '%.1f%%', $miss * 100 / $reqs ) ) ); |
135 | 134 | |
136 | 135 | $s .= APCUtils::tableRow( null, $greenbox . $freeMem, $greenbox . $memHits ); |
137 | 136 | $s .= APCUtils::tableRow( null, $redbox . $usedMem, $redbox . $memMiss ); |
— | — | @@ -146,35 +145,35 @@ |
147 | 146 | |
148 | 147 | // Fragementation: (freeseg - 1) / total_seg |
149 | 148 | $nseg = $freeseg = $fragsize = $freetotal = 0; |
150 | | - for( $i = 0; $i < $mem['num_seg']; $i++ ) { |
| 149 | + for ( $i = 0; $i < $mem['num_seg']; $i++ ) { |
151 | 150 | $ptr = 0; |
152 | | - foreach( $mem['block_lists'][$i] as $block ) { |
| 151 | + foreach ( $mem['block_lists'][$i] as $block ) { |
153 | 152 | if ( $block['offset'] != $ptr ) { |
154 | 153 | ++$nseg; |
155 | 154 | } |
156 | 155 | $ptr = $block['offset'] + $block['size']; |
157 | 156 | /* 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']; |
159 | 158 | $freetotal += $block['size']; |
160 | 159 | } |
161 | | - $freeseg += count($mem['block_lists'][$i]); |
| 160 | + $freeseg += count( $mem['block_lists'][$i] ); |
162 | 161 | } |
163 | 162 | |
164 | 163 | |
165 | | - if (APCImages::graphics_avail()) { |
| 164 | + if ( APCImages::graphics_avail() ) { |
166 | 165 | $attribs = array( |
167 | 166 | '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 ) |
171 | 170 | ); |
172 | 171 | $s .= Xml::element( 'img', $attribs ); |
173 | 172 | } |
174 | 173 | |
175 | | - if ($freeseg > 1) { |
176 | | - $fragPercent = sprintf( '%.2f%%', ($fragsize/$freetotal)*100 ); |
| 174 | + if ( $freeseg > 1 ) { |
| 175 | + $fragPercent = sprintf( '%.2f%%', ( $fragsize / $freetotal ) * 100 ); |
177 | 176 | $s .= wfMsgExt( 'viewapc-fragmentation-info', 'parse', |
178 | | - $wgLang->formatNum( $fragPercent, true), |
| 177 | + $wgLang->formatNum( $fragPercent, true ), |
179 | 178 | $wgLang->formatSize( $fragsize ), |
180 | 179 | $wgLang->formatSize( $freetotal ), |
181 | 180 | $wgLang->formatNum( $freeseg ) |
— | — | @@ -185,10 +184,10 @@ |
186 | 185 | |
187 | 186 | $s .= Xml::closeElement( 'td' ) . Xml::closeElement( 'tr' ); |
188 | 187 | |
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"; |
193 | 192 | else $range = "$cur - $nxt"; |
194 | 193 | $s .= Xml::tags( 'tr', null, |
195 | 194 | Xml::tags( 'th', array( 'align' => 'right' ), $range ) . |