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