Skip to content

Commit

Permalink
[mms] Add Horde_Core_Ui_FlagImage#getFlagImageObByHost.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 14, 2013
1 parent 1530ae5 commit caff330
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
36 changes: 33 additions & 3 deletions framework/Core/lib/Horde/Core/Ui/FlagImage.php
Expand Up @@ -36,12 +36,11 @@ class Horde_Core_Ui_FlagImage
*/
static public function generateFlagImageByHost($host)
{
$data = Horde_Nls::getCountryByHost($host, empty($GLOBALS['conf']['geoip']['datafile']) ? null : $GLOBALS['conf']['geoip']['datafile']);
if ($data === false) {
if (($data = self::getFlagImageObByHost($host)) === false) {
return '';
}

$img = Horde_Themes_Image::tag('flags/' . $data['code'] . '.png', array(
$img = Horde_Themes_Image::tag($data['ob'], array(
'alt' => $data['name'],
'attr' => array('title' => $data['name'])
));
Expand All @@ -51,4 +50,35 @@ static public function generateFlagImageByHost($host)
: '[' . $data['name'] . ']';
}

/**
* Generate flag image object.
*
* @since 2.10.0
*
* @param string $host The hostname.
*
* @return array False if not found, or an array with these keys:
* <pre>
* - name: (string) Country name.
* - ob: (Horde_Themes_Image) Image object.
* </pre>
*/
static public function getFlagImageObByHost($host)
{
global $conf;

$data = Horde_Nls::getCountryByHost(
$host,
empty($conf['geoip']['datafile']) ? null : $conf['geoip']['datafile']
);
if ($data === false) {
return false;
}

return array(
'name' => $data['name'],
'ob' => Horde_Themes::img('flags/' . $data['code'] . '.png')
);
}

}
2 changes: 2 additions & 0 deletions framework/Core/package.xml
Expand Up @@ -39,6 +39,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Add Horde_Core_Ui_FlagImage#getFlagImageObByHost.
* [mms] Add base64img property to Horde_Themes_Image.
* [mjr] Do not assume that the filter API is available (Bug #12757).
* [mms] Add ability to load javascript via a HordeCore AJAX response (Request #10971).
Expand Down Expand Up @@ -3180,6 +3181,7 @@
<date>2013-10-08</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Add Horde_Core_Ui_FlagImage#getFlagImageObByHost.
* [mms] Add base64img property to Horde_Themes_Image.
* [mjr] Do not assume that the filter API is available (Bug #12757).
* [mms] Add ability to load javascript via a HordeCore AJAX response (Request #10971).
Expand Down

0 comments on commit caff330

Please sign in to comment.