From: Michael M Slusarz Date: Sun, 21 Nov 2010 20:52:32 +0000 (-0700) Subject: Add Horde_Themes::themeList() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=57a91a931a84e226af86f488a79ff252fab5bad2;p=horde.git Add Horde_Themes::themeList() --- diff --git a/framework/Core/lib/Horde/Themes.php b/framework/Core/lib/Horde/Themes.php index dcbc24b0e..2808d5c65 100644 --- a/framework/Core/lib/Horde/Themes.php +++ b/framework/Core/lib/Horde/Themes.php @@ -68,6 +68,34 @@ class Horde_Themes } /** + * Returns a list of available themes. + * + * @return array Keys are theme names, values are theme descriptions. + * @throws UnexpectedValueException + */ + static public function themeList() + { + $out = array(); + + // Throws UnexpectedValueException + $di = new DirectoryIterator($GLOBALS['registry']->get('themesfs', 'horde')); + + foreach ($di as $val) { + $theme_name = null; + + if ($val->isDir() && + !$di->isDot() && + (@include $val->getPathname() . '/info.php')) { + $out[strval($val)] = $theme_name; + } + } + + asort($out); + + return $out; + } + + /** * Returns a list of available sounds for a theme. * * @param string $app The app to search in. diff --git a/horde/lib/Prefs/Ui.php b/horde/lib/Prefs/Ui.php index 4e0828027..950f2f3cb 100644 --- a/horde/lib/Prefs/Ui.php +++ b/horde/lib/Prefs/Ui.php @@ -19,7 +19,7 @@ class Horde_Prefs_Ui */ public function prefsEnum($ui) { - global $prefs, $registry; + global $injector, $notification, $prefs, $registry; switch ($ui->group) { case 'display': @@ -27,9 +27,9 @@ class Horde_Prefs_Ui $out = array(); $apps = $registry->listApps(array('active')); foreach ($apps as $a) { - $perms = $GLOBALS['injector']->getInstance('Horde_Perms'); + $perms = $injector->getInstance('Horde_Perms'); if (file_exists($registry->get('fileroot', $a)) && - (($perms->exists($a) && ($perms->hasPermission($a, $GLOBALS['registry']->getAuth(), Horde_Perms::READ) || $registry->isAdmin())) || + (($perms->exists($a) && ($perms->hasPermission($a, $registry->getAuth(), Horde_Perms::READ) || $registry->isAdmin())) || !$perms->exists($a))) { $out[$a] = $registry->get('name', $a); } @@ -39,27 +39,11 @@ class Horde_Prefs_Ui } if (!$prefs->isLocked('theme')) { - $out = array(); - $theme_base = $registry->get('themesfs', 'horde'); - $dh = @opendir($theme_base); - if (!$dh) { - $GLOBALS['notification']->push(_("Theme directory can't be opened"), 'horde.error'); - } else { - while (($dir = readdir($dh)) !== false) { - if ($dir == '.' || $dir == '..') { - continue; - } - - $theme_name = null; - @include $theme_base . '/' . $dir . '/info.php'; - if (!empty($theme_name)) { - $out[$dir] = $theme_name; - } - } + try { + $ui->override['theme'] = Horde_Themes::themeList(); + } catch (UnexpectedValueException $e) { + $notification->push(_("Theme directory can't be opened"), 'horde.error'); } - - asort($out); - $ui->override['theme'] = $out; } break;