]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
better quota message on upload form - need to start moving more functionality into...
authorCash Costello <cash.costello@gmail.com>
Sun, 25 Apr 2010 01:15:26 +0000 (01:15 +0000)
committerCash Costello <cash.costello@gmail.com>
Sun, 25 Apr 2010 01:15:26 +0000 (01:15 +0000)
views/default/tidypics/forms/upload.php

index 077e90b1ee8211c67224b2760a0465ab510f5cf6..6e755612c25057eb993c47f89c9e041447a04757 100644 (file)
        if ($quota) {
                $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size");
                $image_repo_size = (int)$image_repo_size_md->value;
-               $image_repo_size = round($image_repo_size / 1024 / 1024);
-               if ($image_repo_size > $quota)
+               $image_repo_size = $image_repo_size / 1024 / 1024;
+               $quote_percentage = round(100 * ($image_repo_size / $quota));
+               // for small quotas, so one decimal place
+               if ($quota < 10) {
+                       $image_repo_size = sprintf('%.1f', $image_repo_size);
+               } else {
+                       $image_repo_size = round($image_repo_size);
+               }
+               if ($image_repo_size > $quota) {
                        $image_repo_size = $quota;
+               }
        }
 
 ?>
@@ -32,7 +40,7 @@
 <?php 
        if ($quota) {
 ?>
-       <i><?php echo elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . ' MB'; ?></i><br />
+       <i><?php echo elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . " MB ({$quote_percentage}%)"; ?></i><br />
 <?php
        }
 ?>