Преглед изворни кода

Fix coding style formatNumber and formatBytes

Marien Fressinaud пре 11 година
родитељ
комит
036240ab01
4 измењених фајлова са 20 додато и 22 уклоњено
  1. 2 2
      app/views/configure/archiving.phtml
  2. 10 10
      app/views/stats/index.phtml
  3. 2 2
      app/views/user/manage.phtml
  4. 6 8
      lib/lib_rss.php

+ 2 - 2
app/views/configure/archiving.phtml

@@ -60,7 +60,7 @@
 		<div class="form-group">
 			<label class="group-name"><?php echo _t('current_user'); ?></label>
 			<div class="group-controls">
-				<?php echo _t('conf.users.articles_and_size', formatNumber($this->nb_total), formatBytes($this->size_user)); ?>
+				<?php echo _t('conf.users.articles_and_size', format_number($this->nb_total), format_bytes($this->size_user)); ?>
 			</div>
 		</div>
 
@@ -68,7 +68,7 @@
 		<div class="form-group">
 			<label class="group-name"><?php echo _t('users'); ?></label>
 			<div class="group-controls">
-				<?php echo formatBytes($this->size_total); ?>
+				<?php echo format_bytes($this->size_total); ?>
 			</div>
 		</div>
 

+ 10 - 10
app/views/stats/index.phtml

@@ -18,23 +18,23 @@
 			<tbody>
 				<tr>
 					<th><?php echo _t('status_total'); ?></th>
-					<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['total']); ?></td>
-					<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['total']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['total']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['total']); ?></td>
 				</tr>
 				<tr>
 					<th><?php echo _t('status_read'); ?></th>
-					<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['read']); ?></td>
-					<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['read']); ?></td>
+					<td class="numeric"><?php echo FreshRSS_Context::$conf($this->repartition['main_stream']['read']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['read']); ?></td>
 				</tr>
 				<tr>
 					<th><?php echo _t('status_unread'); ?></th>
-					<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['unread']); ?></td>
-					<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['unread']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['unread']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['unread']); ?></td>
 				</tr>
 				<tr>
 					<th><?php echo _t('status_favorites'); ?></th>
-					<td class="numeric"><?php echo formatNumber($this->repartition['main_stream']['favorite']); ?></td>
-					<td class="numeric"><?php echo formatNumber($this->repartition['all_feeds']['favorite']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['main_stream']['favorite']); ?></td>
+					<td class="numeric"><?php echo format_number($this->repartition['all_feeds']['favorite']); ?></td>
 				</tr>
 			</tbody>
 		</table>
@@ -56,8 +56,8 @@
 					<tr>
 						<td><a href="<?php echo _url('stats', 'repartition', 'id', $feed['id']); ?>"><?php echo $feed['name']; ?></a></td>
 						<td><?php echo $feed['category']; ?></td>
-						<td class="numeric"><?php echo formatNumber($feed['count']); ?></td>
-						<td class="numeric"><?php echo formatNumber($feed['count'] / $this->repartition['all_feeds']['total'] * 100, 1);?></td>
+						<td class="numeric"><?php echo format_number($feed['count']); ?></td>
+						<td class="numeric"><?php echo format_number($feed['count'] / $this->repartition['all_feeds']['total'] * 100, 1);?></td>
 					</tr>
 				<?php endforeach;?>
 			</tbody>

+ 2 - 2
app/views/user/manage.phtml

@@ -65,8 +65,8 @@
 				</select>
 
 				<p><?php echo _t('admin.users.articles_and_size',
-				                 formatNumber($this->nb_articles),
-				                 formatBytes($this->size_user)); ?></p>
+				                 format_number($this->nb_articles),
+				                 format_bytes($this->size_user)); ?></p>
 			</div>
 		</div>
 

+ 6 - 8
lib/lib_rss.php

@@ -56,16 +56,14 @@ function checkUrl($url) {
 	}
 }
 
-function formatNumber($n, $precision = 0) {
-	return str_replace(' ', ' ',	//Espace insécable	//TODO: remplacer par une espace _fine_ insécable
-		number_format($n, $precision, '.', ' '));	//number_format does not seem to be Unicode-compatible
-}
 function format_number($n, $precision = 0) {
-	// TODO: coding style, prefer THIS function. Remove formatNumber.
-	return formatNumber($n, $precision);
+	// number_format does not seem to be Unicode-compatible
+	return str_replace(' ', ' ',	//Espace insécable	//TODO: remplacer par une espace _fine_ insécable
+		number_format($n, $precision, '.', ' ')
+	);
 }
 
-function formatBytes($bytes, $precision = 2, $system = 'IEC') {
+function format_bytes($bytes, $precision = 2, $system = 'IEC') {
 	if ($system === 'IEC') {
 		$base = 1024;
 		$units = array('B', 'KiB', 'MiB', 'GiB', 'TiB');
@@ -77,7 +75,7 @@ function formatBytes($bytes, $precision = 2, $system = 'IEC') {
 	$pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base));
 	$pow = min($pow, count($units) - 1);
 	$bytes /= pow($base, $pow);
-	return formatNumber($bytes, $precision) . ' ' . $units[$pow];
+	return format_number($bytes, $precision) . ' ' . $units[$pow];
 }
 
 function timestamptodate ($t, $hour = true) {