1: <?php
2: /**
3: * The Horde_Core_Ui_FlagImage:: class provides a widget for linking to a flag
4: * image.
5: *
6: * Copyright 2003-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
14: * @package Core
15: */
16: class Horde_Core_Ui_FlagImage
17: {
18: /**
19: * Generate a flag image tag.
20: *
21: * @param string $host The hostname.
22: *
23: * @return string An HTML IMG tag (or empty if host is not found).
24: */
25: static public function generateFlagImageByHost($host)
26: {
27: $data = Horde_Nls::getCountryByHost($host, empty($GLOBALS['conf']['geoip']['datafile']) ? null : $GLOBALS['conf']['geoip']['datafile']);
28: if ($data === false) {
29: return '';
30: }
31:
32: $img = strval(Horde::img('flags/' . $data['code'] . '.png', $data['name'], array('title' => $data['name'])));
33:
34: return $img
35: ? $img
36: : '[' . $data['name'] . ']';
37: }
38:
39: }
40: