Skip to content

Commit

Permalink
Improve alerts formatting.
Browse files Browse the repository at this point in the history
Remove language prefix, use alert type as header, show main content with normal font, and remove redundant title attribute.

The title attribute propagated with the alert 'body' aka 'message' is at least for me redundant with the alert 'desc' aka 'description'.
  • Loading branch information
yunosh committed May 30, 2016
1 parent ce9d87e commit 5fe3bea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion horde/lib/Block/Weather.php
Expand Up @@ -115,7 +115,7 @@ protected function _params()
*/
protected function _content()
{
global $injector, $page_output, $prefs;
global $injector, $language, $page_output, $prefs, $registry;

// Set the requested units.
$this->_weather->units = $this->_params['units'];
Expand Down Expand Up @@ -164,6 +164,8 @@ protected function _content()
} catch (Horde_Service_Weather_Exception $e) {
return $e->getMessage();
}
$view->languageFilter = '/^'
. $registry->nlsconfig->languages[$language] . ': /i';

if (!empty($this->_params['showMap']) && !empty($view->instance)) {
$view->map = true;
Expand Down
10 changes: 8 additions & 2 deletions horde/templates/block/weather_content.html.php
Expand Up @@ -9,8 +9,14 @@
<!-- Weather alerts -->
<?php if (!empty($this->alerts)): ?>
<?php foreach ($this->alerts as $alert): ?>
<div class="hordeWeather<?php echo (!empty($this->sig) ? $this->sig : 'Alert') ?>" title="<?php echo $this->h($alert['body']) ?>">
<div style="font-weight:bold;"><?php echo $this->h($alert['desc']) ?></div>
<div class="hordeWeather<?php echo (!empty($this->sig) ? $this->sig : 'Alert') ?>">
<?php if (!empty($alert['type'])): ?>
<span style="font-weight:bold;"><?php echo $this->h($alert['type']) ?></span><br />
<?php endif ?>
<?php $desc = preg_replace($this->languageFilter, '', $alert['desc']) ?>
<?php if (!empty($desc)): ?>
<?php echo $this->h($desc) ?><br />
<?php endif ?>
<?php if (!empty($alert['date'])): ?>
<?php $alert['date']->setTimezone($this->timezone); ?>
<strong><?php echo _("Starts:") ?></strong> <?php echo $this->h($alert['date']->strftime($this->dateFormat . ' ' . $this->timeFormat)) ?><br />
Expand Down

0 comments on commit 5fe3bea

Please sign in to comment.