use finder component to retrieve css and fix namespace issue

This commit is contained in:
Nicolas Le Goff
2012-03-07 11:58:59 +01:00
parent 0c631e1b24
commit d7d52275c0

View File

@@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Request,
Symfony\Component\HttpFoundation\Response, Symfony\Component\HttpFoundation\Response,
Symfony\Component\HttpFoundation\RedirectResponse, Symfony\Component\HttpFoundation\RedirectResponse,
Symfony\Component\HttpKernel\Exception\HttpException, Symfony\Component\HttpKernel\Exception\HttpException,
Symfony\Component\Finder\Finder,
Symfony\Component\HttpKernel\Exception\NotFoundHttpException; Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Alchemy\Phrasea\Helper; use Alchemy\Phrasea\Helper;
@@ -40,49 +41,56 @@ class Root implements ControllerProviderInterface
\User_Adapter::updateClientInfos(1); \User_Adapter::updateClientInfos(1);
$appbox = \appbox::get_instance($app['Core']); $appbox = \appbox::get_instance($app['Core']);
$css = array();
$cssfile = false;
$registry = $app['Core']->getRegistry(); $registry = $app['Core']->getRegistry();
$session = $appbox->get_session();
$user = $app['Core']->getAuthenticatedUser(); $user = $app['Core']->getAuthenticatedUser();
$cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/'; $cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/';
if ($hdir = opendir($cssPath)) $css = array();
$cssfile = false;
$finder = new Finder();
$iterator = $finder
->directories()
->depth(0)
->filter(function(\SplFileInfo $fileinfo)
{ {
while (false !== ($file = readdir($hdir))) return ctype_xdigit($fileinfo->getBasename());
})
->in($cssPath);
foreach ($iterator as $dir)
{ {
if (substr($file, 0, 1) == "." || mb_strtolower($file) == "cvs") $baseName = $dir->getBaseName();
continue; $css[$baseName] = $baseName;
if (is_dir($cssPath . $file) && ctype_xdigit($file))
{
$css[$file] = $file;
}
}
closedir($hdir);
} }
$cssfile = $user->getPrefs('css'); $cssfile = $user->getPrefs('css');
if (!$cssfile && isset($css['000000'])) if (!$cssfile && isset($css['000000']))
{
$cssfile = '000000'; $cssfile = '000000';
}
$user_feeds = \Feed_Collection::load_all($appbox, $user); $user_feeds = \Feed_Collection::load_all($appbox, $user);
$feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds()); $feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
$srt = 'name asc';
$thjslist = ""; $thjslist = "";
$queries_topics = ''; $queries_topics = '';
if ($registry->get('GV_client_render_topics') == 'popups') if ($registry->get('GV_client_render_topics') == 'popups')
$queries_topics = queries::dropdown_topics(); {
$queries_topics = \queries::dropdown_topics();
}
elseif ($registry->get('GV_client_render_topics') == 'tree') elseif ($registry->get('GV_client_render_topics') == 'tree')
{
$queries_topics = \queries::tree_topics(); $queries_topics = \queries::tree_topics();
}
$sbas = $bas2sbas = array(); $sbas = $bas2sbas = array();
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
{ {
$sbas_id = $databox->get_sbas_id(); $sbas_id = $databox->get_sbas_id();
@@ -131,8 +139,6 @@ class Root implements ControllerProviderInterface
'GV_bitly_key' => $registry->get('GV_bitly_key') 'GV_bitly_key' => $registry->get('GV_bitly_key')
)); ));
return new Response($out); return new Response($out);
}); });