Author: david
Date: Fri Aug 26 17:00:50 2011
New Revision: 9614
Log:
Customize 'disk quota' context box for disabled, limited and unlimited cases
Modified:
trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
trunk/apps/qubit/modules/repository/templates/_contextMenu.php
Modified:
trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
Fri Aug 26 16:26:53 2011 (r9613)
+++ trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
Fri Aug 26 17:00:50 2011 (r9614)
@@ -43,8 +43,9 @@
// Filter draft descriptions
$criteria = QubitAcl::addFilterDraftsCriteria($criteria);
- // Show current disk usage vs. limit for repository
- if (0 < $this->resource->uploadLimit)
+ // Show current disk usage vs. limit for repository, unless upload is
+ // disabled (zero)
+ if (0 != $this->resource->uploadLimit)
{
// Convert bytes to GB
$du = floatval($this->resource->getDiskUsage()) / pow(10, 9);
@@ -59,25 +60,40 @@
$this->diskUsage = round($du, 2);
}
- $this->barColor = '#390'; // Default progress bar is green
-
- // Calculate disk usage percentages
- $dup = $du / floatval($this->resource->uploadLimit) * 100;
- if (0 < $dup && 1 > $dup)
+ // Get display value for upload limit
+ if (0 > $this->resource->uploadLimit)
{
- $this->diskUsagePercent = '< 1';
- $this->barPixels = '1';
+ $this->uploadLimit = '<em>Unlimited</em>';
}
- else if (100 < $dup)
+ else
{
- $this->diskUsagePercent = '> 100';
- $this->barPixels = 200;
- $this->barColor = '#C33'; // RED!
+ $this->uploadLimit = $this->resource->uploadLimit;
}
- else
+
+ // Calc progress bar and percentages values for usage limit > 0
+ if (0 < $this->resource->uploadLimit)
{
- $this->diskUsagePercent = round($dup, 0);
- $this->barPixels = round($dup * 2, 0);
+ // Default color for "disk usage" bar is green
+ $this->barColor = '#390';
+
+ // Calculate disk usage percentages
+ $dup = $du / floatval($this->resource->uploadLimit) * 100;
+ if (0 < $dup && 1 > $dup)
+ {
+ $this->diskUsagePercent = '< 1';
+ $this->barPixels = '1';
+ }
+ else if (100 < $dup)
+ {
+ $this->diskUsagePercent = '> 100';
+ $this->barPixels = 200;
+ $this->barColor = '#C33'; // RED!
+ }
+ else
+ {
+ $this->diskUsagePercent = round($dup, 0);
+ $this->barPixels = round($dup * 2, 0);
+ }
}
}
Modified: trunk/apps/qubit/modules/repository/templates/_contextMenu.php
==============================================================================
--- trunk/apps/qubit/modules/repository/templates/_contextMenu.php Fri Aug
26 16:26:53 2011 (r9613)
+++ trunk/apps/qubit/modules/repository/templates/_contextMenu.php Fri Aug
26 17:00:50 2011 (r9614)
@@ -1,17 +1,31 @@
-<?php if (0 < floatval($resource->uploadLimit) && QubitAcl::check($resource,
'update')): ?>
+<?php if (QubitAcl::check($resource, 'update')): ?>
<div>
<h3><?php echo __('Disk quota used') ?></h3>
<div style="margin: 5px 2px">
+
+<?php if (0 < floatval($resource->uploadLimit)): ?>
+
<div class="progressBar" style="padding: 1px; background-color: #CCC;
height: 10px; width: 200px">
<div style="height: 10px; width: <?php echo $barPixels ?>px;
background-color: <?php echo $barColor ?>;"></div>
</div>
<?php echo __('%1% of %2% <abbr title="1 GB = 1 000 000 000
bytes">GB</abbr> (%3%%)', array('%1%' => $diskUsage, '%2%' =>
$resource->uploadLimit, '%3%' => $diskUsagePercent)) ?>
+
+<?php elseif (0 == $resource->uploadLimit): ?>
+
+ <?php echo __('Upload is disabled for this %1%', array('%1%' =>
strtolower(sfConfig::get('app_ui_label_repository')))) ?>
+
+<?php else: ?>
+
+ <?php echo __('%1% <abbr title="1 GB = 1 000 000 000 bytes">GB</abbr> of
<em>Unlimited</em>', array('%1%' => $diskUsage)) ?>
+
+<?php endif; // Limited, disabled, unlimited disk usage ?>
+
</div>
</div>
-<?php endif; ?>
+<?php endif; // Show disk quota box ?>
<div>
<h3><?php echo sfConfig::get('app_ui_label_holdings') ?></h3>
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.