From 43856b7f62bb9bd48915bc8ffccca8e52a6d206c Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 19 Apr 2013 20:58:30 +0200 Subject: [PATCH] Cleanup Code --- lib/Alchemy/Phrasea/Application.php | 1 - lib/Alchemy/Phrasea/Application/Api.php | 1 + lib/Alchemy/Phrasea/Controller/Setup.php | 39 +++++++++---------- .../Controller/Thesaurus/Thesaurus.php | 6 +-- .../Provider/PhraseaLocaleServiceProvider.php | 1 + .../PhraseaVersionServiceProvider.php | 1 - .../Provider/PhraseanetServiceProvider.php | 1 - .../Phrasea/PhraseaEngineQueryParser.php | 3 -- .../Phrasea/Setup/Probe/CacheServerProbe.php | 2 +- .../Phrasea/Setup/Probe/OpcodeCacheProbe.php | 2 +- .../Phrasea/Setup/Probe/SearchEngineProbe.php | 3 +- .../Requirements/LocalesRequirements.php | 2 +- .../Setup/Requirements/SystemRequirements.php | 2 - .../Phrasea/Setup/System/Information.php | 15 +++++++ .../Setup/System/InformationInterface.php | 20 ++++++++++ 15 files changed, 63 insertions(+), 36 deletions(-) diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 37e9e68468..982a4556bc 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -320,7 +320,6 @@ class Application extends SilexApplication throw new \RuntimeException('No Imagine driver available'); }); - $app = $this; $this['phraseanet.logger'] = $this->protect(function($databox) use ($app) { try { diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 3c9b8e1288..111388003c 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -73,6 +73,7 @@ return call_user_func(function($environment = 'prod') { if ($app->isAuthenticated()) { $app['dispatcher']->dispatch(PhraseaEvents::API_OAUTH2_END, new ApiOAuth2EndEvent()); + return; } diff --git a/lib/Alchemy/Phrasea/Controller/Setup.php b/lib/Alchemy/Phrasea/Controller/Setup.php index cae3d785b8..b6c76b858a 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Setup.php @@ -16,8 +16,7 @@ use Silex\ControllerProviderInterface; use Silex\Application as SilexApplication; use Symfony\Component\HttpFoundation\Request; - -class Setup implements ControllerProviderInterface +class Setup implements ControllerProviderInterface { public function connect(SilexApplication $app) { @@ -43,10 +42,10 @@ class Setup implements ControllerProviderInterface $requirementsCollection = $this->getRequirementsCollection(); return $app['twig']->render('/setup/index.html.twig', array( - 'locale' => $app['locale'], - 'available_locales' => \Alchemy\Phrasea\Application::getAvailableLanguages(), - 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/', - 'requirementsCollection' => $requirementsCollection, + 'locale' => $app['locale'], + 'available_locales' => \Alchemy\Phrasea\Application::getAvailableLanguages(), + 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/', + 'requirementsCollection' => $requirementsCollection, )); } @@ -70,8 +69,8 @@ class Setup implements ControllerProviderInterface $requirementsCollection = $this->getRequirementsCollection(); - foreach($requirementsCollection as $requirements) { - foreach($requirements->getRequirements() as $requirement) { + foreach ($requirementsCollection as $requirements) { + foreach ($requirements->getRequirements() as $requirement) { if (!$requirement->isFulfilled() && !$requirement->isOptional()) { $warnings[] = $requirement->getTestMessage(); } @@ -142,16 +141,16 @@ class Setup implements ControllerProviderInterface $binaryData = array(); foreach (array( - 'php_binary' => $request->request->get('binary_php'), - 'convert_binary' => $request->request->get('binary_convert'), - 'composite_binary' => $request->request->get('binary_composite'), - 'swf_extract_binary' => $request->request->get('binary_swfextract'), - 'pdf2swf_binary' => $request->request->get('binary_pdf2swf'), - 'swf_render_binary' => $request->request->get('binary_swfrender'), - 'unoconv_binary' => $request->request->get('binary_unoconv'), - 'ffmpeg_binary' => $request->request->get('binary_ffmpeg'), - 'mp4box_binary' => $request->request->get('binary_MP4Box'), - 'pdftotext_binary' => $request->request->get('binary_xpdf'), + 'php_binary' => $request->request->get('binary_php'), + 'convert_binary' => $request->request->get('binary_convert'), + 'composite_binary' => $request->request->get('binary_composite'), + 'swf_extract_binary' => $request->request->get('binary_swfextract'), + 'pdf2swf_binary' => $request->request->get('binary_pdf2swf'), + 'swf_render_binary' => $request->request->get('binary_swfrender'), + 'unoconv_binary' => $request->request->get('binary_unoconv'), + 'ffmpeg_binary' => $request->request->get('binary_ffmpeg'), + 'mp4box_binary' => $request->request->get('binary_MP4Box'), + 'pdftotext_binary' => $request->request->get('binary_xpdf'), ) as $key => $path) { $binaryData[$key] = $path; } @@ -159,14 +158,14 @@ class Setup implements ControllerProviderInterface $user = $installer->install($email, $password, $abConn, $servername, $dataPath, $dbConn, $template, $binaryData); $app->openAccount(new \Session_Authentication_None($user)); -//exit; $redirection = '/admin/?section=taskmanager¬ice=install_success'; + return $app->redirect($redirection); } catch (\Exception $e) { } - var_dump($e->getMessage(), $e->getFile(), $e->getLine()); + return $app->redirect('/setup/installer/step2/?error=' . sprintf(_('an error occured : %s'), $e->getMessage())); } diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php index 77e641f6c6..aa8a7408d1 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php @@ -499,10 +499,10 @@ class Thesaurus implements ControllerProviderInterface } } } - if ( ! $query) { + if (! $query) { $query = $query0; } - if ( ! $label) { + if (! $label) { $label = $label0; } @@ -2798,7 +2798,7 @@ class Thesaurus implements ControllerProviderInterface "reindex" => $request->get('reindex'), "debug" => $request->get('debug'), ), true))); - + $refresh_list = $root->appendChild($ret->createElement("refresh_list")); if (null === $bid = $request->get("bid")) { diff --git a/lib/Alchemy/Phrasea/Core/Provider/PhraseaLocaleServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PhraseaLocaleServiceProvider.php index 030d387817..05521cd755 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PhraseaLocaleServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PhraseaLocaleServiceProvider.php @@ -47,6 +47,7 @@ class PhraseaLocaleServiceProvider implements ServiceProviderInterface { if (isset($this->locale)) { $this->app['locale'] = $this->locale; + return; } diff --git a/lib/Alchemy/Phrasea/Core/Provider/PhraseaVersionServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PhraseaVersionServiceProvider.php index 1d033ad93f..ca7c68dbc5 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PhraseaVersionServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PhraseaVersionServiceProvider.php @@ -12,7 +12,6 @@ namespace Alchemy\Phrasea\Core\Provider; use Alchemy\Phrasea\Core\Version; -use Alchemy\Phrasea\Security\Firewall; use Silex\Application as SilexApplication; use Silex\ServiceProviderInterface; diff --git a/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php index a27ef7addd..311a1e2d13 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PhraseanetServiceProvider.php @@ -11,7 +11,6 @@ namespace Alchemy\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Security\Firewall; use Silex\Application as SilexApplication; use Silex\ServiceProviderInterface; diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php index ac79b14676..39ef24626b 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php @@ -1217,7 +1217,6 @@ class PhraseaEngineQueryParser } break; - // lé ca devient la zone pour savoir si on a que l'année ou si c'est une date sans espaces,slash ou tiret case 1 : switch (strlen($tmp[0])) { @@ -1278,8 +1277,6 @@ class PhraseaEngineQueryParser break; } - - break; } diff --git a/lib/Alchemy/Phrasea/Setup/Probe/CacheServerProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/CacheServerProbe.php index 934213e582..8e3e8cf6e8 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/CacheServerProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/CacheServerProbe.php @@ -30,7 +30,7 @@ class CacheServerProbe extends CacheServerRequirement implements ProbeInterface ); if (null !== $cache->getStats()) { - foreach($cache->getStats() as $name => $value) { + foreach ($cache->getStats() as $name => $value) { $this->addInformation($name, $value); } } diff --git a/lib/Alchemy/Phrasea/Setup/Probe/OpcodeCacheProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/OpcodeCacheProbe.php index ff87ad75b1..f4d718f697 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/OpcodeCacheProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/OpcodeCacheProbe.php @@ -30,7 +30,7 @@ class OpcodeCacheProbe extends OpcodeCacheRequirement implements ProbeInterface ); if (null !== $cache->getStats()) { - foreach($cache->getStats() as $name => $value) { + foreach ($cache->getStats() as $name => $value) { $this->addInformation($name, $value); } } diff --git a/lib/Alchemy/Phrasea/Setup/Probe/SearchEngineProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/SearchEngineProbe.php index 8fce37c9bd..0ec1630bff 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/SearchEngineProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/SearchEngineProbe.php @@ -21,8 +21,7 @@ class SearchEngineProbe extends RequirementCollection implements ProbeInterface { $this->setName('Search Engine'); - foreach ($searchEngine->getStatus() as $infos) - { + foreach ($searchEngine->getStatus() as $infos) { $this->addInformation($infos[0], $infos[1]); } } diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php index cd2c254ab4..b8df2153c1 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/LocalesRequirements.php @@ -27,7 +27,7 @@ class LocalesRequirements extends RequirementCollection ); if (function_exists('_')) { - foreach (PhraseaApplication::getAvailableLanguages() as $code => $language_name){ + foreach (PhraseaApplication::getAvailableLanguages() as $code => $language_name) { \phrasea::use_i18n($code, 'test'); $this->addRecommendation( diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php index fcf895cab6..8c13836ce5 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php @@ -12,7 +12,6 @@ namespace Alchemy\Phrasea\Setup\Requirements; use Alchemy\Phrasea\Setup\System\RequirementCollection; -use Alchemy\Phrasea\Application as PhraseaApplication; class SystemRequirements extends RequirementCollection { @@ -279,7 +278,6 @@ class SystemRequirements extends RequirementCollection 'Install and enable the XML extension.' ); - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { $this->addRecommendation( function_exists('posix_isatty'), diff --git a/lib/Alchemy/Phrasea/Setup/System/Information.php b/lib/Alchemy/Phrasea/Setup/System/Information.php index 901a82b9bf..cd65e17107 100644 --- a/lib/Alchemy/Phrasea/Setup/System/Information.php +++ b/lib/Alchemy/Phrasea/Setup/System/Information.php @@ -1,5 +1,14 @@ value = $value; } + /** + * {@inheritdoc} + */ public function getName() { return $this->name; } + /** + * {@inheritdoc} + */ public function getValue() { return $this->value; diff --git a/lib/Alchemy/Phrasea/Setup/System/InformationInterface.php b/lib/Alchemy/Phrasea/Setup/System/InformationInterface.php index 46b27561dd..c8c620d5c6 100644 --- a/lib/Alchemy/Phrasea/Setup/System/InformationInterface.php +++ b/lib/Alchemy/Phrasea/Setup/System/InformationInterface.php @@ -1,9 +1,29 @@