Skip to content

Commit

Permalink
Iterate in the template, and improve layout while we are at it.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Aug 13, 2016
1 parent ac3c51c commit 9ff75ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
22 changes: 3 additions & 19 deletions horde/lib/Block/Metar.php
Expand Up @@ -215,25 +215,9 @@ protected function _content()
}

// Clouds.
// @todo - fix units, fix indentation
if (isset($weather['clouds'])) {
$view->clouds = '';
foreach ($weather['clouds'] as $cloud) {
if (!empty($view->clouds)) {
$view->clouds .= '<br /> ';
}
if (isset($cloud['height'])) {
$view->clouds .= sprintf(
_("%s at %s %s"),
$cloud['amount'],
$cloud['height'],
$units['height']
);
} else {
$view->clouds .= $cloud['amount'];
}
}
}
$view->clouds = isset($weather['clouds'])
? $weather['clouds']
: array();

// Remarks.
if (isset($weather['remark'])) {
Expand Down
10 changes: 9 additions & 1 deletion horde/templates/block/metar_content.html.php
Expand Up @@ -24,7 +24,15 @@
<strong><?php echo _("Humidity")?>:</strong> <?php echo $this->weather['humidity']?>
<?php endif;?>
<?php if (isset($this->clouds)):?>
<br /><strong><?php echo _("Clouds")?>:</strong> <?php echo $this->clouds ?>
<br /><strong><?php echo _("Clouds")?>:</strong>
<?php foreach ($this->clouds as $clouds): ?>
<div style="margin-left: 8px;">
<?php if (isset($clouds['height'])):?>
<?php echo sprintf(_("%s at %s %s"), $clouds['amount'], $clouds['height'], $this->units['height']);?></div>
<?php elseif (!empty($clouds)): ?>
<?php echo $clouds['amount']?>
<?php endif;?>
<?php endforeach;?>
<?php endif;?>
<?php if (isset($this->weather['conditions'])):?>
<br /><strong><?php echo _("Conditions")?>:</strong> <?php echo $this->weather['conditions'] ?>
Expand Down

0 comments on commit 9ff75ed

Please sign in to comment.