ca5f98981be818febdd84e50286fc368161b21c2
[phorkie.git] / src / phorkie / HtmlHelper.php
1 <?php
2 namespace phorkie;
3
4 class HtmlHelper
5 {
6     public function getIconUrl($email, $size = 32)
7     {
8         if ($email == 'anonymous@phorkie') {
9             return 'phorkie/anonymous.png';
10         }
11
12         $s = new \Services_Libravatar();
13         return $s->url(
14             $email,
15             array(
16                 'size'    => $size,
17                 'default' => Tools::fullUrl('phorkie/anonymous.png')
18             )
19         );
20     }
21
22     public function getLanguageOptions(File $file = null)
23     {
24         $html = '<option value="_auto_">* automatic *</option>';
25         $fileExt = null;
26         if ($file !== null) {
27             $fileExt = $file->getExt();
28         }
29         foreach ($GLOBALS['phorkie']['languages'] as $ext => $arLang) {
30             if (isset($arLang['show']) && !$arLang['show']) {
31                 continue;
32             }
33             $html .= sprintf(
34                 '<option value="%s"%s>%s</option>',
35                 $ext,
36                 $fileExt == $ext ? ' selected="selected"' : '',
37                 $arLang['title']
38             ) . "\n";
39         }
40         return $html;
41     }
42
43     public function getDomain($url)
44     {
45         return parse_url($url, PHP_URL_HOST);
46     }
47
48     public function fullUrl($path = '')
49     {
50         return Tools::fullUrl($path);
51     }
52 }
53
54 ?>