-
Notifications
You must be signed in to change notification settings - Fork 127
/
icon_browser.php
82 lines (73 loc) · 2.45 KB
/
icon_browser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Icon browser for Horde themes.
*
* This script requires the user to be authenticated (to prevent abuses).
*
* Copyright 2004-2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL-2). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @category Horde
* @copyright 2004-2014 Horde LLC
* @license http://www.horde.org/licenses/lgpl LGPL-2
* @package Horde
*/
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('horde');
$apps = $registry->listAllApps();
sort($apps);
$url = new Horde_Url('icon_browser.php');
$vars = $injector->getInstance('Horde_Variables');
if (($app = basename($vars->app)) && in_array($app, $apps)) {
$img = Horde_Themes::img(null, array(
'app' => $app,
'theme' => 'default'
));
$img_fs = $img->fs;
// Throws Exception on error.
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($img_fs));
// Provide a non-white background for eyeballing transparency.
echo '<html><body bgcolor="#aaaaaa">' .
'<h2>' . sprintf(_("Icons for %s"), $registry->get('name', $app)) . '</h2>';
foreach ($iterator as $val) {
if ($val->isFile() &&
(in_array(substr($val->getFilename(), -4), array('.png', '.gif', 'jpg')))) {
$imgs[] = strval($val);
}
}
if (count($imgs)) {
natsort($imgs);
foreach ($imgs as $img) {
echo Horde_Themes_Image::tag(
Horde_Themes::img(
str_replace($img_fs . DIRECTORY_SEPARATOR, '', $img),
array(
'app' => $app,
'theme' => 'default'
)
),
array(
'alt' => $img,
'attr' => array(
'hspace' => 10,
'title' => $img,
'vspace' => 10
)
)
);
}
} else {
echo _("No icons found.");
}
echo '<p /><a href="' . $url . '">Return to app browser</a></body></html>';
} else {
// List apps.
foreach ($apps as $app) {
if ($name = $registry->get('name', $app)) {
echo Horde::link($url->add('app', $app)) . htmlspecialchars($name) . ' [' . htmlspecialchars($app) . ']</a><br />';
}
}
}