diff --git a/bin/developer b/bin/developer index ac7088e183..6326046041 100755 --- a/bin/developer +++ b/bin/developer @@ -57,10 +57,10 @@ $cli = new CLI(" . ' Phraseanet Developer Tools ', Version::getName() . ' ' . Version::getNumber()); if ($cli['configuration']->isSetup()) { - $helpers = array( + $helpers = [ 'db' => new ConnectionHelper($cli['EM']->getConnection()), 'em' => new EntityManagerHelper($cli['EM']) - ); + ]; $helperSet = $cli['console']->getHelperSet(); foreach ($helpers as $name => $helper) { @@ -80,7 +80,7 @@ $cli->command(new Uninstaller()); $cli->command(new \module_console_systemTemplateGenerator('system:generate-templates')); -$cli['console']->addCommands(array( +$cli['console']->addCommands([ // DBAL Commands new RunSqlCommand(), new ImportCommand(), @@ -99,6 +99,6 @@ $cli['console']->addCommands(array( new ConvertMappingCommand(), new RunDqlCommand(), new ValidateSchemaCommand(), -)); +]); exit($cli->runCLI()); diff --git a/builder.php b/builder.php index 3c6ca744c8..78767e1b3d 100755 --- a/builder.php +++ b/builder.php @@ -48,20 +48,20 @@ $finder ->ignoreVCS(false) ->in(__DIR__); -$files = array(); +$files = []; foreach ($finder as $file) { $files[$file->getRealpath()] = $file->getRealpath(); } -foreach (array( +foreach ([ __DIR__ . '/bin/behat', __DIR__ . '/bin/developer', __DIR__ . '/bin/doctrine.php', __DIR__ . '/bin/doctrine', __DIR__ . '/bin/phpunit', __DIR__ . '/bin/validate-json', -) as $binary) { +] as $binary) { if (is_file($binary)) { $files[$binary] = $binary; } @@ -71,7 +71,7 @@ $finder = new Finder(); $finder ->ignoreDotFiles(false) ->ignoreVCS(false) - ->in(array('logs')); + ->in(['logs']); foreach ($finder as $file) { $files[$file->getRealpath()] = $file->getRealpath(); @@ -118,7 +118,7 @@ $finder ->in(__DIR__); -$dirs = array(); +$dirs = []; foreach ($finder as $dir) { $dirs[] = $dir->getRealpath(); diff --git a/functionnal-tests/api/dailymotion.php b/functionnal-tests/api/dailymotion.php index 084c46eb2d..c287c1a55b 100644 --- a/functionnal-tests/api/dailymotion.php +++ b/functionnal-tests/api/dailymotion.php @@ -49,13 +49,13 @@ $console $bridge->set_oauth_token($configuration['dailymotion']['dev_token']); - $options = array(); - $samples = array( + $options = []; + $samples = [ 'title' => $record->get_title(), 'description' => 'Upload functionnal test', 'tags' => 'phraseanet upload test dm api', 'private' => true, - ); + ]; foreach($bridge->get_fields() as $field) { $options[$field['name']] = isset($samples[$field['name']]) ? $samples[$field['name']] : uniqid('test_upload'); diff --git a/launchpadToLocales.php b/launchpadToLocales.php index 87070a8486..3583ef2771 100755 --- a/launchpadToLocales.php +++ b/launchpadToLocales.php @@ -29,9 +29,9 @@ $finder ->files() ->name('phraseanet-*.po') ->in( - array( + [ __DIR__ . '/' . $argv[1], - ) + ] ) ; diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index 732d03ed5f..1085b8d590 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -152,13 +152,13 @@ use Symfony\Component\Form\Exception\FormException; class Application extends SilexApplication { - private static $availableLanguages = array( + private static $availableLanguages = [ 'de_DE' => 'Deutsch', 'en_GB' => 'English', 'fr_FR' => 'Français', 'nl_NL' => 'Dutch', - ); - private static $flashTypes = array('warning', 'info', 'success', 'error'); + ]; + private static $flashTypes = ['warning', 'info', 'success', 'error']; private $environment; const ENV_DEV = 'dev'; @@ -222,9 +222,9 @@ class Application extends SilexApplication $this->register(new MediaAlchemystServiceProvider()); $this['media-alchemyst.configuration'] = $this->share(function (Application $app) { - $configuration = array(); + $configuration = []; - foreach (array( + foreach ([ 'swftools.pdf2swf.binaries' => 'pdf2swf_binary', 'swftools.swfrender.binaries' => 'swf_render_binary', 'swftools.swfextract.binaries' => 'swf_extract_binary', @@ -239,7 +239,7 @@ class Application extends SilexApplication 'mp4box.timeout' => 'mp4box_timeout', 'swftools.timeout' => 'swftools_timeout', 'unoconv.timeout' => 'unoconv_timeout', - ) as $parameter => $key) { + ] as $parameter => $key) { if (isset($this['configuration']['binaries'][$key])) { $configuration[$parameter] = $this['configuration']['binaries'][$key]; } @@ -284,20 +284,20 @@ class Application extends SilexApplication }); $this->register(new SearchEngineServiceProvider()); - $this->register(new SessionServiceProvider(), array( + $this->register(new SessionServiceProvider(), [ 'session.test' => $this->getEnvironment() === static::ENV_TEST - )); + ]); $this->register(new ServiceControllerServiceProvider()); $this->register(new SwiftmailerServiceProvider()); $this->register(new TasksServiceProvider()); $this->register(new TemporaryFilesystemServiceProvider()); $this->register(new TokensServiceProvider()); - $this->register(new TwigServiceProvider(), array( - 'twig.options' => array( + $this->register(new TwigServiceProvider(), [ + 'twig.options' => [ 'cache' => $this['root.path'] . '/tmp/cache_twig/', - ), - 'twig.form.templates' => array('login/common/form_div_layout.html.twig') - )); + ], + 'twig.form.templates' => ['login/common/form_div_layout.html.twig'] + ]); $this->register(new FormServiceProvider()); $this->setupTwig(); @@ -319,24 +319,24 @@ class Application extends SilexApplication if ($app['phraseanet.registry']->get('GV_smtp')) { $transport = new \Swift_Transport_EsmtpTransport( $app['swiftmailer.transport.buffer'], - array($app['swiftmailer.transport.authhandler']), + [$app['swiftmailer.transport.authhandler']], $app['swiftmailer.transport.eventdispatcher'] ); $encryption = null; - if (in_array($app['phraseanet.registry']->get('GV_smtp_secure'), array('ssl', 'tls'))) { + if (in_array($app['phraseanet.registry']->get('GV_smtp_secure'), ['ssl', 'tls'])) { $encryption = $app['phraseanet.registry']->get('GV_smtp_secure'); } - $options = $app['swiftmailer.options'] = array_replace(array( + $options = $app['swiftmailer.options'] = array_replace([ 'host' => $app['phraseanet.registry']->get('GV_smtp_host'), 'port' => $app['phraseanet.registry']->get('GV_smtp_port'), 'username' => $app['phraseanet.registry']->get('GV_smtp_user'), 'password' => $app['phraseanet.registry']->get('GV_smtp_password'), 'encryption' => $encryption, 'auth_mode' => null, - ), $app['swiftmailer.options']); + ], $app['swiftmailer.options']); $transport->setHost($options['host']); $transport->setPort($options['port']); @@ -400,8 +400,8 @@ class Application extends SilexApplication $this['dispatcher'] = $this->share( $this->extend('dispatcher', function ($dispatcher, Application $app) { - $dispatcher->addListener(KernelEvents::REQUEST, array($app, 'initSession'), 254); - $dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'addUTF8Charset'), -128); + $dispatcher->addListener(KernelEvents::REQUEST, [$app, 'initSession'], 254); + $dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128); $dispatcher->addSubscriber(new LogoutSubscriber()); $dispatcher->addSubscriber(new PhraseaLocaleSubscriber($app)); $dispatcher->addSubscriber(new MaintenanceSubscriber($app)); @@ -411,7 +411,7 @@ class Application extends SilexApplication }) ); - $this['log.channels'] = array('monolog', 'task-manager.logger'); + $this['log.channels'] = ['monolog', 'task-manager.logger']; $this->register(new LocaleServiceProvider()); @@ -462,7 +462,7 @@ class Application extends SilexApplication * * @throws FormException if any given option is not applicable to the given type */ - public function form($type = 'form', $data = null, array $options = array(), FormBuilderInterface $parent = null) + public function form($type = 'form', $data = null, array $options = [], FormBuilderInterface $parent = null) { return $this['form.factory']->create($type, $data, $options, $parent); } @@ -475,7 +475,7 @@ class Application extends SilexApplication * * @return string The generated path */ - public function path($route, $parameters = array()) + public function path($route, $parameters = []) { return $this['url_generator']->generate($route, $parameters, UrlGenerator::ABSOLUTE_PATH); } @@ -488,7 +488,7 @@ class Application extends SilexApplication * * @return RedirectResponse */ - public function redirectPath($route, $parameters = array()) + public function redirectPath($route, $parameters = []) { return $this->redirect($this->path($route, $parameters)); } @@ -501,7 +501,7 @@ class Application extends SilexApplication * * @return string The generated URL */ - public function url($route, $parameters = array()) + public function url($route, $parameters = []) { return $this['url_generator']->generate($route, $parameters, UrlGenerator::ABSOLUTE_URL); } @@ -514,7 +514,7 @@ class Application extends SilexApplication * * @return RedirectResponse */ - public function redirectUrl($route, $parameters = array()) + public function redirectUrl($route, $parameters = []) { return $this->redirect($this->url($route, $parameters)); } @@ -671,7 +671,7 @@ class Application extends SilexApplication * * @return array */ - public function getFlash($type, array $default = array()) + public function getFlash($type, array $default = []) { return $this['session']->getFlashBag()->get($type, $default); } @@ -763,7 +763,7 @@ class Application extends SilexApplication */ public function getOpenCollections() { - return array(); + return []; } public function bindRoutes() diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 55c33d3cd3..7e88af31cb 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -39,24 +39,24 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { $result = new \API_V1_result($app, $request, $apiAdapter); - return $result->set_datas(array( + return $result->set_datas([ 'name' => $app['phraseanet.registry']->get('GV_homeTitle'), 'type' => 'phraseanet', 'description' => $app['phraseanet.registry']->get('GV_metaDescription'), 'documentation' => 'https://docs.phraseanet.com/Devel', - 'versions' => array( - '1' => array( + 'versions' => [ + '1' => [ 'number' => $apiAdapter->get_version(), 'uri' => '/api/v1/', 'authenticationProtocol' => 'OAuth2', 'authenticationVersion' => 'draft#v9', - 'authenticationEndPoints' => array( + 'authenticationEndPoints' => [ 'authorization_token' => '/api/oauthv2/authorize', 'access_token' => '/api/oauthv2/token' - ) - ) - ) - ))->get_response(); + ] + ] + ] + ])->get_response(); }); $app->mount('/api/oauthv2', new Oauth2()); diff --git a/lib/Alchemy/Phrasea/Application/Root.php b/lib/Alchemy/Phrasea/Application/Root.php index e6470185d9..cf48540fae 100644 --- a/lib/Alchemy/Phrasea/Application/Root.php +++ b/lib/Alchemy/Phrasea/Application/Root.php @@ -50,9 +50,9 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { $app->bindRoutes(); if (PhraseaApplication::ENV_DEV === $app->getEnvironment()) { - $app->register($p = new WebProfilerServiceProvider(), array( + $app->register($p = new WebProfilerServiceProvider(), [ 'profiler.cache_dir' => $app['root.path'] . '/tmp/cache/profiler', - )); + ]); $app->mount('/_profiler', $p); } diff --git a/lib/Alchemy/Phrasea/Authentication/ACLProvider.php b/lib/Alchemy/Phrasea/Authentication/ACLProvider.php index 420a290155..61d1bd1a4d 100644 --- a/lib/Alchemy/Phrasea/Authentication/ACLProvider.php +++ b/lib/Alchemy/Phrasea/Authentication/ACLProvider.php @@ -21,7 +21,7 @@ class ACLProvider * * @var array */ - private static $cache = array(); + private static $cache = []; private $app; @@ -51,7 +51,7 @@ class ACLProvider */ public function purge() { - self::$cache = array(); + self::$cache = []; } /** diff --git a/lib/Alchemy/Phrasea/Authentication/AccountCreator.php b/lib/Alchemy/Phrasea/Authentication/AccountCreator.php index bee068c7ee..8ce723e9de 100644 --- a/lib/Alchemy/Phrasea/Authentication/AccountCreator.php +++ b/lib/Alchemy/Phrasea/Authentication/AccountCreator.php @@ -61,7 +61,7 @@ class AccountCreator * @throws RuntimeException In case the AccountCreator is disabled * @throws InvalidArgumentException In case a user with the same email already exists */ - public function create(Application $app, $id, $email = null, array $templates = array()) + public function create(Application $app, $id, $email = null, array $templates = []) { if (!$this->enabled) { throw new RuntimeException('Account creator is disabled'); @@ -81,7 +81,7 @@ class AccountCreator $user = \User_Adapter::create($app, $login, $this->random->generatePassword(), $email, false, false); - $base_ids = array(); + $base_ids = []; foreach ($this->appbox->get_databoxes() as $databox) { foreach ($databox->get_collections() as $collection) { $base_ids[] = $collection->get_base_id(); diff --git a/lib/Alchemy/Phrasea/Authentication/Authenticator.php b/lib/Alchemy/Phrasea/Authentication/Authenticator.php index b9d1c39abd..3256087a15 100644 --- a/lib/Alchemy/Phrasea/Authentication/Authenticator.php +++ b/lib/Alchemy/Phrasea/Authentication/Authenticator.php @@ -88,7 +88,7 @@ class Authenticator public function refreshAccount(Session $session) { - if (!$this->em->getRepository('Alchemy\Phrasea\Model\Entities\Session')->findOneBy(array('id' => $session->getId()))) { + if (!$this->em->getRepository('Alchemy\Phrasea\Model\Entities\Session')->findOneBy(['id' => $session->getId()])) { throw new RuntimeException('Unable to refresh the session, it does not exist anymore'); } diff --git a/lib/Alchemy/Phrasea/Authentication/Context.php b/lib/Alchemy/Phrasea/Authentication/Context.php index 95e8bcd37e..dd039366ac 100644 --- a/lib/Alchemy/Phrasea/Authentication/Context.php +++ b/lib/Alchemy/Phrasea/Authentication/Context.php @@ -34,7 +34,7 @@ class Context public function setContext($context) { - if (false === in_array($context, array(static::CONTEXT_OAUTH2_NATIVE, static::CONTEXT_OAUTH2_TOKEN, static::CONTEXT_NATIVE, static::CONTEXT_GUEST), true)) { + if (false === in_array($context, [static::CONTEXT_OAUTH2_NATIVE, static::CONTEXT_OAUTH2_TOKEN, static::CONTEXT_NATIVE, static::CONTEXT_GUEST], true)) { throw new InvalidArgumentException(sprintf('`%s` is not a valid context', $context)); } diff --git a/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php b/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php index 5b52ff66d4..c1b4b02fde 100644 --- a/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php +++ b/lib/Alchemy/Phrasea/Authentication/PersistentCookie/Manager.php @@ -39,7 +39,7 @@ class Manager { $session = $this->em ->getRepository('Alchemy\Phrasea\Model\Entities\Session') - ->findOneBy(array('token' => $cookieValue)); + ->findOneBy(['token' => $cookieValue]); if (!$session) { return false; diff --git a/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php b/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php index 9614db60e5..50df717c01 100644 --- a/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php +++ b/lib/Alchemy/Phrasea/Authentication/Phrasea/NativeAuthentication.php @@ -36,7 +36,7 @@ class NativeAuthentication implements PasswordAuthenticationInterface */ public function getUsrId($username, $password, Request $request) { - if (in_array($username, array('invite', 'autoregister'))) { + if (in_array($username, ['invite', 'autoregister'])) { return null; } @@ -48,7 +48,7 @@ class NativeAuthentication implements PasswordAuthenticationInterface LIMIT 0, 1'; $stmt = $this->conn->prepare($sql); - $stmt->execute(array(':login' => $username)); + $stmt->execute([':login' => $username]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -71,11 +71,11 @@ class NativeAuthentication implements PasswordAuthenticationInterface $sql = 'UPDATE usr SET usr_password = :password, nonce = :nonce WHERE usr_id = :usr_id'; $stmt = $this->conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':password' => $row['usr_password'], ':nonce' => $row['nonce'], ':usr_id' => $row['usr_id'], - )); + ]); $stmt->closeCursor(); } } diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php b/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php index 72f71c1627..91c8210b9b 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/AbstractProvider.php @@ -57,7 +57,7 @@ abstract class AbstractProvider implements ProviderInterface */ public function getTemplates(Identity $identity) { - return array(); + return []; } /** diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php b/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php index db18c3911b..7a27383d34 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Facebook.php @@ -51,14 +51,14 @@ class Facebook extends AbstractProvider */ public function authenticate() { - return new RedirectResponse($this->facebook->getLoginUrl(array( + return new RedirectResponse($this->facebook->getLoginUrl([ 'scope' => 'email', 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ) - ))); + ])); } /** diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php b/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php index bd868e3586..918f75f098 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php @@ -26,7 +26,7 @@ class Factory $this->session = $session; } - public function build($name, array $options = array()) + public function build($name, array $options = []) { $name = implode('', array_map(function ($chunk) { return ucfirst(strtolower($chunk)); diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Github.php b/lib/Alchemy/Phrasea/Authentication/Provider/Github.php index c14f3fefc2..4f3988eb96 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Github.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Github.php @@ -84,16 +84,16 @@ class Github extends AbstractProvider $this->session->set('github.provider.state', $state); - return new RedirectResponse('https://github.com/login/oauth/authorize?' . http_build_query(array( + return new RedirectResponse('https://github.com/login/oauth/authorize?' . http_build_query([ 'client_id' => $this->key, 'scope' => 'user,user:email', 'state' => $state, 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), - ), '', '&')); + ], '', '&')); } /** @@ -120,16 +120,16 @@ class Github extends AbstractProvider try { $guzzleRequest = $this->client->post('access_token'); - $guzzleRequest->addPostFields(array( + $guzzleRequest->addPostFields([ 'code' => $request->query->get('code'), 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), 'client_id' => $this->key, 'client_secret' => $this->secret, - )); + ]); $guzzleRequest->setHeader('Accept', 'application/json'); $response = $guzzleRequest->send(); } catch (GuzzleException $e) { diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php b/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php index 6087eb0fa0..203c028f39 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/GooglePlus.php @@ -38,16 +38,16 @@ class GooglePlus extends AbstractProvider $this->plus = new \Google_PlusService($this->client); - $this->client->setScopes(array( + $this->client->setScopes([ 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/userinfo.email', - )); + ]); $this->client->setRedirectUri( $this->generator->generate( - 'login_authentication_provider_callback', array( + 'login_authentication_provider_callback', [ 'providerId' => $this->getId(), - ), UrlGenerator::ABSOLUTE_URL + ], UrlGenerator::ABSOLUTE_URL ) ); @@ -218,7 +218,7 @@ class GooglePlus extends AbstractProvider try { $request = $this->guzzle->get(sprintf( 'https://www.googleapis.com/oauth2/v1/tokeninfo?%s', - http_build_query(array('access_token' => $token['access_token']), '', '&') + http_build_query(['access_token' => $token['access_token']], '', '&') )); $response = $request->send(); } catch (GuzzleException $e) { diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php b/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php index d05ab8460c..e8016475b0 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Linkedin.php @@ -84,17 +84,17 @@ class Linkedin extends AbstractProvider $this->session->set('linkedin.provider.state', $state); - return new RedirectResponse('https://www.linkedin.com/uas/oauth2/authorization?' . http_build_query(array( + return new RedirectResponse('https://www.linkedin.com/uas/oauth2/authorization?' . http_build_query([ 'response_type' => 'code', 'client_id' => $this->key, 'scope' => 'r_basicprofile r_emailaddress', 'state' => $state, 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), - ), '', '&')); + ], '', '&')); } /** @@ -119,17 +119,17 @@ class Linkedin extends AbstractProvider } try { - $guzzleRequest = $this->client->post('https://www.linkedin.com/uas/oauth2/accessToken?' . http_build_query(array( + $guzzleRequest = $this->client->post('https://www.linkedin.com/uas/oauth2/accessToken?' . http_build_query([ 'grant_type' => 'authorization_code', 'code' => $request->query->get('code'), 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), 'client_id' => $this->key, 'client_secret' => $this->secret, - ), '', '&')); + ], '', '&')); $response = $guzzleRequest->send(); } catch (GuzzleException $e) { throw new NotAuthenticatedException('Unable to query LinkedIn access token', $e->getCode(), $e); diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php b/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php index ddf6e0eba2..55f9144516 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Token/Identity.php @@ -23,7 +23,7 @@ class Identity const PROPERTY_USERNAME = 'username'; const PROPERTY_COMPANY = 'company'; - private $data = array( + private $data = [ self::PROPERTY_ID => null, self::PROPERTY_IMAGEURL => null, self::PROPERTY_EMAIL => null, @@ -31,9 +31,9 @@ class Identity self::PROPERTY_LASTNAME => null, self::PROPERTY_USERNAME => null, self::PROPERTY_COMPANY => null, - ); + ]; - public function __construct(array $data = array()) + public function __construct(array $data = []) { $this->data = array_merge($this->data, $data); } @@ -55,10 +55,10 @@ class Identity */ public function getDisplayName() { - $data = array_filter(array( + $data = array_filter([ $this->get(self::PROPERTY_FIRSTNAME), $this->get(self::PROPERTY_LASTNAME), - )); + ]); return implode(' ', $data); } diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php b/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php index d7d3144c76..26dda5c1da 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Twitter.php @@ -74,11 +74,11 @@ class Twitter extends AbstractProvider $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/request_token', ''), - array('oauth_callback' => $this->generator->generate( + ['oauth_callback' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL - )) + )] ); if ($code != 200) { @@ -92,7 +92,7 @@ class Twitter extends AbstractProvider return new RedirectResponse(sprintf( '%s?%s', $this->twitter->url("oauth/authenticate", ''), - http_build_query(array('oauth_token' => $oauth['oauth_token']), '', '&') + http_build_query(['oauth_token' => $oauth['oauth_token']], '', '&') )); } @@ -117,7 +117,7 @@ class Twitter extends AbstractProvider $code = $this->twitter->request( 'POST', $this->twitter->url('oauth/access_token', ''), - array('oauth_verifier' => $request->query->get('oauth_verifier')) + ['oauth_verifier' => $request->query->get('oauth_verifier')] ); if ($code != 200) { @@ -248,11 +248,11 @@ class Twitter extends AbstractProvider */ public static function create(UrlGenerator $generator, SessionInterface $session, array $options) { - $twitter = new \tmhOAuth(array( + $twitter = new \tmhOAuth([ 'consumer_key' => $options['consumer-key'], 'consumer_secret' => $options['consumer-secret'], 'timezone' => date_default_timezone_get(), - )); + ]); return new Twitter($generator, $session, $twitter); } diff --git a/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php b/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php index 9922c70b79..d7d4e1caff 100644 --- a/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php +++ b/lib/Alchemy/Phrasea/Authentication/Provider/Viadeo.php @@ -85,16 +85,16 @@ class Viadeo extends AbstractProvider $this->session->set('viadeo.provider.state', $state); - return new RedirectResponse('https://secure.viadeo.com/oauth-provider/authorize2?' . http_build_query(array( + return new RedirectResponse('https://secure.viadeo.com/oauth-provider/authorize2?' . http_build_query([ 'client_id' => $this->key, 'state' => $state, 'response_type' => 'code', 'redirect_uri' => $this->generator->generate( 'login_authentication_provider_callback', - array('providerId' => $this->getId()), + ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL ), - ))); + ])); } /** @@ -138,13 +138,13 @@ class Viadeo extends AbstractProvider try { $guzzleRequest = $this->client->post('https://secure.viadeo.com/oauth-provider/access_token2'); - $guzzleRequest->addPostFields(array( + $guzzleRequest->addPostFields([ 'grant_type' => 'authorization_code', 'code' => $request->query->get('code'), - 'redirect_uri' => $this->generator->generate('login_authentication_provider_callback', array('providerId' => $this->getId()), UrlGenerator::ABSOLUTE_URL), + 'redirect_uri' => $this->generator->generate('login_authentication_provider_callback', ['providerId' => $this->getId()], UrlGenerator::ABSOLUTE_URL), 'client_id' => $this->key, 'client_secret' => $this->secret, - )); + ]); $guzzleRequest->setHeader('Accept', 'application/json'); $response = $guzzleRequest->send(); } catch (GuzzleException $e) { diff --git a/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php b/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php index 65467fbf50..5bdc9736cb 100644 --- a/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php +++ b/lib/Alchemy/Phrasea/Authentication/ProvidersCollection.php @@ -16,7 +16,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; class ProvidersCollection implements \Countable, \IteratorAggregate { - private $providers = array(); + private $providers = []; public function getIterator() { diff --git a/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php b/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php index e92ee6c360..a813f1d936 100644 --- a/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php +++ b/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php @@ -42,7 +42,7 @@ class SuggestionFinder $sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':email' => $infos->get(Identity::PROPERTY_EMAIL))); + $stmt->execute([':email' => $infos->get(Identity::PROPERTY_EMAIL)]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php b/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php index ee6eba475d..496a9f6dc7 100644 --- a/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php +++ b/lib/Alchemy/Phrasea/Border/Attribute/MetaField.php @@ -87,11 +87,11 @@ class MetaField implements AttributeInterface */ public function asString() { - return serialize(array( + return serialize([ 'id' => $this->databox_field->get_id(), 'sbas_id' => $this->databox_field->get_databox()->get_sbas_id(), 'value' => $this->value - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php b/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php index 1c0d1b277e..a37ef77626 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php +++ b/lib/Alchemy/Phrasea/Border/Checker/AbstractChecker.php @@ -20,8 +20,8 @@ use Alchemy\Phrasea\Border\File; abstract class AbstractChecker implements CheckerInterface { protected $app; - protected $databoxes = array(); - protected $collections = array(); + protected $databoxes = []; + protected $collections = []; public function __construct(Application $app) { @@ -44,7 +44,7 @@ abstract class AbstractChecker implements CheckerInterface throw new \LogicException('You can not restrict on databoxes and collections simultanously'); } - $this->databoxes = array(); + $this->databoxes = []; foreach ($this->toIterator($databoxes) as $databox) { if (! $databox instanceof \databox) { @@ -72,7 +72,7 @@ abstract class AbstractChecker implements CheckerInterface throw new \LogicException('You can not restrict on databoxes and collections simultanously'); } - $this->collections = array(); + $this->collections = []; foreach ($this->toIterator($collections) as $collection) { if (! $collection instanceof \collection) { @@ -122,6 +122,6 @@ abstract class AbstractChecker implements CheckerInterface */ protected function toIterator($data) { - return new \ArrayObject(is_array($data) ? $data : array($data)); + return new \ArrayObject(is_array($data) ? $data : [$data]); } } diff --git a/lib/Alchemy/Phrasea/Border/Checker/Filename.php b/lib/Alchemy/Phrasea/Border/Checker/Filename.php index 78d208172f..372b66ae08 100644 --- a/lib/Alchemy/Phrasea/Border/Checker/Filename.php +++ b/lib/Alchemy/Phrasea/Border/Checker/Filename.php @@ -28,7 +28,7 @@ class Filename extends AbstractChecker * @param Application $app * @param array $options An array of options. available : 'sensitive' (false by default) */ - public function __construct(Application $app, array $options = array()) + public function __construct(Application $app, array $options = []) { if ( ! isset($options['sensitive'])) { $options['sensitive'] = false; diff --git a/lib/Alchemy/Phrasea/Border/File.php b/lib/Alchemy/Phrasea/Border/File.php index d3f9eac215..02c6c4fc50 100644 --- a/lib/Alchemy/Phrasea/Border/File.php +++ b/lib/Alchemy/Phrasea/Border/File.php @@ -65,7 +65,7 @@ class File $this->app = $app; $this->media = $media; $this->collection = $collection; - $this->attributes = array(); + $this->attributes = []; $this->originalName = $originalName ? : pathinfo($this->media->getFile()->getPathname(), PATHINFO_BASENAME); } @@ -96,13 +96,13 @@ class File return $this->uuid; } - $availableUUIDs = array( + $availableUUIDs = [ 'XMP-exif:ImageUniqueID', 'SigmaRaw:ImageUniqueID', 'IPTC:UniqueDocumentID', 'ExifIFD:ImageUniqueID', 'Canon:ImageUniqueID', - ); + ]; if (! $this->uuid) { $metadatas = $this->media->getMetadatas(); diff --git a/lib/Alchemy/Phrasea/Border/Manager.php b/lib/Alchemy/Phrasea/Border/Manager.php index 1c1ad8da42..1e80ceadb1 100644 --- a/lib/Alchemy/Phrasea/Border/Manager.php +++ b/lib/Alchemy/Phrasea/Border/Manager.php @@ -49,7 +49,7 @@ use XPDF\PdfToText; */ class Manager { - protected $checkers = array(); + protected $checkers = []; protected $app; protected $filesystem; protected $pdfToText; @@ -279,12 +279,12 @@ class Manager ) ); - $metadatas = array(); + $metadatas = []; /** * @todo $key is not tagname but fieldname */ - $fieldToKeyMap = array(); + $fieldToKeyMap = []; if (! $fieldToKeyMap) { foreach ($file->getCollection()->get_databox()->get_meta_structure() as $databox_field) { @@ -292,7 +292,7 @@ class Manager $tagname = $databox_field->get_tag()->getTagname(); if ( ! isset($fieldToKeyMap[$tagname])) { - $fieldToKeyMap[$tagname] = array(); + $fieldToKeyMap[$tagname] = []; } $fieldToKeyMap[$tagname][] = $databox_field->get_name(); @@ -309,7 +309,7 @@ class Manager foreach ($fieldToKeyMap[$key] as $k) { if ( ! isset($metadatas[$k])) { - $metadatas[$k] = array(); + $metadatas[$k] = []; } $metadatas[$k] = array_merge($metadatas[$k], $metadata->getValue()->asArray()); @@ -328,7 +328,7 @@ class Manager $key = $attribute->getField()->get_name(); if ( ! isset($metadatas[$key])) { - $metadatas[$key] = array(); + $metadatas[$key] = []; } $metadatas[$key] = array_merge($metadatas[$key], $attribute->getValue()); @@ -344,7 +344,7 @@ class Manager foreach ($fieldToKeyMap[$key] as $k) { if ( ! isset($metadatas[$k])) { - $metadatas[$k] = array(); + $metadatas[$k] = []; } $metadatas[$k] = array_merge($metadatas[$k], $attribute->getValue()->getValue()->asArray()); @@ -368,7 +368,7 @@ class Manager $databox = $element->get_databox(); - $metas = array(); + $metas = []; foreach ($metadatas as $fieldname => $values) { foreach ($databox->get_meta_structure()->get_elements() as $databox_field) { @@ -377,7 +377,7 @@ class Manager if ($databox_field->is_multi()) { - $tmpValues = array(); + $tmpValues = []; foreach ($values as $value) { $tmpValues = array_merge($tmpValues, \caption_field::get_multi_values($value, $databox_field->get_separator())); } @@ -388,11 +388,11 @@ class Manager if ( ! trim($value)) { continue; } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'meta_id' => null, 'value' => $value, - ); + ]; } } else { @@ -402,11 +402,11 @@ class Manager continue; } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'meta_id' => null, 'value' => $value, - ); + ]; } } } diff --git a/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php b/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php index 303bbb5029..0fee025c3e 100644 --- a/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php +++ b/lib/Alchemy/Phrasea/Border/MetaFieldsBag.php @@ -25,7 +25,7 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface */ public function toMetadataArray(\databox_descriptionStructure $metadatasStructure) { - $metas = array(); + $metas = []; $unicode = new \unicode(); foreach ($metadatasStructure as $databox_field) { @@ -34,7 +34,7 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface $values = $this->get($databox_field->get_name())->getValue(); - $tmp = array(); + $tmp = []; foreach ($values as $value) { foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) { @@ -52,11 +52,11 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } else { @@ -69,11 +69,11 @@ class MetaFieldsBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } } diff --git a/lib/Alchemy/Phrasea/Border/MetadataBag.php b/lib/Alchemy/Phrasea/Border/MetadataBag.php index 07528a9ad0..6cffd252d7 100644 --- a/lib/Alchemy/Phrasea/Border/MetadataBag.php +++ b/lib/Alchemy/Phrasea/Border/MetadataBag.php @@ -26,7 +26,7 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface */ public function toMetadataArray(\databox_descriptionStructure $metadatasStructure) { - $metas = array(); + $metas = []; $unicode = new \unicode(); foreach ($metadatasStructure as $databox_field) { @@ -42,7 +42,7 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface $values = $this->get($databox_field->get_tag()->getTagname())->getValue()->asArray(); - $tmp = array(); + $tmp = []; foreach ($values as $value) { foreach (\caption_field::get_multi_values($value, $databox_field->get_separator()) as $v) { @@ -60,11 +60,11 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } else { $value = $this->get($databox_field->get_tag()->getTagname())->getValue()->asString(); @@ -75,11 +75,11 @@ class MetadataBag extends ArrayCollection implements MetaBagInterface $value = $unicode->parseDate($value); } - $metas[] = array( + $metas[] = [ 'meta_struct_id' => $databox_field->get_id(), 'value' => $value, 'meta_id' => null - ); + ]; } } } diff --git a/lib/Alchemy/Phrasea/Border/Visa.php b/lib/Alchemy/Phrasea/Border/Visa.php index b4bde581a7..671e7d60a9 100644 --- a/lib/Alchemy/Phrasea/Border/Visa.php +++ b/lib/Alchemy/Phrasea/Border/Visa.php @@ -33,7 +33,7 @@ class Visa */ public function __construct() { - $this->responses = array(); + $this->responses = []; } /** diff --git a/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php b/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php index 2ec5f41e1f..39be32c34d 100644 --- a/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php +++ b/lib/Alchemy/Phrasea/Cache/ConnectionFactory.php @@ -15,7 +15,7 @@ use Alchemy\Phrasea\Exception\RuntimeException; class ConnectionFactory { - private $connections = array(); + private $connections = []; /** * Returns a Redis connection. @@ -26,9 +26,9 @@ class ConnectionFactory * * @throws RuntimeException */ - public function getRedisConnection(array $options = array()) + public function getRedisConnection(array $options = []) { - $options = array_replace(array('host' => 'localhost', 'port' => 6379), $options); + $options = array_replace(['host' => 'localhost', 'port' => 6379], $options); if (null !== $cache = $this->getConnection('redis', $options)) { return $cache; } @@ -58,9 +58,9 @@ class ConnectionFactory * * @throws RuntimeException */ - public function getMemcacheConnection(array $options = array()) + public function getMemcacheConnection(array $options = []) { - $options = array_replace(array('host' => 'localhost', 'port' => 11211), $options); + $options = array_replace(['host' => 'localhost', 'port' => 11211], $options); if (null !== $cache = $this->getConnection('memcache', $options)) { return $cache; } @@ -91,9 +91,9 @@ class ConnectionFactory * * @throws RuntimeException */ - public function getMemcachedConnection(array $options = array()) + public function getMemcachedConnection(array $options = []) { - $options = array_replace(array('host' => 'localhost', 'port' => 11211), $options); + $options = array_replace(['host' => 'localhost', 'port' => 11211], $options); if (null !== $cache = $this->getConnection('memcached', $options)) { return $cache; } diff --git a/lib/Alchemy/Phrasea/Cache/Manager.php b/lib/Alchemy/Phrasea/Cache/Manager.php index 0ed4ead53d..3a2f830c53 100644 --- a/lib/Alchemy/Phrasea/Cache/Manager.php +++ b/lib/Alchemy/Phrasea/Cache/Manager.php @@ -22,8 +22,8 @@ class Manager private $file; /** @var Compiler */ private $compiler; - private $registry = array(); - private $drivers = array(); + private $registry = []; + private $drivers = []; /** @var Logger */ private $logger; /** @var Factory */ @@ -37,7 +37,7 @@ class Manager $this->factory = $factory; if (!is_file($file)) { - $this->registry = array(); + $this->registry = []; $this->save(); } else { $this->registry = require $file; @@ -55,7 +55,7 @@ class Manager $driver->flushAll(); } - $this->registry = array(); + $this->registry = []; $this->save(); return $this; @@ -78,7 +78,7 @@ class Manager $cache = $this->factory->create($name, $options); } catch (RuntimeException $e) { $this->logger->error($e->getMessage()); - $cache = $this->factory->create('array', array()); + $cache = $this->factory->create('array', []); } $cache->setNamespace(md5(__DIR__)); diff --git a/lib/Alchemy/Phrasea/Cache/RedisCache.php b/lib/Alchemy/Phrasea/Cache/RedisCache.php index 58efb346de..e2ecc934e9 100644 --- a/lib/Alchemy/Phrasea/Cache/RedisCache.php +++ b/lib/Alchemy/Phrasea/Cache/RedisCache.php @@ -96,13 +96,13 @@ class RedisCache extends CacheProvider implements Cache { $stats = $this->_redis->info(); - return array( + return [ Cache::STATS_HITS => false, Cache::STATS_MISSES => false, Cache::STATS_UPTIME => $stats['uptime_in_seconds'], Cache::STATS_MEMORY_USAGE => $stats['used_memory'], Cache::STATS_MEMORY_AVAILIABLE => false, - ); + ]; } /** diff --git a/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php b/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php index 094bdf0c92..939512694c 100644 --- a/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php +++ b/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php @@ -73,7 +73,7 @@ class BuildMissingSubdefs extends Command if ( ! $record->has_subdef($subdef->get_name())) { $todo = true; } - if (in_array($subdef->get_name(), array('preview', 'thumbnail', 'thumbnailgif'))) { + if (in_array($subdef->get_name(), ['preview', 'thumbnail', 'thumbnailgif'])) { try { $sub = $record->get_subdef($subdef->get_name()); if ( ! $sub->is_physically_present()) { @@ -85,7 +85,7 @@ class BuildMissingSubdefs extends Command } if ($todo) { - $record->generate_subdefs($databox, $this->container, array($subdef->get_name())); + $record->generate_subdefs($databox, $this->container, [$subdef->get_name()]); $this->container['monolog']->addInfo("generate " . $subdef->get_name() . " for record " . $record->get_record_id()); $n ++; } diff --git a/lib/Alchemy/Phrasea/Command/CheckConfig.php b/lib/Alchemy/Phrasea/Command/CheckConfig.php index 964c67e048..041356868d 100644 --- a/lib/Alchemy/Phrasea/Command/CheckConfig.php +++ b/lib/Alchemy/Phrasea/Command/CheckConfig.php @@ -40,7 +40,7 @@ class CheckConfig extends AbstractCheckCommand protected function provideRequirements() { - return array( + return [ BinariesProbe::create($this->container), CacheServerProbe::create($this->container), DataboxStructureProbe::create($this->container), @@ -52,6 +52,6 @@ class CheckConfig extends AbstractCheckCommand SearchEngineProbe::create($this->container), SubdefsPathsProbe::create($this->container), SystemProbe::create($this->container), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Command/CreateCollection.php b/lib/Alchemy/Phrasea/Command/CreateCollection.php index 76533e12ff..b2d78c3f33 100644 --- a/lib/Alchemy/Phrasea/Command/CreateCollection.php +++ b/lib/Alchemy/Phrasea/Command/CreateCollection.php @@ -52,7 +52,7 @@ class CreateCollection extends Command if ($new_collection && $input->getOption('base_id_rights')) { $query = new \User_Query($this->container); - $total = $query->on_base_ids(array($input->getOption('base_id_rights')))->get_total(); + $total = $query->on_base_ids([$input->getOption('base_id_rights')])->get_total(); $n = 0; while ($n < $total) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php b/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php index a252d03c17..788bf40f94 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php +++ b/lib/Alchemy/Phrasea/Command/Developer/AbstractRoutesDumper.php @@ -25,7 +25,7 @@ abstract class AbstractRoutesDumper extends Command $maxNameLength = 0; $maxMethodsLength = 0; - $data = array(); + $data = []; foreach ($routes as $name => $route) { $methods = implode('|', $route->getMethods()); @@ -40,12 +40,12 @@ abstract class AbstractRoutesDumper extends Command $warning = true; } - $data[] = array( + $data[] = [ 'name' => $name, 'methods' => $methods ?: 'ALL', 'pattern' => $pattern, 'warning' => $warning - ); + ]; } foreach ($data as $route) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php b/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php index c684b1034d..95afa2df82 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php +++ b/lib/Alchemy/Phrasea/Command/Developer/BowerInstall.php @@ -59,7 +59,7 @@ class BowerInstall extends Command if ($input->getOption('clear-cache')) { $output->write("Cleaning bower cache... "); - $bower->command(array('cache', 'clean')); + $bower->command(['cache', 'clean']); $output->writeln("OK"); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php index 2442e6daa9..08180dc20b 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php +++ b/lib/Alchemy/Phrasea/Command/Developer/ComposerInstall.php @@ -42,7 +42,7 @@ class ComposerInstall extends Command $output->writeln("ERROR Failed to update composer, bypassing"); } - $commands = array('install', '--optimize-autoloader', '--quiet', '--no-interaction'); + $commands = ['install', '--optimize-autoloader', '--quiet', '--no-interaction']; if ($input->getOption('prefer-source')) { $commands[] = '--prefer-source'; } @@ -50,11 +50,11 @@ class ComposerInstall extends Command try { if ($input->getOption('no-dev')) { $output->write("Installing dependencies without developer packages "); - $composer->command(array_merge($commands, array('--no-dev'))); + $composer->command(array_merge($commands, ['--no-dev'])); $output->writeln("OK"); } else { $output->write("Installing dependencies with developer packages "); - $composer->command(array_merge($commands, array('--dev'))); + $composer->command(array_merge($commands, ['--dev'])); $output->writeln("OK"); } } catch (ExecutionFailureException $e) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php b/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php index 47e9fdab94..f67595f2b3 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Uninstaller.php @@ -32,7 +32,7 @@ class Uninstaller extends Command { $root = $this->container['root.path']; - foreach (array( + foreach ([ $root.'/tmp/configuration-compiled.php', $root.'/config/configuration.yml', $root.'/config/services.yml', @@ -44,20 +44,20 @@ class Uninstaller extends Command $root.'/config/_GV.php.old', $root.'/tmp/cache_registry.php', $root.'/tmp/cache_registry.yml', - ) as $file) { + ] as $file) { if (is_file($file)) { unlink($file); } } - foreach (array( + foreach ([ $root.'/tmp/serializer', $root.'/tmp/cache_twig', $root.'/tmp/cache_minify', $root.'/tmp/download', $root.'/tmp/locks', $root.'/tmp/cache', - ) as $dir) { + ] as $dir) { if (is_dir($dir)) { $finder = new Finder(); foreach ($finder->files()->in($dir) as $file) { diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php index f196e12a56..f118881108 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/BowerDriver.php @@ -32,13 +32,13 @@ class BowerDriver extends AbstractBinary * * @return BowerDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('bower.binaries', array('bower')); + $binaries = $conf->get('bower.binaries', ['bower']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php index 1d1b1db75f..a6cfed4fd9 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/ComposerDriver.php @@ -32,13 +32,13 @@ class ComposerDriver extends AbstractBinary * * @return ComposerDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('composer.binaries', array('composer')); + $binaries = $conf->get('composer.binaries', ['composer']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php index ce6837b955..61ca237e88 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/GruntDriver.php @@ -32,13 +32,13 @@ class GruntDriver extends AbstractBinary * * @return GruntDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('grunt.binaries', array('grunt')); + $binaries = $conf->get('grunt.binaries', ['grunt']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php index edf71cecc7..f8c2cf0b40 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/RecessDriver.php @@ -32,13 +32,13 @@ class RecessDriver extends AbstractBinary * * @return RecessDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('recess.binaries', array('recess')); + $binaries = $conf->get('recess.binaries', ['recess']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php b/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php index e3b106d60d..f12677a0e3 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php +++ b/lib/Alchemy/Phrasea/Command/Developer/Utils/UglifyJsDriver.php @@ -32,13 +32,13 @@ class UglifyJsDriver extends AbstractBinary * * @return UglifyJsDriver */ - public static function create($conf = array(), LoggerInterface $logger = null) + public static function create($conf = [], LoggerInterface $logger = null) { if (!$conf instanceof ConfigurationInterface) { $conf = new Configuration($conf); } - $binaries = $conf->get('uglifyjs.binaries', array('uglifyjs')); + $binaries = $conf->get('uglifyjs.binaries', ['uglifyjs']); return static::load($binaries, $logger, $conf); } diff --git a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php index 5831d03a65..59aeafc93c 100644 --- a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php +++ b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php @@ -19,7 +19,7 @@ abstract class AbstractPluginCommand extends Command { protected function validatePlugins(InputInterface $input, OutputInterface $output) { - $manifests = array(); + $manifests = []; $output->write("Validating plugins..."); foreach ($this->container['plugins.explorer'] as $directory) { diff --git a/lib/Alchemy/Phrasea/Command/RecordAdd.php b/lib/Alchemy/Phrasea/Command/RecordAdd.php index a56af11811..e1cad50439 100644 --- a/lib/Alchemy/Phrasea/Command/RecordAdd.php +++ b/lib/Alchemy/Phrasea/Command/RecordAdd.php @@ -68,7 +68,7 @@ class RecordAdd extends Command if (!$input->getOption('yes')) { do { $continue = strtolower($dialog->ask($output, sprintf("Will add record %s (%s) on collection %s\nContinue ? (y/N)", $file, $media->getType(), $collection->get_label($this->container['locale.I18n'])), 'N')); - } while ( ! in_array($continue, array('y', 'n'))); + } while ( ! in_array($continue, ['y', 'n'])); if (strtolower($continue) !== 'y') { $output->writeln('Aborted !'); diff --git a/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php b/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php index e0ecddf7b2..4552a20cb8 100644 --- a/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php +++ b/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php @@ -55,7 +55,7 @@ class RescanTechnicalDatas extends Command $dialog = $this->getHelperSet()->get('dialog'); do { $continue = mb_strtolower($dialog->ask($output, sprintf('Estimated duration is %s, continue ? (y/N)', $duration), 'N')); - } while ( ! in_array($continue, array('y', 'n'))); + } while ( ! in_array($continue, ['y', 'n'])); if (strtolower($continue) !== 'y') { $output->writeln('Aborting !'); diff --git a/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php b/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php index b2f884812d..5637fd5466 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php +++ b/lib/Alchemy/Phrasea/Command/Setup/CheckEnvironment.php @@ -41,7 +41,7 @@ class CheckEnvironment extends AbstractCheckCommand */ protected function provideRequirements() { - return array( + return [ new BinariesRequirements(), new CacheServerRequirement(), new FilesystemRequirements(), @@ -50,6 +50,6 @@ class CheckEnvironment extends AbstractCheckCommand new PhraseaRequirements(), new PhpRequirements(), new SystemRequirements(), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Command/Setup/Install.php b/lib/Alchemy/Phrasea/Command/Setup/Install.php index 3c32f0cbad..81994eea1d 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/Install.php +++ b/lib/Alchemy/Phrasea/Command/Setup/Install.php @@ -129,14 +129,14 @@ class Install extends Command $abName = $dialog->ask($output, "DB name (phraseanet) : ", 'phraseanet'); try { - $abConn = new \connection_pdo('appbox', $hostname, $port, $dbUser, $dbPassword, $abName, array(), $this->container['debug']); + $abConn = new \connection_pdo('appbox', $hostname, $port, $dbUser, $dbPassword, $abName, [], $this->container['debug']); $output->writeln("\n\tApplication-Box : Connection successful !\n"); } catch (\Exception $e) { $output->writeln("\n\tInvalid connection parameters\n"); } } while (!$abConn); } else { - $abConn = new \connection_pdo('appbox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('appbox'), array(), $this->container['debug']); + $abConn = new \connection_pdo('appbox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('appbox'), [], $this->container['debug']); $output->writeln("\n\tApplication-Box : Connection successful !\n"); } @@ -155,12 +155,12 @@ class Install extends Command if ($dbName) { try { - $dbConn = new \connection_pdo('databox', $credentials['hostname'], $credentials['port'], $credentials['user'], $credentials['password'], $dbName, array(), $this->container['debug']); + $dbConn = new \connection_pdo('databox', $credentials['hostname'], $credentials['port'], $credentials['user'], $credentials['password'], $dbName, [], $this->container['debug']); $output->writeln("\n\tData-Box : Connection successful !\n"); do { $template = $dialog->ask($output, 'Choose a language template for metadata structure, available are fr (french) and en (english) (en) : ', 'en'); - } while (!in_array($template, array('en', 'fr'))); + } while (!in_array($template, ['en', 'fr'])); $output->writeln("\n\tLanguage selected is '$template'\n"); } catch (\Exception $e) { @@ -171,12 +171,12 @@ class Install extends Command } } while ($retry); } else { - $dbConn = new \connection_pdo('databox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('databox'), array(), $this->container['debug']); + $dbConn = new \connection_pdo('databox', $input->getOption('db-host'), $input->getOption('db-port'), $input->getOption('db-user'), $input->getOption('db-password'), $input->getOption('databox'), [], $this->container['debug']); $output->writeln("\n\tData-Box : Connection successful !\n"); $template = $input->getOption('db-template') ? : 'en'; } - return array($dbConn, $template); + return [$dbConn, $template]; } private function getCredentials(InputInterface $input, OutputInterface $output, DialogHelper $dialog) @@ -205,7 +205,7 @@ class Install extends Command throw new \RuntimeException('You have to provide both email and password'); } - return array($email, $password); + return [$email, $password]; } private function getDataPath(InputInterface $input, OutputInterface $output, DialogHelper $dialog) @@ -259,7 +259,7 @@ class Install extends Command private function detectBinaries() { - return array( + return [ 'php_binary' => $this->executableFinder->find('php'), 'phraseanet_indexer' => $this->executableFinder->find('phraseanet_indexer'), 'pdf2swf_binary' => $this->executableFinder->find('pdf2swf'), @@ -272,6 +272,6 @@ class Install extends Command 'pdftotext_binary' => $this->executableFinder->find('pdftotext'), 'ghostscript_binary' => $this->executableFinder->find('gs'), 'recess_binary' => $this->executableFinder->find('recess'), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php b/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php index 4a43efcaa4..b190011e22 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php +++ b/lib/Alchemy/Phrasea/Command/Setup/XSendFileMappingGenerator.php @@ -45,11 +45,11 @@ class XSendFileMappingGenerator extends Command $factory = new XSendFileFactory($this->container['monolog'], true, $type, $this->computeMapping($paths)); $mode = $factory->getMode(true); - $conf = array( + $conf = [ 'enabled' => $enabled, 'type' => $type, 'mapping' => $mode->getMapping(), - ); + ]; if ($input->getOption('write')) { $output->write("Writing configuration ..."); @@ -60,7 +60,7 @@ class XSendFileMappingGenerator extends Command } else { $output->writeln("Configuration will not be written, use --write option to write it"); $output->writeln(""); - $output->writeln(Yaml::dump(array('xsendfile' => $conf), 4)); + $output->writeln(Yaml::dump(['xsendfile' => $conf], 4)); } return 0; @@ -68,10 +68,10 @@ class XSendFileMappingGenerator extends Command private function computeMapping($paths) { - return array_merge(array( - array('mount-point' => 'protected_lazaret', 'directory' => $this->container['root.path'] . '/tmp/lazaret'), - array('mount-point' => 'protected_download', 'directory' => $this->container['root.path'] . '/tmp/download'), - ), array_map(array($this, 'pathsToConf'), array_unique($paths))); + return array_merge([ + ['mount-point' => 'protected_lazaret', 'directory' => $this->container['root.path'] . '/tmp/lazaret'], + ['mount-point' => 'protected_download', 'directory' => $this->container['root.path'] . '/tmp/download'], + ], array_map([$this, 'pathsToConf'], array_unique($paths))); } private function pathsToConf($path) @@ -79,7 +79,7 @@ class XSendFileMappingGenerator extends Command static $n = 0; $n++; - return array('mount-point' => 'protected_dir_'.$n, 'directory' => $path); + return ['mount-point' => 'protected_dir_'.$n, 'directory' => $path]; } private function extractPath(\appbox $appbox) diff --git a/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php b/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php index d47135f9b9..7d68b9bab9 100644 --- a/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php +++ b/lib/Alchemy/Phrasea/Command/Task/SchedulerRun.php @@ -38,7 +38,7 @@ class SchedulerRun extends Command protected function doExecute(InputInterface $input, OutputInterface $output) { declare(ticks=1); - $this->container['signal-handler']->register(array(SIGINT, SIGTERM), array($this, 'signalHandler')); + $this->container['signal-handler']->register([SIGINT, SIGTERM], [$this, 'signalHandler']); $this->container['task-manager']->addSubscriber(new LockFileSubscriber($this->container['task-manager.logger'], $this->container['root.path'].'/tmp/locks')); $this->container['task-manager']->start(); } diff --git a/lib/Alchemy/Phrasea/Command/Task/TaskList.php b/lib/Alchemy/Phrasea/Command/Task/TaskList.php index 5bcf634ca8..d6cf8782f3 100644 --- a/lib/Alchemy/Phrasea/Command/Task/TaskList.php +++ b/lib/Alchemy/Phrasea/Command/Task/TaskList.php @@ -36,18 +36,18 @@ class TaskList extends Command $errors ++; } - return array( + return [ $task->getId(), $task->getName(), $task->getStatus() !== 'started' ? $task->getStatus() . " (warning)" : $task->getStatus(), $error ? $info['actual'] . " (error)" : $info['actual'], $info['process-id'], - ); + ]; }, $this->container['manipulator.task']->getRepository()->findAll()); $this ->getHelperSet()->get('table') - ->setHeaders(array('Id', 'Name', 'Status', 'Actual', 'Process Id')) + ->setHeaders(['Id', 'Name', 'Status', 'Actual', 'Process Id']) ->setRows($rows) ->render($output); diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php index 5aea327d52..a018ea112a 100644 --- a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php +++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php @@ -137,11 +137,11 @@ class Step31 implements DatasUpgraderInterface $sql = 'UPDATE record SET uuid = :uuid, sha256 = :sha256 WHERE record_id = :record_id'; - $params = array( + $params = [ ':uuid' => $uuid, 'sha256' => $sha256, ':record_id' => $record['record_id'], - ); + ]; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php index cc428cfabc..3bdd33b52a 100644 --- a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php +++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php @@ -73,7 +73,7 @@ class Step35 implements DatasUpgraderInterface $stmt = $databox->get_connection()->prepare($sql); foreach ($rs as $row) { - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); try { $record = new \record_adapter($this->app, $databox->get_sbas_id(), $row['record_id']); @@ -138,7 +138,7 @@ class Step35 implements DatasUpgraderInterface { $metas = $record->get_databox()->get_meta_structure(); - $datas = $metadatas = array(); + $datas = $metadatas = []; if (false !== $sxe = simplexml_load_string($xml)) { $fields = $sxe->xpath('/record/description'); @@ -176,18 +176,18 @@ class Step35 implements DatasUpgraderInterface foreach ($datas as $meta_struct_id => $values) { if (is_array($values)) { foreach ($values as $value) { - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $value - ); + ]; } } else { - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta_struct_id , 'meta_id' => null , 'value' => $values - ); + ]; } } @@ -222,7 +222,7 @@ class Step35 implements DatasUpgraderInterface } } - $stmt[$databox->get_sbas_id()]->execute(array(':originalname' => $original, ':record_id' => $record['record_id'])); + $stmt[$databox->get_sbas_id()]->execute([':originalname' => $original, ':record_id' => $record['record_id']]); } /** diff --git a/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php b/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php index aa0f49532c..3ac72c1105 100644 --- a/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php +++ b/lib/Alchemy/Phrasea/Command/UpgradeDBDatas.php @@ -26,7 +26,7 @@ use vierbergenlars\SemVer\version; */ class UpgradeDBDatas extends Command { - protected $upgrades = array(); + protected $upgrades = []; /** * Constructor @@ -63,10 +63,10 @@ EOF throw new \Exception('You CAN NOT provide a `from` AND `at-version` option at the same time'); } - $versions = array( + $versions = [ 'Upgrade\\Step31' => '3.1', 'Upgrade\\Step35' => '3.5', - ); + ]; if (null !== $input->getOption('from')) { foreach ($versions as $classname => $version) { @@ -91,7 +91,7 @@ EOF public function setUpgrades(array $upgrades) { - $this->upgrades = array(); + $this->upgrades = []; foreach ($upgrades as $upgrade) { $this->addUpgrade($upgrade); @@ -131,7 +131,7 @@ EOF do { $continue = strtolower($dialog->ask($output, $question . 'Continue ? (Y/n)', 'Y')); - } while ( ! in_array($continue, array('y', 'n'))); + } while ( ! in_array($continue, ['y', 'n'])); if (strtolower($continue) !== 'y') { $output->writeln('Aborting !'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php index 274cacc22c..36f45b36d9 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php @@ -130,12 +130,12 @@ class Collection implements ControllerProviderInterface { $collection = \collection::get_from_base_id($app, $bas_id); - $admins = array(); + $admins = []; if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($bas_id, 'manage')) { $query = new \User_Query($app); - $admins = $query->on_base_ids(array($bas_id)) - ->who_have_right(array('order_master')) + $admins = $query->on_base_ids([$bas_id]) + ->who_have_right(['order_master']) ->execute() ->get_results(); } @@ -155,12 +155,12 @@ class Collection implements ControllerProviderInterface break; } - return $app['twig']->render('admin/collection/collection.html.twig', array( + return $app['twig']->render('admin/collection/collection.html.twig', [ 'collection' => $collection, 'admins' => $admins, 'errorMsg' => $errorMsg, 'reloadTree' => $request->query->get('reload-tree') === '1' - )); + ]); } /** @@ -175,8 +175,8 @@ class Collection implements ControllerProviderInterface { $success = false; - if (count($admins = $request->request->get('admins', array())) > 0) { - $newAdmins = array(); + if (count($admins = $request->request->get('admins', [])) > 0) { + $newAdmins = []; foreach ($admins as $admin) { $newAdmins[] = $admin; @@ -189,17 +189,17 @@ class Collection implements ControllerProviderInterface try { $userQuery = new \User_Query($app); - $result = $userQuery->on_base_ids(array($bas_id)) - ->who_have_right(array('order_master')) + $result = $userQuery->on_base_ids([$bas_id]) + ->who_have_right(['order_master']) ->execute()->get_results(); foreach ($result as $user) { - $app['acl']->get($user)->update_rights_to_base($bas_id, array('order_master' => false)); + $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => false]); } foreach (array_filter($newAdmins) as $admin) { $user = \User_Adapter::getInstance($admin, $app); - $app['acl']->get($user)->update_rights_to_base($bas_id, array('order_master' => true)); + $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => true]); } $conn->commit(); @@ -210,10 +210,10 @@ class Collection implements ControllerProviderInterface } } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => (int) $success, - )); + ]); } /** @@ -246,17 +246,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -281,17 +281,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -316,17 +316,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -351,17 +351,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -387,17 +387,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, - )); + ]); } /** @@ -415,19 +415,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 1024 * 1024) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -437,17 +437,17 @@ class Collection implements ControllerProviderInterface $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -465,19 +465,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 1024 * 1024) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -487,17 +487,17 @@ class Collection implements ControllerProviderInterface $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -515,19 +515,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 65535) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -536,17 +536,17 @@ class Collection implements ControllerProviderInterface $app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_WM); $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -564,19 +564,19 @@ class Collection implements ControllerProviderInterface } if ($file->getClientSize() > 65535) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-too-big', - )); + ]); } if (!$file->isValid()) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-invalid', - )); + ]); } $collection = \collection::get_from_base_id($app, $bas_id); @@ -585,17 +585,17 @@ class Collection implements ControllerProviderInterface $app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_LOGO); $app['filesystem']->remove($file->getPathname()); } catch (\Exception $e) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 0, 'error' => 'file-error', - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $bas_id, 'success' => 1, - )); + ]); } /** @@ -627,32 +627,32 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg - )); + ]); } if ($collection->get_record_amount() > 0) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => 0, 'error' => 'collection-not-empty', - )); + ]); } if ($success) { - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => 1, 'reload-tree' => 1, - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => 0, - )); + ]); } /** @@ -677,16 +677,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('The publication has been stopped') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -715,17 +715,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, 'reload-tree' => 1, - )); + ]); } public function labels(Application $app, Request $request, $bas_id) @@ -753,17 +753,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_base_id(), 'success' => (int) $success, 'reload-tree' => 1, - )); + ]); } /** @@ -792,16 +792,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -826,16 +826,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -860,16 +860,16 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } - return $app->redirectPath('admin_display_collection', array( + return $app->redirectPath('admin_display_collection', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -883,7 +883,7 @@ class Collection implements ControllerProviderInterface { $databox = $app['phraseanet.appbox']->get_databox(\phrasea::sbasFromBas($app, $bas_id)); $collection = \collection::get_from_base_id($app, $bas_id); - $structFields = $suggestedValues = $basePrefs = array(); + $structFields = $suggestedValues = $basePrefs = []; foreach ($databox->get_meta_structure() as $meta) { if ($meta->is_readonly()) { @@ -900,9 +900,9 @@ class Collection implements ControllerProviderInterface foreach ($z[0] as $ki => $vi) { if ($vi && isset($structFields[$ki])) { foreach ($vi->value as $oneValue) { - $suggestedValues[] = array( + $suggestedValues[] = [ 'key' => $ki, 'value' => $f, 'name' => (string) $oneValue - ); + ]; $f++; } } @@ -912,7 +912,7 @@ class Collection implements ControllerProviderInterface $z = $sxe->xpath('/baseprefs'); if ($z && is_array($z)) { foreach ($z[0] as $ki => $vi) { - $pref = array('status' => null, 'xml' => null); + $pref = ['status' => null, 'xml' => null]; if ($ki == 'status') { $pref['status'] = $vi; @@ -925,13 +925,13 @@ class Collection implements ControllerProviderInterface } } - return $app['twig']->render('admin/collection/suggested_value.html.twig', array( + return $app['twig']->render('admin/collection/suggested_value.html.twig', [ 'collection' => $collection, 'databox' => $databox, 'suggestedValues' => $suggestedValues, 'structFields' => $structFields, 'basePrefs' => $basePrefs, - )); + ]); } /** @@ -959,17 +959,17 @@ class Collection implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'bas_id' => $collection->get_base_id() - )); + ]); } - return $app->redirectPath('admin_collection_display_suggested_values', array( + return $app->redirectPath('admin_collection_display_suggested_values', [ 'bas_id' => $collection->get_sbas_id(), 'success' => (int) $success, - )); + ]); } /** @@ -984,12 +984,12 @@ class Collection implements ControllerProviderInterface { $collection = \collection::get_from_base_id($app, $bas_id); - $out = array('total' => array('totobj' => 0, 'totsiz' => 0, 'mega' => '0', 'giga' => '0'), 'result' => array()); + $out = ['total' => ['totobj' => 0, 'totsiz' => 0, 'mega' => '0', 'giga' => '0'], 'result' => []]; foreach ($collection->get_record_details() as $vrow) { $last_k1 = $last_k2 = null; - $outRow = array('midobj' => 0, 'midsiz' => 0); + $outRow = ['midobj' => 0, 'midsiz' => 0]; if ($vrow['amount'] > 0 || $last_k1 !== $vrow['coll_id']) { @@ -1059,9 +1059,9 @@ class Collection implements ControllerProviderInterface $out['total']['giga'] = $out['total']['totsiz'] / (1024 * 1024 * 1024); } - return $app['twig']->render('admin/collection/details.html.twig', array( + return $app['twig']->render('admin/collection/details.html.twig', [ 'collection' => $collection, 'table' => $out, - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php index d3217d5aab..942a7f47ec 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/ConnectedUsers.php @@ -42,13 +42,13 @@ class ConnectedUsers implements ControllerProviderInterface ORDER BY s.updated DESC'; $date = new \DateTime('-2 hours'); - $params = array('date' => $date->format('Y-m-d h:i:s')); + $params = ['date' => $date->format('Y-m-d h:i:s')]; $query = $app['EM']->createQuery($dql); $query->setParameters($params); $sessions = $query->getResult(); - $result = array(); + $result = []; foreach ($sessions as $session) { $info = ''; @@ -76,15 +76,15 @@ class ConnectedUsers implements ControllerProviderInterface )); } - $result[] = array( + $result[] = [ 'session' => $session, 'info' => $info, - ); + ]; } - $ret = array( + $ret = [ 'sessions' => $result, - 'applications' => array( + 'applications' => [ '0' => 0, '1' => 0, '2' => 0, @@ -94,8 +94,8 @@ class ConnectedUsers implements ControllerProviderInterface '6' => 0, '7' => 0, '8' => 0, - ) - ); + ] + ]; foreach ($result as $session) { foreach ($session['session']->getModules() as $module) { @@ -105,7 +105,7 @@ class ConnectedUsers implements ControllerProviderInterface } } - return $app['twig']->render('admin/connected-users.html.twig', array('data' => $ret)); + return $app['twig']->render('admin/connected-users.html.twig', ['data' => $ret]); } /** @@ -117,7 +117,7 @@ class ConnectedUsers implements ControllerProviderInterface */ public static function appName($appId) { - $appRef = array( + $appRef = [ '0' => _('admin::monitor: module inconnu'), '1' => _('admin::monitor: module production'), '2' => _('admin::monitor: module client'), @@ -127,7 +127,7 @@ class ConnectedUsers implements ControllerProviderInterface '6' => _('admin::monitor: module comparateur'), '7' => _('admin::monitor: module validation'), '8' => _('admin::monitor: module upload'), - ); + ]; return isset($appRef[$appId]) ? $appRef[$appId] : null; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php index 8e4ad84ec0..efd5988fbf 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php @@ -72,11 +72,11 @@ class Dashboard implements ControllerProviderInterface break; } - $parameters = array( + $parameters = [ 'cache_flushed' => $request->query->get('flush_cache') === 'ok', 'admins' => \User_Adapter::get_sys_admins($app), 'email_status' => $emailStatus, - ); + ]; return $app['twig']->render('admin/dashboard.html.twig', $parameters); } @@ -91,10 +91,10 @@ class Dashboard implements ControllerProviderInterface public function flush(Application $app, Request $request) { if ($app['phraseanet.cache-service']->flushAll()) { - return $app->redirectPath('admin_dashbord', array('flush_cache' => 'ok')); + return $app->redirectPath('admin_dashbord', ['flush_cache' => 'ok']); } - return $app->redirectPath('admin_dashbord', array('flush_cache' => 'ko')); + return $app->redirectPath('admin_dashbord', ['flush_cache' => 'ko']); } /** @@ -117,7 +117,7 @@ class Dashboard implements ControllerProviderInterface try { $receiver = new Receiver(null, $mail); } catch (InvalidArgumentException $e) { - return $app->redirectPath('admin_dashbord', array('email' => 'not-sent')); + return $app->redirectPath('admin_dashbord', ['email' => 'not-sent']); } $mail = MailTest::create($app, $receiver); @@ -125,7 +125,7 @@ class Dashboard implements ControllerProviderInterface $app['notification.deliverer']->deliver($mail); $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']); - return $app->redirectPath('admin_dashbord', array('email' => 'sent')); + return $app->redirectPath('admin_dashbord', ['email' => 'sent']); } /** @@ -153,7 +153,7 @@ class Dashboard implements ControllerProviderInterface */ public function addAdmins(Application $app, Request $request) { - if (count($admins = $request->request->get('admins', array())) > 0) { + if (count($admins = $request->request->get('admins', [])) > 0) { if (!in_array($app['authentication']->getUser()->get_id(), $admins)) { $admins[] = $app['authentication']->getUser()->get_id(); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php index 22ccf964fb..3a1a5e295a 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php @@ -181,12 +181,12 @@ class Databox implements ControllerProviderInterface break; } - return $app['twig']->render('admin/databox/databox.html.twig', array( + return $app['twig']->render('admin/databox/databox.html.twig', [ 'databox' => $databox, 'showDetail' => (int) $request->query->get("sta") < 1, 'errorMsg' => $errorMsg, 'reloadTree' => $request->query->get('reload-tree') === '1' - )); + ]); } /** @@ -199,11 +199,11 @@ class Databox implements ControllerProviderInterface */ public function getDatabaseCGU(Application $app, Request $request, $databox_id) { - return $app['twig']->render('admin/databox/cgus.html.twig', array( + return $app['twig']->render('admin/databox/cgus.html.twig', [ 'languages' => $app['locales.available'], 'cgus' => $app['phraseanet.appbox']->get_databox($databox_id)->get_cgus(), 'current_locale' => $app['locale'] - )); + ]); } /** @@ -235,17 +235,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, 'sbas_id' => $databox->get_sbas_id() - )); + ]); } - $params = array( + $params = [ 'databox_id' => $databox->get_sbas_id(), 'success' => (int) $success, - ); + ]; if ($databox->get_record_amount() > 0) { $params['error'] = 'databox-not-empty'; @@ -279,10 +279,10 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured') - )); + ]); } return $app->redirect('/admin/databox/' . $databox->get_sbas_id() . '/?success=' . (int) $success . '&reload-tree=1'); @@ -308,17 +308,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => (int) $success, - )); + ]); } /** @@ -341,17 +341,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => (int) $success, - )); + ]); } /** @@ -367,20 +367,20 @@ class Databox implements ControllerProviderInterface $databox = $app['phraseanet.appbox']->get_databox($databox_id); try { - foreach ($request->request->get('TOU', array()) as $loc => $terms) { + foreach ($request->request->get('TOU', []) as $loc => $terms) { $databox->update_cgus($loc, $terms, !!$request->request->get('valid', false)); } } catch (\Exception $e) { - return $app->redirectPath('admin_database_display_cgus', array( + return $app->redirectPath('admin_database_display_cgus', [ 'databox_id' => $databox_id, 'success' => 0, - )); + ]); } - return $app->redirectPath('admin_database_display_cgus', array( + return $app->redirectPath('admin_database_display_cgus', [ 'databox_id' => $databox_id, 'success' => 1, - )); + ]); } /** @@ -405,7 +405,7 @@ class Databox implements ControllerProviderInterface $query = new \User_Query($app); $n = 0; - while ($n < $query->on_base_ids(array($othCollSel))->get_total()) { + while ($n < $query->on_base_ids([$othCollSel])->get_total()) { $results = $query->limit($n, 50)->execute()->get_results(); foreach ($results as $user) { @@ -417,17 +417,17 @@ class Databox implements ControllerProviderInterface $app['phraseanet.appbox']->get_connection()->commit(); - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'mount' => 'ok', - )); + ]); } catch (\Exception $e) { $app['phraseanet.appbox']->get_connection()->rollBack(); - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'mount' => 'ko', - )); + ]); } } @@ -449,30 +449,30 @@ class Databox implements ControllerProviderInterface $app['phraseanet.appbox']->write_databox_pic($app['media-alchemyst'], $app['filesystem'], $databox, $file, \databox::PIC_PDF); unlink($file->getPathname()); - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '1', - )); + ]); } else { - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '0', 'error' => 'file-too-big', - )); + ]); } } else { - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '0', 'error' => 'file-invalid', - )); + ]); } } catch (\Exception $e) { - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'success' => '0', 'error' => 'file-error', - )); + ]); } } @@ -496,17 +496,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful removal') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -529,17 +529,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -566,17 +566,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -601,16 +601,16 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('The publication has been stopped') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_databases', array( + return $app->redirectPath('admin_databases', [ 'reload-tree' => 1, - )); + ]); } /** @@ -649,17 +649,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database', array( + return $app->redirectPath('admin_database', [ 'databox_id' => $databox_id, 'error' => 'file-too-big', - )); + ]); } /** @@ -678,7 +678,7 @@ class Databox implements ControllerProviderInterface $app['phraseanet.appbox'] = $app['phraseanet.appbox']; - $ret = array( + $ret = [ 'success' => false, 'msg' => _('An error occured'), 'sbas_id' => null, @@ -688,7 +688,7 @@ class Databox implements ControllerProviderInterface 'thesaurus_indexed' => 0, 'viewname' => null, 'printLogoURL' => null - ); + ]; try { $databox = $app['phraseanet.appbox']->get_databox($databox_id); @@ -724,9 +724,9 @@ class Databox implements ControllerProviderInterface */ public function getReorder(Application $app, Request $request, $databox_id) { - return $app['twig']->render('admin/collection/reorder.html.twig', array( - 'collections' => $app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox_id)), - )); + return $app['twig']->render('admin/collection/reorder.html.twig', [ + 'collections' => $app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox_id]), + ]); } /** @@ -740,7 +740,7 @@ class Databox implements ControllerProviderInterface public function setReorder(Application $app, Request $request, $databox_id) { try { - foreach ($request->request->get('order', array()) as $data) { + foreach ($request->request->get('order', []) as $data) { $collection = \collection::get_from_base_id($app, $data['id']); $collection->set_ord($data['offset']); } @@ -750,17 +750,17 @@ class Databox implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Successful update') : _('An error occured'), 'sbas_id' => $databox_id - )); + ]); } - return $app->redirectPath('admin_database_display_collections_order', array( + return $app->redirectPath('admin_database_display_collections_order', [ 'databox_id' => $databox_id, 'success' => (int) $success, - )); + ]); } /** @@ -787,10 +787,10 @@ class Databox implements ControllerProviderInterface public function createCollection(Application $app, Request $request, $databox_id) { if (($name = trim($request->request->get('name', ''))) === '') { - return $app->redirectPath('admin_database_display_new_collection_form', array( + return $app->redirectPath('admin_database_display_new_collection_form', [ 'databox_id' => $databox_id, 'error' => 'name', - )); + ]); } try { @@ -800,7 +800,7 @@ class Databox implements ControllerProviderInterface if (($request->request->get('ccusrothercoll') === "on") && (null !== $othcollsel = $request->request->get('othcollsel'))) { $query = new \User_Query($app); - $total = $query->on_base_ids(array($othcollsel))->get_total(); + $total = $query->on_base_ids([$othcollsel])->get_total(); $n = 0; while ($n < $total) { $results = $query->limit($n, 20)->execute()->get_results(); @@ -811,9 +811,9 @@ class Databox implements ControllerProviderInterface } } - return $app->redirectPath('admin_display_collection', array('bas_id' => $collection->get_base_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_display_collection', ['bas_id' => $collection->get_base_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { - return $app->redirectPath('admin_database_submit_collection', array('databox_id' => $databox_id, 'error' => 'error')); + return $app->redirectPath('admin_database_submit_collection', ['databox_id' => $databox_id, 'error' => 'error']); } } @@ -829,15 +829,15 @@ class Databox implements ControllerProviderInterface { $databox = $app['phraseanet.appbox']->get_databox($databox_id); - $details = array(); - $total = array('total_subdefs' => 0, 'total_size' => 0); + $details = []; + $total = ['total_subdefs' => 0, 'total_size' => 0]; foreach ($databox->get_record_details($request->query->get('sort')) as $collName => $colDetails) { - $details[$collName] = array( + $details[$collName] = [ 'total_subdefs' => 0, 'total_size' => 0, - 'medias' => array() - ); + 'medias' => [] + ]; foreach ($colDetails as $subdefName => $subdefDetails) { $details[$collName]['total_subdefs'] += $subdefDetails['n']; @@ -845,18 +845,18 @@ class Databox implements ControllerProviderInterface $details[$collName]['total_size'] += $subdefDetails['siz']; $total['total_size'] += $subdefDetails['siz']; - $details[$collName]['medias'][] = array ( + $details[$collName]['medias'][] = [ 'subdef_name' => $subdefName, 'total_subdefs' => $subdefDetails['n'], 'total_size' => $subdefDetails['siz'], - ); + ]; } } - return $app['twig']->render('admin/databox/details.html.twig', array( + return $app['twig']->render('admin/databox/details.html.twig', [ 'databox' => $databox, 'table' => $details, 'total' => $total - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php index 6d48ed2294..8cf8a48b20 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php @@ -69,28 +69,28 @@ class Databoxes implements ControllerProviderInterface public function getDatabases(Application $app, Request $request) { $sbasIds = array_merge( - array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(array('bas_manage'))) - , array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(array('bas_modify_struct'))) + array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(['bas_manage'])) + , array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas(['bas_modify_struct'])) ); - $sbas = array(); + $sbas = []; foreach ($sbasIds as $sbasId) { - $sbas[$sbasId] = array( + $sbas[$sbasId] = [ 'version' => 'unknown', 'image' => '/skins/icons/db-remove.png', 'server_info' => '', 'name' => _('Unreachable server') - ); + ]; try { $databox = $app['phraseanet.appbox']->get_databox($sbasId); - $sbas[$sbasId] = array( + $sbas[$sbasId] = [ 'version' => $databox->get_version(), 'image' => '/skins/icons/foldph20close_0.gif', 'server_info' => $databox->get_connection()->server_info(), 'name' => \phrasea::sbas_labels($sbasId, $app) - ); + ]; } catch (\Exception $e) { } @@ -128,14 +128,14 @@ class Databoxes implements ControllerProviderInterface $upgrader = new \Setup_Upgrade($app); - return $app['twig']->render('admin/databases.html.twig', array( + return $app['twig']->render('admin/databases.html.twig', [ 'files' => new \DirectoryIterator($app['root.path'] . '/lib/conf.d/data_templates'), 'sbas' => $sbas, 'error_msg' => $errorMsg, 'recommendations' => $upgrader->getRecommendations(), - 'advices' => $request->query->get('advices', array()), + 'advices' => $request->query->get('advices', []), 'reloadTree' => (Boolean) $request->query->get('reload-tree'), - )); + ]); } /** @@ -149,11 +149,11 @@ class Databoxes implements ControllerProviderInterface public function createDatabase(Application $app, Request $request) { if ('' === $dbName = $request->request->get('new_dbname', '')) { - return $app->redirectPath('admin_databases', array('error' => 'no-empty')); + return $app->redirectPath('admin_databases', ['error' => 'no-empty']); } if (\p4string::hasAccent($dbName)) { - return $app->redirectPath('admin_databases', array('error' => 'special-chars')); + return $app->redirectPath('admin_databases', ['error' => 'special-chars']); } if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) { @@ -169,9 +169,9 @@ class Databoxes implements ControllerProviderInterface $dataTemplate = new \SplFileInfo($app['root.path'] . '/lib/conf.d/data_templates/' . $dataTemplate . '.xml'); try { - $connbas = new \connection_pdo('databox_creation', $hostname, $port, $user, $password, $dbName, array(), $app['debug']); + $connbas = new \connection_pdo('databox_creation', $hostname, $port, $user, $password, $dbName, [], $app['debug']); } catch (\PDOException $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'database-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'database-failed']); } try { @@ -179,9 +179,9 @@ class Databoxes implements ControllerProviderInterface $base->registerAdmin($app['authentication']->getUser()); $app['acl']->get($app['authentication']->getUser())->delete_data_from_cache(); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'base-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'base-failed']); } } @@ -195,17 +195,17 @@ class Databoxes implements ControllerProviderInterface try { $data_template = new \SplFileInfo($app['root.path'] . '/lib/conf.d/data_templates/' . $dataTemplate . '.xml'); - $connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $app['debug']); + $connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, [], $app['debug']); try { $base = \databox::create($app, $connbas, $data_template, $app['phraseanet.registry']); $base->registerAdmin($app['authentication']->getUser()); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'base-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'base-failed']); } } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'database-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'database-failed']); } } } @@ -220,11 +220,11 @@ class Databoxes implements ControllerProviderInterface public function databaseMount(Application $app, Request $request) { if ('' === $dbName = trim($request->request->get('new_dbname', ''))) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'no-empty')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'no-empty']); } if (\p4string::hasAccent($dbName)) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'special-chars')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'special-chars']); } if ((null === $request->request->get('new_settings'))) { @@ -242,11 +242,11 @@ class Databoxes implements ControllerProviderInterface $base->registerAdmin($app['authentication']->getUser()); $app['phraseanet.appbox']->get_connection()->commit(); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { $app['phraseanet.appbox']->get_connection()->rollBack(); - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'mount-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'mount-failed']); } } @@ -263,11 +263,11 @@ class Databoxes implements ControllerProviderInterface $base->registerAdmin($app['authentication']->getUser()); $app['phraseanet.appbox']->get_connection()->commit(); - return $app->redirectPath('admin_database', array('databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1)); + return $app->redirectPath('admin_database', ['databox_id' => $base->get_sbas_id(), 'success' => 1, 'reload-tree' => 1]); } catch (\Exception $e) { $app['phraseanet.appbox']->get_connection()->rollBack(); - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'mount-failed')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'mount-failed']); } } } @@ -283,20 +283,20 @@ class Databoxes implements ControllerProviderInterface { $info = $app['task-manager.live-information']->getManager(); if (TaskManagerStatus::STATUS_STARTED === $info['actual']) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'scheduler-started')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'scheduler-started']); } try { $upgrader = new \Setup_Upgrade($app); $advices = $app['phraseanet.appbox']->forceUpgrade($upgrader, $app); - return $app->redirectPath('admin_databases', array('success' => 1, 'notice' => 'restart', 'advices' => $advices)); + return $app->redirectPath('admin_databases', ['success' => 1, 'notice' => 'restart', 'advices' => $advices]); } catch (\Exception_Setup_UpgradeAlreadyStarted $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'already-started')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'already-started']); } catch (\Exception_Setup_FixBadEmailAddresses $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'bad-email')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'bad-email']); } catch (\Exception $e) { - return $app->redirectPath('admin_databases', array('success' => 0, 'error' => 'unknow')); + return $app->redirectPath('admin_databases', ['success' => 0, 'error' => 'unknow']); } } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php index 90d0889e4a..ee4478999a 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Fields.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Fields.php @@ -90,7 +90,7 @@ class Fields implements ControllerProviderInterface public function updateFields(Application $app, Request $request, $sbas_id) { - $fields = array(); + $fields = []; $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $metaStructure = $databox->get_meta_structure(); $connection = $databox->get_connection(); @@ -125,7 +125,7 @@ class Fields implements ControllerProviderInterface public function getLanguage(Application $app, Request $request) { - return $app->json(array( + return $app->json([ 'something_wrong' => _('Something wrong happened, please try again or contact an admin.'), 'created_success' => _('%s field has been created with success.'), 'deleted_success' => _('%s field has been deleted with success.'), @@ -136,29 +136,29 @@ class Fields implements ControllerProviderInterface 'validation_tag_invalid' => _('Field source is not valid.'), 'field_error' => _('Field %s contains errors.'), 'fields_save' => _('Your configuration has been successfuly saved.'), - )); + ]); } public function displayApp(Application $app, Request $request, $sbas_id) { - $languages = array(); + $languages = []; foreach ($app['locales.available'] as $code => $language) { $data = explode('_', $code); $languages[$data[0]] = $language; } - return $app['twig']->render('/admin/fields/index.html.twig', array( + return $app['twig']->render('/admin/fields/index.html.twig', [ 'sbas_id' => $sbas_id, 'languages' => $languages, - )); + ]); } public function listDcFields(Application $app, Request $request) { $data = $app['serializer']->serialize(array_values(\databox::get_available_dcfields()), 'json'); - return new Response($data, 200, array('content-type' => 'application/json')); + return new Response($data, 200, ['content-type' => 'application/json']); } public function listVocabularies(Application $app, Request $request) @@ -166,10 +166,10 @@ class Fields implements ControllerProviderInterface $vocabularies = VocabularyController::getAvailable($app); return $app->json(array_map(function ($vocabulary) { - return array( + return [ 'type' => $vocabulary->getType(), 'name' => $vocabulary->getName(), - ); + ]; }, $vocabularies)); } @@ -177,16 +177,16 @@ class Fields implements ControllerProviderInterface { $vocabulary = VocabularyController::get($app, $type); - return $app->json(array( + return $app->json([ 'type' => $vocabulary->getType(), 'name' => $vocabulary->getName(), - )); + ]); } public function searchTag(Application $app, Request $request) { $term = trim(strtolower($request->query->get('term'))); - $res = array(); + $res = []; if ($term) { $provider = new TagProvider(); @@ -199,11 +199,11 @@ class Fields implements ControllerProviderInterface continue; } - $res[] = array( + $res[] = [ 'id' => $namespace . '/' . $tagname, 'label' => $datas['namespace'] . ' / ' . $datas['tagname'], 'value' => $datas['namespace'] . ':' . $datas['tagname'], - ); + ]; } } } @@ -216,7 +216,7 @@ class Fields implements ControllerProviderInterface $tag = \databox_field::loadClassFromTagName($tagname); $json = $app['serializer']->serialize($tag, 'json'); - return new Response($json, 200, array('Content-Type' => 'application/json')); + return new Response($json, 200, ['Content-Type' => 'application/json']); } public function createField(Application $app, Request $request, $sbas_id) @@ -236,11 +236,11 @@ class Fields implements ControllerProviderInterface $app->abort(500, _(sprintf('Field %s could not be created, please try again or contact an admin.', $data['name']))); } - return $app->json($field->toArray(), 201, array( - 'location' => $app->path('admin_fields_show_field', array( + return $app->json($field->toArray(), 201, [ + 'location' => $app->path('admin_fields_show_field', [ 'sbas_id' => $sbas_id, 'id' => $field->get_id() - )))); + ])]); } public function listFields(Application $app, $sbas_id) @@ -361,11 +361,11 @@ class Fields implements ControllerProviderInterface private function getMandatoryFieldProperties() { - return array( + return [ 'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'required', 'separator', 'readonly', 'type', 'tbranch', 'report', 'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels' - ); + ]; } private function validateNameField(\databox_descriptionStructure $metaStructure, array $field) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php index dc1fbd8f77..476a8034b9 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php @@ -42,7 +42,7 @@ class Publications implements ControllerProviderInterface ); return $app['twig'] - ->render('admin/publications/list.html.twig', array('feeds' => $feeds)); + ->render('admin/publications/list.html.twig', ['feeds' => $feeds]); })->bind('admin_feeds_list'); $controllers->post('/create/', function (PhraseaApplication $app, Request $request) { @@ -82,7 +82,7 @@ class Publications implements ControllerProviderInterface $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id); return $app['twig'] - ->render('admin/publications/fiche.html.twig', array('feed' => $feed, 'error' => $app['request']->query->get('error'))); + ->render('admin/publications/fiche.html.twig', ['feed' => $feed, 'error' => $app['request']->query->get('error')]); }) ->bind('admin_feeds_feed') ->assert('id', '\d+'); @@ -112,17 +112,17 @@ class Publications implements ControllerProviderInterface $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $request->attributes->get('id')); if (!$feed->isOwner($app['authentication']->getUser())) { - return $app->redirectPath('admin_feeds_feed', array('id' => $request->attributes->get('id'), 'error' => _('You are not the owner of this feed, you can not edit it'))); + return $app->redirectPath('admin_feeds_feed', ['id' => $request->attributes->get('id'), 'error' => _('You are not the owner of this feed, you can not edit it')]); } }) ->bind('admin_feeds_feed_update') ->assert('id', '\d+'); $controllers->post('/feed/{id}/iconupload/', function (PhraseaApplication $app, Request $request, $id) { - $datas = array( + $datas = [ 'success' => false, 'message' => '', - ); + ]; $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id); if (null === $feed) { @@ -213,7 +213,7 @@ class Publications implements ControllerProviderInterface $error = "An error occured"; } - return $app->redirectPath('admin_feeds_feed', array('id' => $id, 'error' => $error)); + return $app->redirectPath('admin_feeds_feed', ['id' => $id, 'error' => $error]); }) ->bind('admin_feeds_feed_add_publisher') ->assert('id', '\d+'); @@ -240,7 +240,7 @@ class Publications implements ControllerProviderInterface $error = "An error occured"; } - return $app->redirectPath('admin_feeds_feed', array('id' => $id, 'error' => $error)); + return $app->redirectPath('admin_feeds_feed', ['id' => $id, 'error' => $error]); }) ->bind('admin_feeds_feed_remove_publisher') ->assert('id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Root.php b/lib/Alchemy/Phrasea/Controller/Admin/Root.php index 51e1dd9e0e..5abe74203d 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Root.php @@ -43,7 +43,7 @@ class Root implements ControllerProviderInterface $section = $request->query->get('section', false); - $available = array( + $available = [ 'connected', 'registrations', 'taskmanager', @@ -52,7 +52,7 @@ class Root implements ControllerProviderInterface 'collection', 'user', 'users' - ); + ]; $feature = 'connected'; $featured = false; @@ -67,7 +67,7 @@ class Root implements ControllerProviderInterface } } - $databoxes = $off_databoxes = array(); + $databoxes = $off_databoxes = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) { @@ -82,14 +82,14 @@ class Root implements ControllerProviderInterface $databoxes[] = $databox; } - $params = array( + $params = [ 'feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes - ); + ]; - return $app['twig']->render('admin/index.html.twig', array( + return $app['twig']->render('admin/index.html.twig', [ 'module' => 'admin', 'events' => $app['events-manager'], 'module_name' => 'Admin', @@ -99,7 +99,7 @@ class Root implements ControllerProviderInterface 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes, 'tree' => $app['twig']->render('admin/tree.html.twig', $params), - )); + ]); })->bind('admin'); $controllers->get('/tree/', function (Application $app, Request $request) { @@ -111,7 +111,7 @@ class Root implements ControllerProviderInterface $section = $request->query->get('section', false); - $available = array( + $available = [ 'connected', 'registrations', 'taskmanager', @@ -120,7 +120,7 @@ class Root implements ControllerProviderInterface 'collection', 'user', 'users' - ); + ]; $feature = 'connected'; $featured = false; @@ -136,7 +136,7 @@ class Root implements ControllerProviderInterface } } - $databoxes = $off_databoxes = array(); + $databoxes = $off_databoxes = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { try { if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) { @@ -152,12 +152,12 @@ class Root implements ControllerProviderInterface $databoxes[] = $databox; } - $params = array( + $params = [ 'feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes - ); + ]; return $app['twig']->render('admin/tree.html.twig', $params); })->bind('admin_display_tree'); @@ -168,7 +168,7 @@ class Root implements ControllerProviderInterface $app->abort(400, _('Bad request format, only JSON is allowed')); } - if (0 !== count($tests = $request->query->get('tests', array()))) { + if (0 !== count($tests = $request->query->get('tests', []))) { $app->abort(400, _('Missing tests parameter')); } @@ -192,7 +192,7 @@ class Root implements ControllerProviderInterface } } - return $app->json(array('results' => $result)); + return $app->json(['results' => $result]); }) ->bind('admin_test_paths'); @@ -213,13 +213,13 @@ class Root implements ControllerProviderInterface $errorsStructure = true; } - return $app['twig']->render('admin/structure.html.twig', array( + return $app['twig']->render('admin/structure.html.twig', [ 'databox' => $databox, 'errors' => $errors, 'structure' => $structure, 'errorsStructure' => $errorsStructure, 'updateOk' => $updateOk - )); + ]); })->assert('databox_id', '\d+') ->bind('database_display_stucture'); @@ -242,9 +242,9 @@ class Root implements ControllerProviderInterface $databox = $app['phraseanet.appbox']->get_databox($databox_id); $databox->saveStructure($domst); - return $app->redirectPath('database_display_stucture', array('databox_id' => $databox_id, 'success' => 1)); + return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 1]); } else { - return $app->redirectPath('database_display_stucture', array('databox_id' => $databox_id, 'success' => 0, 'error' => 'struct')); + return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 0, 'error' => 'struct']); } })->assert('databox_id', '\d+') ->bind('database_submit_stucture'); @@ -254,9 +254,9 @@ class Root implements ControllerProviderInterface $app->abort(403); } - return $app['twig']->render('admin/statusbit.html.twig', array( + return $app['twig']->render('admin/statusbit.html.twig', [ 'databox' => $app['phraseanet.appbox']->get_databox($databox_id), - )); + ]); })->assert('databox_id', '\d+') ->bind('database_display_statusbit'); @@ -290,7 +290,7 @@ class Root implements ControllerProviderInterface if (isset($status[$bit])) { $status = $status[$bit]; } else { - $status = array( + $status = [ "labeloff" => '', "labelon" => '', "img_off" => '', @@ -299,7 +299,7 @@ class Root implements ControllerProviderInterface "path_on" => '', "searchable" => false, "printable" => false, - ); + ]; foreach ($app['locales.I18n.available'] as $code => $language) { $status['labels_on'][$code] = null; @@ -307,10 +307,10 @@ class Root implements ControllerProviderInterface } } - return $app['twig']->render('admin/statusbit/edit.html.twig', array( + return $app['twig']->render('admin/statusbit/edit.html.twig', [ 'status' => $status, 'errorMsg' => $errorMsg - )); + ]); })->assert('databox_id', '\d+') ->assert('bit', '\d+') ->bind('database_display_statusbit_form'); @@ -332,7 +332,7 @@ class Root implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); }) ->bind('admin_statusbit_delete') ->assert('databox_id', '\d+') @@ -343,15 +343,15 @@ class Root implements ControllerProviderInterface $app->abort(403); } - $properties = array( + $properties = [ 'searchable' => $request->request->get('searchable') ? '1' : '0', 'printable' => $request->request->get('printable') ? '1' : '0', 'name' => $request->request->get('name', ''), 'labelon' => $request->request->get('label_on', ''), 'labeloff' => $request->request->get('label_off', ''), - 'labels_on' => $request->request->get('labels_on', array()), - 'labels_off' => $request->request->get('labels_off', array()), - ); + 'labels_on' => $request->request->get('labels_on', []), + 'labels_off' => $request->request->get('labels_off', []), + ]; \databox_status::updateStatus($app, $databox_id, $bit, $properties); @@ -363,41 +363,41 @@ class Root implements ControllerProviderInterface try { \databox_status::updateIcon($app, $databox_id, $bit, 'off', $file); } catch (AccessDeniedHttpException $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights', - )); + ]); } catch (\Exception_InvalidArgument $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } catch (\Exception_Upload_FileTooBig $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big', - )); + ]); } catch (\Exception_Upload_Error $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error', - )); + ]); } catch (\Exception_Upload_CannotWriteFile $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error', - )); + ]); } catch (\Exception $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } } @@ -409,45 +409,45 @@ class Root implements ControllerProviderInterface try { \databox_status::updateIcon($app, $databox_id, $bit, 'on', $file); } catch (AccessDeniedHttpException $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights', - )); + ]); } catch (\Exception_InvalidArgument $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } catch (\Exception_Upload_FileTooBig $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big', - )); + ]); } catch (\Exception_Upload_Error $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error', - )); + ]); } catch (\Exception_Upload_CannotWriteFile $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error', - )); + ]); } catch (\Exception $e) { - return $app->redirectPath('database_display_statusbit_form', array( + return $app->redirectPath('database_display_statusbit_form', [ 'databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error', - )); + ]); } } - return $app->redirectPath('database_display_statusbit', array('databox_id' => $databox_id, 'success' => 1)); + return $app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]); })->assert('databox_id', '\d+') ->assert('bit', '\d+') ->bind('database_submit_statusbit'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php index 29351a180a..dacbb807d4 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php @@ -68,11 +68,11 @@ class Setup implements ControllerProviderInterface } } - return $app['twig']->render('admin/setup.html.twig', array( + return $app['twig']->render('admin/setup.html.twig', [ 'GV' => $GV, 'update_post_datas' => $update, 'listTimeZone' => \DateTimeZone::listAbbreviations() - )); + ]); } /** @@ -85,13 +85,13 @@ class Setup implements ControllerProviderInterface public function postGlobals(Application $app, Request $request) { if (\setup::create_global_values($app, $request->request->all())) { - return $app->redirectPath('setup_display_globals', array( + return $app->redirectPath('setup_display_globals', [ 'success' => 1 - )); + ]); } - return $app->redirectPath('setup_display_globals', array( + return $app->redirectPath('setup_display_globals', [ 'success' => 0 - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php b/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php index 32db55af72..89fb639388 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Subdefs.php @@ -36,10 +36,10 @@ class Subdefs implements ControllerProviderInterface $controllers->get('/{sbas_id}/', function (Application $app, $sbas_id) { $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); - return $app['twig']->render('admin/subdefs.html.twig', array( + return $app['twig']->render('admin/subdefs.html.twig', [ 'databox' => $databox, 'subdefs' => $databox->get_subdef_structure() - )); + ]); }) ->bind('admin_subdefs_subdef') ->assert('sbas_id', '\d+'); @@ -47,11 +47,11 @@ class Subdefs implements ControllerProviderInterface $controllers->post('/{sbas_id}/', function (Application $app, Request $request, $sbas_id) { $delete_subdef = $request->request->get('delete_subdef'); $toadd_subdef = $request->request->get('add_subdef'); - $Parmsubdefs = $request->request->get('subdefs', array()); + $Parmsubdefs = $request->request->get('subdefs', []); $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); - $add_subdef = array('class' => null, 'name' => null, 'group' => null); + $add_subdef = ['class' => null, 'name' => null, 'group' => null]; foreach ($add_subdef as $k => $v) { if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') unset($add_subdef[$k]); @@ -81,7 +81,7 @@ class Subdefs implements ControllerProviderInterface foreach ($Parmsubdefs as $post_sub) { - $options = array(); + $options = []; $post_sub_ex = explode('_', $post_sub); @@ -91,7 +91,7 @@ class Subdefs implements ControllerProviderInterface $class = $request->request->get($post_sub . '_class'); $downloadable = $request->request->get($post_sub . '_downloadable'); - $defaults = array('path', 'meta', 'mediatype'); + $defaults = ['path', 'meta', 'mediatype']; foreach ($defaults as $def) { $parm_loc = $request->request->get($post_sub . '_' . $def); @@ -104,7 +104,7 @@ class Subdefs implements ControllerProviderInterface } $mediatype = $request->request->get($post_sub . '_mediatype'); - $media = $request->request->get($post_sub . '_' . $mediatype, array()); + $media = $request->request->get($post_sub . '_' . $mediatype, []); foreach ($media as $option => $value) { @@ -115,13 +115,13 @@ class Subdefs implements ControllerProviderInterface $options[$option] = $value; } - $labels = $request->request->get($post_sub . '_label', array()); + $labels = $request->request->get($post_sub . '_label', []); $subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels); } } - return $app->redirectPath('admin_subdefs_subdef', array('sbas_id' => $databox->get_sbas_id())); + return $app->redirectPath('admin_subdefs_subdef', ['sbas_id' => $databox->get_sbas_id()]); }) ->bind('admin_subdefs_subdef_update') ->assert('sbas_id', '\d+'); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php index 22f75dcd2c..223d0dfbd0 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php @@ -122,10 +122,10 @@ class TaskManager implements ControllerProviderInterface public function getTasks(Application $app, Request $request) { - return $app['twig']->render('admin/task-manager/list.html.twig', array( + return $app['twig']->render('admin/task-manager/list.html.twig', [ 'available_jobs' => $app['task-manager.available-jobs'], 'tasks' => $app['manipulator.task']->getRepository()->findAll(), - )); + ]); } public function postCreateTask(Application $app, Request $request) @@ -143,7 +143,7 @@ class TaskManager implements ControllerProviderInterface $job->getEditor()->getDefaultPeriod() ); - return $app->redirectPath('admin_tasks_task_show', array('task' => $task->getId())); + return $app->redirectPath('admin_tasks_task_show', ['task' => $task->getId()]); } public function getSchedulerLog(Application $app, Request $request) @@ -153,10 +153,10 @@ class TaskManager implements ControllerProviderInterface $logFile->clear(); } - return $app['twig']->render('admin/task-manager/log.html.twig', array( + return $app['twig']->render('admin/task-manager/log.html.twig', [ 'logfile' => $logFile, 'logname' => 'Scheduler', - )); + ]); } public function getTaskLog(Application $app, Request $request, Task $task) @@ -166,10 +166,10 @@ class TaskManager implements ControllerProviderInterface $logFile->clear(); } - return $app['twig']->render('admin/task-manager/log.html.twig', array( + return $app['twig']->render('admin/task-manager/log.html.twig', [ 'logfile' => $logFile, 'logname' => sprintf('%s (task id %d)', $task->getName(), $task->getId()), - )); + ]); } public function postTaskDelete(Application $app, Request $request, Task $task) @@ -197,13 +197,13 @@ class TaskManager implements ControllerProviderInterface { $app['manipulator.task']->resetCrashes($task); - return $app->json(array('success' => true)); + return $app->json(['success' => true]); } public function postSaveTask(Application $app, Request $request, Task $task) { if (!$this->doValidateXML($request->request->get('settings'))) { - return $app->json(array('success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml')))); + return $app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]); } $form = $app->form(new TaskForm()); @@ -212,13 +212,13 @@ class TaskManager implements ControllerProviderInterface if ($form->isValid()) { $app['manipulator.task']->update($task); - return $app->json(array('success' => true)); + return $app->json(['success' => true]); } - return $app->json(array( + return $app->json([ 'success' => false, 'message' => implode("\n", $form->getErrors()) - )); + ]); } public function postTaskFacility(Application $app, Request $request, Task $task) @@ -246,16 +246,16 @@ class TaskManager implements ControllerProviderInterface $form = $app->form(new TaskForm()); $form->setData($task); - return $app['twig']->render($editor->getTemplatePath(), array( + return $app['twig']->render($editor->getTemplatePath(), [ 'task' => $task, 'form' => $form->createView(), 'view' => 'XML', - )); + ]); } public function validateXML(Application $app, Request $request) { - return $app->json(array('success' => $this->doValidateXML($request->getContent()))); + return $app->json(['success' => $this->doValidateXML($request->getContent())]); } private function doValidateXML($string) diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index d54e3b58b9..5867f2b758 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -50,7 +50,7 @@ class Users implements ControllerProviderInterface $controllers->post('/rights/reset/', function (Application $app, Request $request) { try { - $datas = array('error' => false); + $datas = ['error' => false]; $helper = new UserHelper\Edit($app, $request); $helper->resetRights(); @@ -70,7 +70,7 @@ class Users implements ControllerProviderInterface }); $controllers->post('/rights/apply/', function (Application $app) { - $datas = array('error' => true); + $datas = ['error' => true]; try { $rights = new UserHelper\Edit($app, $app['request']); @@ -88,7 +88,7 @@ class Users implements ControllerProviderInterface $rights->apply_infos(); - $datas = array('error' => false); + $datas = ['error' => false]; } catch (\Exception $e) { $datas['message'] = $e->getMessage(); } @@ -106,7 +106,7 @@ class Users implements ControllerProviderInterface $rights = new UserHelper\Edit($app, $app['request']); $rights->apply_quotas(); - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); }); $controllers->post('/rights/time/', function (Application $app) { @@ -125,7 +125,7 @@ class Users implements ControllerProviderInterface $rights = new UserHelper\Edit($app, $app['request']); $rights->apply_time(); - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); }); $controllers->post('/rights/masks/', function (Application $app) { @@ -138,7 +138,7 @@ class Users implements ControllerProviderInterface $rights = new UserHelper\Edit($app, $app['request']); $rights->apply_masks(); - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); }); $controllers->match('/search/', function (Application $app) { @@ -152,8 +152,8 @@ class Users implements ControllerProviderInterface $users = new UserHelper\Manage($app, $app['request']); - $userTable = array( - array( + $userTable = [ + [ 'ID', 'Login', 'Last Name', @@ -170,12 +170,12 @@ class Users implements ControllerProviderInterface 'Job', 'Company', 'Position' - ) - ); + ] + ]; foreach ($users->export() as $user) { /* @var $user \User_Adapter */ - $userTable[] = array( + $userTable[] = [ $user->get_id(), $user->get_login(), $user->get_lastname(), @@ -192,12 +192,12 @@ class Users implements ControllerProviderInterface $user->get_job(), $user->get_company(), $user->get_position() - ); + ]; } $CSVDatas = \format::arr_to_csv($userTable); - $response = new Response($CSVDatas, 200, array('Content-Type' => 'text/csv')); + $response = new Response($CSVDatas, 200, ['Content-Type' => 'text/csv']); $response->headers->set('Content-Disposition', 'attachment; filename=export.csv'); return $response; @@ -220,10 +220,10 @@ class Users implements ControllerProviderInterface $user_query = new \User_Query($app); $like_value = $request->query->get('term'); - $rights = $request->query->get('filter_rights') ? : array(); - $have_right = $request->query->get('have_right') ? : array(); - $have_not_right = $request->query->get('have_not_right') ? : array(); - $on_base = $request->query->get('on_base') ? : array(); + $rights = $request->query->get('filter_rights') ? : []; + $have_right = $request->query->get('have_right') ? : []; + $have_not_right = $request->query->get('have_not_right') ? : []; + $on_base = $request->query->get('on_base') ? : []; $elligible_users = $user_query ->on_sbas_where_i_am($app['acl']->get($app['authentication']->getUser()), $rights) @@ -238,15 +238,15 @@ class Users implements ControllerProviderInterface ->execute() ->get_results(); - $datas = array(); + $datas = []; foreach ($elligible_users as $user) { - $datas[] = array( + $datas[] = [ 'email' => $user->get_email() ? : '' , 'login' => $user->get_login() ? : '' , 'name' => $user->get_display_name() ? : '' , 'id' => $user->get_id() - ); + ]; } return $app->json($datas); @@ -254,7 +254,7 @@ class Users implements ControllerProviderInterface $controllers->post('/create/', function (Application $app) { - $datas = array('error' => false, 'message' => '', 'data' => null); + $datas = ['error' => false, 'message' => '', 'data' => null]; try { $request = $app['request']; $module = new UserHelper\Manage($app, $app['request']); @@ -284,15 +284,15 @@ class Users implements ControllerProviderInterface $on_base = $request->request->get('base_id') ? : null; $on_sbas = $request->request->get('sbas_id') ? : null; - $elligible_users = $user_query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canadmin')) + $elligible_users = $user_query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canadmin']) ->like($like_field, $like_value) ->on_base_ids($on_base) ->on_sbas_ids($on_sbas); $offset = 0; - $buffer = array(); + $buffer = []; - $buffer[] = array( + $buffer[] = [ 'ID' , 'Login' , _('admin::compte-utilisateur nom') @@ -309,7 +309,7 @@ class Users implements ControllerProviderInterface , _('admin::compte-utilisateur poste') , _('admin::compte-utilisateur societe') , _('admin::compte-utilisateur activite') - ); + ]; do { $elligible_users->limit($offset, 20); $offset += 20; @@ -317,7 +317,7 @@ class Users implements ControllerProviderInterface $results = $elligible_users->execute()->get_results(); foreach ($results as $user) { - $buffer[] = array( + $buffer[] = [ $user->get_id() , $user->get_login() , $user->get_lastname() @@ -334,16 +334,16 @@ class Users implements ControllerProviderInterface , $user->get_job() , $user->get_company() , $user->get_position() - ); + ]; } } while (count($results) > 0); $out = \format::arr_to_csv($buffer); - $response = new Response($out, 200, array( + $response = new Response($out, 200, [ 'Content-type' => 'text/csv', 'Content-Disposition' => 'attachment; filename=export.csv', - )); + ]); $response->setCharset('UTF-8'); @@ -355,15 +355,15 @@ class Users implements ControllerProviderInterface $lastMonth = time() - (3 * 4 * 7 * 24 * 60 * 60); $sql = "DELETE FROM demand WHERE date_modif < :date"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':date' => date('Y-m-d', $lastMonth))); + $stmt->execute([':date' => date('Y-m-d', $lastMonth)]); $stmt->closeCursor(); - $baslist = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $baslist = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canadmin'])); $sql = 'SELECT usr_id, usr_login FROM usr WHERE model_of = :usr_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $models = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -381,7 +381,7 @@ class Users implements ControllerProviderInterface $stmt->closeCursor(); $currentUsr = null; - $table = array('user' => array(), 'coll' => array()); + $table = ['user' => [], 'coll' => []]; foreach ($rs as $row) { if ($row['usr_id'] != $currentUsr) { @@ -391,7 +391,7 @@ class Users implements ControllerProviderInterface } if (!isset($table['coll'][$row['usr_id']])) { - $table['coll'][$row['usr_id']] = array(); + $table['coll'][$row['usr_id']] = []; } if (!in_array($row['base_id'], $table['coll'][$row['usr_id']])) { @@ -401,17 +401,17 @@ class Users implements ControllerProviderInterface $stmt->closeCursor(); - return $app['twig']->render('admin/user/demand.html.twig', array( + return $app['twig']->render('admin/user/demand.html.twig', [ 'table' => $table, 'models' => $models, - )); + ]); })->bind('users_display_demands'); $controllers->post('/demands/', function (Application $app, Request $request) { - $templates = $deny = $accept = $options = array(); + $templates = $deny = $accept = $options = []; - foreach ($request->request->get('template', array()) as $tmp) { + foreach ($request->request->get('template', []) as $tmp) { if (trim($tmp) != '') { $tmp = explode('_', $tmp); @@ -421,29 +421,29 @@ class Users implements ControllerProviderInterface } } - foreach ($request->request->get('deny', array()) as $den) { + foreach ($request->request->get('deny', []) as $den) { $den = explode('_', $den); if (count($den) == 2 && !isset($templates[$den[0]])) { $deny[$den[0]][$den[1]] = $den[1]; } } - foreach ($request->request->get('accept', array()) as $acc) { + foreach ($request->request->get('accept', []) as $acc) { $acc = explode('_', $acc); if (count($acc) == 2 && !isset($templates[$acc[0]])) { $accept[$acc[0]][$acc[1]] = $acc[1]; - $options[$acc[0]][$acc[1]] = array('HD' => false, 'WM' => false); + $options[$acc[0]][$acc[1]] = ['HD' => false, 'WM' => false]; } } - foreach ($request->request->get('accept_hd', array()) as $accHD) { + foreach ($request->request->get('accept_hd', []) as $accHD) { $accHD = explode('_', $accHD); if (count($accHD) == 2 && isset($accept[$accHD[0]]) && isset($options[$accHD[0]][$accHD[1]])) { $options[$accHD[0]][$accHD[1]]['HD'] = true; } } - foreach ($request->request->get('watermark', array()) as $wm) { + foreach ($request->request->get('watermark', []) as $wm) { $wm = explode('_', $wm); if (count($wm) == 2 && isset($accept[$wm[0]]) && isset($options[$wm[0]][$wm[1]])) { $options[$wm[0]][$wm[1]]['WM'] = true; @@ -451,8 +451,8 @@ class Users implements ControllerProviderInterface } if (count($templates) > 0 || count($deny) > 0 || count($accept) > 0) { - $done = array(); - $cache_to_update = array(); + $done = []; + $cache_to_update = []; foreach ($templates as $usr => $template_id) { $user = \User_Adapter::getInstance($usr, $app); @@ -464,7 +464,7 @@ class Users implements ControllerProviderInterface $app['acl']->get($user)->apply_model($user_template, $base_ids); if (!isset($done[$usr])) { - $done[$usr] = array(); + $done[$usr] = []; } foreach ($base_ids as $base_id) { @@ -477,7 +477,7 @@ class Users implements ControllerProviderInterface AND (base_id = " . implode(' OR base_id = ', $base_ids) . ")"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr)); + $stmt->execute([':usr_id' => $usr]); $stmt->closeCursor(); } @@ -491,10 +491,10 @@ class Users implements ControllerProviderInterface foreach ($deny as $usr => $bases) { $cache_to_update[$usr] = true; foreach ($bases as $bas) { - $stmt->execute(array(':usr_id' => $usr, ':base_id' => $bas)); + $stmt->execute([':usr_id' => $usr, ':base_id' => $bas]); if (!isset($done[$usr])) { - $done[$usr] = array(); + $done[$usr] = []; } $done[$usr][$bas] = false; @@ -508,28 +508,28 @@ class Users implements ControllerProviderInterface $cache_to_update[$usr] = true; foreach ($bases as $bas) { - $app['acl']->get($user)->give_access_to_sbas(array(\phrasea::sbasFromBas($app, $bas))); + $app['acl']->get($user)->give_access_to_sbas([\phrasea::sbasFromBas($app, $bas)]); - $rights = array( + $rights = [ 'canputinalbum' => '1' , 'candwnldhd' => ($options[$usr][$bas]['HD'] ? '1' : '0') , 'nowatermark' => ($options[$usr][$bas]['WM'] ? '0' : '1') , 'candwnldpreview' => '1' , 'actif' => '1' - ); + ]; - $app['acl']->get($user)->give_access_to_base(array($bas)); + $app['acl']->get($user)->give_access_to_base([$bas]); $app['acl']->get($user)->update_rights_to_base($bas, $rights); if (!isset($done[$usr])) { - $done[$usr] = array(); + $done[$usr] = []; } $done[$usr][$bas] = true; $sql = "DELETE FROM demand WHERE usr_id = :usr_id AND base_id = :base_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr, ':base_id' => $bas)); + $stmt->execute([':usr_id' => $usr, ':base_id' => $bas]); $stmt->closeCursor(); } } @@ -544,7 +544,7 @@ class Users implements ControllerProviderInterface $sql = 'SELECT usr_mail FROM usr WHERE usr_id = :usr_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $usr)); + $stmt->execute([':usr_id' => $usr]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -579,7 +579,7 @@ class Users implements ControllerProviderInterface } } - return $app->redirectPath('users_display_demands', array('success' => 1)); + return $app->redirectPath('users_display_demands', ['success' => 1]); })->bind('users_submit_demands'); $controllers->get('/import/file/', function (Application $app, Request $request) { @@ -588,16 +588,16 @@ class Users implements ControllerProviderInterface $controllers->post('/import/file/', function (Application $app, Request $request) { if ((null === $file = $request->files->get('files')) || !$file->isValid()) { - return $app->redirectPath('users_display_import_file', array('error' => 'file-invalid')); + return $app->redirectPath('users_display_import_file', ['error' => 'file-invalid']); } $equivalenceToMysqlField = self::getEquivalenceToMysqlField(); $loginDefined = $pwdDefined = $mailDefined = false; - $loginNew = array(); - $out = array( - 'ignored_row' => array(), - 'errors' => array() - ); + $loginNew = []; + $out = [ + 'ignored_row' => [], + 'errors' => [] + ]; $nbUsrToAdd = 0; $lines = \format::csv_to_arr($file->getPathname()); @@ -633,15 +633,15 @@ class Users implements ControllerProviderInterface } if (!$loginDefined) { - return $app->redirectPath('users_display_import_file', array('error' => 'row-login')); + return $app->redirectPath('users_display_import_file', ['error' => 'row-login']); } if (!$pwdDefined) { - return $app->redirectPath('users_display_import_file', array('error' => 'row-pwd')); + return $app->redirectPath('users_display_import_file', ['error' => 'row-pwd']); } if (!$mailDefined) { - return $app->redirectPath('users_display_import_file', array('error' => 'row-mail')); + return $app->redirectPath('users_display_import_file', ['error' => 'row-mail']); } foreach ($lines as $nbLine => $line) { @@ -703,15 +703,15 @@ class Users implements ControllerProviderInterface } if (count($out['errors']) > 0 && $nbUsrToAdd === 0) { - return $app['twig']->render('admin/user/import/file.html.twig', array( + return $app['twig']->render('admin/user/import/file.html.twig', [ 'errors' => $out['errors'] - )); + ]); } if ($nbUsrToAdd === 0) { - return $app->redirectPath('users_display_import_file', array( + return $app->redirectPath('users_display_import_file', [ 'error' => 'no-user' - )); + ]); } $sql = " @@ -720,22 +720,22 @@ class Users implements ControllerProviderInterface INNER JOIN basusr ON (basusr.usr_id=usr.usr_id) WHERE usr.model_of = :usr_id - AND base_id in(" . implode(', ', array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('manage')))) . ") + AND base_id in(" . implode(', ', array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage']))) . ") AND usr_login not like '(#deleted_%)' GROUP BY usr_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $models = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - return $app['twig']->render('/admin/user/import/view.html.twig', array( + return $app['twig']->render('/admin/user/import/view.html.twig', [ 'nb_user_to_add' => $nbUsrToAdd, 'models' => $models, 'lines_serialized' => serialize($lines), 'columns_serialized' => serialize($columns), 'errors' => $out['errors'] - )); + ]); })->bind('users_submit_import_file'); $controllers->post('/import/', function (Application $app, Request $request) { @@ -759,7 +759,7 @@ class Users implements ControllerProviderInterface $equivalenceToMysqlField = Users::getEquivalenceToMysqlField(); foreach ($lines as $nbLine => $line) { - $curUser = array(); + $curUser = []; foreach ($columns as $nbCol => $colName) { if (!isset($equivalenceToMysqlField[$colName]) || !isset($line[$nbCol])) { continue; @@ -859,7 +859,7 @@ class Users implements ControllerProviderInterface } $app['acl']->get($NewUser)->apply_model( - \User_Adapter::getInstance($model, $app), array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('manage'))) + \User_Adapter::getInstance($model, $app), array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage'])) ); $nbCreation++; @@ -867,7 +867,7 @@ class Users implements ControllerProviderInterface } } - return $app->redirectPath('admin_users_search', array('user-updated' => $nbCreation)); + return $app->redirectPath('admin_users_search', ['user-updated' => $nbCreation]); })->bind('users_submit_import'); $controllers->get('/import/example/csv/', function (Application $app) { @@ -913,7 +913,7 @@ class Users implements ControllerProviderInterface public static function getEquivalenceToMysqlField() { - $equivalenceToMysqlField = array(); + $equivalenceToMysqlField = []; $equivalenceToMysqlField['civilite'] = 'usr_sexe'; $equivalenceToMysqlField['gender'] = 'usr_sexe'; diff --git a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php index 2dc9c8e714..72d15a18e8 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php +++ b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php @@ -86,15 +86,15 @@ class Oauth2 implements ControllerProviderInterface return $app->redirectPath('oauth2_authorize'); } } catch (RequireCaptchaException $e) { - return $app->redirectPath('oauth2_authorize', array('error' => 'captcha')); + return $app->redirectPath('oauth2_authorize', ['error' => 'captcha']); } catch (AccountLockedException $e) { - return $app->redirectPath('oauth2_authorize', array('error' => 'account-locked')); + return $app->redirectPath('oauth2_authorize', ['error' => 'account-locked']); } $app['authentication']->openAccount(\User_Adapter::getInstance($usr_id, $app)); } - return new Response($app['twig']->render($template, array("auth" => $oauth2_adapter))); + return new Response($app['twig']->render($template, ["auth" => $oauth2_adapter])); } //check if current client is already authorized by current user @@ -114,10 +114,10 @@ class Oauth2 implements ControllerProviderInterface $params['account_id'] = $account->get_id(); if (!$app_authorized && $action_accept === null) { - $params = array( + $params = [ "auth" => $oauth2_adapter, "errorMessage" => $errorMessage, - ); + ]; return new Response($app['twig']->render($template, $params)); } elseif (!$app_authorized && $action_accept !== null) { @@ -149,7 +149,7 @@ class Oauth2 implements ControllerProviderInterface */ $controllers->post('/token', function (\Silex\Application $app, Request $request) { if ( ! $request->isSecure()) { - throw new HttpException(400, 'This route requires the use of the https scheme', null, array('content-type' => 'application/json')); + throw new HttpException(400, 'This route requires the use of the https scheme', null, ['content-type' => 'application/json']); } $app['oauth']->grantAccessToken($request); diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1.php b/lib/Alchemy/Phrasea/Controller/Api/V1.php index 3eb20acb8d..363797fe80 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1.php @@ -142,7 +142,7 @@ class V1 implements ControllerProviderInterface } } - return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action); + return ['ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action]; }; /** @@ -227,7 +227,7 @@ class V1 implements ControllerProviderInterface $controllers->get('/monitor/task/{task}/', function (SilexApplication $app, Request $request, $task) { return $app['api']->get_task($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin)->assert('task', '\d+'); /** @@ -244,7 +244,7 @@ class V1 implements ControllerProviderInterface $controllers->post('/monitor/task/{task}/', function (SilexApplication $app, Request $request, $task) { return $app['api']->set_task_property($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin)->assert('task', '\d+'); /** @@ -260,7 +260,7 @@ class V1 implements ControllerProviderInterface $controllers->post('/monitor/task/{task}/start/', function (SilexApplication $app, Request $request, $task) { return $app['api']->start_task($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin); /** @@ -276,7 +276,7 @@ class V1 implements ControllerProviderInterface $controllers->post('/monitor/task/{task}/stop/', function (SilexApplication $app, Request $request, $task) { return $app['api']->stop_task($app, $task)->get_response(); }) - ->convert('task', array($app['converter.task'], 'convert')) + ->convert('task', [$app['converter.task'], 'convert']) ->before($mustBeAdmin); /** diff --git a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php index 5765c17388..ba22eb5398 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Baskets.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Baskets.php @@ -71,9 +71,9 @@ class Baskets implements ControllerProviderInterface } - return $app->redirectPath('get_client_baskets', array( + return $app->redirectPath('get_client_baskets', [ 'courChuId' => $request->request->get('courChuId', '') - )); + ]); } /** @@ -122,9 +122,9 @@ class Baskets implements ControllerProviderInterface } - return $app->redirectPath('get_client_baskets', array( + return $app->redirectPath('get_client_baskets', [ 'courChuId' => null !== $basket ? $basket->getId() : '' - )); + ]); } /** @@ -154,9 +154,9 @@ class Baskets implements ControllerProviderInterface } - return $app->redirectPath('get_client_baskets', array( + return $app->redirectPath('get_client_baskets', [ 'courChuId' => $basket ? $basket->getId() : '' - )); + ]); } /** @@ -185,13 +185,13 @@ class Baskets implements ControllerProviderInterface return (Boolean) $basket->getPusherId(); }); - return $app['twig']->render('client/baskets.html.twig', array( + return $app['twig']->render('client/baskets.html.twig', [ 'total_baskets' => $baskets->count(), 'user_baskets' => $basketCollections[1], 'recept_user_basket' => $basketCollections[0], 'selected_basket' => $selectedBasket, 'selected_basket_elements' => $selectedBasket ? $selectedBasket->getElements() : new ArrayCollection() - )); + ]); } /** @@ -215,10 +215,10 @@ class Baskets implements ControllerProviderInterface } } - return $app->json(array( + return $app->json([ 'success' => true, 'message' => '', 'no_view' => $noview - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Client/Root.php b/lib/Alchemy/Phrasea/Controller/Client/Root.php index c510d3affd..87a282796d 100644 --- a/lib/Alchemy/Phrasea/Controller/Client/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Client/Root.php @@ -32,7 +32,7 @@ class Root implements ControllerProviderInterface $controllers->before(function (Request $request) use ($app) { if (!$app['authentication']->isAuthenticated() && null !== $request->query->get('nolog')) { - return $app->redirectPath('login_authenticate_as_guest', array('redirect' => 'client')); + return $app->redirectPath('login_authenticate_as_guest', ['redirect' => 'client']); } $app['firewall']->requireAuthentication(); }); @@ -116,17 +116,17 @@ class Root implements ControllerProviderInterface return new Response($app['twig']->render("client/help.html.twig")); } - $resultData = array(); + $resultData = []; foreach ($searchData as $record) { try { $record->get_subdef('document'); - $lightInfo = $app['twig']->render('common/technical_datas.html.twig', array('record' => $record)); + $lightInfo = $app['twig']->render('common/technical_datas.html.twig', ['record' => $record]); } catch (\Exception $e) { $lightInfo = ''; } - $caption = $app['twig']->render('common/caption.html.twig', array('view' => 'answer', 'record' => $record)); + $caption = $app['twig']->render('common/caption.html.twig', ['view' => 'answer', 'record' => $record]); $docType = $record->get_type(); $isVideo = ($docType == 'video'); @@ -148,7 +148,7 @@ class Root implements ControllerProviderInterface $previewExists = false; } - $resultData[] = array( + $resultData[] = [ 'record' => $record, 'mini_logo' => \collection::getLogo($record->get_base_id(), $app), 'preview_exists' => $previewExists, @@ -160,10 +160,10 @@ class Root implements ControllerProviderInterface 'is_document' => $isDocument, 'can_download' => $canDownload, 'can_add_to_basket' => $app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'canputinalbum') - ); + ]; } - return new Response($app['twig']->render("client/answers.html.twig", array( + return new Response($app['twig']->render("client/answers.html.twig", [ 'mod_col' => $modCol, 'mod_row' => $modRow, 'result_data' => $resultData, @@ -174,7 +174,7 @@ class Root implements ControllerProviderInterface 'result' => $result, 'proposals' => $currentPage === 1 ? $result->getProposals() : null, 'help' => count($resultData) === 0 ? $this->getHelpStartPage($app) : '', - ))); + ])); } /** @@ -210,7 +210,7 @@ class Root implements ControllerProviderInterface */ public function getClientLanguage(Application $app, Request $request) { - $out = array(); + $out = []; $out['createWinInvite'] = _('paniers:: Quel nom souhaitez vous donner a votre panier ?'); $out['chuNameEmpty'] = _('paniers:: Quel nom souhaitez vous donner a votre panier ?'); $out['noDLok'] = _('export:: aucun document n\'est disponible au telechargement'); @@ -251,7 +251,7 @@ class Root implements ControllerProviderInterface $renderTopics = \queries::tree_topics($app['locale.I18n']); } - return new Response($app['twig']->render('client/index.html.twig', array( + return new Response($app['twig']->render('client/index.html.twig', [ 'last_action' => !$app['authentication']->getUser()->is_guest() && false !== $request->cookies->has('last_act') ? $request->cookies->has('last_act') : null, 'phrasea_home' => $this->getDefaultClientStartPage($app), 'render_topics' => $renderTopics, @@ -260,13 +260,13 @@ class Root implements ControllerProviderInterface 'storage_access' => $this->getDocumentStorageAccess($app), 'tabs_setup' => $this->getTabSetup($app), 'module' => 'client', - 'menubar' => $app['twig']->render('common/menubar.html.twig', array('module' => 'client')), + 'menubar' => $app['twig']->render('common/menubar.html.twig', ['module' => 'client']), 'css_file' => $this->getCssFile($app), 'basket_status' => null !== $app['authentication']->getUser()->getPrefs('client_basket_status') ? $app['authentication']->getUser()->getPrefs('client_basket_status') : "1", 'mod_pres' => null !== $app['authentication']->getUser()->getPrefs('client_view') ? $app['authentication']->getUser()->getPrefs('client_view') : '', 'start_page' => $app['authentication']->getUser()->getPrefs('start_page'), 'start_page_query' => null !== $app['authentication']->getUser()->getPrefs('start_page_query') ? $app['authentication']->getUser()->getPrefs('start_page_query') : '' - ))); + ])); } /** @@ -276,15 +276,15 @@ class Root implements ControllerProviderInterface */ private function getGridProperty() { - return array( - array('w' => '3', 'h' => '2', 'name' => '3*2', 'selected' => '0'), - array('w' => '5', 'h' => '4', 'name' => '5*4', 'selected' => '0'), - array('w' => '4', 'h' => '10', 'name' => '4*10', 'selected' => '0'), - array('w' => '6', 'h' => '3', 'name' => '6*3', 'selected' => '1'), - array('w' => '8', 'h' => '4', 'name' => '8*4', 'selected' => '0'), - array('w' => '1', 'h' => '10', 'name' => 'list*10', 'selected' => '0'), - array('w' => '1', 'h' => '100', 'name' => 'list*100', 'selected' => '0') - ); + return [ + ['w' => '3', 'h' => '2', 'name' => '3*2', 'selected' => '0'], + ['w' => '5', 'h' => '4', 'name' => '5*4', 'selected' => '0'], + ['w' => '4', 'h' => '10', 'name' => '4*10', 'selected' => '0'], + ['w' => '6', 'h' => '3', 'name' => '6*3', 'selected' => '1'], + ['w' => '8', 'h' => '4', 'name' => '8*4', 'selected' => '0'], + ['w' => '1', 'h' => '10', 'name' => 'list*10', 'selected' => '0'], + ['w' => '1', 'h' => '100', 'name' => 'list*100', 'selected' => '0'] + ]; } /** @@ -295,22 +295,22 @@ class Root implements ControllerProviderInterface */ private function getDocumentStorageAccess(Application $app) { - $allDataboxes = $allCollections = array(); + $allDataboxes = $allCollections = []; foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_sbas() as $databox) { if (count($app['phraseanet.appbox']->get_databoxes()) > 0) { - $allDataboxes[$databox->get_sbas_id()] = array('databox' => $databox, 'collections' => array()); + $allDataboxes[$databox->get_sbas_id()] = ['databox' => $databox, 'collections' => []]; } if (count($databox->get_collections()) > 0) { - foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { + foreach ($app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]) as $coll) { $allDataboxes[$databox->get_sbas_id()]['collections'][$coll->get_base_id()] = $coll; $allCollections[$coll->get_base_id()] = $coll; } } } - return array('databoxes' => $allDataboxes, 'collections' => $allCollections); + return ['databoxes' => $allDataboxes, 'collections' => $allCollections]; } /** @@ -321,16 +321,16 @@ class Root implements ControllerProviderInterface */ private function getTabSetup(Application $app) { - $tong = array( + $tong = [ $app['phraseanet.registry']->get('GV_ong_search') => 1, $app['phraseanet.registry']->get('GV_ong_advsearch') => 2, $app['phraseanet.registry']->get('GV_ong_topics') => 3 - ); + ]; unset($tong[0]); if (count($tong) == 0) { - $tong = array(1 => 1); + $tong = [1 => 1]; } ksort($tong); @@ -348,7 +348,7 @@ class Root implements ControllerProviderInterface { $cssPath = __DIR__ . '/../../../../../www/skins/client/'; - $css = array(); + $css = []; $cssFile = $app['authentication']->getUser()->getPrefs('client_css'); $finder = new Finder(); @@ -387,8 +387,8 @@ class Root implements ControllerProviderInterface $query .= $clientQuery; } - $opAdv = $request->request->get('opAdv', array()); - $queryAdv = $request->request->get('qryAdv', array()); + $opAdv = $request->request->get('opAdv', []); + $queryAdv = $request->request->get('qryAdv', []); if (count($opAdv) > 0 && count($opAdv) == count($queryAdv)) { foreach ($opAdv as $opId => $op) { @@ -423,7 +423,7 @@ class Root implements ControllerProviderInterface return $this->getPublicationStartPage($app); } - if (in_array($startPage, array('QUERY', 'LAST_QUERY'))) { + if (in_array($startPage, ['QUERY', 'LAST_QUERY'])) { return $this->getQueryStartPage($app); } @@ -438,7 +438,7 @@ class Root implements ControllerProviderInterface */ private function getQueryStartPage(Application $app) { - $collections = $queryParameters = array(); + $collections = $queryParameters = []; $searchSet = json_decode($app['authentication']->getUser()->getPrefs('search')); @@ -456,11 +456,11 @@ class Root implements ControllerProviderInterface $queryParameters["pag"] = 0; $queryParameters["search_type"] = SearchEngineOptions::RECORD_RECORD; $queryParameters["qryAdv"] = ''; - $queryParameters["opAdv"] = array(); - $queryParameters["status"] = array(); + $queryParameters["opAdv"] = []; + $queryParameters["status"] = []; $queryParameters["recordtype"] = SearchEngineOptions::TYPE_ALL; $queryParameters["sort"] = $app['phraseanet.registry']->get('GV_phrasea_sort', ''); - $queryParameters["infield"] = array(); + $queryParameters["infield"] = []; $queryParameters["ord"] = SearchEngineOptions::SORT_MODE_DESC; $subRequest = Request::create('/client/query/', 'POST', $queryParameters); @@ -476,10 +476,10 @@ class Root implements ControllerProviderInterface */ private function getPublicationStartPage(Application $app) { - return $app['twig']->render('client/home_inter_pub_basket.html.twig', array( + return $app['twig']->render('client/home_inter_pub_basket.html.twig', [ 'feeds' => Aggregate::createFromUser($app, $app['authentication']->getUser()), 'image_size' => (int) $app['authentication']->getUser()->getPrefs('images_size') - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Controller/Lightbox.php b/lib/Alchemy/Phrasea/Controller/Lightbox.php index 868ce57ec2..a6a58091af 100644 --- a/lib/Alchemy/Phrasea/Controller/Lightbox.php +++ b/lib/Alchemy/Phrasea/Controller/Lightbox.php @@ -53,11 +53,11 @@ class Lightbox implements ControllerProviderInterface } switch ($datas['type']) { case \random::TYPE_FEED_ENTRY: - return $app->redirectPath('lightbox_feed_entry', array('entry_id' => $datas['datas'])); + return $app->redirectPath('lightbox_feed_entry', ['entry_id' => $datas['datas']]); break; case \random::TYPE_VALIDATE: case \random::TYPE_VIEW: - return $app->redirectPath('lightbox_validation', array('basket' => $datas['datas'])); + return $app->redirectPath('lightbox_validation', ['basket' => $datas['datas']]); break; } }); @@ -88,11 +88,11 @@ class Lightbox implements ControllerProviderInterface $template = 'lightbox/IE6/index.html.twig'; } - return new Response($app['twig']->render($template, array( + return new Response($app['twig']->render($template, [ 'baskets_collection' => $basket_collection, 'module_name' => 'Lightbox', 'module' => 'lightbox' - ) + ] )); }) ->bind('lightbox'); @@ -107,10 +107,10 @@ class Lightbox implements ControllerProviderInterface ->getRepository('Alchemy\Phrasea\Model\Entities\BasketElement') ->findUserElement($sselcont_id, $app['authentication']->getUser()); - $parameters = array( + $parameters = [ 'basket_element' => $basketElement, 'module_name' => '', - ); + ]; return $app['twig']->render('lightbox/note_form.html.twig', $parameters); }) @@ -123,10 +123,10 @@ class Lightbox implements ControllerProviderInterface $BasketElement = $repository->findUserElement($sselcont_id, $app['authentication']->getUser()); if ($app['browser']->isMobile()) { - $output = $app['twig']->render('lightbox/basket_element.html.twig', array( + $output = $app['twig']->render('lightbox/basket_element.html.twig', [ 'basket_element' => $BasketElement, 'module_name' => $BasketElement->getRecord($app)->get_title() - ) + ] ); return new Response($output); @@ -145,16 +145,16 @@ class Lightbox implements ControllerProviderInterface $Basket = $BasketElement->getBasket(); - $ret = array(); + $ret = []; $ret['number'] = $BasketElement->getRecord($app)->get_number(); $ret['title'] = $BasketElement->getRecord($app)->get_title(); - $ret['preview'] = $app['twig']->render($template_preview, array('record' => $BasketElement->getRecord($app), 'not_wrapped' => true)); - $ret['options_html'] = $app['twig']->render($template_options, array('basket_element' => $BasketElement)); - $ret['agreement_html'] = $app['twig']->render($template_agreement, array('basket' => $Basket, 'basket_element' => $BasketElement)); - $ret['selector_html'] = $app['twig']->render($template_selector, array('basket_element' => $BasketElement)); - $ret['note_html'] = $app['twig']->render($template_note, array('basket_element' => $BasketElement)); - $ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $BasketElement->getRecord($app))); + $ret['preview'] = $app['twig']->render($template_preview, ['record' => $BasketElement->getRecord($app), 'not_wrapped' => true]); + $ret['options_html'] = $app['twig']->render($template_options, ['basket_element' => $BasketElement]); + $ret['agreement_html'] = $app['twig']->render($template_agreement, ['basket' => $Basket, 'basket_element' => $BasketElement]); + $ret['selector_html'] = $app['twig']->render($template_selector, ['basket_element' => $BasketElement]); + $ret['note_html'] = $app['twig']->render($template_note, ['basket_element' => $BasketElement]); + $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $BasketElement->getRecord($app)]); return $app->json($ret); } @@ -168,10 +168,10 @@ class Lightbox implements ControllerProviderInterface $item = $entry->getItem($item_id); if ($app['browser']->isMobile()) { - $output = $app['twig']->render('lightbox/feed_element.html.twig', array( + $output = $app['twig']->render('lightbox/feed_element.html.twig', [ 'feed_element' => $item, 'module_name' => $item->getRecord($app)->get_title() - ) + ] ); return new Response($output); @@ -184,13 +184,13 @@ class Lightbox implements ControllerProviderInterface $template_options = 'lightbox/IE6/feed_options_box.html.twig'; } - $ret = array(); + $ret = []; $ret['number'] = $item->getRecord($app)->get_number(); $ret['title'] = $item->getRecord($app)->get_title(); - $ret['preview'] = $app['twig']->render($template_preview, array('record' => $item->getRecord($app), 'not_wrapped' => true)); - $ret['options_html'] = $app['twig']->render($template_options, array('feed_element' => $item)); - $ret['caption'] = $app['twig']->render($template_caption, array('view' => 'preview', 'record' => $item->getRecord($app))); + $ret['preview'] = $app['twig']->render($template_preview, ['record' => $item->getRecord($app), 'not_wrapped' => true]); + $ret['options_html'] = $app['twig']->render($template_options, ['feed_element' => $item]); + $ret['caption'] = $app['twig']->render($template_caption, ['view' => 'preview', 'record' => $item->getRecord($app)]); $ret['agreement_html'] = $ret['selector_html'] = $ret['note_html'] = ''; @@ -233,13 +233,13 @@ class Lightbox implements ControllerProviderInterface $template = 'lightbox/IE6/validate.html.twig'; } - $response = new Response($app['twig']->render($template, array( + $response = new Response($app['twig']->render($template, [ 'baskets_collection' => $basket_collection, 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') - ) + ] )); $response->setCharset('UTF-8'); @@ -280,13 +280,13 @@ class Lightbox implements ControllerProviderInterface $template = 'lightbox/IE6/validate.html.twig'; } - $response = new Response($app['twig']->render($template, array( + $response = new Response($app['twig']->render($template, [ 'baskets_collection' => $basket_collection, 'basket' => $basket, 'local_title' => strip_tags($basket->getName()), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') - ) + ] )); $response->setCharset('UTF-8'); @@ -314,13 +314,13 @@ class Lightbox implements ControllerProviderInterface $content = $feed_entry->getItems(); $first = $content->first(); - $output = $app['twig']->render($template, array( + $output = $app['twig']->render($template, [ 'feed_entry' => $feed_entry, 'first_item' => $first, 'local_title' => $feed_entry->getTitle(), 'module' => 'lightbox', 'module_name' => _('admin::monitor: module validation') - ) + ] ); $response = new Response($output, 200); $response->setCharset('UTF-8'); @@ -331,13 +331,13 @@ class Lightbox implements ControllerProviderInterface ->assert('entry_id', '\d+'); $controllers->get('/ajax/LOAD_REPORT/{basket}/', function (SilexApplication $app, Basket $basket) { - return new Response($app['twig']->render('lightbox/basket_content_report.html.twig', array('basket' => $basket))); + return new Response($app['twig']->render('lightbox/basket_content_report.html.twig', ['basket' => $basket])); }) ->bind('lightbox_ajax_report') ->assert('basket', '\d+'); $controllers->post('/ajax/SET_NOTE/{sselcont_id}/', function (SilexApplication $app, $sselcont_id) { - $output = array('error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees')); + $output = ['error' => true, 'datas' => _('Erreur lors de l\'enregistrement des donnees')]; $request = $app['request']; $note = $request->request->get('note'); @@ -359,15 +359,15 @@ class Lightbox implements ControllerProviderInterface $app['EM']->flush(); if ($app['browser']->isMobile()) { - $datas = $app['twig']->render('lightbox/sc_note.html.twig', array('basket_element' => $basket_element)); + $datas = $app['twig']->render('lightbox/sc_note.html.twig', ['basket_element' => $basket_element]); - $output = array('error' => false, 'datas' => $datas); + $output = ['error' => false, 'datas' => $datas]; } else { $template = 'lightbox/sc_note.html.twig'; - $datas = $app['twig']->render($template, array('basket_element' => $basket_element)); + $datas = $app['twig']->render($template, ['basket_element' => $basket_element]); - $output = array('error' => false, 'datas' => $datas); + $output = ['error' => false, 'datas' => $datas]; } return $app->json($output); @@ -387,11 +387,11 @@ class Lightbox implements ControllerProviderInterface $releasable = false; try { - $ret = array( + $ret = [ 'error' => true, 'releasable' => false, 'datas' => _('Erreur lors de la mise a jour des donnes ') - ); + ]; $repository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\BasketElement'); @@ -423,11 +423,11 @@ class Lightbox implements ControllerProviderInterface $releasable = _('Do you want to send your report ?'); } - $ret = array( + $ret = [ 'error' => false , 'datas' => '' , 'releasable' => $releasable - ); + ]; } catch (ControllerException $e) { $ret['datas'] = $e->getMessage(); } @@ -439,7 +439,7 @@ class Lightbox implements ControllerProviderInterface $controllers->post('/ajax/SET_RELEASE/{basket}/', function (SilexApplication $app, Basket $basket) { - $datas = array('error' => true, 'datas' => ''); + $datas = ['error' => true, 'datas' => '']; try { if (!$basket->getValidation()) { @@ -466,20 +466,20 @@ class Lightbox implements ControllerProviderInterface $participant = $basket->getValidation()->getParticipant($app['authentication']->getUser(), $app); $expires = new \DateTime('+10 days'); - $url = $app->url('lightbox', array('LOG' => $app['tokens']->getUrlToken( + $url = $app->url('lightbox', ['LOG' => $app['tokens']->getUrlToken( \random::TYPE_VALIDATE , $basket->getValidation()->getInitiator($app)->get_id() , $expires , $basket->getId() - ))); + )]); $to = $basket->getValidation()->getInitiator($app)->get_id(); - $params = array( + $params = [ 'ssel_id' => $basket->getId(), 'from' => $app['authentication']->getUser()->get_id(), 'url' => $url, 'to' => $to - ); + ]; $app['events-manager']->trigger('__VALIDATION_DONE__', $params); @@ -488,9 +488,9 @@ class Lightbox implements ControllerProviderInterface $app['EM']->merge($participant); $app['EM']->flush(); - $datas = array('error' => false, 'datas' => _('Envoie avec succes')); + $datas = ['error' => false, 'datas' => _('Envoie avec succes')]; } catch (ControllerException $e) { - $datas = array('error' => true, 'datas' => $e->getMessage()); + $datas = ['error' => true, 'datas' => $e->getMessage()]; } return $app->json($datas); diff --git a/lib/Alchemy/Phrasea/Controller/Minifier.php b/lib/Alchemy/Phrasea/Controller/Minifier.php index 00ff222346..5e1debcb2d 100644 --- a/lib/Alchemy/Phrasea/Controller/Minifier.php +++ b/lib/Alchemy/Phrasea/Controller/Minifier.php @@ -80,7 +80,7 @@ class Minifier implements ControllerProviderInterface * array('//static' => 'D:\\staticStorage') // Windows * */ - $min_symlinks = array(); + $min_symlinks = []; /** * If you upload files from Windows to a non-Windows server, Windows may report diff --git a/lib/Alchemy/Phrasea/Controller/Permalink.php b/lib/Alchemy/Phrasea/Controller/Permalink.php index 75cb69d4d7..a992319447 100644 --- a/lib/Alchemy/Phrasea/Controller/Permalink.php +++ b/lib/Alchemy/Phrasea/Controller/Permalink.php @@ -33,7 +33,7 @@ class Permalink extends AbstractDelivery $that = $this; $retrieveRecord = function ($app, $databox, $token, $record_id, $subdef) { - if (in_array($subdef, array(\databox_subdef::CLASS_PREVIEW, \databox_subdef::CLASS_THUMBNAIL)) && $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedItem')->isRecordInPublicFeed($app, $databox->get_sbas_id(), $record_id)) { + if (in_array($subdef, [\databox_subdef::CLASS_PREVIEW, \databox_subdef::CLASS_THUMBNAIL]) && $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedItem')->isRecordInPublicFeed($app, $databox->get_sbas_id(), $record_id)) { $record = $databox->get_record($record_id); } else { $record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef); @@ -51,13 +51,13 @@ class Permalink extends AbstractDelivery $record = $retrieveRecord($app, $databox, $token, $record_id, $subdef); - $params = array( + $params = [ 'subdef_name' => $subdef , 'module_name' => 'overview' , 'module' => 'overview' , 'view' => 'overview' , 'record' => $record - ); + ]; return $app['twig']->render('overview.html.twig', $params); }; @@ -86,7 +86,7 @@ class Permalink extends AbstractDelivery } $response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); - $linkToCaption = $app->url("permalinks_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token)); + $linkToCaption = $app->url("permalinks_caption", ['sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token]); $response->headers->set('Link', $linkToCaption); return $response; @@ -108,7 +108,7 @@ class Permalink extends AbstractDelivery $response = $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app); - $linkToCaption = $app->url("permalinks_caption", array('sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token)); + $linkToCaption = $app->url("permalinks_caption", ['sbas_id' => $sbas_id, 'record_id' => $record_id, 'token' => $token]); $response->headers->set('Link', $linkToCaption); return $response; @@ -121,7 +121,7 @@ class Permalink extends AbstractDelivery $record = $retrieveRecord($app, $databox, $token, $record_id, \databox_subdef::CLASS_THUMBNAIL); $caption = $record->get_caption(); - return new Response($caption->serialize(\caption_record::SERIALIZE_JSON), 200, array("Content-Type" => 'application/json')); + return new Response($caption->serialize(\caption_record::SERIALIZE_JSON), 200, ["Content-Type" => 'application/json']); }) ->assert('sbas_id', '\d+')->assert('record_id', '\d+') ->bind('permalinks_caption'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php index 2d44f08bf8..ed931703de 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/BasketController.php @@ -111,10 +111,10 @@ class BasketController implements ControllerProviderInterface } } - $params = array( + $params = [ 'basket' => $basket, 'ordre' => $request->query->get('order') - ); + ]; return $app['twig']->render('prod/WorkZone/Basket.html.twig', $params); } @@ -152,17 +152,17 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); if ($request->getRequestFormat() === 'json') { - $data = array( + $data = [ 'success' => true , 'message' => _('Basket created') - , 'basket' => array( + , 'basket' => [ 'id' => $Basket->getId() - ) - ); + ] + ]; return $app->json($data); } else { - return $app->redirectPath('prod_baskets_basket', array('basket' => $Basket->getId())); + return $app->redirectPath('prod_baskets_basket', ['basket' => $Basket->getId()]); } } @@ -171,10 +171,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->remove($basket); $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => _('Basket has been deleted') - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -194,10 +194,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => _('Record removed from basket') - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -227,11 +227,11 @@ class BasketController implements ControllerProviderInterface $msg = _('An error occurred'); } - $data = array( + $data = [ 'success' => $success , 'message' => $msg - , 'basket' => array('id' => $basket->getId()) - ); + , 'basket' => ['id' => $basket->getId()] + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -242,17 +242,17 @@ class BasketController implements ControllerProviderInterface public function displayUpdateForm(Application $app, BasketEntity $basket) { - return $app['twig']->render('prod/Baskets/Update.html.twig', array('basket' => $basket)); + return $app['twig']->render('prod/Baskets/Update.html.twig', ['basket' => $basket]); } public function displayReorderForm(Application $app, BasketEntity $basket) { - return $app['twig']->render('prod/Baskets/Reorder.html.twig', array('basket' => $basket)); + return $app['twig']->render('prod/Baskets/Reorder.html.twig', ['basket' => $basket]); } public function reorder(Application $app, BasketEntity $basket) { - $ret = array('success' => false, 'message' => _('An error occured')); + $ret = ['success' => false, 'message' => _('An error occured')]; try { $order = $app['request']->request->get('element'); @@ -266,7 +266,7 @@ class BasketController implements ControllerProviderInterface } $app['EM']->flush(); - $ret = array('success' => true, 'message' => _('Basket updated')); + $ret = ['success' => true, 'message' => _('Basket updated')]; } catch (\Exception $e) { } @@ -289,11 +289,11 @@ class BasketController implements ControllerProviderInterface $message = _('Basket has been unarchived'); } - $data = array( + $data = [ 'success' => true , 'archive' => $archive_status , 'message' => $message - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -338,10 +338,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => sprintf(_('%d records added'), $n) - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); @@ -370,10 +370,10 @@ class BasketController implements ControllerProviderInterface $app['EM']->flush(); - $data = array( + $data = [ 'success' => true , 'message' => sprintf(_('%d records moved'), $n) - ); + ]; if ($request->getRequestFormat() === 'json') { return $app->json($data); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index f04a362d46..396d8108df 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -100,12 +100,12 @@ class Bridge implements ControllerProviderInterface public function doPostManager(Application $app, Request $request) { $route = new RecordHelper\Bridge($app, $request); - $params = array( + $params = [ 'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $app['authentication']->getUser()), 'available_apis' => \Bridge_Api::get_availables($app), 'route' => $route, 'current_account_id' => '', - ); + ]; return $app['twig']->render('prod/actions/Bridge/index.html.twig', $params); } @@ -147,7 +147,7 @@ class Bridge implements ControllerProviderInterface $error_message = $e->getMessage(); } - $params = array('error_message' => $error_message); + $params = ['error_message' => $error_message]; return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params); } @@ -158,10 +158,10 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); $account->get_api()->get_connector()->disconnect(); - return $app->redirectPath('bridge_load_elements', array( + return $app->redirectPath('bridge_load_elements', [ 'account_id' => $account_id, 'type' => $account->get_api()->get_connector()->get_default_element_type(), - )); + ]); } public function doPostAccountDelete(Application $app, Request $request, $account_id) @@ -183,7 +183,7 @@ class Bridge implements ControllerProviderInterface $message = _('Something went wrong, please contact an administrator'); } - return $app->json(array('success' => $success, 'message' => $message)); + return $app->json(['success' => $success, 'message' => $message]); } public function doGetloadRecords(Application $app, Request $request, $account_id) @@ -196,13 +196,13 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); - $params = array( + $params = [ 'adapter_action' => 'load-records' , 'account' => $account , 'elements' => $elements , 'error_message' => $request->query->get('error') , 'notice_message' => $request->query->get('notice') - ); + ]; return $app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params); } @@ -218,14 +218,14 @@ class Bridge implements ControllerProviderInterface $elements = $account->get_api()->list_elements($type, $offset_start, $quantity); - $params = array( + $params = [ 'action_type' => $type, 'adapter_action' => 'load-elements', 'account' => $account, 'elements' => $elements, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), - ); + ]; return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params); } @@ -240,14 +240,14 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); $elements = $account->get_api()->list_containers($type, $offset_start, $quantity); - $params = array( + $params = [ 'action_type' => $type, 'adapter_action' => 'load-containers', 'account' => $account, 'elements' => $elements, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), - ); + ]; return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params); } @@ -257,11 +257,11 @@ class Bridge implements ControllerProviderInterface $account = \Bridge_Account::load_account($app, $account_id); $this->requireConnection($app, $account); - $elements = $request->query->get('elements_list', array()); + $elements = $request->query->get('elements_list', []); $elements = is_array($elements) ? $elements : explode(';', $elements); $destination = $request->query->get('destination'); - $route_params = array(); + $route_params = []; $class = $account->get_api()->get_connector()->get_object_class_from_type($element_type); switch ($action) { @@ -270,25 +270,25 @@ class Bridge implements ControllerProviderInterface case 'modify': if (count($elements) != 1) { - return $app->redirectPath('bridge_load_elements', array( + return $app->redirectPath('bridge_load_elements', [ 'account_id' => $account_id, 'type' => $element_type, 'page' => '', 'error' => _('Vous ne pouvez pas editer plusieurs elements simultanement'), - )); + ]); } foreach ($elements as $element_id) { if ($class === \Bridge_Api_Interface::OBJECT_CLASS_ELEMENT) { - $route_params = array('element' => $account->get_api()->get_element_from_id($element_id, $element_type)); + $route_params = ['element' => $account->get_api()->get_element_from_id($element_id, $element_type)]; } if ($class === \Bridge_Api_Interface::OBJECT_CLASS_CONTAINER) { - $route_params = array('element' => $account->get_api()->get_container_from_id($element_id, $element_type)); + $route_params = ['element' => $account->get_api()->get_container_from_id($element_id, $element_type)]; } } break; case 'moveinto': - $route_params = array('containers' => $account->get_api()->list_containers($destination, 0, 0)); + $route_params = ['containers' => $account->get_api()->list_containers($destination, 0, 0)]; break; case 'deleteelement': @@ -299,7 +299,7 @@ class Bridge implements ControllerProviderInterface break; } - $params = array( + $params = [ 'account' => $account, 'destination' => $destination, 'element_type' => $element_type, @@ -309,7 +309,7 @@ class Bridge implements ControllerProviderInterface 'elements' => $elements, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), - ); + ]; $params = array_merge($params, $route_params); $template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig'; @@ -323,7 +323,7 @@ class Bridge implements ControllerProviderInterface $this->requireConnection($app, $account); - $elements = $request->request->get('elements_list', array()); + $elements = $request->request->get('elements_list', []); $elements = is_array($elements) ? $elements : explode(';', $elements); $destination = $request->request->get('destination'); @@ -342,7 +342,7 @@ class Bridge implements ControllerProviderInterface } if (count($errors) > 0) { - $params = array( + $params = [ 'element' => $account->get_api()->get_element_from_id($element_id, $element_type), 'account' => $account, 'destination' => $destination, @@ -353,7 +353,7 @@ class Bridge implements ControllerProviderInterface 'error_message' => _('Request contains invalid datas'), 'constraint_errors' => $errors, 'notice_message' => $request->request->get('notice'), - ); + ]; $template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig'; @@ -417,14 +417,14 @@ class Bridge implements ControllerProviderInterface $route->grep_records($account->get_api()->acceptable_records()); - $params = array( + $params = [ 'route' => $route, 'account' => $account, 'error_message' => $request->query->get('error'), 'notice_message' => $request->query->get('notice'), 'constraint_errors' => null, 'adapter_action' => 'upload', - ); + ]; return $app['twig']->render( 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params @@ -433,7 +433,7 @@ class Bridge implements ControllerProviderInterface public function doPostUpload(Application $app, Request $request) { - $errors = array(); + $errors = []; $account = \Bridge_Account::load_account($app, $request->request->get('account_id')); $this->requireConnection($app, $account); @@ -448,14 +448,14 @@ class Bridge implements ControllerProviderInterface } if (count($errors) > 0) { - $params = array( + $params = [ 'route' => $route, 'account' => $account, 'error_message' => _('Request contains invalid datas'), 'constraint_errors' => $errors, 'notice_message' => $request->request->get('notice'), 'adapter_action' => 'upload', - ); + ]; return $app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params); } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php b/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php index e16bed26d4..d01b1197d7 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/DoDownload.php @@ -63,7 +63,7 @@ class DoDownload implements ControllerProviderInterface $app->abort(500, 'Invalid datas'); } - $records = array(); + $records = []; foreach ($list['files'] as $file) { if (!is_array($file) || !isset($file['base_id']) || !isset($file['record_id'])) { @@ -81,14 +81,14 @@ class DoDownload implements ControllerProviderInterface } return new Response($app['twig']->render( - '/prod/actions/Download/prepare.html.twig', array( + '/prod/actions/Download/prepare.html.twig', [ 'module_name' => _('Export'), 'module' => _('Export'), 'list' => $list, 'records' => $records, 'token' => $token, 'anonymous' => $request->query->get('anonymous', false) - ))); + ])); } /** @@ -153,17 +153,17 @@ class DoDownload implements ControllerProviderInterface try { $datas = $app['tokens']->helloToken($token); } catch (NotFoundHttpException $e) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => 'Invalid token' - )); + ]); } if (false === $list = @unserialize((string) $datas['datas'])) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => 'Invalid datas' - )); + ]); } set_time_limit(0); @@ -178,9 +178,9 @@ class DoDownload implements ControllerProviderInterface sprintf($app['root.path'] . '/tmp/download/%s.zip', $datas['value']) // Dest file ); - return $app->json(array( + return $app->json([ 'success' => true, 'message' => '' - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Download.php b/lib/Alchemy/Phrasea/Controller/Prod/Download.php index 8f44b98a93..8006d6ecba 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Download.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Download.php @@ -48,7 +48,7 @@ class Download implements ControllerProviderInterface { $lst = $request->request->get('lst'); $ssttid = $request->request->get('ssttid', ''); - $subdefs = $request->request->get('obj', array()); + $subdefs = $request->request->get('obj', []); $download = new \set_export($app, $lst, $ssttid); @@ -77,14 +77,14 @@ class Download implements ControllerProviderInterface throw new \RuntimeException('Download token could not be generated'); } - $app['events-manager']->trigger('__DOWNLOAD__', array( + $app['events-manager']->trigger('__DOWNLOAD__', [ 'lst' => $lst, 'downloader' => $app['authentication']->getUser()->get_id(), 'subdefs' => $subdefs, 'from_basket' => $ssttid, 'export_file' => $download->getExportName() - )); + ]); - return $app->redirectPath('prepare_download', array('token' => $token)); + return $app->redirectPath('prepare_download', ['token' => $token]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php index bc54f51928..5be280301e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Edit.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Edit.php @@ -39,11 +39,11 @@ class Edit implements ControllerProviderInterface $controllers->post('/', function (Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, array('canmodifrecord')); + $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']); $thesaurus = false; $status = $ids = $elements = $suggValues = - $fields = $JSFields = array(); + $fields = $JSFields = []; $databox = null; $multipleDataboxes = count($records->databoxes()) > 1; @@ -60,12 +60,12 @@ class Edit implements ControllerProviderInterface $separator = $meta->get_separator(); - $JSFields[$meta->get_id()] = array( + $JSFields[$meta->get_id()] = [ 'meta_struct_id' => $meta->get_id() , 'name' => $meta->get_name() , '_status' => 0 , '_value' => '' - , '_sgval' => array() + , '_sgval' => [] , 'required' => $meta->is_required() , 'label' => $meta->get_label($app['locale.I18n']) , 'readonly' => $meta->is_readonly() @@ -79,7 +79,7 @@ class Edit implements ControllerProviderInterface , 'separator' => $separator , 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null , 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false - ); + ]; if (trim($meta->get_tbranch()) !== '') { $thesaurus = true; @@ -92,7 +92,7 @@ class Edit implements ControllerProviderInterface foreach ($records->collections() as $collection) { /* @var $record record_adapter */ - $suggValues['b' . $collection->get_base_id()] = array(); + $suggValues['b' . $collection->get_base_id()] = []; if ($sxe = simplexml_load_string($collection->get_prefs())) { $z = $sxe->xpath('/baseprefs/sugestedValues'); @@ -107,7 +107,7 @@ class Edit implements ControllerProviderInterface continue; } - $suggValues['b' . $collection->get_base_id()][$field->get_id()] = array(); + $suggValues['b' . $collection->get_base_id()][$field->get_id()] = []; foreach ($vi->value as $oneValue) { $suggValues['b' . $collection->get_base_id()][$field->get_id()][] = (string) $oneValue; @@ -124,7 +124,7 @@ class Edit implements ControllerProviderInterface $dbstatus = \databox_status::getDisplayStatus($app); if (isset($dbstatus[$databox->get_sbas_id()])) { foreach ($dbstatus[$databox->get_sbas_id()] as $n => $statbit) { - $status[$n] = array(); + $status[$n] = []; $status[$n]['label0'] = $statbit['labels_off_i18n'][$app['locale.I18n']]; $status[$n]['label1'] = $statbit['labels_on_i18n'][$app['locale.I18n']]; $status[$n]['img_off'] = $statbit['img_off']; @@ -138,24 +138,24 @@ class Edit implements ControllerProviderInterface * generate javascript elements */ foreach ($databox->get_meta_structure() as $field) { - $databox_fields[$field->get_id()] = array( + $databox_fields[$field->get_id()] = [ 'dirty' => false, 'meta_struct_id' => $field->get_id(), - 'values' => array() - ); + 'values' => [] + ]; } foreach ($records as $record) { $indice = $record->get_number(); - $elements[$indice] = array( + $elements[$indice] = [ 'bid' => $record->get_base_id(), 'rid' => $record->get_record_id(), 'sselcont_id' => null, '_selected' => false, 'fields' => $databox_fields - ); + ]; - $elements[$indice]['statbits'] = array(); + $elements[$indice]['statbits'] = []; if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'chgstatus')) { foreach ($status as $n => $s) { $tmp_val = substr(strrev($record->get_status()), $n, 1); @@ -172,7 +172,7 @@ class Edit implements ControllerProviderInterface continue; } - $values = array(); + $values = []; foreach ($field->get_values() as $value) { $type = $id = null; @@ -181,38 +181,38 @@ class Edit implements ControllerProviderInterface $id = $value->getVocabularyId(); } - $values[$value->getId()] = array( + $values[$value->getId()] = [ 'meta_id' => $value->getId(), 'value' => $value->getValue(), 'vocabularyId' => $id, 'vocabularyType' => $type - ); + ]; } - $elements[$indice]['fields'][$meta_struct_id] = array( + $elements[$indice]['fields'][$meta_struct_id] = [ 'dirty' => false, 'meta_struct_id' => $meta_struct_id, 'values' => $values - ); + ]; } - $elements[$indice]['subdefs'] = array(); + $elements[$indice]['subdefs'] = []; $thumbnail = $record->get_thumbnail(); - $elements[$indice]['subdefs']['thumbnail'] = array( + $elements[$indice]['subdefs']['thumbnail'] = [ 'url' => $thumbnail->get_url() , 'w' => $thumbnail->get_width() , 'h' => $thumbnail->get_height() - ); + ]; - $elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', array('record' => $record)); + $elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', ['record' => $record]); $elements[$indice]['type'] = $record->get_type(); } } - $params = array( + $params = [ 'multipleDataboxes' => $multipleDataboxes, 'recordsRequest' => $records, 'databox' => $databox, @@ -224,13 +224,13 @@ class Edit implements ControllerProviderInterface 'fields' => $fields, 'JSonSuggValues' => json_encode($suggValues), 'thesaurus' => $thesaurus, - ); + ]; return $app['twig']->render('prod/actions/edit_default.html.twig', $params); }); $controllers->get('/vocabulary/{vocabulary}/', function (Application $app, Request $request, $vocabulary) { - $datas = array('success' => false, 'message' => '', 'results' => array()); + $datas = ['success' => false, 'message' => '', 'results' => []]; $sbas_id = (int) $request->query->get('sbas_id'); @@ -251,15 +251,15 @@ class Edit implements ControllerProviderInterface $results = $VC->find($query, $app['authentication']->getUser(), $databox); - $list = array(); + $list = []; foreach ($results as $Term) { /* @var $Term \Alchemy\Phrasea\Vocabulary\Term */ - $list[] = array( + $list[] = [ 'id' => $Term->getId(), 'context' => $Term->getContext(), 'value' => $Term->getValue(), - ); + ]; } $datas['success'] = true; @@ -270,7 +270,7 @@ class Edit implements ControllerProviderInterface $controllers->post('/apply/', function (Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, array('canmodifrecord')); + $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']); if (count($records->databoxes()) !== 1) { throw new \Exception('Unable to edit on multiple databoxes'); @@ -289,7 +289,7 @@ class Edit implements ControllerProviderInterface } foreach ($newsubdef_reg->get_subdefs() as $name => $value) { - if (!in_array($name, array('thumbnail', 'preview'))) { + if (!in_array($name, ['thumbnail', 'preview'])) { continue; } $media = $app['mediavorus']->guess($value->get_pathfile()); @@ -307,7 +307,7 @@ class Edit implements ControllerProviderInterface } if (!is_array($request->request->get('mds'))) { - return $app->json(array('message' => '', 'error' => false)); + return $app->json(['message' => '', 'error' => false]); } $databoxes = $records->databoxes(); @@ -354,7 +354,7 @@ class Edit implements ControllerProviderInterface * todo : this should not work */ if ($write_edit_el instanceof \databox_field) { - $fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()), true); + $fields = $record->get_caption()->get_fields([$write_edit_el->get_name()], true); $field = array_pop($fields); $meta_id = null; @@ -364,21 +364,21 @@ class Edit implements ControllerProviderInterface $meta_id = array_pop($values)->getId(); } - $metas = array( - array( + $metas = [ + [ 'meta_struct_id' => $write_edit_el->get_id(), 'meta_id' => $meta_id, 'value' => $date_obj->format('Y-m-d h:i:s'), - ) - ); + ] + ]; $record->set_metadatas($metas, true); } $newstat = $record->get_status(); $statbits = ltrim($statbits, 'x'); - if (!in_array($statbits, array('', 'null'))) { - $mask_and = ltrim(str_replace(array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0'); + if (!in_array($statbits, ['', 'null'])) { + $mask_and = ltrim(str_replace(['x', '0', '1', 'z'], ['1', 'z', '0', '1'], $statbits), '0'); if ($mask_and != '') { $newstat = \databox_status::operation_and_not($app, $newstat, $mask_and); } @@ -407,7 +407,7 @@ class Edit implements ControllerProviderInterface } } - return $app->json(array('success' => true)); + return $app->json(['success' => true]); }); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index fccb4772b2..fa20e9cefe 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php @@ -67,13 +67,13 @@ class Export implements ControllerProviderInterface $request->request->get('story') ); - return new Response($app['twig']->render('common/dialog_export.html.twig', array( + return new Response($app['twig']->render('common/dialog_export.html.twig', [ 'download' => $download, 'ssttid' => $request->request->get('ssel'), 'lst' => $download->serialize_list(), 'default_export_title' => $app['phraseanet.registry']->get('GV_default_export_title'), 'choose_export_title' => $app['phraseanet.registry']->get('GV_choose_export_title') - ))); + ])); } /** @@ -100,10 +100,10 @@ class Export implements ControllerProviderInterface $msg = sprintf(_('Error while connecting to FTP')); } - return $app->json(array( + return $app->json([ 'success' => $success, 'message' => $msg - )); + ]); } /** @@ -116,7 +116,7 @@ class Export implements ControllerProviderInterface { $download = new \set_exportftp($app, $request->request->get('lst'), $request->request->get('ssttid')); - $mandatoryParameters = array('address', 'login', 'dest_folder', 'prefix_folder', 'obj'); + $mandatoryParameters = ['address', 'login', 'dest_folder', 'prefix_folder', 'obj']; foreach ($mandatoryParameters as $parameter) { if (!$request->request->get($parameter)) { @@ -125,10 +125,10 @@ class Export implements ControllerProviderInterface } if (count($download->get_display_ftp()) == 0) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => _("You do not have required rights to send these documents over FTP") - )); + ]); } try { @@ -153,15 +153,15 @@ class Export implements ControllerProviderInterface $request->request->get('logfile') ); - return $app->json(array( + return $app->json([ 'success' => true, 'message' => _('Export saved in the waiting queue') - )); + ]); } catch (\Exception $e) { - return $app->json(array( + return $app->json([ 'success' => false, 'message' => _('Something went wrong') - )); + ]); } } @@ -197,19 +197,19 @@ class Export implements ControllerProviderInterface $list['export_name'] = sprintf("%s.zip", $download->getExportName()); $list['email'] = implode(';', preg_split($separator, $request->request->get("destmail", ""))); - $destMails = array(); + $destMails = []; //get destination mails foreach (explode(";", $list['email']) as $mail) { if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { $destMails[] = $mail; } else { - $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( + $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ 'usr_id' => $app['authentication']->getUser()->get_id(), 'lst' => $lst, 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => \eventsmanager_notify_downloadmailfail::MAIL_NO_VALID - )); + ]); } } @@ -228,7 +228,7 @@ class Export implements ControllerProviderInterface $remaingEmails = $destMails; - $url = $app->url('prepare_download', array('token' => $token, 'anonymous')); + $url = $app->url('prepare_download', ['token' => $token, 'anonymous']); $emitter = new Emitter($app['authentication']->getUser()->get_display_name(), $app['authentication']->getUser()->get_email()); @@ -250,30 +250,30 @@ class Export implements ControllerProviderInterface //some mails failed if (count($remaingEmails) > 0) { foreach ($remaingEmails as $mail) { - $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( + $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ 'usr_id' => $app['authentication']->getUser()->get_id(), 'lst' => $lst, 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => \eventsmanager_notify_downloadmailfail::MAIL_FAIL - )); + ]); } } } elseif (!$token && count($destMails) > 0) { //couldn't generate token foreach ($destMails as $mail) { - $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( + $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [ 'usr_id' => $app['authentication']->getUser()->get_id(), 'lst' => $lst, 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => 0 - )); + ]); } } - return $app->json(array( + return $app->json([ 'success' => true, 'message' => '' - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index faf317714f..0dd3fb2b51 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -44,9 +44,9 @@ class Feed implements ControllerProviderInterface $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser( $app['acl']->get($app['authentication']->getUser()) ); - $publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub')); + $publishing = RecordsRequest::fromRequest($app, $request, true, [], ['bas_chupub']); - return $app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds)); + return $app['twig']->render('prod/actions/publish/publish.html.twig', ['publishing' => $publishing, 'feeds' => $feeds]); }); $controllers->post('/entry/create/', function (Application $app, Request $request) { @@ -56,7 +56,7 @@ class Feed implements ControllerProviderInterface $app->abort(404, "Feed not found"); } - $publisher = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedPublisher')->findOneBy(array('feed' => $feed, 'usrId' => $app['authentication']->getUser()->get_id())); + $publisher = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedPublisher')->findOneBy(['feed' => $feed, 'usrId' => $app['authentication']->getUser()->get_id()]); if ('' === $title = trim($request->request->get('title', ''))) { $app->abort(400, "Bad request"); @@ -76,7 +76,7 @@ class Feed implements ControllerProviderInterface $feed->addEntry($entry); - $publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub')); + $publishing = RecordsRequest::fromRequest($app, $request, true, [], ['bas_chupub']); foreach ($publishing as $record) { $item = new FeedItem(); $item->setEntry($entry) @@ -90,9 +90,9 @@ class Feed implements ControllerProviderInterface $app['EM']->persist($feed); $app['EM']->flush(); - $app['events-manager']->trigger('__FEED_ENTRY_CREATE__', array('entry_id' => $entry->getId(), 'notify_email' => (Boolean) $request->request->get('notify')), $entry); + $app['events-manager']->trigger('__FEED_ENTRY_CREATE__', ['entry_id' => $entry->getId(), 'notify_email' => (Boolean) $request->request->get('notify')], $entry); - $datas = array('error' => false, 'message' => false); + $datas = ['error' => false, 'message' => false]; return $app->json($datas); }) @@ -110,7 +110,7 @@ class Feed implements ControllerProviderInterface $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/actions/publish/publish_edit.html.twig', array('entry' => $entry, 'feeds' => $feeds)); + $datas = $app['twig']->render('prod/actions/publish/publish_edit.html.twig', ['entry' => $entry, 'feeds' => $feeds]); return new Response($datas); }) @@ -121,7 +121,7 @@ class Feed implements ControllerProviderInterface }); $controllers->post('/entry/{id}/update/', function (Application $app, Request $request, $id) { - $datas = array('error' => true, 'message' => '', 'datas' => ''); + $datas = ['error' => true, 'message' => '', 'datas' => '']; $entry = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedEntry')->find($id); if (null === $entry) { @@ -170,13 +170,13 @@ class Feed implements ControllerProviderInterface $app['EM']->persist($entry); $app['EM']->flush(); - return $app->json(array( + return $app->json([ 'error' => false, 'message' => 'succes', - 'datas' => $app['twig']->render('prod/feeds/entry.html.twig', array( + 'datas' => $app['twig']->render('prod/feeds/entry.html.twig', [ 'entry' => $entry - )) - )); + ]) + ]); }) ->bind('prod_feeds_entry_update') ->assert('id', '\d+')->before(function (Request $request) use ($app) { @@ -184,7 +184,7 @@ class Feed implements ControllerProviderInterface }); $controllers->post('/entry/{id}/delete/', function (Application $app, Request $request, $id) { - $datas = array('error' => true, 'message' => ''); + $datas = ['error' => true, 'message' => '']; $entry = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedEntry')->find($id); @@ -198,7 +198,7 @@ class Feed implements ControllerProviderInterface $app['EM']->remove($entry); $app['EM']->flush(); - return $app->json(array('error' => false, 'message' => 'succes')); + return $app->json(['error' => false, 'message' => 'succes']); }) ->bind('prod_feeds_entry_delete') ->assert('id', '\d+')->before(function (Request $request) use ($app) { @@ -212,11 +212,11 @@ class Feed implements ControllerProviderInterface $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/feeds/feeds.html.twig', array( + $datas = $app['twig']->render('prod/feeds/feeds.html.twig', [ 'feeds' => $feeds, 'feed' => new Aggregate($app['EM'], $feeds), 'page' => $page - )); + ]); return new Response($datas); })->bind('prod_feeds'); @@ -231,7 +231,7 @@ class Feed implements ControllerProviderInterface } $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/feeds/feeds.html.twig', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page)); + $datas = $app['twig']->render('prod/feeds/feeds.html.twig', ['feed' => $feed, 'feeds' => $feeds, 'page' => $page]); return new Response($datas); }) @@ -249,12 +249,12 @@ class Feed implements ControllerProviderInterface null, $renew ); - $output = array( + $output = [ 'texte' => '

' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') . '

' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '

', 'titre' => _('publications::votre rss personnel') - ); + ]; return $app->json($output); })->bind('prod_feeds_subscribe_aggregated'); @@ -268,12 +268,12 @@ class Feed implements ControllerProviderInterface } $link = $app['feed.user-link-generator']->generate($feed, $app['authentication']->getUser(), FeedLinkGenerator::FORMAT_RSS, null, $renew); - $output = array( + $output = [ 'texte' => '

' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.') . '

' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '

', 'titre' => _('publications::votre rss personnel') - ); + ]; return $app->json($output); }) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Language.php b/lib/Alchemy/Phrasea/Controller/Prod/Language.php index ea50197e9d..5ff3b4d10f 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Language.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Language.php @@ -29,7 +29,7 @@ class Language implements ControllerProviderInterface $controller->get("/", function (Application $app) { - $out = array(); + $out = []; $out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.'); $out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?'); $out['serverError'] = _('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique'); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php index b4bcf78643..2e44ab203d 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Lazaret.php @@ -87,7 +87,7 @@ class Lazaret implements ControllerProviderInterface */ public function listElement(Application $app, Request $request) { - $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('canaddrecord'))); + $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canaddrecord'])); $lazaretFiles = null; @@ -100,7 +100,7 @@ class Lazaret implements ControllerProviderInterface } return $app['twig']->render( - 'prod/upload/lazaret.html.twig', array('lazaretFiles' => $lazaretFiles) + 'prod/upload/lazaret.html.twig', ['lazaretFiles' => $lazaretFiles] ); } @@ -115,7 +115,7 @@ class Lazaret implements ControllerProviderInterface */ public function getElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; $lazaretFile = $app['EM']->find('Alchemy\Phrasea\Model\Entities\LazaretFile', $file_id); @@ -126,7 +126,7 @@ class Lazaret implements ControllerProviderInterface return $app->json($ret); } - $file = array( + $file = [ 'filename' => $lazaretFile->getOriginalName(), 'base_id' => $lazaretFile->getBaseId(), 'created' => $lazaretFile->getCreated()->format(\DateTime::ATOM), @@ -134,7 +134,7 @@ class Lazaret implements ControllerProviderInterface 'pathname' => $app['root.path'] . '/tmp/lazaret/' . $lazaretFile->getFilename(), 'sha256' => $lazaretFile->getSha256(), 'uuid' => $lazaretFile->getUuid(), - ); + ]; $ret['result'] = $file; $ret['success'] = true; @@ -157,11 +157,11 @@ class Lazaret implements ControllerProviderInterface */ public function addElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; //Optional parameter $keepAttributes = !!$request->request->get('keep_attributes', false); - $attributesToKeep = $request->request->get('attributes', array()); + $attributesToKeep = $request->request->get('attributes', []); //Mandatory parameter if (null === $request->request->get('bas_id')) { @@ -258,7 +258,7 @@ class Lazaret implements ControllerProviderInterface } try { - $app['filesystem']->remove(array($lazaretFileName, $lazaretThumbFileName)); + $app['filesystem']->remove([$lazaretFileName, $lazaretThumbFileName]); } catch (IOException $e) { } @@ -277,7 +277,7 @@ class Lazaret implements ControllerProviderInterface */ public function denyElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; $lazaretFile = $app['EM']->find('Alchemy\Phrasea\Model\Entities\LazaretFile', $file_id); /* @var $lazaretFile LazaretFile */ @@ -306,7 +306,7 @@ class Lazaret implements ControllerProviderInterface $app['EM']->flush(); try { - $app['filesystem']->remove(array($lazaretFileName, $lazaretThumbFileName)); + $app['filesystem']->remove([$lazaretFileName, $lazaretThumbFileName]); } catch (IOException $e) { } @@ -324,7 +324,7 @@ class Lazaret implements ControllerProviderInterface */ public function emptyLazaret(Application $app, Request $request) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; $lazaretFiles = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\LazaretFile')->findAll(); @@ -355,7 +355,7 @@ class Lazaret implements ControllerProviderInterface */ public function acceptElement(Application $app, Request $request, $file_id) { - $ret = array('success' => false, 'message' => '', 'result' => array()); + $ret = ['success' => false, 'message' => '', 'result' => []]; //Mandatory parameter if (null === $recordId = $request->request->get('record_id')) { @@ -416,7 +416,7 @@ class Lazaret implements ControllerProviderInterface } try { - $app['filesystem']->remove(array($lazaretFileName, $lazaretThumbFileName)); + $app['filesystem']->remove([$lazaretFileName, $lazaretThumbFileName]); } catch (IOException $e) { } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php index 683fb75e92..507d125bc0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/MoveCollection.php @@ -46,32 +46,32 @@ class MoveCollection implements ControllerProviderInterface public function displayForm(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, false, array('candeleterecord')); + $records = RecordsRequest::fromRequest($app, $request, false, ['candeleterecord']); $sbas_ids = array_map(function (\databox $databox) { return $databox->get_sbas_id(); }, $records->databoxes()); $collections = $app['acl']->get($app['authentication']->getUser()) - ->get_granted_base(array('canaddrecord'), $sbas_ids); + ->get_granted_base(['canaddrecord'], $sbas_ids); - $parameters = array( + $parameters = [ 'records' => $records, 'message' => '', 'collections' => $collections, - ); + ]; return $app['twig']->render('prod/actions/collection_default.html.twig', $parameters); } public function apply(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, false, array('candeleterecord')); + $records = RecordsRequest::fromRequest($app, $request, false, ['candeleterecord']); - $datas = array( + $datas = [ 'success' => false, 'message' => '', - ); + ]; try { if (null === $request->request->get('base_id')) { @@ -106,15 +106,15 @@ class MoveCollection implements ControllerProviderInterface } } - $ret = array( + $ret = [ 'success' => true, 'message' => _('Records have been successfuly moved'), - ); + ]; } catch (\Exception $e) { - $ret = array( + $ret = [ 'success' => false, 'message' => _('An error occured'), - ); + ]; } return $app->json($ret); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Order.php b/lib/Alchemy/Phrasea/Controller/Prod/Order.php index 917992ffc5..0ca4ef6fac 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Order.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Order.php @@ -91,10 +91,10 @@ class Order implements ControllerProviderInterface { $success = false; $collectionHasOrderAdmins = new ArrayCollection(); - $toRemove = array(); + $toRemove = []; - $records = RecordsRequest::fromRequest($app, $request, true, array('cancmd')); - $hasOneAdmin = array(); + $records = RecordsRequest::fromRequest($app, $request, true, ['cancmd']); + $hasOneAdmin = []; if (!$records->isEmpty()) { $order = new OrderEntity(); @@ -110,8 +110,8 @@ class Order implements ControllerProviderInterface if (!isset($hasOneAdmin[$record->get_base_id()])) { $query = new \User_Query($app); - $hasOneAdmin[$record->get_base_id()] = (Boolean) count($query->on_base_ids(array($record->get_base_id())) - ->who_have_right(array('order_master')) + $hasOneAdmin[$record->get_base_id()] = (Boolean) count($query->on_base_ids([$record->get_base_id()]) + ->who_have_right(['order_master']) ->execute()->get_results()); } @@ -146,10 +146,10 @@ class Order implements ControllerProviderInterface $order->setTodo($order->getElements()->count()); try { - $app['events-manager']->trigger('__NEW_ORDER__', array( + $app['events-manager']->trigger('__NEW_ORDER__', [ 'order_id' => $order->getId(), 'usr_id' => $order->getUsrId() - )); + ]); $success = true; $app['EM']->persist($order); @@ -168,16 +168,16 @@ class Order implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $msg, - )); + ]); } - return $app->redirectPath('prod_orders', array( + return $app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send' - )); + ]); } /** @@ -195,19 +195,19 @@ class Order implements ControllerProviderInterface $perPage = (int) $request->query->get('per-page', 10); $sort = $request->query->get('sort'); - $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('order_master'))); + $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['order_master'])); $ordersList = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->listOrders($baseIds, $offsetStart, $perPage, $sort); $total = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Order')->countTotalOrders($baseIds); - return $app['twig']->render('prod/orders/order_box.html.twig', array( + return $app['twig']->render('prod/orders/order_box.html.twig', [ 'page' => $page, 'perPage' => $perPage, 'total' => $total, 'previousPage' => $page < 2 ? false : ($page - 1), 'nextPage' => $page >= ceil($total / $perPage) ? false : $page + 1, 'orders' => new ArrayCollection($ordersList) - )); + ]); } /** @@ -225,9 +225,9 @@ class Order implements ControllerProviderInterface throw new NotFoundHttpException('Order not found'); } - return $app['twig']->render('prod/orders/order_item.html.twig', array( + return $app['twig']->render('prod/orders/order_item.html.twig', [ 'order' => $order - )); + ]); } /** @@ -261,7 +261,7 @@ class Order implements ControllerProviderInterface } $n = 0; - $elements = $request->request->get('elements', array()); + $elements = $request->request->get('elements', []); foreach ($order->getElements() as $orderElement) { if (in_array($orderElement->getId(), $elements)) { $sbas_id = \phrasea::sbasFromBas($app, $orderElement->getBaseId()); @@ -286,12 +286,12 @@ class Order implements ControllerProviderInterface if ($n > 0) { $order->setTodo($order->getTodo() - $n); - $app['events-manager']->trigger('__ORDER_DELIVER__', array( + $app['events-manager']->trigger('__ORDER_DELIVER__', [ 'ssel_id' => $order->getBasket()->getId(), 'from' => $app['authentication']->getUser()->get_id(), 'to' => $dest_user->get_id(), 'n' => $n - )); + ]); } $success = true; @@ -304,17 +304,17 @@ class Order implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Order has been sent') : _('An error occured while sending, please retry or contact an admin if problem persists'), 'order_id' => $order_id - )); + ]); } - return $app->redirectPath('prod_orders', array( + return $app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send' - )); + ]); } /** @@ -334,7 +334,7 @@ class Order implements ControllerProviderInterface } $n = 0; - $elements = $request->request->get('elements', array()); + $elements = $request->request->get('elements', []); foreach ($order->getElements() as $orderElement) { if (in_array($orderElement->getId(),$elements)) { $orderElement->setOrderMasterId($app['authentication']->getUser()->get_id()); @@ -349,11 +349,11 @@ class Order implements ControllerProviderInterface if ($n > 0) { $order->setTodo($order->getTodo() - $n); - $app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', array( + $app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', [ 'from' => $app['authentication']->getUser()->get_id(), 'to' => $order->getUsrId(), 'n' => $n - )); + ]); } $success = true; @@ -364,16 +364,16 @@ class Order implements ControllerProviderInterface } if ('json' === $app['request']->getRequestFormat()) { - return $app->json(array( + return $app->json([ 'success' => $success, 'msg' => $success ? _('Order has been denied') : _('An error occured while denying, please retry or contact an admin if problem persists'), 'order_id' => $order_id - )); + ]); } - return $app->redirectPath('prod_orders', array( + return $app->redirectPath('prod_orders', [ 'success' => (int) $success, 'action' => 'send' - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php index c9f1e96213..269b2532b4 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Printer.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Printer.php @@ -33,7 +33,7 @@ class Printer implements ControllerProviderInterface $controllers->post('/', function (Application $app) { $printer = new RecordHelper\Printer($app, $app['request']); - return $app['twig']->render('prod/actions/printer_default.html.twig', array('printer' => $printer, 'message' => '')); + return $app['twig']->render('prod/actions/printer_default.html.twig', ['printer' => $printer, 'message' => '']); } ); @@ -50,7 +50,7 @@ class Printer implements ControllerProviderInterface } $PDF = new PDFExport($app, $printer->get_elements(), $layout); - $response = new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf')); + $response = new Response($PDF->render(), 200, ['Content-Type' => 'application/pdf']); $response->headers->set('Pragma', 'public', true); $response->setMaxAge(0); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Property.php b/lib/Alchemy/Phrasea/Controller/Prod/Property.php index 96f581c5d8..bd0cb4419e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Property.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Property.php @@ -61,16 +61,16 @@ class Property implements ControllerProviderInterface $app->abort(400); } - $records = RecordsRequest::fromRequest($app, $request, false, array('chgstatus')); + $records = RecordsRequest::fromRequest($app, $request, false, ['chgstatus']); $databoxStatus = \databox_status::getDisplayStatus($app); - $statusBit = $nRec = array(); + $statusBit = $nRec = []; foreach ($records as $record) { //perform logic $sbasId = $record->get_databox()->get_sbas_id(); if (!isset($nRec[$sbasId])) { - $nRec[$sbasId] = array('stories' => 0, 'records' => 0); + $nRec[$sbasId] = ['stories' => 0, 'records' => 0]; } $nRec[$sbasId]['records']++; @@ -80,7 +80,7 @@ class Property implements ControllerProviderInterface } if (!isset($statusBit[$sbasId])) { - $statusBit[$sbasId] = isset($databoxStatus[$sbasId]) ? $databoxStatus[$sbasId] : array(); + $statusBit[$sbasId] = isset($databoxStatus[$sbasId]) ? $databoxStatus[$sbasId] : []; foreach (array_keys($statusBit[$sbasId]) as $bit) { $statusBit[$sbasId][$bit]['nset'] = 0; @@ -101,11 +101,11 @@ class Property implements ControllerProviderInterface } } - return new Response($app['twig']->render('prod/actions/Property/index.html.twig', array( + return new Response($app['twig']->render('prod/actions/Property/index.html.twig', [ 'records' => $records, 'statusBit' => $statusBit, 'nRec' => $nRec - ))); + ])); } /** @@ -121,29 +121,29 @@ class Property implements ControllerProviderInterface $app->abort(400); } - $records = RecordsRequest::fromRequest($app, $request, false, array('canmodifrecord')); + $records = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']); - $recordsType = array(); + $recordsType = []; foreach ($records as $record) { //perform logic $sbasId = $record->get_databox()->get_sbas_id(); if (!isset($recordsType[$sbasId])) { - $recordsType[$sbasId] = array(); + $recordsType[$sbasId] = []; } if (!isset($recordsType[$sbasId][$record->get_type()])) { - $recordsType[$sbasId][$record->get_type()] = array(); + $recordsType[$sbasId][$record->get_type()] = []; } $recordsType[$sbasId][$record->get_type()][] = $record; } - return new Response($app['twig']->render('prod/actions/Property/type.html.twig', array( + return new Response($app['twig']->render('prod/actions/Property/type.html.twig', [ 'records' => $records, 'recordsType' => $recordsType, - ))); + ])); } /** @@ -155,9 +155,9 @@ class Property implements ControllerProviderInterface */ public function changeStatus(Application $app, Request $request) { - $applyStatusToChildren = $request->request->get('apply_to_children', array()); - $records = RecordsRequest::fromRequest($app, $request, false, array('chgstatus')); - $updated = array(); + $applyStatusToChildren = $request->request->get('apply_to_children', []); + $records = RecordsRequest::fromRequest($app, $request, false, ['chgstatus']); + $updated = []; $postStatus = (array) $request->request->get('status'); foreach ($records as $record) { @@ -178,7 +178,7 @@ class Property implements ControllerProviderInterface } } - return $app->json(array('success' => true, 'updated' => $updated), 201); + return $app->json(['success' => true, 'updated' => $updated], 201); } /** @@ -190,10 +190,10 @@ class Property implements ControllerProviderInterface */ public function changeType(Application $app, Request $request) { - $typeLst = $request->request->get('types', array()); - $records = RecordsRequest::fromRequest($app, $request, false, array('canmodifrecord')); + $typeLst = $request->request->get('types', []); + $records = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']); $forceType = $request->request->get('force_types', ''); - $updated = array(); + $updated = []; foreach ($records as $record) { try { @@ -208,7 +208,7 @@ class Property implements ControllerProviderInterface } } - return $app->json(array('success' => true, 'updated' => $updated), 201); + return $app->json(['success' => true, 'updated' => $updated], 201); } /** @@ -233,10 +233,10 @@ class Property implements ControllerProviderInterface $record->set_binary_status(strrev($newStatus)); - return array( + return [ 'current_status' => $currentStatus, 'new_status' => $newStatus - ); + ]; } return null; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php index bbc3690555..98ec635cc3 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php @@ -36,9 +36,9 @@ class Push implements ControllerProviderInterface protected function getUserFormatter() { return function (\User_Adapter $user) { - $subtitle = array_filter(array($user->get_job(), $user->get_company())); + $subtitle = array_filter([$user->get_job(), $user->get_company()]); - return array( + return [ 'type' => 'USER' , 'usr_id' => $user->get_id() , 'firstname' => $user->get_firstname() @@ -46,7 +46,7 @@ class Push implements ControllerProviderInterface , 'email' => $user->get_email() , 'display_name' => $user->get_display_name() , 'subtitle' => implode(', ', $subtitle) - ); + ]; }; } @@ -55,23 +55,23 @@ class Push implements ControllerProviderInterface $userFormatter = $this->getUserFormatter(); return function (UsrList $List) use ($userFormatter, $app) { - $entries = array(); + $entries = []; foreach ($List->getEntries() as $entry) { /* @var $entry UsrListEntry */ - $entries[] = array( + $entries[] = [ 'Id' => $entry->getId(), 'User' => $userFormatter($entry->getUser($app)) - ); + ]; } - return array( + return [ 'type' => 'LIST' , 'list_id' => $List->getId() , 'name' => $List->getName() , 'length' => count($entries) , 'entries' => $entries - ); + ]; }; } @@ -125,13 +125,13 @@ class Push implements ControllerProviderInterface $RecommendedUsers = $userSelection($push->get_elements()); - $params = array( + $params = [ 'push' => $push, 'message' => '', 'lists' => $repository->findUserLists($app['authentication']->getUser()), 'context' => 'Push', 'RecommendedUsers' => $RecommendedUsers - ); + ]; return $app['twig']->render('prod/actions/Push.html.twig', $params); }); @@ -143,13 +143,13 @@ class Push implements ControllerProviderInterface $RecommendedUsers = $userSelection($push->get_elements()); - $params = array( + $params = [ 'push' => $push, 'message' => '', 'lists' => $repository->findUserLists($app['authentication']->getUser()), 'context' => 'Feedback', 'RecommendedUsers' => $RecommendedUsers - ); + ]; return $app['twig']->render('prod/actions/Push.html.twig', $params); }); @@ -157,10 +157,10 @@ class Push implements ControllerProviderInterface $controllers->post('/send/', function (Application $app) { $request = $app['request']; - $ret = array( + $ret = [ 'success' => false, 'message' => _('Unable to send the documents') - ); + ]; try { $pusher = new RecordHelper\Push($app, $app['request']); @@ -220,7 +220,7 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $url = $app->url('lightbox_compare', array( + $url = $app->url('lightbox_compare', [ 'basket' => $Basket->getId(), 'LOG' => $app['tokens']->getUrlToken( \random::TYPE_VIEW, @@ -228,11 +228,11 @@ class Push implements ControllerProviderInterface null, $Basket->getId() ) - )); + ]); $receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : ''; - $params = array( + $params = [ 'from' => $app['authentication']->getUser()->get_id() , 'from_email' => $app['authentication']->getUser()->get_email() , 'to' => $user_receiver->get_id() @@ -242,7 +242,7 @@ class Push implements ControllerProviderInterface , 'accuse' => $receipt , 'message' => $request->request->get('message') , 'ssel_id' => $Basket->getId() - ); + ]; $app['events-manager']->trigger('__PUSH_DATAS__', $params); } @@ -258,10 +258,10 @@ class Push implements ControllerProviderInterface , count($receivers) ); - $ret = array( + $ret = [ 'success' => true, 'message' => $message - ); + ]; } catch (ControllerException $e) { $ret['message'] = $e->getMessage() . $e->getFile() . $e->getLine(); } @@ -272,10 +272,10 @@ class Push implements ControllerProviderInterface $controllers->post('/validate/', function (Application $app) { $request = $app['request']; - $ret = array( + $ret = [ 'success' => false, 'message' => _('Unable to send the documents') - ); + ]; $app['EM']->beginTransaction(); @@ -349,16 +349,16 @@ class Push implements ControllerProviderInterface } if (!$found) { - $participants[$app['authentication']->getUser()->get_id()] = array( + $participants[$app['authentication']->getUser()->get_id()] = [ 'see_others' => 1, 'usr_id' => $app['authentication']->getUser()->get_id(), 'agree' => 0, 'HD' => 0 - ); + ]; } foreach ($participants as $key => $participant) { - foreach (array('see_others', 'usr_id', 'agree', 'HD') as $mandatoryparam) { + foreach (['see_others', 'usr_id', 'agree', 'HD'] as $mandatoryparam) { if (!array_key_exists($mandatoryparam, $participant)) throw new ControllerException(sprintf(_('Missing mandatory parameter %s'), $mandatoryparam)); } @@ -418,7 +418,7 @@ class Push implements ControllerProviderInterface $app['EM']->flush(); - $url = $app->url('lightbox_validation', array( + $url = $app->url('lightbox_validation', [ 'basket' => $Basket->getId(), 'LOG' => $app['tokens']->getUrlToken( \random::TYPE_VALIDATE, @@ -426,11 +426,11 @@ class Push implements ControllerProviderInterface null, $Basket->getId() ) - )); + ]); $receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : ''; - $params = array( + $params = [ 'from' => $app['authentication']->getUser()->get_id(), 'from_email' => $app['authentication']->getUser()->get_email(), 'to' => $participant_user->get_id(), @@ -441,7 +441,7 @@ class Push implements ControllerProviderInterface 'message' => $request->request->get('message'), 'ssel_id' => $Basket->getId(), 'duration' => (int) $request->request->get('duration'), - ); + ]; $app['events-manager']->trigger('__PUSH_VALIDATION__', $params); } @@ -457,10 +457,10 @@ class Push implements ControllerProviderInterface , count($request->request->get('participants')) ); - $ret = array( + $ret = [ 'success' => true, 'message' => $message - ); + ]; $app['EM']->commit(); } catch (ControllerException $e) { @@ -478,9 +478,9 @@ class Push implements ControllerProviderInterface $query = new \User_Query($app); - $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canpush')); + $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); - $query->in(array($usr_id)); + $query->in([$usr_id]); $result = $query->include_phantoms() ->limit(0, 1) @@ -512,7 +512,7 @@ class Push implements ControllerProviderInterface ->assert('list_id', '\d+'); $controllers->post('/add-user/', function (Application $app, Request $request) use ($userFormatter) { - $result = array('success' => false, 'message' => '', 'user' => null); + $result = ['success' => false, 'message' => '', 'user' => null]; try { if (!$app['acl']->get($app['authentication']->getUser())->has_right('manageusers')) @@ -577,7 +577,7 @@ class Push implements ControllerProviderInterface })->bind('prod_push_do_add_user'); $controllers->get('/add-user/', function (Application $app, Request $request) { - $params = array('callback' => $request->query->get('callback')); + $params = ['callback' => $request->query->get('callback')]; return $app['twig']->render('prod/User/Add.html.twig', $params); })->bind('prod_push_add_user'); @@ -587,7 +587,7 @@ class Push implements ControllerProviderInterface $query = new \User_Query($app); - $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canpush')); + $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); $query->like(\User_Query::LIKE_FIRSTNAME, $request->query->get('query')) ->like(\User_Query::LIKE_LASTNAME, $request->query->get('query')) @@ -602,7 +602,7 @@ class Push implements ControllerProviderInterface $lists = $repository->findUserListLike($app['authentication']->getUser(), $request->query->get('query')); - $datas = array(); + $datas = []; if ($lists) { foreach ($lists as $list) { @@ -627,7 +627,7 @@ class Push implements ControllerProviderInterface $query = new \User_Query($app); - $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), array('canpush')); + $query->on_bases_where_i_am($app['acl']->get($app['authentication']->getUser()), ['canpush']); if ($request->get('query')) { $query->like($request->get('like_field'), $request->get('query')) @@ -661,13 +661,13 @@ class Push implements ControllerProviderInterface ->limit($offset_start, $perPage) ->execute()->get_results(); - $params = array( + $params = [ 'query' => $query , 'results' => $results , 'list' => $list , 'sort' => $sort , 'ord' => $ord - ); + ]; if ($request->get('type') === 'fragment') { return new Response( diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index 437e7efcd8..113f3036bd 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -61,7 +61,7 @@ class Query implements ControllerProviderInterface $mod = $app['authentication']->getUser()->getPrefs('view'); - $json = array(); + $json = []; $options = SearchEngineOptions::fromRequest($app, $request); @@ -196,12 +196,12 @@ class Query implements ControllerProviderInterface } } - $json['results'] = $app['twig']->render($template, array( + $json['results'] = $app['twig']->render($template, [ 'results' => $result, 'highlight' => $result->getQuery(), 'searchEngine' => $app['phraseanet.SE'], 'suggestions' => $prop - ) + ] ); $json['query'] = $query; @@ -239,12 +239,12 @@ class Query implements ControllerProviderInterface $record = new \record_preview($app, 'RESULT', $pos, '', $app['phraseanet.SE'], $query); - return $app->json(array( - 'current' => $app['twig']->render('prod/preview/result_train.html.twig', array( + return $app->json([ + 'current' => $app['twig']->render('prod/preview/result_train.html.twig', [ 'records' => $record->get_train($pos, $query, $app['phraseanet.SE']), 'selected' => $pos - )) - )); + ]) + ]); } /** @@ -258,9 +258,9 @@ class Query implements ControllerProviderInterface { $record = new \record_preview($app, 'REG', $request->request->get('pos'), $request->request->get('cont')); - return new Response($app['twig']->render('prod/preview/reg_train.html.twig', array( + return new Response($app['twig']->render('prod/preview/reg_train.html.twig', [ 'container_records' => $record->get_container()->get_children(), 'record' => $record - ))); + ])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Records.php b/lib/Alchemy/Phrasea/Controller/Prod/Records.php index 6a9551fb16..ce8309f590 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Records.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Records.php @@ -96,48 +96,48 @@ class Records implements ControllerProviderInterface if ($record->is_from_reg()) { $train = $app['twig']->render('prod/preview/reg_train.html.twig', - array('record' => $record) + ['record' => $record] ); } if ($record->is_from_basket() && $reloadTrain) { $train = $app['twig']->render('prod/preview/basket_train.html.twig', - array('record' => $record) + ['record' => $record] ); } if ($record->is_from_feed()) { $train = $app['twig']->render('prod/preview/feed_train.html.twig', - array('record' => $record) + ['record' => $record] ); } - return $app->json(array( - "desc" => $app['twig']->render('prod/preview/caption.html.twig', array( + return $app->json([ + "desc" => $app['twig']->render('prod/preview/caption.html.twig', [ 'record' => $record, 'highlight' => $query, 'searchEngine' => $searchEngine - )), - "html_preview" => $app['twig']->render('common/preview.html.twig', array( + ]), + "html_preview" => $app['twig']->render('common/preview.html.twig', [ 'record' => $record - )), - "others" => $app['twig']->render('prod/preview/appears_in.html.twig', array( + ]), + "others" => $app['twig']->render('prod/preview/appears_in.html.twig', [ 'parents' => $record->get_grouping_parents(), 'baskets' => $record->get_container_baskets($app['EM'], $app['authentication']->getUser()) - )), + ]), "current" => $train, - "history" => $app['twig']->render('prod/preview/short_history.html.twig', array( + "history" => $app['twig']->render('prod/preview/short_history.html.twig', [ 'record' => $record - )), - "popularity" => $app['twig']->render('prod/preview/popularity.html.twig', array( + ]), + "popularity" => $app['twig']->render('prod/preview/popularity.html.twig', [ 'record' => $record - )), - "tools" => $app['twig']->render('prod/preview/tools.html.twig', array( + ]), + "tools" => $app['twig']->render('prod/preview/tools.html.twig', [ 'record' => $record - )), + ]), "pos" => $record->get_number(), "title" => $record->get_title($query, $searchEngine) - )); + ]); } /** @@ -149,14 +149,14 @@ class Records implements ControllerProviderInterface */ public function doDeleteRecords(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), array( + $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), [ 'candeleterecord' - )); + ]); $basketElementsRepository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\BasketElement'); $StoryWZRepository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\StoryWZ'); - $deleted = array(); + $deleted = []; foreach ($records as $record) { try { @@ -194,13 +194,13 @@ class Records implements ControllerProviderInterface */ public function whatCanIDelete(Application $app, Request $request) { - $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), array( + $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('del_children'), [ 'candeleterecord' - )); + ]); - return $app['twig']->render('prod/actions/delete_records_confirm.html.twig', array( + return $app['twig']->render('prod/actions/delete_records_confirm.html.twig', [ 'records' => $records - )); + ]); } /** @@ -215,7 +215,7 @@ class Records implements ControllerProviderInterface { $records = RecordsRequest::fromRequest($app, $request, !!$request->request->get('renew_children_url')); - $renewed = array(); + $renewed = []; foreach ($records as $record) { $renewed[$record->get_serialize_key()] = $record->get_preview()->renew_url(); }; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php index 512fe9018d..dd310cb6b3 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php @@ -50,7 +50,7 @@ class Root implements ControllerProviderInterface $cssPath = $app['root.path'] . '/www/skins/prod/'; - $css = array(); + $css = []; $cssfile = false; $finder = new Finder(); @@ -87,25 +87,25 @@ class Root implements ControllerProviderInterface $queries_topics = \queries::tree_topics($app['locale.I18n']); } - $sbas = $bas2sbas = array(); + $sbas = $bas2sbas = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { $sbas_id = $databox->get_sbas_id(); - $sbas['s' + $sbas_id] = array( + $sbas['s' + $sbas_id] = [ 'sbid' => $sbas_id, - 'seeker' => null); + 'seeker' => null]; foreach ($databox->get_collections() as $coll) { - $bas2sbas['b' . $coll->get_base_id()] = array( + $bas2sbas['b' . $coll->get_base_id()] = [ 'sbid' => $sbas_id, - 'ckobj' => array('checked' => false), + 'ckobj' => ['checked' => false], 'waschecked' => false - ); + ]; } } - return $app['twig']->render('prod/index.html.twig', array( + return $app['twig']->render('prod/index.html.twig', [ 'module_name' => 'Production', 'WorkZone' => new Helper\WorkZone($app, $app['request']), 'module_prod' => new Helper\Prod($app, $app['request']), @@ -127,7 +127,7 @@ class Root implements ControllerProviderInterface 'thesau_json_sbas' => json_encode($sbas), 'thesau_json_bas2sbas' => json_encode($bas2sbas), 'thesau_languages' => $app['locales.available'], - )); + ]); })->bind('prod'); return $controllers; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Share.php b/lib/Alchemy/Phrasea/Controller/Prod/Share.php index 1748c10e97..1aa55942a6 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Share.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Share.php @@ -57,8 +57,8 @@ class Share implements ControllerProviderInterface $app->abort(403); } - return new Response($app['twig']->render('prod/Share/record.html.twig', array( + return new Response($app['twig']->render('prod/Share/record.html.twig', [ 'record' => $record, - ))); + ])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Story.php b/lib/Alchemy/Phrasea/Controller/Prod/Story.php index 5d09f80222..c8215f74cb 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Story.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Story.php @@ -38,7 +38,7 @@ class Story implements ControllerProviderInterface }); $controllers->get('/create/', function (Application $app) { - return $app['twig']->render('prod/Story/Create.html.twig', array()); + return $app['twig']->render('prod/Story/Create.html.twig', []); })->bind('prod_stories_create'); $controllers->post('/', function (Application $app, Request $request) { @@ -61,7 +61,7 @@ class Story implements ControllerProviderInterface $Story->appendChild($record); } - $metadatas = array(); + $metadatas = []; foreach ($collection->get_databox()->get_meta_structure() as $meta) { if ($meta->get_thumbtitle()) { @@ -70,11 +70,11 @@ class Story implements ControllerProviderInterface continue; } - $metadatas[] = array( + $metadatas[] = [ 'meta_struct_id' => $meta->get_id() , 'meta_id' => null , 'value' => $value - ); + ]; break; } @@ -90,29 +90,29 @@ class Story implements ControllerProviderInterface $app['EM']->flush(); if ($request->getRequestFormat() == 'json') { - $data = array( + $data = [ 'success' => true , 'message' => _('Story created') , 'WorkZone' => $StoryWZ->getId() - , 'story' => array( + , 'story' => [ 'sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id(), - ) - ); + ] + ]; return $app->json($data); } else { - return $app->redirectPath('prod_stories_story', array( + return $app->redirectPath('prod_stories_story', [ 'sbas_id' => $StoryWZ->getSbasId(), 'record_id' => $StoryWZ->getRecordId(), - )); + ]); } })->bind('prod_stories_do_create'); $controllers->get('/{sbas_id}/{record_id}/', function (Application $app, $sbas_id, $record_id) { $Story = new \record_adapter($app, $sbas_id, $record_id); - $html = $app['twig']->render('prod/WorkZone/Story.html.twig', array('Story' => $Story)); + $html = $app['twig']->render('prod/WorkZone/Story.html.twig', ['Story' => $Story]); return new Response($html); }) @@ -139,15 +139,15 @@ class Story implements ControllerProviderInterface $n++; } - $data = array( + $data = [ 'success' => true , 'message' => sprintf(_('%d records added'), $n) - ); + ]; if ($request->getRequestFormat() == 'json') { return $app->json($data); } else { - return $app->redirectPath('prod_stories_story', array('sbas_id' => $sbas_id,'record_id' => $record_id)); + return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id,'record_id' => $record_id]); } })->assert('sbas_id', '\d+')->assert('record_id', '\d+'); @@ -161,15 +161,15 @@ class Story implements ControllerProviderInterface $Story->removeChild($record); - $data = array( + $data = [ 'success' => true , 'message' => _('Record removed from story') - ); + ]; if ($request->getRequestFormat() == 'json') { return $app->json($data); } else { - return $app->redirectPath('prod_stories_story', array('sbas_id' => $sbas_id,'record_id' => $record_id)); + return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id,'record_id' => $record_id]); } }) ->bind('prod_stories_story_remove_element') @@ -191,7 +191,7 @@ class Story implements ControllerProviderInterface return new Response( $app['twig']->render( 'prod/Story/Reorder.html.twig' - , array('story' => $story) + , ['story' => $story] ) ); }) @@ -200,7 +200,7 @@ class Story implements ControllerProviderInterface ->assert('record_id', '\d+'); $controllers->post('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) { - $ret = array('success' => false, 'message' => _('An error occured')); + $ret = ['success' => false, 'message' => _('An error occured')]; try { $story = new \record_adapter($app, $sbas_id, $record_id); @@ -218,19 +218,19 @@ class Story implements ControllerProviderInterface $stmt = $story->get_databox()->get_connection()->prepare($sql); foreach ($app['request']->request->get('element') as $record_id => $ord) { - $params = array( + $params = [ ':ord' => $ord, ':parent_id' => $story->get_record_id(), ':children_id' => $record_id - ); + ]; $stmt->execute($params); } $stmt->closeCursor(); - $ret = array('success' => true, 'message' => _('Story updated')); + $ret = ['success' => true, 'message' => _('Story updated')]; } catch (ControllerException $e) { - $ret = array('success' => false, 'message' => $e->getMessage()); + $ret = ['success' => false, 'message' => $e->getMessage()]; } catch (\Exception $e) { } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php index 0a5ac013cb..1472b88f75 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php @@ -52,13 +52,13 @@ class TOU implements ControllerProviderInterface */ public function denyTermsOfUse(Application $app, Request $request, $sbas_id) { - $ret = array('success' => false, 'message' => ''); + $ret = ['success' => false, 'message' => '']; try { $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $app['acl']->get($app['authentication']->getUser())->revoke_access_from_bases( - array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id()))) + array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()])) ); $app['acl']->get($app['authentication']->getUser())->revoke_unused_sbas_rights(); @@ -81,8 +81,8 @@ class TOU implements ControllerProviderInterface */ public function displayTermsOfUse(Application $app, Request $request) { - $toDisplay = $request->query->get('to_display', array()); - $data = array(); + $toDisplay = $request->query->get('to_display', []); + $data = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { if (count($toDisplay) > 0 && !in_array($databox->get_sbas_id(), $toDisplay)) { @@ -98,9 +98,9 @@ class TOU implements ControllerProviderInterface $data[$databox->get_label($app['locale.I18n'])] = $cgus[$app['locale']]['value']; } - return new Response($app['twig']->render('/prod/TOU.html.twig', array( + return new Response($app['twig']->render('/prod/TOU.html.twig', [ 'TOUs' => $data, 'local_title' => _('Terms of use') - ))); + ])); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php index 11c31b58c7..d5a87bc851 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tools.php @@ -59,21 +59,21 @@ class Tools implements ControllerProviderInterface } } - $var = array( + $var = [ 'records' => $records, 'record' => $record, 'metadatas' => $metadatas, - ); + ]; return $app['twig']->render('prod/actions/Tools/index.html.twig', $var); }); $controllers->post('/rotate/', function (Application $app, Request $request) { - $return = array('success' => true, 'errorMessage' => ''); + $return = ['success' => true, 'errorMessage' => '']; $records = RecordsRequest::fromRequest($app, $request, false); - $rotation = in_array($request->request->get('rotation'), array('-90', '90', '180')) ? $request->request->get('rotation', 90) : 90; + $rotation = in_array($request->request->get('rotation'), ['-90', '90', '180']) ? $request->request->get('rotation', 90) : 90; foreach ($records as $record) { foreach ($record->get_subdefs() as $name => $subdef) { @@ -92,9 +92,9 @@ class Tools implements ControllerProviderInterface })->bind('prod_tools_rotate'); $controllers->post('/image/', function (Application $app, Request $request) { - $return = array('success' => true); + $return = ['success' => true]; - $selection = RecordsRequest::fromRequest($app, $request, false, array('canmodifrecord')); + $selection = RecordsRequest::fromRequest($app, $request, false, ['canmodifrecord']); foreach ($selection as $record) { @@ -169,10 +169,10 @@ class Tools implements ControllerProviderInterface $app->abort(400, 'Missing file parameter'); } - return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', array( + return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', [ 'success' => $success, 'message' => $message, - )); + ]); })->bind('prod_tools_hd_substitution'); $controllers->post('/chgthumb/', function (Application $app, Request $request) { @@ -223,22 +223,22 @@ class Tools implements ControllerProviderInterface $app->abort(400, 'Missing file parameter'); } - return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', array( + return $app['twig']->render('prod/actions/Tools/iframeUpload.html.twig', [ 'success' => $success, 'message' => $message, - )); + ]); })->bind('prod_tools_thumbnail_substitution'); $controllers->post('/thumb-extractor/confirm-box/', function (Application $app, Request $request) { - $return = array('error' => false, 'datas' => ''); + $return = ['error' => false, 'datas' => '']; $template = 'prod/actions/Tools/confirm.html.twig'; try { $record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id')); - $var = array( + $var = [ 'video_title' => $record->get_title() , 'image' => $request->request->get('image', '') - ); + ]; $return['datas'] = $app['twig']->render($template, $var); } catch (\Exception $e) { $return['datas'] = _('an error occured'); @@ -249,7 +249,7 @@ class Tools implements ControllerProviderInterface }); $controllers->post('/thumb-extractor/apply/', function (Application $app, Request $request) { - $return = array('success' => false, 'message' => ''); + $return = ['success' => false, 'message' => '']; try { $record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id')); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php index 9023a49905..ce41398736 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php @@ -84,14 +84,14 @@ class Tooltip implements ControllerProviderInterface public function displayBasket(Application $app, Basket $basket) { - return $app['twig']->render('prod/Tooltip/Basket.html.twig', array('basket' => $basket)); + return $app['twig']->render('prod/Tooltip/Basket.html.twig', ['basket' => $basket]); } public function displayStory(Application $app, $sbas_id, $record_id) { $Story = new \record_adapter($app, $sbas_id, $record_id); - return $app['twig']->render('prod/Tooltip/Story.html.twig', array('Story' => $Story)); + return $app['twig']->render('prod/Tooltip/Story.html.twig', ['Story' => $Story]); } public function displayUserBadge(Application $app, $usr_id) @@ -100,7 +100,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/User.html.twig' - , array('user' => $user) + , ['user' => $user] ); } @@ -110,7 +110,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/Preview.html.twig' - , array('record' => $record, 'not_wrapped' => true) + , ['record' => $record, 'not_wrapped' => true] ); } @@ -132,12 +132,12 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/Caption.html.twig' - , array( + , [ 'record' => $record, 'view' => $context, 'highlight' => $app['request']->request->get('query'), 'searchEngine' => $search_engine, - )); + ]); } public function displayTechnicalDatas(Application $app, $sbas_id, $record_id) @@ -152,7 +152,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/TechnicalDatas.html.twig' - , array('record' => $record, 'document' => $document) + , ['record' => $record, 'document' => $document] ); } @@ -163,7 +163,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/DataboxField.html.twig' - , array('field' => $field) + , ['field' => $field] ); } @@ -174,7 +174,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/DCESFieldInfo.html.twig' - , array('field' => $field) + , ['field' => $field] ); } @@ -185,7 +185,7 @@ class Tooltip implements ControllerProviderInterface return $app['twig']->render( 'prod/Tooltip/DataboxFieldRestrictions.html.twig' - , array('field' => $field) + , ['field' => $field] ); } } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php index f2225fc90c..6e6b6ca2e0 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php @@ -76,12 +76,12 @@ class Upload implements ControllerProviderInterface $maxFileSize = $this->getUploadMaxFileSize(); return $app['twig']->render( - 'prod/upload/upload-flash.html.twig', array( + 'prod/upload/upload-flash.html.twig', [ 'sessionId' => session_id(), 'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())), 'maxFileSize' => $maxFileSize, 'maxFileSizeReadable' => \p4string::format_octets($maxFileSize) - )); + ]); } /** @@ -97,11 +97,11 @@ class Upload implements ControllerProviderInterface $maxFileSize = $this->getUploadMaxFileSize(); return $app['twig']->render( - 'prod/upload/upload.html.twig', array( + 'prod/upload/upload.html.twig', [ 'collections' => $this->getGrantedCollections($app['acl']->get($app['authentication']->getUser())), 'maxFileSize' => $maxFileSize, 'maxFileSizeReadable' => \p4string::format_octets($maxFileSize) - )); + ]); } /** @@ -121,14 +121,14 @@ class Upload implements ControllerProviderInterface */ public function upload(Application $app, Request $request) { - $datas = array( + $datas = [ 'success' => false, 'code' => null, 'message' => '', 'element' => '', - 'reasons' => array(), + 'reasons' => [], 'id' => '', - ); + ]; if (null === $request->files->get('files')) { throw new BadRequestHttpException('Missing file parameter'); @@ -185,7 +185,7 @@ class Upload implements ControllerProviderInterface $forceBehavior = $request->request->get('forceAction'); - $reasons = array(); + $reasons = []; $elementCreated = null; $callback = function ($element, $visa, $code) use (&$reasons, &$elementCreated) { @@ -205,7 +205,7 @@ class Upload implements ControllerProviderInterface $app['filesystem']->rename($renamedFilename, $uploadedFilename); if (!!$forceBehavior) { - $reasons = array(); + $reasons = []; } if ($elementCreated instanceof \record_adapter) { @@ -237,7 +237,7 @@ class Upload implements ControllerProviderInterface } } } else { - $params = array('lazaret_file' => $elementCreated); + $params = ['lazaret_file' => $elementCreated]; $app['events-manager']->trigger('__UPLOAD_QUARANTINE__', $params); @@ -246,14 +246,14 @@ class Upload implements ControllerProviderInterface $message = _('The file was moved to the quarantine'); } - $datas = array( + $datas = [ 'success' => true, 'code' => $code, 'message' => $message, 'element' => $element, 'reasons' => $reasons, 'id' => $id, - ); + ]; } catch (\Exception $e) { $datas['message'] = _('Unable to add file to Phraseanet'); } @@ -275,16 +275,16 @@ class Upload implements ControllerProviderInterface */ private function getGrantedCollections(\ACL $acl) { - $collections = array(); + $collections = []; - foreach ($acl->get_granted_base(array('canaddrecord')) as $collection) { + foreach ($acl->get_granted_base(['canaddrecord']) as $collection) { $databox = $collection->get_databox(); if ( ! isset($collections[$databox->get_sbas_id()])) { - $collections[$databox->get_sbas_id()] = array( + $collections[$databox->get_sbas_id()] = [ 'databox' => $databox, - 'databox_collections' => array() - ); + 'databox_collections' => [] + ]; } $collections[$databox->get_sbas_id()]['databox_collections'][] = $collection; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php index 62b5455ff0..2441726862 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php @@ -78,11 +78,11 @@ class UsrLists implements ControllerProviderInterface public function getAll(Application $app, Request $request) { - $datas = array( + $datas = [ 'success' => false , 'message' => '' , 'result' => null - ); + ]; $lists = new ArrayCollection(); @@ -91,13 +91,13 @@ class UsrLists implements ControllerProviderInterface $lists = $repository->findUserLists($app['authentication']->getUser()); - $result = array(); + $result = []; foreach ($lists as $list) { - $owners = $entries = array(); + $owners = $entries = []; foreach ($list->getOwners() as $owner) { - $owners[] = array( + $owners[] = [ 'usr_id' => $owner->getUser($app)->get_id(), 'display_name' => $owner->getUser($app)->get_display_name(), 'position' => $owner->getUser($app)->get_position(), @@ -105,40 +105,40 @@ class UsrLists implements ControllerProviderInterface 'company' => $owner->getUser($app)->get_company(), 'email' => $owner->getUser($app)->get_email(), 'role' => $owner->getRole() - ); + ]; } foreach ($list->getEntries() as $entry) { - $entries[] = array( + $entries[] = [ 'usr_id' => $owner->getUser($app)->get_id(), 'display_name' => $owner->getUser($app)->get_display_name(), 'position' => $owner->getUser($app)->get_position(), 'job' => $owner->getUser($app)->get_job(), 'company' => $owner->getUser($app)->get_company(), 'email' => $owner->getUser($app)->get_email(), - ); + ]; } /* @var $list UsrList */ - $result[] = array( + $result[] = [ 'name' => $list->getName(), 'created' => $list->getCreated()->format(DATE_ATOM), 'updated' => $list->getUpdated()->format(DATE_ATOM), 'owners' => $owners, 'users' => $entries - ); + ]; } - $datas = array( + $datas = [ 'success' => true , 'message' => '' , 'result' => $result - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { } @@ -147,7 +147,7 @@ class UsrLists implements ControllerProviderInterface return $app->json($datas); } - return $app['twig']->render('prod/actions/Feedback/lists-all.html.twig', array('lists' => $lists)); + return $app['twig']->render('prod/actions/Feedback/lists-all.html.twig', ['lists' => $lists]); } public function createList(Application $app) @@ -156,11 +156,11 @@ class UsrLists implements ControllerProviderInterface $list_name = $request->request->get('name'); - $datas = array( + $datas = [ 'success' => false , 'message' => sprintf(_('Unable to create list %s'), $list_name) , 'list_id' => null - ); + ]; try { if (!$list_name) { @@ -181,16 +181,16 @@ class UsrLists implements ControllerProviderInterface $app['EM']->persist($List); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('List %s has been created'), $list_name) , 'list_id' => $List->getId() - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { } @@ -208,7 +208,7 @@ class UsrLists implements ControllerProviderInterface $owners = new ArrayCollection(); foreach ($list->getOwners() as $owner) { - $owners[] = array( + $owners[] = [ 'usr_id' => $owner->getUser($app)->get_id(), 'display_name' => $owner->getUser($app)->get_display_name(), 'position' => $owner->getUser($app)->get_position(), @@ -216,40 +216,40 @@ class UsrLists implements ControllerProviderInterface 'company' => $owner->getUser($app)->get_company(), 'email' => $owner->getUser($app)->get_email(), 'role' => $owner->getRole($app) - ); + ]; } foreach ($list->getEntries() as $entry) { - $entries[] = array( + $entries[] = [ 'usr_id' => $entry->getUser($app)->get_id(), 'display_name' => $entry->getUser($app)->get_display_name(), 'position' => $entry->getUser($app)->get_position(), 'job' => $entry->getUser($app)->get_job(), 'company' => $entry->getUser($app)->get_company(), 'email' => $entry->getUser($app)->get_email(), - ); + ]; } - return $app->json(array( - 'result' => array( + return $app->json([ + 'result' => [ 'id' => $list->getId(), 'name' => $list->getName(), 'created' => $list->getCreated()->format(DATE_ATOM), 'updated' => $list->getUpdated()->format(DATE_ATOM), 'owners' => $owners, 'users' => $entries - ) - )); + ] + ]); } public function updateList(Application $app, $list_id) { $request = $app['request']; - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to update list') - ); + ]; try { $list_name = $request->request->get('name'); @@ -270,15 +270,15 @@ class UsrLists implements ControllerProviderInterface $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('List has been updated') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { } @@ -300,21 +300,21 @@ class UsrLists implements ControllerProviderInterface $app['EM']->remove($list); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('List has been deleted')) - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => sprintf(_('Unable to delete list')) - ); + ]; } return $app->json($datas); @@ -339,21 +339,21 @@ class UsrLists implements ControllerProviderInterface $app['EM']->remove($user_entry); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('Entry removed from list') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to remove entry from list ' . $e->getMessage()) - ); + ]; } return $app->json($datas); @@ -375,7 +375,7 @@ class UsrLists implements ControllerProviderInterface throw new ControllerException(_('You are not authorized to do this')); } - $inserted_usr_ids = array(); + $inserted_usr_ids = []; foreach ($request->request->get('usr_ids') as $usr_id) { $user_entry = \User_Adapter::getInstance($usr_id, $app); @@ -397,29 +397,29 @@ class UsrLists implements ControllerProviderInterface $app['EM']->flush(); if (count($inserted_usr_ids) > 1) { - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('%d Users added to list'), count($inserted_usr_ids)) , 'result' => $inserted_usr_ids - ); + ]; } else { - $datas = array( + $datas = [ 'success' => true , 'message' => sprintf(_('%d User added to list'), count($inserted_usr_ids)) , 'result' => $inserted_usr_ids - ); + ]; } } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to add usr to list') - ); + ]; } return $app->json($datas); @@ -443,16 +443,16 @@ class UsrLists implements ControllerProviderInterface } - return $app['twig']->render('prod/actions/Feedback/List-Share.html.twig', array('list' => $list)); + return $app['twig']->render('prod/actions/Feedback/List-Share.html.twig', ['list' => $list]); } public function shareWithUser(Application $app, $list_id, $usr_id) { - $availableRoles = array( + $availableRoles = [ UsrListOwner::ROLE_USER, UsrListOwner::ROLE_EDITOR, UsrListOwner::ROLE_ADMIN, - ); + ]; if (!$app['request']->request->get('role')) throw new BadRequestHttpException('Missing role parameter'); @@ -493,21 +493,21 @@ class UsrLists implements ControllerProviderInterface $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('List shared to user') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to share the list with the usr') - ); + ]; } return $app->json($datas); @@ -532,20 +532,20 @@ class UsrLists implements ControllerProviderInterface $app['EM']->remove($owner); $app['EM']->flush(); - $datas = array( + $datas = [ 'success' => true , 'message' => _('Owner removed from list') - ); + ]; } catch (ControllerException $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => $e->getMessage() - ); + ]; } catch (\Exception $e) { - $datas = array( + $datas = [ 'success' => false , 'message' => _('Unable to remove usr from list') - ); + ]; } return $app->json($datas); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php index 1a019f6d91..8014b40f47 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/WorkZone.php @@ -66,12 +66,12 @@ class WorkZone implements ControllerProviderInterface public function displayWorkzone(Application $app) { - $params = array( + $params = [ 'WorkZone' => new WorkzoneHelper($app, $app['request']) , 'selected_type' => $app['request']->query->get('type') , 'selected_id' => $app['request']->query->get('id') , 'srt' => $app['request']->query->get('sort') - ); + ]; return $app['twig']->render('prod/WorkZone/WorkZone.html.twig', $params); } @@ -104,7 +104,7 @@ class WorkZone implements ControllerProviderInterface $page = floor($offsetStart / $PerPage) + 1; $maxPage = floor(count($Baskets) / $PerPage) + 1; - $params = array( + $params = [ 'Baskets' => $Baskets , 'Page' => $page , 'MaxPage' => $maxPage @@ -112,14 +112,14 @@ class WorkZone implements ControllerProviderInterface , 'Query' => $request->query->get('Query') , 'Year' => $request->query->get('Year') , 'Type' => $request->query->get('Type') - ); + ]; return $app['twig']->render('prod/WorkZone/Browser/Results.html.twig', $params); } public function browseBasket(Application $app, Request $request, Basket $basket) { - return $app['twig']->render('prod/WorkZone/Browser/Basket.html.twig', array('Basket' => $basket)); + return $app['twig']->render('prod/WorkZone/Browser/Basket.html.twig', ['Basket' => $basket]); } public function attachStories(Application $app, Request $request) @@ -132,7 +132,7 @@ class WorkZone implements ControllerProviderInterface $alreadyFixed = $done = 0; - $stories = $request->request->get('stories', array()); + $stories = $request->request->get('stories', []); foreach ($stories as $element) { $element = explode('_', $element); @@ -190,10 +190,10 @@ class WorkZone implements ControllerProviderInterface } if ($request->getRequestFormat() == 'json') { - return $app->json(array( + return $app->json([ 'success' => true , 'message' => $message - )); + ]); } return $app->redirectPath('prod_workzone_show'); @@ -216,10 +216,10 @@ class WorkZone implements ControllerProviderInterface $app['EM']->flush(); if ($request->getRequestFormat() == 'json') { - return $app->json(array( + return $app->json([ 'success' => true , 'message' => _('Story detached from the WorkZone') - )); + ]); } return $app->redirectPath('prod_workzone_show'); diff --git a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php index 08c8399db2..4ad903a04a 100644 --- a/lib/Alchemy/Phrasea/Controller/RecordsRequest.php +++ b/lib/Alchemy/Phrasea/Controller/RecordsRequest.php @@ -45,7 +45,7 @@ class RecordsRequest extends ArrayCollection $this->isSingleStory = ($flatten !== self::FLATTEN_YES && 1 === count($this) && $this->first()->is_grouping()); if (self::FLATTEN_NO !== $flatten) { - $to_remove = array(); + $to_remove = []; foreach ($this as $key => $record) { if ($record->is_grouping()) { if (self::FLATTEN_YES === $flatten) { @@ -77,7 +77,7 @@ class RecordsRequest extends ArrayCollection public function databoxes() { if (!$this->databoxes) { - $this->databoxes = array(); + $this->databoxes = []; foreach ($this as $record) { if (false === array_key_exists($record->get_databox()->get_sbas_id(), $this->databoxes)) { @@ -99,7 +99,7 @@ class RecordsRequest extends ArrayCollection public function collections() { if (!$this->collections) { - $this->collections = array(); + $this->collections = []; foreach ($this as $record) { if (false === array_key_exists($record->get_base_id(), $this->collections)) { @@ -182,7 +182,7 @@ class RecordsRequest extends ArrayCollection return $this->singleStory()->get_serialize_key(); } - $basrec = array(); + $basrec = []; foreach ($this as $record) { $basrec[] = $record->get_serialize_key(); } @@ -200,9 +200,9 @@ class RecordsRequest extends ArrayCollection * @param array $rightsDatabox * @return RecordsRequest */ - public static function fromRequest(Application $app, Request $request, $flattenStories = self::FLATTEN_NO, array $rightsColl = array(), array $rightsDatabox = array()) + public static function fromRequest(Application $app, Request $request, $flattenStories = self::FLATTEN_NO, array $rightsColl = [], array $rightsDatabox = []) { - $elements = $received = array(); + $elements = $received = []; $basket = null; if ($request->get('ssel')) { @@ -239,7 +239,7 @@ class RecordsRequest extends ArrayCollection $elements = $received; - $to_remove = array(); + $to_remove = []; foreach ($elements as $id => $record) { diff --git a/lib/Alchemy/Phrasea/Controller/Report/Activity.php b/lib/Alchemy/Phrasea/Controller/Report/Activity.php index 49c3e579b9..d6ba29bd16 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Activity.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Activity.php @@ -105,22 +105,22 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { $report = $activity->getConnexionBase(false, $request->request->get('on', 'user')); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -133,13 +133,13 @@ class Activity implements ControllerProviderInterface */ public function doReportDownloadsByUsers(Application $app, Request $request) { - $conf = array( - 'user' => array(_('report:: utilisateur'), 0, 1, 0, 0), - 'nbdoc' => array(_('report:: nombre de documents'), 0, 0, 0, 0), - 'poiddoc' => array(_('report:: poids des documents'), 0, 0, 0, 0), - 'nbprev' => array(_('report:: nombre de preview'), 0, 0, 0, 0), - 'poidprev' => array(_('report:: poids des previews'), 0, 0, 0, 0) - ); + $conf = [ + 'user' => [_('report:: utilisateur'), 0, 1, 0, 0], + 'nbdoc' => [_('report:: nombre de documents'), 0, 0, 0, 0], + 'poiddoc' => [_('report:: poids des documents'), 0, 0, 0, 0], + 'nbprev' => [_('report:: nombre de preview'), 0, 0, 0, 0], + 'poidprev' => [_('report:: poids des previews'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -171,20 +171,20 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -197,11 +197,11 @@ class Activity implements ControllerProviderInterface */ public function doReportBestOfQuestions(Application $app, Request $request) { - $conf = array( - 'search' => array(_('report:: question'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0) - ); + $conf = [ + 'search' => [_('report:: question'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'nb_rep' => [_('report:: nombre de reponses'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -227,22 +227,22 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { $report = $activity->getTopQuestion($conf); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -255,11 +255,11 @@ class Activity implements ControllerProviderInterface */ public function doReportNoBestOfQuestions(Application $app, Request $request) { - $conf = array( - 'search' => array(_('report:: question'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'nb_rep' => array(_('report:: nombre de reponses'), 0, 0, 0, 0) - ); + $conf = [ + 'search' => [_('report:: question'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'nb_rep' => [_('report:: nombre de reponses'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -292,22 +292,22 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { $report = $activity->getTopQuestion($conf, true); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -342,20 +342,20 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => true, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -368,12 +368,12 @@ class Activity implements ControllerProviderInterface */ public function doReportSiteActiviyPerDays(Application $app, Request $request) { - $conf = array( - 'ddate' => array(_('report:: jour'), 0, 0, 0, 0), - 'total' => array(_('report:: total des telechargements'), 0, 0, 0, 0), - 'preview' => array(_('report:: preview'), 0, 0, 0, 0), - 'document' => array(_('report:: document original'), 0, 0, 0, 0) - ); + $conf = [ + 'ddate' => [_('report:: jour'), 0, 0, 0, 0], + 'total' => [_('report:: total des telechargements'), 0, 0, 0, 0], + 'preview' => [_('report:: preview'), 0, 0, 0, 0], + 'document' => [_('report:: document original'), 0, 0, 0, 0] + ]; $activity = new \module_report_activity( $app, @@ -406,20 +406,20 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } else { - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } } @@ -432,14 +432,14 @@ class Activity implements ControllerProviderInterface */ public function doReportPushedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'getter' => array("Destinataire", 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'getter' => ["Destinataire", 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_push( $app, @@ -461,7 +461,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -470,15 +470,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -486,7 +486,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -498,13 +498,13 @@ class Activity implements ControllerProviderInterface */ public function doReportAddedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_add( $app, @@ -526,7 +526,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -535,15 +535,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -551,7 +551,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -563,13 +563,13 @@ class Activity implements ControllerProviderInterface */ public function doReportEditedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_edit( $app, @@ -591,7 +591,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -600,15 +600,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -616,7 +616,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -628,14 +628,14 @@ class Activity implements ControllerProviderInterface */ public function doReportValidatedDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'getter' => array("Destinataire", 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'getter' => ["Destinataire", 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + ]; $activity = new \module_report_validate( $app, @@ -657,7 +657,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -666,15 +666,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -682,7 +682,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -694,14 +694,14 @@ class Activity implements ControllerProviderInterface */ public function doReportSentDocuments(Application $app, Request $request) { - $conf = array( - 'user' => array('', 1, 0, 1, 1), - 'date' => array('', 1, 0, 1, 1), - 'record_id' => array('', 1, 1, 1, 1), - 'file' => array('', 1, 0, 1, 1), - 'mime' => array('', 1, 0, 1, 1), - 'comment' => array(_('Receiver'), 1, 0, 1, 1), - ); + $conf = [ + 'user' => ['', 1, 0, 1, 1], + 'date' => ['', 1, 0, 1, 1], + 'record_id' => ['', 1, 1, 1, 1], + 'file' => ['', 1, 0, 1, 1], + 'mime' => ['', 1, 0, 1, 1], + 'comment' => [_('Receiver'), 1, 0, 1, 1], + ]; $activity = new \module_report_sent( $app, @@ -723,7 +723,7 @@ class Activity implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $activity, $conf); @@ -732,15 +732,15 @@ class Activity implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -748,7 +748,7 @@ class Activity implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -790,9 +790,9 @@ class Activity implements ControllerProviderInterface //display content of a table column when user click on it if ($request->request->get('conf') == 'on') { - return $app->json(array('liste' => $app['twig']->render('report/listColumn.html.twig', array( + return $app->json(['liste' => $app['twig']->render('report/listColumn.html.twig', [ 'conf' => $base_conf - )), "title" => _("configuration"))); + ]), "title" => _("configuration")]); } //set order @@ -803,7 +803,7 @@ class Activity implements ControllerProviderInterface //work on filters $mapColumnTitleToSqlField = $report->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -816,10 +816,10 @@ class Activity implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - )), "title" => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), "title" => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -854,18 +854,18 @@ class Activity implements ControllerProviderInterface $groupField = isset($conf[strtolower($groupby)]['title']) ? $conf[strtolower($groupby)]['title'] : ''; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => true, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField)) - )); + ]); } //set Limit diff --git a/lib/Alchemy/Phrasea/Controller/Report/Export.php b/lib/Alchemy/Phrasea/Controller/Report/Export.php index 38e8cec583..b0fc59b1e3 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Export.php @@ -54,7 +54,7 @@ class Export implements ControllerProviderInterface $filename = mb_strtolower('report_' . $name . '_' . date('dmY') . '.csv'); $data = preg_replace('/[ \t\r\f]+/', '', $data); - $response = new Response($data, 200, array( + $response = new Response($data, 200, [ 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s'). ' GMT', 'Cache-Control' => 'no-store, no-cache, must-revalidate', @@ -64,7 +64,7 @@ class Export implements ControllerProviderInterface 'Content-Length' => strlen($data), 'Cache-Control' => 'max-age=3600, must-revalidate', 'Content-Disposition' => 'max-age=3600, must-revalidate', - )); + ]); $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename)); diff --git a/lib/Alchemy/Phrasea/Controller/Report/Informations.php b/lib/Alchemy/Phrasea/Controller/Report/Informations.php index 1fd2136673..9a68ac4fa9 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Informations.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Informations.php @@ -50,38 +50,38 @@ class Informations implements ControllerProviderInterface */ public function doReportInformationsUser(Application $app, Request $request) { - $conf = array( - 'config' => array( - 'photo' => array(_('report:: document'), 0, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 0, 0, 0, 0), - 'date' => array(_('report:: date'), 0, 0, 0, 0), - 'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'titre' => array(_('report:: titre'), 0, 0, 0, 0), - 'taille' => array(_('report:: poids'), 0, 0, 0, 0) - ), - 'conf' => array( - 'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0), - 'nom' => array(_('report:: nom'), 0, 0, 0, 0), - 'mail' => array(_('report:: email'), 0, 0, 0, 0), - 'adresse' => array(_('report:: adresse'), 0, 0, 0, 0), - 'tel' => array(_('report:: telephone'), 0, 0, 0, 0) - ), - 'config_cnx' => array( - 'ddate' => array(_('report:: date'), 0, 0, 0, 0), - 'appli' => array(_('report:: modules'), 0, 0, 0, 0), - ), - 'config_dl' => array( - 'ddate' => array(_('report:: date'), 0, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 0, 1, 0, 0), - 'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'coll_id' => array(_('report:: collections'), 0, 0, 0, 0), - 'comment' => array(_('report:: commentaire'), 0, 0, 0, 0), - ), - 'config_ask' => array( - 'search' => array(_('report:: question'), 0, 0, 0, 0), - 'ddate' => array(_('report:: date'), 0, 0, 0, 0) - ) - ); + $conf = [ + 'config' => [ + 'photo' => [_('report:: document'), 0, 0, 0, 0], + 'record_id' => [_('report:: record id'), 0, 0, 0, 0], + 'date' => [_('report:: date'), 0, 0, 0, 0], + 'type' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'titre' => [_('report:: titre'), 0, 0, 0, 0], + 'taille' => [_('report:: poids'), 0, 0, 0, 0] + ], + 'conf' => [ + 'identifiant' => [_('report:: identifiant'), 0, 0, 0, 0], + 'nom' => [_('report:: nom'), 0, 0, 0, 0], + 'mail' => [_('report:: email'), 0, 0, 0, 0], + 'adresse' => [_('report:: adresse'), 0, 0, 0, 0], + 'tel' => [_('report:: telephone'), 0, 0, 0, 0] + ], + 'config_cnx' => [ + 'ddate' => [_('report:: date'), 0, 0, 0, 0], + 'appli' => [_('report:: modules'), 0, 0, 0, 0], + ], + 'config_dl' => [ + 'ddate' => [_('report:: date'), 0, 0, 0, 0], + 'record_id' => [_('report:: record id'), 0, 1, 0, 0], + 'final' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'coll_id' => [_('report:: collections'), 0, 0, 0, 0], + 'comment' => [_('report:: commentaire'), 0, 0, 0, 0], + ], + 'config_ask' => [ + 'search' => [_('report:: question'), 0, 0, 0, 0], + 'ddate' => [_('report:: date'), 0, 0, 0, 0] + ] + ]; $report = null; $html = $html_info = ''; @@ -94,10 +94,10 @@ class Informations implements ControllerProviderInterface } if ('' !== $on && $app['phraseanet.registry']->get('GV_anonymousReport') == true) { - $conf['conf'] = array( - $on => array($on, 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0) - ); + $conf['conf'] = [ + $on => [$on, 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0] + ]; } if ($from == 'CNXU' || $from == 'CNX') { @@ -135,7 +135,7 @@ class Informations implements ControllerProviderInterface if ($report) { $mapColumnTitleToSqlField = $report->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -148,10 +148,10 @@ class Informations implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - )), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -188,17 +188,17 @@ class Informations implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } - $html = $app['twig']->render('report/ajax_data_content.html.twig', array( + $html = $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => $report instanceof \module_report_download, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); } $info = new \module_report_nav( @@ -214,32 +214,32 @@ class Informations implements ControllerProviderInterface $infoArray = $info->buildTabGrpInfo( null !== $report ? $report->getReq() : '', - null !== $report ? $report->getParams() : array(), + null !== $report ? $report->getParams() : [], $selectValue, $conf['conf'], $on ); if (false == $app['phraseanet.registry']->get('GV_anonymousReport')) { - $html_info = $app['twig']->render('report/ajax_data_content.html.twig', array( + $html_info = $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($infoArray['report']) ? $infoArray['report'] : $infoArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); $title = ('' === $on && isset($infoArray['result'])) ? $infoArray['result'][0]['identifiant'] : $selectValue; } else { $title = $selectValue; } - return $app->json(array( + return $app->json([ 'rs' => sprintf('%s%s', $html_info, $html), 'display_nav' => false, 'title' => $title - )); + ]); } /** @@ -251,10 +251,10 @@ class Informations implements ControllerProviderInterface */ public function doReportinformationsBrowser(Application $app, Request $request) { - $conf = array( - 'version' => array(_('report::version '), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0) - ); + $conf = [ + 'version' => [_('report::version '), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0] + ]; $info = new \module_report_nav( $app, @@ -273,18 +273,18 @@ class Informations implements ControllerProviderInterface $reportArray = $info->buildTabInfoNav($conf, $browser); - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => $browser - )); + ]); } /** @@ -296,26 +296,26 @@ class Informations implements ControllerProviderInterface */ public function doReportInformationsDocument(Application $app, Request $request) { - $config = array( - 'photo' => array(_('report:: document'), 0, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 0, 0, 0, 0), - 'date' => array(_('report:: date'), 0, 0, 0, 0), - 'type' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'titre' => array(_('report:: titre'), 0, 0, 0, 0), - 'taille' => array(_('report:: poids'), 0, 0, 0, 0) - ); + $config = [ + 'photo' => [_('report:: document'), 0, 0, 0, 0], + 'record_id' => [_('report:: record id'), 0, 0, 0, 0], + 'date' => [_('report:: date'), 0, 0, 0, 0], + 'type' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'titre' => [_('report:: titre'), 0, 0, 0, 0], + 'taille' => [_('report:: poids'), 0, 0, 0, 0] + ]; - $config_dl = array( - 'ddate' => array(_('report:: date'), 0, 0, 0, 0), - 'user' => array(_('report:: utilisateurs'), 0, 0, 0, 0), - 'final' => array(_('phrseanet:: sous definition'), 0, 0, 0, 0), - 'coll_id' => array(_('report:: collections'), 0, 0, 0, 0), - 'comment' => array(_('report:: commentaire'), 0, 0, 0, 0), - 'fonction' => array(_('report:: fonction'), 0, 0, 0, 0), - 'activite' => array(_('report:: activite'), 0, 0, 0, 0), - 'pays' => array(_('report:: pays'), 0, 0, 0, 0), - 'societe' => array(_('report:: societe'), 0, 0, 0, 0) - ); + $config_dl = [ + 'ddate' => [_('report:: date'), 0, 0, 0, 0], + 'user' => [_('report:: utilisateurs'), 0, 0, 0, 0], + 'final' => [_('phrseanet:: sous definition'), 0, 0, 0, 0], + 'coll_id' => [_('report:: collections'), 0, 0, 0, 0], + 'comment' => [_('report:: commentaire'), 0, 0, 0, 0], + 'fonction' => [_('report:: fonction'), 0, 0, 0, 0], + 'activite' => [_('report:: activite'), 0, 0, 0, 0], + 'pays' => [_('report:: pays'), 0, 0, 0, 0], + 'societe' => [_('report:: societe'), 0, 0, 0, 0] + ]; //format conf according user preferences if ('' !== $columnsList = $request->request->get('list_column', '')) { @@ -361,25 +361,25 @@ class Informations implements ControllerProviderInterface $title = $what->getTitle(); - $html = $app['twig']->render('report/ajax_data_content.html.twig', array( + $html = $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); $from = $request->request->get('from', ''); if ('TOOL' === $from) { $what->setTitle(''); - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } if ('DASH' !== $from && 'PUSHDOC' !== $from) { @@ -393,7 +393,7 @@ class Informations implements ControllerProviderInterface $mapColumnTitleToSqlField = $download->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -406,10 +406,10 @@ class Informations implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $download->colFilter($field), 'field' => $field - )), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -437,33 +437,33 @@ class Informations implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } - $html .= $app['twig']->render('report/ajax_data_content.html.twig', array( + $html .= $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } if ($app['phraseanet.registry']->get('GV_anonymousReport') == false && $from !== 'DOC' && $from !== 'DASH' && $from !== 'GEN' && $from !== 'PUSHDOC') { - $conf = array( - 'identifiant' => array(_('report:: identifiant'), 0, 0, 0, 0), - 'nom' => array(_('report:: nom'), 0, 0, 0, 0), - 'mail' => array(_('report:: email'), 0, 0, 0, 0), - 'adresse' => array(_('report:: adresse'), 0, 0, 0, 0), - 'tel' => array(_('report:: telephone'), 0, 0, 0, 0) - ); + $conf = [ + 'identifiant' => [_('report:: identifiant'), 0, 0, 0, 0], + 'nom' => [_('report:: nom'), 0, 0, 0, 0], + 'mail' => [_('report:: email'), 0, 0, 0, 0], + 'adresse' => [_('report:: adresse'), 0, 0, 0, 0], + 'tel' => [_('report:: telephone'), 0, 0, 0, 0] + ]; $info = new \module_report_nav( $app, @@ -477,7 +477,7 @@ class Informations implements ControllerProviderInterface $info->setConfig(false); $info->setTitle(_('report:: utilisateur')); - $reportArray = $info->buildTabGrpInfo(false, array(), $request->request->get('user'), $conf, false); + $reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false); if ($request->request->get('printcsv') == 'on') { $download->setPrettyString(false); @@ -488,29 +488,29 @@ class Informations implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } - $html .= $app['twig']->render('report/ajax_data_content.html.twig', array( + $html .= $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )); + ]); - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } - return $app->json(array( + return $app->json([ 'rs' => $html, 'display_nav' => false, 'title' => $title - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Report/Root.php b/lib/Alchemy/Phrasea/Controller/Report/Root.php index 1d0959dc88..8f3f818307 100644 --- a/lib/Alchemy/Phrasea/Controller/Report/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Report/Root.php @@ -74,7 +74,7 @@ class Root implements ControllerProviderInterface $dashboard->execute(); - return $app['twig']->render('report/report_layout_child.html.twig', array( + return $app['twig']->render('report/report_layout_child.html.twig', [ 'ajax_dash' => true, 'dashboard' => $dashboard, 'home_title' => $app['phraseanet.registry']->get('GV_homeTitle'), @@ -84,7 +84,7 @@ class Root implements ControllerProviderInterface 'g_anal' => $app['phraseanet.registry']->get('GV_googleAnalytics'), 'ajax' => false, 'ajax_chart' => false - )); + ]); } $dmin = $request->request->get('dmin'); @@ -96,9 +96,9 @@ class Root implements ControllerProviderInterface $dashboard->execute(); - return $app->json(array('html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', array( + return $app->json(['html' => $app['twig']->render('report/ajax_dashboard_content_child.html.twig', [ 'dashboard' => $dashboard - )))); + ])]); } /** @@ -111,7 +111,7 @@ class Root implements ControllerProviderInterface */ public function initReport(Application $app, Request $request) { - $popbases = $request->request->get('popbases', array()); + $popbases = $request->request->get('popbases', []); if ('' === $dmin = $request->request->get('dmin', '')) { $dmin = '01-' . date('m') . '-' . date('Y'); @@ -125,7 +125,7 @@ class Root implements ControllerProviderInterface $dmax = \DateTime::createFromFormat('d-m-Y H:i:s', sprintf('%s 23:59:59', $dmax)); //get user's sbas & collections selection from popbases - $selection = array(); + $selection = []; $liste = $id_sbas = ''; $i = 0; foreach (array_fill_keys($popbases, 0) as $key => $val) { @@ -142,13 +142,13 @@ class Root implements ControllerProviderInterface //fill the last entry $selection[$id_sbas]['liste'] = $liste; - return $app['twig']->render('report/ajax_report_content.html.twig', array( + return $app['twig']->render('report/ajax_report_content.html.twig', [ 'selection' => $selection, 'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'), 'ajax' => true, 'dmin' => $dmin->format('Y-m-d H:i:s'), 'dmax' => $dmax->format('Y-m-d H:i:s'), - )); + ]); } /** @@ -168,16 +168,16 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf = array( - 'user' => array(_('phraseanet::utilisateurs'), 1, 1, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'ip' => array(_('report:: IP'), 1, 0, 0, 0), - 'appli' => array(_('report:: modules'), 1, 0, 0, 0), - 'fonction' => array(_('report::fonction'), 1, 1, 1, 1), - 'activite' => array(_('report::activite'), 1, 1, 1, 1), - 'pays' => array(_('report::pays'), 1, 1, 1, 1), - 'societe' => array(_('report::societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('phraseanet::utilisateurs'), 1, 1, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'ip' => [_('report:: IP'), 1, 0, 0, 0], + 'appli' => [_('report:: modules'), 1, 0, 0, 0], + 'fonction' => [_('report::fonction'), 1, 1, 1, 1], + 'activite' => [_('report::activite'), 1, 1, 1, 1], + 'pays' => [_('report::pays'), 1, 1, 1, 1], + 'societe' => [_('report::societe'), 1, 1, 1, 1] + ]; if ($request->request->get('printcsv') == 'on') { $cnx->setHasLimit(false); @@ -189,7 +189,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $cnx, $conf); @@ -198,15 +198,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -214,7 +214,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -234,15 +234,15 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf = array( - 'user' => array(_('report:: utilisateur'), 1, 1, 1, 1), - 'search' => array(_('report:: question'), 1, 0, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1), - 'activite' => array(_('report:: activite'), 1, 1, 1, 1), - 'pays' => array(_('report:: pays'), 1, 1, 1, 1), - 'societe' => array(_('report:: societe'), 1, 1, 1, 1) - ); + $conf = [ + 'user' => [_('report:: utilisateur'), 1, 1, 1, 1], + 'search' => [_('report:: question'), 1, 0, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], + 'activite' => [_('report:: activite'), 1, 1, 1, 1], + 'pays' => [_('report:: pays'), 1, 1, 1, 1], + 'societe' => [_('report:: societe'), 1, 1, 1, 1] + ]; if ($request->request->get('printcsv') == 'on') { $questions->setHasLimit(false); @@ -254,7 +254,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $questions, $conf); @@ -263,15 +263,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -279,7 +279,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -299,24 +299,24 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf_pref = array(); + $conf_pref = []; foreach (\module_report::getPreff($app, $request->request->get('sbasid')) as $field) { - $conf_pref[strtolower($field)] = array($field, 0, 0, 0, 0); + $conf_pref[strtolower($field)] = [$field, 0, 0, 0, 0]; } - $conf = array_merge(array( - 'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1), - 'ddate' => array(_('report:: date'), 1, 0, 1, 1), - 'record_id' => array(_('report:: record id'), 1, 1, 1, 1), - 'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1), - 'coll_id' => array(_('report:: collections'), 1, 0, 1, 1), - 'comment' => array(_('report:: commentaire'), 1, 0, 0, 0), - 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1), - 'activite' => array(_('report:: activite'), 1, 1, 1, 1), - 'pays' => array(_('report:: pays'), 1, 1, 1, 1), - 'societe' => array(_('report:: societe'), 1, 1, 1, 1) - ), $conf_pref); + $conf = array_merge([ + 'user' => [_('report:: utilisateurs'), 1, 1, 1, 1], + 'ddate' => [_('report:: date'), 1, 0, 1, 1], + 'record_id' => [_('report:: record id'), 1, 1, 1, 1], + 'final' => [_('phrseanet:: sous definition'), 1, 0, 1, 1], + 'coll_id' => [_('report:: collections'), 1, 0, 1, 1], + 'comment' => [_('report:: commentaire'), 1, 0, 0, 0], + 'fonction' => [_('report:: fonction'), 1, 1, 1, 1], + 'activite' => [_('report:: activite'), 1, 1, 1, 1], + 'pays' => [_('report:: pays'), 1, 1, 1, 1], + 'societe' => [_('report:: societe'), 1, 1, 1, 1] + ], $conf_pref); if ($request->request->get('printcsv') == 'on') { $download->setHasLimit(false); @@ -328,7 +328,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $download, $conf); @@ -337,15 +337,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -353,7 +353,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -373,20 +373,20 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf_pref = array(); + $conf_pref = []; foreach (\module_report::getPreff($app, $request->request->get('sbasid')) as $field) { - $conf_pref[strtolower($field)] = array($field, 0, 0, 0, 0); + $conf_pref[strtolower($field)] = [$field, 0, 0, 0, 0]; } - $conf = array_merge(array( - 'telechargement' => array(_('report:: telechargements'), 1, 0, 0, 0), - 'record_id' => array(_('report:: record id'), 1, 1, 1, 0), - 'final' => array(_('phraseanet:: sous definition'), 1, 0, 1, 1), - 'file' => array(_('report:: fichier'), 1, 0, 0, 1), - 'mime' => array(_('report:: type'), 1, 0, 1, 1), - 'size' => array(_('report:: taille'), 1, 0, 1, 1) - ), $conf_pref); + $conf = array_merge([ + 'telechargement' => [_('report:: telechargements'), 1, 0, 0, 0], + 'record_id' => [_('report:: record id'), 1, 1, 1, 0], + 'final' => [_('phraseanet:: sous definition'), 1, 0, 1, 1], + 'file' => [_('report:: fichier'), 1, 0, 0, 1], + 'mime' => [_('report:: type'), 1, 0, 1, 1], + 'size' => [_('report:: taille'), 1, 0, 1, 1] + ], $conf_pref); if ($request->request->get('printcsv') == 'on') { $document->setHasLimit(false); @@ -398,7 +398,7 @@ class Root implements ControllerProviderInterface $csv = ''; } - return $app->json(array('rs' => $csv)); + return $app->json(['rs' => $csv]); } $report = $this->doReport($app, $request, $document, $conf, 'record_id'); @@ -407,15 +407,15 @@ class Root implements ControllerProviderInterface return $report; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => true - )), + ]), 'display_nav' => $report['display_nav'], // do we display the prev and next button ? 'next' => $report['next_page'], //Number of the next page 'prev' => $report['previous_page'], //Number of the previoous page @@ -423,7 +423,7 @@ class Root implements ControllerProviderInterface 'filter' => ((sizeof($report['filter']) > 0) ? serialize($report['filter']) : ''), //the serialized filters 'col' => $report['active_column'], //all the columns where a filter is applied 'limit' => $report['nb_record'] - )); + ]); } /** @@ -443,63 +443,63 @@ class Root implements ControllerProviderInterface $request->request->get('collection') ); - $conf_nav = array( - 'nav' => array(_('report:: navigateur'), 0, 1, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); + $conf_nav = [ + 'nav' => [_('report:: navigateur'), 0, 1, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; - $conf_combo = array( - 'combo' => array(_('report:: navigateurs et plateforme'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); - $conf_os = array( - 'os' => array(_('report:: plateforme'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); - $conf_res = array( - 'res' => array(_('report:: resolution'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); - $conf_mod = array( - 'appli' => array(_('report:: module'), 0, 0, 0, 0), - 'nb' => array(_('report:: nombre'), 0, 0, 0, 0), - 'pourcent' => array(_('report:: pourcentage'), 0, 0, 0, 0) - ); + $conf_combo = [ + 'combo' => [_('report:: navigateurs et plateforme'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; + $conf_os = [ + 'os' => [_('report:: plateforme'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; + $conf_res = [ + 'res' => [_('report:: resolution'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; + $conf_mod = [ + 'appli' => [_('report:: module'), 0, 0, 0, 0], + 'nb' => [_('report:: nombre'), 0, 0, 0, 0], + 'pourcent' => [_('report:: pourcentage'), 0, 0, 0, 0] + ]; - $report = array( + $report = [ 'nav' => $nav->buildTabNav($conf_nav), 'os' => $nav->buildTabOs($conf_os), 'res' => $nav->buildTabRes($conf_res), 'mod' => $nav->buildTabModule($conf_mod), 'combo' => $nav->buildTabCombo($conf_combo) - ); + ]; if ($request->request->get('printcsv') == 'on') { - return $app->json(array( + return $app->json([ 'nav' => \format::arr_to_csv($report['nav']['result'], $conf_nav), 'os' => \format::arr_to_csv($report['os']['result'], $conf_os), 'res' => \format::arr_to_csv($report['res']['result'], $conf_res), 'mod' => \format::arr_to_csv($report['mod']['result'], $conf_mod), 'combo' => \format::arr_to_csv($report['combo']['result'], $conf_combo) - )); + ]); } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($report['report']) ? $report['report'] : $report, 'is_infouser' => false, 'is_nav' => true, 'is_groupby' => false, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => false - )); + ]); } /** @@ -541,9 +541,9 @@ class Root implements ControllerProviderInterface //display content of a table column when user click on it if ($request->request->get('conf') == 'on') { - return $app->json(array('liste' => $app['twig']->render('report/listColumn.html.twig', array( + return $app->json(['liste' => $app['twig']->render('report/listColumn.html.twig', [ 'conf' => $base_conf - )), 'title' => _('configuration'))); + ]), 'title' => _('configuration')]); } //set order @@ -554,7 +554,7 @@ class Root implements ControllerProviderInterface //work on filters $mapColumnTitleToSqlField = $report->getTransQueryString(); - $currentfilter = array(); + $currentfilter = []; if ('' !== $serializedFilter = $request->request->get('liste_filter', '')) { $currentfilter = @unserialize(urldecode($serializedFilter)); @@ -567,10 +567,10 @@ class Root implements ControllerProviderInterface $value = $request->request->get('filter_value', ''); if ($request->request->get('liste') == 'on') { - return $app->json(array('diag' => $app['twig']->render('report/colFilter.html.twig', array( + return $app->json(['diag' => $app['twig']->render('report/colFilter.html.twig', [ 'result' => $report->colFilter($field), 'field' => $field - )), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field))); + ]), 'title' => sprintf(_('filtrer les resultats sur la colonne %s'), $field)]); } if ($field === $value) { @@ -605,18 +605,18 @@ class Root implements ControllerProviderInterface $groupField = isset($conf[strtolower($groupby)]['title']) ? $conf[strtolower($groupby)]['title'] : ''; } - return $app->json(array( - 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( + return $app->json([ + 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [ 'result' => isset($reportArray['report']) ? $reportArray['report'] : $reportArray, 'is_infouser' => false, 'is_nav' => false, 'is_groupby' => true, 'is_plot' => false, 'is_doc' => false - )), + ]), 'display_nav' => false, 'title' => _(sprintf('Groupement des resultats sur le champ %s', $groupField)) - )); + ]); } //set Limit diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php index 6c6a20c6a6..492eeeab5a 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Account.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php @@ -108,7 +108,7 @@ class Account implements ControllerProviderInterface return $app['twig']->render('account/change-password.html.twig', array_merge( Login::getDefaultTemplateVariables($app), - array('form' => $form->createView()) + ['form' => $form->createView()] )); } @@ -148,7 +148,7 @@ class Account implements ControllerProviderInterface $date = new \DateTime('1 day'); $token = $app['tokens']->getUrlToken(\random::TYPE_EMAIL, $app['authentication']->getUser()->get_id(), $date, $app['authentication']->getUser()->get_email()); - $url = $app->url('account_reset_email', array('token' => $token)); + $url = $app->url('account_reset_email', ['token' => $token]); try { $receiver = Receiver::fromUser($app['authentication']->getUser()); @@ -227,7 +227,7 @@ class Account implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -241,9 +241,9 @@ class Account implements ControllerProviderInterface { require_once $app['root.path'] . '/lib/classes/deprecated/inscript.api.php'; - return $app['twig']->render('account/access.html.twig', array( + return $app['twig']->render('account/access.html.twig', [ 'inscriptions' => giveMeBases($app, $app['authentication']->getUser()->get_id()) - )); + ]); } /** @@ -255,9 +255,9 @@ class Account implements ControllerProviderInterface */ public function accountAuthorizedApps(Application $app, Request $request) { - return $app['twig']->render('account/authorized_apps.html.twig', array( + return $app['twig']->render('account/authorized_apps.html.twig', [ "applications" => \API_OAuth2_Application::load_app_by_user($app, $app['authentication']->getUser()), - )); + ]); } /** @@ -274,10 +274,10 @@ class Account implements ControllerProviderInterface ORDER BY s.created DESC'; $query = $app['EM']->createQuery($dql); - $query->setParameters(array('usr_id' => $app['session']->get('usr_id'))); + $query->setParameters(['usr_id' => $app['session']->get('usr_id')]); $sessions = $query->getResult(); - $result = array(); + $result = []; foreach ($sessions as $session) { $info = ''; try { @@ -302,13 +302,13 @@ class Account implements ControllerProviderInterface } - $result[] = array( + $result[] = [ 'session' => $session, 'info' => $info, - ); + ]; } - return $app['twig']->render('account/sessions.html.twig', array('sessions' => $result)); + return $app['twig']->render('account/sessions.html.twig', ['sessions' => $result]); } /** @@ -320,11 +320,11 @@ class Account implements ControllerProviderInterface */ public function displayAccount(Application $app, Request $request) { - return $app['twig']->render('account/account.html.twig', array( + return $app['twig']->render('account/account.html.twig', [ 'user' => $app['authentication']->getUser(), 'evt_mngr' => $app['events-manager'], 'notifications' => $app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()), - )); + ]); } /** @@ -336,7 +336,7 @@ class Account implements ControllerProviderInterface */ public function updateAccount(PhraseaApplication $app, Request $request) { - $demands = (array) $request->request->get('demand', array()); + $demands = (array) $request->request->get('demand', []); if (0 !== count($demands)) { $register = new \appbox_register($app['phraseanet.appbox']); @@ -351,7 +351,7 @@ class Account implements ControllerProviderInterface } } - $accountFields = array( + $accountFields = [ 'form_gender', 'form_firstname', 'form_lastname', @@ -369,7 +369,7 @@ class Account implements ControllerProviderInterface 'form_destFTP', 'form_prefixFTPfolder', 'form_retryFTP' - ); + ]; if (0 === count(array_diff($accountFields, array_keys($request->request->all())))) { @@ -410,7 +410,7 @@ class Account implements ControllerProviderInterface } } - $requestedNotifications = (array) $request->request->get('notifications', array()); + $requestedNotifications = (array) $request->request->get('notifications', []); foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()) as $notifications) { foreach ($notifications as $notification) { diff --git a/lib/Alchemy/Phrasea/Controller/Root/Developers.php b/lib/Alchemy/Phrasea/Controller/Root/Developers.php index 79a925fe83..a17e2ef8d7 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Developers.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Developers.php @@ -90,7 +90,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -121,7 +121,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -158,7 +158,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error, 'token' => $accessToken)); + return $app->json(['success' => !$error, 'token' => $accessToken]); } /** @@ -184,7 +184,7 @@ class Developers implements ControllerProviderInterface $error = true; } - return $app->json(array('success' => !$error)); + return $app->json(['success' => !$error]); } /** @@ -212,13 +212,13 @@ class Developers implements ControllerProviderInterface ->set_type($form->getType()) ->set_website($form->getSchemeWebsite() . $form->getWebsite()); - return $app->redirectPath('developers_application', array('id' => $application->get_id())); + return $app->redirectPath('developers_application', ['id' => $application->get_id()]); } - $var = array( + $var = [ "violations" => $violations, "form" => $form - ); + ]; return $app['twig']->render('/developers/application_form.html.twig', $var); } @@ -232,9 +232,9 @@ class Developers implements ControllerProviderInterface */ public function listApps(Application $app, Request $request) { - return $app['twig']->render('developers/applications.html.twig', array( + return $app['twig']->render('developers/applications.html.twig', [ "applications" => \API_OAuth2_Application::load_dev_app_by_user($app, $app['authentication']->getUser()) - )); + ]); } /** @@ -246,11 +246,11 @@ class Developers implements ControllerProviderInterface */ public function displayFormApp(Application $app, Request $request) { - return $app['twig']->render('developers/application_form.html.twig', array( + return $app['twig']->render('developers/application_form.html.twig', [ "violations" => null, 'form' => null, 'request' => $request - )); + ]); } /** @@ -271,10 +271,10 @@ class Developers implements ControllerProviderInterface $token = $client->get_user_account($app['authentication']->getUser())->get_token()->get_value(); - return $app['twig']->render('developers/application.html.twig', array( + return $app['twig']->render('developers/application.html.twig', [ "application" => $client, "user" => $app['authentication']->getUser(), "token" => $token - )); + ]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php index 67a6065e4a..2cfb59c44f 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Login.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php @@ -50,21 +50,21 @@ class Login implements ControllerProviderInterface { public static function getDefaultTemplateVariables(Application $app) { - $items = array(); + $items = []; foreach ($app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedItem')->loadLatest($app, 20) as $item) { $record = $item->getRecord($app); $preview = $record->get_subdef('preview'); $permalink = $preview->get_permalink(); - $items[] = array( + $items[] = [ 'record' => $record, 'preview' => $preview, 'permalink' => $permalink - ); + ]; } - return array( + return [ 'last_publication_items' => $items, 'instance_title' => $app['phraseanet.registry']->get('GV_homeTitle'), 'has_terms_of_use' => $app->hasTermsOfUse(), @@ -84,7 +84,7 @@ class Login implements ControllerProviderInterface 'authentication_providers' => $app['authentication.providers'], 'registration_fields' => $app['registration.fields'], 'registration_optional_fields' => $app['registration.optional-fields'] - ); + ]; } public function connect(Application $app) @@ -110,10 +110,10 @@ class Login implements ControllerProviderInterface // then post login operation like getting baskets from an invit session // could be done by Session_handler authentication process - $params = array(); + $params = []; if (null !== $redirect = $request->query->get('redirect')) { - $params = array('redirect' => ltrim($redirect, '/')); + $params = ['redirect' => ltrim($redirect, '/')]; } $response = $app->redirectPath('logout', $params); @@ -203,7 +203,7 @@ class Login implements ControllerProviderInterface // Displays Terms of use $controllers->get('/cgus', function (PhraseaApplication $app, Request $request) { return $app['twig']->render('login/cgus.html.twig', array_merge( - array('cgus' => \databox_cgu::getHome($app)), + ['cgus' => \databox_cgu::getHome($app)], self::getDefaultTemplateVariables($app) )); })->bind('login_cgus'); @@ -216,7 +216,7 @@ class Login implements ControllerProviderInterface public function getLanguage(Application $app, Request $request) { - $response = $app->json(array( + $response = $app->json([ 'validation_blank' => _('Please provide a value.'), 'validation_choice_min' => _('Please select at least %s choice.'), 'validation_email' => _('Please provide a valid email address.'), @@ -234,7 +234,7 @@ class Login implements ControllerProviderInterface 'ordinary' => _('Ordinary'), 'good' => _('Good'), 'great' => _('Great'), - )); + ]); $response->setExpires(new \DateTime('+1 day')); @@ -314,7 +314,7 @@ class Login implements ControllerProviderInterface $selected = isset($data['collections']) ? $data['collections'] : null; } $inscriptions = giveMeBases($app); - $inscOK = array(); + $inscOK = []; foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { @@ -342,7 +342,7 @@ class Login implements ControllerProviderInterface $user = \User_Adapter::create($app, $data['login'], $data['password'], $data['email'], false); - foreach (array( + foreach ([ 'gender' => 'set_gender', 'firstname' => 'set_firstname', 'lastname' => 'set_lastname', @@ -354,9 +354,9 @@ class Login implements ControllerProviderInterface 'company' => 'set_company', 'position' => 'set_position', 'geonameid' => 'set_geonameid', - ) as $property => $method) { + ] as $property => $method) { if (isset($data[$property])) { - call_user_func(array($user, $method), $data[$property]); + call_user_func([$user, $method], $data[$property]); } } @@ -365,7 +365,7 @@ class Login implements ControllerProviderInterface $app['EM']->flush(); } - $demandOK = array(); + $demandOK = []; if ($app['phraseanet.registry']->get('GV_autoregister')) { @@ -373,7 +373,7 @@ class Login implements ControllerProviderInterface $template_user = \User_Adapter::getInstance($template_user_id, $app); - $base_ids = array(); + $base_ids = []; foreach (array_keys($inscOK) as $base_id) { $base_ids[] = $base_id; @@ -395,11 +395,11 @@ class Login implements ControllerProviderInterface $demandOK[$base_id] = true; } - $params = array( + $params = [ 'demand' => $demandOK, 'autoregister' => $autoReg, 'usr_id' => $user->get_id() - ); + ]; $app['events-manager']->trigger('__REGISTER_AUTOREGISTER__', $params); $app['events-manager']->trigger('__REGISTER_APPROVAL__', $params); @@ -423,21 +423,21 @@ class Login implements ControllerProviderInterface $provider = $this->findProvider($app, $request->query->get('providerId')); $identity = $provider->getIdentity(); - $form->setData(array_filter(array( + $form->setData(array_filter([ 'email' => $identity->getEmail(), 'firstname' => $identity->getFirstname(), 'lastname' => $identity->getLastname(), 'company' => $identity->getCompany(), 'provider-id' => $provider->getId(), - ))); + ])); } return $app['twig']->render('login/register-classic.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array( + [ 'geonames_server_uri' => str_replace(sprintf('%s:', parse_url($app['geonames.server-uri'], PHP_URL_SCHEME)), '', $app['geonames.server-uri']), 'form' => $form->createView() - ))); + ])); } private function attachProviderToUser(EntityManager $em, ProviderInterface $provider, \User_Adapter $user) @@ -505,7 +505,7 @@ class Login implements ControllerProviderInterface $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->get_id(), $expire, $user->get_email()); $mail = MailRequestEmailConfirmation::create($app, $receiver); - $mail->setButtonUrl($app->url('login_register_confirm', array('code' => $token))); + $mail->setButtonUrl($app->url('login_register_confirm', ['code' => $token])); $mail->setExpiration($expire); $app['notification.deliverer']->deliver($mail); @@ -589,7 +589,7 @@ class Login implements ControllerProviderInterface } $form = $app->form(new PhraseaRecoverPasswordForm($app)); - $form->setData(array('token' => $token)); + $form->setData(['token' => $token]); if ('POST' === $request->getMethod()) { $form->bind($request); @@ -615,7 +615,7 @@ class Login implements ControllerProviderInterface return $app['twig']->render('login/renew-password.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array('form' => $form->createView()) + ['form' => $form->createView()] )); } @@ -655,7 +655,7 @@ class Login implements ControllerProviderInterface return $app->abort(500, 'Unable to generate a token'); } - $url = $app->url('login_renew_password', array('token' => $token), true); + $url = $app->url('login_renew_password', ['token' => $token], true); $mail = MailRequestPasswordUpdate::create($app, $receiver); $mail->setLogin($user->get_login()); @@ -673,9 +673,9 @@ class Login implements ControllerProviderInterface return $app['twig']->render('login/forgot-password.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array( + [ 'form' => $form->createView(), - ))); + ])); } /** @@ -712,9 +712,9 @@ class Login implements ControllerProviderInterface $app->addFlash('info', _('Vous etes maintenant deconnecte. A bientot.')); - $response = $app->redirectPath('homepage', array( + $response = $app->redirectPath('homepage', [ 'redirect' => $request->query->get("redirect") - )); + ]); $response->headers->clearCookie('persistent'); $response->headers->clearCookie('last_act'); @@ -740,19 +740,19 @@ class Login implements ControllerProviderInterface $app->addFlash('error', _('login::erreur: No available connection - Please contact sys-admin')); } - $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(array('public' => true), array('updatedOn' => 'DESC')); + $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(['public' => true], ['updatedOn' => 'DESC']); $form = $app->form(new PhraseaAuthenticationForm()); - $form->setData(array( + $form->setData([ 'redirect' => $request->query->get('redirect') - )); + ]); return $app['twig']->render('login/index.html.twig', array_merge( self::getDefaultTemplateVariables($app), - array( + [ 'feeds' => $feeds, 'form' => $form->createView(), - ))); + ])); } /** @@ -765,7 +765,7 @@ class Login implements ControllerProviderInterface public function authenticate(PhraseaApplication $app, Request $request) { $form = $app->form(new PhraseaAuthenticationForm()); - $redirector = function (array $params = array()) use ($app) { + $redirector = function (array $params = []) use ($app) { return $app->redirectPath('homepage', $params); }; @@ -847,13 +847,13 @@ class Login implements ControllerProviderInterface continue; } - $app['events-manager']->trigger('__VALIDATION_REMINDER__', array( + $app['events-manager']->trigger('__VALIDATION_REMINDER__', [ 'to' => $participantId, 'ssel_id' => $basketId, 'from' => $validationSession->getInitiatorId(), 'validate_id' => $validationSession->getId(), - 'url' => $app->url('lightbox_validation', array('basket' => $basketId, 'LOG' => $token)), - )); + 'url' => $app->url('lightbox_validation', ['basket' => $basketId, 'LOG' => $token]), + ]); $participant->setReminded(new \DateTime('now')); $app['EM']->persist($participant); @@ -959,7 +959,7 @@ class Login implements ControllerProviderInterface return $app->redirect($redirection); } elseif ($app['registration.enabled']) { - return $app->redirectPath('login_register_classic', array('providerId' => $providerId)); + return $app->redirectPath('login_register_classic', ['providerId' => $providerId]); } $app->addFlash('error', _('Your identity is not recognized.')); @@ -999,7 +999,7 @@ class Login implements ControllerProviderInterface throw new AuthenticationException(call_user_func($redirector)); } - $params = array(); + $params = []; if (null !== $redirect = $request->get('redirect')) { $params['redirect'] = ltrim($redirect, '/'); @@ -1039,7 +1039,7 @@ class Login implements ControllerProviderInterface if ($user->get_id() != $inviteUsrId = $request->cookies->get('invite-usr_id')) { $repo = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); - $baskets = $repo->findBy(array('usr_id' => $inviteUsrId)); + $baskets = $repo->findBy(['usr_id' => $inviteUsrId]); foreach ($baskets as $basket) { $basket->setUsrId($user->get_id()); diff --git a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php index ab3f646e66..cbe408bc7a 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php +++ b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php @@ -67,7 +67,7 @@ class RSSFeeds implements ControllerProviderInterface ->assert('format', '(rss|atom)'); $controllers->get('/userfeed/aggregated/{token}/{format}/', function (Application $app, $token, $format) { - $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(array("value" => $token)); + $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(["value" => $token]); $user = \User_Adapter::getInstance($token->getUsrId(), $app); diff --git a/lib/Alchemy/Phrasea/Controller/Root/Root.php b/lib/Alchemy/Phrasea/Controller/Root/Root.php index 703e2e2b28..41147d861c 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Root.php @@ -52,7 +52,7 @@ class Root implements ControllerProviderInterface $buffer = "User-Agent: *\n" . "Disallow: /\n"; } - return new Response($buffer, 200, array('Content-Type' => 'text/plain')); + return new Response($buffer, 200, ['Content-Type' => 'text/plain']); } public function getRoot(Application $app, Request $request) diff --git a/lib/Alchemy/Phrasea/Controller/Root/Session.php b/lib/Alchemy/Phrasea/Controller/Root/Session.php index 7548beb04b..063db799f2 100644 --- a/lib/Alchemy/Phrasea/Controller/Root/Session.php +++ b/lib/Alchemy/Phrasea/Controller/Root/Session.php @@ -50,12 +50,12 @@ class Session implements ControllerProviderInterface $app->abort(400); } - $ret = array( + $ret = [ 'status' => 'unknown', 'message' => '', 'notifications' => false, - 'changed' => array() - ); + 'changed' => [] + ]; if ($app['authentication']->isAuthenticated()) { $usr_id = $app['authentication']->getUser()->get_id(); @@ -99,9 +99,9 @@ class Session implements ControllerProviderInterface $ret['status'] = 'ok'; - $ret['notifications'] = $app['twig']->render('prod/notifications.html.twig', array( + $ret['notifications'] = $app['twig']->render('prod/notifications.html.twig', [ 'notifications' => $app['events-manager']->get_notifications() - )); + ]); $baskets = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket')->findUnreadActiveByUser($app['authentication']->getUser()); @@ -109,7 +109,7 @@ class Session implements ControllerProviderInterface $ret['changed'][] = $basket->getId(); } - if (in_array($app['session']->get('phraseanet.message'), array('1', null))) { + if (in_array($app['session']->get('phraseanet.message'), ['1', null])) { if ($app['configuration']['main']['maintenance']) { $ret['message'] .= _('The application is going down for maintenance, please logout.'); } @@ -147,10 +147,10 @@ class Session implements ControllerProviderInterface $app['EM']->flush(); if ($app['request']->isXmlHttpRequest()) { - return $app->json(array( + return $app->json([ 'success' => true, 'session_id' => $id - )); + ]); } return $app->redirectPath('account_sessions'); diff --git a/lib/Alchemy/Phrasea/Controller/Setup.php b/lib/Alchemy/Phrasea/Controller/Setup.php index 4b75ae0071..c86ea983d3 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Setup.php @@ -53,37 +53,37 @@ class Setup implements ControllerProviderInterface { $requirementsCollection = $this->getRequirementsCollection(); - return $app['twig']->render('/setup/index.html.twig', array( + return $app['twig']->render('/setup/index.html.twig', [ 'locale' => $app['locale'], 'available_locales' => Application::getAvailableLanguages(), 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/', 'requirementsCollection' => $requirementsCollection, - )); + ]); } private function getRequirementsCollection() { - return array( + return [ new BinariesRequirements(), new FilesystemRequirements(), new LocalesRequirements(), new PhpRequirements(), new PhraseaRequirements(), new SystemRequirements(), - ); + ]; } public function displayUpgradeInstructions(Application $app, Request $request) { - return $app['twig']->render('/setup/upgrade-instructions.html.twig', array( + return $app['twig']->render('/setup/upgrade-instructions.html.twig', [ 'locale' => $app['locale'], 'available_locales' => Application::getAvailableLanguages(), - )); + ]); } public function getInstallForm(Application $app, Request $request) { - $warnings = array(); + $warnings = []; $requirementsCollection = $this->getRequirementsCollection(); @@ -99,16 +99,16 @@ class Setup implements ControllerProviderInterface $warnings[] = _('It is not recommended to install Phraseanet without HTTPS support'); } - return $app['twig']->render('/setup/step2.html.twig', array( + return $app['twig']->render('/setup/step2.html.twig', [ 'locale' => $app['locale'], 'available_locales' => Application::getAvailableLanguages(), - 'available_templates' => array('en', 'fr'), + 'available_templates' => ['en', 'fr'], 'warnings' => $warnings, 'error' => $request->query->get('error'), 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/', 'discovered_binaries' => \setup::discover_binaries(), 'rootpath' => realpath(__DIR__ . '/../../../../'), - )); + ]); } public function doInstall(Application $app, Request $request) @@ -128,21 +128,21 @@ class Setup implements ControllerProviderInterface $databox_name = $request->request->get('db_name'); try { - $abConn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $ab_password, $appbox_name, array(), $app['debug']); + $abConn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $ab_password, $appbox_name, [], $app['debug']); } catch (\Exception $e) { - return $app->redirectPath('install_step2', array( + return $app->redirectPath('install_step2', [ 'error' => _('Appbox is unreachable'), - )); + ]); } try { if ($databox_name) { - $dbConn = new \connection_pdo('databox', $hostname, $port, $user_ab, $ab_password, $databox_name, array(), $app['debug']); + $dbConn = new \connection_pdo('databox', $hostname, $port, $user_ab, $ab_password, $databox_name, [], $app['debug']); } } catch (\Exception $e) { - return $app->redirectPath('install_step2', array( + return $app->redirectPath('install_step2', [ 'error' => _('Databox is unreachable'), - )); + ]); } $email = $request->request->get('email'); @@ -154,8 +154,8 @@ class Setup implements ControllerProviderInterface $installer = $app['phraseanet.installer']; $installer->setPhraseaIndexerPath($request->request->get('binary_phraseanet_indexer')); - $binaryData = array(); - foreach (array( + $binaryData = []; + foreach ([ 'php_binary' => $request->request->get('binary_php'), 'phraseanet_indexer' => $request->request->get('binary_phraseanet_indexer'), 'swf_extract_binary' => $request->request->get('binary_swfextract'), @@ -166,7 +166,7 @@ class Setup implements ControllerProviderInterface 'mp4box_binary' => $request->request->get('binary_MP4Box'), 'pdftotext_binary' => $request->request->get('binary_xpdf'), 'recess_binary' => $request->request->get('binary_recess'), - ) as $key => $path) { + ] as $key => $path) { $binaryData[$key] = $path; } @@ -174,14 +174,14 @@ class Setup implements ControllerProviderInterface $app['authentication']->openAccount($user); - return $app->redirectPath('admin', array( + return $app->redirectPath('admin', [ 'section' => 'taskmanager', 'notice' => 'install_success', - )); + ]); } catch (\Exception $e) { - return $app->redirectPath('install_step2', array( + return $app->redirectPath('install_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 a8e0296653..7479f580b2 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php @@ -104,7 +104,7 @@ class Thesaurus implements ControllerProviderInterface } } - return $app['twig']->render('thesaurus/accept.html.twig', array( + return $app['twig']->render('thesaurus/accept.html.twig', [ 'dlg' => $request->get('dlg'), 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), @@ -117,12 +117,12 @@ class Thesaurus implements ControllerProviderInterface 'fullpath_tgt' => $fullpath_tgt, 'fullpath_src' => $fullpath_src, 'acceptable' => $acceptable, - )); + ]); } public function exportText(Application $app, Request $request) { - $thits = $tnodes = array(); + $thits = $tnodes = []; $output = ''; if (null === $bid = $request->get("bid")) { @@ -167,10 +167,10 @@ class Thesaurus implements ControllerProviderInterface } } - return $app['twig']->render('thesaurus/export-text.html.twig', array( + return $app['twig']->render('thesaurus/export-text.html.twig', [ 'output' => $output, 'smp' => $request->get('smp'), - )); + ]); } private function printTNodes(&$output, &$tnodes, $iln, $hit, $ilg, $osl) @@ -272,29 +272,29 @@ class Thesaurus implements ControllerProviderInterface { if ($node->nodeType == XML_ELEMENT_NODE) { if (($nname = $node->nodeName) == "thesaurus" || $nname == "cterms") { - $tnodes[] = array( + $tnodes[] = [ "type" => "ROOT", "depth" => $depth, "name" => $nname, "cdate" => $node->getAttribute("creation_date"), "mdate" => $node->getAttribute("modification_date") - ); + ]; } elseif (($fld = $node->getAttribute("field"))) { if ($node->getAttribute("delbranch")) { - $tnodes[] = array( + $tnodes[] = [ "type" => "TRASH", "depth" => $depth, "name" => $fld - ); + ]; } else { - $tnodes[] = array( + $tnodes[] = [ "type" => "FIELD", "depth" => $depth, "name" => $fld - ); + ]; } } else { - $tsy = array(); + $tsy = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "sy") { $id = $n->getAttribute("id"); @@ -304,21 +304,21 @@ class Thesaurus implements ControllerProviderInterface $hits = 0; } - $tsy[] = array( + $tsy[] = [ "v" => $n->getAttribute("v"), "lng" => $n->getAttribute("lng"), "hits" => $hits - ); + ]; } } - $tnodes[] = array("type" => "TERM", "depth" => $depth, "syns" => $tsy); + $tnodes[] = ["type" => "TERM", "depth" => $depth, "syns" => $tsy]; } } } private function export0($znode, &$tnodes, &$thits, &$output, $iln, $hit, $ilg, $osl) { - $nodes = array(); + $nodes = []; $depth = 0; for ($node = $znode->parentNode; $node; $node = $node->parentNode) { @@ -349,13 +349,13 @@ class Thesaurus implements ControllerProviderInterface public function exportTextDialog(Application $app, Request $request) { - return $app['twig']->render('thesaurus/export-text-dialog.html.twig', array( + return $app['twig']->render('thesaurus/export-text-dialog.html.twig', [ 'dlg' => $request->get('dlg'), 'bid' => $request->get('bid'), 'typ' => $request->get('typ'), 'piv' => $request->get('piv'), 'id' => $request->get('id'), - )); + ]); } public function exportTopics(Application $app, Request $request) @@ -363,7 +363,7 @@ class Thesaurus implements ControllerProviderInterface $lng = $app['locale']; $obr = explode(';', $request->get('obr')); - $t_lng = array(); + $t_lng = []; if ($request->get('ofm') == 'tofiles') { $t_lng = array_map(function ($code) { @@ -399,7 +399,7 @@ class Thesaurus implements ControllerProviderInterface } $now = date('YmdHis'); - $lngs = array(); + $lngs = []; try { $databox = $app['phraseanet.appbox']->get_databox((int) $request->get("bid")); if ($request->get("typ") == "TH") { @@ -438,7 +438,7 @@ class Thesaurus implements ControllerProviderInterface $this->export0Topics($xpathth->query($q)->item(0), $dom, $root, $lng, $request->get("srt"), $request->get("sth"), $request->get("sand"), $opened_display, $obr); if ($request->get("ofm") == 'toscreen') { - $lngs[$lng] = str_replace(array('&', '<', '>'), array('&', '<', '>'), $dom->saveXML()); + $lngs[$lng] = str_replace(['&', '<', '>'], ['&', '<', '>'], $dom->saveXML()); } elseif ($request->get("ofm") == 'tofiles') { $fname = 'topics_' . $lng . '.xml'; @@ -456,10 +456,10 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/export-topics.html.twig', array( + return $app['twig']->render('thesaurus/export-topics.html.twig', [ 'lngs' => $lngs, 'ofm' => $request->get('ofm'), - )); + ]); } private function export0Topics($znode, \DOMDocument $dom, \DOMNode $root, $lng, $srt, $sth, $sand, $opened_display, $obr) @@ -472,8 +472,8 @@ class Thesaurus implements ControllerProviderInterface { $ntopics = 0; if ($node->nodeType == XML_ELEMENT_NODE) { - $t_node = array(); - $t_sort = array(); + $t_node = []; + $t_sort = []; $i = 0; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "te") { @@ -506,7 +506,7 @@ class Thesaurus implements ControllerProviderInterface } $t_sort[$i] = $query; // tri sur w - $t_node[$i] = array('label' => $label, 'node' => $n); + $t_node[$i] = ['label' => $label, 'node' => $n]; $i ++; } @@ -550,14 +550,14 @@ class Thesaurus implements ControllerProviderInterface public function exportTopicsDialog(Application $app, Request $request) { - return $app['twig']->render('thesaurus/export-topics-dialog.html.twig', array( + return $app['twig']->render('thesaurus/export-topics-dialog.html.twig', [ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), 'dlg' => $request->get('dlg'), 'id' => $request->get('id'), 'obr' => $request->get('obr'), - )); + ]); } public function import(Application $app, Request $request) @@ -584,8 +584,8 @@ class Thesaurus implements ControllerProviderInterface $node->removeChild($node->firstChild); } - $cbad = array(); - $cok = array(); + $cbad = []; + $cok = []; for ($i = 0; $i < 32; $i ++) { $cbad[] = chr($i); $cok[] = '_'; @@ -732,7 +732,7 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/import.html.twig', array('err' => $err)); + return $app['twig']->render('thesaurus/import.html.twig', ['err' => $err]); } private function checkEncoding($string, $string_encoding) @@ -745,12 +745,12 @@ class Thesaurus implements ControllerProviderInterface public function importDialog(Application $app, Request $request) { - return $app['twig']->render('thesaurus/import-dialog.html.twig', array( + return $app['twig']->render('thesaurus/import-dialog.html.twig', [ 'dlg' => $request->get('dlg'), 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), - )); + ]); } public function indexThesaurus(Application $app, Request $request) @@ -770,10 +770,10 @@ class Thesaurus implements ControllerProviderInterface HAVING bas_edit_thesaurus > 0 ORDER BY sbas.ord"; - $bases = $languages = array(); + $bases = $languages = []; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -791,10 +791,10 @@ class Thesaurus implements ControllerProviderInterface $languages[$lng_code[0]] = $lng; } - return $app['twig']->render('thesaurus/index.html.twig', array( + return $app['twig']->render('thesaurus/index.html.twig', [ 'languages' => $languages, 'bases' => $bases, - )); + ]); } public function linkFieldStep1(Application $app, Request $request) @@ -830,7 +830,7 @@ class Thesaurus implements ControllerProviderInterface $fullBranch = " / " . $sy . $fullBranch; } } - $fieldnames = array(); + $fieldnames = []; $nodes = $xpathstruct->query("/record/description/*"); for ($i = 0; $i < $nodes->length; $i ++) { $fieldname = $nodes->item($i)->nodeName; @@ -852,13 +852,13 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/link-field-step1.html.twig', array( + return $app['twig']->render('thesaurus/link-field-step1.html.twig', [ 'piv' => $request->get('piv'), 'bid' => $request->get('bid'), 'tid' => $request->get('tid'), 'fullBranch' => $fullBranch, 'fieldnames' => $fieldnames - )); + ]); } public function linkFieldStep2(Application $app, Request $request) @@ -867,7 +867,7 @@ class Thesaurus implements ControllerProviderInterface return new Response('Missing bid parameter', 400); } - $oldlinks = array(); + $oldlinks = []; $needreindex = false; try { @@ -884,7 +884,7 @@ class Thesaurus implements ControllerProviderInterface $fieldname = $nodes->item($i)->nodeName; $oldbranch = $nodes->item($i)->getAttribute("tbranch"); $ck = false; - $tids = array(); // les ids de branches liees e ce champ + $tids = []; // les ids de branches liees e ce champ if ($oldbranch) { // ce champ a deje un tbranch, on balaye les branches auxquelles il est lie $thnodes = $xpathth->query($oldbranch); @@ -900,7 +900,7 @@ class Thesaurus implements ControllerProviderInterface } } - if (in_array($fieldname, $request->get('field', array())) != $ck) { + if (in_array($fieldname, $request->get('field', [])) != $ck) { if ($ck) { // print("il etait lie a la branche, il ne l'est plus
\n"); unset($tids[$request->get('tid')]); @@ -922,10 +922,10 @@ class Thesaurus implements ControllerProviderInterface } } - $oldlinks[$fieldname] = array( + $oldlinks[$fieldname] = [ 'old_branch' => $oldbranch, 'new_branch' => $newtbranch - ); + ]; if ($newtbranch != "") { $needreindex = true; @@ -937,13 +937,13 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/link-field-step2.html.twig', array( + return $app['twig']->render('thesaurus/link-field-step2.html.twig', [ 'piv' => $request->get('piv'), 'bid' => $request->get('bid'), 'tid' => $request->get('tid'), 'oldlinks' => $oldlinks, 'need_reindex' => $needreindex, - )); + ]); } public function linkFieldStep3(Application $app, Request $request) @@ -963,15 +963,15 @@ class Thesaurus implements ControllerProviderInterface $xpathct = new \DOMXPath($domct); $ctchanged = false; - $candidates2del = array(); - foreach ($request->get("f2unlk", array()) as $f2unlk) { + $candidates2del = []; + foreach ($request->get("f2unlk", []) as $f2unlk) { $q = "/cterms/te[@field='" . \thesaurus::xquery_escape($f2unlk) . "']"; $nodes = $xpathct->query($q); for ($i = 0; $i < $nodes->length; $i ++) { - $candidates2del[] = array( + $candidates2del[] = [ "field" => $f2unlk, "node" => $nodes->item($i) - ); + ]; } $field = $meta_struct->get_element_by_name($f2unlk); @@ -984,7 +984,7 @@ class Thesaurus implements ControllerProviderInterface $ctchanged = true; } - foreach ($request->get("fbranch", array()) as $fbranch) { + foreach ($request->get("fbranch", []) as $fbranch) { $p = strpos($fbranch, "<"); if ($p > 1) { $fieldname = substr($fbranch, 0, $p); @@ -1003,8 +1003,8 @@ class Thesaurus implements ControllerProviderInterface $sql = "DELETE FROM thit WHERE name = :name"; $stmt = $connbas->prepare($sql); - foreach ($request->get("f2unlk", array()) as $f2unlk) { - $stmt->execute(array(':name' => $f2unlk)); + foreach ($request->get("f2unlk", []) as $f2unlk) { + $stmt->execute([':name' => $f2unlk]); } $stmt->closeCursor(); @@ -1018,13 +1018,13 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/link-field-step3.html.twig', array( - 'field2del' => $request->get('f2unlk', array()), + return $app['twig']->render('thesaurus/link-field-step3.html.twig', [ + 'field2del' => $request->get('f2unlk', []), 'candidates2del' => $candidates2del, - 'branch2del' => $request->get('fbranch', array()), + 'branch2del' => $request->get('fbranch', []), 'ctchanged' => $ctchanged, 'reindexed' => $request->get('reindex'), - )); + ]); } private function fixThesaurus($app, \DOMDocument $domct, \DOMDocument $domth, \connection_interface $connbas) @@ -1057,7 +1057,7 @@ class Thesaurus implements ControllerProviderInterface $updated = false; $validThesaurus = true; - $ctlist = array(); + $ctlist = []; $name = \phrasea::sbas_labels($request->get('bid'), $app); try { @@ -1092,10 +1092,10 @@ class Thesaurus implements ControllerProviderInterface for ($ct = $domct->documentElement->firstChild; $ct; $ct = $ct->nextSibling) { if ($ct->nodeName == "te") { - $ctlist[] = array( + $ctlist[] = [ 'id' => $ct->getAttribute("id"), 'field' => $ct->getAttribute("field") - ); + ]; } } } else { @@ -1105,29 +1105,29 @@ class Thesaurus implements ControllerProviderInterface } - return $app['twig']->render('thesaurus/load-thesaurus.html.twig', array( + return $app['twig']->render('thesaurus/load-thesaurus.html.twig', [ 'bid' => $request->get('bid'), 'name' => $name, 'cterms' => $ctlist, 'valid_thesaurus' => $validThesaurus, 'updated' => $updated - )); + ]); } public function newSynonymDialog(Application $app, Request $request) { - $languages = array(); + $languages = []; foreach ($app['locales.available'] as $lng_code => $lng) { $lng_code = explode('_', $lng_code); $languages[$lng_code[0]] = $lng; } - return $app['twig']->render('thesaurus/new-synonym-dialog.html.twig', array( + return $app['twig']->render('thesaurus/new-synonym-dialog.html.twig', [ 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), 'languages' => $languages, - )); + ]); } @@ -1152,17 +1152,17 @@ class Thesaurus implements ControllerProviderInterface $nb_candidates_bad ++; } } - $candidates_list = array(); + $candidates_list = []; for ($i = 0; $i < $candidates->length; $i ++) { if ($candidates->item($i)->getAttribute("sourceok") == "1") { - $candidates_list = array( + $candidates_list = [ 'id' => $candidates->item($i)->getAttribute("id"), 'field' => $candidates->item($i)->getAttribute("field"), - ); + ]; } } - return $app['twig']->render('thesaurus/new-term.html.twig', array( + return $app['twig']->render('thesaurus/new-term.html.twig', [ 'typ' => $request->get('typ'), 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), @@ -1174,7 +1174,7 @@ class Thesaurus implements ControllerProviderInterface 'context' => $context, 'nb_candidates_ok' => $nb_candidates_ok, 'nb_candidates_bad' => $nb_candidates_bad, - )); + ]); } public function properties(Application $app, Request $request) @@ -1183,16 +1183,16 @@ class Thesaurus implements ControllerProviderInterface $fullpath = $dom->getElementsByTagName("fullpath_html")->item(0)->firstChild->nodeValue; $hits = $dom->getElementsByTagName("allhits")->item(0)->firstChild->nodeValue; - $languages = $synonyms = array(); + $languages = $synonyms = []; $sy_list = $dom->getElementsByTagName("sy_list")->item(0); for ($n = $sy_list->firstChild; $n; $n = $n->nextSibling) { - $synonyms[] = array( + $synonyms[] = [ 'id' => $n->getAttribute("id"), 'lng' => $n->getAttribute("lng"), 't' => $n->getAttribute("t"), 'hits' => $n->getAttribute("hits"), - ); + ]; } foreach ($app['locales.available'] as $code => $language) { @@ -1200,7 +1200,7 @@ class Thesaurus implements ControllerProviderInterface $languages[$lng_code[0]] = $language; } - return $app['twig']->render('thesaurus/properties.html.twig', array( + return $app['twig']->render('thesaurus/properties.html.twig', [ 'typ' => $request->get('typ'), 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), @@ -1210,7 +1210,7 @@ class Thesaurus implements ControllerProviderInterface 'fullpath' => $fullpath, 'hits' => $hits, 'synonyms' => $synonyms, - )); + ]); } public function search(Application $app, Request $request) @@ -1220,21 +1220,21 @@ class Thesaurus implements ControllerProviderInterface public function thesaurus(Application $app, Request $request) { - $flags = $jsFlags = array(); + $flags = $jsFlags = []; foreach ($app['locales.available'] as $code => $language) { $lng_code = explode('_', $code); $flags[$lng_code[0]] = $language; - $jsFlags[$lng_code[0]] = array('w' => 18, 'h' => 13); + $jsFlags[$lng_code[0]] = ['w' => 18, 'h' => 13]; } $jsFlags = json_encode($jsFlags); - return $app['twig']->render('thesaurus/thesaurus.html.twig', array( + return $app['twig']->render('thesaurus/thesaurus.html.twig', [ 'piv' => $request->get('piv'), 'bid' => $request->get('bid'), 'flags' => $flags, 'jsFlags' => $jsFlags, - )); + ]); } @@ -1245,11 +1245,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "piv" => $request->get('piv'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1279,7 +1279,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function acceptBranch(Application $app, $sbas_id, \DOMElement $node) @@ -1295,10 +1295,10 @@ class Thesaurus implements ControllerProviderInterface try { $connbas = \connection::getPDOConnection($app, $sbas_id); $stmt = $connbas->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':thit_new' => $thit_newid, 'thit_old' => $thit_oldid - )); + ]); $stmt->closeCursor(); } catch (\Exception $e) { @@ -1318,13 +1318,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'cid' => $request->get('cid'), 'pid' => $request->get('pid'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1368,7 +1368,7 @@ class Thesaurus implements ControllerProviderInterface $oldid = $ct->getAttribute("id"); $te = $domth->importNode($ct, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { $pid = "T" . $nid; @@ -1388,7 +1388,7 @@ class Thesaurus implements ControllerProviderInterface WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); if ($icid == 0) { // on update la destination une seule fois @@ -1417,7 +1417,7 @@ class Thesaurus implements ControllerProviderInterface $oldid = $ct2->getAttribute("id"); $te = $domth->importNode($ct2, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { $pid = "T" . $nid; } else { @@ -1436,7 +1436,7 @@ class Thesaurus implements ControllerProviderInterface WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); $thchanged = true; @@ -1468,7 +1468,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function renumerate($node, $id, &$chgids, $depth = 0) @@ -1491,13 +1491,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'newlng' => $request->get('cid'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -1542,7 +1542,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function changeSynonymPositionXml(Application $app, Request $request) @@ -1552,13 +1552,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'dir' => $request->get('dir'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -1609,7 +1609,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function removeNoHitXml(Application $app, Request $request) @@ -1619,13 +1619,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'piv' => $request->get('piv'), 'id' => $request->get('id'), 'pid' => $request->get('pid'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -1665,7 +1665,7 @@ class Thesaurus implements ControllerProviderInterface } if (($znode = $xpath->query($q)->item(0))) { - $nodestodel = array(); + $nodestodel = []; $root->setAttribute('n_nohits', (string) $this->doDeleteNohits($znode, $s_thits, $nodestodel)); foreach ($nodestodel as $n) { $n->parentNode->removeChild($n); @@ -1680,7 +1680,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function doDeleteNohits($node, &$s_thits, &$nodestodel) @@ -1713,12 +1713,12 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1800,10 +1800,10 @@ class Thesaurus implements ControllerProviderInterface $sql = "UPDATE thit SET value = :new_id WHERE value = :old_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':new_id' => $sql_newid, ':old_id' => $sql_oldid)); + $stmt->execute([':new_id' => $sql_newid, ':old_id' => $sql_oldid]); $stmt->closeCursor(); - $sql = array(); + $sql = []; $databox->saveCterms($domct); if ($request->get('typ') == "CT") { @@ -1837,7 +1837,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function removeSpecificTermXml(Application $app, Request $request) @@ -1847,11 +1847,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -1872,7 +1872,7 @@ class Thesaurus implements ControllerProviderInterface $thnode = $xpathth->query($q)->item(0); if ($thnode) { - $chgids = array(); + $chgids = []; $pid = $thnode->parentNode->getAttribute("id"); if ($pid === "") { $pid = "T"; @@ -1917,7 +1917,7 @@ class Thesaurus implements ControllerProviderInterface WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); $thnode->parentNode->removeChild($thnode); @@ -1934,7 +1934,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function getHtmlBranchXml(Application $app, Request $request) @@ -1944,11 +1944,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement("html")); @@ -1985,7 +1985,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function formatHTMLBranch($srcnode, $dstdom, $dstnode, $depth) @@ -2027,7 +2027,7 @@ class Thesaurus implements ControllerProviderInterface $allsy = "THESAURUS"; } - return array("allsy" => $allsy, "nts" => $nts); + return ["allsy" => $allsy, "nts" => $nts]; } public function getSynonymXml(Application $app, Request $request) @@ -2037,11 +2037,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'typ' => $request->get('typ'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -2083,7 +2083,7 @@ class Thesaurus implements ControllerProviderInterface $sy = $root->appendchild($ret->createElement("sy")); $sy->setAttribute("t", $t); - foreach (array("v", "w", "k", "lng", "id") as $a) { + foreach (["v", "w", "k", "lng", "id"] as $a) { if ($nodes->item(0)->hasAttribute($a)) { $sy->setAttribute($a, $nodes->item(0)->getAttribute($a)); } @@ -2134,7 +2134,7 @@ class Thesaurus implements ControllerProviderInterface $sql = "SELECT COUNT(DISTINCT(record_id)) AS hits FROM thit WHERE value = :id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $id)); + $stmt->execute([':id' => $id]); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2149,7 +2149,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function getTermXml(Application $app, Request $request) @@ -2159,7 +2159,7 @@ class Thesaurus implements ControllerProviderInterface $request->get('piv'), $request->get('sortsy'), $request->get('sel'), $request->get('nots'), $request->get('acf'))->saveXML(), 200, - array('Content-Type' => 'text/xml') + ['Content-Type' => 'text/xml'] ); } @@ -2170,7 +2170,7 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $bid, "id" => $id, "typ" => $typ, @@ -2179,7 +2179,7 @@ class Thesaurus implements ControllerProviderInterface "sel" => $sel, "nots" => $nots, "acf" => $acf, - ), true))); + ], true))); $cfield = $root->appendChild($ret->createElement("cfield")); $ts_list = $root->appendChild($ret->createElement("ts_list")); @@ -2232,7 +2232,7 @@ class Thesaurus implements ControllerProviderInterface $root->setAttribute('found', '' . $nodes->length); if ($nodes->length > 0) { $nts = 0; - $tts = array(); + $tts = []; // on dresse la liste des termes specifiques avec comme cle le synonyme // dans la langue pivot for ($n = $nodes->item(0)->firstChild; $n; $n = $n->nextSibling) { @@ -2276,17 +2276,17 @@ class Thesaurus implements ControllerProviderInterface break; } } - $tts[$realksy . "_" . $uniq] = array( + $tts[$realksy . "_" . $uniq] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length - ); + ]; } else { - $tts[] = array( + $tts[] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length - ); + ]; } } } elseif ($n->nodeName == "sy") { @@ -2297,7 +2297,7 @@ class Thesaurus implements ControllerProviderInterface FROM thit WHERE value = :id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $value_id)); + $stmt->execute([':id' => $value_id]); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2395,7 +2395,7 @@ class Thesaurus implements ControllerProviderInterface FROM thit WHERE value = :id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $value_id)); + $stmt->execute([':id' => $value_id]); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2411,7 +2411,7 @@ class Thesaurus implements ControllerProviderInterface FROM thit WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $value_id . '%')); + $stmt->execute([':like' => $value_id . '%']); $rowbas2 = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -2438,12 +2438,12 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), 'typ' => $request->get('typ'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2479,7 +2479,7 @@ class Thesaurus implements ControllerProviderInterface $sql = "DELETE FROM thit WHERE value LIKE :like"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $xml_oldid . '%')); + $stmt->execute([':like' => $xml_oldid . '%']); $stmt->closeCursor(); if ($request->get('typ') == "CT") { @@ -2511,7 +2511,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function newSynonymXml(Application $app, Request $request) @@ -2521,14 +2521,14 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "pid" => $request->get('pid'), "piv" => $request->get('piv'), "sylng" => $request->get('sylng'), "t" => $request->get('t'), "k" => $request->get('k'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2598,7 +2598,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function splitTermAndContext($word) @@ -2612,7 +2612,7 @@ class Thesaurus implements ControllerProviderInterface } } - return array($term, $context); + return [$term, $context]; } public function newSpecificTermXml(Application $app, Request $request) @@ -2622,14 +2622,14 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "pid" => $request->get('pid'), "t" => $request->get('t'), "k" => $request->get('k'), "sylng" => $request->get('sylng'), "reindex" => $request->get('reindex'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2709,7 +2709,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function openBranchesXml(Application $app, Request $request) @@ -2719,13 +2719,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "typ" => $request->get('typ'), "t" => $request->get('t'), "method" => $request->get('method'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement("html")); @@ -2795,7 +2795,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function getBranchHTML($type, $srcnode, $dstdom, $dstnode, $depth) @@ -2843,7 +2843,7 @@ class Thesaurus implements ControllerProviderInterface } } - return array("allsy" => $allsy, "nts" => $nts); + return ["allsy" => $allsy, "nts" => $nts]; } public function RejectXml(Application $app, Request $request) @@ -2853,11 +2853,11 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), 'piv' => $request->get('piv'), - ), true))); + ], true))); $refresh_list = $root->appendChild($ret->createElement("refresh_list")); @@ -2890,7 +2890,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function doRejectBranch(\connection_pdo $connbas, \DOMElement $node) @@ -2902,7 +2902,7 @@ class Thesaurus implements ControllerProviderInterface $thit_newid = str_replace(".", "d", $newid) . "d"; $sql = "UPDATE thit SET value = :new_value WHERE value = :old_value"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':old_value' => $thit_oldid, ':new_value' => $thit_newid)); + $stmt->execute([':old_value' => $thit_oldid, ':new_value' => $thit_newid]); $stmt->closeCursor(); } for ($n = $node->firstChild; $n; $n = $n->nextSibling) { @@ -2920,7 +2920,7 @@ class Thesaurus implements ControllerProviderInterface $ret = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $request->get('t'), $request->get('k'), $request->get('piv')); - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function doSearchCandidate(Application $app, $bid, $pid, $t, $k, $piv) @@ -2930,13 +2930,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $bid, "pid" => $pid, "t" => $t, "k" => $k, "piv" => $piv, - ), true))); + ], true))); $ctlist = $root->appendChild($ret->createElement("candidates_list")); @@ -2952,7 +2952,7 @@ class Thesaurus implements ControllerProviderInterface $xpathct = new \DOMXPath($domct); // on cherche les champs d'oe peut provenir un candidat, en fct de l'endroit oe on veut inserer le nouveau terme - $fields = array(); + $fields = []; $xpathstruct = new \DOMXPath($domstruct); $nodes = $xpathstruct->query("/record/description/*[@tbranch]"); for ($i = 0; $i < $nodes->length; $i ++) { @@ -2964,12 +2964,12 @@ class Thesaurus implements ControllerProviderInterface $q = "(" . $tbranch . ")/descendant-or-self::te[not(@id)]"; } - $fields[$fieldname] = array( + $fields[$fieldname] = [ "name" => $fieldname, "tbranch" => $tbranch, "cid" => null, "sourceok" => false - ); + ]; if (! $tbranch) { continue; @@ -2987,12 +2987,12 @@ class Thesaurus implements ControllerProviderInterface } } // on considere que la source 'deleted' est toujours valide - $fields["[deleted]"] = array( + $fields["[deleted]"] = [ "name" => _('thesaurus:: corbeille'), "tbranch" => null, "cid" => null, "sourceok" => true - ); + ]; if (count($fields) > 0) { $q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'"; @@ -3045,13 +3045,13 @@ class Thesaurus implements ControllerProviderInterface $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "pid" => $request->get('pid'), 'typ' => $request->get('typ'), 'id' => $request->get('id'), "piv" => $request->get('piv'), - ), true))); + ], true))); if (null === $bid = $request->get("bid")) { return new Response('Missing bid parameter', 400); @@ -3097,7 +3097,7 @@ class Thesaurus implements ControllerProviderInterface } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } private function countNohits($node, &$s_thits) diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php index 0b03012c7e..bcfd31a7b6 100644 --- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php +++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php @@ -56,8 +56,8 @@ class Xmlhttp implements ControllerProviderInterface public function AcceptCandidatesJson(Application $app, Request $request) { - $ret = array('refresh' => array()); - $refresh = array(); + $ret = ['refresh' => []]; + $refresh = []; $sbas_id = $request->get('sbid'); @@ -107,7 +107,7 @@ class Xmlhttp implements ControllerProviderInterface $oldid = $ct->getAttribute("id"); $te = $domth->importNode($ct, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { $pid = "T" . $nid; } else { @@ -133,24 +133,24 @@ class Xmlhttp implements ControllerProviderInterface printf("soldid=%s ; snewid=%s
\nsql=%s
\n", $soldid, $snewid, $sql); } else { $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); } $refreshid = $parentnode->getAttribute('id'); - $refresh['T' . $refreshid] = array( + $refresh['T' . $refreshid] = [ 'type' => 'T', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $thchanged = true; $refreshid = $ct->parentNode->getAttribute("id"); - $refresh['C' . $refreshid] = array( + $refresh['C' . $refreshid] = [ 'type' => 'C', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $ct->parentNode->removeChild($ct); @@ -166,7 +166,7 @@ class Xmlhttp implements ControllerProviderInterface $oldid = $ct2->getAttribute("id"); $te = $domth->importNode($ct2, true); - $chgids = array(); + $chgids = []; if (($pid = $parentnode->getAttribute("id")) == "") { // racine $pid = "T" . $nid; @@ -193,7 +193,7 @@ class Xmlhttp implements ControllerProviderInterface printf("soldid=%s ; snewid=%s
\nsql=%s
\n", $soldid, $snewid, $sql); } else { $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $soldid . '%')); + $stmt->execute([':like' => $soldid . '%']); $stmt->closeCursor(); } @@ -201,18 +201,18 @@ class Xmlhttp implements ControllerProviderInterface } $refreshid = $parentnode->parentNode->getAttribute("id"); - $refresh['T' . $refreshid] = array( + $refresh['T' . $refreshid] = [ 'type' => 'T', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $refreshid = $ct->parentNode->getAttribute("id"); - $refresh['C' . $refreshid] = array( + $refresh['C' . $refreshid] = [ 'type' => 'C', 'sbid' => $sbas_id, 'id' => $refreshid - ); + ]; $ct->parentNode->removeChild($ct); $ctchanged = true; @@ -255,7 +255,7 @@ class Xmlhttp implements ControllerProviderInterface public function CheckCandidateTargetJson(Application $app, Request $request) { - $json = array(); + $json = []; if (null === $sbas_id = $request->get("sbid")) { return $app->json($json); @@ -362,14 +362,14 @@ class Xmlhttp implements ControllerProviderInterface { $usr_id = $app['authentication']->getUser()->get_id(); - $ret = array('parm' => array( + $ret = ['parm' => [ 'act' => $request->get('act'), 'sbas' => $request->get('sbas'), 'presetid' => $request->get('presetid'), 'title' => $request->get('title'), 'f' => $request->get('f'), 'debug' => $request->get('debug'), - )); + ]]; switch ($request->get('act')) { case 'DELETE': @@ -377,10 +377,10 @@ class Xmlhttp implements ControllerProviderInterface WHERE edit_preset_id = :editpresetid AND usr_id = :usr_id'; - $params = array( + $params = [ ':editpresetid' => $request->get('presetid'), ':usr_id' => $usr_id - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -402,12 +402,12 @@ class Xmlhttp implements ControllerProviderInterface VALUES (NOW(), :sbas_id, :usr_id, :title, :presets)'; - $params = array( + $params = [ ':sbas_id' => $request->get('sbas'), ':usr_id' => $usr_id, ':title' => $request->get('title'), ':presets' => $dom->saveXML(), - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -424,15 +424,15 @@ class Xmlhttp implements ControllerProviderInterface WHERE edit_preset_id = :edit_preset_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':edit_preset_id' => $request->get('presetid'))); + $stmt->execute([':edit_preset_id' => $request->get('presetid')]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $fields = array(); + $fields = []; if ($row && ($sx = simplexml_load_string($row['xml']))) { foreach ($sx->fields->children() as $fn => $fv) { if (!array_key_exists($fn, $fields)) { - $fields[$fn] = array(); + $fields[$fn] = []; } $fields[$fn][] = trim($fv); } @@ -456,10 +456,10 @@ class Xmlhttp implements ControllerProviderInterface ORDER BY creation_date ASC'; $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':sbas_id' => $sbas_id, ':usr_id' => $usr_id, - )); + ]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -467,7 +467,7 @@ class Xmlhttp implements ControllerProviderInterface if (!($sx = simplexml_load_string($row['xml']))) { continue; } - $t_desc = array(); + $t_desc = []; foreach ($sx->fields->children() as $fn => $fv) { if (!array_key_exists($fn, $t_desc)) { $t_desc[$fn] = trim($fv); @@ -477,7 +477,7 @@ class Xmlhttp implements ControllerProviderInterface } $desc = ''; foreach ($t_desc as $fn => $fv) { - $desc .= '

' . $fn . ': ' . str_replace(array('&', '<', '>'), array('&', '<', '>'), $fv) . '

' . "\n"; + $desc .= '

' . $fn . ': ' . str_replace(['&', '<', '>'], ['&', '<', '>'], $fv) . '

' . "\n"; } ob_start(); @@ -505,10 +505,10 @@ class Xmlhttp implements ControllerProviderInterface $ret->standalone = true; $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 'id' => $request->get('id'), - ), true))); + ], true))); if (null !== $request->get('bid')) { @@ -527,7 +527,7 @@ class Xmlhttp implements ControllerProviderInterface } } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function GetTermHtml(Application $app, Request $request) @@ -560,14 +560,14 @@ class Xmlhttp implements ControllerProviderInterface $nodes = $xpath->query($q); if ($nodes->length > 0) { $nts = 0; - $tts = array(); + $tts = []; // on dresse la liste des termes specifiques avec comme cle le synonyme // dans la langue pivot for ($n = $nodes->item(0)->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "te") { $nts++; $allsy = ""; - $tsy = array(); + $tsy = []; $firstksy = null; $ksy = $realksy = null; // on liste les sy pour fabriquer la cle @@ -587,16 +587,16 @@ class Xmlhttp implements ControllerProviderInterface $realksy = $ksy; $allsy = $t . ($allsy ? " ; " : "") . $allsy; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } else { $allsy .= ( $allsy ? " ; " : "") . $t; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } } } @@ -609,19 +609,19 @@ class Xmlhttp implements ControllerProviderInterface break; } } - $tts[$realksy . "_" . $uniq] = array( + $tts[$realksy . "_" . $uniq] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } else { - $tts[] = array( + $tts[] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } } elseif ($n->nodeName == "sy") { @@ -671,12 +671,12 @@ class Xmlhttp implements ControllerProviderInterface $ret->standalone = true; $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement("result")); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ "bid" => $request->get('bid'), "id" => $request->get('id'), "sortsy" => $request->get('sortsy'), "debug" => $request->get('debug'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement("html")); @@ -705,14 +705,14 @@ class Xmlhttp implements ControllerProviderInterface $nodes = $xpath->query($q); if ($nodes->length > 0) { $nts = 0; - $tts = array(); + $tts = []; // on dresse la liste des termes specifiques avec comme cle le synonyme // dans la langue pivot for ($n = $nodes->item(0)->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "te") { $nts++; $allsy = ""; - $tsy = array(); + $tsy = []; $firstksy = null; $ksy = $realksy = null; // on liste les sy pour fabriquer la cle @@ -733,16 +733,16 @@ class Xmlhttp implements ControllerProviderInterface $realksy = $ksy; $allsy = $t . ($allsy ? " ; " : "") . $allsy; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } else { $allsy .= ( $allsy ? " ; " : "") . $t; - array_push($tsy, array( + array_push($tsy, [ "id" => $n2->getAttribute("id"), "sy" => $t - )); + ]); } } } @@ -755,19 +755,19 @@ class Xmlhttp implements ControllerProviderInterface break; } } - $tts[$realksy . "_" . $uniq] = array( + $tts[$realksy . "_" . $uniq] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } else { - $tts[] = array( + $tts[] = [ "id" => $n->getAttribute("id"), "allsy" => $allsy, "nchild" => $xpath->query("te", $n)->length, "tsy" => $tsy - ); + ]; } } elseif ($n->nodeName == "sy") { @@ -810,7 +810,7 @@ class Xmlhttp implements ControllerProviderInterface $html->appendChild($ret->createTextNode($zhtml)); } - return new Response($ret->saveXML(), 200, array('Content-Type' => 'text/xml')); + return new Response($ret->saveXML(), 200, ['Content-Type' => 'text/xml']); } public function OpenBranchJson(Application $app, Request $request) @@ -833,7 +833,7 @@ class Xmlhttp implements ControllerProviderInterface $connbas = \connection::getPDOConnection($app, $sbid); $dbname = \phrasea::sbas_labels($sbid, $app); - $t_nrec = array(); + $t_nrec = []; $lthid = strlen($thid); // count occurences @@ -844,7 +844,7 @@ class Xmlhttp implements ControllerProviderInterface FROM thit WHERE value LIKE :like '; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -860,7 +860,7 @@ class Xmlhttp implements ControllerProviderInterface GROUP BY k'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -877,7 +877,7 @@ class Xmlhttp implements ControllerProviderInterface GROUP BY k'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -893,7 +893,7 @@ class Xmlhttp implements ControllerProviderInterface GROUP BY k'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':like' => $dthid . '%')); + $stmt->execute([':like' => $dthid . '%']); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -948,7 +948,7 @@ class Xmlhttp implements ControllerProviderInterface // on dresse la liste des termes specifiques avec comme cle le synonyme dans la langue pivot $nts = 0; - $tts = array(); + $tts = []; for ($n = $node0->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == 'te' && !$n->getAttribute('delbranch') && substr($n->getAttribute('id'), 0, 1) != 'R') { $nts++; @@ -963,11 +963,11 @@ class Xmlhttp implements ControllerProviderInterface break; } } - $tts[$key0 . '_' . $uniq] = array( + $tts[$key0 . '_' . $uniq] = [ 'label' => $label, 'nts' => $nts0, 'n' => $n - ); + ]; } } @@ -1027,7 +1027,7 @@ class Xmlhttp implements ControllerProviderInterface } - return $app->json(array('parm' => array( + return $app->json(['parm' => [ 'sbid' => $request->get('sbid'), 'type' => $request->get('type'), 'id' => $request->get('id'), @@ -1036,7 +1036,7 @@ class Xmlhttp implements ControllerProviderInterface 'debug' => $request->get('debug'), 'root' => $request->get('root'), 'last' => $request->get('last'), - ), 'html' => $html)); + ], 'html' => $html]); } private function buildBranchLabel($dbname, $language, $n, &$key0, &$nts0) @@ -1165,7 +1165,7 @@ class Xmlhttp implements ControllerProviderInterface } } - return array($term, $context); + return [$term, $context]; } private function getBranchesHTML($bid, $srcnode, &$html, $depth) @@ -1230,12 +1230,12 @@ class Xmlhttp implements ControllerProviderInterface $ret->standalone = true; $ret->preserveWhiteSpace = false; $root = $ret->appendChild($ret->createElement('result')); - $root->appendChild($ret->createCDATASection(var_export(array( + $root->appendChild($ret->createCDATASection(var_export([ 'bid' => $request->get('bid'), 't' => $request->get('t'), 'mod' => $request->get('mod'), 'debug' => $request->get('debug'), - ), true))); + ], true))); $html = $root->appendChild($ret->createElement('html')); @@ -1288,7 +1288,7 @@ class Xmlhttp implements ControllerProviderInterface $html->appendChild($ret->createTextNode($zhtml)); } - return new Response($zhtml, 200, array('Content-Type' => 'text/xml')); + return new Response($zhtml, 200, ['Content-Type' => 'text/xml']); } private function getBrancheXML($bid, $srcnode, &$html, $depth) @@ -1344,28 +1344,28 @@ class Xmlhttp implements ControllerProviderInterface public function ReplaceCandidateJson(Application $app, Request $request) { - $tsbas = array(); + $tsbas = []; - $ret = array( - 'ctermsDeleted' => array(), + $ret = [ + 'ctermsDeleted' => [], 'maxRecsUpdatable' => self::SEARCH_REPLACE_MAXREC, 'nRecsToUpdate' => 0, 'nRecsUpdated' => 0, 'msg' => '' - ); + ]; foreach ($request->get('id') as $id) { $id = explode('.', $id); $sbas_id = array_shift($id); if (!array_key_exists('b' . $sbas_id, $tsbas)) { - $tsbas['b' . $sbas_id] = array( + $tsbas['b' . $sbas_id] = [ 'sbas_id' => (int) $sbas_id, - 'tids' => array(), + 'tids' => [], 'domct' => null, - 'tvals' => array(), + 'tvals' => [], 'lid' => '', - 'trids' => array() - ); + 'trids' => [] + ]; } $tsbas['b' . $sbas_id]['tids'][] = implode('.', $id); } @@ -1402,7 +1402,7 @@ class Xmlhttp implements ControllerProviderInterface $field = $sy->parentNode->parentNode->getAttribute('field'); if (!array_key_exists($field, $tsbas[$ksbas]['tvals'])) { - $tsbas[$ksbas]['tvals'][$field] = array(); + $tsbas[$ksbas]['tvals'][$field] = []; } $tsbas[$ksbas]['tvals'][$field][] = $sy; } @@ -1443,8 +1443,8 @@ class Xmlhttp implements ControllerProviderInterface try { $record = $databox->get_record($rid); - $metadatask = array(); // datas to keep - $metadatasd = array(); // datas to delete + $metadatask = []; // datas to keep + $metadatasd = []; // datas to delete /* @var $field caption_field */ foreach ($record->get_caption()->get_fields(null, true) as $field) { @@ -1453,11 +1453,11 @@ class Xmlhttp implements ControllerProviderInterface $fname = $field->get_name(); if (!array_key_exists($fname, $sbas['tvals'])) { foreach ($field->get_values() as $v) { - $metadatask[] = array( + $metadatask[] = [ 'meta_struct_id' => $meta_struct_id, 'meta_id' => $v->getId(), 'value' => $v->getValue() - ); + ]; } } else { foreach ($field->get_values() as $v) { @@ -1470,17 +1470,17 @@ class Xmlhttp implements ControllerProviderInterface } if ($keep) { - $metadatask[] = array( + $metadatask[] = [ 'meta_struct_id' => $meta_struct_id, 'meta_id' => $v->getId(), 'value' => $v->getValue() - ); + ]; } else { - $metadatasd[] = array( + $metadatasd[] = [ 'meta_struct_id' => $meta_struct_id, 'meta_id' => $v->getId(), 'value' => $request->get('t') ? $request->get('t') : '' - ); + ]; } } } @@ -1590,13 +1590,13 @@ class Xmlhttp implements ControllerProviderInterface } - return $app->json(array('parm' => array( + return $app->json(['parm' => [ 'sbid' => $request->get('sbid'), 't' => $request->get('t'), 'field' => $request->get('field'), 'lng' => $request->get('lng'), 'debug' => $request->get('debug'), - ), 'html' => $html)); + ], 'html' => $html]); } private function buildTermLabel($language, $n, &$key0, &$nts0) @@ -1648,7 +1648,7 @@ class Xmlhttp implements ControllerProviderInterface // let's work on each 'te' (=ts) subnode $nts = 0; $ntsopened = 0; - $tts = array(); + $tts = []; for ($n = $srcnode->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == 'te') { if ($n->getAttribute('open')) { @@ -1661,7 +1661,7 @@ class Xmlhttp implements ControllerProviderInterface if (!isset($tts[$key0 . '_' . $uniq])) break; } - $tts[$key0 . '_' . $uniq] = array('label' => $label, 'nts' => $nts0, 'n' => $n); + $tts[$key0 . '_' . $uniq] = ['label' => $label, 'nts' => $nts0, 'n' => $n]; $ntsopened++; } $nts++; diff --git a/lib/Alchemy/Phrasea/Controller/User/Notifications.php b/lib/Alchemy/Phrasea/Controller/User/Notifications.php index 77081a2238..ad9e441fa8 100644 --- a/lib/Alchemy/Phrasea/Controller/User/Notifications.php +++ b/lib/Alchemy/Phrasea/Controller/User/Notifications.php @@ -60,9 +60,9 @@ class Notifications implements ControllerProviderInterface $app['authentication']->getUser()->get_id() ); - return $app->json(array('success' => true, 'message' => '')); + return $app->json(['success' => true, 'message' => '']); } catch (\Exception $e) { - return $app->json(array('success' => false, 'message' => $e->getMessage())); + return $app->json(['success' => false, 'message' => $e->getMessage()]); } } diff --git a/lib/Alchemy/Phrasea/Controller/User/Preferences.php b/lib/Alchemy/Phrasea/Controller/User/Preferences.php index 318cb2bcf5..fa2b4f86b2 100644 --- a/lib/Alchemy/Phrasea/Controller/User/Preferences.php +++ b/lib/Alchemy/Phrasea/Controller/User/Preferences.php @@ -65,7 +65,7 @@ class Preferences implements ControllerProviderInterface $msg = _('Preference saved !'); } - return new JsonResponse(array('success' => $success, 'message' => $msg)); + return new JsonResponse(['success' => $success, 'message' => $msg]); } /** @@ -92,6 +92,6 @@ class Preferences implements ControllerProviderInterface $msg = _('Preference saved !'); } - return new JsonResponse(array('success' => $success, 'message' => $msg)); + return new JsonResponse(['success' => $success, 'message' => $msg]); } } diff --git a/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php b/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php index 7296201b8e..63d0bcd42b 100644 --- a/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php +++ b/lib/Alchemy/Phrasea/Controller/Utils/ConnectionTest.php @@ -42,7 +42,7 @@ class ConnectionTest implements ControllerProviderInterface $connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false; try { - $conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), false); + $conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, [], false); $connection_ok = true; } catch (\Exception $e) { @@ -50,7 +50,7 @@ class ConnectionTest implements ControllerProviderInterface if ($dbname && $connection_ok === true) { try { - $conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), false); + $conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, [], false); $db_ok = true; $sql = "SHOW TABLE STATUS"; @@ -75,13 +75,13 @@ class ConnectionTest implements ControllerProviderInterface } } - $datas = array( + $datas = [ 'connection' => $connection_ok , 'database' => $db_ok , 'is_empty' => $empty , 'is_appbox' => $is_appbox , 'is_databox' => $is_databox - ); + ]; return $app->json($datas); }); diff --git a/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php b/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php index 469772431c..410d063e30 100644 --- a/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php +++ b/lib/Alchemy/Phrasea/Controller/Utils/PathFileTest.php @@ -32,18 +32,18 @@ class PathFileTest implements ControllerProviderInterface * @todo : check this as it would lead to a security issue */ $controllers->get('/path/', function (Application $app, Request $request) { - return $app->json(array( + return $app->json([ 'exists' => file_exists($request->query->get('path')) , 'file' => is_file($request->query->get('path')) , 'dir' => is_dir($request->query->get('path')) , 'readable' => is_readable($request->query->get('path')) , 'writeable' => is_writable($request->query->get('path')) , 'executable' => is_executable($request->query->get('path')) - )); + ]); }); $controllers->get('/url/', function (Application $app, Request $request) { - return $app->json(array('code' => \http_query::getHttpCodeFromUrl($request->query->get('url')))); + return $app->json(['code' => \http_query::getHttpCodeFromUrl($request->query->get('url'))]); }); return $controllers; diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php index f2a41879f1..1bf4aee688 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/CLIDriversServiceProvider.php @@ -30,7 +30,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface }); $app['driver.binary-finder'] = $app->protect(function ($name, $configName) use ($app) { - $extraDirs = array(); + $extraDirs = []; if (is_dir($app['root.path'] . '/node_modules')) { $extraDirs[] = $app['root.path'] . '/node_modules/.bin'; @@ -54,7 +54,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find bower executable.'); } - return BowerDriver::create(array('bower.binaries' => $bowerBinary, 'timeout' => 300), $app['monolog']); + return BowerDriver::create(['bower.binaries' => $bowerBinary, 'timeout' => 300], $app['monolog']); }); $app['driver.recess'] = $app->share(function (Application $app) { @@ -64,7 +64,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find recess executable.'); } - return RecessDriver::create(array('recess.binaries' => $recessBinary), $app['monolog']); + return RecessDriver::create(['recess.binaries' => $recessBinary], $app['monolog']); }); $app['driver.composer'] = $app->share(function (Application $app) { @@ -74,7 +74,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find composer executable.'); } - return ComposerDriver::create(array('composer.binaries' => $composerBinary, 'timeout' => 300), $app['monolog']); + return ComposerDriver::create(['composer.binaries' => $composerBinary, 'timeout' => 300], $app['monolog']); }); $app['driver.uglifyjs'] = $app->share(function (Application $app) { @@ -84,7 +84,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find uglifyJs executable.'); } - return UglifyJsDriver::create(array('uglifyjs.binaries' => $uglifyJsBinary), $app['monolog']); + return UglifyJsDriver::create(['uglifyjs.binaries' => $uglifyJsBinary], $app['monolog']); }); $app['driver.grunt'] = $app->share(function (Application $app) { @@ -94,7 +94,7 @@ class CLIDriversServiceProvider implements ServiceProviderInterface throw new RuntimeException('Unable to find grunt executable.'); } - return GruntDriver::create(array('grunt.binaries' => $gruntBinary), $app['monolog']); + return GruntDriver::create(['grunt.binaries' => $gruntBinary], $app['monolog']); }); } diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php index 5c2158e056..c5d0f2132b 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/LessBuilderServiceProvider.php @@ -21,21 +21,21 @@ class LessBuilderServiceProvider implements ServiceProviderInterface public function register(Application $app) { $app['phraseanet.less-assets'] = $app->share(function ($app) { - return array( + return [ $app['root.path'] . '/www/assets/bootstrap/img/glyphicons-halflings-white.png' => $app['root.path'] . '/www/skins/build/bootstrap/img/glyphicons-halflings-white.png', $app['root.path'] . '/www/assets/bootstrap/img/glyphicons-halflings.png' => $app['root.path'] . '/www/skins/build/bootstrap/img/glyphicons-halflings.png', - ); + ]; }); $app['phraseanet.less-mapping.base'] = $app->share(function ($app) { - return array(); + return []; }); $app['phraseanet.less-mapping.customizable'] = $app->share(function ($app) { - return array( + return [ $app['root.path'] . '/www/skins/login/less/login.less' => $app['root.path'] . '/www/assets/build/login.css', $app['root.path'] . '/www/skins/account/account.less' => $app['root.path'] . '/www/assets/build/account.css', - ); + ]; }); $app['phraseanet.less-mapping'] = $app->share(function ($app) { diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php index f0d656ca90..c85c11d036 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/PluginServiceProvider.php @@ -71,9 +71,9 @@ class PluginServiceProvider implements ServiceProviderInterface }); $app['plugins.importer'] = $app->share(function (Application $app) { - return new Importer($app['plugins.import-strategy'], array( + return new Importer($app['plugins.import-strategy'], [ 'plugins.importer.folder-importer' => $app['plugins.importer.folder-importer'], - )); + ]); }); $app['plugins.importer.folder-importer'] = $app->share(function (Application $app) { diff --git a/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php index c8b27ef3af..973e683b24 100644 --- a/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/CLIProvider/TaskManagerServiceProvider.php @@ -37,11 +37,11 @@ class TaskManagerServiceProvider implements ServiceProviderInterface $app['dispatcher'], $app['task-manager.logger'], $app['task-manager.task-list'], - array( + [ 'listener_protocol' => $options['protocol'], 'listener_host' => $options['host'], 'listener_port' => $options['port'], - ) + ] ); }); diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php b/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php index cf625fd8e2..9601fc2caa 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php @@ -162,10 +162,10 @@ class Configuration implements ConfigurationInterface public function delete() { $this->cache = null; - foreach (array( + foreach ([ $this->config, $this->compiled, - ) as $file) { + ] as $file) { $this->eraseFile($file); } } @@ -196,11 +196,11 @@ class Configuration implements ConfigurationInterface public function getTestConnectionParameters() { - return array( + return [ 'driver' => 'pdo_sqlite', 'path' => '/tmp/db.sqlite', 'charset' => 'UTF8', - ); + ]; } private function loadDefaultConfiguration() diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php index ecac06bd66..416aa292be 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php @@ -33,14 +33,14 @@ class ApiExceptionHandlerSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::EXCEPTION => array('onSilexError', 0), - ); + return [ + KernelEvents::EXCEPTION => ['onSilexError', 0], + ]; } public function onSilexError(GetResponseForExceptionEvent $event) { - $headers = array(); + $headers = []; $e = $event->getException(); if ($e instanceof \API_V1_exception_methodnotallowed) { diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php index f0ea27a88e..b4a837ad29 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiOauth2ErrorsSubscriber.php @@ -29,9 +29,9 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::EXCEPTION => array('onSilexError', 20), - ); + return [ + KernelEvents::EXCEPTION => ['onSilexError', 20], + ]; } public function onSilexError(GetResponseForExceptionEvent $event) @@ -46,7 +46,7 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface $code = 500; $msg = _('Whoops, looks like something went wrong.'); - $headers = array(); + $headers = []; if ($e instanceof HttpExceptionInterface) { $headers = $e->getHeaders(); @@ -55,7 +55,7 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface } if (isset($headers['content-type']) && $headers['content-type'] == 'application/json') { - $msg = json_encode(array('msg' => $msg, 'code' => $code)); + $msg = json_encode(['msg' => $msg, 'code' => $code]); $event->setResponse(new Response($msg, $code, $headers)); } else { $event->setResponse($this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException())); diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php index b0ceeb3d09..77c6b8362d 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/BridgeExceptionSubscriber.php @@ -35,9 +35,9 @@ class BridgeExceptionSubscriber implements EventSubscriberInterface $e = $event->getException(); $request = $event->getRequest(); - $params = array( + $params = [ 'account' => null, - 'elements' => array(), + 'elements' => [], 'message' => $e->getMessage(), 'error_message' => null, 'notice_message' => null, @@ -45,23 +45,23 @@ class BridgeExceptionSubscriber implements EventSubscriberInterface 'line' => $e->getLine(), 'r_method' => $request->getMethod(), 'r_action' => $request->getRequestUri(), - 'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all()), - ); + 'r_parameters' => ($request->getMethod() == 'GET' ? [] : $request->request->all()), + ]; if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) { - $params = array_replace($params, array('account' => $this->app['bridge.account'])); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['account' => $this->app['bridge.account']]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, ['X-Status-Code' => 200]); } elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) { - $params = array_replace($params, array('account' => $this->app['bridge.account'])); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['account' => $this->app['bridge.account']]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, ['X-Status-Code' => 200]); } elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) { - $params = array_replace($params, array('account' => $this->app['bridge.account'])); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['account' => $this->app['bridge.account']]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, ['X-Status-Code' => 200]); } elseif ($e instanceof \Bridge_Exception_ApiDisabled) { - $params = array_replace($params, array('api' => $e->get_api())); - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, array('X-Status-Code' => 200)); + $params = array_replace($params, ['api' => $e->get_api()]); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, ['X-Status-Code' => 200]); } else { - $response = new Response($this->app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, array('X-Status-Code' => 200)); + $response = new Response($this->app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, ['X-Status-Code' => 200]); } $response->headers->set('Phrasea-StatusCode', 200); @@ -74,6 +74,6 @@ class BridgeExceptionSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array(KernelEvents::EXCEPTION => array('onSilexError', 20)); + return [KernelEvents::EXCEPTION => ['onSilexError', 20]]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php index b7b5f9a763..a8b3205ea2 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/CookiesDisablerSubscriber.php @@ -32,10 +32,10 @@ class CookiesDisablerSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('checkRoutePattern', 512), - KernelEvents::RESPONSE => array('removeCookies', -512), - ); + return [ + KernelEvents::REQUEST => ['checkRoutePattern', 512], + KernelEvents::RESPONSE => ['removeCookies', -512], + ]; } public function checkRoutePattern(GetResponseEvent $event) diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php index 23d24061ce..657c8d7db6 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/DebuggerSubscriber.php @@ -28,11 +28,11 @@ class DebuggerSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array( - array('checkIp', 255), - ), - ); + return [ + KernelEvents::REQUEST => [ + ['checkIp', 255], + ], + ]; } public function checkIp(GetResponseEvent $event) @@ -46,12 +46,12 @@ class DebuggerSubscriber implements EventSubscriberInterface && isset($this->app['configuration']['debugger']['allowed-ips'])) { $allowedIps = $this->app['configuration']['debugger']['allowed-ips']; - $allowedIps = is_array($allowedIps) ? $allowedIps : array($allowedIps); + $allowedIps = is_array($allowedIps) ? $allowedIps : [$allowedIps]; } else { - $allowedIps = array(); + $allowedIps = []; } - $ips = array_merge(array('127.0.0.1', 'fe80::1', '::1'), $allowedIps); + $ips = array_merge(['127.0.0.1', 'fe80::1', '::1'], $allowedIps); if (!in_array($event->getRequest()->getClientIp(), $ips)) { throw new AccessDeniedHttpException('You are not allowed to access this file. Check index_dev.php for more information.'); diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php index f28c2662a9..6e58beb1a7 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/FirewallSubscriber.php @@ -22,10 +22,10 @@ class FirewallSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() { - return array( - KernelEvents::RESPONSE => array('onKernelResponse', 0), - KernelEvents::EXCEPTION => array('onSilexError', 20), - ); + return [ + KernelEvents::RESPONSE => ['onKernelResponse', 0], + KernelEvents::EXCEPTION => ['onSilexError', 20], + ]; } public function onKernelResponse(FilterResponseEvent $event) @@ -43,7 +43,7 @@ class FirewallSubscriber implements EventSubscriberInterface $headers = $e->getHeaders(); if (isset($headers['X-Phraseanet-Redirect'])) { - $event->setResponse(new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, array('X-Status-Code' => 302))); + $event->setResponse(new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, ['X-Status-Code' => 302])); } } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php index d21e902e69..da7774bed5 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/JsonRequestSubscriber.php @@ -27,12 +27,12 @@ class JsonRequestSubscriber implements EventSubscriberInterface || 0 === strpos($request->getPathInfo(), '/admin/collection/') || 0 === strpos($request->getPathInfo(), '/admin/databox/')) && $request->getRequestFormat() == 'json') { - $datas = array( + $datas = [ 'success' => false, 'message' => $exception->getMessage(), - ); + ]; - $event->setResponse(new JsonResponse($datas, 200, array('X-Status-Code' => 200))); + $event->setResponse(new JsonResponse($datas, 200, ['X-Status-Code' => 200])); } } @@ -41,6 +41,6 @@ class JsonRequestSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array(KernelEvents::EXCEPTION => array('onSilexError', 10)); + return [KernelEvents::EXCEPTION => ['onSilexError', 10]]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php index 74c4372ff0..ad11289532 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/LogoutSubscriber.php @@ -25,8 +25,8 @@ class LogoutSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( + return [ PhraseaEvents::LOGOUT => 'onLogout', - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php index f5c17feebe..e28a4ec374 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/MaintenanceSubscriber.php @@ -27,15 +27,15 @@ class MaintenanceSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('checkForMaintenance', 0), - ); + return [ + KernelEvents::REQUEST => ['checkForMaintenance', 0], + ]; } public function checkForMaintenance(GetResponseEvent $event) { if ($this->app['configuration']->isSetup() && $this->app['configuration']['main']['maintenance']) { - $this->app->abort(503, 'Service Temporarily Unavailable', array('Retry-After' => 3600)); + $this->app->abort(503, 'Service Temporarily Unavailable', ['Retry-After' => 3600]); } } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php index 0f0a675fcc..205a4fb3a8 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PersistentCookieSubscriber.php @@ -27,9 +27,9 @@ class PersistentCookieSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('checkPersistentCookie', 128), - ); + return [ + KernelEvents::REQUEST => ['checkPersistentCookie', 128], + ]; } public function checkPersistentCookie(GetResponseEvent $event) diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php index 24973b0a73..b6ccd33eb5 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaExceptionHandlerSubscriber.php @@ -46,6 +46,6 @@ class PhraseaExceptionHandlerSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array(KernelEvents::EXCEPTION => array('onSilexError', 0)); + return [KernelEvents::EXCEPTION => ['onSilexError', 0]]; } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php index ef908ba83a..8ffa88edca 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php @@ -30,20 +30,20 @@ class PhraseaLocaleSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array( - array('addLocale', 255), + return [ + KernelEvents::REQUEST => [ + ['addLocale', 255], // symfony locale is set on 16 priority, let's override it - array('addLocale', 17), - array('addLocale', 15), - ), - KernelEvents::RESPONSE => array( - array('addLocaleCookie', 8), - ), - KernelEvents::FINISH_REQUEST => array( - array('unsetLocale', -255), - ) - ); + ['addLocale', 17], + ['addLocale', 15], + ], + KernelEvents::RESPONSE => [ + ['addLocaleCookie', 8], + ], + KernelEvents::FINISH_REQUEST => [ + ['unsetLocale', -255], + ] + ]; } public function unsetLocale() diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php index 8be4c78530..f9aa1516db 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/TrustedProxySubscriber.php @@ -28,9 +28,9 @@ class TrustedProxySubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('setProxyConf', 0), - ); + return [ + KernelEvents::REQUEST => ['setProxyConf', 0], + ]; } public function setProxyConf(GetResponseEvent $event) @@ -39,7 +39,7 @@ class TrustedProxySubscriber implements EventSubscriberInterface return; } - $proxies = isset($this->configuration['trusted-proxies']) ? $this->configuration['trusted-proxies'] : array(); + $proxies = isset($this->configuration['trusted-proxies']) ? $this->configuration['trusted-proxies'] : []; Request::setTrustedProxies($proxies); } } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php index 72199b06ab..cdddd7c97e 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/XSendFileSubscriber.php @@ -28,9 +28,9 @@ class XSendFileSubscriber implements EventSubscriberInterface public static function getSubscribedEvents() { - return array( - KernelEvents::REQUEST => array('applyHeaders', 0), - ); + return [ + KernelEvents::REQUEST => ['applyHeaders', 0], + ]; } public function applyHeaders(GetResponseEvent $event) diff --git a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php index 3d074bb047..0fc372fb1f 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php @@ -32,7 +32,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface $options = $app['configuration']['border-manager']; - $registeredCheckers = array(); + $registeredCheckers = []; if ($options['enabled']) { foreach ($options['checkers'] as $checker) { @@ -50,7 +50,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface continue; } - $options = array(); + $options = []; if (isset($checker['options']) && is_array($checker['options'])) { $options = $checker['options']; @@ -60,7 +60,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface $checkerObj = new $className($app, $options); if (isset($checker['databoxes'])) { - $databoxes = array(); + $databoxes = []; foreach ($checker['databoxes'] as $sbas_id) { try { $databoxes[] = $app['phraseanet.appbox']->get_databox($sbas_id); @@ -73,7 +73,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface } if (isset($checker['collections'])) { - $collections = array(); + $collections = []; foreach ($checker['collections'] as $base_id) { try { $collections[] = \collection::get_from_base_id($app, $base_id); diff --git a/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php index 19ad24b047..41c8611e4b 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/LocaleServiceProvider.php @@ -68,7 +68,7 @@ class LocaleServiceProvider implements ServiceProviderInterface }); $app['locales.mapping'] = $app->share(function (Application $app) { - $codes = array(); + $codes = []; foreach ($app['locales.available'] as $code => $language) { $data = explode('_', $code); $codes[$data[0]] = $code; @@ -78,7 +78,7 @@ class LocaleServiceProvider implements ServiceProviderInterface }); $app['locales.I18n.available'] = $app->share(function (Application $app) { - $locales = array(); + $locales = []; foreach ($app['locales.available'] as $code => $language) { $data = explode('_', $code); diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 3231c022c4..a7ca7478f0 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -63,7 +63,7 @@ class ORMServiceProvider implements ServiceProviderInterface $annotationDriver = new AnnotationDriver( $annotationReader, - array($app['root.path'].'/lib/Alchemy/Phrasea/Model/Entities') + [$app['root.path'].'/lib/Alchemy/Phrasea/Model/Entities'] ); $driverChain->addDriver($annotationDriver, 'Alchemy\Phrasea\Model\Entities'); @@ -136,13 +136,13 @@ class ORMServiceProvider implements ServiceProviderInterface $platform = $em->getConnection()->getDatabasePlatform(); - $types = array( + $types = [ 'blob' => 'Alchemy\Phrasea\Model\Types\Blob', 'enum' => 'Alchemy\Phrasea\Model\Types\Blob', 'longblob' => 'Alchemy\Phrasea\Model\Types\LongBlob', 'varbinary' => 'Alchemy\Phrasea\Model\Types\VarBinary', 'binary' => 'Alchemy\Phrasea\Model\Types\Binary', - ); + ]; foreach ($types as $type => $class) { if (!Type::hasType($type)) { diff --git a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php index 4f1deeee40..b838772e92 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PluginServiceProvider.php @@ -24,7 +24,7 @@ class PluginServiceProvider implements ServiceProviderInterface { $app['twig'] = $app->share( $app->extend('twig', function ($twig, Application $app) { - $function = new \Twig_SimpleFunction('plugin_asset', array('Alchemy\Phrasea\Plugin\Management\AssetsManager', 'twigPluginAsset')); + $function = new \Twig_SimpleFunction('plugin_asset', ['Alchemy\Phrasea\Plugin\Management\AssetsManager', 'twigPluginAsset']); $twig->addFunction($function); return $twig; diff --git a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php index f5a0408d48..f5115839c2 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php @@ -21,7 +21,7 @@ class RegistrationServiceProvider implements ServiceProviderInterface public function register(Application $app) { $app['registration.fields'] = $app->share(function (Application $app) { - return isset($app['configuration']['registration-fields']) ? $app['configuration']['registration-fields'] : array(); + return isset($app['configuration']['registration-fields']) ? $app['configuration']['registration-fields'] : []; }); $app['registration.enabled'] = $app->share(function (Application $app) { @@ -41,97 +41,97 @@ class RegistrationServiceProvider implements ServiceProviderInterface }); $app['registration.optional-fields'] = $app->share(function (Application $app) { - return array( - 'login'=> array( + return [ + 'login'=> [ 'label' => _('admin::compte-utilisateur identifiant'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), new NewLogin($app), - ) - ), - 'gender' => array( + ] + ], + 'gender' => [ 'label' => _('admin::compte-utilisateur sexe'), 'type' => 'choice', 'multiple' => false, 'expanded' => false, - 'choices' => array( + 'choices' => [ '0' => _('admin::compte-utilisateur:sexe: mademoiselle'), '1' => _('admin::compte-utilisateur:sexe: madame'), '2' => _('admin::compte-utilisateur:sexe: monsieur'), - ) - ), - 'firstname' => array( + ] + ], + 'firstname' => [ 'label' => _('admin::compte-utilisateur prenom'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'lastname' => array( + ] + ], + 'lastname' => [ 'label' => _('admin::compte-utilisateur nom'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'address' => array( + ] + ], + 'address' => [ 'label' => _('admin::compte-utilisateur adresse'), 'type' => 'textarea', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'zipcode' => array( + ] + ], + 'zipcode' => [ 'label' => _('admin::compte-utilisateur code postal'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'geonameid' => array( + ] + ], + 'geonameid' => [ 'label' => _('admin::compte-utilisateur ville'), 'type' => new \Alchemy\Phrasea\Form\Type\GeonameType(), - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'position' => array( + ] + ], + 'position' => [ 'label' => _('admin::compte-utilisateur poste'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'company' => array( + ] + ], + 'company' => [ 'label' => _('admin::compte-utilisateur societe'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'job' => array( + ] + ], + 'job' => [ 'label' => _('admin::compte-utilisateur activite'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'tel' => array( + ] + ], + 'tel' => [ 'label' => _('admin::compte-utilisateur tel'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - 'fax' => array( + ] + ], + 'fax' => [ 'label' => _('admin::compte-utilisateur fax'), 'type' => 'text', - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ) - ), - ); + ] + ], + ]; }); } diff --git a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php index 2ee275b615..470b1b2974 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php @@ -39,15 +39,15 @@ class TasksServiceProvider implements ServiceProviderInterface if (isset($app['configuration']['task-manager']) && isset($app['configuration']['task-manager']['listener'])) { $listenerConf = $app['configuration']['task-manager']['listener']; } else { - $listenerConf = array(); + $listenerConf = []; } - return array_replace(array( + return array_replace([ 'protocol' => 'tcp', 'host' => '127.0.0.1', 'port' => 6660, 'linger' => 500, - ), $listenerConf); + ], $listenerConf); }); $app['task-manager.job-factory'] = $app->share(function (Application $app) { @@ -71,7 +71,7 @@ class TasksServiceProvider implements ServiceProviderInterface }); $app['task-manager.available-jobs'] = $app->share(function (Application $app) { - return array( + return [ new FtpJob(), new ArchiveJob(), new BridgeJob(), @@ -80,7 +80,7 @@ class TasksServiceProvider implements ServiceProviderInterface new RecordMoverJob(), new SubdefsJob(), new WriteMetadataJob(), - ); + ]; }); } diff --git a/lib/Alchemy/Phrasea/Feed/Aggregate.php b/lib/Alchemy/Phrasea/Feed/Aggregate.php index a7b2d062fb..31b6aca024 100644 --- a/lib/Alchemy/Phrasea/Feed/Aggregate.php +++ b/lib/Alchemy/Phrasea/Feed/Aggregate.php @@ -54,7 +54,7 @@ class Aggregate implements FeedInterface $this->updatedOn = new \DateTime(); $this->em = $em; - $tmp_feeds = array(); + $tmp_feeds = []; foreach ($feeds as $feed) { $tmp_feeds[$feed->getId()] = $feed; @@ -77,7 +77,7 @@ class Aggregate implements FeedInterface public static function createFromUser(Application $app, \User_Adapter $user) { $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($user)); - $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(array('usrId' => $user->get_id())); + $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(['usrId' => $user->get_id()]); return new static($app['EM'], $feeds, $token); } @@ -114,7 +114,7 @@ class Aggregate implements FeedInterface return null; } - $feedIds = array(); + $feedIds = []; foreach ($this->feeds as $feed) { $feedIds[] = $feed->getId(); } @@ -200,7 +200,7 @@ class Aggregate implements FeedInterface public function getCountTotalEntries() { if (count($this->feeds) > 0) { - $feedIds = array(); + $feedIds = []; foreach ($this->feeds as $feed) { $feedIds[] = $feed->getId(); } @@ -237,6 +237,6 @@ class Aggregate implements FeedInterface */ public static function getPublic(Application $app) { - return new static($app['EM'], $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(array('public' => true), array('updatedOn' => 'DESC'))); + return new static($app['EM'], $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(['public' => true], ['updatedOn' => 'DESC'])); } } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php index bce5da422a..759cd44e02 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php @@ -36,7 +36,7 @@ class AtomFormatter extends FeedFormatterAbstract implements FeedFormatterInterf public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null) { $content = $this->format($feed, $page, $user, $generator, $app); - $response = new Response($content, 200, array('Content-Type' => 'application/atom+xml')); + $response = new Response($content, 200, ['Content-Type' => 'application/atom+xml']); return $response; } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php index 0e9d91af41..6dc48f7607 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php @@ -37,7 +37,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null) { $content = $this->format($feed, $page, $user, $generator, $app); - $response = new Response($content, 200, array('Content-Type' => 'application/rss+xml')); + $response = new Response($content, 200, ['Content-Type' => 'application/rss+xml']); return $response; } @@ -188,7 +188,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn $medium = strtolower($content->getRecord($app)->get_type()); - if ( ! in_array($medium, array('image', 'audio', 'video'))) { + if ( ! in_array($medium, ['image', 'audio', 'video'])) { return $this; } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php b/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php index 0a77fe9b51..8a9379f595 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterAbstract.php @@ -53,7 +53,7 @@ abstract class FeedFormatterAbstract $medium = strtolower($content->getRecord($app)->get_type()); - if ( ! in_array($medium, array('image', 'audio', 'video'))) { + if ( ! in_array($medium, ['image', 'audio', 'video'])) { return $this; } diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php index 754f5d3ce6..381f4ffe93 100644 --- a/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php +++ b/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php @@ -38,7 +38,7 @@ class RssFormatter extends FeedFormatterAbstract implements FeedFormatterInterfa public function createResponse(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null) { $content = $this->format($feed, $page, $user, $generator, $app); - $response = new Response($content, 200, array('Content-Type' => 'application/rss+xml')); + $response = new Response($content, 200, ['Content-Type' => 'application/rss+xml']); return $response; } diff --git a/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php b/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php index 851121d921..a58d80705c 100644 --- a/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php +++ b/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php @@ -42,10 +42,10 @@ class AggregateLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array( + $params = [ 'token' => $this->getAggregateToken($user, $renew)->getValue(), 'format' => 'atom' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -56,10 +56,10 @@ class AggregateLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array( + $params = [ 'token' => $this->getAggregateToken($user, $renew)->getValue(), 'format' => 'rss' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -93,7 +93,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array('format' => 'atom'); + $params = ['format' => 'atom']; if (null !== $page) { $params['page'] = $page; } @@ -104,7 +104,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array('format' => 'rss'); + $params = ['format' => 'rss']; if (null !== $page) { $params['page'] = $page; } @@ -123,7 +123,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface { $token = $this->em ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') - ->findOneBy(array('usrId' => $user->get_id())); + ->findOneBy(['usrId' => $user->get_id()]); if (null === $token || true === $renew) { if (null === $token) { diff --git a/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php b/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php index 001465813f..7a892f5bae 100644 --- a/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php +++ b/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php @@ -50,11 +50,11 @@ class FeedLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array( + $params = [ 'token' => $this->getFeedToken($feed, $user, $renew)->getValue(), 'id' => $feed->getId(), 'format' => 'atom' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -65,11 +65,11 @@ class FeedLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array( + $params = [ 'token' => $this->getFeedToken($feed, $user, $renew)->getValue(), 'id' => $feed->getId(), 'format' => 'rss' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -103,10 +103,10 @@ class FeedLinkGenerator implements LinkGeneratorInterface switch ($format) { case self::FORMAT_ATOM: - $params = array( + $params = [ 'id' => $feed->getId(), 'format' => 'atom' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -117,10 +117,10 @@ class FeedLinkGenerator implements LinkGeneratorInterface 'application/atom+xml' ); case self::FORMAT_RSS: - $params = array( + $params = [ 'id' => $feed->getId(), 'format' => 'rss' - ); + ]; if (null !== $page) { $params['page'] = $page; } @@ -139,7 +139,7 @@ class FeedLinkGenerator implements LinkGeneratorInterface { $token = $this->em ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') - ->findOneBy(array('usrId' => $user->get_id(), 'feed' => $feed->getId())); + ->findOneBy(['usrId' => $user->get_id(), 'feed' => $feed->getId()]); if (null === $token || true === $renew) { if (null === $token) { diff --git a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php index 81a9089898..571ff56819 100644 --- a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php +++ b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php @@ -7,7 +7,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; class LinkGeneratorCollection implements LinkGeneratorInterface { - private $generators = array(); + private $generators = []; /** * Adds a LinkGeneratorInterface to the internal array. diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php index 2a9b679734..0d2c7f7268 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaAuthenticationForm.php @@ -19,37 +19,37 @@ class PhraseaAuthenticationForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('login', 'text', array( + $builder->add('login', 'text', [ 'label' => _('Login'), 'required' => true, 'disabled' => $options['disabled'], - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ), - )); + ], + ]); - $builder->add('password', 'password', array( + $builder->add('password', 'password', [ 'label' => _('Password'), 'required' => true, 'disabled' => $options['disabled'], - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ), - )); + ], + ]); - $builder->add('remember-me', 'checkbox', array( + $builder->add('remember-me', 'checkbox', [ 'label' => _('Remember me'), 'mapped' => false, 'required' => false, - 'attr' => array( + 'attr' => [ 'checked' => 'checked', 'value' => '1', - ) - )); + ] + ]); - $builder->add('redirect', 'hidden', array( + $builder->add('redirect', 'hidden', [ 'required' => false, - )); + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php index 7bfb6b39ad..4612548bc3 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaForgotPasswordForm.php @@ -19,14 +19,14 @@ class PhraseaForgotPasswordForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('email', 'email', array( + $builder->add('email', 'email', [ 'label' => _('E-mail'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), new Assert\Email() - ), - )); + ], + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php index 48b1e2c596..a3f78d258f 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRecoverPasswordForm.php @@ -31,26 +31,26 @@ class PhraseaRecoverPasswordForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('token', 'hidden', array( + $builder->add('token', 'hidden', [ 'required' => true, - 'constraints' => array( + 'constraints' => [ new PasswordToken($this->app, $this->app['tokens']) - ) - )); + ] + ]); - $builder->add('password', 'repeated', array( + $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, 'invalid_message' => _('Please provide the same passwords.'), 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => array('label' => _('New password')), - 'second_options' => array('label' => _('New password (confirmation)')), - 'constraints' => array( + 'first_options' => ['label' => _('New password')], + 'second_options' => ['label' => _('New password (confirmation)')], + 'constraints' => [ new Assert\NotBlank(), - new Assert\Length(array('min' => 5)), - ), - )); + new Assert\Length(['min' => 5]), + ], + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php index 341662e016..3e7d49972c 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRegisterForm.php @@ -24,7 +24,7 @@ class PhraseaRegisterForm extends AbstractType private $params; private $camelizer; - public function __construct(Application $app, array $available, array $params = array(), Camelizer $camelizer = null) + public function __construct(Application $app, array $available, array $params = [], Camelizer $camelizer = null) { $this->app = $app; $this->available = $available; @@ -34,46 +34,46 @@ class PhraseaRegisterForm extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('email', 'email', array( + $builder->add('email', 'email', [ 'label' => _('E-mail'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), new Assert\Email(), new \Alchemy\Phrasea\Form\Constraint\NewEmail($this->app), - ), - )); + ], + ]); - $builder->add('password', 'repeated', array( + $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, 'invalid_message' => _('Please provide the same passwords.'), 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => array('label' => _('Password')), - 'second_options' => array('label' => _('Password (confirmation)')), - 'constraints' => array( + 'first_options' => ['label' => _('Password')], + 'second_options' => ['label' => _('Password (confirmation)')], + 'constraints' => [ new Assert\NotBlank(), - new Assert\Length(array('min' => 5)), - ), - )); + new Assert\Length(['min' => 5]), + ], + ]); if ($this->app->hasTermsOfUse()) { - $builder->add('accept-tou', 'checkbox', array( + $builder->add('accept-tou', 'checkbox', [ 'label' => _('Terms of Use'), 'mapped' => false, - "constraints" => array( - new Assert\True(array( + "constraints" => [ + new Assert\True([ "message" => _("Please accept the Terms and conditions in order to register.") - ))), - )); + ])], + ]); } $builder->add('provider-id', 'hidden'); require_once $this->app['root.path'] . '/lib/classes/deprecated/inscript.api.php'; - $choices = array(); - $baseIds = array(); + $choices = []; + $baseIds = []; foreach (\giveMeBases($this->app) as $sbas_id => $baseInsc) { if (($baseInsc['CollsCGU'] || $baseInsc['Colls']) && $baseInsc['inscript']) { @@ -83,7 +83,7 @@ class PhraseaRegisterForm extends AbstractType $sbasName= \phrasea::sbas_names($sbas_id, $this->app); if (!isset($choices[$sbasName])) { - $choices[$sbasName] = array(); + $choices[$sbasName] = []; } $choices[$sbasName][$baseId] = \phrasea::bas_labels($baseId, $this->app); @@ -97,7 +97,7 @@ class PhraseaRegisterForm extends AbstractType $sbasName= \phrasea::sbas_names($sbas_id, $this->app); if (!isset($choices[$sbasName])) { - $choices[$sbasName] = array(); + $choices[$sbasName] = []; } $choices[$sbasName][$baseId] = \phrasea::bas_labels($baseId, $this->app); @@ -108,19 +108,19 @@ class PhraseaRegisterForm extends AbstractType } if (!$this->app['phraseanet.registry']->get('GV_autoselectDB')) { - $builder->add('collections', 'choice', array( + $builder->add('collections', 'choice', [ 'choices' => $choices, 'multiple' => true, 'expanded' => false, - 'constraints' => array( - new Assert\Choice(array( + 'constraints' => [ + new Assert\Choice([ 'choices' => $baseIds, 'minMessage' => _('You must select at least %s collection.'), 'multiple' => true, 'min' => 1, - )), - ), - )); + ]), + ], + ]); } foreach ($this->params as $param) { @@ -129,7 +129,7 @@ class PhraseaRegisterForm extends AbstractType throw new InvalidArgumentException(sprintf('%s is not a valid fieldname')); } if (isset($this->available[$name])) { - $options = array_merge($this->available[$name], array('required' => $param['required'])); + $options = array_merge($this->available[$name], ['required' => $param['required']]); if (!$param['required']) { unset($options['constraints']); } diff --git a/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php b/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php index 04236af7cb..15c287fb4d 100644 --- a/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php +++ b/lib/Alchemy/Phrasea/Form/Login/PhraseaRenewPasswordForm.php @@ -22,27 +22,27 @@ class PhraseaRenewPasswordForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('oldPassword', 'password', array( + $builder->add('oldPassword', 'password', [ 'label' => _('Current password'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank() - ) - )); + ] + ]); - $builder->add('password', 'repeated', array( + $builder->add('password', 'repeated', [ 'type' => 'password', 'required' => true, 'invalid_message' => _('Please provide the same passwords.'), 'first_name' => 'password', 'second_name' => 'confirm', - 'first_options' => array('label' => _('New password')), - 'second_options' => array('label' => _('New password (confirmation)')), - 'constraints' => array( + 'first_options' => ['label' => _('New password')], + 'second_options' => ['label' => _('New password (confirmation)')], + 'constraints' => [ new Assert\NotBlank(), - new Assert\Length(array('min' => 5)), - ), - )); + new Assert\Length(['min' => 5]), + ], + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Form/TaskForm.php b/lib/Alchemy/Phrasea/Form/TaskForm.php index 04b7489a5c..546d424e7d 100644 --- a/lib/Alchemy/Phrasea/Form/TaskForm.php +++ b/lib/Alchemy/Phrasea/Form/TaskForm.php @@ -21,36 +21,36 @@ class TaskForm extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('name', 'text', array( + $builder->add('name', 'text', [ 'label' => _('Task name'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - ), - )); - $builder->add('period', 'integer', array( + ], + ]); + $builder->add('period', 'integer', [ 'label' => _('Task period (in seconds)'), 'required' => true, - 'constraints' => array( + 'constraints' => [ new Assert\NotBlank(), - new Assert\GreaterThan(array('value' => 0)), - ), - )); - $builder->add('status', 'choice', array( + new Assert\GreaterThan(['value' => 0]), + ], + ]); + $builder->add('status', 'choice', [ 'label' => _('The task status'), - 'choices' => array( + 'choices' => [ Task::STATUS_STARTED => 'Started', Task::STATUS_STOPPED => 'Stopped', - ), - )); + ], + ]); $builder->add('settings', 'hidden'); } public function setDefaultOptions(OptionsResolverInterface $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'data_class' => 'Alchemy\Phrasea\Model\Entities\Task', - )); + ]); } public function getName() diff --git a/lib/Alchemy/Phrasea/Helper/Prod.php b/lib/Alchemy/Phrasea/Helper/Prod.php index ea6c329b21..b32c4b48fb 100644 --- a/lib/Alchemy/Phrasea/Helper/Prod.php +++ b/lib/Alchemy/Phrasea/Helper/Prod.php @@ -21,13 +21,13 @@ class Prod extends Helper public function get_search_datas() { - $search_datas = array( - 'bases' => array(), - 'dates' => array(), - 'fields' => array() - ); + $search_datas = [ + 'bases' => [], + 'dates' => [], + 'fields' => [] + ]; - $bases = $fields = $dates = array(); + $bases = $fields = $dates = []; if (! $this->app['authentication']->getUser() instanceof \User_Adapter) { return $search_datas; @@ -38,21 +38,21 @@ class Prod extends Helper foreach ($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); - $bases[$sbas_id] = array( + $bases[$sbas_id] = [ 'thesaurus' => (trim($databox->get_thesaurus()) != ""), 'cterms' => false, - 'collections' => array(), + 'collections' => [], 'sbas_id' => $sbas_id - ); + ]; - foreach ($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id())) as $coll) { + foreach ($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]) as $coll) { $selected = (isset($searchSet['bases']) && isset($searchSet['bases'][$sbas_id])) ? (in_array($coll->get_base_id(), $searchSet['bases'][$sbas_id])) : true; $bases[$sbas_id]['collections'][] = - array( + [ 'selected' => $selected, 'base_id' => $coll->get_base_id() - ); + ]; } $meta_struct = $databox->get_meta_structure(); @@ -65,18 +65,18 @@ class Prod extends Helper if (isset($dates[$id])) $dates[$id]['sbas'][] = $sbas_id; else - $dates[$id] = array('sbas' => array($sbas_id), 'fieldname' => $name); + $dates[$id] = ['sbas' => [$sbas_id], 'fieldname' => $name]; } if (isset($fields[$name])) { $fields[$name]['sbas'][] = $sbas_id; } else { - $fields[$name] = array( - 'sbas' => array($sbas_id) + $fields[$name] = [ + 'sbas' => [$sbas_id] , 'fieldname' => $name , 'type' => $meta->get_type() , 'id' => $id - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/Helper/Record/Helper.php b/lib/Alchemy/Phrasea/Helper/Record/Helper.php index d165cab385..5b2400f3e3 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Helper.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Helper.php @@ -62,13 +62,13 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper * * @var Array */ - protected $required_rights = array(); + protected $required_rights = []; /** * * @var Array */ - protected $required_sbas_rights = array(); + protected $required_sbas_rights = []; /** * @@ -125,7 +125,7 @@ class Helper extends \Alchemy\Phrasea\Helper\Helper $storyWZ = $repository->findByUserAndId($app, $app['authentication']->getUser(), $Request->get('story')); - $this->selection->load_list(array($storyWZ->getRecord($this->app)->get_serialize_key()), $this->flatten_groupings); + $this->selection->load_list([$storyWZ->getRecord($this->app)->get_serialize_key()], $this->flatten_groupings); } else { $this->selection->load_list(explode(";", $Request->get('lst')), $this->flatten_groupings); } diff --git a/lib/Alchemy/Phrasea/Helper/Record/Push.php b/lib/Alchemy/Phrasea/Helper/Record/Push.php index 0fedb9767f..533db7f209 100644 --- a/lib/Alchemy/Phrasea/Helper/Record/Push.php +++ b/lib/Alchemy/Phrasea/Helper/Record/Push.php @@ -25,6 +25,6 @@ use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper; class Push extends RecordHelper { protected $flatten_groupings = true; - protected $required_rights = array('canpush'); + protected $required_rights = ['canpush']; } diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php index 916bd00e70..ca033cf0ac 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Edit.php +++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php @@ -29,7 +29,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper * * @var array */ - protected $users = array(); + protected $users = []; /** * @@ -49,7 +49,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $this->users = explode(';', $Request->get('users')); - $users = array(); + $users = []; foreach ($this->users as $usr_id) { $usr_id = (int) $usr_id; @@ -77,7 +77,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper protected function delete_user(\User_Adapter $user) { - $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); $this->app['acl']->get($user)->revoke_access_from_bases($list); @@ -90,7 +90,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper public function get_users_rights() { - $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); $sql = "SELECT b.sbas_id, @@ -154,7 +154,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $access = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $base_ids = array(); + $base_ids = []; foreach ($access as $acc) { $base_ids[$acc['base_id']] = $acc; } @@ -174,14 +174,14 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper ->execute()->get_results(); $this->users_datas = $rs; - $out = array( + $out = [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'main_user' => null, 'templates' => $templates - ); + ]; if (count($this->users) == 1) { $usr_id = array_pop($this->users); @@ -202,19 +202,19 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = \connection::getPDOConnection($this->app); $stmt = $conn->prepare($sql); - $stmt->execute(array(':base_id' => $this->base_id)); + $stmt->execute([':base_id' => $this->base_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->users_datas = $rs; - return array( + return [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'collection' => \collection::get_from_base_id($this->app, $this->base_id), - ); + ]; } public function get_masks() @@ -228,17 +228,17 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = $this->app['phraseanet.appbox']->get_connection(); $stmt = $conn->prepare($sql); - $stmt->execute(array(':base_id' => $this->base_id)); + $stmt->execute([':base_id' => $this->base_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $tbits_and = array(); - $tbits_xor = array(); + $tbits_and = []; + $tbits_xor = []; $nrows = 0; for ($bit = 0; $bit < 32; $bit++) - $tbits_and[$bit] = $tbits_xor[$bit] = array("nset" => 0); + $tbits_and[$bit] = $tbits_xor[$bit] = ["nset" => 0]; foreach ($rs as $row) { $sta_xor = strrev($row["mask_xor"]); @@ -255,8 +255,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $nrows++; } - $tbits_left = array(); - $tbits_right = array(); + $tbits_left = []; + $tbits_right = []; $sbas_id = \phrasea::sbasFromBas($this->app, $this->base_id); $databox = $this->app['phraseanet.appbox']->get_databox($sbas_id); @@ -296,22 +296,22 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper } } - $this->users_datas = array( + $this->users_datas = [ 'tbits_left' => $tbits_left, 'tbits_right' => $tbits_right, 'vand_and' => $vand_and, 'vand_or' => $vand_or, 'vxor_and' => $vxor_and, 'vxor_or' => $vxor_or - ); + ]; - return array( + return [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'collection' => \collection::get_from_base_id($this->app, $this->base_id), - ); + ]; } public function get_time() @@ -325,7 +325,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = \connection::getPDOConnection($this->app); $stmt = $conn->prepare($sql); - $stmt->execute(array(':base_id' => $this->base_id)); + $stmt->execute([':base_id' => $this->base_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -355,17 +355,17 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $limited_to = $date_obj_to->format('Y-m-d'); } - $datas = array('time_limited' => $time_limited, 'limited_from' => $limited_from, 'limited_to' => $limited_to); + $datas = ['time_limited' => $time_limited, 'limited_from' => $limited_from, 'limited_to' => $limited_to]; $this->users_datas = $datas; - return array( + return [ 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'base_id' => $this->base_id, 'collection' => \collection::get_from_base_id($this->app, $this->base_id), - ); + ]; } public function get_time_sbas() @@ -381,11 +381,11 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $conn = \connection::getPDOConnection($this->app); $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $sbas_id)); + $stmt->execute([':sbas_id' => $sbas_id]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $time_limited = $limited_from = $limited_to = array(); + $time_limited = $limited_from = $limited_to = []; foreach ($rs as $row) { $time_limited[] = $row['time_limited']; @@ -417,39 +417,39 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $limited_to = false; } - $datas = array( + $datas = [ 'time_limited' => array_pop($time_limited), 'limited_from' => $limited_from, 'limited_to' => $limited_to - ); + ]; } else { - $datas = array( + $datas = [ 'time_limited' => 2, 'limited_from' => '', 'limited_to' => '' - ); + ]; } $this->users_datas = $datas; - return array( + return [ 'sbas_id' => $sbas_id, 'datas' => $this->users_datas, 'users' => $this->users, 'users_serial' => implode(';', $this->users), 'databox' => $this->app['phraseanet.appbox']->get_databox($sbas_id), - ); + ]; } public function apply_rights() { $ACL = $this->app['acl']->get($this->app['authentication']->getUser()); - $base_ids = array_keys($ACL->get_granted_base(array('canadmin'))); + $base_ids = array_keys($ACL->get_granted_base(['canadmin'])); - $update = $create = $delete = $create_sbas = $update_sbas = array(); + $update = $create = $delete = $create_sbas = $update_sbas = []; foreach ($base_ids as $base_id) { - $rights = array( + $rights = [ 'access', 'actif', 'canputinalbum', @@ -467,7 +467,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper 'canpush', 'manage', 'modify_struct' - ); + ]; foreach ($rights as $k => $right) { if (($right == 'access' && !$ACL->has_access_to_base($base_id)) || ($right != 'access' && !$ACL->has_right_on_base($base_id, $right))) { @@ -503,12 +503,12 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $sbas_ids = $ACL->get_granted_sbas(); foreach ($sbas_ids as $databox) { - $rights = array( + $rights = [ 'bas_modif_th', 'bas_manage', 'bas_modify_struct', 'bas_chupub' - ); + ]; foreach ($rights as $k => $right) { if (!$ACL->has_right_on_sbas($databox->get_sbas_id(), $right)) { unset($rights[$k]); @@ -576,7 +576,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper return $this; } - $infos = array( + $infos = [ 'gender' , 'first_name' , 'last_name' @@ -589,7 +589,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper , 'activite' , 'telephone' , 'fax' - ); + ]; $parm = $this->unserializedRequestData($this->app['request'], $infos, 'user_infos'); @@ -649,7 +649,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper throw new AccessDeniedHttpException('You are not the owner of the template'); } - $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); foreach ($this->users as $usr_id) { $user = \User_adapter::getInstance($usr_id, $this->app); @@ -709,7 +709,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper $activate = !!$this->request->get('limit'); - $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); foreach ($this->users as $usr_id) { $user = \User_Adapter::getInstance($usr_id, $this->app); @@ -728,7 +728,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper public function resetRights() { - $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('canadmin'))); + $base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin'])); foreach ($this->users as $usr_id) { $user = \User_Adapter::getInstance($usr_id, $this->app); @@ -758,7 +758,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper private function unserializedRequestData(Request $request, array $indexes, $requestIndex) { - $parameters = $data = array(); + $parameters = $data = []; parse_str($request->get($requestIndex), $data); if (count($data) > 0) { diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php index b711635cb0..feb7d54a4d 100644 --- a/lib/Alchemy/Phrasea/Helper/User/Manage.php +++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php @@ -49,7 +49,7 @@ class Manage extends Helper $offset_start = (int) $request->get('offset_start'); $offset_start = $offset_start < 0 ? 0 : $offset_start; - $this->query_parms = array( + $this->query_parms = [ 'inactives' => $request->get('inactives') , 'like_field' => $request->get('like_field') , 'like_value' => $request->get('like_value') @@ -59,7 +59,7 @@ class Manage extends Helper , 'srt' => $request->get("srt", \User_Query::SORT_CREATIONDATE) , 'ord' => $request->get("ord", \User_Query::ORD_DESC) , 'offset_start' => 0 - ); + ]; $query = new \User_Query($this->app); @@ -73,7 +73,7 @@ class Manage extends Helper ->last_model_is($this->query_parms['last_model']) ->get_inactives($this->query_parms['inactives']) ->include_templates(false) - ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), array('canadmin')) + ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), ['canadmin']) ->execute(); return $this->results->get_results(); @@ -86,7 +86,7 @@ class Manage extends Helper $results_quantity = (int) $this->request->get('per_page'); $results_quantity = ($results_quantity < 10 || $results_quantity > 50) ? 20 : $results_quantity; - $this->query_parms = array( + $this->query_parms = [ 'inactives' => $this->request->get('inactives') , 'like_field' => $this->request->get('like_field') , 'like_value' => $this->request->get('like_value') @@ -97,7 +97,7 @@ class Manage extends Helper , 'ord' => $this->request->get("ord", \User_Query::ORD_DESC) , 'per_page' => $results_quantity , 'offset_start' => $offset_start - ); + ]; $query = new \User_Query($this->app); @@ -111,7 +111,7 @@ class Manage extends Helper ->last_model_is($this->query_parms['last_model']) ->get_inactives($this->query_parms['inactives']) ->include_templates(true) - ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), array('canadmin')) + ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), ['canadmin']) ->limit($offset_start, $results_quantity) ->execute(); @@ -139,13 +139,13 @@ class Manage extends Helper ->only_templates(true) ->execute()->get_results(); - return array( + return [ 'users' => $this->results, 'parm' => $this->query_parms, 'invite_user' => $invite, 'autoregister_user' => $autoregister, 'templates' => $templates - ); + ]; } public function create_newuser() @@ -159,7 +159,7 @@ class Manage extends Helper $conn = $this->app['phraseanet.appbox']->get_connection(); $sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':email' => $email)); + $stmt->execute([':email' => $email]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $count = count($row); @@ -181,7 +181,7 @@ class Manage extends Helper $urlToken = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->get_id()); if ($receiver && false !== $urlToken) { - $url = $this->app->url('login_renew_password', array('token' => $urlToken)); + $url = $this->app->url('login_renew_password', ['token' => $urlToken]); $mail = MailRequestPasswordSetup::create($this->app, $receiver, null, '', $url); $mail->setLogin($createdUser->get_login()); $this->app['notification.deliverer']->deliver($mail); @@ -194,7 +194,7 @@ class Manage extends Helper if ($receiver) { $expire = new \DateTime('+3 days'); $token = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->get_id(), $expire, $createdUser->get_email()); - $url = $this->app->url('login_register_confirm', array('code' => $token)); + $url = $this->app->url('login_register_confirm', ['code' => $token]); $mail = MailRequestEmailConfirmation::create($this->app, $receiver, null, '', $url, $expire); $this->app['notification.deliverer']->deliver($mail); diff --git a/lib/Alchemy/Phrasea/Helper/WorkZone.php b/lib/Alchemy/Phrasea/Helper/WorkZone.php index 03017b0d13..dd7f4765b8 100644 --- a/lib/Alchemy/Phrasea/Helper/WorkZone.php +++ b/lib/Alchemy/Phrasea/Helper/WorkZone.php @@ -44,7 +44,7 @@ class WorkZone extends Helper /* @var $repo_baskets Alchemy\Phrasea\Model\Repositories\BasketRepository */ $repo_baskets = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket'); - $sort = in_array($sort, array('date', 'name')) ? $sort : 'name'; + $sort = in_array($sort, ['date', 'name']) ? $sort : 'name'; $ret = new ArrayCollection(); @@ -59,7 +59,7 @@ class WorkZone extends Helper $this->app['EM']->persist($basket); $this->app['EM']->flush(); - $baskets = array($basket); + $baskets = [$basket]; } $validations = $repo_baskets->findActiveValidationByUser($this->app['authentication']->getUser(), $sort); diff --git a/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php b/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php index fd709afbdd..cfa62e3e46 100644 --- a/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php +++ b/lib/Alchemy/Phrasea/Http/ServeFileResponseFactory.php @@ -72,7 +72,7 @@ class ServeFileResponseFactory implements DeliverDataInterface private function sanitizeFilename($filename) { - return str_replace(array('/', '\\'), '', $filename); + return str_replace(['/', '\\'], '', $filename); } private function sanitizeFilenameFallback($filename) diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php b/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php index cfc09ffc92..c89a297269 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/AbstractXSendFileMode.php @@ -15,7 +15,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException; abstract class AbstractXSendFileMode { - protected $mapping = array(); + protected $mapping = []; /** * @params array $mapping diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php b/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php index 1102205288..d77aa63103 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/ApacheMode.php @@ -21,9 +21,9 @@ class ApacheMode extends AbstractXSendFileMode implements ModeInterface */ public function setHeaders(Request $request) { - $request->headers->add(array( + $request->headers->add([ 'X-Sendfile-Type' => 'X-SendFile', - )); + ]); } /** @@ -31,7 +31,7 @@ class ApacheMode extends AbstractXSendFileMode implements ModeInterface */ public function setMapping(array $mapping) { - $final = array(); + $final = []; foreach ($mapping as $entry) { if (!is_array($entry)) { @@ -46,9 +46,9 @@ class ApacheMode extends AbstractXSendFileMode implements ModeInterface continue; } - $final[] = array( + $final[] = [ 'directory' => $this->sanitizePath(realpath($entry['directory'])) - ); + ]; } $this->mapping = $final; diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php b/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php index 1d81d329b6..610af6d88a 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/NginxMode.php @@ -21,17 +21,17 @@ class NginxMode extends AbstractXSendFileMode implements ModeInterface */ public function setHeaders(Request $request) { - $xAccelMapping = array(); + $xAccelMapping = []; foreach ($this->mapping as $entry) { $xAccelMapping[] = sprintf('%s=%s', $entry['mount-point'], $entry['directory']); } if (count($xAccelMapping) > 0 ) { - $request->headers->add(array( + $request->headers->add([ 'X-Sendfile-Type' => 'X-Accel-Redirect', 'X-Accel-Mapping' => implode(',', $xAccelMapping), - )); + ]); } } @@ -40,7 +40,7 @@ class NginxMode extends AbstractXSendFileMode implements ModeInterface */ public function setMapping(array $mapping) { - $final = array(); + $final = []; foreach ($mapping as $entry) { if (!is_array($entry)) { @@ -59,10 +59,10 @@ class NginxMode extends AbstractXSendFileMode implements ModeInterface continue; } - $final[] = array( + $final[] = [ 'directory' => $this->sanitizePath(realpath($entry['directory'])), 'mount-point' => $this->sanitizeMountPoint($entry['mount-point']) - ); + ]; } $this->mapping = $final; diff --git a/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php b/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php index 10b67a811d..2f51791a2a 100644 --- a/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php +++ b/lib/Alchemy/Phrasea/Http/XSendFile/XSendFileFactory.php @@ -50,7 +50,7 @@ class XSendFileFactory { $conf = $app['configuration']['xsendfile']; - $mapping = array(); + $mapping = []; if (isset($conf['mapping'])) { $mapping = $conf['mapping']; diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php index 545d6ab407..af0a6de749 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Audio.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Audio.php @@ -26,14 +26,14 @@ class Audio extends Provider public function __construct() { - $AVaudiosamplerate = array( + $AVaudiosamplerate = [ 8000, 11025, 16000, 22050, 32000, 44056, 44100, 47250, 48000, 50000, 50400, 88200, 96000 - ); + ]; $this->registerOption(new OptionType\Range(_('Audio Birate'), self::OPTION_AUDIOBITRATE, 32, 320, 128, 32)); $this->registerOption(new OptionType\Enum(_('AudioSamplerate'), self::OPTION_AUDIOSAMPLERATE, $AVaudiosamplerate)); - $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, array('libmp3lame', 'flac'), 'libmp3lame')); + $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, ['libmp3lame', 'flac'], 'libmp3lame')); } public function getType() diff --git a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php index b9e1dfe71e..4550f67b48 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/FlexPaper.php @@ -19,7 +19,7 @@ namespace Alchemy\Phrasea\Media\Subdef; */ class FlexPaper extends Provider { - protected $options = array(); + protected $options = []; public function __construct() { diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Image.php b/lib/Alchemy/Phrasea/Media/Subdef/Image.php index 9a7f6ee2e3..eda3ebab9b 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Image.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Image.php @@ -26,7 +26,7 @@ class Image extends Provider const OPTION_STRIP = 'strip'; const OPTION_QUALITY = 'quality'; - protected $options = array(); + protected $options = []; public function __construct() { diff --git a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php index e1b5549d3e..344acdf02e 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/OptionType/Multi.php @@ -28,7 +28,7 @@ class Multi implements OptionType { $this->displayName = $displayName; $this->name = $name; - $this->available = array(); + $this->available = []; foreach ($available as $a) { $this->available[$a] = false; } @@ -93,7 +93,7 @@ class Multi implements OptionType return $this->available; } - $value = array(); + $value = []; foreach ($this->available as $a => $selected) { if ($selected) { diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php index a068f63a9f..4a000aef59 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Provider.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Provider.php @@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Media\Subdef; */ abstract class Provider implements Subdef { - protected $options = array(); + protected $options = []; protected $spec; public function registerOption(OptionType\OptionType $option) diff --git a/lib/Alchemy/Phrasea/Media/Subdef/Video.php b/lib/Alchemy/Phrasea/Media/Subdef/Video.php index 3a5f8d2293..07a12fdd56 100644 --- a/lib/Alchemy/Phrasea/Media/Subdef/Video.php +++ b/lib/Alchemy/Phrasea/Media/Subdef/Video.php @@ -25,7 +25,7 @@ class Video extends Audio const OPTION_VCODEC = 'vcodec'; const OPTION_GOPSIZE = 'GOPsize'; - protected $options = array(); + protected $options = []; public function __construct() { @@ -35,9 +35,9 @@ class Video extends Audio $this->registerOption(new OptionType\Range(_('GOP size'), self::OPTION_GOPSIZE, 1, 300, 10)); $this->registerOption(new OptionType\Range(_('Dimension'), self::OPTION_SIZE, 64, 2000, 600, 16)); $this->registerOption(new OptionType\Range(_('Frame Rate'), self::OPTION_FRAMERATE, 1, 200, 20)); - $this->registerOption(new OptionType\Enum(_('Video Codec'), self::OPTION_VCODEC, array('libx264', 'libvpx', 'libtheora'), 'libx264')); + $this->registerOption(new OptionType\Enum(_('Video Codec'), self::OPTION_VCODEC, ['libx264', 'libvpx', 'libtheora'], 'libx264')); $this->unregisterOption(self::OPTION_ACODEC); - $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, array('libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'), 'libfaac')); + $this->registerOption(new OptionType\Enum(_('Audio Codec'), self::OPTION_ACODEC, ['libfaac', 'libvo_aacenc', 'libmp3lame', 'libvorbis'], 'libfaac')); } public function getType() diff --git a/lib/Alchemy/Phrasea/Metadata/TagProvider.php b/lib/Alchemy/Phrasea/Metadata/TagProvider.php index ad888ccdd3..26009ffe87 100644 --- a/lib/Alchemy/Phrasea/Metadata/TagProvider.php +++ b/lib/Alchemy/Phrasea/Metadata/TagProvider.php @@ -20,7 +20,7 @@ class TagProvider extends ExiftoolTagProvider parent::__construct(); $this['Phraseanet'] = $this->share(function () { - return array( + return [ 'PdfText' => new \Alchemy\Phrasea\Metadata\Tag\PdfText(), 'TfArchivedate' => new \Alchemy\Phrasea\Metadata\Tag\TfArchivedate(), 'TfAtime' => new \Alchemy\Phrasea\Metadata\Tag\TfAtime(), @@ -41,7 +41,7 @@ class TagProvider extends ExiftoolTagProvider 'TfRecordid' => new \Alchemy\Phrasea\Metadata\Tag\TfRecordid(), 'TfSize' => new \Alchemy\Phrasea\Metadata\Tag\TfSize(), 'TfWidth' => new \Alchemy\Phrasea\Metadata\Tag\TfWidth(), - ); + ]; }); } @@ -57,107 +57,107 @@ class TagProvider extends ExiftoolTagProvider { $table = parent::getLookupTable(); - $table['phraseanet'] = array( - 'pdftext' => array( + $table['phraseanet'] = [ + 'pdftext' => [ 'tagname' => 'PdfText', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\PdfText', - 'namespace' => 'Phraseanet'), - 'tfarchivedate' => array( + 'namespace' => 'Phraseanet'], + 'tfarchivedate' => [ 'tagname' => 'TfArchivedate', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfArchivedate', 'namespace' => 'Phraseanet' - ), - 'tfatime' => array( + ], + 'tfatime' => [ 'tagname' => 'TfAtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfAtime', 'namespace' => 'Phraseanet' - ), - 'tfbasename' => array( + ], + 'tfbasename' => [ 'tagname' => 'TfBasename', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBasename', 'namespace' => 'Phraseanet' - ), - 'tfbits' => array( + ], + 'tfbits' => [ 'tagname' => 'TfBits', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfBits', 'namespace' => 'Phraseanet' - ), - 'tfchannels' => array( + ], + 'tfchannels' => [ 'tagname' => 'TfChannels', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfChannels', 'namespace' => 'Phraseanet' - ), - 'tTfCtime' => array( + ], + 'tTfCtime' => [ 'tagname' => 'TfCtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfCtime', 'namespace' => 'Phraseanet' - ), - 'tfdirname' => array( + ], + 'tfdirname' => [ 'tagname' => 'TfDirname', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDirname', 'namespace' => 'Phraseanet' - ), - 'tfduration' => array( + ], + 'tfduration' => [ 'tagname' => 'TfDuration', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfDuration', 'namespace' => 'Phraseanet' - ), - 'tfeditdate' => array( + ], + 'tfeditdate' => [ 'tagname' => 'TfEditdate', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfEditdate', 'namespace' => 'Phraseanet' - ), - 'tfextension' => array( + ], + 'tfextension' => [ 'tagname' => 'TfExtension', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfExtension', 'namespace' => 'Phraseanet' - ), - 'tffilename' => array( + ], + 'tffilename' => [ 'tagname' => 'TfFilename', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfFilename', 'namespace' => 'Phraseanet' - ), - 'tffilepath' => array( + ], + 'tffilepath' => [ 'tagname' => 'TfFilepath', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfFilepath', 'namespace' => 'Phraseanet' - ), - 'tfheight' => array( + ], + 'tfheight' => [ 'tagname' => 'TfHeight', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfHeight', 'namespace' => 'Phraseanet' - ), - 'tfmimetype' => array( + ], + 'tfmimetype' => [ 'tagname' => 'TfMimetype', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfMimetype', 'namespace' => 'Phraseanet' - ), - 'tfmtime' => array( + ], + 'tfmtime' => [ 'tagname' => 'TfMtime', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfMtime', 'namespace' => 'Phraseanet' - ), - 'tfquarantine' => array( + ], + 'tfquarantine' => [ 'tagname' => 'TfQuarantine', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfQuarantine', 'namespace' => 'Phraseanet' - ), - 'tfrecordid' => array( + ], + 'tfrecordid' => [ 'tagname' => 'TfRecordid', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfRecordid', 'namespace' => 'Phraseanet' - ), - 'tfsize' => array( + ], + 'tfsize' => [ 'tagname' => 'TfSize', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfSize', 'namespace' => 'Phraseanet' - ), - 'tfwidth' => array( + ], + 'tfwidth' => [ 'tagname' => 'TfWidth', 'classname' => '\\Alchemy\\Phrasea\\Metadata\\Tag\\TfWidth', 'namespace' => 'Phraseanet' - ), - ); + ], + ]; return $table; } diff --git a/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php b/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php index 29473fda6c..61508b63e0 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php +++ b/lib/Alchemy/Phrasea/Model/Entities/LazaretFile.php @@ -425,7 +425,7 @@ class LazaretFile */ public function getRecordsToSubstitute(Application $app) { - $ret = array(); + $ret = []; $shaRecords = \record_adapter::get_record_by_sha( $app, $this->getCollection($app)->get_sbas_id(), $this->getSha256() diff --git a/lib/Alchemy/Phrasea/Model/Entities/Task.php b/lib/Alchemy/Phrasea/Model/Entities/Task.php index 93bed32811..696531795f 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/Task.php +++ b/lib/Alchemy/Phrasea/Model/Entities/Task.php @@ -198,7 +198,7 @@ class Task */ public function setStatus($status) { - if (!in_array($status, array(static::STATUS_STARTED, static::STATUS_STOPPED), true)) { + if (!in_array($status, [static::STATUS_STARTED, static::STATUS_STOPPED], true)) { throw new InvalidArgumentException('Invalid status value.'); } diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index 916039f696..3f20659a49 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -48,7 +48,7 @@ class User * * @var array */ - private static $defaultUserSettings = array( + private static $defaultUserSettings = [ 'view' => 'thumbs', 'images_per_page' => '20', 'images_size' => '120', @@ -70,7 +70,7 @@ class User 'basket_caption_display' => '0', 'basket_status_display' => '0', 'basket_title_display' => '0' - ); + ]; /** * @ORM\Column(type="integer") @@ -439,11 +439,11 @@ class User */ public function setGender($gender) { - if (null !== $gender && !in_array($gender, array( + if (null !== $gender && !in_array($gender, [ self::GENDER_MISS, self::GENDER_MR, self::GENDER_MRS - ))) { + ])) { throw new InvalidArgumentException(sprintf("Invalid gender %s.", $gender)); } @@ -1018,7 +1018,7 @@ class User */ public function isSpecial() { - return in_array($this->login, array(self::USER_GUEST, self::USER_AUTOREGISTER)); + return in_array($this->login, [self::USER_GUEST, self::USER_AUTOREGISTER]); } /** diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php index 7763147922..865bd3c53f 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php +++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php @@ -111,7 +111,7 @@ class UsrListOwner */ public function setRole($role) { - if ( ! in_array($role, array(self::ROLE_ADMIN, self::ROLE_EDITOR, self::ROLE_USER))) + if ( ! in_array($role, [self::ROLE_ADMIN, self::ROLE_EDITOR, self::ROLE_USER])) throw new \Exception('Unknown role `' . $role . '`'); $this->role = $role; diff --git a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php index 64f87d1a9d..01eedfb30e 100644 --- a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php +++ b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php @@ -137,7 +137,7 @@ class UserManager private function cleanFtpExports(User $user) { $elements = $this->objectManager->getRepository('Alchemy\Phrasea\Model\Entities\FtpExport') - ->findBy(array('usrId' => $user->getId())); + ->findBy(['usrId' => $user->getId()]); foreach ($elements as $element) { $this->objectManager->remove($element); @@ -152,7 +152,7 @@ class UserManager private function cleanOrders(User $user) { $orders = $this->objectManager->getRepository('Alchemy\Phrasea\Model\Entities\Order') - ->findBy(array('usrId' => $user->getId())); + ->findBy(['usrId' => $user->getId()]); foreach ($orders as $order) { $this->objectManager->remove($order); @@ -166,13 +166,13 @@ class UserManager */ private function cleanProperties(User $user) { - foreach(array( + foreach ([ 'DELETE FROM `edit_presets` WHERE usr_id = :usr_id', 'DELETE FROM `sselnew` WHERE usr_id = :usr_id', 'DELETE FROM `tokens` WHERE usr_id = :usr_id', - ) as $sql) { + ] as $sql) { $stmt = $this->appboxConnection->prepare($sql); - $stmt->execute(array(':usr_id' => $user->getId())); + $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); } @@ -190,12 +190,12 @@ class UserManager */ private function cleanRights(User $user) { - foreach(array( + foreach ([ 'DELETE FROM `basusr` WHERE usr_id = :usr_id', 'DELETE FROM `sbasusr` WHERE usr_id = :usr_id', - ) as $sql) { + ] as $sql) { $stmt = $this->appboxConnection->prepare($sql); - $stmt->execute(array(':usr_id' => $user->getId())); + $stmt->execute([':usr_id' => $user->getId()]); $stmt->closeCursor(); } } diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php index 8b47cab291..430a466bc6 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php @@ -79,12 +79,12 @@ class ACLManipulator implements ManipulatorInterface { $collections = $databox->get_collections(); - $acl->update_rights_to_sbas($databox->get_sbas_id(), array( + $acl->update_rights_to_sbas($databox->get_sbas_id(), [ 'bas_manage' => '1', 'bas_modify_struct' => '1', 'bas_modif_th' => '1', 'bas_chupub' => '1' - )); + ]); $acl->give_access_to_base(array_map(function (\collection $collection) { return $collection->get_base_id(); @@ -108,7 +108,7 @@ class ACLManipulator implements ManipulatorInterface $acl->set_limits($baseId, false); $acl->remove_quotas_on_base($baseId); $acl->set_masks_on_base($baseId, '0', '0', '0', '0'); - $acl->update_rights_to_base($baseId, array( + $acl->update_rights_to_base($baseId, [ 'canputinalbum' => '1', 'candwnldhd' => '1', 'candwnldsubdef' => '1', @@ -127,7 +127,7 @@ class ACLManipulator implements ManipulatorInterface 'manage' => '1', 'modify_struct' => '1', 'bas_modify_struct' => '1' - )); + ]); } /** @@ -140,7 +140,7 @@ class ACLManipulator implements ManipulatorInterface private function makeTraversable($var) { if (!is_array($var) && !$var instanceof \Traversable) { - return array($var); + return [$var]; } return $var; diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php index 5edf389598..01b75ad7ab 100644 --- a/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php +++ b/lib/Alchemy/Phrasea/Model/Manipulator/UserManipulator.php @@ -293,7 +293,7 @@ class UserManipulator implements ManipulatorInterface private function makeTraversable($var) { if (!is_array($var) && !$var instanceof \Traversable) { - return array($var); + return [$var]; } return $var; diff --git a/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php b/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php index a944af7e9c..aee7ec3d80 100644 --- a/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php +++ b/lib/Alchemy/Phrasea/Model/MonologSQLLogger.php @@ -31,7 +31,7 @@ class MonologSQLLogger implements SQLLogger */ private $logger; private $start; - private $output = array(); + private $output = []; private $outputType; /** diff --git a/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php index 592c67c128..91e2d58863 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/AuthFailureRepository.php @@ -20,7 +20,7 @@ class AuthFailureRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\AuthFailure f WHERE f.created < :date'; - $params = array('date' => $date->format('Y-m-d h:i:s')); + $params = ['date' => $date->format('Y-m-d h:i:s')]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -35,10 +35,10 @@ class AuthFailureRepository extends EntityRepository WHERE (f.username = :username OR f.ip = :ip) AND f.locked = true'; - $params = array( + $params = [ 'username' => $username, 'ip' => $ip, - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php index fededd3268..1cd35e8f08 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php @@ -26,11 +26,11 @@ class BasketElementRepository extends EntityRepository WHERE (b.usr_id = :usr_id OR p.usr_id = :same_usr_id) AND e.id = :element_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), 'same_usr_id' => $user->get_id(), 'element_id' => $element_id - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -55,10 +55,10 @@ class BasketElementRepository extends EntityRepository WHERE e.record_id = :record_id AND e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -75,9 +75,9 @@ class BasketElementRepository extends EntityRepository LEFT JOIN s.participants p WHERE e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $databox->get_sbas_id(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -103,11 +103,11 @@ class BasketElementRepository extends EntityRepository AND e.record_id = :record_id AND e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'usr_id' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -126,11 +126,11 @@ class BasketElementRepository extends EntityRepository AND e.record_id = :record_id AND e.sbas_id = :sbas_id'; - $params = array( + $params = [ 'sbas_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'usr_id' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php index dd9595f534..e40653eed7 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php @@ -47,7 +47,7 @@ class BasketRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array('usr_id' => $user->get_id())); + $query->setParameters(['usr_id' => $user->get_id()]); return $query->getResult(); } @@ -74,11 +74,11 @@ class BasketRepository extends EntityRepository ) AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())'; - $params = array( + $params = [ 'usr_id_owner' => $user->get_id(), 'usr_id_ownertwo' => $user->get_id(), 'usr_id_participant' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -111,7 +111,7 @@ class BasketRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id())); + $query->setParameters([1 => $user->get_id(), 2 => $user->get_id()]); return $query->getResult(); } @@ -125,10 +125,10 @@ class BasketRepository extends EntityRepository WHERE e.record_id = :record_id AND e.sbas_id = e.sbas_id AND b.usr_id = :usr_id'; - $params = array( + $params = [ 'record_id' => $record->get_record_id(), 'usr_id' => $user->get_id() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -138,7 +138,7 @@ class BasketRepository extends EntityRepository public function findWorkzoneBasket(\User_Adapter $user, $query, $year, $type, $offset, $perPage) { - $params = array(); + $params = []; switch ($type) { case self::RECEIVED: @@ -146,9 +146,9 @@ class BasketRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\Basket b JOIN b.elements e WHERE b.usr_id = :usr_id AND b.pusher_id IS NOT NULL'; - $params = array( + $params = [ 'usr_id' => $user->get_id() - ); + ]; break; case self::VALIDATION_DONE: $dql = 'SELECT b @@ -157,10 +157,10 @@ class BasketRepository extends EntityRepository JOIN b.validation s JOIN s.participants p WHERE b.usr_id != ?1 AND p.usr_id = ?2'; - $params = array( + $params = [ 1 => $user->get_id() , 2 => $user->get_id() - ); + ]; break; case self::VALIDATION_SENT: $dql = 'SELECT b @@ -168,9 +168,9 @@ class BasketRepository extends EntityRepository JOIN b.elements e JOIN b.validation v WHERE b.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id() - ); + ]; break; default: $dql = 'SELECT b @@ -179,10 +179,10 @@ class BasketRepository extends EntityRepository LEFT JOIN b.validation s LEFT JOIN s.participants p WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), 'validating_usr_id' => $user->get_id() - ); + ]; break; case self::MYBASKETS: $dql = 'SELECT b @@ -191,9 +191,9 @@ class BasketRepository extends EntityRepository LEFT JOIN b.validation s LEFT JOIN s.participants p WHERE (b.usr_id = :usr_id)'; - $params = array( + $params = [ 'usr_id' => $user->get_id() - ); + ]; break; } @@ -249,7 +249,7 @@ class BasketRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array('usr_id' => $user->get_id())); + $query->setParameters(['usr_id' => $user->get_id()]); return $query->getResult(); } diff --git a/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php index 272f0f22ba..3e3f38d75b 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/FeedItemRepository.php @@ -34,7 +34,7 @@ class FeedItemRepository extends EntityRepository AND f.public = true'; $query = $this->_em->createQuery($dql); - $query->setParameters(array('sbas_id' => $sbas_id, 'record_id' => $record_id)); + $query->setParameters(['sbas_id' => $sbas_id, 'record_id' => $record_id]); return count($query->getResult()) > 0; } @@ -50,7 +50,7 @@ class FeedItemRepository extends EntityRepository public function loadLatest(Application $app, $nbItems = 20) { $execution = 0; - $items = array(); + $items = []; do { $dql = 'SELECT i diff --git a/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php index 94eaeb789e..472f40c56d 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php @@ -59,6 +59,6 @@ class FtpExportRepository extends EntityRepository */ public function findByUser(\User_Adapter $user) { - return $this->findBy(array('usrId' => $user->get_id())); + return $this->findBy(['usrId' => $user->get_id()]); } } diff --git a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php index d36e8d026a..c89ddb374d 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php @@ -21,7 +21,7 @@ class OrderRepository extends EntityRepository */ public function findByUser(\User_Adapter $user) { - return $this->findBy(array('usrId' => $user->get_id())); + return $this->findBy(['usrId' => $user->get_id()]); } /** @@ -66,7 +66,7 @@ class OrderRepository extends EntityRepository * * @return integer */ - public function countTotalOrders(array $baseIds = array()) + public function countTotalOrders(array $baseIds = []) { $qb = $this ->createQueryBuilder('o'); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php index b7b73a0c98..5847feb2d0 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php @@ -25,7 +25,7 @@ class StoryWZRepository extends EntityRepository } $query = $this->_em->createQuery($dql); - $query->setParameters(array('usr_id' => $user->get_id())); + $query->setParameters(['usr_id' => $user->get_id()]); $stories = $query->getResult(); @@ -41,7 +41,7 @@ class StoryWZRepository extends EntityRepository $this->getEntityManager()->flush(); if ($sort == 'name') { - $sortedStories = array(); + $sortedStories = []; foreach ($stories as $story) { $sortedStories[] = $story->getRecord($app)->get_title(); } @@ -87,11 +87,11 @@ class StoryWZRepository extends EntityRepository public function findUserStory(Application $app, \User_Adapter $user, \record_adapter $Story) { $story = $this->findOneBy( - array( + [ 'usr_id' => $user->get_id(), 'sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id(), - ) + ] ); if ($story) { @@ -113,10 +113,10 @@ class StoryWZRepository extends EntityRepository AND s.record_id = :record_id'; $query = $this->_em->createQuery($dql); - $query->setParameters(array( + $query->setParameters([ 'sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id(), - )); + ]); $stories = $query->getResult(); @@ -138,9 +138,9 @@ class StoryWZRepository extends EntityRepository $dql = 'SELECT s FROM Alchemy\Phrasea\Model\Entities\StoryWZ s WHERE s.sbas_id = :sbas_id'; $query = $this->_em->createQuery($dql); - $query->setParameters(array( + $query->setParameters([ 'sbas_id' => $databox->get_sbas_id(), - )); + ]); $stories = $query->getResult(); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php index 2181933111..f9283bc82a 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UserRepository.php @@ -47,7 +47,7 @@ class UserRepository extends EntityRepository */ public function findByLogin($login) { - return $this->findOneBy(array('login' => $login)); + return $this->findOneBy(['login' => $login]); } /** diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php index 34e4d43e97..dd5409293c 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php @@ -18,7 +18,7 @@ class UsrAuthProviderRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\UsrAuthProvider u WHERE u.usr_id = :usrId'; - $params = array('usrId' => $user->get_id()); + $params = ['usrId' => $user->get_id()]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -32,7 +32,7 @@ class UsrAuthProviderRepository extends EntityRepository FROM Alchemy\Phrasea\Model\Entities\UsrAuthProvider u WHERE u.provider = :providerId AND u.distant_id = :distantId'; - $params = array('providerId' => $providerId, 'distantId' => $distantId); + $params = ['providerId' => $providerId, 'distantId' => $distantId]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php index b9d2900ea1..9d41de33d0 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php @@ -28,9 +28,9 @@ class UsrListEntryRepository extends EntityRepository $dql = 'SELECT e FROM Alchemy\Phrasea\Model\Entities\UsrListEntry e WHERE e.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -60,10 +60,10 @@ class UsrListEntryRepository extends EntityRepository JOIN e.list l WHERE e.usr_id = :usr_id AND l.id = :list_id'; - $params = array( + $params = [ 'usr_id' => $usr_id, 'list_id' => $list->getId(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php index 7c66fb4fb1..eb3b8fb2a8 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListOwnerRepository.php @@ -53,10 +53,10 @@ class UsrListOwnerRepository extends EntityRepository JOIN o.list l WHERE l.id = :list_id AND o.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $usr_id, 'list_id' => $list->getId() - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php index a7fcc9e9ca..38a5e4aa4b 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php @@ -29,9 +29,9 @@ class UsrListRepository extends EntityRepository JOIN l.owners o WHERE o.usr_id = :usr_id'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); @@ -74,10 +74,10 @@ class UsrListRepository extends EntityRepository JOIN l.owners o WHERE o.usr_id = :usr_id AND l.name LIKE :name'; - $params = array( + $params = [ 'usr_id' => $user->get_id(), 'name' => $name . '%' - ); + ]; $query = $this->_em->createQuery($dql); $query->setParameters($params); diff --git a/lib/Alchemy/Phrasea/Notification/Deliverer.php b/lib/Alchemy/Phrasea/Notification/Deliverer.php index 6a09287db5..7fa2781968 100644 --- a/lib/Alchemy/Phrasea/Notification/Deliverer.php +++ b/lib/Alchemy/Phrasea/Notification/Deliverer.php @@ -68,7 +68,7 @@ class Deliverer if (!$mail->getEmitter()) { throw new LogicException('You must provide an emitter for a ReadReceipt'); } - $message->setReadReceiptTo(array($mail->getEmitter()->getEmail() => $mail->getEmitter()->getName())); + $message->setReadReceiptTo([$mail->getEmitter()->getEmail() => $mail->getEmitter()->getName()]); } $ret = $this->mailer->send($message); diff --git a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php index 016b724962..2fd672a58a 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/AbstractMail.php @@ -47,7 +47,7 @@ abstract class AbstractMail implements MailInterface */ public function renderHTML() { - return $this->app['twig']->render('email-template.html.twig', array( + return $this->app['twig']->render('email-template.html.twig', [ 'phraseanetURL' => $this->getPhraseanetURL(), 'phraseanetTitle' => $this->getPhraseanetTitle(), 'logoUrl' => $this->getLogoUrl(), @@ -59,7 +59,7 @@ abstract class AbstractMail implements MailInterface 'expiration' => $this->getExpiration(), 'buttonUrl' => $this->getButtonURL(), 'buttonText' => $this->getButtonText(), - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php index 17cd0b220c..2776425cf8 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoSomebodyAutoregistered.php @@ -45,6 +45,6 @@ class MailInfoSomebodyAutoregistered extends AbstractMailWithLink */ public function getButtonURL() { - return $this->app->url('admin', array('section' => 'users')); + return $this->app->url('admin', ['section' => 'users']); } } diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php index 0981334531..0516af5e60 100644 --- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php +++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php @@ -65,6 +65,6 @@ class MailInfoUserRegistered extends AbstractMail */ public function getButtonURL() { - return $this->app->url('admin', array('section' => 'registrations')); + return $this->app->url('admin', ['section' => 'registrations']); } } diff --git a/lib/Alchemy/Phrasea/Out/Module/PDF.php b/lib/Alchemy/Phrasea/Out/Module/PDF.php index ec2d10562f..6f1b811801 100644 --- a/lib/Alchemy/Phrasea/Out/Module/PDF.php +++ b/lib/Alchemy/Phrasea/Out/Module/PDF.php @@ -36,7 +36,7 @@ class PDF { $this->app = $app; - $list = array(); + $list = []; foreach ($records as $record) { switch ($layout) { @@ -458,8 +458,8 @@ class PDF $this->pdf->SetFont(PhraseaPDF::FONT, '', 12); $t = str_replace( - array("<", ">", "&") - , array("<", ">", "&") + ["<", ">", "&"] + , ["<", ">", "&"] , strip_tags($field->get_serialized_values()) ); diff --git a/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php b/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php index e74656fd56..d0d6e363a0 100644 --- a/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php +++ b/lib/Alchemy/Phrasea/Plugin/Exception/JsonValidationException.php @@ -17,7 +17,7 @@ class JsonValidationException extends RuntimeException { protected $errors; - public function __construct($message, $errors = array()) + public function __construct($message, $errors = []) { $this->errors = $errors; parent::__construct($message); diff --git a/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php b/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php index 79394d8fca..3ba13cf9bf 100644 --- a/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php +++ b/lib/Alchemy/Phrasea/Plugin/Management/ComposerInstaller.php @@ -66,12 +66,12 @@ class ComposerInstaller throw new ComposerInstallException('Unable to install composer.', $e->getCode(), $e); } } else { - $process = ProcessBuilder::create(array( + $process = ProcessBuilder::create([ $this->phpExecutable, $this->composer, 'self-update' - ))->getProcess(); + ])->getProcess(); $process->run(); } - return ProcessBuilder::create(array($this->phpExecutable, $this->composer)); + return ProcessBuilder::create([$this->phpExecutable, $this->composer]); } } diff --git a/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php b/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php index 779909c690..ecbee28b98 100644 --- a/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php +++ b/lib/Alchemy/Phrasea/Plugin/Schema/Manifest.php @@ -67,17 +67,17 @@ class Manifest public function getServices() { - return $this->get('services') ? : array(); + return $this->get('services') ? : []; } public function getCommands() { - return $this->get('commands') ? : array(); + return $this->get('commands') ? : []; } public function getTwigPaths() { - return $this->get('twig-paths') ? : array(); + return $this->get('twig-paths') ? : []; } public function getExtra() diff --git a/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php b/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php index 26e9d18c5b..1f368f6c26 100644 --- a/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php +++ b/lib/Alchemy/Phrasea/Plugin/Schema/ManifestValidator.php @@ -45,7 +45,7 @@ class ManifestValidator $this->validator->check($data, $this->schemaData); if (!$this->validator->isValid()) { - $errors = array(); + $errors = []; foreach ((array) $this->validator->getErrors() as $error) { $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message']; } @@ -53,7 +53,7 @@ class ManifestValidator } if (!preg_match('/^[a-z0-9-_]+$/', $data->name)) { - throw new JsonValidationException('Does not match the expected JSON schema', array('"name" must not contains only alphanumeric caracters')); + throw new JsonValidationException('Does not match the expected JSON schema', ['"name" must not contains only alphanumeric caracters']); } if (isset($data->{'minimum-phraseanet-version'})) { diff --git a/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php b/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php index c963a0c363..0f10b199f0 100644 --- a/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php +++ b/lib/Alchemy/Phrasea/Plugin/Schema/PluginValidator.php @@ -95,7 +95,7 @@ class PluginValidator } if (is_array($data)) { - return array_map(array($this, 'objectToArray'), $data); + return array_map([$this, 'objectToArray'], $data); } return $data; diff --git a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php index 10b54c187b..d9099e22a6 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php @@ -20,7 +20,7 @@ abstract class AbstractConfigurationPanel implements ConfigurationPanelInterface */ public function getAvailableDateFields(array $databoxes) { - $date_fields = array(); + $date_fields = []; foreach ($databoxes as $databox) { foreach ($databox->get_meta_structure() as $field) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php index 2c408ce979..5ae8ede86a 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php @@ -42,10 +42,10 @@ class ConfigurationPanel extends AbstractConfigurationPanel { $configuration = $this->getConfiguration(); - $params = array( + $params = [ 'configuration' => $configuration, 'available_sort'=> $this->searchEngine->getAvailableSort(), - ); + ]; return $app['twig']->render('admin/search-engine/phrasea.html.twig', $params); } @@ -56,9 +56,9 @@ class ConfigurationPanel extends AbstractConfigurationPanel public function post(Application $app, Request $request) { $configuration = $this->getConfiguration(); - $configuration['date_fields'] = array(); + $configuration['date_fields'] = []; - foreach ($request->request->get('date_fields', array()) as $field) { + foreach ($request->request->get('date_fields', []) as $field) { $configuration['date_fields'][] = $field; } @@ -75,14 +75,14 @@ class ConfigurationPanel extends AbstractConfigurationPanel */ public function getConfiguration() { - $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : array(); + $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : []; if (!is_array($configuration)) { - $configuration = array(); + $configuration = []; } if (!isset($configuration['date_fields'])) { - $configuration['date_fields'] = array(); + $configuration['date_fields'] = []; } if (!isset($configuration['default_sort'])) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php index 81ab20947c..a5bcd9c604 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php @@ -32,11 +32,11 @@ class PhraseaEngine implements SearchEngineInterface private $app; private $dateFields; private $configuration; - private $queries = array(); - private $arrayq = array(); - private $colls = array(); - private $qp = array(); - private $needthesaurus = array(); + private $queries = []; + private $arrayq = []; + private $colls = []; + private $qp = []; + private $needthesaurus = []; private $configurationPanel; private $resetCacheNextQuery = false; @@ -63,7 +63,7 @@ class PhraseaEngine implements SearchEngineInterface public function getAvailableDateFields() { if (!$this->dateFields) { - $this->dateFields = array(); + $this->dateFields = []; foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($databox->get_meta_structure() as $databox_field) { if ($databox_field->get_type() != \databox_field::TYPE_DATE) { @@ -109,7 +109,7 @@ class PhraseaEngine implements SearchEngineInterface { $date_fields = $this->getAvailableDateFields(); - $sort = array('' => _('No sort')); + $sort = ['' => _('No sort')]; foreach ($date_fields as $field) { $sort[$field] = $field; @@ -133,10 +133,10 @@ class PhraseaEngine implements SearchEngineInterface */ public function getAvailableOrder() { - return array( + return [ 'desc' => _('descendant'), 'asc' => _('ascendant'), - ); + ]; } /** @@ -214,9 +214,9 @@ class PhraseaEngine implements SearchEngineInterface */ public function getStatus() { - $status = array(); + $status = []; foreach (phrasea_info() as $key => $value) { - $status[] = array($key, $value); + $status[] = [$key, $value]; } return $status; @@ -239,7 +239,7 @@ class PhraseaEngine implements SearchEngineInterface */ public function getAvailableTypes() { - return array(self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY); + return [self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY]; } /** @@ -259,17 +259,17 @@ class PhraseaEngine implements SearchEngineInterface $sql = "DELETE FROM prop WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record->get_record_id())); + $stmt->execute([':record_id' => $record->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM idx WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record->get_record_id())); + $stmt->execute([':record_id' => $record->get_record_id()]); $stmt->closeCursor(); $sql = "DELETE FROM thit WHERE record_id = :record_id"; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $record->get_record_id())); + $stmt->execute([':record_id' => $record->get_record_id()]); $stmt->closeCursor(); unset($stmt, $connbas); @@ -377,7 +377,7 @@ class PhraseaEngine implements SearchEngineInterface $sql = 'SELECT query, query_time, duration, total FROM cache WHERE session_id = :ses_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':ses_id' => $this->app['session']->get('phrasea_session_id'))); + $stmt->execute([':ses_id' => $this->app['session']->get('phrasea_session_id')]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -398,7 +398,7 @@ class PhraseaEngine implements SearchEngineInterface $sql = 'SELECT query, query_time, duration, total FROM cache WHERE session_id = :ses_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':ses_id' => $this->app['session']->get('phrasea_session_id'))); + $stmt->execute([':ses_id' => $this->app['session']->get('phrasea_session_id')]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); } else { @@ -412,7 +412,7 @@ class PhraseaEngine implements SearchEngineInterface $this->app['session']->get('phrasea_session_id'), $offset + 1, $perPage, false ); - $rs = array(); + $rs = []; $error = _('Unable to execute query'); if (isset($res['results']) && is_array($res['results'])) { @@ -450,7 +450,7 @@ class PhraseaEngine implements SearchEngineInterface */ private function getSuggestions($query) { - $suggestions = array(); + $suggestions = []; if ($this->qp && isset($this->qp['main'])) { $suggestions = array_map(function ($value) use ($query) { @@ -512,7 +512,7 @@ class PhraseaEngine implements SearchEngineInterface * * @return PhraseaEngine */ - public static function create(Application $app, array $options = array()) + public static function create(Application $app, array $options = []) { return new static($app); } @@ -542,7 +542,7 @@ class PhraseaEngine implements SearchEngineInterface } foreach ($this->queries as $sbas_id => $qry) { - $BF = array(); + $BF = []; foreach ($this->options->getBusinessFieldsOn() as $collection) { // limit business field query to databox local collection @@ -575,12 +575,12 @@ class PhraseaEngine implements SearchEngineInterface SET query = :query, query_time = NOW(), duration = :duration, total = :total WHERE session_id = :ses_id'; - $params = array( + $params = [ 'query' => $query, ':ses_id' => $this->app['session']->get('phrasea_session_id'), ':duration' => $total_time, ':total' => $nbanswers, - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -602,7 +602,7 @@ class PhraseaEngine implements SearchEngineInterface */ public function excerpt($query, $fields, \record_adapter $record) { - $ret = array(); + $ret = []; $this->initialize(); $this->checkSession(); @@ -613,22 +613,22 @@ class PhraseaEngine implements SearchEngineInterface ); if (!isset($res['results']) || !is_array($res['results'])) { - return array(); + return []; } $rs = $res['results']; $res = array_shift($rs); if (!isset($res['xml'])) { - return array(); + return []; } $sxe = @simplexml_load_string($res['xml']); foreach ($fields as $name => $field) { if ($sxe && $sxe->description && $sxe->description->$name) { - $val = array(); + $val = []; foreach ($sxe->description->$name as $value) { - $val[] = str_replace(array('[[em]]', '[[/em]]'), array('', ''), (string) $value); + $val[] = str_replace(['[[em]]', '[[/em]]'], ['', ''], (string) $value); } $separator = $field['separator'] ? $field['separator'][0] : ''; $val = implode(' ' . $separator . ' ', $val); @@ -648,7 +648,7 @@ class PhraseaEngine implements SearchEngineInterface public function resetCache() { $this->resetCacheNextQuery = true; - $this->queries = $this->arrayq = $this->colls = $this->qp = $this->needthesaurus = array(); + $this->queries = $this->arrayq = $this->colls = $this->qp = $this->needthesaurus = []; return $this; } @@ -721,7 +721,7 @@ class PhraseaEngine implements SearchEngineInterface foreach ($this->options->getDataboxes() as $databox) { $sbas_id = $databox->get_sbas_id(); - $this->colls[$sbas_id] = array(); + $this->colls[$sbas_id] = []; foreach ($databox->get_collections() as $collection) { if (in_array($collection->get_base_id(), $base_ids)) { @@ -803,7 +803,7 @@ class PhraseaEngine implements SearchEngineInterface $sql = "SELECT session_id FROM cache WHERE lastaccess <= :date"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':date' => $date->format(DATE_ISO8601))); + $stmt->execute([':date' => $date->format(DATE_ISO8601)]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php index 24002f2f79..e0f08457e2 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngineQueryParser.php @@ -21,53 +21,53 @@ use Alchemy\Phrasea\Application; */ class PhraseaEngineQueryParser { - public $ops = array( - "et" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false), - "and" => array("NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false), - "ou" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false), - "or" => array("NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false), - "sauf" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false), - "except" => array("NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false), - "pres" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true), - "near" => array("NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true), - "avant" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true), - "before" => array("NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true), - "apres" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true), - "after" => array("NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true), - "dans" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false), - "in" => array("NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false) - ); - public $opk = array( - "<" => array("NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false), - ">" => array("NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false), - "<=" => array("NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false), - ">=" => array("NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false), - "<>" => array("NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false), - "=" => array("NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false), - ":" => array("NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false) - ); - public $spw = array( - "all" => array( + public $ops = [ + "et" => ["NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false], + "and" => ["NODETYPE" => PHRASEA_OP_AND, "CANNUM" => false], + "ou" => ["NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false], + "or" => ["NODETYPE" => PHRASEA_OP_OR, "CANNUM" => false], + "sauf" => ["NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false], + "except" => ["NODETYPE" => PHRASEA_OP_EXCEPT, "CANNUM" => false], + "pres" => ["NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true], + "near" => ["NODETYPE" => PHRASEA_OP_NEAR, "CANNUM" => true], + "avant" => ["NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true], + "before" => ["NODETYPE" => PHRASEA_OP_BEFORE, "CANNUM" => true], + "apres" => ["NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true], + "after" => ["NODETYPE" => PHRASEA_OP_AFTER, "CANNUM" => true], + "dans" => ["NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false], + "in" => ["NODETYPE" => PHRASEA_OP_IN, "CANNUM" => false] + ]; + public $opk = [ + "<" => ["NODETYPE" => PHRASEA_OP_LT, "CANNUM" => false], + ">" => ["NODETYPE" => PHRASEA_OP_GT, "CANNUM" => false], + "<=" => ["NODETYPE" => PHRASEA_OP_LEQT, "CANNUM" => false], + ">=" => ["NODETYPE" => PHRASEA_OP_GEQT, "CANNUM" => false], + "<>" => ["NODETYPE" => PHRASEA_OP_NOTEQU, "CANNUM" => false], + "=" => ["NODETYPE" => PHRASEA_OP_EQUAL, "CANNUM" => false], + ":" => ["NODETYPE" => PHRASEA_OP_COLON, "CANNUM" => false] + ]; + public $spw = [ + "all" => [ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false - ), - "last" => array( + ], + "last" => [ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true - ), + ], // "first" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true), // "premiers" => array("CLASS"=>PHRASEA_KW_FIRST, "CANNUM"=>true), - "tout" => array( + "tout" => [ "CLASS" => "PHRASEA_KW_ALL", "NODETYPE" => PHRASEA_KW_ALL, "CANNUM" => false - ), - "derniers" => array( + ], + "derniers" => [ "CLASS" => "PHRASEA_KW_LAST", "NODETYPE" => PHRASEA_KW_LAST, "CANNUM" => true - ) - ); - public $quoted_defaultop = array( + ] + ]; + public $quoted_defaultop = [ "VALUE" => "default_avant", "NODETYPE" => PHRASEA_OP_BEFORE, "PNUM" => 0 - ); - public $defaultop = array( + ]; + public $defaultop = [ "VALUE" => "and", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL - ); + ]; public $defaultlast = 12; public $phq; public $errmsg = ""; @@ -84,7 +84,7 @@ class PhraseaEngineQueryParser * * @var array */ - public $proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array()); + public $proposals = ["QRY" => "", "BASES" => [], "QUERIES" => []]; public $app; /** @@ -121,7 +121,7 @@ class PhraseaEngineQueryParser } } - $this->proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array()); + $this->proposals = ["QRY" => "", "BASES" => [], "QUERIES" => []]; $this->phq = $this->mb_trim($phq, 'UTF-8'); if ($this->phq != "") { return($this->maketree(0)); @@ -377,13 +377,13 @@ class PhraseaEngineQueryParser if ($tree["CLASS"] == "OPK" && ($tree["RB"]["CLASS"] == "OPS")) { // on a un truc du genre (a = (5 ou 6)), on le transforme en ((a = 5) ou (a = 6)) - $tmp = array("CLASS" => $tree["CLASS"], + $tmp = ["CLASS" => $tree["CLASS"], "NODETYPE" => $tree["NODETYPE"], "VALUE" => $tree["VALUE"], "PNUM" => $tree["PNUM"], "LB" => $tree["LB"], "RB" => $tree["RB"]["RB"], - "DEPTH" => $tree["LB"]["DEPTH"]); + "DEPTH" => $tree["LB"]["DEPTH"]]; $t = $tree["RB"]; $tree["RB"] = $t["LB"]; $t["LB"] = $tree; @@ -403,7 +403,7 @@ class PhraseaEngineQueryParser } if (($tree["CLASS"] == "SIMPLE" || $tree["CLASS"] == "QSIMPLE") && isset($tree["SREF"]) && isset($tree["SREF"]["TIDS"])) { - $tids = array(); + $tids = []; foreach ($tree["SREF"]["TIDS"] as $tid) { if ($tid["bid"] == $bid) $tids[] = $tid["pid"]; @@ -422,7 +422,7 @@ class PhraseaEngineQueryParser $tree["VALUE"] = array("^" . $val); } */ - $tree["VALUE"] = array(); + $tree["VALUE"] = []; foreach ($tids as $tid) $tree["VALUE"][] = str_replace(".", "d", $tid) . "d%";; } else { @@ -506,26 +506,26 @@ class PhraseaEngineQueryParser } if ($keepFullText) { // on fait un OU entre la recherche ft et une recherche th - $tmp = array("CLASS" => "OPS", + $tmp = ["CLASS" => "OPS", "NODETYPE" => PHRASEA_OP_OR, "VALUE" => "OR", "PNUM" => null, "DEPTH" => $simple["DEPTH"], "LB" => $simple, - "RB" => array("CLASS" => "OPK", + "RB" => ["CLASS" => "OPK", "NODETYPE" => PHRASEA_OP_COLON, "VALUE" => ":", // "CONTEXT"=>$context, "PNUM" => null, "DEPTH" => $simple["DEPTH"] + 1, - "LB" => array("CLASS" => "SIMPLE", + "LB" => ["CLASS" => "SIMPLE", "NODETYPE" => PHRASEA_KEYLIST, - "VALUE" => array("*"), + "VALUE" => ["*"], "DEPTH" => $simple["DEPTH"] + 2 - ), + ], "RB" => $simple - ) - ); + ] + ]; // on vire le contexte du coté fulltext unset($tmp["LB"]["CONTEXT"]); // ajoute le contexte si nécéssaire @@ -542,19 +542,19 @@ class PhraseaEngineQueryParser $tmp["RB"]["RB"]["PATH"] = $path; } else { // on remplace le ft par du th - $tmp = array("CLASS" => "OPK", + $tmp = ["CLASS" => "OPK", "NODETYPE" => PHRASEA_OP_COLON, "VALUE" => ":", // "CONTEXT"=>$context, "PNUM" => null, "DEPTH" => $simple["DEPTH"] + 1, - "LB" => array("CLASS" => "SIMPLE", + "LB" => ["CLASS" => "SIMPLE", "NODETYPE" => PHRASEA_KEYLIST, - "VALUE" => array("*"), + "VALUE" => ["*"], "DEPTH" => $simple["DEPTH"] + 1 - ), + ], "RB" => $simple - ); + ]; // ajoute le contexte si nécéssaire if ($context !== null) $tmp["CONTEXT"] = $context; @@ -577,7 +577,7 @@ class PhraseaEngineQueryParser print("thesaurus2:\n\$tree=" . var_export($tree, true) . "\n"); if ($depth == 0) - $this->proposals["BASES"]["b$bid"] = array("BID" => $bid, "NAME" => $name, "TERMS" => array()); + $this->proposals["BASES"]["b$bid"] = ["BID" => $bid, "NAME" => $name, "TERMS" => []]; if (!$tree) { return(0); @@ -597,14 +597,14 @@ class PhraseaEngineQueryParser public function propAsHTML(&$node, &$html, $path, $depth = 0) { if ($depth > 0) { - $tsy = array(); + $tsy = []; $lngfound = "?"; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeName == "sy") { $lng = $n->getAttribute("lng"); if (!array_key_exists($lng, $tsy)) - $tsy[$lng] = array(); - $zsy = array("v" => $n->getAttribute("v"), "w" => $n->getAttribute("w"), "k" => $n->getAttribute("k"), "lng" => $lng); + $tsy[$lng] = []; + $zsy = ["v" => $n->getAttribute("v"), "w" => $n->getAttribute("w"), "k" => $n->getAttribute("k"), "lng" => $lng]; if ($lngfound == "?" || ($lng == $this->lng && $lngfound != $lng)) { $lngfound = $lng; @@ -625,7 +625,7 @@ class PhraseaEngineQueryParser $ksug = $syfound["w"] . '(' . $syfound["k"] . ')'; $vsug = $syfound["w"] . ($syfound["k"] ? (' (' . $syfound["k"] . ')'):''); - $this->proposals['QUERIES'][$ksug] = array('value'=>$vsug, 'current'=>$node->getAttribute("marked")=="2", 'hits'=>null, 'lng'=>$syfound['lng']); + $this->proposals['QUERIES'][$ksug] = ['value'=>$vsug, 'current'=>$node->getAttribute("marked")=="2", 'hits'=>null, 'lng'=>$syfound['lng']]; $thtml = $syfound["v"]; $kjs = $syfound["k"] ? ("'" . \p4string::MakeString($syfound["k"], "js") . "'") : "null"; @@ -641,7 +641,7 @@ class PhraseaEngineQueryParser $html .= $tab . "\t" . $thtml . "\n"; } - $tsort = array(); + $tsort = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if ($n->nodeType == XML_ELEMENT_NODE && $n->getAttribute("marked")) { // only 'te' marked $lngfound = '?'; @@ -748,7 +748,7 @@ class PhraseaEngineQueryParser $nodes = $dxp->query($x); if (!isset($tree["RB"]["SREF"]["TIDS"])) - $tree["RB"]["SREF"]["TIDS"] = array(); + $tree["RB"]["SREF"]["TIDS"] = []; if ($nodes->length >= 1) { if ($nodes->length == 1) { // on cherche un id simple, on utilisera la syntaxe sql 'like' (l'extension repérera elle méme la syntaxe car la value finira par '%') @@ -821,16 +821,16 @@ class PhraseaEngineQueryParser } } if (!$found) - $extendednode["SREF"]["TIDS"][] = array("bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p); + $extendednode["SREF"]["TIDS"][] = ["bid" => $bid, "pid" => $pid, "id" => $id, "w" => $w, "k" => $k, "lng" => $lng, "p" => $p]; // on liste les propositions de thésaurus pour ce node (dans l'arbre simple) if (!isset($this->proposals["BASES"]["b$bid"]["TERMS"][$path])) { - // $this->proposals["TERMS"][$path] = array("TERM"=>implode(" ", $extendednode["VALUE"]), "PROPOSALS"=>array()); + // $this->proposals["TERMS"][$path] = array("TERM"=>implode(" ", $extendednode["VALUE"]), "PROPOSALS"=>[]); $term = implode(" ", $extendednode["VALUE"]); if (isset($extendednode["CONTEXT"]) && $extendednode["CONTEXT"]) { $term .= " (" . $extendednode["CONTEXT"] . ")"; } - $this->proposals["BASES"]["b$bid"]["TERMS"][$path] = array("TERM" => $term); // , "PROPOSALS"=>array() ); //, "PROPOSALS_TREE"=>new DOMDocument("1.0", "UTF-8")); + $this->proposals["BASES"]["b$bid"]["TERMS"][$path] = ["TERM" => $term]; // , "PROPOSALS"=>[] ); //, "PROPOSALS_TREE"=>new DOMDocument("1.0", "UTF-8")); } // printf("<%s id='%s'>
\n", $DOMnode->tagName, $DOMnode->getAttribute("id")); // printf("found node <%s id='%s' w='%s' k='%s'>
\n", $DOMnode->nodeName, $DOMnode->getAttribute('id'), $DOMnode->getAttribute('w'), $DOMnode->getAttribute('k')); @@ -854,7 +854,7 @@ class PhraseaEngineQueryParser public function astext_ambigu($tree, &$ambiguites, $mouseCallback = "void", $depth = 0) { if ($depth == 0) { - $ambiguites = array("n" => 0, "refs" => array()); + $ambiguites = ["n" => 0, "refs" => []]; } switch ($tree["CLASS"]) { case "SIMPLE": @@ -914,7 +914,7 @@ class PhraseaEngineQueryParser } if ($depth == 0) { - $t_ambiguites = array(); + $t_ambiguites = []; $r = ($this->astext_ambigu($tree, $t_ambiguites, $mouseCallback)); $t_ambiguites["query"] = $r; @@ -984,26 +984,26 @@ class PhraseaEngineQueryParser $pnum++; } else { if ($treetmp == null) { - $treetmp = array("CLASS" => $tree["CLASS"], + $treetmp = ["CLASS" => $tree["CLASS"], "NODETYPE" => $tree["NODETYPE"], "VALUE" => $tree["VALUE"][$i], "PNUM" => $tree["PNUM"], - "DEPTH" => $tree["DEPTH"]); + "DEPTH" => $tree["DEPTH"]]; $pnum = 0; } else { $dop = $tree["CLASS"] == "QSIMPLE" ? $this->quoted_defaultop : $this->defaultop; - $treetmp = array("CLASS" => "OPS", + $treetmp = ["CLASS" => "OPS", "VALUE" => $dop["VALUE"], "NODETYPE" => $dop["NODETYPE"], "PNUM" => $pnum, // peut-être écrasé par defaultop "DEPTH" => $depth, "LB" => $treetmp, - "RB" => array("CLASS" => $tree["CLASS"], + "RB" => ["CLASS" => $tree["CLASS"], "NODETYPE" => $tree["NODETYPE"], "VALUE" => $tree["VALUE"][$i], "PNUM" => $tree["PNUM"], - "DEPTH" => $tree["DEPTH"]) - ); + "DEPTH" => $tree["DEPTH"]] + ]; if (array_key_exists("PNUM", $dop)) $treetmp["PNUM"] = $dop["PNUM"]; $pnum = 0; @@ -1031,7 +1031,7 @@ class PhraseaEngineQueryParser if ($tree["NODETYPE"] == PHRASEA_OP_OR && ($tree["LB"]["CLASS"] == "SIMPLE" || $tree["LB"]["CLASS"] == "QSIMPLE") && ($tree["RB"]["CLASS"] == "SIMPLE" || $tree["RB"]["CLASS"] == "QSIMPLE")) { $tree["CLASS"] = "SIMPLE"; $tree["NODETYPE"] = PHRASEA_KEYLIST; - $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : array($tree["LB"]["VALUE"]); + $tree["VALUE"] = is_array($tree["LB"]["VALUE"]) ? $tree["LB"]["VALUE"] : [$tree["LB"]["VALUE"]]; if (is_array($tree["RB"]["VALUE"])) { foreach ($tree["RB"]["VALUE"] as $v) $tree["VALUE"][] = $v; @@ -1094,41 +1094,41 @@ class PhraseaEngineQueryParser ## creation branche gauche avec ">=" // print("changeNodeEquals2\n"); // print("creation branche gauche ( '>=' ) \n"); - $newTreeLB = array("CLASS" => "OPK", + $newTreeLB = ["CLASS" => "OPK", "VALUE" => ">=", "NODETYPE" => PHRASEA_OP_GEQT, "PNUM" => NULL, "DEPTH" => 0, "LB" => $oneBranch["LB"], - "RB" => array("CLASS" => "SIMPLE", + "RB" => ["CLASS" => "SIMPLE", "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], false), "NODETYPE" => PHRASEA_KEYLIST, "PNUM" => NULL, - "DEPTH" => 0) - ); + "DEPTH" => 0] + ]; - $newTreeRB = array("CLASS" => "OPK", + $newTreeRB = ["CLASS" => "OPK", "VALUE" => "<=", "NODETYPE" => PHRASEA_OP_LEQT, "PNUM" => NULL, "DEPTH" => 0, "LB" => $oneBranch["LB"], - "RB" => array("CLASS" => "SIMPLE", + "RB" => ["CLASS" => "SIMPLE", "VALUE" => $this->isoDate($oneBranch["RB"]["VALUE"], true), "NODETYPE" => PHRASEA_KEYLIST, "PNUM" => NULL, - "DEPTH" => 0) - ); + "DEPTH" => 0] + ]; // print("fin creation branche droite avec '<=' \n"); ## fin creation branche droite ( "<=" ) - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => NULL, "DEPTH" => 0, "LB" => $newTreeLB, - "RB" => $newTreeRB); + "RB" => $newTreeRB]; return $tree; } @@ -1282,7 +1282,7 @@ class PhraseaEngineQueryParser public function distrib_in(&$tree, $depth = 0) { - $opdistrib = array(PHRASEA_OP_AND, PHRASEA_OP_OR, PHRASEA_OP_EXCEPT, PHRASEA_OP_NEAR, PHRASEA_OP_BEFORE, PHRASEA_OP_AFTER); // ces opérateurs sont 'distribuables' autour d'un 'IN' + $opdistrib = [PHRASEA_OP_AND, PHRASEA_OP_OR, PHRASEA_OP_EXCEPT, PHRASEA_OP_NEAR, PHRASEA_OP_BEFORE, PHRASEA_OP_AFTER]; // ces opérateurs sont 'distribuables' autour d'un 'IN' if ($tree["CLASS"] == "OPS" || $tree["CLASS"] == "OPK") { if ($tree["NODETYPE"] == PHRASEA_OP_IN || $tree["CLASS"] == "OPK") { @@ -1308,12 +1308,12 @@ class PhraseaEngineQueryParser $tree["LB"]["VALUE"] = $m_v; $tree["LB"]["PNUM"] = $m_n; - $tree["RB"] = array("CLASS" => $m_t, + $tree["RB"] = ["CLASS" => $m_t, "NODETYPE" => $m_o, "VALUE" => $m_v, "PNUM" => $m_n, "LB" => $tree["LB"]["RB"], - "RB" => $tree["RB"]); + "RB" => $tree["RB"]]; $tree["LB"]["RB"] = $tree["RB"]["RB"]; // return; @@ -1338,12 +1338,12 @@ class PhraseaEngineQueryParser $tree["RB"]["VALUE"] = $m_v; $tree["RB"]["PNUM"] = $m_n; - $tree["LB"] = array("CLASS" => $m_t, + $tree["LB"] = ["CLASS" => $m_t, "NODETYPE" => $m_o, "VALUE" => $m_v, "PNUM" => $m_n, "LB" => $tree["LB"], - "RB" => $tree["RB"]["LB"]); + "RB" => $tree["RB"]["LB"]]; $tree["RB"]["LB"] = $tree["LB"]["LB"]; } @@ -1355,7 +1355,7 @@ class PhraseaEngineQueryParser public function makequery($tree) { - $a = array($tree["NODETYPE"]); + $a = [$tree["NODETYPE"]]; switch ($tree["CLASS"]) { case "PHRASEA_KW_LAST": if ($tree["PNUM"] !== NULL) @@ -1436,13 +1436,13 @@ class PhraseaEngineQueryParser $tree = null; } else { // ici on applique l'opérateur par défaut - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => $this->defaultop["VALUE"], "NODETYPE" => $this->defaultop["NODETYPE"], "PNUM" => $this->defaultop["PNUM"], "DEPTH" => $depth, "LB" => $tree, - "RB" => $this->maketree($depth + 1)); + "RB" => $this->maketree($depth + 1)]; } } if (!$tree) { @@ -1483,13 +1483,13 @@ class PhraseaEngineQueryParser $tree = null; } else { // ici on applique l'opérateur par défaut - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => $this->defaultop["VALUE"], "NODETYPE" => $this->defaultop["NODETYPE"], "PNUM" => $this->defaultop["PNUM"], "DEPTH" => $depth, "LB" => $tree, - "RB" => $this->maketree($depth + 1, true)); + "RB" => $this->maketree($depth + 1, true)]; } } if (!$tree) { @@ -1587,7 +1587,7 @@ class PhraseaEngineQueryParser return(null); } - return(array("CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); + return(["CLASS" => "OPK", "VALUE" => $t["VALUE"], "NODETYPE" => $this->opk[$t["VALUE"]]["NODETYPE"], "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, "RB" => null]); break; case "TOK_WORD": if ($t["CLASS"] == "TOK_WORD" && isset($this->ops[$t["VALUE"]]) && !$inquote) { @@ -1620,7 +1620,7 @@ class PhraseaEngineQueryParser } } - return(array("CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null)); + return(["CLASS" => "OPS", "VALUE" => $t["VALUE"], "NODETYPE" => $this->ops[$t["VALUE"]]["NODETYPE"], "PNUM" => $pnum, "DEPTH" => $depth, "LB" => $tree, "RB" => null]); } else { // ce mot n'est pas un opérateur $pnum = null; @@ -1672,7 +1672,7 @@ class PhraseaEngineQueryParser } } if (!$tree) { - return(array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth)); + return(["CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, "DEPTH" => $depth]); } switch ($tree["CLASS"]) { case "SIMPLE": @@ -1680,24 +1680,24 @@ class PhraseaEngineQueryParser if ($type == "SIMPLE" || $type == "QSIMPLE") $tree["VALUE"][] = $t["VALUE"]; else { - $tree = array("CLASS" => "OPS", + $tree = ["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, - "RB" => array("CLASS" => $type, + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), + "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, - "DEPTH" => $depth)); + "DEPTH" => $depth]]; } return($tree); case "OPS": case "OPK": if ($tree["RB"] == null) { - $tree["RB"] = array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth); + $tree["RB"] = ["CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, "DEPTH" => $depth]; return($tree); } else { @@ -1707,43 +1707,43 @@ class PhraseaEngineQueryParser return($tree); } if (($tree["RB"]["CLASS"] == "PHRASEA_KW_LAST" || $tree["RB"]["CLASS"] == "PHRASEA_KW_ALL") && $tree["RB"]["DEPTH"] == $depth) { - $tree["RB"] = array("CLASS" => "OPS", + $tree["RB"] = ["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => null, "DEPTH" => $depth, "LB" => $tree["RB"], - "RB" => array("CLASS" => $type, + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), + "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, - "DEPTH" => $depth)); + "DEPTH" => $depth]]; return($tree); } - return(array("CLASS" => "OPS", + return(["CLASS" => "OPS", "VALUE" => $this->defaultop["VALUE"], "NODETYPE" => $this->defaultop["NODETYPE"], "PNUM" => $this->defaultop["PNUM"], "DEPTH" => $depth, "LB" => $tree, - "RB" => array("CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => array($t["VALUE"]), "PNUM" => $pnum, "DEPTH" => $depth) - )); + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, "DEPTH" => $depth] + ]); } case "PHRASEA_KW_LAST": case "PHRASEA_KW_ALL": - return(array("CLASS" => "OPS", + return(["CLASS" => "OPS", "VALUE" => "et", "NODETYPE" => PHRASEA_OP_AND, "PNUM" => null, "DEPTH" => $depth, "LB" => $tree, - "RB" => array("CLASS" => $type, + "RB" => ["CLASS" => $type, "NODETYPE" => $nodetype, - "VALUE" => array($t["VALUE"]), + "VALUE" => [$t["VALUE"]], "PNUM" => $pnum, - "DEPTH" => $depth))); + "DEPTH" => $depth]]); } } @@ -1764,7 +1764,7 @@ class PhraseaEngineQueryParser if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $c2 = $c . substr($this->phq, 1, 1); if ($c2 == "<=" || $c2 == ">=" || $c2 == "<>") { @@ -1774,47 +1774,47 @@ class PhraseaEngineQueryParser $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); } - return(array("CLASS" => "TOK_CMP", "VALUE" => $c)); + return(["CLASS" => "TOK_CMP", "VALUE" => $c]); break; case "=": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_CMP", "VALUE" => "=")); + return(["CLASS" => "TOK_CMP", "VALUE" => "="]); break; case ":": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_CMP", "VALUE" => ":")); + return(["CLASS" => "TOK_CMP", "VALUE" => ":"]); break; case "(": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_LP", "VALUE" => "(")); + return(["CLASS" => "TOK_LP", "VALUE" => "("]); break; case ")": if ($inquote) { $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_VOID", "VALUE" => $c)); + return(["CLASS" => "TOK_VOID", "VALUE" => $c]); } $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_RP", "VALUE" => ")")); + return(["CLASS" => "TOK_RP", "VALUE" => ")"]); break; case "[": // if($inquote) @@ -1833,7 +1833,7 @@ class PhraseaEngineQueryParser } $context = $this->app['unicode']->remove_indexer_chars($context); - return(array("CLASS" => "TOK_CONTEXT", "VALUE" => $context)); + return(["CLASS" => "TOK_CONTEXT", "VALUE" => $context]); break; /* case "]": @@ -1850,7 +1850,7 @@ class PhraseaEngineQueryParser case "\"": $this->phq = $this->mb_ltrim(mb_substr($this->phq, 1, 99999, 'UTF-8'), 'UTF-8'); - return(array("CLASS" => "TOK_QUOTE", "VALUE" => "\"")); + return(["CLASS" => "TOK_QUOTE", "VALUE" => "\""]); break; default: $l = mb_strlen($this->phq, 'UTF-8'); @@ -1865,7 +1865,7 @@ class PhraseaEngineQueryParser break; } // if ($c_utf8 == "(" || $c_utf8 == ")" || $c_utf8 == "[" || $c_utf8 == "]" || $c_utf8 == "=" || $c_utf8 == ":" || $c_utf8 == "<" || $c_utf8 == ">" || $c_utf8 == "\"") - if (in_array($c_utf8, array("(", ")", "[", "]", "=", ":", "<", ">", "\""))) { + if (in_array($c_utf8, ["(", ")", "[", "]", "=", ":", "<", ">", "\""])) { // ces caractéres sont des délimiteurs avec un sens, il faut les garder $this->phq = $this->mb_ltrim(mb_substr($this->phq, $i, 99999, 'UTF-8'), 'UTF-8'); } else { @@ -1873,9 +1873,9 @@ class PhraseaEngineQueryParser $this->phq = $this->mb_ltrim(mb_substr($this->phq, $i + 1, 99999, 'UTF-8'), 'UTF-8'); } if ($t != "") { - return(array("CLASS" => "TOK_WORD", "VALUE" => $t)); + return(["CLASS" => "TOK_WORD", "VALUE" => $t]); } else { - return(array("CLASS" => "TOK_VOID", "VALUE" => $t)); + return(["CLASS" => "TOK_VOID", "VALUE" => $t]); } break; } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php index ba669fee48..621bf619dd 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineInterface.php @@ -238,5 +238,5 @@ interface SearchEngineInterface * @param Application $app * @param array $options */ - public static function create(Application $app, array $options = array()); + public static function create(Application $app, array $options = []); } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php index 69d5c34f73..9151893caa 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineLogger.php @@ -33,7 +33,7 @@ class SearchEngineLogger $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':log_id' => $this->app['phraseanet.logger']($databox)->get_id(), ':date' => date("Y-m-d H:i:s"), ':query' => $query, @@ -41,7 +41,7 @@ class SearchEngineLogger ':colls' => implode(',', array_map(function ($coll_id) { return (int) $coll_id; }, $coll_ids)), - )); + ]); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php index 62b2b4b115..38cc7b7a2f 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php @@ -46,19 +46,19 @@ class SearchEngineOptions * * @var array */ - protected $collections = array(); + protected $collections = []; /** * * @var array */ - protected $fields = array(); + protected $fields = []; /** * * @var array */ - protected $status = array(); + protected $status = []; /** * @@ -76,7 +76,7 @@ class SearchEngineOptions * * @var array */ - protected $date_fields = array(); + protected $date_fields = []; /** * @@ -101,7 +101,7 @@ class SearchEngineOptions * @var string */ protected $sort_ord = self::SORT_MODE_DESC; - protected $business_fields = array(); + protected $business_fields = []; /** * Defines locale code to use for query @@ -163,7 +163,7 @@ class SearchEngineOptions */ public function disallowBusinessFields() { - $this->business_fields = array(); + $this->business_fields = []; return $this; } @@ -284,7 +284,7 @@ class SearchEngineOptions */ public function getDataboxes() { - $databoxes = array(); + $databoxes = []; foreach ($this->collections as $collection) { $databoxes[$collection->get_databox()->get_sbas_id()] = $collection->get_databox(); @@ -320,7 +320,7 @@ class SearchEngineOptions */ public function setStatus(Array $status) { - $tmp = array(); + $tmp = []; foreach ($status as $n => $options) { if (count($options) > 1) { continue; @@ -467,17 +467,17 @@ class SearchEngineOptions */ public function serialize() { - $ret = array(); + $ret = []; foreach ($this as $key => $value) { if ($value instanceof \DateTime) { $value = $value->format(DATE_ATOM); } - if (in_array($key, array('date_fields', 'fields'))) { + if (in_array($key, ['date_fields', 'fields'])) { $value = array_map(function (\databox_field $field) { return $field->get_databox()->get_sbas_id() . '_' . $field->get_id(); }, $value); } - if (in_array($key, array('collections', 'business_fields'))) { + if (in_array($key, ['collections', 'business_fields'])) { $value = array_map(function ($collection) { return $collection->get_base_id(); }, $value); @@ -516,19 +516,19 @@ class SearchEngineOptions case is_null($value): $value = null; break; - case in_array($key, array('date_min', 'date_max')): + case in_array($key, ['date_min', 'date_max']): $value = \DateTime::createFromFormat(DATE_ATOM, $value); break; case $value instanceof stdClass: $tmpvalue = (array) $value; - $value = array(); + $value = []; foreach ($tmpvalue as $k => $data) { $k = ctype_digit($k) ? (int) $k : $k; $value[$k] = $data; } break; - case in_array($key, array('date_fields', 'fields')): + case in_array($key, ['date_fields', 'fields']): $value = array_map(function ($serialized) use ($app) { $data = explode('_', $serialized); @@ -536,7 +536,7 @@ class SearchEngineOptions return \collection::get_from_base_id($app, $base_id); }, $value); break; - case in_array($key, array('collections', 'business_fields')): + case in_array($key, ['collections', 'business_fields']): $value = array_map(function ($base_id) use ($app) { return \collection::get_from_base_id($app, $base_id); }, $value); @@ -637,7 +637,7 @@ class SearchEngineOptions } }); - $databoxes = array(); + $databoxes = []; foreach ($bas as $collection) { if (!isset($databoxes[$collection->get_sbas_id()])) { @@ -653,10 +653,10 @@ class SearchEngineOptions $options->allowBusinessFieldsOn($BF); } - $status = is_array($request->get('status')) ? $request->get('status') : array(); - $fields = is_array($request->get('fields')) ? $request->get('fields') : array(); + $status = is_array($request->get('status')) ? $request->get('status') : []; + $fields = is_array($request->get('fields')) ? $request->get('fields') : []; - $databoxFields = array(); + $databoxFields = []; foreach ($databoxes as $databox) { foreach ($fields as $field) { @@ -690,7 +690,7 @@ class SearchEngineOptions $options->setMinDate($min_date); $options->setMaxDate($max_date); - $databoxDateFields = array(); + $databoxDateFields = []; foreach ($databoxes as $databox) { foreach (explode('|', $request->get('date_field')) as $field) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php index 172cf271eb..bf3131021d 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SearchEngineSuggestion.php @@ -73,9 +73,9 @@ class SearchEngineSuggestion */ public function toArray() { - return array( + return [ 'query' => $this->getSuggestion(), 'hits' => $this->getHits(), - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php index 4738b3eb92..3584c402a0 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php @@ -45,12 +45,12 @@ class ConfigurationPanel extends AbstractConfigurationPanel { $configuration = $this->getConfiguration(); - $params = array( + $params = [ 'configuration' => $configuration, 'configfile' => $this->generateSphinxConf($app['phraseanet.appbox']->get_databoxes(), $configuration), 'charsets' => $this->getAvailableCharsets(), 'date_fields' => $this->getAvailableDateFields($app['phraseanet.appbox']->get_databoxes()), - ); + ]; return $app['twig']->render('admin/search-engine/sphinx-search.html.twig', $params); } @@ -61,13 +61,13 @@ class ConfigurationPanel extends AbstractConfigurationPanel public function post(Application $app, Request $request) { $configuration = $this->getConfiguration(); - $configuration['charset_tables'] = array(); - $configuration['date_fields'] = array(); + $configuration['charset_tables'] = []; + $configuration['date_fields'] = []; - foreach ($request->request->get('charset_tables', array()) as $table) { + foreach ($request->request->get('charset_tables', []) as $table) { $configuration['charset_tables'][] = $table; } - foreach ($request->request->get('date_fields', array()) as $field) { + foreach ($request->request->get('date_fields', []) as $field) { $configuration['date_fields'][] = $field; } @@ -86,7 +86,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel */ public function getConfiguration() { - $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : array(); + $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : []; return self::populateConfiguration($configuration); } @@ -114,7 +114,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel return $this->charsets; } - $this->charsets = array(); + $this->charsets = []; $finder = new Finder(); $finder->in(__DIR__ . '/Charset/')->files()->name('*.php'); @@ -208,7 +208,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel $index_crc = $this->searchEngine->CRCdatabox($databox); - $date_selects = $date_left_joins = $date_fields = array(); + $date_selects = $date_left_joins = $date_fields = []; foreach ($configuration['date_fields'] as $name) { $field = $databox->get_meta_structure()->get_element_by_name($name); @@ -738,13 +738,13 @@ searchd */ public static function populateConfiguration(array $configuration) { - return array_replace(array( - 'charset_tables' => array("common", "latin"), - 'date_fields' => array(), + return array_replace([ + 'charset_tables' => ["common", "latin"], + 'date_fields' => [], 'host' => '127.0.0.1', 'port' => 9312, 'rt_host' => '127.0.0.1', 'rt_port' => 9306, - ), $configuration); + ], $configuration); } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php index 6aeb06d832..1500ecc922 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php @@ -123,11 +123,11 @@ class SphinxSearchEngine implements SearchEngineInterface */ public function getAvailableSort() { - return array( + return [ 'relevance' => _('pertinence'), 'created_on' => _('date dajout'), 'random' => _('aleatoire'), - ); + ]; } /** @@ -135,10 +135,10 @@ class SphinxSearchEngine implements SearchEngineInterface */ public function getAvailableOrder() { - return array( + return [ 'desc' => _('descendant'), 'asc' => _('ascendant'), - ); + ]; } /** @@ -195,7 +195,7 @@ class SphinxSearchEngine implements SearchEngineInterface */ public function getAvailableTypes() { - return array(self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY); + return [self::GEM_TYPE_RECORD, self::GEM_TYPE_STORY]; } /** @@ -207,8 +207,8 @@ class SphinxSearchEngine implements SearchEngineInterface throw new RuntimeException('Unable to connect to sphinx real-time index'); } - $all_datas = array(); - $status = array(); + $all_datas = []; + $status = []; $binStatus = strrev($record->get_status()); @@ -220,13 +220,13 @@ class SphinxSearchEngine implements SearchEngineInterface $sql_date_fields = $this->getSqlDateFields($record); - $indexes = array( + $indexes = [ "metas_realtime" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_fr_" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_nl_" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_de_" . $this->CRCdatabox($record->get_databox()), "metas_realtime_stemmed_en_" . $this->CRCdatabox($record->get_databox()), - ); + ]; foreach ($record->get_caption()->get_fields(null, true) as $field) { if (!$field->is_indexable()) { @@ -263,13 +263,13 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $indexes = array( + $indexes = [ "docs_realtime" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_fr_" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_nl_" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_en_" . $this->CRCdatabox($record->get_databox()), "docs_realtime_stemmed_de_" . $this->CRCdatabox($record->get_databox()), - ); + ]; foreach ($indexes as $index) { $this->rt_conn->exec("REPLACE INTO " @@ -303,27 +303,27 @@ class SphinxSearchEngine implements SearchEngineInterface } $CRCdatabox = $this->CRCdatabox($record->get_databox()); - $indexes = array( + $indexes = [ "metadatas" . $CRCdatabox, "metadatas" . $CRCdatabox . "_stemmed_en", "metadatas" . $CRCdatabox . "_stemmed_fr", "metadatas" . $CRCdatabox . "_stemmed_de", "metadatas" . $CRCdatabox . "_stemmed_nl", - ); - $RTindexes = array( + ]; + $RTindexes = [ "metas_realtime" . $CRCdatabox, "metas_realtime_stemmed_fr_" . $CRCdatabox, "metas_realtime_stemmed_en_" . $CRCdatabox, "metas_realtime_stemmed_nl_" . $CRCdatabox, "metas_realtime_stemmed_de_" . $CRCdatabox, - ); + ]; foreach ($record->get_caption()->get_fields(null, true) as $field) { foreach ($field->get_values() as $value) { foreach ($indexes as $index) { - $this->sphinx->UpdateAttributes($index, array("deleted"), array($value->getId() => array(1))); + $this->sphinx->UpdateAttributes($index, ["deleted"], [$value->getId() => [1]]); } foreach ($RTindexes as $index) { @@ -332,23 +332,23 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $indexes = array( + $indexes = [ "documents" . $CRCdatabox, "documents" . $CRCdatabox . "_stemmed_fr", "documents" . $CRCdatabox . "_stemmed_en", "documents" . $CRCdatabox . "_stemmed_de", "documents" . $CRCdatabox . "_stemmed_nl" - ); - $RTindexes = array( + ]; + $RTindexes = [ "docs_realtime" . $CRCdatabox, "docs_realtime_stemmed_fr_" . $CRCdatabox, "docs_realtime_stemmed_en_" . $CRCdatabox, "docs_realtime_stemmed_nl_" . $CRCdatabox, "docs_realtime_stemmed_de_" . $CRCdatabox, - ); + ]; foreach ($indexes as $index) { - $this->sphinx->UpdateAttributes($index, array("deleted"), array($record->get_record_id() => array(1))); + $this->sphinx->UpdateAttributes($index, ["deleted"], [$record->get_record_id() => [1]]); } foreach ($RTindexes as $index) { @@ -461,7 +461,7 @@ class SphinxSearchEngine implements SearchEngineInterface $preg = preg_match('/\s?(recordid|storyid)\s?=\s?([0-9]+)/i', $query, $matches, 0, 0); if ($preg > 0) { - $this->sphinx->SetFilter('record_id', array($matches[2])); + $this->sphinx->SetFilter('record_id', [$matches[2]]); $query = ''; } @@ -483,7 +483,7 @@ class SphinxSearchEngine implements SearchEngineInterface $total = $available = $duration = 0; $suggestions = new ArrayCollection(); - $propositions = array(); + $propositions = []; } else { $error = $res['error']; $warning = $res['warning']; @@ -551,12 +551,12 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $opts = array( + $opts = [ 'before_match' => "", 'after_match' => "", - ); + ]; - $fields_to_send = array(); + $fields_to_send = []; foreach ($fields as $k => $f) { $fields_to_send[$k] = $f['value']; @@ -578,7 +578,7 @@ class SphinxSearchEngine implements SearchEngineInterface * * @return SphinxSearchEngine */ - public static function create(Application $app, array $options = array()) + public static function create(Application $app, array $options = []) { $options = ConfigurationPanel::populateConfiguration($options); @@ -595,7 +595,7 @@ class SphinxSearchEngine implements SearchEngineInterface { return sprintf("%u", crc32( str_replace( - array('.', '%') + ['.', '%'] , '_' , sprintf('%s_%s_%s_%s', $databox->get_host(), $databox->get_port(), $databox->get_user(), $databox->get_dbname()) ) @@ -614,7 +614,7 @@ class SphinxSearchEngine implements SearchEngineInterface { $this->resetSphinx(); - $filters = array(); + $filters = []; foreach ($options->getCollections() as $collection) { $filters[] = sprintf("%u", crc32($collection->get_databox()->get_sbas_id() . '_' . $collection->get_coll_id())); @@ -622,8 +622,8 @@ class SphinxSearchEngine implements SearchEngineInterface $this->sphinx->SetFilter('crc_sbas_coll', $filters); - $this->sphinx->SetFilter('deleted', array(0)); - $this->sphinx->SetFilter('parent_record_id', array($options->getSearchType())); + $this->sphinx->SetFilter('deleted', [0]); + $this->sphinx->SetFilter('parent_record_id', [$options->getSearchType()]); if ($options->getDateFields() && ($options->getMaxDate() || $options->getMinDate())) { foreach (array_unique(array_map(function (\databox_field $field) { @@ -638,7 +638,7 @@ class SphinxSearchEngine implements SearchEngineInterface if ($options->getFields()) { - $filters = array(); + $filters = []; foreach ($options->getFields() as $field) { $filters[] = sprintf("%u", crc32($field->get_databox()->get_sbas_id() . '_' . $field->get_id())); } @@ -648,14 +648,14 @@ class SphinxSearchEngine implements SearchEngineInterface if ($options->getBusinessFieldsOn()) { - $crc_coll_business = array(); + $crc_coll_business = []; foreach ($options->getBusinessFieldsOn() as $collection) { $crc_coll_business[] = sprintf("%u", crc32($collection->get_coll_id() . '_1')); $crc_coll_business[] = sprintf("%u", crc32($collection->get_coll_id() . '_0')); } - $non_business = array(); + $non_business = []; foreach ($options->getCollections() as $collection) { foreach ($options->getBusinessFieldsOn() as $BFcollection) { @@ -672,7 +672,7 @@ class SphinxSearchEngine implements SearchEngineInterface $this->sphinx->SetFilter('crc_coll_business', $crc_coll_business); } elseif ($options->getFields()) { - $this->sphinx->SetFilter('business', array(0)); + $this->sphinx->SetFilter('business', [0]); } /** @@ -686,12 +686,12 @@ class SphinxSearchEngine implements SearchEngineInterface if (!array_key_exists($databox->get_sbas_id(), $status_opts[$n])) continue; $crc = sprintf("%u", crc32($databox->get_sbas_id() . '_' . $n)); - $this->sphinx->SetFilter('status', array($crc), ($status_opts[$n][$databox->get_sbas_id()] == '0')); + $this->sphinx->SetFilter('status', [$crc], ($status_opts[$n][$databox->get_sbas_id()] == '0')); } } if ($options->getRecordType()) { - $this->sphinx->SetFilter('crc_type', array(sprintf("%u", crc32($options->getRecordType())))); + $this->sphinx->SetFilter('crc_type', [sprintf("%u", crc32($options->getRecordType()))]); } $order = ''; @@ -727,7 +727,7 @@ class SphinxSearchEngine implements SearchEngineInterface { $configuration = $this->getConfiguration(); - $sql_fields = array(); + $sql_fields = []; foreach ($configuration['date_fields'] as $field_name) { @@ -756,7 +756,7 @@ class SphinxSearchEngine implements SearchEngineInterface */ private function cleanupQuery($query) { - return str_replace(array("all", "last", "et", "ou", "sauf", "and", "or", "except", "in", "dans", "'", '"', "(", ")", "_", "-", "+"), ' ', $query); + return str_replace(["all", "last", "et", "ou", "sauf", "and", "or", "except", "in", "dans", "'", '"', "(", ")", "_", "-", "+"], ' ', $query); } /** @@ -770,7 +770,7 @@ class SphinxSearchEngine implements SearchEngineInterface // First we split the query into simple words $words = explode(" ", $this->cleanupQuery(mb_strtolower($query))); - $tmpWords = array(); + $tmpWords = []; foreach ($words as $word) { if (trim($word) === '') { @@ -781,10 +781,10 @@ class SphinxSearchEngine implements SearchEngineInterface $words = array_unique($tmpWords); - $altVersions = array(); + $altVersions = []; foreach ($words as $word) { - $altVersions[$word] = array($word); + $altVersions[$word] = [$word]; } // As we got words, we look for alternate word for each of them @@ -814,10 +814,10 @@ class SphinxSearchEngine implements SearchEngineInterface } // We now build an array of all possibilities based on the original query - $queries = array($query); + $queries = [$query]; foreach ($altVersions as $word => $versions) { - $tmp_queries = array(); + $tmp_queries = []; foreach ($versions as $version) { foreach ($queries as $alt_query) { $tmp_queries[] = $alt_query; @@ -828,7 +828,7 @@ class SphinxSearchEngine implements SearchEngineInterface $queries = array_unique(array_merge($queries, $tmp_queries)); } - $suggestions = array(); + $suggestions = []; $max_results = 0; foreach ($queries as $alt_query) { @@ -842,7 +842,7 @@ class SphinxSearchEngine implements SearchEngineInterface } } - usort($suggestions, array('self', 'suggestionsHitSorter')); + usort($suggestions, ['self', 'suggestionsHitSorter']); $tmpSuggestions = new ArrayCollection(); foreach ($suggestions as $key => $suggestion) { @@ -891,7 +891,7 @@ class SphinxSearchEngine implements SearchEngineInterface $this->suggestionClient->SetSortMode(SPH_SORT_EXTENDED, "@weight DESC"); $this->suggestionClient->SetLimits(0, 10); - $indexes = array(); + $indexes = []; foreach ($this->options->getDataboxes() as $databox) { $indexes[] = 'suggest' . $this->CRCdatabox($databox); @@ -901,14 +901,14 @@ class SphinxSearchEngine implements SearchEngineInterface $res = $this->suggestionClient->Query($query, $index); if ($this->suggestionClient->Status() === false) { - return array(); + return []; } if (!$res || !isset($res["matches"])) { - return array(); + return []; } - $words = array(); + $words = []; foreach ($res["matches"] as $match) { $words[] = $match['attrs']['keyword']; } @@ -920,7 +920,7 @@ class SphinxSearchEngine implements SearchEngineInterface { $index = '*'; - $index_keys = array(); + $index_keys = []; foreach ($this->options->getDataboxes() as $databox) { $index_keys[] = $this->CRCdatabox($databox); @@ -976,9 +976,9 @@ class SphinxSearchEngine implements SearchEngineInterface } } - $query = str_ireplace(array(' ou ', ' or '), '|', $query); - $query = str_ireplace(array(' sauf ', ' except '), ' -', $query); - $query = str_ireplace(array(' and ', ' et '), ' +', $query); + $query = str_ireplace([' ou ', ' or '], '|', $query); + $query = str_ireplace([' sauf ', ' except '], ' -', $query); + $query = str_ireplace([' and ', ' et '], ' +', $query); return $query; } @@ -1019,7 +1019,7 @@ class SphinxSearchEngine implements SearchEngineInterface protected function BuildDictionarySQL($dictionnary, $threshold) { - $out = array(); + $out = []; $n = 1; $lines = explode("\n", $dictionnary); diff --git a/lib/Alchemy/Phrasea/Security/Firewall.php b/lib/Alchemy/Phrasea/Security/Firewall.php index fad8a1eb9e..ee065b5520 100644 --- a/lib/Alchemy/Phrasea/Security/Firewall.php +++ b/lib/Alchemy/Phrasea/Security/Firewall.php @@ -16,9 +16,9 @@ class Firewall public function requireSetUp() { if (!$this->app['phraseanet.configuration-tester']->isInstalled()) { - $this->app->abort(302, 'Phraseanet is not installed', array( + $this->app->abort(302, 'Phraseanet is not installed', [ 'X-Phraseanet-Redirect' => $this->app->path('setup') - )); + ]); } return null; @@ -115,9 +115,9 @@ class Firewall public function requireAuthentication() { if (!$this->app['authentication']->isAuthenticated()) { - $this->app->abort(302, 'You are not authenticated', array( + $this->app->abort(302, 'You are not authenticated', [ 'X-Phraseanet-Redirect' => $this->app->path('homepage') - )); + ]); } return $this; @@ -126,9 +126,9 @@ class Firewall public function requireNotAuthenticated() { if ($this->app['authentication']->isAuthenticated()) { - $this->app->abort(302, 'You are authenticated', array( + $this->app->abort(302, 'You are authenticated', [ 'X-Phraseanet-Redirect' => $this->app->path('prod') - )); + ]); } return $this; @@ -136,7 +136,7 @@ class Firewall public function requireOrdersAdmin() { - if (false === !!count($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(array('order_master')))) { + if (false === !!count($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['order_master']))) { $this->app->abort(403, 'You are not an order admin'); } diff --git a/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php b/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php index 39c96a37bc..42972cbf6b 100644 --- a/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php +++ b/lib/Alchemy/Phrasea/Setup/ConfigurationTester.php @@ -39,11 +39,11 @@ class ConfigurationTester { $this->app = $app; - $this->versionProbes = array( + $this->versionProbes = [ new Probe31($this->app), new Probe35($this->app), new Probe38($this->app), - ); + ]; } public function getRequirements() @@ -52,7 +52,7 @@ class ConfigurationTester return $this->requirements; } - $this->requirements = array( + $this->requirements = [ BinariesProbe::create($this->app), CacheServerProbe::create($this->app), DataboxStructureProbe::create($this->app), @@ -64,7 +64,7 @@ class ConfigurationTester SearchEngineProbe::create($this->app), SubdefsPathsProbe::create($this->app), SystemProbe::create($this->app), - ); + ]; return $this->requirements; } @@ -136,7 +136,7 @@ class ConfigurationTester public function getMigrations() { - $migrations = array(); + $migrations = []; if ($this->isUpToDate()) { return $migrations; diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php index 6dd2131c17..6f390e48a0 100644 --- a/lib/Alchemy/Phrasea/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Setup/Installer.php @@ -24,7 +24,7 @@ class Installer $this->app = $app; } - public function install($email, $password, \connection_interface $abConn, $serverName, $dataPath, \connection_interface $dbConn = null, $template = null, array $binaryData = array()) + public function install($email, $password, \connection_interface $abConn, $serverName, $dataPath, \connection_interface $dbConn = null, $template = null, array $binaryData = []) { $this->rollbackInstall($abConn, $dbConn); @@ -79,27 +79,27 @@ class Installer $template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $template . '-simple.xml'); $databox = \databox::create($this->app, $dbConn, $template, $this->app['phraseanet.registry']); $this->app['acl']->get($this->app['authentication']->getUser()) - ->give_access_to_sbas(array($databox->get_sbas_id())) + ->give_access_to_sbas([$databox->get_sbas_id()]) ->update_rights_to_sbas( - $databox->get_sbas_id(), array( + $databox->get_sbas_id(), [ 'bas_manage' => 1, 'bas_modify_struct' => 1, 'bas_modif_th' => 1, 'bas_chupub' => 1 - ) + ] ); $collection = \collection::create($this->app, $databox, $this->app['phraseanet.appbox'], 'test', $this->app['authentication']->getUser()); - $this->app['acl']->get($this->app['authentication']->getUser())->give_access_to_base(array($collection->get_base_id())); - $this->app['acl']->get($this->app['authentication']->getUser())->update_rights_to_base($collection->get_base_id(), array( + $this->app['acl']->get($this->app['authentication']->getUser())->give_access_to_base([$collection->get_base_id()]); + $this->app['acl']->get($this->app['authentication']->getUser())->update_rights_to_base($collection->get_base_id(), [ 'canpush' => 1, 'cancmd' => 1 , 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1 , 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1 , 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1 , 'modify_struct' => 1, 'nowatermark' => 1 - ) + ] ); - foreach (array('PhraseanetIndexer', 'Subdefs', 'WriteMetadata') as $jobName) { + foreach (['PhraseanetIndexer', 'Subdefs', 'WriteMetadata'] as $jobName) { $job = $this->app['task-manager.job-factory']->create($jobName); $this->app['manipulator.task']->create( $job->getName(), diff --git a/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php index 985520a241..e83f5d5b7f 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/BinariesProbe.php @@ -18,7 +18,7 @@ class BinariesProbe extends BinariesRequirements implements ProbeInterface { public function __construct(array $binaries) { - parent::__construct(array_filter(array( + parent::__construct(array_filter([ 'php_binary' => isset($binaries['php_binary']) ? $binaries['php_binary'] : null, 'pdf2swf_binary' => isset($binaries['pdf2swf_binary']) ? $binaries['pdf2swf_binary'] : null, 'unoconv_binary' => isset($binaries['unoconv_binary']) ? $binaries['unoconv_binary'] : null, @@ -29,7 +29,7 @@ class BinariesProbe extends BinariesRequirements implements ProbeInterface 'ffmpeg_binary' => isset($binaries['ffmpeg_binary']) ? $binaries['ffmpeg_binary'] : null, 'ffprobe_binary' => isset($binaries['ffprobe_binary']) ? $binaries['ffprobe_binary'] : null, 'recess_binary' => isset($binaries['recess_binary']) ? $binaries['recess_binary'] : null, - ))); + ])); } /** diff --git a/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php index 605cb1c2b2..addd80f127 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/FilesystemProbe.php @@ -22,9 +22,9 @@ class FilesystemProbe extends FilesystemRequirements implements ProbeInterface $baseDir = realpath(__DIR__ . '/../../../../../'); - $paths = array( + $paths = [ $baseDir . '/config/configuration.yml', - ); + ]; foreach ($paths as $path) { $this->addRecommendation( @@ -34,7 +34,7 @@ class FilesystemProbe extends FilesystemRequirements implements ProbeInterface ); } - $path = array(); + $path = []; if ($registry->is_set('GV_base_datapath_noweb')) { $paths[] = $registry->get('GV_base_datapath_noweb'); diff --git a/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php b/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php index 19b001b702..9317bbe8fd 100644 --- a/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php +++ b/lib/Alchemy/Phrasea/Setup/Probe/PhraseaProbe.php @@ -18,9 +18,9 @@ class PhraseaProbe extends PhraseaRequirements implements ProbeInterface { public function __construct(Application $app) { - parent::__construct(array( + parent::__construct([ // here goes the custom setting - )); + ]); } /** diff --git a/lib/Alchemy/Phrasea/Setup/RequirementCollection.php b/lib/Alchemy/Phrasea/Setup/RequirementCollection.php index 607352d9a7..bc48c71428 100644 --- a/lib/Alchemy/Phrasea/Setup/RequirementCollection.php +++ b/lib/Alchemy/Phrasea/Setup/RequirementCollection.php @@ -11,8 +11,8 @@ namespace Alchemy\Phrasea\Setup; */ class RequirementCollection implements RequirementCollectionInterface { - private $requirements = array(); - private $informations = array(); + private $requirements = []; + private $informations = []; private $name; /** @@ -114,7 +114,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getRequirements() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if (!$req->isOptional()) { $array[] = $req; @@ -129,7 +129,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getFailedRequirements() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if (!$req->isFulfilled() && !$req->isOptional()) { $array[] = $req; @@ -144,7 +144,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getRecommendations() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if ($req->isOptional()) { $array[] = $req; @@ -159,7 +159,7 @@ class RequirementCollection implements RequirementCollectionInterface */ public function getFailedRecommendations() { - $array = array(); + $array = []; foreach ($this->requirements as $req) { if (!$req->isFulfilled() && $req->isOptional()) { $array[] = $req; diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php index 61ab381327..59cf7cd631 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/BinariesRequirements.php @@ -24,7 +24,7 @@ class BinariesRequirements extends RequirementCollection implements RequirementI const MP4BOX_VERSION = '0.4.0'; const EXIFTOOL_VERSION = '9.15'; - public function __construct($binaries = array()) + public function __construct($binaries = []) { $this->setName('Binaries'); diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php index 4656a5b1bc..4cdeb3088d 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/FilesystemRequirements.php @@ -21,7 +21,7 @@ class FilesystemRequirements extends RequirementCollection implements Requiremen $this->setName('Filesystem'); - $paths = array( + $paths = [ $baseDir . '/config', $baseDir . '/config/stamp', $baseDir . '/config/status', @@ -41,7 +41,7 @@ class FilesystemRequirements extends RequirementCollection implements Requiremen $baseDir . '/tmp/desc_tmp', $baseDir . '/tmp/download', $baseDir . '/tmp/batches' - ); + ]; foreach ($paths as $path) { $this->addRequirement( diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php index 7d295782eb..830095deb5 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/PhraseaRequirements.php @@ -19,7 +19,7 @@ class PhraseaRequirements extends RequirementCollection implements RequirementIn const PHRASEA_EXTENSION_VERSION = '1.21.1.0'; const PHRASEA_INDEXER_VERSION = '3.10.2.3'; - public function __construct($binaries = array()) + public function __construct($binaries = []) { $this->setName('Phrasea'); diff --git a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php index e7c84a4720..f7124afd55 100644 --- a/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php +++ b/lib/Alchemy/Phrasea/Setup/Requirements/SystemRequirements.php @@ -48,7 +48,7 @@ class SystemRequirements extends RequirementCollection implements RequirementInt ); if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { - $timezones = array(); + $timezones = []; foreach (\DateTimeZone::listAbbreviations() as $abbreviations) { foreach ($abbreviations as $abbreviation) { $timezones[$abbreviation['timezone_id']] = true; diff --git a/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php b/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php index ee273acda6..ba164bde32 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php +++ b/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php @@ -36,21 +36,21 @@ class MailChecker $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $users = array(); + $users = []; foreach ($rs as $row) { if (!isset($users[$row['usr_mail']])) { - $users[$row['usr_mail']] = array(); + $users[$row['usr_mail']] = []; } $users[$row['usr_mail']][] = $row; } - $badUsers = array(); + $badUsers = []; foreach ($users as $email => $usrs) { if (count($usrs) > 1) { - $badUsers[$email] = array(); + $badUsers[$email] = []; foreach ($usrs as $usrInfo) { $badUsers[$email][$usrInfo['usr_id']] = $usrInfo; } diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php index 4f40d208db..0c205a4def 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration31.php @@ -38,13 +38,13 @@ class Migration31 implements MigrationInterface $retrieve_old_credentials = function () { require __DIR__ . '/../../../../../../config/connexion.inc'; - return array( + return [ 'hostname' => $hostname, 'port' => $port, 'user' => $user, 'password' => $password, 'dbname' => $dbname, - ); + ]; }; $params = $retrieve_old_credentials(); @@ -110,19 +110,19 @@ class Migration31 implements MigrationInterface break; } - $stmt->execute(array( + $stmt->execute([ ':key' => $datas['name'], ':value' => $val, ':type' => $type, - )); + ]); } } - $stmt->execute(array( + $stmt->execute([ ':key' => 'GV_sit', ':value' => GV_sit, ':type' => \registry::TYPE_STRING, - )); + ]); $stmt->closeCursor(); diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php index 66e9260c36..31e46bfe3d 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php @@ -38,13 +38,13 @@ class Migration35 implements MigrationInterface $retrieve_old_credentials = function () { require __DIR__ . '/../../../../../../config/connexion.inc'; - return array( + return [ 'hostname' => $hostname, 'port' => $port, 'user' => $user, 'password' => $password, 'dbname' => $dbname, - ); + ]; }; foreach ($retrieve_old_credentials() as $key => $value) { @@ -55,9 +55,9 @@ class Migration35 implements MigrationInterface $retrieve_old_parameters = function () { require __DIR__ . '/../../../../../../config/config.inc'; - return array( + return [ 'servername' => $servername - ); + ]; }; $old_parameters = $retrieve_old_parameters(); diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php index fb1eb3522e..f82813214a 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration38.php @@ -58,12 +58,12 @@ class Migration38 implements MigrationInterface $app['configuration']->setConfig($conf); - foreach (array( + foreach ([ $this->configYaml, $this->connexionsYaml, $this->binariesYaml, $this->servicesYaml - ) as $file) { + ] as $file) { if (is_file($file)) { rename($file, $file.'.bkp'); } @@ -103,7 +103,7 @@ class Migration38 implements MigrationInterface if (isset($services['Cache'][$opcodeCacheService]['options'])) { $conf['main']['opcodecache']['options'] = $services['Cache'][$opcodeCacheService]['options']; } else { - $conf['main']['opcodecache']['options'] = array(); + $conf['main']['opcodecache']['options'] = []; } } if (null !== $cacheService) { @@ -111,7 +111,7 @@ class Migration38 implements MigrationInterface if (isset($services['Cache'][$cacheService]['options'])) { $conf['main']['cache']['options'] = $services['Cache'][$cacheService]['options']; } else { - $conf['main']['cache']['options'] = array(); + $conf['main']['cache']['options'] = []; } } $conf['border-manager'] = $services['Border']['border_manager']['options']; diff --git a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php index 035896f35e..f9e42b8fb2 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php +++ b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/PreSchemaUpgradeCollection.php @@ -19,7 +19,7 @@ use Alchemy\Phrasea\Application; class PreSchemaUpgradeCollection { /** @var PreSchemaUpgradeInterface[] */ - private $upgrades = array(); + private $upgrades = []; public function __construct() { diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php index 4fc9280ce8..44154c1d50 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/AbstractEditor.php @@ -56,7 +56,7 @@ abstract class AbstractEditor implements EditorInterface } } - return new Response($dom->saveXML(), 200, array('Content-type' => 'text/xml')); + return new Response($dom->saveXML(), 200, ['Content-type' => 'text/xml']); } /** diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php index 7759649769..5a20eaa494 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php @@ -55,7 +55,7 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'base_id' => static::FORM_TYPE_INTEGER, 'hotfolder' => static::FORM_TYPE_STRING, 'move_archived' => static::FORM_TYPE_BOOLEAN, @@ -63,6 +63,6 @@ EOF; 'delfolder' => static::FORM_TYPE_BOOLEAN, 'copy_spe' => static::FORM_TYPE_BOOLEAN, 'cold' => static::FORM_TYPE_INTEGER, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php index a9c1e9f8f9..54d3888deb 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php @@ -45,6 +45,6 @@ EOF; protected function getFormProperties() { - return array(); + return []; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php index 343d9718e6..fa6efdddba 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php @@ -50,9 +50,9 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'proxy' => static::FORM_TYPE_STRING, 'proxyport' => static::FORM_TYPE_STRING, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php index 723836695f..6ef283074e 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php @@ -58,7 +58,7 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'proxy' => static::FORM_TYPE_STRING, 'proxyport' => static::FORM_TYPE_STRING, 'passive' => static::FORM_TYPE_BOOLEAN, @@ -69,6 +69,6 @@ EOF; 'localpath' => static::FORM_TYPE_STRING, 'port' => static::FORM_TYPE_INTEGER, 'host' => static::FORM_TYPE_STRING, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php index 316dfd2643..a36fee73bf 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php @@ -77,7 +77,7 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'host' => static::FORM_TYPE_STRING, 'port' => static::FORM_TYPE_INTEGER, 'base' => static::FORM_TYPE_STRING, @@ -91,6 +91,6 @@ EOF; 'debugmask' => static::FORM_TYPE_INTEGER, 'stem' => static::FORM_TYPE_STRING, 'sortempty' => static::FORM_TYPE_STRING, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php index 95493cbdae..31cc7443c2 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php @@ -37,7 +37,7 @@ class RecordMoverEditor extends AbstractEditor public function facility(Application $app, Request $request) { - $ret = array('tasks' => array()); + $ret = ['tasks' => []]; $job = new RecordMoverJob(); switch ($request->get('ACT')) { case 'CALCTEST': @@ -141,6 +141,6 @@ EOF; */ protected function getFormProperties() { - return array('logsql' => static::FORM_TYPE_BOOLEAN); + return ['logsql' => static::FORM_TYPE_BOOLEAN]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php index 7b5eb9b17c..6545eea93c 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php @@ -49,8 +49,8 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'embedded' => static::FORM_TYPE_BOOLEAN, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php index 2ee993f2dc..467c54cbb0 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php @@ -49,8 +49,8 @@ EOF; */ protected function getFormProperties() { - return array( + return [ 'cleardoc' => static::FORM_TYPE_BOOLEAN, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php b/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php index 8e50a92781..7e49a27bb1 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php +++ b/lib/Alchemy/Phrasea/TaskManager/Event/FinishedJobRemoverSubscriber.php @@ -31,9 +31,9 @@ class FinishedJobRemoverSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array( - JobEvents::FINISHED => array($this, 'onJobFinish'), - ); + return [ + JobEvents::FINISHED => [$this, 'onJobFinish'], + ]; } public function onJobFinish(JobFinishedEvent $event) diff --git a/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php b/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php index 0a5fdd8748..9d9f6a55f2 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php +++ b/lib/Alchemy/Phrasea/TaskManager/Event/PhraseanetIndexerStopperSubscriber.php @@ -29,9 +29,9 @@ class PhraseanetIndexerStopperSubscriber implements EventSubscriberInterface */ public static function getSubscribedEvents() { - return array( - TaskManagerEvents::STOP_REQUEST => array('onStopRequest'), - ); + return [ + TaskManagerEvents::STOP_REQUEST => ['onStopRequest'], + ]; } public function onStopRequest(JobEvent $event) diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php index 44fc0eab3f..69f4dc4c8f 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/ArchiveJob.php @@ -81,7 +81,7 @@ class ArchiveJob extends AbstractJob $databox = $app['phraseanet.appbox']->get_databox($sbasId); - $TColls = array(); + $TColls = []; $collection = null; foreach ($databox->get_collections() as $coll) { $TColls['c' . $coll->get_coll_id()] = $coll->get_coll_id(); @@ -92,8 +92,8 @@ class ArchiveJob extends AbstractJob $server_coll_id = $collection->get_coll_id(); // mask(s) of accepted files - $tmask = array(); - $tmaskgrp = array(); + $tmask = []; + $tmaskgrp = []; $cold = min(max((int) $settings->cold, self::MINCOLD), self::MAXCOLD); $stat0 = $stat1 = "0"; @@ -123,26 +123,26 @@ class ArchiveJob extends AbstractJob // load masks if ($settings->files && $settings->files->file) { foreach ($settings->files->file as $ft) { - $tmask[] = array( + $tmask[] = [ "mask" => (string) $ft["mask"] , "caption" => (string) $ft["caption"] , "accept" => (string) $ft["accept"] - ); + ]; } } if ($settings->files && $settings->files->grouping) { foreach ($settings->files->grouping as $ft) { - $tmaskgrp[] = array( + $tmaskgrp[] = [ "mask" => (string) $ft["mask"] , "caption" => (string) $ft["caption"] , "representation" => (string) $ft["representation"] , "accept" => (string) $ft["accept"] - ); + ]; } } if (count($tmask) == 0) { // no mask defined : accept all kind of files - $tmask[] = array("mask" => ".*", "caption" => "", "accept" => ""); + $tmask[] = ["mask" => ".*", "caption" => "", "accept" => ""]; } while ($this->isStarted()) { @@ -282,7 +282,7 @@ class ArchiveJob extends AbstractJob $n = $node->appendChild($dom->createElement('file')); $n->setAttribute('name', $file); $stat = stat($path . '/' . $file); - foreach (array("size", "ctime", "mtime") as $k) { + foreach (["size", "ctime", "mtime"] as $k) { $n->setAttribute($k, $stat[$k]); } $nnew++; @@ -345,7 +345,7 @@ class ArchiveJob extends AbstractJob $this->listFilesPhase2($app, $dom, $dnl->item(0), $path . '/' . $file, $depth + 1); } else { $stat = stat($path . '/' . $file); - foreach (array("size", "ctime", "mtime") as $k) { + foreach (["size", "ctime", "mtime"] as $k) { if ($dnl->item(0)->getAttribute($k) != $stat[$k]) { $this->setBranchHot($dom, $dnl->item(0)); break; @@ -374,7 +374,7 @@ class ArchiveJob extends AbstractJob } // make xml lighter (free ram) - foreach (array("size", "ctime", "mtime") as $k) { + foreach (["size", "ctime", "mtime"] as $k) { $n->removeAttribute($k); } @@ -398,7 +398,7 @@ class ArchiveJob extends AbstractJob // this group in new (to be created) // do we need one (or both) linked file ? (caption or representation) $err = false; - $flink = array('caption' => null, 'representation' => null); + $flink = ['caption' => null, 'representation' => null]; foreach ($flink as $linkName => $v) { if (isset($grpSettings[$linkName]) && $grpSettings[$linkName] != '') { @@ -438,7 +438,7 @@ class ArchiveJob extends AbstractJob // something is missing, the whole group goes error, ... $n->setAttribute('grp', 'todelete'); - $this->setAllChildren($dom, $n, array('error' => '1')); + $this->setAllChildren($dom, $n, ['error' => '1']); // bubble to the top for ($nn = $n; $nn && $nn->nodeType == XML_ELEMENT_NODE; $nn = $nn->parentNode) { @@ -498,7 +498,7 @@ class ArchiveJob extends AbstractJob return $ret; } - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { usleep(10); @@ -567,7 +567,7 @@ class ArchiveJob extends AbstractJob return; } - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { usleep(10); @@ -681,7 +681,7 @@ class ArchiveJob extends AbstractJob return $ret; } - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { usleep(10); @@ -1042,7 +1042,7 @@ class ArchiveJob extends AbstractJob $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas()); - $metaFields = array(); + $metaFields = []; if ($captionFile !== null && true === $app['filesystem']->exists($captionFile)) { $metaFields = $this->readXMLForDatabox($app, $metadatasStructure, $captionFile); $captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile)); @@ -1096,7 +1096,7 @@ class ArchiveJob extends AbstractJob */ private function archiveFilesToGrp(Application $app, \databox $databox, \DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, $grp_rid, $stat0, $stat1, $moveError, $moveArchived) { - $nodesToDel = array(); + $nodesToDel = []; for ($n = $node->firstChild; $n; $n = $n->nextSibling) { if (!$this->isStarted()) { break; @@ -1420,7 +1420,7 @@ class ArchiveJob extends AbstractJob $metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, $values)); } else { - $metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, array($field))); + $metadataBag->set($meta->get_name(), new BorderAttribute\MetaField($meta, [$field])); } } @@ -1448,7 +1448,7 @@ class ArchiveJob extends AbstractJob private function listFolder($path) { - $list = array(); + $list = []; if ($hdir = opendir($path)) { while (false !== $file = readdir($hdir)) { $list[] = $file; diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php index b925381fe5..27b3422449 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php @@ -55,13 +55,13 @@ class BridgeJob extends AbstractJob { $app = $data->getApplication(); - $status = array( + $status = [ \Bridge_Element::STATUS_PENDING, \Bridge_Element::STATUS_PROCESSING, \Bridge_Element::STATUS_PROCESSING_SERVER - ); + ]; - $params = array(); + $params = []; $n = 1; foreach ($status as $stat) { @@ -96,7 +96,7 @@ class BridgeJob extends AbstractJob $this->log('error', sprintf("An error occured : %s", $e->getMessage())); $sql = 'UPDATE bridge_elements SET status = :status WHERE id = :id'; - $params = array(':status' => \Bridge_Element::STATUS_ERROR, ':id' => $row['id']); + $params = [':status' => \Bridge_Element::STATUS_ERROR, ':id' => $row['id']]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -154,13 +154,13 @@ class BridgeJob extends AbstractJob switch ($status) { case \Bridge_Element::STATUS_ERROR: - $params = array( + $params = [ 'usr_id' => $account->get_user()->get_id(), 'reason' => $error_message, 'account_id' => $account->get_id(), 'sbas_id' => $element->get_record()->get_sbas_id(), 'record_id' => $element->get_record()->get_record_id(), - ); + ]; $app['events-manager']->trigger('__BRIDGE_UPLOAD_FAIL__', $params); break; diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php index 28f6594f3e..55b029d240 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/FtpJob.php @@ -159,16 +159,16 @@ class FtpJob extends AbstractJob } } - $obj = array(); + $obj = []; $basefolder = ''; - if (!in_array(trim($export->getDestfolder()), array('.', './', ''))) { + if (!in_array(trim($export->getDestfolder()), ['.', './', ''])) { $basefolder = \p4string::addEndSlash($export->getDestfolder()); } $basefolder .= $export->getFoldertocreate(); - if (in_array(trim($basefolder), array('.', './', ''))) { + if (in_array(trim($basefolder), ['.', './', ''])) { $basefolder = '/'; } @@ -229,10 +229,10 @@ class FtpJob extends AbstractJob $ftp_client->put($remotefile, $localfile); - $obj[] = array( + $obj[] = [ "name" => $subdef, "size" => filesize($localfile), "shortXml" => ($sdcaption ? $sdcaption : '') - ); + ]; if ($subdef == 'caption') { unlink($localfile); @@ -340,7 +340,7 @@ class FtpJob extends AbstractJob private function send_mails(Application $app, FtpExport $export) { - $transferts = array(); + $transferts = []; $transfert_status = _('task::ftp:Tous les documents ont ete transferes avec succes'); foreach ($export->getElements() as $element) { diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php index c431db59d2..44842edf87 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/FtpPullJob.php @@ -67,14 +67,14 @@ class FtpPullJob extends AbstractJob $ssl = (Boolean) (string) $settings->ssl; $passive = (Boolean) (string) $settings->passive; - foreach (array( + foreach ([ 'localpath' => $localPath, 'host' => $host, 'port' => $host, 'user' => $user, 'password' => $password, 'ftppath' => $ftpPath, - ) as $name => $value) { + ] as $name => $value) { if (trim($value) === '') { // maybe throw an exception to consider the job as failing ? $this->log('error', sprintf('setting `%s` must be set', $name)); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php index abec06b4cf..425f848032 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/PhraseanetIndexerJob.php @@ -101,7 +101,7 @@ class PhraseanetIndexerJob extends AbstractJob private function getCommandline($indexerPath, Application $app, Task $task) { - $cmd = array($indexerPath, '-o'); + $cmd = [$indexerPath, '-o']; $settings = simplexml_load_string($task->getSettings()); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php index 720d360df6..d8b280b638 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/RecordMoverJob.php @@ -123,7 +123,7 @@ class RecordMoverJob extends AbstractJob private function getData(Application $app, array $tasks, $logsql) { - $ret = array(); + $ret = []; foreach ($tasks as $sxtask) { if (!$this->isStarted()) { @@ -150,11 +150,11 @@ class RecordMoverJob extends AbstractJob $stmt = $databox->get_connection()->prepare($task['sql']['real']['sql']); $stmt->execute(); while ($this->isStarted() && false !== $row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $tmp = array( + $tmp = [ 'sbas_id' => $task['sbas_id'], 'record_id' => $row['record_id'], 'action' => $task['action'] - ); + ]; $rec = $databox->get_record($row['record_id']); switch ($task['action']) { @@ -188,7 +188,7 @@ class RecordMoverJob extends AbstractJob { $sbas_id = (int) $sxtask['sbas_id']; - $ret = array( + $ret = [ 'name' => $sxtask['name'] ? (string) $sxtask['name'] : 'sans nom', 'name_htmlencoded' => \p4string::MakeString(($sxtask['name'] ? $sxtask['name'] : 'sans nom'), 'html'), 'active' => trim($sxtask['active']) === '1', @@ -199,7 +199,7 @@ class RecordMoverJob extends AbstractJob 'sql' => null, 'err' => '', 'err_htmlencoded' => '', - ); + ]; try { $dbox = $app['phraseanet.appbox']->get_databox($sbas_id); @@ -229,7 +229,7 @@ class RecordMoverJob extends AbstractJob private function calcUPDATE(Application $app, $sbas_id, &$sxtask, $playTest) { - $tws = array(); // NEGATION of updates, used to build the 'test' sql + $tws = []; // NEGATION of updates, used to build the 'test' sql // // set coll_id ? if (($x = (int) ($sxtask->to->coll['id'])) > 0) { @@ -238,8 +238,8 @@ class RecordMoverJob extends AbstractJob // set status ? $x = $sxtask->to->status['mask']; - $mx = str_replace(' ', '0', ltrim(str_replace(array('0', 'x'), array(' ', ' '), $x))); - $ma = str_replace(' ', '0', ltrim(str_replace(array('x', '0'), array(' ', '1'), $x))); + $mx = str_replace(' ', '0', ltrim(str_replace(['0', 'x'], [' ', ' '], $x))); + $ma = str_replace(' ', '0', ltrim(str_replace(['x', '0'], [' ', '1'], $x))); if ($mx && $ma) $tws[] = '((status ^ 0b' . $mx . ') & 0b' . $ma . ')!=0'; elseif ($mx) @@ -266,18 +266,18 @@ class RecordMoverJob extends AbstractJob if (count($tw) > 0) $sql .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')'); - $ret = array( - 'real' => array( + $ret = [ + 'real' => [ 'sql' => $sql, 'sql_htmlencoded' => htmlentities($sql), - ), - 'test' => array( + ], + 'test' => [ 'sql' => $sql_test, 'sql_htmlencoded' => htmlentities($sql_test), 'result' => NULL, 'err' => NULL - ) - ); + ] + ]; if ($playTest) { $ret['test']['result'] = $this->playTest($app, $sbas_id, $sql_test); @@ -302,18 +302,18 @@ class RecordMoverJob extends AbstractJob if (count($tw) > 0) $sql .= ' WHERE ' . ((count($tw) == 1) ? $tw[0] : '(' . implode(') AND (', $tw) . ')'); - $ret = array( - 'real' => array( + $ret = [ + 'real' => [ 'sql' => $sql, 'sql_htmlencoded' => htmlentities($sql), - ), - 'test' => array( + ], + 'test' => [ 'sql' => $sql_test, 'sql_htmlencoded' => htmlentities($sql_test), 'result' => NULL, 'err' => NULL - ) - ); + ] + ]; if ($playTest) { $ret['test']['result'] = $this->playTest($app, $sbas_id, $sql_test); @@ -325,12 +325,12 @@ class RecordMoverJob extends AbstractJob private function playTest(Application $app, $sbas_id, $sql) { $connbas = \connection::getPDOConnection($app, $sbas_id); - $result = array('rids' => array(), 'err' => '', 'n' => null); + $result = ['rids' => [], 'err' => '', 'n' => null]; $result['n'] = $connbas->query('SELECT COUNT(*) AS n FROM (' . $sql . ') AS x')->fetchColumn(); $stmt = $connbas->prepare('SELECT record_id FROM (' . $sql . ') AS x LIMIT 10'); - if ($stmt->execute(array())) { + if ($stmt->execute([])) { while (($row = $stmt->fetch(\PDO::FETCH_ASSOC))) { $result['rids'][] = $row['record_id']; } @@ -346,7 +346,7 @@ class RecordMoverJob extends AbstractJob { $connbas = \connection::getPDOConnection($app, $sbas_id); - $tw = array(); + $tw = []; $join = ''; $ijoin = 0; @@ -367,7 +367,7 @@ class RecordMoverJob extends AbstractJob foreach ($sxtask->from->text as $x) { $ijoin++; $comp = strtoupper($x['compare']); - if (in_array($comp, array('<', '>', '<=', '>=', '=', '!='))) { + if (in_array($comp, ['<', '>', '<=', '>=', '=', '!='])) { $s = 'p' . $ijoin . '.name=\'' . $x['field'] . '\' AND p' . $ijoin . '.value' . $comp; $s .= '' . $connbas->quote($x['value']) . ''; @@ -419,8 +419,8 @@ class RecordMoverJob extends AbstractJob // criteria $x = $sxtask->from->status['mask']; - $mx = str_replace(' ', '0', ltrim(str_replace(array('0', 'x'), array(' ', ' '), $x))); - $ma = str_replace(' ', '0', ltrim(str_replace(array('x', '0'), array(' ', '1'), $x))); + $mx = str_replace(' ', '0', ltrim(str_replace(['0', 'x'], [' ', ' '], $x))); + $ma = str_replace(' ', '0', ltrim(str_replace(['x', '0'], [' ', '1'], $x))); if ($mx && $ma) { $tw[] = '((status^0b' . $mx . ')&0b' . $ma . ')=0'; } elseif ($mx) { @@ -429,6 +429,6 @@ class RecordMoverJob extends AbstractJob $tw[] = '(status&0b' . $ma . ")=0"; } - return array($tw, $join); + return [$tw, $join]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php index e39c16ece2..5ae298d45a 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/SubdefsJob.php @@ -92,7 +92,7 @@ class SubdefsJob extends AbstractJob WHERE record_id=:record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); $stmt->closeCursor(); // rewrite metadata @@ -101,7 +101,7 @@ class SubdefsJob extends AbstractJob jeton=(jeton | ' . JETON_WRITE_META_SUBDEF . ') WHERE record_id=:record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); $stmt->closeCursor(); unset($record); diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php index 1905543e83..3eb1a1b153 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/WriteMetadataJob.php @@ -68,7 +68,7 @@ class WriteMetadataJob extends AbstractJob $connbas = $databox->get_connection(); $subdefgroups = $databox->get_subdef_structure(); - $metasubdefs = array(); + $metasubdefs = []; foreach ($subdefgroups as $type => $subdefs) { foreach ($subdefs as $sub) { @@ -96,7 +96,7 @@ class WriteMetadataJob extends AbstractJob $type = $record->get_type(); $subdefs = $record->get_subdefs(); - $tsub = array(); + $tsub = []; foreach ($subdefs as $name => $subdef) { $write_document = (($jeton & JETON_WRITE_META_DOC) && $name == 'document'); @@ -137,7 +137,7 @@ class WriteMetadataJob extends AbstractJob $datas = $field->get_values(); if ($meta->is_multi()) { - $values = array(); + $values = []; foreach ($datas as $data) { $values[] = $data->getValue(); } @@ -167,7 +167,7 @@ class WriteMetadataJob extends AbstractJob $sql = 'UPDATE record SET jeton=jeton & ~' . JETON_WRITE_META . ' WHERE record_id = :record_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':record_id' => $row['record_id'])); + $stmt->execute([':record_id' => $row['record_id']]); $stmt->closeCursor(); } } diff --git a/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php b/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php index 099b2a31c2..384846e3f5 100644 --- a/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php +++ b/lib/Alchemy/Phrasea/TaskManager/LiveInformation.php @@ -35,11 +35,11 @@ class LiveInformation { $data = $this->notifier->notify(Notifier::MESSAGE_INFORMATIONS); - return array( + return [ 'configuration' => $this->status->getStatus(), 'actual' => isset($data['manager']) ? TaskManagerStatus::STATUS_STARTED : TaskManagerStatus::STATUS_STOPPED, 'process-id' => isset($data['manager']) ? $data['manager']['process-id'] : null, - ); + ]; } /** @@ -50,12 +50,12 @@ class LiveInformation public function getTask(Task $task) { $data = $this->notifier->notify(Notifier::MESSAGE_INFORMATIONS); - $taskData = (isset($data['jobs']) && isset($data['jobs'][$task->getId()])) ? $data['jobs'][$task->getId()] : array(); + $taskData = (isset($data['jobs']) && isset($data['jobs'][$task->getId()])) ? $data['jobs'][$task->getId()] : []; - return array( + return [ 'configuration' => $this->status->getStatus(), 'actual' => isset($taskData['status']) ? $taskData['status'] : Task::STATUS_STOPPED, 'process-id' => isset($taskData['process-id']) ? $taskData['process-id'] : null, - ); + ]; } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Notifier.php b/lib/Alchemy/Phrasea/TaskManager/Notifier.php index 48a2e08b7c..1d8bae86a6 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Notifier.php +++ b/lib/Alchemy/Phrasea/TaskManager/Notifier.php @@ -91,7 +91,7 @@ class Notifier * * @return Notifier */ - public static function create(array $options = array()) + public static function create(array $options = []) { $context = new \ZMQContext(); $socket = $context->getSocket(\ZMQ::SOCKET_REQ); diff --git a/lib/Alchemy/Phrasea/TaskManager/TaskList.php b/lib/Alchemy/Phrasea/TaskManager/TaskList.php index 766f31b235..df78679f0c 100644 --- a/lib/Alchemy/Phrasea/TaskManager/TaskList.php +++ b/lib/Alchemy/Phrasea/TaskManager/TaskList.php @@ -36,13 +36,13 @@ class TaskList implements TaskListInterface */ public function refresh() { - return array_map(array($this, 'entityToTask'), $this->repository->findActiveTasks()); + return array_map([$this, 'entityToTask'], $this->repository->findActiveTasks()); } public function entityToTask(TaskEntity $task) { $name = $task->getId() ; - $arguments = array($this->phpExec); + $arguments = [$this->phpExec]; if ($this->phpConf) { $arguments[] = '-c'; diff --git a/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php b/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php index 11bccfb1fe..64bf49a223 100644 --- a/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php +++ b/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php @@ -78,7 +78,7 @@ class TaskManagerStatus private function ensureConfigurationSchema() { if (!isset($this->conf['task-manager'])) { - $this->conf['task-manager'] = array('status' => static::STATUS_STARTED); + $this->conf['task-manager'] = ['status' => static::STATUS_STARTED]; return; } @@ -95,6 +95,6 @@ class TaskManagerStatus private function isValidStatus($status) { - return in_array($status, array(static::STATUS_STARTED, static::STATUS_STOPPED)); + return in_array($status, [static::STATUS_STARTED, static::STATUS_STOPPED]); } } diff --git a/lib/Alchemy/Phrasea/Twig/BytesConverter.php b/lib/Alchemy/Phrasea/Twig/BytesConverter.php index fda3004dba..bf06f70646 100644 --- a/lib/Alchemy/Phrasea/Twig/BytesConverter.php +++ b/lib/Alchemy/Phrasea/Twig/BytesConverter.php @@ -17,7 +17,7 @@ class BytesConverter extends \Twig_Extension public function __construct() { - $this->unit = array(); + $this->unit = []; $this->unit['B'] = 'Bytes'; // 8 bits $this->unit['KB'] = 'Kilobytes'; // 1024 bytes $this->unit['MB'] = 'Megabytes'; // 1048576 bytes @@ -36,14 +36,14 @@ class BytesConverter extends \Twig_Extension public function getFilters() { - return array( + return [ 'bytesTo*' => new \Twig_Filter_Method($this, 'bytes2Filter') - ); + ]; } public function bytes2Filter($suffix, $bytes, $precision = 2) { - $auto = array('Human', 'Auto'); + $auto = ['Human', 'Auto']; $unit = array_keys($this->unit); if ($bytes <= 0) { diff --git a/lib/Alchemy/Phrasea/Twig/Camelize.php b/lib/Alchemy/Phrasea/Twig/Camelize.php index 3d2b524ccb..5bd9472fee 100644 --- a/lib/Alchemy/Phrasea/Twig/Camelize.php +++ b/lib/Alchemy/Phrasea/Twig/Camelize.php @@ -40,9 +40,9 @@ class Camelize extends \Twig_Extension */ public function getFilters() { - return array( + return [ 'camelize' => new \Twig_Filter_Method($this, 'toCamelCase'), - ); + ]; } public function toCamelCase($str, $separator = '-', $pascalCase = false) diff --git a/lib/Alchemy/Phrasea/Twig/JSUniqueID.php b/lib/Alchemy/Phrasea/Twig/JSUniqueID.php index 1962c31ad8..cc9cc5370a 100644 --- a/lib/Alchemy/Phrasea/Twig/JSUniqueID.php +++ b/lib/Alchemy/Phrasea/Twig/JSUniqueID.php @@ -20,13 +20,13 @@ class JSUniqueID extends \Twig_Extension */ public function getFilters() { - return array( + return [ 'JSUniqueID' => new \Twig_Filter_Method($this, 'JSUniqueID'), - ); + ]; } public function JSUniqueID($prefix = null, $suffix = null) { - return $prefix . 'id' . str_replace(array(',', '.'), '-', microtime(true)) . base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36) . $suffix; + return $prefix . 'id' . str_replace([',', '.'], '-', microtime(true)) . base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36) . $suffix; } } diff --git a/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php b/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php index 7c122c398f..37d95a17b9 100644 --- a/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php +++ b/lib/Alchemy/Phrasea/Utilities/ComposerSetup.php @@ -61,7 +61,7 @@ class ComposerSetup throw new RuntimeException('Unable to move to target directory for composer install.'); } - $process = ProcessBuilder::create(array($this->phpExecutable, $installer))->getProcess(); + $process = ProcessBuilder::create([$this->phpExecutable, $installer])->getProcess(); try { $process->run(); diff --git a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php index df9bcd6a0a..3eacc9604e 100644 --- a/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php +++ b/lib/Alchemy/Phrasea/Utilities/Less/Compiler.php @@ -40,7 +40,7 @@ class Compiler $this->filesystem->mkdir(dirname($target)); if (!$files instanceof \Traversable) { - $files = new \ArrayObject(is_array($files) ? $files : array($files)); + $files = new \ArrayObject(is_array($files) ? $files : [$files]); } $files = (array) $files; diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php index a4738d6744..e4a6f494e4 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php +++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php @@ -65,7 +65,7 @@ class UserProvider implements ControlProviderInterface ->like(\User_Query::LIKE_LOGIN, $query) ->like_match(\User_Query::LIKE_MATCH_OR) ->include_phantoms(true) - ->on_bases_where_i_am($this->app['acl']->get($for_user), array('canadmin')) + ->on_bases_where_i_am($this->app['acl']->get($for_user), ['canadmin']) ->limit(0, 50) ->execute()->get_results(); diff --git a/lib/Alchemy/Phrasea/Vocabulary/Controller.php b/lib/Alchemy/Phrasea/Vocabulary/Controller.php index 9d463a2922..4e80871782 100644 --- a/lib/Alchemy/Phrasea/Vocabulary/Controller.php +++ b/lib/Alchemy/Phrasea/Vocabulary/Controller.php @@ -52,8 +52,8 @@ class Controller */ public static function getAvailable(Application $app) { - return array( + return [ new ControlProvider\UserProvider($app) - ); + ]; } } diff --git a/lib/classes/ACL.php b/lib/classes/ACL.php index 8c4c5ea498..7b0e1a0cf8 100644 --- a/lib/classes/ACL.php +++ b/lib/classes/ACL.php @@ -65,7 +65,7 @@ class ACL implements cache_cacheableInterface * * @var Array */ - protected $_global_rights = array( + protected $_global_rights = [ 'taskmanager' => false, 'manageusers' => false, 'order' => false, @@ -86,7 +86,7 @@ class ACL implements cache_cacheableInterface 'bas_chupub' => false, 'candwnldpreview' => true, 'candwnldhd' => true - ); + ]; /** * @@ -151,13 +151,13 @@ class ACL implements cache_cacheableInterface VALUES (null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)'; - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':sbas_id' => $record->get_sbas_id() , ':record_id' => $record->get_record_id() , ':case' => $action , ':pusher' => $pusher->get_id() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -175,13 +175,13 @@ class ACL implements cache_cacheableInterface VALUES (null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)'; - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':sbas_id' => $record->get_sbas_id() , ':record_id' => $record->get_record_id() , ':case' => $action , ':pusher' => $pusher->get_id() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -278,7 +278,7 @@ class ACL implements cache_cacheableInterface return $this; } - $sbas_ids = array(); + $sbas_ids = []; foreach ($base_ids as $base_id) { $sbas_ids[] = phrasea::sbasFromBas($this->app, $base_id); @@ -286,10 +286,10 @@ class ACL implements cache_cacheableInterface $sbas_ids = array_unique($sbas_ids); - $sbas_rights = array('bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub'); + $sbas_rights = ['bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub']; - $sbas_to_acces = array(); - $rights_to_give = array(); + $sbas_to_acces = []; + $rights_to_give = []; foreach ($this->app['acl']->get($template_user)->get_granted_sbas() as $databox) { $sbas_id = $databox->get_sbas_id(); @@ -314,27 +314,27 @@ class ACL implements cache_cacheableInterface $this->update_rights_to_sbas($sbas_id, $rights); } - $bas_rights = array('canputinalbum', 'candwnldhd' + $bas_rights = ['canputinalbum', 'candwnldhd' , 'candwnldpreview', 'cancmd' , 'canadmin', 'actif', 'canreport', 'canpush' , 'canaddrecord', 'canmodifrecord', 'candeleterecord' , 'chgstatus', 'imgtools' , 'manage', 'modify_struct' , 'nowatermark', 'order_master' - ); + ]; - $bas_to_acces = $masks_to_give = $rights_to_give = array(); + $bas_to_acces = $masks_to_give = $rights_to_give = []; /** * map masks (and+xor) of template to masks to apply to user on base * (and_and, and_or, xor_and, xor_or) */ - $sbmap = array( - '00' => array('aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'), - '01' => array('aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'), - '10' => array('aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'), - '11' => array('aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1') - ); + $sbmap = [ + '00' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], + '01' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'], + '10' => ['aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'], + '11' => ['aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1'] + ]; foreach ($this->app['acl']->get($template_user)->get_granted_base() as $collection) { $base_id = $collection->get_base_id(); @@ -371,7 +371,7 @@ class ACL implements cache_cacheableInterface . databox_status::dec2bin($this->app, $mask_xor) , -32 ); - $m = array('aa' => '', 'ao' => '', 'xa' => '', 'xo' => ''); + $m = ['aa' => '', 'ao' => '', 'xa' => '', 'xo' => '']; for ($i = 0; $i < 32; $i++) { $ax = $mand[$i] . $mxor[$i]; @@ -380,12 +380,12 @@ class ACL implements cache_cacheableInterface } } - $masks_to_give[$base_id] = array( + $masks_to_give[$base_id] = [ 'aa' => $m['aa'] , 'ao' => $m['ao'] , 'xa' => $m['xa'] , 'xo' => $m['xo'] - ); + ]; } $this->give_access_to_base($bas_to_acces); @@ -678,10 +678,10 @@ class ACL implements cache_cacheableInterface * @param array|null $sbas_ids Optionnal sbas_id to restrict the query on * @return array An array of collection */ - public function get_granted_base(Array $rights = array(), array $sbas_ids = null) + public function get_granted_base(Array $rights = [], array $sbas_ids = null) { $this->load_rights_bas(); - $ret = array(); + $ret = []; foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) { if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids)) { @@ -725,16 +725,16 @@ class ACL implements cache_cacheableInterface * @param Array $rights * @return Array */ - public function get_granted_sbas($rights = array()) + public function get_granted_sbas($rights = []) { if (is_string($rights)) - $rights = array($rights); + $rights = [$rights]; assert(is_array($rights)); $this->load_rights_sbas(); - $ret = array(); + $ret = []; foreach ($this->_rights_sbas as $sbas_id => $datas) { $continue = false; @@ -770,10 +770,10 @@ class ACL implements cache_cacheableInterface $sql = 'UPDATE usr SET create_db = :create_db WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':create_db' => $boolean ? '1' : '0', ':usr_id' => $this->user->get_id() - )); + ]); $stmt->closeCursor(); $this->delete_data_from_cache(self::CACHE_IS_ADMIN); @@ -808,13 +808,13 @@ class ACL implements cache_cacheableInterface FROM records_rights WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); - $this->_rights_records_preview = array(); - $this->_rights_records_document = array(); + $this->_rights_records_preview = []; + $this->_rights_records_document = []; foreach ($rs as $row) { $currentid = $row["sbas_id"] . "_" . $row["record_id"]; @@ -823,10 +823,10 @@ class ACL implements cache_cacheableInterface $this->_rights_records_preview[$currentid] = $currentid; } - $datas = array( + $datas = [ 'preview' => $this->_rights_records_preview , 'document' => $this->_rights_records_document - ); + ]; $this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS); @@ -850,7 +850,7 @@ class ACL implements cache_cacheableInterface FROM usr WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); @@ -887,11 +887,11 @@ class ACL implements cache_cacheableInterface AND sbas.sbas_id = sbasusr.sbas_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $this->_rights_sbas = array(); + $this->_rights_sbas = []; $this->_global_rights['bas_modif_th'] = false; $this->_global_rights['bas_modify_struct'] = false; @@ -948,11 +948,11 @@ class ACL implements cache_cacheableInterface AND s.sbas_id = b.sbas_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $this->_rights_bas = $this->_limited = array(); + $this->_rights_bas = $this->_limited = []; $this->_global_rights['manageusers'] = false; $this->_global_rights['coll_manage'] = false; @@ -1009,10 +1009,10 @@ class ACL implements cache_cacheableInterface if ($row['time_limited'] == '1' && ($row['limited_from'] !== '' || $row['limited_to'] !== '')) { - $this->_limited[$row['base_id']] = array( + $this->_limited[$row['base_id']] = [ 'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null , 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null - ); + ]; } $this->_rights_bas[$row['base_id']]['imgtools'] @@ -1128,7 +1128,7 @@ class ACL implements cache_cacheableInterface $usr_id = $this->user->get_id(); foreach ($base_ids as $base_id) { - if (!$stmt_del->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id))) { + if (!$stmt_del->execute([':base_id' => $base_id, ':usr_id' => $usr_id])) { throw new Exception('Error while deleteing some rights'); } } @@ -1148,12 +1148,12 @@ class ACL implements cache_cacheableInterface VALUES (null, :base_id, :usr_id, "1")'; $stmt_ins = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_ins); $usr_id = $this->user->get_id(); - $to_update = array(); + $to_update = []; $this->load_rights_bas(); foreach ($base_ids as $base_id) { if (!isset($this->_rights_bas[$base_id])) { - $stmt_ins->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id)); + $stmt_ins->execute([':base_id' => $base_id, ':usr_id' => $usr_id]); } elseif ($this->_rights_bas[$base_id]['actif'] === false) { $to_update[] = $base_id; } @@ -1164,7 +1164,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id AND base_id = :base_id'; $stmt_upd = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_upd); foreach ($to_update as $base_id) { - $stmt_upd->execute(array(':usr_id' => $usr_id, ':base_id' => $base_id)); + $stmt_upd->execute([':usr_id' => $usr_id, ':base_id' => $base_id]); } $stmt_upd->closeCursor(); @@ -1188,7 +1188,7 @@ class ACL implements cache_cacheableInterface foreach ($sbas_ids as $sbas_id) { if (!$this->has_access_to_sbas($sbas_id)) - $stmt_ins->execute(array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id)); + $stmt_ins->execute([':sbas_id' => $sbas_id, ':usr_id' => $usr_id]); } $this->delete_data_from_cache(self::CACHE_RIGHTS_SBAS); @@ -1207,12 +1207,12 @@ class ACL implements cache_cacheableInterface { if (!$this->has_access_to_base($base_id) && (!isset($rights['actif']) || $rights['actif'] == '1')) { - $this->give_access_to_base(array($base_id)); + $this->give_access_to_base([$base_id]); } $sql_up = "UPDATE basusr SET "; - $sql_args = $params = array(); + $sql_args = $params = []; foreach ($rights as $right => $v) { $sql_args[] = " " . $right . " = :" . $right; switch ($right) { @@ -1237,7 +1237,7 @@ class ACL implements cache_cacheableInterface $params = array_merge( $params - , array(':base_id' => $base_id, ':usr_id' => $usr_id) + , [':base_id' => $base_id, ':usr_id' => $usr_id] ); $stmt_up = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_up); @@ -1262,7 +1262,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id_2 AND b.base_id = bu.base_id)'; $usr_id = $this->user->get_id(); - $params = array(':usr_id_1' => $usr_id, ':usr_id_2' => $usr_id); + $params = [':usr_id_1' => $usr_id, ':usr_id_2' => $usr_id]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -1282,13 +1282,13 @@ class ACL implements cache_cacheableInterface public function update_rights_to_sbas($sbas_id, $rights) { if (!$this->has_access_to_sbas($sbas_id)) - $this->give_access_to_sbas(array($sbas_id)); + $this->give_access_to_sbas([$sbas_id]); $sql_up = "UPDATE sbasusr SET "; - $sql_args = array(); + $sql_args = []; $usr_id = $this->user->get_id(); - $params = array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id); + $params = [':sbas_id' => $sbas_id, ':usr_id' => $usr_id]; foreach ($rights as $right => $v) { $sql_args[] = " " . $right . " = :" . $right; @@ -1324,7 +1324,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id AND base_id = :base_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id(), ':base_id' => $base_id)); + $stmt->execute([':usr_id' => $this->user->get_id(), ':base_id' => $base_id]); $stmt->closeCursor(); unset($stmt); @@ -1340,13 +1340,13 @@ class ACL implements cache_cacheableInterface AND usr_id = :usr_id AND MONTH(lastconn) != MONTH(NOW()) AND restrict_dwnld = 1'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $stmt->closeCursor(); $sql = "UPDATE basusr SET lastconn=now() WHERE usr_id = :usr_id AND actif = 1"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $stmt->closeCursor(); unset($stmt); @@ -1368,12 +1368,12 @@ class ACL implements cache_cacheableInterface SET remain_dwnld = :restes, restrict_dwnld = 1, month_dwnld_max = :droits WHERE usr_id = :usr_id AND base_id = :base_id '; - $params = array( + $params = [ ':usr_id' => $this->user->get_id(), ':base_id' => $base_id, ':restes' => $restes, ':droits' => $droits - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -1390,10 +1390,10 @@ class ACL implements cache_cacheableInterface $sql = 'SELECT * FROM basusr WHERE base_id = :base_from AND usr_id = :usr_id'; - $params = array( + $params = [ ':base_from' => $base_id_from, ':usr_id' => $this->user->get_id() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -1404,12 +1404,12 @@ class ACL implements cache_cacheableInterface return $this; } - $this->give_access_to_base(array($base_id_dest)); + $this->give_access_to_base([$base_id_dest]); - $rights = array( + $rights = [ 'mask_and' => $row['mask_and'], 'mask_xor' => $row['mask_xor'], - ); + ]; if ($row['canputinalbum']) $rights['canputinalbum'] = true; @@ -1476,15 +1476,15 @@ class ACL implements cache_cacheableInterface $stmt = $databox->get_connection()->prepare($sql); $iord = 0; - foreach ($this->get_granted_base(array(), array($databox->get_sbas_id())) as $collection) { - $stmt->execute(array( + foreach ($this->get_granted_base([], [$databox->get_sbas_id()]) as $collection) { + $stmt->execute([ ':site_id' => $this->app['configuration']['main']['key'], ':usr_id' => $this->user->get_id(), ':coll_id' => $collection->get_coll_id(), ':mask_and' => $this->get_mask_and($collection->get_base_id()), ':mask_xor' => $this->get_mask_xor($collection->get_base_id()), ':ord' => $iord++ - )); + ]); } $stmt->closeCursor(); @@ -1504,10 +1504,10 @@ class ACL implements cache_cacheableInterface public function delete_injected_rights_sbas(databox $databox) { $sql = 'DELETE FROM collusr WHERE usr_id = :usr_id AND site = :site'; - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':site' => $this->app['configuration']['main']['key'] - ); + ]; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); @@ -1517,13 +1517,13 @@ class ACL implements cache_cacheableInterface public function set_masks_on_base($base_id, $and_and, $and_or, $xor_and, $xor_or) { - $vhex = array(); - $datas = array( + $vhex = []; + $datas = [ 'and_and' => $and_and, 'and_or' => $and_or, 'xor_and' => $xor_and, 'xor_or' => $xor_or - ); + ]; foreach ($datas as $name => $f) { $vhex[$name] = "0x"; @@ -1545,7 +1545,7 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id and base_id = :base_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $base_id, ':usr_id' => $this->user->get_id())); + $stmt->execute([':base_id' => $base_id, ':usr_id' => $this->user->get_id()]); $stmt->closeCursor(); unset($stmt); @@ -1596,12 +1596,12 @@ class ACL implements cache_cacheableInterface WHERE base_id = :base_id AND usr_id = :usr_id'; } - $params = array( + $params = [ ':usr_id' => $this->user->get_id() , ':base_id' => $base_id , 'limited_from' => ($limit_from ? $limit_from->format(DATE_ISO8601) : null) , 'limited_to' => ($limit_to ? $limit_to->format(DATE_ISO8601) : null) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); @@ -1623,11 +1623,11 @@ class ACL implements cache_cacheableInterface { $sql = 'SELECT base_id FROM basusr WHERE order_master="1" AND usr_id= :usr_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->user->get_id())); + $stmt->execute([':usr_id' => $this->user->get_id()]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $collections = array(); + $collections = []; foreach ($rs as $row) { $collections[] = \collection::get_from_base_id($this->app, $row['base_id']); @@ -1650,11 +1650,11 @@ class ACL implements cache_cacheableInterface WHERE usr_id = :usr_id AND base_id = :base_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':master' => $bool ? 1 : 0, ':usr_id' => $this->user->get_id(), ':base_id' => $collection->get_base_id() - )); + ]); $stmt->closeCursor(); return $this; diff --git a/lib/classes/API/OAuth2/Account.php b/lib/classes/API/OAuth2/Account.php index c6603eb57d..48bcd16a5e 100644 --- a/lib/classes/API/OAuth2/Account.php +++ b/lib/classes/API/OAuth2/Account.php @@ -88,7 +88,7 @@ class API_OAuth2_Account WHERE api_account_id = :api_account_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':api_account_id' => $this->id)); + $stmt->execute([':api_account_id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -150,10 +150,10 @@ class API_OAuth2_Account $sql = 'UPDATE api_accounts SET revoked = :revoked WHERE api_account_id = :account_id'; - $params = array( + $params = [ ':revoked' => ($boolean ? '1' : '0') , 'account_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -218,7 +218,7 @@ class API_OAuth2_Account $sql = 'DELETE FROM api_accounts WHERE api_account_id = :account_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array('account_id' => $this->id)); + $stmt->execute(['account_id' => $this->id]); $stmt->closeCursor(); return; @@ -231,13 +231,13 @@ class API_OAuth2_Account VALUES (null, :usr_id, :revoked, :api_version, :application_id, :created)'; $datetime = new Datetime(); - $params = array( + $params = [ ':usr_id' => $user->get_id() , ':application_id' => $application->get_id() , ':api_version' => API_OAuth2_Adapter::API_VERSION , ':revoked' => 0 , ':created' => $datetime->format("Y-m-d H:i:s") - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -253,10 +253,10 @@ class API_OAuth2_Account $sql = 'SELECT api_account_id FROM api_accounts WHERE usr_id = :usr_id AND application_id = :application_id'; - $params = array( + $params = [ ":usr_id" => $user->get_id(), ":application_id" => $application->get_id() - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/API/OAuth2/Adapter.php b/lib/classes/API/OAuth2/Adapter.php index 88026704e8..86b0618d5c 100644 --- a/lib/classes/API/OAuth2/Adapter.php +++ b/lib/classes/API/OAuth2/Adapter.php @@ -55,12 +55,12 @@ class API_OAuth2_Adapter extends OAuth2 * * @var array */ - protected $token_type = array("bearer" => "Bearer"); + protected $token_type = ["bearer" => "Bearer"]; /** * @var array */ - protected $authentication_scheme = array("authorization", "uri", "body"); + protected $authentication_scheme = ["authorization", "uri", "body"]; /** * @@ -95,7 +95,7 @@ class API_OAuth2_Adapter extends OAuth2 public function __construct(Application $app) { parent::__construct(); - $this->params = array(); + $this->params = []; $this->app = $app; return $this; @@ -227,7 +227,7 @@ class API_OAuth2_Adapter extends OAuth2 try { $token = API_OAuth2_Token::load_by_oauth_token($this->app, $oauth_token); - $result = array( + $result = [ 'scope' => $token->get_scope() , 'expires' => $token->get_expires() , 'client_id' => $token->get_account()->get_application()->get_client_id() @@ -235,7 +235,7 @@ class API_OAuth2_Adapter extends OAuth2 , 'revoked' => ($token->get_account()->is_revoked() ? '1' : '0') , 'usr_id' => $token->get_account()->get_user()->get_id() , 'oauth_token' => $token->get_value() - ); + ]; } catch (Exception $e) { @@ -272,10 +272,10 @@ class API_OAuth2_Adapter extends OAuth2 */ protected function getSupportedGrantTypes() { - return array( + return [ OAUTH2_GRANT_TYPE_AUTH_CODE, OAUTH2_GRANT_TYPE_USER_CREDENTIALS - ); + ]; } /** @@ -286,7 +286,7 @@ class API_OAuth2_Adapter extends OAuth2 */ protected function getSupportedScopes() { - return array(); + return []; } /** @@ -300,12 +300,12 @@ class API_OAuth2_Adapter extends OAuth2 try { $code = new API_OAuth2_AuthCode($this->app, $code); - return array( + return [ 'redirect_uri' => $code->get_redirect_uri() , 'client_id' => $code->get_account()->get_application()->get_client_id() , 'expires' => $code->get_expires() , 'account_id' => $code->get_account()->get_id() - ); + ]; } catch (Exception $e) { } @@ -352,11 +352,11 @@ class API_OAuth2_Adapter extends OAuth2 try { $token = new API_OAuth2_RefreshToken($this->app, $refresh_token); - return array( + return [ 'token' => $token->get_value() , 'expires' => $token->get_expires()->format('U') , 'client_id' => $token->get_account()->get_application()->get_client_id() - ); + ]; } catch (Exception $e) { } @@ -383,11 +383,11 @@ class API_OAuth2_Adapter extends OAuth2 public function getAuthorizationRequestParameters(Request $request) { - $datas = array( + $datas = [ 'response_type' => $request->get('response_type', false) , 'client_id' => $request->get('client_id', false) , 'redirect_uri' => $request->get('redirect_uri', false) - ); + ]; $scope = $request->get('scope', false); $state = $request->get('state', false); @@ -400,21 +400,21 @@ class API_OAuth2_Adapter extends OAuth2 $datas["scope"] = $scope; } - $filters = array( - "client_id" => array( + $filters = [ + "client_id" => [ "filter" => FILTER_VALIDATE_REGEXP - , "options" => array("regexp" => OAUTH2_CLIENT_ID_REGEXP) + , "options" => ["regexp" => OAUTH2_CLIENT_ID_REGEXP] , "flags" => FILTER_REQUIRE_SCALAR - ) - , "response_type" => array( + ] + , "response_type" => [ "filter" => FILTER_VALIDATE_REGEXP - , "options" => array("regexp" => OAUTH2_AUTH_RESPONSE_TYPE_REGEXP) + , "options" => ["regexp" => OAUTH2_AUTH_RESPONSE_TYPE_REGEXP] , "flags" => FILTER_REQUIRE_SCALAR - ) - , "redirect_uri" => array("filter" => FILTER_SANITIZE_URL) - , "state" => array("flags" => FILTER_REQUIRE_SCALAR) - , "scope" => array("flags" => FILTER_REQUIRE_SCALAR) - ); + ] + , "redirect_uri" => ["filter" => FILTER_SANITIZE_URL] + , "state" => ["flags" => FILTER_REQUIRE_SCALAR] + , "scope" => ["flags" => FILTER_REQUIRE_SCALAR] + ]; $input = filter_var_array($datas, $filters); @@ -544,13 +544,13 @@ class API_OAuth2_Adapter extends OAuth2 * @param array $params * @return string */ - public function finishNativeClientAuthorization($is_authorized, $params = array()) + public function finishNativeClientAuthorization($is_authorized, $params = []) { - $result = array(); - $params += array( + $result = []; + $params += [ 'scope' => NULL, 'state' => NULL, - ); + ]; extract($params); if ($state !== NULL) @@ -632,12 +632,12 @@ class API_OAuth2_Adapter extends OAuth2 return TRUE; } - public function finishClientAuthorization($is_authorized, $params = array()) + public function finishClientAuthorization($is_authorized, $params = []) { - $params += array( + $params += [ 'scope' => NULL, 'state' => NULL, - ); + ]; extract($params); if ($state !== NULL) @@ -659,17 +659,17 @@ class API_OAuth2_Adapter extends OAuth2 */ public function grantAccessToken() { - $filters = array( - "grant_type" => array("filter" => FILTER_VALIDATE_REGEXP, "options" => array("regexp" => OAUTH2_GRANT_TYPE_REGEXP), "flags" => FILTER_REQUIRE_SCALAR), - "scope" => array("flags" => FILTER_REQUIRE_SCALAR), - "code" => array("flags" => FILTER_REQUIRE_SCALAR), - "redirect_uri" => array("filter" => FILTER_SANITIZE_URL), - "username" => array("flags" => FILTER_REQUIRE_SCALAR), - "password" => array("flags" => FILTER_REQUIRE_SCALAR), - "assertion_type" => array("flags" => FILTER_REQUIRE_SCALAR), - "assertion" => array("flags" => FILTER_REQUIRE_SCALAR), - "refresh_token" => array("flags" => FILTER_REQUIRE_SCALAR), - ); + $filters = [ + "grant_type" => ["filter" => FILTER_VALIDATE_REGEXP, "options" => ["regexp" => OAUTH2_GRANT_TYPE_REGEXP], "flags" => FILTER_REQUIRE_SCALAR], + "scope" => ["flags" => FILTER_REQUIRE_SCALAR], + "code" => ["flags" => FILTER_REQUIRE_SCALAR], + "redirect_uri" => ["filter" => FILTER_SANITIZE_URL], + "username" => ["flags" => FILTER_REQUIRE_SCALAR], + "password" => ["flags" => FILTER_REQUIRE_SCALAR], + "assertion_type" => ["flags" => FILTER_REQUIRE_SCALAR], + "assertion" => ["flags" => FILTER_REQUIRE_SCALAR], + "refresh_token" => ["flags" => FILTER_REQUIRE_SCALAR], + ]; $input = filter_input_array(INPUT_POST, $filters); @@ -773,10 +773,10 @@ class API_OAuth2_Adapter extends OAuth2 protected function createAccessToken($account_id, $scope = NULL) { - $token = array( + $token = [ "access_token" => $this->genAccessToken(), "scope" => $scope - ); + ]; if ($this->enable_expire) $token['expires_in'] = $this->getVariable('access_token_lifetime', OAUTH2_DEFAULT_ACCESS_TOKEN_LIFETIME); @@ -810,11 +810,11 @@ class API_OAuth2_Adapter extends OAuth2 $account = API_OAuth2_Account::load_with_user($this->app, $application, $user); - return array( + return [ 'redirect_uri' => $application->get_redirect_uri() , 'client_id' => $application->get_client_id() , 'account_id' => $account->get_id() - ); + ]; } catch (AccountLockedException $e) { return false; } catch (RequireCaptchaException $e) { diff --git a/lib/classes/API/OAuth2/Application.php b/lib/classes/API/OAuth2/Application.php index a213dfa7ef..32b49e65e3 100644 --- a/lib/classes/API/OAuth2/Application.php +++ b/lib/classes/API/OAuth2/Application.php @@ -147,7 +147,7 @@ class API_OAuth2_Application WHERE application_id = :application_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':application_id' => $this->id)); + $stmt->execute([':application_id' => $this->id]); if (0 === $stmt->rowCount()) { throw new NotFoundHttpException(sprintf('Application with id %d not found', $this->id)); @@ -215,7 +215,7 @@ class API_OAuth2_Application */ public function set_type($type) { - if ( ! in_array($type, array(self::DESKTOP_TYPE, self::WEB_TYPE))) + if ( ! in_array($type, [self::DESKTOP_TYPE, self::WEB_TYPE])) throw new Exception_InvalidArgument(); $this->type = $type; @@ -226,10 +226,10 @@ class API_OAuth2_Application $sql = 'UPDATE api_applications SET type = :type, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':type' => $this->type , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -259,10 +259,10 @@ class API_OAuth2_Application $sql = 'UPDATE api_applications SET name = :name, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':name' => $this->name , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -293,10 +293,10 @@ class API_OAuth2_Application SET description = :description, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':description' => $this->description , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -327,10 +327,10 @@ class API_OAuth2_Application SET website = :website, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':website' => $this->website , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -361,10 +361,10 @@ class API_OAuth2_Application SET activated = :activated, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':activated' => $this->activated , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -395,10 +395,10 @@ class API_OAuth2_Application SET grant_password = :grant_password, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':grant_password' => $this->grant_password , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -447,10 +447,10 @@ class API_OAuth2_Application SET client_id = :client_id, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':client_id' => $this->client_id , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -481,10 +481,10 @@ class API_OAuth2_Application SET client_secret = :client_secret, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':client_secret' => $this->client_secret , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -514,10 +514,10 @@ class API_OAuth2_Application SET redirect_uri = :redirect_uri, last_modified = NOW() WHERE application_id = :application_id'; - $params = array( + $params = [ ':redirect_uri' => $this->redirect_uri , ':application_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -536,10 +536,10 @@ class API_OAuth2_Application $sql = 'SELECT api_account_id FROM api_accounts WHERE usr_id = :usr_id AND application_id = :id'; - $params = array( + $params = [ ':usr_id' => $user->get_id() , ':id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -566,7 +566,7 @@ class API_OAuth2_Application WHERE application_id = :application_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':application_id' => $this->get_id())); + $stmt->execute([':application_id' => $this->get_id()]); $stmt->closeCursor(); return; @@ -582,11 +582,11 @@ class API_OAuth2_Application WHERE application_id = :application_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':application_id' => $this->get_id())); + $stmt->execute([':application_id' => $this->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $accounts = array(); + $accounts = []; foreach ($rs as $row) { $accounts[] = new API_OAuth2_Account($this->app, $row['api_account_id']); @@ -618,7 +618,7 @@ class API_OAuth2_Application $client_secret = API_OAuth2_Token::generate_token(); $client_token = API_OAuth2_Token::generate_token(); - $params = array( + $params = [ ':usr_id' => $user ? $user->get_id() : null, ':name' => $name, ':client_id' => $client_token, @@ -626,7 +626,7 @@ class API_OAuth2_Application ':nonce' => $nonce, ':activated' => 1, ':grant_password' => 0 - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -655,7 +655,7 @@ class API_OAuth2_Application WHERE client_id = :client_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':client_id' => $client_id)); + $stmt->execute([':client_id' => $client_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -672,11 +672,11 @@ class API_OAuth2_Application WHERE a.creator = :usr_id AND a.application_id = b.application_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $apps = array(); + $apps = []; foreach ($rs as $row) { $apps[] = new API_OAuth2_Application($app, $row['application_id']); } @@ -691,11 +691,11 @@ class API_OAuth2_Application WHERE usr_id = :usr_id AND c.application_id = a.application_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $apps = array(); + $apps = []; foreach ($rs as $row) { $apps[] = new API_OAuth2_Application($app, $row['application_id']); } @@ -712,11 +712,11 @@ class API_OAuth2_Application AND revoked = 0'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $apps = array(); + $apps = []; foreach ($rs as $row) { $apps[] = new API_OAuth2_Application($app, $row['application_id']); } diff --git a/lib/classes/API/OAuth2/AuthCode.php b/lib/classes/API/OAuth2/AuthCode.php index 6c380026ad..c5dcc6dba5 100644 --- a/lib/classes/API/OAuth2/AuthCode.php +++ b/lib/classes/API/OAuth2/AuthCode.php @@ -40,7 +40,7 @@ class API_OAuth2_AuthCode FROM api_oauth_codes WHERE code = :code'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':code' => $this->code)); + $stmt->execute([':code' => $this->code]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -82,7 +82,7 @@ class API_OAuth2_AuthCode $sql = 'UPDATE api_oauth_codes SET redirect_uri = :redirect_uri WHERE code = :code'; - $params = array(':redirect_uri' => $redirect_uri, ':code' => $this->code); + $params = [':redirect_uri' => $redirect_uri, ':code' => $this->code]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -112,7 +112,7 @@ class API_OAuth2_AuthCode $sql = 'UPDATE api_oauth_codes SET scope = :scope WHERE code = :code'; - $params = array(':scope' => $scope, ':code' => $this->code); + $params = [':scope' => $scope, ':code' => $this->code]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -128,7 +128,7 @@ class API_OAuth2_AuthCode $sql = 'DELETE FROM api_oauth_codes WHERE code = :code'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':code' => $this->code)); + $stmt->execute([':code' => $this->code]); $stmt->closeCursor(); return; @@ -147,12 +147,12 @@ class API_OAuth2_AuthCode $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array(":account_id" => $account->get_id()); + $params = [":account_id" => $account->get_id()]; $stmt->execute($params); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $codes = array(); + $codes = []; foreach ($rs as $row) { $codes[] = new API_OAuth2_AuthCode($app, $row['code']); @@ -177,11 +177,11 @@ class API_OAuth2_AuthCode $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array( + $params = [ ":code" => $code, ":account_id" => $account->get_id(), ":expires" => $expires - ); + ]; $stmt->execute($params); $stmt->closeCursor(); diff --git a/lib/classes/API/OAuth2/Form/DevAppDesktop.php b/lib/classes/API/OAuth2/Form/DevAppDesktop.php index b8b0fdddd6..bad53804cd 100644 --- a/lib/classes/API/OAuth2/Form/DevAppDesktop.php +++ b/lib/classes/API/OAuth2/Form/DevAppDesktop.php @@ -144,8 +144,8 @@ class API_OAuth2_Form_DevAppDesktop */ public static function loadValidatorMetadata(ClassMetadata $metadata) { - $blank = array('message' => _('Cette valeur ne peut être vide')); - $url = array('message' => _('Url non valide')); + $blank = ['message' => _('Cette valeur ne peut être vide')]; + $url = ['message' => _('Url non valide')]; $metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank)); $metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank)); diff --git a/lib/classes/API/OAuth2/Form/DevAppInternet.php b/lib/classes/API/OAuth2/Form/DevAppInternet.php index 7e57318a63..0720f6dcc0 100644 --- a/lib/classes/API/OAuth2/Form/DevAppInternet.php +++ b/lib/classes/API/OAuth2/Form/DevAppInternet.php @@ -147,8 +147,8 @@ class API_OAuth2_Form_DevAppInternet */ public static function loadValidatorMetadata(ClassMetadata $metadata) { - $blank = array('message' => _('Cette valeur ne peut être vide')); - $url = array('message' => _('Url non valide')); + $blank = ['message' => _('Cette valeur ne peut être vide')]; + $url = ['message' => _('Url non valide')]; $metadata->addPropertyConstraint('name', new Constraints\NotBlank($blank)); $metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank)); diff --git a/lib/classes/API/OAuth2/RefreshToken.php b/lib/classes/API/OAuth2/RefreshToken.php index c1b66d4c6e..446ff34d4f 100644 --- a/lib/classes/API/OAuth2/RefreshToken.php +++ b/lib/classes/API/OAuth2/RefreshToken.php @@ -39,7 +39,7 @@ class API_OAuth2_RefreshToken FROM api_oauth_refresh_tokens WHERE refresh_token = :token'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':token' => $this->token)); + $stmt->execute([':token' => $this->token]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -88,7 +88,7 @@ class API_OAuth2_RefreshToken WHERE refresh_token = :refresh_token'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(":refresh_token" => $this->token)); + $stmt->execute([":refresh_token" => $this->token]); $stmt->closeCursor(); return; @@ -106,11 +106,11 @@ class API_OAuth2_RefreshToken WHERE api_account_id = :account_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $account->get_id())); + $stmt->execute([':account_id' => $account->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $tokens = array(); + $tokens = []; foreach ($rs as $row) { $tokens[] = new API_OAuth2_RefreshToken($app, $row['refresh_token']); @@ -135,12 +135,12 @@ class API_OAuth2_RefreshToken VALUES (:refresh_token, :account_id, :expires, :scope)'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array( + $params = [ ":refresh_token" => $refresh_token, ":account_id" => $account->get_id(), ":expires" => $expires, ":scope" => $scope - ); + ]; $stmt->execute($params); $stmt->closeCursor(); diff --git a/lib/classes/API/OAuth2/Token.php b/lib/classes/API/OAuth2/Token.php index d2f6072b8d..e96763472d 100644 --- a/lib/classes/API/OAuth2/Token.php +++ b/lib/classes/API/OAuth2/Token.php @@ -75,7 +75,7 @@ class API_OAuth2_Token FROM api_oauth_tokens WHERE api_account_id = :account_id'; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $this->account->get_id())); + $stmt->execute([':account_id' => $this->account->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ( ! $row) @@ -110,10 +110,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET oauth_token = :oauth_token WHERE oauth_token = :current_token'; - $params = array( + $params = [ ':oauth_token' => $oauth_token , ':current_token' => $this->token - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -143,10 +143,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET session_id = :session_id WHERE oauth_token = :current_token'; - $params = array( + $params = [ ':session_id' => $session_id , ':current_token' => $this->token - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -176,10 +176,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET expires = FROM_UNIXTIME(:expires) WHERE oauth_token = :oauth_token'; - $params = array( + $params = [ ':expires' => $expires , ':oauth_token' => $this->get_value() - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -204,10 +204,10 @@ class API_OAuth2_Token $sql = 'UPDATE api_oauth_tokens SET scope = :scope WHERE oauth_token = :oauth_token'; - $params = array( + $params = [ ':scope' => $scope , ':oauth_token' => $this->get_value() - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -238,10 +238,10 @@ class API_OAuth2_Token $new_token = self::generate_token(); - $params = array( + $params = [ ':new_token' => $new_token , ':old_token' => $this->get_value() - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -261,7 +261,7 @@ class API_OAuth2_Token $sql = 'DELETE FROM api_oauth_tokens WHERE oauth_token = :oauth_token'; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':oauth_token' => $this->get_value())); + $stmt->execute([':oauth_token' => $this->get_value()]); $stmt->closeCursor(); return; @@ -281,7 +281,7 @@ class API_OAuth2_Token AND a.api_account_id = b.api_account_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $params = array(":oauth_token" => $oauth_token); + $params = [":oauth_token" => $oauth_token]; $stmt->execute($params); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -309,12 +309,12 @@ class API_OAuth2_Token $expires = new \DateTime('+1 hour'); - $params = array( + $params = [ ':token' => self::generate_token() , ':account_id' => $account->get_id() , ':expire' => $expires->format(DATE_ISO8601) , ':scope' => $scope - ); + ]; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/API/V1/Log.php b/lib/classes/API/V1/Log.php index 82d3741474..080b9af696 100644 --- a/lib/classes/API/V1/Log.php +++ b/lib/classes/API/V1/Log.php @@ -108,7 +108,7 @@ class API_V1_Log api_log_id = :log_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':log_id' => $this->id)); + $stmt->execute([':log_id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -137,10 +137,10 @@ class API_V1_Log SET api_account_id = :account_id WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':api_account_id' => $this->account_id , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -162,10 +162,10 @@ class API_V1_Log SET api_log_date = :date WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':date' => $this->date->format("Y-m-d H:i:s") , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -187,10 +187,10 @@ class API_V1_Log SET api_log_status_code = :code WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':code' => $this->status_code , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -207,7 +207,7 @@ class API_V1_Log public function set_format($format) { - if ( ! in_array($format, array('json', 'jsonp', 'yaml', 'unknow'))) + if ( ! in_array($format, ['json', 'jsonp', 'yaml', 'unknow'])) throw new Exception_InvalidArgument(); $this->format = $format; @@ -216,10 +216,10 @@ class API_V1_Log SET api_log_format = :format WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':format' => $this->format , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -235,7 +235,7 @@ class API_V1_Log public function set_ressource($ressource) { - if ( ! in_array($format, array(self::DATABOXES_RESSOURCE, self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE))) + if ( ! in_array($format, [self::DATABOXES_RESSOURCE, self::BASKETS_RESSOURCE, self::FEEDS_RESSOURCE, self::RECORDS_RESSOURCE])) throw new Exception_InvalidArgument(); $this->ressource = $ressource; @@ -244,10 +244,10 @@ class API_V1_Log SET api_log_ressource = :ressource WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':ressource' => $this->ressource , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -269,10 +269,10 @@ class API_V1_Log SET api_log_general = :general WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':general' => $this->general , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -294,10 +294,10 @@ class API_V1_Log SET api_log_aspect = :aspect WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':aspect' => $this->aspect , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -319,10 +319,10 @@ class API_V1_Log SET api_log_action = :action WHERE api_log_id = :log_id'; - $params = array( + $params = [ ':action' => $this->action , ':log_id' => $this->id - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -365,7 +365,7 @@ class API_V1_Log :action )'; - $params = array( + $params = [ ':account_id' => $account->get_id(), ':route' => $route, ':status_code' => $status_code, @@ -374,7 +374,7 @@ class API_V1_Log ':general' => $general, ':aspect' => $aspect, ':action' => $action - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/API/V1/Timer.php b/lib/classes/API/V1/Timer.php index 5b5f233b05..f495865762 100644 --- a/lib/classes/API/V1/Timer.php +++ b/lib/classes/API/V1/Timer.php @@ -28,11 +28,11 @@ class API_V1_Timer implements ServiceProviderInterface $n++; $name = $event->getName() . '#' . $n; } - $app['api.timers']->add(array( + $app['api.timers']->add([ 'name' => $name, 'memory' => memory_get_usage(), 'time' => microtime(true) - $app['api.timers.start'], - )); + ]); }; $app['dispatcher']->addListener(KernelEvents::CONTROLLER, $callback, -999999); diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php index bf46002883..5f4ed76e37 100644 --- a/lib/classes/API/V1/adapter.php +++ b/lib/classes/API/V1/adapter.php @@ -119,14 +119,14 @@ class API_V1_adapter extends API_V1_Abstract $date = new \DateTime(); $data = $app['task-manager.live-information']->getManager(); - $result->set_datas(array('scheduler' => array( + $result->set_datas(['scheduler' => [ 'configuration' => $data['configuration'], 'state' => $data['actual'], 'status' => $data['actual'], 'pid' => $data['process-id'], 'process-id' => $data['process-id'], 'updated_on' => $date->format(DATE_ATOM), - ))); + ]]); return $result; } @@ -142,12 +142,12 @@ class API_V1_adapter extends API_V1_Abstract { $result = new \API_V1_result($app, $app['request'], $this); - $ret = array(); + $ret = []; foreach ($app['manipulator.task']->getRepository()->findAll() as $task) { $ret[] = $this->list_task($app, $task); } - $result->set_datas(array('tasks' => $ret)); + $result->set_datas(['tasks' => $ret]); return $result; } @@ -156,7 +156,7 @@ class API_V1_adapter extends API_V1_Abstract { $data = $app['task-manager.live-information']->getTask($task); - return array( + return [ 'id' => $task->getId(), 'title' => $task->getName(), 'name' => $task->getName(), @@ -174,7 +174,7 @@ class API_V1_adapter extends API_V1_Abstract 'auto_start' => $task->getStatus() === Task::STATUS_STARTED, 'crashed' => $task->getCrashed(), 'status' => $task->getStatus(), - ); + ]; } /** @@ -187,7 +187,7 @@ class API_V1_adapter extends API_V1_Abstract public function get_task(Application $app, Task $task) { $result = new \API_V1_result($app, $app['request'], $this); - $ret = array('task' => $this->list_task($app, $task)); + $ret = ['task' => $this->list_task($app, $task)]; $result->set_datas($ret); return $result; @@ -205,7 +205,7 @@ class API_V1_adapter extends API_V1_Abstract $result = new \API_V1_result($app, $app['request'], $this); $app['manipulator.task']->start($task); - $result->set_datas(array('task' => $this->list_task($app, $task))); + $result->set_datas(['task' => $this->list_task($app, $task)]); return $result; } @@ -222,7 +222,7 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($app, $app['request'], $this); $app['manipulator.task']->stop($task); - $result->set_datas(array('task' => $this->list_task($app, $task))); + $result->set_datas(['task' => $this->list_task($app, $task)]); return $result; } @@ -255,7 +255,7 @@ class API_V1_adapter extends API_V1_Abstract $task->setStatus(Task::STATUS_STARTED); } - $result->set_datas(array('task' => $this->list_task($app, $task))); + $result->set_datas(['task' => $this->list_task($app, $task)]); return $result; } @@ -268,23 +268,23 @@ class API_V1_adapter extends API_V1_Abstract */ protected function get_cache_info(Application $app) { - $caches = array( + $caches = [ 'main' => $app['cache'], 'op_code' => $app['opcode-cache'], 'doctrine_metadatas' => $this->app['EM']->getConfiguration()->getMetadataCacheImpl(), 'doctrine_query' => $this->app['EM']->getConfiguration()->getQueryCacheImpl(), 'doctrine_result' => $this->app['EM']->getConfiguration()->getResultCacheImpl(), - ); + ]; - $ret = array(); + $ret = []; foreach ($caches as $name => $service) { if ($service instanceof \Alchemy\Phrasea\Cache\Cache) { - $ret['cache'][$name] = array( + $ret['cache'][$name] = [ 'type' => $service->getName(), 'online' => $service->isOnline(), 'stats' => $service->getStats(), - ); + ]; } else { $ret['cache'][$name] = null; } @@ -301,12 +301,12 @@ class API_V1_adapter extends API_V1_Abstract */ protected function get_config_info(Application $app) { - $ret = array(); + $ret = []; - $ret['phraseanet']['version'] = array( + $ret['phraseanet']['version'] = [ 'name' => $app['phraseanet.version']::getName(), 'number' => $app['phraseanet.version']::getNumber(), - ); + ]; $ret['phraseanet']['environment'] = $app->getEnvironment(); $ret['phraseanet']['debug'] = $app['debug']; @@ -327,99 +327,99 @@ class API_V1_adapter extends API_V1_Abstract try { $SEStatus = $app['phraseanet.SE']->getStatus(); } catch (\RuntimeException $e) { - $SEStatus = array('error' => $e->getMessage()); + $SEStatus = ['error' => $e->getMessage()]; } $binaries = $app['configuration']['binaries']; - return array( - 'global_values' => array( + return [ + 'global_values' => [ 'serverName' => $app['phraseanet.registry']->get('GV_ServerName'), 'title' => $app['phraseanet.registry']->get('GV_homeTitle'), 'keywords' => $app['phraseanet.registry']->get('GV_metaKeywords'), 'description' => $app['phraseanet.registry']->get('GV_metaDescription'), - 'httpServer' => array( + 'httpServer' => [ 'logErrors' => $app['phraseanet.registry']->get('GV_log_errors'), 'phpTimezone' => ini_get('date.timezone'), 'siteId' => $app['configuration']['main']['key'], 'staticUrl' => $app['phraseanet.registry']->get('GV_STATIC_URL'), 'defaultLanguage' => $app['phraseanet.registry']->get('id_GV_default_lng'), 'allowIndexing' => $app['phraseanet.registry']->get('GV_allow_search_engine'), - 'modes' => array( + 'modes' => [ 'XsendFile' => $app['configuration']['xsendfile']['enabled'], 'XsendFileMapping' => $app['configuration']['xsendfile']['mapping'], 'h264Streaming' => $app['phraseanet.registry']->get('GV_h264_streaming'), 'authTokenDirectory' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory'), 'authTokenDirectoryPath' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory_path'), 'authTokenPassphrase' => $app['phraseanet.registry']->get('GV_mod_auth_token_passphrase'), - ) - ), - 'maintenance' => array( + ] + ], + 'maintenance' => [ 'alertMessage' => $app['phraseanet.registry']->get('GV_message'), 'displayMessage' => $app['phraseanet.registry']->get('GV_message_on'), - ), - 'webServices' => array( + ], + 'webServices' => [ 'googleApi' => $app['phraseanet.registry']->get('GV_google_api'), 'googleAnalyticsId' => $app['phraseanet.registry']->get('GV_googleAnalytics'), 'i18nWebService' => $app['phraseanet.registry']->get('GV_i18n_service'), - 'recaptacha' => array( + 'recaptacha' => [ 'active' => $app['phraseanet.registry']->get('GV_captchas'), 'publicKey' => $app['phraseanet.registry']->get('GV_captcha_public_key'), 'privateKey' => $app['phraseanet.registry']->get('GV_captcha_private_key'), - ), - 'youtube' => array( + ], + 'youtube' => [ 'active' => $app['phraseanet.registry']->get('GV_youtube_api'), 'clientId' => $app['phraseanet.registry']->get('GV_youtube_client_id'), 'clientSecret' => $app['phraseanet.registry']->get('GV_youtube_client_secret'), 'devKey' => $app['phraseanet.registry']->get('GV_youtube_dev_key'), - ), - 'flickr' => array( + ], + 'flickr' => [ 'active' => $app['phraseanet.registry']->get('GV_flickr_api'), 'clientId' => $app['phraseanet.registry']->get('GV_flickr_client_id'), 'clientSecret' => $app['phraseanet.registry']->get('GV_flickr_client_secret'), - ), - 'dailymtotion' => array( + ], + 'dailymtotion' => [ 'active' => $app['phraseanet.registry']->get('GV_dailymotion_api'), 'clientId' => $app['phraseanet.registry']->get('GV_dailymotion_client_id'), 'clientSecret' => $app['phraseanet.registry']->get('GV_dailymotion_client_secret'), - ) - ), - 'navigator' => array( + ] + ], + 'navigator' => [ 'active' => $app['phraseanet.registry']->get('GV_client_navigator'), - ), - 'office-plugin' => array( + ], + 'office-plugin' => [ 'active' => $app['phraseanet.registry']->get('GV_client_navigator'), - ), - 'homepage' => array( + ], + 'homepage' => [ 'viewType' => $app['phraseanet.registry']->get('GV_home_publi'), - ), - 'report' => array( + ], + 'report' => [ 'anonymous' => $app['phraseanet.registry']->get('GV_anonymousReport'), - ), - 'events' => array( + ], + 'events' => [ 'events' => $app['phraseanet.registry']->get('GV_events'), 'notifications' => $app['phraseanet.registry']->get('GV_notifications'), - ), - 'upload' => array( + ], + 'upload' => [ 'allowedFileExtension' => $app['phraseanet.registry']->get('GV_appletAllowedFileEx'), - ), - 'filesystem' => array( + ], + 'filesystem' => [ 'noWeb' => $app['phraseanet.registry']->get('GV_base_datapath_noweb'), - ), - 'searchEngine' => array( - 'configuration' => array( + ], + 'searchEngine' => [ + 'configuration' => [ 'defaultQuery' => $app['phraseanet.registry']->get('GV_defaultQuery'), 'defaultQueryType' => $app['phraseanet.registry']->get('GV_defaultQuery_type'), 'minChar' => $app['phraseanet.registry']->get('GV_min_letters_truncation'), 'sort' => $app['phraseanet.registry']->get('GV_phrasea_sort'), - ), - 'engine' => array( + ], + 'engine' => [ 'type' => $app['phraseanet.SE']->getName(), 'status' => $SEStatus, 'configuration' => $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration(), - ), - ), - 'binary' => array( + ], + ], + 'binary' => [ 'phpCli' => isset($binaries['php_binary']) ? $binaries['php_binary'] : null, 'phpIni' => $app['phraseanet.registry']->get('GV_PHP_INI'), 'swfExtract' => isset($binaries['swf_extract_binary']) ? $binaries['swf_extract_binary'] : null, @@ -431,21 +431,21 @@ class API_V1_adapter extends API_V1_Abstract 'mp4box' => isset($binaries['mp4box_binary']) ? $binaries['mp4box_binary'] : null, 'pdftotext' => isset($binaries['pdftotext_binary']) ? $binaries['pdftotext_binary'] : null, 'recess' => isset($binaries['recess_binary']) ? $binaries['recess_binary'] : null, - 'pdfmaxpages' => $app['phraseanet.registry']->get('GV_pdfmaxpages'),), - 'mainConfiguration' => array( + 'pdfmaxpages' => $app['phraseanet.registry']->get('GV_pdfmaxpages'),], + 'mainConfiguration' => [ 'adminMail' => $app['phraseanet.registry']->get('GV_adminMail'), 'viewBasAndCollName' => $app['phraseanet.registry']->get('GV_view_bas_and_coll'), 'chooseExportTitle' => $app['phraseanet.registry']->get('GV_choose_export_title'), 'defaultExportTitle' => $app['phraseanet.registry']->get('GV_default_export_title'), - 'socialTools' => $app['phraseanet.registry']->get('GV_social_tools'),), - 'modules' => array( + 'socialTools' => $app['phraseanet.registry']->get('GV_social_tools'),], + 'modules' => [ 'thesaurus' => $app['phraseanet.registry']->get('GV_thesaurus'), 'storyMode' => $app['phraseanet.registry']->get('GV_multiAndReport'), 'docSubsitution' => $app['phraseanet.registry']->get('GV_seeOngChgDoc'), - 'subdefSubstitution' => $app['phraseanet.registry']->get('GV_seeNewThumb'),), - 'email' => array( + 'subdefSubstitution' => $app['phraseanet.registry']->get('GV_seeNewThumb'),], + 'email' => [ 'defaultMailAddress' => $app['phraseanet.registry']->get('GV_defaulmailsenderaddr'), - 'smtp' => array( + 'smtp' => [ 'active' => $app['phraseanet.registry']->get('GV_smtp'), 'auth' => $app['phraseanet.registry']->get('GV_smtp_auth'), 'host' => $app['phraseanet.registry']->get('GV_smtp_host'), @@ -453,12 +453,12 @@ class API_V1_adapter extends API_V1_Abstract 'secure' => $app['phraseanet.registry']->get('GV_smtp_secure'), 'user' => $app['phraseanet.registry']->get('GV_smtp_user'), 'password' => $app['phraseanet.registry']->get('GV_smtp_password'), - ), - ), - 'ftp' => array( + ], + ], + 'ftp' => [ 'active' => $app['phraseanet.registry']->get('GV_activeFTP'), - 'activeForUser' => $app['phraseanet.registry']->get('GV_ftp_for_user'),), - 'client' => array( + 'activeForUser' => $app['phraseanet.registry']->get('GV_ftp_for_user'),], + 'client' => [ 'maxSizeDownload' => $app['phraseanet.registry']->get('GV_download_max'), 'tabSearchMode' => $app['phraseanet.registry']->get('GV_ong_search'), 'tabAdvSearchPosition' => $app['phraseanet.registry']->get('GV_ong_advsearch'), @@ -470,17 +470,17 @@ class API_V1_adapter extends API_V1_Abstract 'collRenderMode' => $app['phraseanet.registry']->get('GV_client_coll_ckbox'), 'viewSizeBaket' => $app['phraseanet.registry']->get('GV_viewSizeBaket'), 'clientAutoShowProposals' => $app['phraseanet.registry']->get('GV_clientAutoShowProposals'), - 'needAuth2DL' => $app['phraseanet.registry']->get('GV_needAuth2DL'),), - 'inscription' => array( + 'needAuth2DL' => $app['phraseanet.registry']->get('GV_needAuth2DL'),], + 'inscription' => [ 'autoSelectDB' => $app['phraseanet.registry']->get('GV_autoselectDB'), 'autoRegister' => $app['phraseanet.registry']->get('GV_autoregister'), - ), - 'push' => array( + ], + 'push' => [ 'validationReminder' => $app['phraseanet.registry']->get('GV_validation_reminder'), 'expirationValue' => $app['phraseanet.registry']->get('GV_val_expiration'), - ), - ) - ); + ], + ] + ]; } /** @@ -516,7 +516,7 @@ class API_V1_adapter extends API_V1_Abstract { $result = new API_V1_result($this->app, $request, $this); - $result->set_datas(array("databoxes" => $this->list_databoxes())); + $result->set_datas(["databoxes" => $this->list_databoxes()]); return $result; } @@ -534,11 +534,11 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "collections" => $this->list_databox_collections( $this->app['phraseanet.appbox']->get_databox($databox_id) ) - ) + ] ); return $result; @@ -557,12 +557,12 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "status" => $this->list_databox_status( $this->app['phraseanet.appbox']->get_databox($databox_id)->get_statusbits() ) - ) + ] ); return $result; @@ -581,13 +581,13 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "document_metadatas" => $this->list_databox_metadatas_fields( $this->app['phraseanet.appbox']->get_databox($databox_id) ->get_meta_structure() ) - ) + ] ); return $result; @@ -606,10 +606,10 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "termsOfUse" => $this->list_databox_terms($this->app['phraseanet.appbox']->get_databox($databox_id)) - ) + ] ); return $result; @@ -622,14 +622,14 @@ class API_V1_adapter extends API_V1_Abstract $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); $fields = $record->get_caption()->get_fields(); - $ret = array('caption_metadatas' => array()); + $ret = ['caption_metadatas' => []]; foreach ($fields as $field) { - $ret['caption_metadatas'][] = array( + $ret['caption_metadatas'][] = [ 'meta_structure_id' => $field->get_meta_struct_id(), 'name' => $field->get_name(), 'value' => $field->get_serialized_values(";"), - ); + ]; } $result->set_datas($ret); @@ -682,7 +682,7 @@ class API_V1_adapter extends API_V1_Abstract $callback = function ($element, $visa, $code) use (&$reasons, &$output) { if (!$visa->isValid()) { - $reasons = array(); + $reasons = []; foreach ($visa->getResponses() as $response) { $reasons[] = $response->getMessage(); @@ -709,9 +709,9 @@ class API_V1_adapter extends API_V1_Abstract $app['border-manager']->process($session, $Package, $callback, $behavior); - $ret = array( + $ret = [ 'entity' => null, - ); + ]; if ($output instanceof \record_adapter) { $ret['entity'] = '0'; @@ -735,9 +735,9 @@ class API_V1_adapter extends API_V1_Abstract $offset_start = max($request->get('offset_start', 0), 0); $per_page = min(max($request->get('per_page', 10), 1), 20); - $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('canaddrecord'))); + $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canaddrecord'])); - $lazaretFiles = array(); + $lazaretFiles = []; if (count($baseIds) > 0) { $lazaretRepository = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\LazaretFile'); @@ -747,7 +747,7 @@ class API_V1_adapter extends API_V1_Abstract ); } - $ret = array(); + $ret = []; foreach ($lazaretFiles as $lazaretFile) { $ret[] = $this->list_lazaret_file($lazaretFile); @@ -755,11 +755,11 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); - $result->set_datas(array( + $result->set_datas([ 'offset_start' => $offset_start, 'per_page' => $per_page, 'quarantine_items' => $ret, - )); + ]); return $result; } @@ -777,7 +777,7 @@ class API_V1_adapter extends API_V1_Abstract throw new \API_V1_exception_forbidden('You do not have access to this quarantine item'); } - $ret = array('quarantine_item' => $this->list_lazaret_file($lazaretFile)); + $ret = ['quarantine_item' => $this->list_lazaret_file($lazaretFile)]; $result = new API_V1_result($this->app, $request, $this); @@ -788,7 +788,7 @@ class API_V1_adapter extends API_V1_Abstract protected function list_lazaret_file(LazaretFile $file) { - $checks = array(); + $checks = []; if ($file->getChecks()) { foreach ($file->getChecks() as $checker) { @@ -802,12 +802,12 @@ class API_V1_adapter extends API_V1_Abstract $usr_id = $file->getSession()->getUser($this->app)->get_id(); } - $session = array( + $session = [ 'id' => $file->getSession()->getId(), 'usr_id' => $usr_id, - ); + ]; - return array( + return [ 'id' => $file->getId(), 'quarantine_session' => $session, 'base_id' => $file->getBaseId(), @@ -815,10 +815,10 @@ class API_V1_adapter extends API_V1_Abstract 'sha256' => $file->getSha256(), 'uuid' => $file->getUuid(), 'forced' => $file->getForced(), - 'checks' => $file->getForced() ? array() : $checks, + 'checks' => $file->getForced() ? [] : $checks, 'created_on' => $file->getCreated()->format(DATE_ATOM), 'updated_on' => $file->getUpdated()->format(DATE_ATOM), - ); + ]; } /** @@ -833,7 +833,7 @@ class API_V1_adapter extends API_V1_Abstract list($ret, $search_result) = $this->prepare_search_request($request); - $ret['results'] = array('records' => array(), 'stories' => array()); + $ret['results'] = ['records' => [], 'stories' => []]; foreach ($search_result->getResults() as $record) { if ($record->is_grouping()) { @@ -909,7 +909,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['phraseanet.SE.logger']->log($databox, $search_result->getQuery(), $search_result->getTotal(), $colls); } - $ret = array( + $ret = [ 'offset_start' => $offsetStart, 'per_page' => $perPage, 'available_results' => $search_result->getAvailable(), @@ -921,11 +921,11 @@ class API_V1_adapter extends API_V1_Abstract 'suggestions' => array_map(function (SearchEngineSuggestion $suggestion) { return $suggestion->toArray(); }, $search_result->getSuggestions()->toArray()), - 'results' => array(), + 'results' => [], 'query' => $search_result->getQuery(), - ); + ]; - return array($ret, $search_result); + return [$ret, $search_result]; } /** @@ -956,10 +956,10 @@ class API_V1_adapter extends API_V1_Abstract return $that->list_story($story); }, array_values($record->get_grouping_parents()->get_elements())); - $result->set_datas(array( + $result->set_datas([ "baskets" => $baskets, "stories" => $stories, - )); + ]); return $result; } @@ -980,9 +980,9 @@ class API_V1_adapter extends API_V1_Abstract $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); $result->set_datas( - array( + [ "record_metadatas" => $this->list_record_caption($record->get_caption()) - ) + ] ); return $result; @@ -1006,13 +1006,13 @@ class API_V1_adapter extends API_V1_Abstract ->get_record($record_id); $result->set_datas( - array( + [ "status" => $this->list_record_status( $this->app['phraseanet.appbox']->get_databox($databox_id) , $record->get_status() ) - ) + ] ); return $result; @@ -1034,16 +1034,16 @@ class API_V1_adapter extends API_V1_Abstract $record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id); - $ret = array(); + $ret = []; - $devices = $request->get('devices', array()); - $mimes = $request->get('mimes', array()); + $devices = $request->get('devices', []); + $mimes = $request->get('mimes', []); foreach ($record->get_embedable_medias($devices, $mimes) as $name => $media) { $ret[] = $this->list_embedable_media($media, $this->app['phraseanet.registry']); } - $result->set_datas(array("embed" => $ret)); + $result->set_datas(["embed" => $ret]); return $result; } @@ -1066,16 +1066,16 @@ class API_V1_adapter extends API_V1_Abstract ->get_databox($databox_id) ->get_record($record_id); - $ret = array(); + $ret = []; - $devices = $request->get('devices', array()); - $mimes = $request->get('mimes', array()); + $devices = $request->get('devices', []); + $mimes = $request->get('mimes', []); foreach ($record->get_embedable_medias($devices, $mimes) as $name => $media) { $ret[] = $this->list_embedable_media($media, $this->app['phraseanet.registry']); } - $result->set_datas(array("embed" => $ret)); + $result->set_datas(["embed" => $ret]); return $result; } @@ -1099,7 +1099,7 @@ class API_V1_adapter extends API_V1_Abstract } $record->set_metadatas($metadatas); - $result->set_datas(array("record_metadatas" => $this->list_record_caption($record->get_caption()))); + $result->set_datas(["record_metadatas" => $this->list_record_caption($record->get_caption())]); } catch (Exception $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); } @@ -1126,7 +1126,7 @@ class API_V1_adapter extends API_V1_Abstract if ($n > 31 || $n < 4) { throw new API_V1_exception_badrequest(); } - if (!in_array($value, array('0', '1'))) { + if (!in_array($value, ['0', '1'])) { throw new API_V1_exception_badrequest(); } if (!isset($status_bits[$n])) { @@ -1141,10 +1141,10 @@ class API_V1_adapter extends API_V1_Abstract $this->app['phraseanet.SE']->updateRecord($record); - $result->set_datas(array( + $result->set_datas([ "status" => $this->list_record_status($databox, $record->get_status()) - ) + ] ); } catch (Exception $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('An error occured')); @@ -1171,7 +1171,7 @@ class API_V1_adapter extends API_V1_Abstract $collection = collection::get_from_base_id($this->app, $request->get('base_id')); $record->move_to_collection($collection, $this->app['phraseanet.appbox']); - $result->set_datas(array("record" => $this->list_record($record))); + $result->set_datas(["record" => $this->list_record($record)]); } catch (Exception $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $e->getMessage()); } @@ -1193,7 +1193,7 @@ class API_V1_adapter extends API_V1_Abstract $databox = $this->app['phraseanet.appbox']->get_databox($databox_id); try { $record = $databox->get_record($record_id); - $result->set_datas(array('record' => $this->list_record($record))); + $result->set_datas(['record' => $this->list_record($record)]); } catch (NotFoundHttpException $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Record Not Found')); } catch (Exception $e) { @@ -1217,7 +1217,7 @@ class API_V1_adapter extends API_V1_Abstract $databox = $this->app['phraseanet.appbox']->get_databox($databox_id); try { $story = $databox->get_record($story_id); - $result->set_datas(array('story' => $this->list_story($story))); + $result->set_datas(['story' => $this->list_story($story)]); } catch (NotFoundHttpException $e) { $result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, _('Story Not Found')); } catch (Exception $e) { @@ -1239,7 +1239,7 @@ class API_V1_adapter extends API_V1_Abstract $usr_id = $this->app['authentication']->getUser()->get_id(); - $result->set_datas(array('baskets' => $this->list_baskets($usr_id))); + $result->set_datas(['baskets' => $this->list_baskets($usr_id)]); return $result; } @@ -1257,7 +1257,7 @@ class API_V1_adapter extends API_V1_Abstract $baskets = $repo->findActiveByUser($this->app['authentication']->getUser()); - $ret = array(); + $ret = []; foreach ($baskets as $basket) { $ret[] = $this->list_basket($basket); } @@ -1288,7 +1288,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['EM']->persist($Basket); $this->app['EM']->flush(); - $result->set_datas(array("basket" => $this->list_basket($Basket))); + $result->set_datas(["basket" => $this->list_basket($Basket)]); return $result; } @@ -1320,10 +1320,10 @@ class API_V1_adapter extends API_V1_Abstract $result = new API_V1_result($this->app, $request, $this); $result->set_datas( - array( + [ "basket" => $this->list_basket($basket), "basket_elements" => $this->list_basket_content($basket) - ) + ] ); return $result; @@ -1337,7 +1337,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_basket_content(Basket $Basket) { - $ret = array(); + $ret = []; foreach ($Basket->getElements() as $basket_element) { $ret[] = $this->list_basket_element($basket_element); @@ -1354,15 +1354,15 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_basket_element(BasketElement $basket_element) { - $ret = array( + $ret = [ 'basket_element_id' => $basket_element->getId(), 'order' => $basket_element->getOrd(), 'record' => $this->list_record($basket_element->getRecord($this->app)), 'validation_item' => null != $basket_element->getBasket()->getValidation(), - ); + ]; if ($basket_element->getBasket()->getValidation()) { - $choices = array(); + $choices = []; $agreement = null; $note = ''; @@ -1370,19 +1370,19 @@ class API_V1_adapter extends API_V1_Abstract $participant = $validation_datas->getParticipant(); $user = $participant->getUser($this->app); /* @var $validation_datas Alchemy\Phrasea\Model\Entities\ValidationData */ - $choices[] = array( - 'validation_user' => array( + $choices[] = [ + 'validation_user' => [ 'usr_id' => $user->get_id(), 'usr_name' => $user->get_display_name(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(), - ), + ], 'agreement' => $validation_datas->getAgreement(), 'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM), 'note' => null === $validation_datas->getNote() ? '' : $validation_datas->getNote(), - ); + ]; if ($user->get_id() == $this->app['authentication']->getUser()->get_id()) { $agreement = $validation_datas->getAgreement(); @@ -1415,7 +1415,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['EM']->persist($basket); $this->app['EM']->flush(); - $result->set_datas(array("basket" => $this->list_basket($basket))); + $result->set_datas(["basket" => $this->list_basket($basket)]); return $result; } @@ -1436,7 +1436,7 @@ class API_V1_adapter extends API_V1_Abstract $this->app['EM']->persist($basket); $this->app['EM']->flush(); - $result->set_datas(array("basket" => $this->list_basket($basket))); + $result->set_datas(["basket" => $this->list_basket($basket)]); return $result; } @@ -1454,12 +1454,12 @@ class API_V1_adapter extends API_V1_Abstract $coll = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($this->app['acl']->get($user)); - $datas = array(); + $datas = []; foreach ($coll as $feed) { $datas[] = $this->list_publication($feed, $user); } - $result->set_datas(array("feeds" => $datas)); + $result->set_datas(["feeds" => $datas]); return $result; } @@ -1487,19 +1487,19 @@ class API_V1_adapter extends API_V1_Abstract $feed = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->find($publication_id); if (!$feed->isAccessible($user, $this->app)) { - return $result->set_datas(array()); + return $result->set_datas([]); } $offset_start = (int) ($request->get('offset_start') ? : 0); $per_page = (int) ($request->get('per_page') ? : 5); $per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5; - $datas = array( + $datas = [ 'feed' => $this->list_publication($feed, $user), 'offset_start' => $offset_start, 'per_page' => $per_page, 'entries' => $this->list_publications_entries($feed, $offset_start, $per_page), - ); + ]; $result->set_datas($datas); @@ -1517,12 +1517,12 @@ class API_V1_adapter extends API_V1_Abstract $per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5; - $datas = array( + $datas = [ 'total_entries' => $feed->getCountTotalEntries(), 'offset_start' => $offset_start, 'per_page' => $per_page, 'entries' => $this->list_publications_entries($feed, $offset_start, $per_page), - ); + ]; $result->set_datas($datas); @@ -1541,9 +1541,9 @@ class API_V1_adapter extends API_V1_Abstract throw new \API_V1_exception_forbidden('You have not access to the parent feed'); } - $datas = array( + $datas = [ 'entry' => $this->list_publication_entry($entry), - ); + ]; $result->set_datas($datas); @@ -1559,7 +1559,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_publication(Feed $feed, $user) { - return array( + return [ 'id' => $feed->getId(), 'title' => $feed->getTitle(), 'subtitle' => $feed->getSubtitle(), @@ -1570,7 +1570,7 @@ class API_V1_adapter extends API_V1_Abstract 'deletable' => $feed->isOwner($user), 'created_on' => $feed->getCreatedOn()->format(DATE_ATOM), 'updated_on' => $feed->getUpdatedOn()->format(DATE_ATOM), - ); + ]; } /** @@ -1586,7 +1586,7 @@ class API_V1_adapter extends API_V1_Abstract $entries = $feed->getEntries($offset_start, $how_many); - $out = array(); + $out = []; foreach ($entries as $entry) { $out[] = $this->list_publication_entry($entry); } @@ -1602,12 +1602,12 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_publication_entry(FeedEntry $entry) { - $items = array(); + $items = []; foreach ($entry->getItems() as $item) { $items[] = $this->list_publication_entry_item($item); } - return array( + return [ 'id' => $entry->getId(), 'author_email' => $entry->getAuthorEmail(), 'author_name' => $entry->getAuthorName(), @@ -1619,7 +1619,7 @@ class API_V1_adapter extends API_V1_Abstract 'feed_id' => $entry->getFeed()->getId(), 'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/', 'url' => '/feeds/entry/' . $entry->getId() . '/', - ); + ]; } /** @@ -1630,10 +1630,10 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_publication_entry_item(FeedItem $item) { - $datas = array( + $datas = [ 'item_id' => $item->getId() , 'record' => $this->list_record($item->getRecord($this->app)) - ); + ]; return $datas; } @@ -1683,7 +1683,7 @@ class API_V1_adapter extends API_V1_Abstract $permalink = null; } - return array( + return [ 'name' => $media->get_name(), 'permalink' => $permalink, 'height' => $media->get_height(), @@ -1692,7 +1692,7 @@ class API_V1_adapter extends API_V1_Abstract 'devices' => $media->getDevices(), 'player_type' => $media->get_type(), 'mime_type' => $media->get_mime(), - ); + ]; } /** @@ -1704,7 +1704,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_permalink(media_Permalink_Adapter $permalink, registryInterface $registry) { - return array( + return [ 'created_on' => $permalink->get_created_on()->format(DATE_ATOM), 'id' => $permalink->get_id(), 'is_activated' => $permalink->get_is_activated(), @@ -1713,7 +1713,7 @@ class API_V1_adapter extends API_V1_Abstract 'page_url' => $permalink->get_page(), 'download_url' => $permalink->get_url() . '&download', 'url' => $permalink->get_url() - ); + ]; } /** @@ -1726,9 +1726,9 @@ class API_V1_adapter extends API_V1_Abstract protected function list_record_status(databox $databox, $status) { $status = strrev($status); - $ret = array(); + $ret = []; foreach ($databox->get_statusbits() as $bit => $status_datas) { - $ret[] = array('bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1)); + $ret[] = ['bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1)]; } return $ret; @@ -1742,7 +1742,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_record_caption(caption_record $caption) { - $ret = array(); + $ret = []; foreach ($caption->get_fields() as $field) { foreach ($field->get_values() as $value) { $ret[] = $this->list_record_caption_field($value, $field); @@ -1760,18 +1760,18 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_record_caption_field(caption_Field_Value $value, caption_field $field) { - return array( + return [ 'meta_id' => $value->getId(), 'meta_structure_id' => $field->get_meta_struct_id(), 'name' => $field->get_name(), - 'labels' => array( + 'labels' => [ 'fr' => $field->get_databox_field()->get_label('fr'), 'en' => $field->get_databox_field()->get_label('en'), 'de' => $field->get_databox_field()->get_label('de'), 'nl' => $field->get_databox_field()->get_label('nl'), - ), + ], 'value' => $value->getValue(), - ); + ]; } /** @@ -1782,7 +1782,7 @@ class API_V1_adapter extends API_V1_Abstract */ public function list_basket(Basket $basket) { - $ret = array( + $ret = [ 'basket_id' => $basket->getId(), 'created_on' => $basket->getCreated()->format(DATE_ATOM), 'description' => (string) $basket->getDescription(), @@ -1791,23 +1791,23 @@ class API_V1_adapter extends API_V1_Abstract 'updated_on' => $basket->getUpdated()->format(DATE_ATOM), 'unread' => !$basket->getIsRead(), 'validation_basket' => !!$basket->getValidation() - ); + ]; if ($basket->getValidation()) { - $users = array(); + $users = []; foreach ($basket->getValidation()->getParticipants() as $participant) { /* @var $participant ValidationParticipant */ $user = $participant->getUser($this->app); - $users[] = array( + $users[] = [ 'usr_id' => $user->get_id(), 'usr_name' => $user->get_display_name(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(), - ); + ]; } $expires_on_atom = $basket->getValidation()->getExpires(); @@ -1817,13 +1817,13 @@ class API_V1_adapter extends API_V1_Abstract } $ret = array_merge( - array( + [ 'validation_users' => $users, 'expires_on' => $expires_on_atom, 'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()), 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser(), $this->app)->getIsConfirmed(), 'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser()), - ), $ret + ], $ret ); } @@ -1838,15 +1838,15 @@ class API_V1_adapter extends API_V1_Abstract */ public function list_record(record_adapter $record) { - $technicalInformation = array(); + $technicalInformation = []; foreach ($record->get_technical_infos() as $name => $value) { - $technicalInformation[] = array( + $technicalInformation[] = [ 'name' => $name, 'value' => $value - ); + ]; } - return array( + return [ 'databox_id' => $record->get_sbas_id(), 'record_id' => $record->get_record_id(), 'mime_type' => $record->get_mime(), @@ -1860,7 +1860,7 @@ class API_V1_adapter extends API_V1_Abstract 'technical_informations' => $technicalInformation, 'phrasea_type' => $record->get_type(), 'uuid' => $record->get_uuid(), - ); + ]; } /** @@ -1894,7 +1894,7 @@ class API_V1_adapter extends API_V1_Abstract return $field->get_serialized_values(); }; - return array( + return [ '@entity@' => self::OBJECT_TYPE_STORY, 'databox_id' => $story->get_sbas_id(), 'story_id' => $story->get_record_id(), @@ -1903,7 +1903,7 @@ class API_V1_adapter extends API_V1_Abstract 'collection_id' => phrasea::collFromBas($this->app, $story->get_base_id()), 'thumbnail' => $this->list_embedable_media($story->get_thumbnail(), $this->app['phraseanet.registry']), 'uuid' => $story->get_uuid(), - 'metadatas' => array( + 'metadatas' => [ '@entity@' => self::OBJECT_TYPE_STORY_METADATA_BAG, 'dc:contributor' => $format($caption, databox_Field_DCESAbstract::Contributor), 'dc:coverage' => $format($caption, databox_Field_DCESAbstract::Coverage), @@ -1920,9 +1920,9 @@ class API_V1_adapter extends API_V1_Abstract 'dc:subject' => $format($caption, databox_Field_DCESAbstract::Subject), 'dc:title' => $format($caption, databox_Field_DCESAbstract::Title), 'dc:type' => $format($caption, databox_Field_DCESAbstract::Type), - ), + ], 'records' => $records, - ); + ]; } /** @@ -1932,7 +1932,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databoxes() { - $ret = array(); + $ret = []; foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) { $ret[] = $this->list_databox($databox); } @@ -1948,9 +1948,9 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_terms(databox $databox) { - $ret = array(); + $ret = []; foreach ($databox->get_cgus() as $locale => $array_terms) { - $ret[] = array('locale' => $locale, 'terms' => $array_terms['value']); + $ret[] = ['locale' => $locale, 'terms' => $array_terms['value']]; } return $ret; @@ -1963,17 +1963,17 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox(databox $databox) { - $ret = array(); + $ret = []; $ret['databox_id'] = $databox->get_sbas_id(); $ret['name'] = $databox->get_dbname(); $ret['viewname'] = $databox->get_viewname(); - $ret['labels'] = array( + $ret['labels'] = [ 'en' => $databox->get_label('en'), 'de' => $databox->get_label('de'), 'fr' => $databox->get_label('fr'), 'nl' => $databox->get_label('nl'), - ); + ]; $ret['version'] = $databox->get_version(); return $ret; @@ -1987,7 +1987,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_collections(databox $databox) { - $ret = array(); + $ret = []; foreach ($databox->get_collections() as $collection) { $ret[] = $this->list_collection($collection); @@ -2004,18 +2004,18 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_collection(collection $collection) { - $ret = array( + $ret = [ 'base_id' => $collection->get_base_id(), 'collection_id' => $collection->get_coll_id(), 'name' => $collection->get_name(), - 'labels' => array( + 'labels' => [ 'fr' => $collection->get_label('fr'), 'en' => $collection->get_label('en'), 'de' => $collection->get_label('de'), 'nl' => $collection->get_label('nl'), - ), + ], 'record_amount' => $collection->get_record_amount(), - ); + ]; return $ret; } @@ -2028,23 +2028,23 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_status(array $status) { - $ret = array(); + $ret = []; foreach ($status as $n => $datas) { - $ret[] = array( + $ret[] = [ 'bit' => $n, 'label_on' => $datas['labelon'], 'label_off' => $datas['labeloff'], - 'labels' => array( + 'labels' => [ 'en' => $datas['labels_on_i18n']['en'], 'fr' => $datas['labels_on_i18n']['fr'], 'de' => $datas['labels_on_i18n']['de'], 'nl' => $datas['labels_on_i18n']['nl'], - ), + ], 'img_on' => $datas['img_on'], 'img_off' => $datas['img_off'], 'searchable' => !!$datas['searchable'], 'printable' => !!$datas['printable'], - ); + ]; } return $ret; @@ -2058,7 +2058,7 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_metadatas_fields(databox_descriptionStructure $meta_struct) { - $ret = array(); + $ret = []; foreach ($meta_struct as $meta) { $ret[] = $this->list_databox_metadata_field_properties($meta); } @@ -2074,18 +2074,18 @@ class API_V1_adapter extends API_V1_Abstract */ protected function list_databox_metadata_field_properties(databox_field $databox_field) { - $ret = array( + $ret = [ 'id' => $databox_field->get_id(), 'namespace' => $databox_field->get_tag()->getGroupName(), 'source' => $databox_field->get_tag()->getTagname(), 'tagname' => $databox_field->get_tag()->getName(), 'name' => $databox_field->get_name(), - 'labels' => array( + 'labels' => [ 'fr' => $databox_field->get_label('fr'), 'en' => $databox_field->get_label('en'), 'de' => $databox_field->get_label('de'), 'nl' => $databox_field->get_label('nl'), - ), + ], 'separator' => $databox_field->get_separator(), 'thesaurus_branch' => $databox_field->get_tbranch(), 'type' => $databox_field->get_type(), @@ -2093,7 +2093,7 @@ class API_V1_adapter extends API_V1_Abstract 'multivalue' => $databox_field->is_multi(), 'readonly' => $databox_field->is_readonly(), 'required' => $databox_field->is_required(), - ); + ]; return $ret; } diff --git a/lib/classes/API/V1/result.php b/lib/classes/API/V1/result.php index 8307bad6af..17725ed1a9 100644 --- a/lib/classes/API/V1/result.php +++ b/lib/classes/API/V1/result.php @@ -124,7 +124,7 @@ class API_V1_result } $accept = $this->request->getAcceptableContentTypes(); - $response_types = array(); + $response_types = []; foreach ($accept as $key => $app_type) { $response_types[strtolower($app_type)] = true; @@ -183,8 +183,8 @@ class API_V1_result . $this->request->getPathInfo() ); - $ret = array( - 'meta' => array( + $ret = [ + 'meta' => [ 'api_version' => $this->api_version , 'request' => $request_uri , 'response_time' => $this->response_time @@ -193,9 +193,9 @@ class API_V1_result , 'error_message' => $this->error_message , 'error_details' => $this->error_details , 'charset' => 'UTF-8' - ) + ] , 'response' => $this->response - ); + ]; $this->app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent()); @@ -214,7 +214,7 @@ class API_V1_result break; case self::FORMAT_YAML: if ($ret['response'] instanceof stdClass) - $ret['response'] = array(); + $ret['response'] = []; $dumper = new Symfony\Component\Yaml\Dumper(); $return_value = $dumper->dump($ret, 8); @@ -388,7 +388,7 @@ class API_V1_result $response = new Response( $this->format(), $this->get_http_code(), - array('Content-Type' => $this->get_content_type()) + ['Content-Type' => $this->get_content_type()] ); $response->setCharset('UTF-8'); diff --git a/lib/classes/Bridge/Account.php b/lib/classes/Bridge/Account.php index ac97c72cd6..d1ac26d6ce 100644 --- a/lib/classes/Bridge/Account.php +++ b/lib/classes/Bridge/Account.php @@ -92,7 +92,7 @@ class Bridge_Account FROM bridge_accounts WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -196,11 +196,11 @@ class Bridge_Account $sql = 'UPDATE bridge_accounts SET name = :name, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':name' => $this->name , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -225,7 +225,7 @@ class Bridge_Account $sql = 'DELETE FROM bridge_accounts WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); return; @@ -242,7 +242,7 @@ class Bridge_Account $sql = 'SELECT id, api_id FROM bridge_accounts WHERE id = :account_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $account_id)); + $stmt->execute([':account_id' => $account_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -268,11 +268,11 @@ class Bridge_Account $sql = 'SELECT id FROM bridge_accounts WHERE api_id = :api_id AND usr_id = :usr_id AND dist_id = :dist_id'; - $params = array( + $params = [ ':api_id' => $api->get_id() , ':usr_id' => $user->get_id() , ':dist_id' => $distant_id - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -298,11 +298,11 @@ class Bridge_Account LIMIT 0,' . (int) $quantity; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':api_id' => $api->get_id())); + $stmt->execute([':api_id' => $api->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); + $results = []; foreach ($rs as $row) { $results[] = new Bridge_Account($app, $api, $row['id']); @@ -322,12 +322,12 @@ class Bridge_Account $sql = 'SELECT id, api_id FROM bridge_accounts WHERE usr_id = :usr_id'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); - $apis = array(); + $results = []; + $apis = []; foreach ($rs as $row) { $api_id = $row['api_id']; @@ -360,12 +360,12 @@ class Bridge_Account (id, api_id, dist_id, usr_id, name, created_on, updated_on) VALUES (null, :api_id, :dist_id, :usr_id, :name, NOW(), NOW())'; - $params = array( + $params = [ ':api_id' => $api->get_id() , ':dist_id' => $dist_id , ':usr_id' => $user->get_id() , ':name' => $name - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Bridge/AccountSettings.php b/lib/classes/Bridge/AccountSettings.php index 3faa0e6fe0..1f29a9e488 100644 --- a/lib/classes/Bridge/AccountSettings.php +++ b/lib/classes/Bridge/AccountSettings.php @@ -54,7 +54,7 @@ class Bridge_AccountSettings $sql = 'SELECT value FROM bridge_account_settings WHERE account_id = :account_id AND `key` = :key'; - $params = array(':account_id' => $this->account->get_id(), ':key' => $key); + $params = [':account_id' => $this->account->get_id(), ':key' => $key]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -75,11 +75,11 @@ class Bridge_AccountSettings $sql = 'REPLACE INTO bridge_account_settings (account_id, `key`, value) VALUES (:account_id, :key, :value)'; - $params = array( + $params = [ ':value' => $value , ':account_id' => $this->account->get_id() , ':key' => $key - ); + ]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); @@ -100,7 +100,7 @@ class Bridge_AccountSettings $sql = 'DELETE FROM bridge_account_settings WHERE account_id = :account_id AND `key` = :key'; - $params = array(':account_id' => $this->account->get_id(), ':key' => $key); + $params = [':account_id' => $this->account->get_id(), ':key' => $key]; $stmt = $this->appbox->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Bridge/Api.php b/lib/classes/Bridge/Api.php index 69ce9f96a0..cb6cf68d42 100644 --- a/lib/classes/Bridge/Api.php +++ b/lib/classes/Bridge/Api.php @@ -71,7 +71,7 @@ class Bridge_Api $sql = 'SELECT id, name, disable_time, created_on, updated_on FROM bridge_apis WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -364,7 +364,7 @@ class Bridge_Api * @param array $options specific option, regarding the connector * @return string The distant_id of the created element */ - public function upload(record_adapter $record, array $options = array()) + public function upload(record_adapter $record, array $options = []) { $action = function (Bridge_Api $obj) use ($record, $options) { return $obj->get_connector()->upload($record, $options); @@ -389,7 +389,7 @@ class Bridge_Api $sql = 'DELETE FROM bridge_apis WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); return; @@ -406,11 +406,11 @@ class Bridge_Api $sql = 'UPDATE bridge_apis SET disable_time = :time, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':time' => $value , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -463,7 +463,7 @@ class Bridge_Api */ public static function generate_callback_url(UrlGenerator $generator, $api_name) { - return $generator->generate('prod_bridge_callback', array('api_name' => strtolower($api_name)), UrlGenerator::ABSOLUTE_URL); + return $generator->generate('prod_bridge_callback', ['api_name' => strtolower($api_name)], UrlGenerator::ABSOLUTE_URL); } /** @@ -474,7 +474,7 @@ class Bridge_Api */ public static function generate_login_url(UrlGenerator $generator, $api_name) { - return $generator->generate('prod_bridge_login', array('api_name' => strtolower($api_name)), UrlGenerator::ABSOLUTE_URL); + return $generator->generate('prod_bridge_login', ['api_name' => strtolower($api_name)], UrlGenerator::ABSOLUTE_URL); } /** @@ -504,7 +504,7 @@ class Bridge_Api $sql = 'SELECT id FROM bridge_apis WHERE name = :name'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':name' => $name)); + $stmt->execute([':name' => $name]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -527,7 +527,7 @@ class Bridge_Api $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); + $results = []; foreach ($rs as $row) { try { @@ -547,7 +547,7 @@ class Bridge_Api VALUES (null, :name, 0, null, NOW(), NOW())'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':name' => strtolower($name))); + $stmt->execute([':name' => strtolower($name)]); $stmt->closeCursor(); $api_id = $app['phraseanet.appbox']->get_connection()->lastInsertId(); diff --git a/lib/classes/Bridge/Api/Abstract.php b/lib/classes/Bridge/Api/Abstract.php index 123901dcc9..194e6538ab 100644 --- a/lib/classes/Bridge/Api/Abstract.php +++ b/lib/classes/Bridge/Api/Abstract.php @@ -114,7 +114,7 @@ abstract class Bridge_Api_Abstract * * @return string */ - public function get_auth_url($supp_params = array()) + public function get_auth_url($supp_params = []) { return $this->_auth->get_auth_url($supp_params); } diff --git a/lib/classes/Bridge/Api/AbstractCollection.php b/lib/classes/Bridge/Api/AbstractCollection.php index 2e36321154..18e3dac611 100644 --- a/lib/classes/Bridge/Api/AbstractCollection.php +++ b/lib/classes/Bridge/Api/AbstractCollection.php @@ -45,7 +45,7 @@ abstract class Bridge_Api_AbstractCollection * * @var Array */ - protected $elements = array(); + protected $elements = []; /** * diff --git a/lib/classes/Bridge/Api/Auth/Flickr.php b/lib/classes/Bridge/Api/Auth/Flickr.php index 1e579fb38e..40c73e4b27 100644 --- a/lib/classes/Bridge/Api/Auth/Flickr.php +++ b/lib/classes/Bridge/Api/Auth/Flickr.php @@ -79,7 +79,7 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ $this->get_api()->setAuthToken($auth_token); - return array('auth_token' => $auth_token); + return ['auth_token' => $auth_token]; } /** @@ -117,9 +117,9 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function get_auth_signatures() { - return array( + return [ 'auth_token' => $this->settings->get('auth_token') - ); + ]; } /** @@ -129,7 +129,7 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function set_parameters(Array $parameters) { - $avail_parameters = array('flickr_client_id', 'flickr_client_secret', 'permissions'); + $avail_parameters = ['flickr_client_id', 'flickr_client_secret', 'permissions']; foreach ($parameters as $parameter => $value) { if ( ! in_array($parameter, $avail_parameters)) continue; @@ -144,7 +144,7 @@ class Bridge_Api_Auth_Flickr extends Bridge_Api_Auth_Abstract implements Bridge_ * * @return string */ - public function get_auth_url(Array $supp_params = array()) + public function get_auth_url(Array $supp_params = []) { $request_token = $this->get_api()->requestFrob(); diff --git a/lib/classes/Bridge/Api/Auth/Interface.php b/lib/classes/Bridge/Api/Auth/Interface.php index 921cd3a3d1..202eabce8f 100644 --- a/lib/classes/Bridge/Api/Auth/Interface.php +++ b/lib/classes/Bridge/Api/Auth/Interface.php @@ -31,7 +31,7 @@ interface Bridge_Api_Auth_Interface public function parse_request_token(); - public function get_auth_url(Array $supp_parameters = array()); + public function get_auth_url(Array $supp_parameters = []); public function get_auth_signatures(); diff --git a/lib/classes/Bridge/Api/Auth/OAuth2.php b/lib/classes/Bridge/Api/Auth/OAuth2.php index 68bafbd304..349868483e 100644 --- a/lib/classes/Bridge/Api/Auth/OAuth2.php +++ b/lib/classes/Bridge/Api/Auth/OAuth2.php @@ -75,13 +75,13 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function connect($request_token) { - $post_params = array( + $post_params = [ 'code' => $request_token, 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'redirect_uri' => $this->redirect_uri, 'grant_type' => 'authorization_code' - ); + ]; $response_json = http_query::getUrl($this->token_endpoint, $post_params); $response = json_decode($response_json, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS); @@ -89,7 +89,7 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ if ( ! is_array($response) || ! isset($response['refresh_token']) || ! isset($response['access_token'])) throw new Bridge_Exception_ApiConnectorAccessTokenFailed('Unable to retrieve tokens'); - return array('refresh_token' => $response['refresh_token'], 'auth_token' => $response['access_token']); + return ['refresh_token' => $response['refresh_token'], 'auth_token' => $response['access_token']]; } /** @@ -98,12 +98,12 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function reconnect() { - $post_params = array( + $post_params = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'refresh_token' => $this->settings->get('refresh_token'), 'grant_type' => 'refresh_token' - ); + ]; $response = http_query::getUrl($this->token_endpoint, $post_params); $response = json_decode($response, JSON_HEX_TAG | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_APOS); @@ -141,9 +141,9 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function get_auth_signatures() { - return array( + return [ 'auth_token' => $this->settings->get('auth_token') - ); + ]; } /** @@ -153,7 +153,7 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ */ public function set_parameters(Array $parameters) { - $avail_parameters = array( + $avail_parameters = [ 'client_id' , 'client_secret' , 'redirect_uri' @@ -161,7 +161,7 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ , 'response_type' , 'token_endpoint' , 'auth_endpoint' - ); + ]; foreach ($parameters as $parameter => $value) { if ( ! in_array($parameter, $avail_parameters)) @@ -177,14 +177,14 @@ class Bridge_Api_Auth_OAuth2 extends Bridge_Api_Auth_Abstract implements Bridge_ * * @return string */ - public function get_auth_url(Array $supp_parameters = array()) + public function get_auth_url(Array $supp_parameters = []) { - $params = array_merge(array( + $params = array_merge([ 'response_type' => 'code', 'client_id' => $this->client_id, 'redirect_uri' => $this->redirect_uri, 'scope' => $this->scope - ), $supp_parameters); + ], $supp_parameters); return sprintf('%s?%s', $this->auth_endpoint, http_build_query($params, null, '&')); } diff --git a/lib/classes/Bridge/Api/Auth/Youtube.php b/lib/classes/Bridge/Api/Auth/Youtube.php index 4105b4da22..02f54d34f8 100644 --- a/lib/classes/Bridge/Api/Auth/Youtube.php +++ b/lib/classes/Bridge/Api/Auth/Youtube.php @@ -22,12 +22,12 @@ class Bridge_Api_Auth_Youtube extends Bridge_Api_Auth_OAuth2 * @param array $supp_parameters * @return string */ - public function get_auth_url(array $supp_parameters = array()) + public function get_auth_url(array $supp_parameters = []) { $supp_parameters = array_merge( - $supp_parameters, array( + $supp_parameters, [ 'access_type' => 'offline', - 'approval_prompt' => 'force') + 'approval_prompt' => 'force'] ); return parent::get_auth_url($supp_parameters); diff --git a/lib/classes/Bridge/Api/Dailymotion.php b/lib/classes/Bridge/Api/Dailymotion.php index 1ceea2f94b..8590fafdf6 100644 --- a/lib/classes/Bridge/Api/Dailymotion.php +++ b/lib/classes/Bridge/Api/Dailymotion.php @@ -89,7 +89,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_user_id() { - $result = $this->_api->call("/me", array('fields' => array('id')), $this->oauth_token); + $result = $this->_api->call("/me", ['fields' => ['id']], $this->oauth_token); return $result["id"]; } @@ -100,7 +100,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_user_name() { - $result = $this->_api->call("/me", array('fields' => array('username')), $this->oauth_token); + $result = $this->_api->call("/me", ['fields' => ['username']], $this->oauth_token); return $result["username"]; } @@ -183,7 +183,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_element_types() { - return array(self::ELEMENT_TYPE_VIDEO => _('Videos')); + return [self::ELEMENT_TYPE_VIDEO => _('Videos')]; } /** @@ -192,7 +192,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_container_types() { - return array(self::CONTAINER_TYPE_PLAYLIST => _('Playlists')); + return [self::CONTAINER_TYPE_PLAYLIST => _('Playlists')]; } public function get_oauth_token() @@ -241,7 +241,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($object) { case self::ELEMENT_TYPE_VIDEO: - $result = $this->_api->call('/me/videos', array('fields' => array( + $result = $this->_api->call('/me/videos', ['fields' => [ 'created_time' , 'description' , 'duration' @@ -256,9 +256,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I , 'views_total' , 'id' , 'channel' - ), + ], 'page' => ! $offset_start ? 1 : $offset_start, - 'limit' => $quantity), $this->oauth_token); + 'limit' => $quantity], $this->oauth_token); $element_collection = new Bridge_Api_ElementCollection(); $element_collection->set_items_per_page($result["limit"]); @@ -298,12 +298,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I $username = $this->get_user_name(); - $params = array('fields' => array( + $params = ['fields' => [ 'description' , 'id' , 'name' - ), - 'page' => ! $offset_start ? 1 : $offset_start); + ], + 'page' => ! $offset_start ? 1 : $offset_start]; //add quantity if (! ! $quantity) { $params["limit"] = $quantity; @@ -325,7 +325,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I foreach ($result['list'] as $entry) { //get 1st image - $list_element = $this->list_containers_content($object, $entry['id'], array('thumbnail_medium_url'), 1); + $list_element = $this->list_containers_content($object, $entry['id'], ['thumbnail_medium_url'], 1); $elements = $list_element->get_elements(); $first_element = array_shift($elements); $thumbnail = $first_element instanceof Bridge_Api_Dailymotion_Element ? $first_element->get_thumbnail() : ''; @@ -356,18 +356,18 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function update_element($object, $object_id, Array $datas) { - $required_fields = array("title", "description", "category", "privacy"); + $required_fields = ["title", "description", "category", "privacy"]; foreach ($required_fields as $field) { if ( ! array_key_exists($field, $datas)) throw new Bridge_Exception_ActionMandatoryField("Le paramétre " . $field . " est manquant"); } - $params = array( + $params = [ 'title' => $datas["title"] , 'description' => $datas["description"] , 'channel' => $datas["category"] , 'private' => ! $datas["private"] - ); + ]; if ( ! $this->is_valid_object_id($object_id)) throw new Bridge_Exception_ActionInvalidObjectId($object_id); @@ -397,7 +397,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($container_type) { case self::CONTAINER_TYPE_PLAYLIST: $url = sprintf("POST /me/%ss", $container_type); - $playlist = $this->_api->call($url, array('name' => $request->get("name")), $this->oauth_token); + $playlist = $this->_api->call($url, ['name' => $request->get("name")], $this->oauth_token); return $playlist["id"]; break; @@ -422,9 +422,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($destination) { case self::CONTAINER_TYPE_PLAYLIST: - $array = array($element_id); + $array = [$element_id]; //get containers content - foreach ($this->list_containers_content($destination, $container_id, array('id'))->get_elements() as $element) { + foreach ($this->list_containers_content($destination, $container_id, ['id'])->get_elements() as $element) { $array[] = $element->get_id(); } @@ -432,7 +432,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I $url = sprintf('POST /%s/%s/%ss', $destination, $container_id, $element_type); - $this->_api->call($url, array('ids' => implode(",", $array)), $this->oauth_token); + $this->_api->call($url, ['ids' => implode(",", $array)], $this->oauth_token); return $this->get_container_from_id(self::CONTAINER_TYPE_PLAYLIST, $container_id); break; @@ -458,10 +458,10 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I $url = sprintf("DELETE /%s/%s", $object, $object_id); switch ($object) { case self::ELEMENT_TYPE_VIDEO: - $this->_api->call($url, array(), $this->oauth_token); + $this->_api->call($url, [], $this->oauth_token); break; case self::CONTAINER_TYPE_PLAYLIST: - $this->_api->call($url, array(), $this->oauth_token); + $this->_api->call($url, [], $this->oauth_token); break; default: throw new Bridge_Exception_ObjectUnknown('Unknown object ' . $object); @@ -492,9 +492,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I { $url = sprintf("/%s/%s", $element->get_type(), $element->get_dist_id()); - $result = $this->_api->call($url, array('fields' => array( + $result = $this->_api->call($url, ['fields' => [ 'status' - )), $this->oauth_token); + ]], $this->oauth_token); return $result["status"]; } @@ -578,12 +578,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I * @param array $options * @return string */ - public function upload(record_adapter $record, array $options = array()) + public function upload(record_adapter $record, array $options = []) { switch ($record->get_type()) { case self::ELEMENT_TYPE_VIDEO : $url_file = $this->_api->uploadFileWithToken($record->get_hd_file()->getRealPath(), $this->oauth_token); - $options = array_merge(array('url' => $url_file), $options); + $options = array_merge(['url' => $url_file], $options); $video = $this->_api->call('POST /me/videos', $options, $this->oauth_token); return $video["id"]; @@ -607,7 +607,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($object) { case self::ELEMENT_TYPE_VIDEO: - $entry = $this->_api->call($url, array('fields' => array( + $entry = $this->_api->call($url, ['fields' => [ 'created_time' , 'description' , 'duration' @@ -623,7 +623,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I , 'id' , 'channel' , 'tags' - )), $this->oauth_token); + ]], $this->oauth_token); return new Bridge_Api_Dailymotion_Element($entry, $object); break; @@ -645,11 +645,11 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I switch ($object) { case self::CONTAINER_TYPE_PLAYLIST: - $entry = $this->_api->call($url, array('fields' => array( + $entry = $this->_api->call($url, ['fields' => [ 'description' , 'id' , 'name' - )), $this->oauth_token); + ]], $this->oauth_token); /** * @todo Retieve thumb */ @@ -686,7 +686,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I protected function set_auth_params() { $this->_auth->set_parameters( - array( + [ 'client_id' => $this->registry->get('GV_dailymotion_client_id') , 'client_secret' => $this->registry->get('GV_dailymotion_client_secret') , 'redirect_uri' => Bridge_Api::generate_callback_url($this->generator, $this->get_name()) @@ -694,7 +694,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I , 'response_type' => 'code' , 'token_endpoint' => self::OAUTH2_TOKEN_ENDPOINT , 'auth_endpoint' => self::OAUTH2_AUTHORIZE_ENDPOINT - ) + ] ); return $this; @@ -732,7 +732,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I public function get_category_list() { $locale = explode("_", $this->locale); - $result = $this->_api->call("/channels", array("language" => $locale[0])); + $result = $this->_api->call("/channels", ["language" => $locale[0]]); return $result["list"]; } @@ -742,9 +742,9 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I * @param type $supp_params * @return type */ - public function get_auth_url($supp_params = array()) + public function get_auth_url($supp_params = []) { - $params = array_merge(array('display' => 'popup', 'scope' => 'read write delete manage_playlists'), $supp_params); + $params = array_merge(['display' => 'popup', 'scope' => 'read write delete manage_playlists'], $supp_params); return parent::get_auth_url($params); } @@ -754,10 +754,10 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I * @param string $id * @return Bridge_Api_ElementCollection */ - protected function list_containers_content($object, $id, Array $fields = array(), $iteration = 0) + protected function list_containers_content($object, $id, Array $fields = [], $iteration = 0) { $url = sprintf("/%s/%s/videos", $object, $id); - $result = $this->_api->call($url, array('fields' => $fields), $this->oauth_token); + $result = $this->_api->call($url, ['fields' => $fields], $this->oauth_token); $element_collection = new Bridge_Api_ElementCollection(); $element_collection->set_items_per_page($result["limit"]); @@ -829,7 +829,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I public function check_update_constraints(Array $datas) { - $errors = array(); + $errors = []; $check = function ($field) use (&$errors, $datas) { $required = ! ! $field["required"]; $name = $field["name"]; @@ -863,12 +863,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->get_serialize_key(); - $datas = array( + $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'tag' => $request->get('tags_' . $key), 'private' => $request->get('privacy_' . $key) === 'private' ? true : false, - ); + ]; return $datas; } @@ -880,12 +880,12 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_update_datas(Request $request) { - $datas = array( + $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'tags' => $request->get('modif_tags'), 'private' => $request->get('modif_privacy') === 'private' ? true : false, - ); + ]; return $datas; } @@ -908,7 +908,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ private function check_record_constraints(record_adapter $record) { - $errors = array(); + $errors = []; if ( ! $record->get_hd_file() instanceof \SplFileInfo) $errors["file_size"] = _("Le record n'a pas de fichier physique"); //Record must rely on real file @@ -927,31 +927,31 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I */ public function get_fields() { - return array( - array( + return [ + [ 'name' => 'title', 'length' => '255', 'length_min' => '5', 'required' => true - ) - , array( + ] + , [ 'name' => 'description', 'length' => '2000', 'length_min' => '0', 'required' => false - ) - , array( + ] + , [ 'name' => 'tags', 'length' => '150', 'length_min' => '0', 'required' => false - ) - , array( + ] + , [ 'name' => 'private', 'length' => '0', 'length_min' => '0', 'required' => true - ) - ); + ] + ]; } } diff --git a/lib/classes/Bridge/Api/Dailymotion/Element.php b/lib/classes/Bridge/Api/Dailymotion/Element.php index 6664542d71..f2f222cf6a 100644 --- a/lib/classes/Bridge/Api/Dailymotion/Element.php +++ b/lib/classes/Bridge/Api/Dailymotion/Element.php @@ -170,6 +170,6 @@ class Bridge_Api_Dailymotion_Element implements Bridge_Api_ElementInterface */ public function get_tags() { - return implode(",", $this->get('tags', array())); + return implode(",", $this->get('tags', [])); } } diff --git a/lib/classes/Bridge/Api/Flickr.php b/lib/classes/Bridge/Api/Flickr.php index 91c7ccd3bf..81b9d4d678 100644 --- a/lib/classes/Bridge/Api/Flickr.php +++ b/lib/classes/Bridge/Api/Flickr.php @@ -169,7 +169,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { switch ($object) { case self::ELEMENT_TYPE_PHOTO: - $params = array('photo_id' => $element_id); + $params = ['photo_id' => $element_id]; $th_response = $this->_api->executeMethod('flickr.photos.getInfo', $params); if ( ! $th_response->isOk()) @@ -198,7 +198,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf switch ($object) { case self::CONTAINER_TYPE_PHOTOSET: - $params = array('photoset_id' => $element_id); + $params = ['photoset_id' => $element_id]; $response = $this->_api->executeMethod('flickr.photoset.getInfo', $params); if ( ! $response->isOk()) @@ -227,7 +227,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { switch ($object) { case self::CONTAINER_TYPE_PHOTOSET: - $params = array(); + $params = []; if ($quantity) $params['per_page'] = $quantity; $params['page'] = $quantity != 0 ? floor($offset_start / $quantity) + 1 : 1; @@ -267,17 +267,17 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function update_element($object, $object_id, Array $datas) { - $required_fields = array("title"); + $required_fields = ["title"]; foreach ($required_fields as $field) { if ( ! array_key_exists($field, $datas) || trim($datas[$field]) === '') throw new Bridge_Exception_ActionMandatoryField("Le paramétre " . $field . " est manquant"); } - $params = array( + $params = [ 'title' => $datas["title"] , 'photo_id' => $object_id , 'description' => $datas["description"] - ); + ]; switch ($object) { case self::ELEMENT_TYPE_PHOTO : @@ -309,11 +309,11 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf if (is_null($pid)) throw new Bridge_Exception_ActionMandatoryField('You must define a default photo for the photoset'); - $params = array( + $params = [ 'title' => $request->get('title') , 'primary_photo_id' => $pid , 'description' => $request->get('description') - ); + ]; $response = $this->_api->executeMethod('flickr.photosets.create', $params); @@ -348,7 +348,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf case self::ELEMENT_TYPE_PHOTO: switch ($destination) { case self::CONTAINER_TYPE_PHOTOSET: - $params = array('photo_id' => $element_id, 'photoset_id' => $container_id); + $params = ['photo_id' => $element_id, 'photoset_id' => $container_id]; $response = $this->_api->executeMethod('flickr.photosets.addPhoto', $params); if ( ! $response->isOk()) { @@ -385,7 +385,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf case self::ELEMENT_TYPE_PHOTO: $response = $this->_api->executeMethod( 'flickr.photos.delete' - , array('photo_id' => $object_id) + , ['photo_id' => $object_id] ); if ( ! $response->isOk()) throw new Bridge_Exception_ApiConnectorRequestFailed(); @@ -393,7 +393,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf case self::CONTAINER_TYPE_PHOTOSET: $response = $this->_api->executeMethod( 'flickr.photosets.delete' - , array('photoset_id' => $object_id) + , ['photoset_id' => $object_id] ); if ( ! $response->isOk()) throw new Bridge_Exception_ApiConnectorRequestFailed(); @@ -417,9 +417,9 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf { switch ($type) { case self::ELEMENT_TYPE_PHOTO: - $params = array(); + $params = []; //info to display during search - $extras = array( + $extras = [ 'description' , 'license' , 'date_upload' @@ -430,7 +430,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf , 'views' , 'url_sq' , 'url_t' - ); + ]; $params['user_id'] = $this->get_user_id(); $params['extras'] = implode(",", $extras); @@ -510,7 +510,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf * @param array $options * @return string The new distant Id */ - public function upload(record_adapter $record, Array $options = array()) + public function upload(record_adapter $record, Array $options = []) { $uploader = new Phlickr_Uploader($this->_api); @@ -534,7 +534,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf public function acceptable_records() { return function (record_adapter $record) { - return in_array($record->get_type(), array('image')); + return in_array($record->get_type(), ['image']); }; } @@ -568,7 +568,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf $family = $friends = $public = false; break; } - $ret = array('friends' => $friends, 'family' => $family, 'public' => $public); + $ret = ['friends' => $friends, 'family' => $family, 'public' => $public]; return $ret; } @@ -601,7 +601,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_element_types() { - return array(self::ELEMENT_TYPE_PHOTO => _('Photos')); + return [self::ELEMENT_TYPE_PHOTO => _('Photos')]; } /** @@ -610,7 +610,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_container_types() { - return array(self::CONTAINER_TYPE_PHOTOSET => _('Photosets')); + return [self::CONTAINER_TYPE_PHOTOSET => _('Photosets')]; } /** @@ -622,7 +622,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_category_list() { - return array(); + return []; } public function is_configured() @@ -678,11 +678,11 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf protected function set_auth_params() { $this->_auth->set_parameters( - array( + [ 'flickr_client_id' => $this->registry->get('GV_flickr_client_id') , 'flickr_client_secret' => $this->registry->get('GV_flickr_client_secret') , 'permissions' => 'delete' - ) + ] ); return $this; @@ -719,7 +719,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf public function check_update_constraints(Array $datas) { - $errors = array(); + $errors = []; $check = function ($field) use (&$errors, $datas) { $name = $field['name']; $length = (int) $field['length']; @@ -748,10 +748,10 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ public function get_update_datas(Request $request) { - $datas = array( + $datas = [ 'title' => $request->get('modif_title', ''), 'description' => $request->get('modif_description', '') - ); + ]; return $datas; } @@ -767,13 +767,13 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->get_serialize_key(); - $datas = array( + $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'category' => $request->get('category_' . $key), 'tags' => $request->get('tags_' . $key), 'privacy' => $request->get('privacy_' . $key), - ); + ]; return $datas; } @@ -793,23 +793,23 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ private function get_fields() { - return array( - array( + return [ + [ 'name' => 'title', 'length' => '100', 'required' => true - ) - , array( + ] + , [ 'name' => 'description', 'length' => '500', 'required' => false - ) - , array( + ] + , [ 'name' => 'tags', 'length' => '200', 'required' => false - ) - ); + ] + ]; } /** @@ -819,7 +819,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf */ private function check_record_constraints(record_adapter $record) { - $errors = array(); + $errors = []; if ( ! $record->get_hd_file() instanceof \SplFileInfo) $errors["file_size"] = _("Le record n'a pas de fichier physique"); //Record must rely on real file if ($record->get_technical_infos('size') > self::AUTH_PHOTO_SIZE) @@ -830,8 +830,8 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf private function checkTicket($ticketsId, $type) { - $return = array("status" => self::UPLOAD_STATE_FAILED, "dist_id" => null); - $response = $this->_api->executeMethod("flickr.photos.upload.checkTickets", array("tickets" => $ticketsId)); + $return = ["status" => self::UPLOAD_STATE_FAILED, "dist_id" => null]; + $response = $this->_api->executeMethod("flickr.photos.upload.checkTickets", ["tickets" => $ticketsId]); if ( ! $response->isOk()) throw new Bridge_Exception_ApiConnectorRequestFailed('Unable to retrieve element list ' . $type); diff --git a/lib/classes/Bridge/Api/Flickr/Element.php b/lib/classes/Bridge/Api/Flickr/Element.php index 87c58c53df..2a4cfb6481 100644 --- a/lib/classes/Bridge/Api/Flickr/Element.php +++ b/lib/classes/Bridge/Api/Flickr/Element.php @@ -42,7 +42,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface */ public function __construct(SimpleXMLElement $entry, $user_id, $type, $entry_from_list = true) { - $this->entry = array(); + $this->entry = []; $this->type = $type; if ($entry_from_list) @@ -80,7 +80,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface } $dates = $photo->dates; $visibility = $photo->visibility; - $tags = array(); + $tags = []; foreach ($photo->tags->tag as $one_tag) { $tags[] = $one_tag; } diff --git a/lib/classes/Bridge/Api/Interface.php b/lib/classes/Bridge/Api/Interface.php index 95ae4bfd85..78bf47efc4 100644 --- a/lib/classes/Bridge/Api/Interface.php +++ b/lib/classes/Bridge/Api/Interface.php @@ -152,7 +152,7 @@ interface Bridge_Api_Interface public function get_error_message_from_status($connector_status); - public function upload(record_adapter $record, array $options = array()); + public function upload(record_adapter $record, array $options = []); public function is_valid_object_id($object_id); diff --git a/lib/classes/Bridge/Api/Youtube.php b/lib/classes/Bridge/Api/Youtube.php index 32bd8bcfe5..bbd31f698d 100644 --- a/lib/classes/Bridge/Api/Youtube.php +++ b/lib/classes/Bridge/Api/Youtube.php @@ -167,7 +167,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_element_types() { - return array(self::ELEMENT_TYPE_VIDEO => _('Videos')); + return [self::ELEMENT_TYPE_VIDEO => _('Videos')]; } /** @@ -176,7 +176,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_container_types() { - return array(self::CONTAINER_TYPE_PLAYLIST => _('Playlists')); + return [self::CONTAINER_TYPE_PLAYLIST => _('Playlists')]; } /** @@ -297,7 +297,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function update_element($object, $object_id, Array $datas) { - $required_fields = array("description", "category", "tags", "title", "privacy"); + $required_fields = ["description", "category", "tags", "title", "privacy"]; foreach ($required_fields as $field) { if ( ! array_key_exists($field, $datas)) throw new Bridge_Exception_ActionMandatoryField("Le paramétre " . $field . " est manquant"); @@ -626,7 +626,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ protected function parse_xml_error($string) { - $rs = array(); + $rs = []; libxml_use_internal_errors(true); $xml = simplexml_load_string($string); libxml_clear_errors(); @@ -636,7 +636,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter } if (isset($xml->HEAD) || isset($xml->head)) { - return array(); + return []; } else { $domaine = explode(":", (string) $xml->error[0]->domain); $rs['type'] = count($domaine) > 1 ? $domaine[1] : $domaine[0]; @@ -655,7 +655,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter * @param array $options * @return string The new distant Id */ - public function upload(record_adapter $record, array $options = array()) + public function upload(record_adapter $record, array $options = []) { switch ($record->get_type()) { case 'video': @@ -671,7 +671,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $video_entry->setVideoDescription($options['description']); $video_entry->setVideoCategory($options['category']); $video_entry->SetVideoTags(explode(' ', $options['tags'])); - $video_entry->setVideoDeveloperTags(array('phraseanet')); + $video_entry->setVideoDeveloperTags(['phraseanet']); if ($options['privacy'] == "public") $video_entry->setVideoPublic(); @@ -721,7 +721,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_category_list() { - $cat = array(); + $cat = []; $url_cat = sprintf('%s?hl=%s', self::CATEGORY_URL, $this->get_locale()); if (false === $cxml = simplexml_load_file($url_cat)) { @@ -815,7 +815,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter protected function set_auth_params() { $this->_auth->set_parameters( - array( + [ 'client_id' => $this->registry->get('GV_youtube_client_id') , 'client_secret' => $this->registry->get('GV_youtube_client_secret') , 'redirect_uri' => Bridge_Api::generate_callback_url($this->generator, $this->get_name()) @@ -823,7 +823,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter , 'response_type' => 'code' , 'token_endpoint' => self::OAUTH2_TOKEN_ENDPOINT , 'auth_endpoint' => self::OAUTH2_AUTHORIZE_ENDPOINT - ) + ] ); return $this; @@ -884,11 +884,11 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_locale() { - $youtube_available_locale = array( + $youtube_available_locale = [ 'zh-CN', 'zh-TW', 'cs-CZ', 'nl-NL', 'en-GB', 'en-US', 'fr-FR', 'de-DE', 'it-IT', 'ja-JP', 'ko-KR', 'pl-PL', 'pt-PT', 'ru-RU', 'es-ES', 'es-MX', 'sv-SE' - ); + ]; if ( ! is_null($this->locale)) { $youtube_format_locale = str_replace('_', '-', $this->locale); if (in_array(trim($youtube_format_locale), $youtube_available_locale)) { @@ -937,7 +937,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter public function check_update_constraints(Array $datas) { - $errors = array(); + $errors = []; $check = function ($field) use (&$errors, $datas) { $name = $field['name']; $length = (int) $field['length']; @@ -970,13 +970,13 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ public function get_update_datas(Request $request) { - $datas = array( + $datas = [ 'title' => $request->get('modif_title'), 'description' => $request->get('modif_description'), 'category' => $request->get('modif_category'), 'tags' => $request->get('modif_tags'), 'privacy' => $request->get('modif_privacy'), - ); + ]; return $datas; } @@ -992,13 +992,13 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter public function get_upload_datas(Request $request, record_adapter $record) { $key = $record->get_serialize_key(); - $datas = array( + $datas = [ 'title' => $request->get('title_' . $key), 'description' => $request->get('description_' . $key), 'category' => $request->get('category_' . $key), 'tags' => $request->get('tags_' . $key), 'privacy' => $request->get('privacy_' . $key), - ); + ]; return $datas; } @@ -1021,7 +1021,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ private function check_record_constraints(record_adapter $record) { - $errors = array(); + $errors = []; $key = $record->get_serialize_key(); if ( ! $record->get_hd_file() instanceof SplFileInfo) $errors["file_size_" . $key] = _("Le record n'a pas de fichier physique"); //Record must rely on real file @@ -1041,38 +1041,38 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter */ private function get_fields() { - return array( - array( + return [ + [ 'name' => 'title', 'length' => '100', 'required' => true, 'empty' => false - ) - , array( + ] + , [ 'name' => 'description', 'length' => '2000', 'required' => true, 'empty' => true - ) - , array( + ] + , [ 'name' => 'tags', 'length' => '500', 'tag_length' => '30', 'required' => true, 'empty' => true - ) - , array( + ] + , [ 'name' => 'privacy', 'length' => '0', 'required' => true, 'empty' => false - ) - , array( + ] + , [ 'name' => 'category', 'length' => '0', 'required' => true, 'empty' => false - ) - ); + ] + ]; } } diff --git a/lib/classes/Bridge/Element.php b/lib/classes/Bridge/Element.php index dc629427c3..969c61dd28 100644 --- a/lib/classes/Bridge/Element.php +++ b/lib/classes/Bridge/Element.php @@ -119,7 +119,7 @@ class Bridge_Element , title, serialized_datas, created_on, updated_on, uploaded_on FROM bridge_elements WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -190,11 +190,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET dist_id = :dist_id, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':dist_id' => $this->dist_id , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -225,11 +225,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET status = :status, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':status' => $this->status , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -261,11 +261,11 @@ class Bridge_Element SET connector_status = :connector_status, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':connector_status' => $this->connector_status , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -322,11 +322,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET title = :title, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':title' => $this->title , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -357,11 +357,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET serialized_datas = :datas, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':datas' => serialize($this->datas) , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -402,11 +402,11 @@ class Bridge_Element $sql = 'UPDATE bridge_elements SET uploaded_on = :uploaded_on, updated_on = :update WHERE id = :id'; - $params = array( + $params = [ ':uploaded_on' => $this->uploaded_on ? $this->uploaded_on->format(DATE_ISO8601) : null , ':id' => $this->id , ':update' => $this->updated_on->format(DATE_ISO8601) - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -433,7 +433,7 @@ class Bridge_Element $sql = 'DELETE FROM bridge_elements WHERE id = :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); return; @@ -446,11 +446,11 @@ class Bridge_Element LIMIT ' . (int) $offset_start . ',' . (int) $quantity; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':account_id' => $account->get_id())); + $stmt->execute([':account_id' => $account->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $results = array(); + $results = []; foreach ($rs as $row) { $results[] = new Bridge_Element($app, $account, $row['id']); @@ -459,7 +459,7 @@ class Bridge_Element return $results; } - public static function create(Application $app, Bridge_Account $account, record_adapter $record, $title, $status, $type, Array $datas = array()) + public static function create(Application $app, Bridge_Account $account, record_adapter $record, $title, $status, $type, Array $datas = []) { $sql = 'INSERT INTO bridge_elements (id, account_id, sbas_id, record_id, dist_id, title, `type` @@ -468,7 +468,7 @@ class Bridge_Element (null, :account_id, :sbas_id, :record_id, null, :title, :type ,:datas , :status, NOW(), NOW())'; - $params = array( + $params = [ ':account_id' => $account->get_id() , ':sbas_id' => $record->get_sbas_id() , ':record_id' => $record->get_record_id() @@ -476,7 +476,7 @@ class Bridge_Element , ':title' => $title , ':type' => $type , ':datas' => serialize($datas) - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Browser.php b/lib/classes/Browser.php index 6609f0b48e..c3a205dbae 100644 --- a/lib/classes/Browser.php +++ b/lib/classes/Browser.php @@ -712,13 +712,13 @@ class Browser if (stripos($this->_agent, 'msnb') !== false) { $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'MSN')); $this->setBrowser(self::BROWSER_MSN); - $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); + $this->setVersion(str_replace(['(', ')', ';'], '', $aresult[1])); return true; } $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie')); $this->setBrowser(self::BROWSER_IE); - $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); + $this->setVersion(str_replace(['(', ')', ';'], '', $aresult[1])); return true; } @@ -746,7 +746,7 @@ class Browser $this->setVersion(preg_replace("/[^0-9.]+/", "", $result[1])); // remove Gecko out of the user-agent, otherwise the mozilla check will success - $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); + $this->_agent = str_replace(["Mozilla", "Gecko"], "MSIE", $this->_agent); } return false; @@ -840,7 +840,7 @@ class Browser if (stripos($this->_agent, 'NetPositive') !== false) { $aresult = explode('/', stristr($this->_agent, 'NetPositive')); $aversion = explode(' ', $aresult[1]); - $this->setVersion(str_replace(array('(', ')', ';'), '', $aversion[0])); + $this->setVersion(str_replace(['(', ')', ';'], '', $aversion[0])); $this->setBrowser(self::BROWSER_NETPOSITIVE); return true; @@ -1299,7 +1299,7 @@ class Browser { $this->_is_new_generation = false; - if (in_array($this->_browser_name, array('Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'))) { + if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) @@ -1337,7 +1337,7 @@ class Browser */ protected function checkHTML5() { - if (in_array($this->_browser_name, array('Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'))) { + if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) { switch ($this->_browser_name) { case 'Opera': if ($this->_version >= 10) diff --git a/lib/classes/DailymotionWithoutOauth2.php b/lib/classes/DailymotionWithoutOauth2.php index 102fc5d5b5..0527a365ce 100644 --- a/lib/classes/DailymotionWithoutOauth2.php +++ b/lib/classes/DailymotionWithoutOauth2.php @@ -27,14 +27,13 @@ class DailymotionWithoutOauth2 extends Dailymotion * @throws DailymotionAuthRequiredException if not authentication info is available * @throws DailymotionTransportException if an error occurs during request. */ - public function call($method, $args = array(), $access_token = null) + public function call($method, $args = [], $access_token = null) { - $headers = array('Content-Type: application/json'); - $payload = json_encode(array - ( + $headers = ['Content-Type: application/json']; + $payload = json_encode([ 'call' => $method, 'args' => $args, - )); + ]); $status_code = null; try { @@ -77,10 +76,10 @@ class DailymotionWithoutOauth2 extends Dailymotion */ public function uploadFileWithToken($filePath, $oauth_token) { - $result = $this->call('file.upload', array(), $oauth_token); + $result = $this->call('file.upload', [], $oauth_token); $timeout = $this->timeout; $this->timeout = null; - $result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true); + $result = json_decode($this->httpRequest($result['upload_url'], ['file' => '@' . $filePath]), true); $this->timeout = $timeout; return $result['url']; diff --git a/lib/classes/Session/Logger.php b/lib/classes/Session/Logger.php index 7f1f2ed2b4..b1a46c5f25 100644 --- a/lib/classes/Session/Logger.php +++ b/lib/classes/Session/Logger.php @@ -74,13 +74,13 @@ class Session_Logger $stmt = $this->databox->get_connection()->prepare($sql); - $params = array( + $params = [ ':log_id' => $this->get_id() , ':record_id' => $record->get_record_id() , ':action' => $action , ':final' => $final , ':comm' => $comment - ); + ]; $stmt->execute($params); $stmt->closeCursor(); @@ -98,10 +98,10 @@ class Session_Logger */ public static function create(Application $app, databox $databox, Browser $browser) { - $colls = array(); + $colls = []; if ($app['authentication']->getUser()) { - $bases = $app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id())); + $bases = $app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]); foreach ($bases as $collection) { $colls[] = $collection->get_coll_id(); } @@ -118,7 +118,7 @@ class Session_Logger , :browser, :browser_version, :platform, :screen, :ip , :user_agent, :appli, :fonction, :company, :activity, :country)"; - $params = array( + $params = [ ':ses_id' => $app['session']->get('session_id'), ':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_login() : null, ':site_id' => $app['configuration']['main']['key'], @@ -129,12 +129,12 @@ class Session_Logger ':screen' => $browser->getScreenSize(), ':ip' => $browser->getIP(), ':user_agent' => $browser->getUserAgent(), - ':appli' => serialize(array()), + ':appli' => serialize([]), ':fonction' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_job() : null, ':company' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_company() : null, ':activity' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_position() : null, ':country' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_country() : null - ); + ]; $stmt = $conn->prepare($sql); $stmt->execute($params); @@ -145,10 +145,10 @@ class Session_Logger $stmt = $conn->prepare($sql); foreach ($colls as $collId) { - $stmt->execute(array( + $stmt->execute([ ':log_id' => $log_id, ':coll_id' => $collId - )); + ]); } $stmt->closeCursor(); @@ -166,10 +166,10 @@ class Session_Logger $sql = 'SELECT id FROM log WHERE site = :site AND sit_session = :ses_id'; - $params = array( + $params = [ ':site' => $app['configuration']['main']['key'] , ':ses_id' => $app['session']->get('session_id') - ); + ]; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute($params); @@ -211,7 +211,7 @@ class Session_Logger $user = User_Adapter::getInstance($usrId, $app); - $appName = array( + $appName = [ '1' => 'Prod', '2' => 'Client', '3' => 'Admin', @@ -221,7 +221,7 @@ class Session_Logger '7' => 'Validate', '8' => 'Upload', '9' => 'API' - ); + ]; if (isset($appName[$appId])) { $sbas_ids = array_keys($app['acl']->get($user)->get_granted_sbas()); @@ -233,7 +233,7 @@ class Session_Logger $connbas = connection::getPDOConnection($app, $sbas_id); $sql = 'SELECT appli FROM log WHERE id = :log_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':log_id' => $logger->get_id())); + $stmt->execute([':log_id' => $logger->get_id()]); $row3 = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -247,10 +247,10 @@ class Session_Logger $sql = 'UPDATE log SET appli = :applis WHERE id = :log_id'; - $params = array( + $params = [ ':applis' => serialize($applis) , ':log_id' => $logger->get_id() - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); diff --git a/lib/classes/Setup/Upgrade.php b/lib/classes/Setup/Upgrade.php index e45d85202f..0eec13f186 100644 --- a/lib/classes/Setup/Upgrade.php +++ b/lib/classes/Setup/Upgrade.php @@ -39,7 +39,7 @@ class Setup_Upgrade * * @var array */ - protected $recommendations = array(); + protected $recommendations = []; /** * @@ -135,7 +135,7 @@ class Setup_Upgrade */ public function addRecommendation($recommendation, $command = null) { - $this->recommendations[] = array($recommendation, $command); + $this->recommendations[] = [$recommendation, $command]; } /** @@ -171,13 +171,13 @@ class Setup_Upgrade $date_obj = new DateTime(); $dumper = new Symfony\Component\Yaml\Dumper(); $datas = $dumper->dump( - array( + [ 'percentage' => $this->get_percentage() , 'total_steps' => $this->total_steps , 'completed_steps' => $this->completed_steps , 'message' => $this->message , 'last_update' => $date_obj->format(DATE_ATOM) - ), 1 + ], 1 ); if (!file_put_contents(self::get_lock_file(), $datas)) @@ -241,14 +241,14 @@ class Setup_Upgrade { $active = self::lock_exists(); - $datas = array( + $datas = [ 'active' => $active , 'percentage' => 1 , 'total_steps' => 0 , 'completed_steps' => 0 , 'message' => null , 'last_update' => null - ); + ]; if ($active) { $parser = new Symfony\Component\Yaml\Parser(); diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php index 623c1cef43..8ee7e9e78f 100644 --- a/lib/classes/User/Adapter.php +++ b/lib/classes/User/Adapter.php @@ -32,44 +32,44 @@ class User_Adapter implements User_Interface, cache_cacheableInterface * * @var Array */ - public static $locales = array( + public static $locales = [ 'ar_SA' => 'العربية' , 'de_DE' => 'Deutsch' , 'nl_NL' => 'Dutch' , 'en_GB' => 'English' , 'es_ES' => 'Español' , 'fr_FR' => 'Français' - ); + ]; /** * * @var array */ - protected static $_instance = array(); + protected static $_instance = []; /** * * @var array */ - protected $_prefs = array(); + protected $_prefs = []; /** * * @var array */ - protected static $_users = array(); + protected static $_users = []; /** * * @var array */ - protected $_updated_prefs = array(); + protected $_updated_prefs = []; /** * * @var array */ - public static $def_values = array( + public static $def_values = [ 'view' => 'thumbs', 'images_per_page' => 20, 'images_size' => 120, @@ -91,21 +91,21 @@ class User_Adapter implements User_Interface, cache_cacheableInterface 'basket_caption_display' => '0', 'basket_status_display' => '0', 'basket_title_display' => '0' - ); + ]; /** * * @var array */ - protected static $available_values = array( - 'view' => array('thumbs', 'list'), - 'basket_sort_field' => array('name', 'date'), - 'basket_sort_order' => array('ASC', 'DESC'), - 'start_page' => array('PUBLI', 'QUERY', 'LAST_QUERY', 'HELP'), - 'technical_display' => array('0', '1', 'group'), - 'rollover_thumbnail' => array('caption', 'preview'), - 'bask_val_order' => array('nat', 'asc', 'desc') - ); + protected static $available_values = [ + 'view' => ['thumbs', 'list'], + 'basket_sort_field' => ['name', 'date'], + 'basket_sort_order' => ['ASC', 'DESC'], + 'start_page' => ['PUBLI', 'QUERY', 'LAST_QUERY', 'HELP'], + 'technical_display' => ['0', '1', 'group'], + 'rollover_thumbnail' => ['caption', 'preview'], + 'bask_val_order' => ['nat', 'asc', 'desc'] + ]; /** * @@ -362,7 +362,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $password = $this->app['auth.password-encoder']->encodePassword($pasword, $this->get_nonce()); $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':password' => $password, ':usr_id' => $this->get_id())); + $stmt->execute([':password' => $password, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->password = $password; @@ -389,7 +389,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET usr_mail = :new_email WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':new_email' => $email, ':usr_id' => $this->get_id())); + $stmt->execute([':new_email' => $email, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->email = $email; $this->delete_data_from_cache(); @@ -432,7 +432,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $conn = connection::getPDOConnection($app); $sql = 'SELECT usr_id FROM usr WHERE usr_login = :login'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':login' => trim($login))); + $stmt->execute([':login' => trim($login)]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -451,7 +451,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $value = $boolean ? '1' : '0'; $sql = 'UPDATE usr SET mail_notifications = :mail_notifications WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':mail_notifications' => $value, ':usr_id' => $this->get_id())); + $stmt->execute([':mail_notifications' => $value, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->mail_notifications = !!$boolean; $this->delete_data_from_cache(); @@ -469,7 +469,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $value = $boolean ? '1' : '0'; $sql = 'UPDATE usr SET ldap_created = :ldap_created WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':ldap_created' => $value, ':usr_id' => $this->get_id())); + $stmt->execute([':ldap_created' => $value, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->ldap_created = $boolean; @@ -480,7 +480,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET usr_prenom = :usr_prenom WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_prenom' => $firstname, ':usr_id' => $this->get_id())); + $stmt->execute([':usr_prenom' => $firstname, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->firstname = $firstname; $this->delete_data_from_cache(); @@ -492,7 +492,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET usr_nom = :usr_nom WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_nom' => $lastname, ':usr_id' => $this->get_id())); + $stmt->execute([':usr_nom' => $lastname, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->lastname = $lastname; $this->delete_data_from_cache(); @@ -504,7 +504,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET adresse = :adresse WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':adresse' => $address, ':usr_id' => $this->get_id())); + $stmt->execute([':adresse' => $address, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->address = $address; $this->delete_data_from_cache(); @@ -516,7 +516,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET ville = :city WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':city' => $city, ':usr_id' => $this->get_id())); + $stmt->execute([':city' => $city, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->city = $city; $this->delete_data_from_cache(); @@ -542,11 +542,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET geonameid = :geonameid, pays=:country_code WHERE usr_id = :usr_id'; - $datas = array( + $datas = [ ':geonameid' => $geonameid, ':usr_id' => $this->get_id(), ':country_code' => $country_code - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($datas); @@ -562,7 +562,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET cpostal = :cpostal WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':cpostal' => $zip, ':usr_id' => $this->get_id())); + $stmt->execute([':cpostal' => $zip, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->zip = $zip; $this->delete_data_from_cache(); @@ -574,7 +574,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET usr_sexe = :usr_sexe WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_sexe' => $gender, ':usr_id' => $this->get_id())); + $stmt->execute([':usr_sexe' => $gender, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->gender = $gender; $this->delete_data_from_cache(); @@ -586,7 +586,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET tel = :tel WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':tel' => $tel, ':usr_id' => $this->get_id())); + $stmt->execute([':tel' => $tel, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->tel = $tel; $this->delete_data_from_cache(); @@ -598,7 +598,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET fax = :fax WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':fax' => $fax, ':usr_id' => $this->get_id())); + $stmt->execute([':fax' => $fax, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->fax = $fax; $this->delete_data_from_cache(); @@ -610,7 +610,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET fonction = :fonction WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':fonction' => $job, ':usr_id' => $this->get_id())); + $stmt->execute([':fonction' => $job, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->job = $job; $this->delete_data_from_cache(); @@ -622,7 +622,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET activite = :activite WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':activite' => $position, ':usr_id' => $this->get_id())); + $stmt->execute([':activite' => $position, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->position = $position; $this->delete_data_from_cache(); @@ -634,7 +634,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET societe = :company WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':company' => $company, ':usr_id' => $this->get_id())); + $stmt->execute([':company' => $company, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->company = $company; $this->delete_data_from_cache(); @@ -652,7 +652,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET model_of = :owner_id WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id())); + $stmt->execute([':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this @@ -687,9 +687,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function getFtpCredential() { if (null === $this->ftpCredential) { - $this->ftpCredential = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FtpCredential')->findOneBy(array( + $this->ftpCredential = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FtpCredential')->findOneBy([ 'usrId' => $this->get_id() - )); + ]); if (null === $this->ftpCredential) { $this->ftpCredential = new FtpCredential(); @@ -707,7 +707,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function is_special() { - return in_array($this->login, array('invite', 'autoregister')); + return in_array($this->login, ['invite', 'autoregister']); } public function get_template_owner() @@ -727,7 +727,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface AND usr_login NOT LIKE "(#deleted_%" AND invite="0" AND usr_login != "autoregister"'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':email' => trim($email))); + $stmt->execute([':email' => trim($email)]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -762,42 +762,42 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET usr_login = :usr_login , usr_mail = null WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_login' => '(#deleted_' . $this->get_login() . '_' . $this->get_id(), ':usr_id' => $this->get_id())); + $stmt->execute([':usr_login' => '(#deleted_' . $this->get_login() . '_' . $this->get_id(), ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM basusr WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM sbasusr WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM dsel WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM edit_presets WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM sselnew WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM tokens WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); $sql = 'DELETE FROM usr_settings WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $stmt->closeCursor(); unset(self::$_instance[$this->get_id()]); @@ -823,7 +823,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface FROM usr WHERE usr_id= :id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $id)); + $stmt->execute([':id' => $id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -876,10 +876,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET lastModel = :template_id WHERE usr_id = :usr_id'; - $params = array( + $params = [ ':usr_id' => $this->get_id() , ':template_id' => $template->get_login() - ); + ]; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -893,7 +893,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface { $sql = 'UPDATE usr SET mail_locked = :mail_locked WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id(), ':mail_locked' => ($boolean ? '1' : '0'))); + $stmt->execute([':usr_id' => $this->get_id(), ':mail_locked' => ($boolean ? '1' : '0')]); $stmt->closeCursor(); $this->mail_locked = !!$boolean; @@ -1005,7 +1005,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); @@ -1039,7 +1039,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -1136,11 +1136,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface VALUES (:usr_id, :prop, :value)'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':usr_id' => $this->id, ':prop' => $prop, ':value' => $value - )); + ]); $this->delete_data_from_cache(); } catch (Exception $e) { @@ -1217,7 +1217,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $users = array(); + $users = []; foreach ($rs as $row) $users[$row['usr_id']] = $row['usr_login']; @@ -1230,7 +1230,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface try { $sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id"; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id())); + $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]); $stmt->closeCursor(); $sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")"; @@ -1259,7 +1259,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET locale = :locale WHERE usr_id = :usr_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':locale' => $locale, ':usr_id' => $this->get_id())); + $stmt->execute([':locale' => $locale, ':usr_id' => $this->get_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -1293,14 +1293,14 @@ class User_Adapter implements User_Interface, cache_cacheableInterface VALUES (null, :login, :password, NOW(), :email, :admin, :nonce, 1, :invite)'; $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':login' => $login, ':nonce' => $nonce, ':password' => $app['auth.password-encoder']->encodePassword($password, $nonce), ':email' => ($email ? $email : null), ':admin' => ($admin ? '1' : '0'), ':invite' => ($invite ? '1' : '0') - )); + ]); $stmt->closeCursor(); $usr_id = $conn->lastInsertId(); @@ -1314,7 +1314,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'UPDATE usr SET usr_login = :login WHERE usr_id = :usr_id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':login' => 'invite'.$usr_id, ':usr_id' => $usr_id)); + $stmt->execute([':login' => 'invite'.$usr_id, ':usr_id' => $usr_id]); $stmt->closeCursor(); } @@ -1333,7 +1333,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface $sql = 'SELECT nonce FROM usr WHERE usr_id = :usr_id '; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $this->get_id())); + $stmt->execute([':usr_id' => $this->get_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); unset($stmt); @@ -1347,9 +1347,9 @@ class User_Adapter implements User_Interface, cache_cacheableInterface public function __sleep() { - $vars = array(); + $vars = []; foreach ($this as $key => $value) { - if (in_array($key, array('ACL', 'app'))) + if (in_array($key, ['ACL', 'app'])) continue; $vars[] = $key; } diff --git a/lib/classes/User/Query.php b/lib/classes/User/Query.php index f196a1b7c1..b33d7d4671 100644 --- a/lib/classes/User/Query.php +++ b/lib/classes/User/Query.php @@ -30,19 +30,19 @@ class User_Query implements User_QueryInterface * * @var Array */ - protected $results = array(); + protected $results = []; /** * * @var Array */ - protected $sort = array(); + protected $sort = []; /** * * @var Array */ - protected $like_field = array(); + protected $like_field = []; /** * @@ -78,13 +78,13 @@ class User_Query implements User_QueryInterface * * @var Array */ - protected $active_bases = array(); + protected $active_bases = []; /** * * @var Array */ - protected $active_sbas = array(); + protected $active_sbas = []; /** * @@ -120,13 +120,13 @@ class User_Query implements User_QueryInterface * * @var Array */ - protected $base_ids = array(); + protected $base_ids = []; /** * * @var Array */ - protected $sbas_ids = array(); + protected $sbas_ids = []; /** * @@ -211,7 +211,7 @@ class User_Query implements User_QueryInterface */ protected function generate_sql_constraints() { - $this->sql_params = array(); + $this->sql_params = []; $sql = ' FROM usr LEFT JOIN basusr ON (usr.usr_id = basusr.usr_id) @@ -324,12 +324,12 @@ class User_Query implements User_QueryInterface $sql .= ' AND usr.lastModel = "' . mysql_real_escape_string($this->last_model) . '" '; } - $sql_like = array(); + $sql_like = []; foreach ($this->like_field as $like_field => $like_value) { switch ($like_field) { case self::LIKE_NAME: - $qrys = array(); + $qrys = []; foreach (explode(' ', $like_value) as $like_val) { if (trim($like_val) === '') continue; @@ -338,9 +338,9 @@ class User_Query implements User_QueryInterface ' (usr.`%s` LIKE "%s%%" COLLATE utf8_unicode_ci OR usr.`%s` LIKE "%s%%" COLLATE utf8_unicode_ci) ' , self::LIKE_FIRSTNAME - , str_replace(array('"', '%'), array('\"', '\%'), $like_val) + , str_replace(['"', '%'], ['\"', '\%'], $like_val) , self::LIKE_LASTNAME - , str_replace(array('"', '%'), array('\"', '\%'), $like_val) + , str_replace(['"', '%'], ['\"', '\%'], $like_val) ); } @@ -357,7 +357,7 @@ class User_Query implements User_QueryInterface $sql_like[] = sprintf( ' usr.`%s` LIKE "%s%%" COLLATE utf8_unicode_ci ' , $like_field - , str_replace(array('"', '%'), array('\"', '\%'), $like_value) + , str_replace(['"', '%'], ['\"', '\%'], $like_value) ); break; default; @@ -374,7 +374,7 @@ class User_Query implements User_QueryInterface protected function generate_field_constraints($fieldName, ArrayCollection $fields) { $n = 0; - $constraints = array(); + $constraints = []; foreach ($fields as $field) { $constraints[':' . $fieldName . $n ++] = $field; @@ -389,7 +389,7 @@ class User_Query implements User_QueryInterface public function in(array $usr_ids) { - $tmp_usr_ids = array(); + $tmp_usr_ids = []; foreach ($usr_ids as $usr_id) { $tmp_usr_ids[] = (int) $usr_id; @@ -889,7 +889,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $activities = array(); + $activities = []; foreach ($rs as $row) { if (trim($row['activite']) === '') @@ -914,7 +914,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $fonction = array(); + $fonction = []; foreach ($rs as $row) { if (trim($row['fonction']) === '') @@ -941,7 +941,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $pays = array(); + $pays = []; $ctry = \getCountries($this->app['locale']); @@ -969,7 +969,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $societe = array(); + $societe = []; foreach ($rs as $row) { if (trim($row['societe']) === '') @@ -994,7 +994,7 @@ class User_Query implements User_QueryInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $lastModel = array(); + $lastModel = []; foreach ($rs as $row) { if (trim($row['lastModel']) === '') @@ -1008,7 +1008,7 @@ class User_Query implements User_QueryInterface private function generate_sort_constraint() { - $sorter = array(); + $sorter = []; foreach ($this->sort as $sort => $ord) { diff --git a/lib/classes/appbox.php b/lib/classes/appbox.php index a473fce36e..9120f2252c 100644 --- a/lib/classes/appbox.php +++ b/lib/classes/appbox.php @@ -82,7 +82,7 @@ class appbox extends base if (!is_null($pathfile)) { - if (!in_array(mb_strtolower($pathfile->getMimeType()), array('image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'))) { + if (!in_array(mb_strtolower($pathfile->getMimeType()), ['image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'])) { throw new \InvalidArgumentException('Invalid file format'); } @@ -146,7 +146,7 @@ class appbox extends base $file = $this->app['root.path'] . '/config/' . $pic_type . '/' . $collection->get_base_id(); $custom_path = $this->app['root.path'] . '/www/custom/' . $pic_type . '/' . $collection->get_base_id(); - foreach (array($file, $custom_path) as $target) { + foreach ([$file, $custom_path] as $target) { if (is_file($target)) { @@ -171,12 +171,12 @@ class appbox extends base if (!is_null($pathfile)) { - if (!in_array(mb_strtolower($pathfile->getMimeType()), array('image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png', 'image/gif'))) { + if (!in_array(mb_strtolower($pathfile->getMimeType()), ['image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png', 'image/gif'])) { throw new \InvalidArgumentException('Invalid file format'); } } - if (!in_array($pic_type, array(databox::PIC_PDF))) { + if (!in_array($pic_type, [databox::PIC_PDF])) { throw new \InvalidArgumentException('unknown pic_type'); } @@ -201,7 +201,7 @@ class appbox extends base $file = $this->app['root.path'] . '/config/minilogos/' . $pic_type . '_' . $databox->get_sbas_id() . '.jpg'; $custom_path = $this->app['root.path'] . '/www/custom/minilogos/' . $pic_type . '_' . $databox->get_sbas_id() . '.jpg'; - foreach (array($file, $custom_path) as $target) { + foreach ([$file, $custom_path] as $target) { if (is_file($target)) { $filesystem->remove($target); @@ -231,7 +231,7 @@ class appbox extends base { $sqlupd = "UPDATE bas SET ord = :ordre WHERE base_id = :base_id"; $stmt = $this->get_connection()->prepare($sqlupd); - $stmt->execute(array(':ordre' => $ordre, ':base_id' => $collection->get_base_id())); + $stmt->execute([':ordre' => $ordre, ':base_id' => $collection->get_base_id()]); $stmt->closeCursor(); $collection->get_databox()->delete_data_from_cache(\databox::CACHE_COLLECTIONS); @@ -251,10 +251,10 @@ class appbox extends base $sql = 'UPDATE sbas SET indexable = :indexable WHERE sbas_id = :sbas_id'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':indexable' => ($boolean ? '1' : '0'), ':sbas_id' => $databox->get_sbas_id() - )); + ]); $stmt->closeCursor(); return $this; @@ -270,7 +270,7 @@ class appbox extends base $sql = 'SELECT indexable FROM sbas WHERE sbas_id = :sbas_id'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':sbas_id' => $databox->get_sbas_id())); + $stmt->execute([':sbas_id' => $databox->get_sbas_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -322,13 +322,13 @@ class appbox extends base $upgrader->set_current_message(_('Purging directories')); $finder = new Finder(); - $finder->in(array( + $finder->in([ $this->app['root.path'] . '/tmp/cache_minify/', $this->app['root.path'] . '/tmp/cache_twig/', $this->app['root.path'] . '/tmp/cache/profiler/', $this->app['root.path'] . '/tmp/doctrine/', $this->app['root.path'] . '/tmp/serializer/', - )) + ]) ->depth(0) ->ignoreVCS(true) ->ignoreDotFiles(true); @@ -344,19 +344,19 @@ class appbox extends base */ $upgrader->set_current_message(_('Copying files')); - foreach (array( + foreach ([ 'config/custom_files/' => 'www/custom/', 'config/minilogos/' => 'www/custom/minilogos/', 'config/stamp/' => 'www/custom/stamp/', 'config/status/' => 'www/custom/status/', 'config/wm/' => 'www/custom/wm/', - ) as $source => $target) { + ] as $source => $target) { $app['filesystem']->mirror($this->app['root.path'] . '/' . $source, $this->app['root.path'] . '/' . $target); } $upgrader->add_steps_complete(1); - $advices = array(); + $advices = []; /** * Step 6 @@ -430,7 +430,7 @@ class appbox extends base return $this->databoxes; } - $ret = array(); + $ret = []; foreach ($this->retrieve_sbas_ids() as $sbas_id) { try { $ret[$sbas_id] = new \databox($this->app, $sbas_id); @@ -453,7 +453,7 @@ class appbox extends base } $sql = 'SELECT sbas_id FROM sbas'; - $ret = array(); + $ret = []; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); diff --git a/lib/classes/appbox/register.php b/lib/classes/appbox/register.php index 444cb0f0c0..ed43889d33 100644 --- a/lib/classes/appbox/register.php +++ b/lib/classes/appbox/register.php @@ -51,7 +51,7 @@ class appbox_register $sql = "INSERT INTO demand (date_modif, usr_id, base_id, en_cours, refuser) VALUES (now(), :usr_id , :base_id, 1, 0)"; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id(), ':base_id' => $collection->get_base_id())); + $stmt->execute([':usr_id' => $user->get_id(), ':base_id' => $collection->get_base_id()]); $stmt->closeCursor(); return $this; @@ -70,10 +70,10 @@ class appbox_register { $sql = 'SELECT base_id FROM demand WHERE usr_id = :usr_id AND en_cours="1" '; $stmt = $this->appbox->get_connection()->prepare($sql); - $stmt->execute(array(':usr_id' => $user->get_id())); + $stmt->execute([':usr_id' => $user->get_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $ret[] = collection::get_from_base_id($app, $row['base_id']); } @@ -92,7 +92,7 @@ class appbox_register $lastMonth = new DateTime('-1 month'); $sql = "delete from demand where date_modif < :lastMonth"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':lastMonth' => $lastMonth->format(DATE_ISO8601))); + $stmt->execute([':lastMonth' => $lastMonth->format(DATE_ISO8601)]); $stmt->closeCursor(); return; diff --git a/lib/classes/base.php b/lib/classes/base.php index a6d06cd5d1..e68298a654 100644 --- a/lib/classes/base.php +++ b/lib/classes/base.php @@ -190,7 +190,7 @@ abstract class base implements cache_cacheableInterface { $appbox = $this->get_base_type() == self::APPLICATION_BOX ? $this : $this->get_appbox(); if ($option === appbox::CACHE_LIST_BASES) { - $keys = array($this->get_cache_key(appbox::CACHE_LIST_BASES)); + $keys = [$this->get_cache_key(appbox::CACHE_LIST_BASES)]; phrasea::reset_sbasDatas($appbox); phrasea::reset_baseDatas($appbox); phrasea::clear_sbas_params($this->app); @@ -244,9 +244,9 @@ abstract class base implements cache_cacheableInterface protected function upgradeDb($apply_patches, Setup_Upgrade $upgrader, Application $app) { - $recommends = array(); + $recommends = []; - $allTables = array(); + $allTables = []; $schema = $this->get_schema(); @@ -262,7 +262,7 @@ abstract class base implements cache_cacheableInterface $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ORMTables = array( + $ORMTables = [ 'AuthFailures', 'AggregateTokens', 'BasketElements', @@ -296,7 +296,7 @@ abstract class base implements cache_cacheableInterface 'UserSettings', 'Users', 'UserNotificationSettings', - ); + ]; foreach ($rs as $row) { $tname = $row["Name"]; @@ -306,17 +306,17 @@ abstract class base implements cache_cacheableInterface $engine = strtolower(trim($allTables[$tname]->engine)); $ref_engine = strtolower($row['Engine']); - if ($engine != $ref_engine && in_array($engine, array('innodb', 'myisam'))) { + if ($engine != $ref_engine && in_array($engine, ['innodb', 'myisam'])) { $sql = 'ALTER TABLE `' . $tname . '` ENGINE = ' . $engine; try { $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); } catch (Exception $e) { - $recommends[] = array( + $recommends[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $sql - ); + ]; } } @@ -325,10 +325,10 @@ abstract class base implements cache_cacheableInterface unset($allTables[$tname]); $upgrader->add_steps_complete(1); } elseif ( ! in_array($tname, $ORMTables)) { - $recommends[] = array( + $recommends[] = [ 'message' => 'Une table pourrait etre supprime', 'sql' => 'DROP TABLE ' . $this->dbname . '.`' . $tname . '`;' - ); + ]; } } @@ -361,7 +361,7 @@ abstract class base implements cache_cacheableInterface } if ($sql !== '') { $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':version' => $version->getNumber())); + $stmt->execute([':version' => $version->getNumber()]); $stmt->closeCursor(); $this->version = $version->getNumber(); @@ -423,7 +423,7 @@ abstract class base implements cache_cacheableInterface */ protected function createTable(SimpleXMLElement $table) { - $field_stmt = $defaults_stmt = array(); + $field_stmt = $defaults_stmt = []; $create_stmt = "CREATE TABLE `" . $table['name'] . "` ("; @@ -438,9 +438,9 @@ abstract class base implements cache_cacheableInterface $is_default = ''; $character_set = ''; - if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext')) + if (in_array(strtolower((string) $field->type), ['text', 'longtext', 'mediumtext', 'tinytext']) || substr(strtolower((string) $field->type), 0, 7) == 'varchar' - || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) { + || in_array(substr(strtolower((string) $field->type), 0, 4), ['char', 'enum'])) { $collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci'; @@ -459,7 +459,7 @@ abstract class base implements cache_cacheableInterface foreach ($table->indexes->index as $index) { switch ($index->type) { case "PRIMARY": - $primary_fields = array(); + $primary_fields = []; foreach ($index->fields->field as $field) { $primary_fields[] = "`" . $field . "`"; @@ -468,7 +468,7 @@ abstract class base implements cache_cacheableInterface $field_stmt[] = 'PRIMARY KEY (' . implode(',', $primary_fields) . ')'; break; case "UNIQUE": - $unique_fields = array(); + $unique_fields = []; foreach ($index->fields->field as $field) { $unique_fields[] = "`" . $field . "`"; @@ -477,7 +477,7 @@ abstract class base implements cache_cacheableInterface $field_stmt[] = 'UNIQUE KEY `' . $index->name . '` (' . implode(',', $unique_fields) . ')'; break; case "INDEX": - $index_fields = array(); + $index_fields = []; foreach ($index->fields->field as $field) { $index_fields[] = "`" . $field . "`"; @@ -490,7 +490,7 @@ abstract class base implements cache_cacheableInterface } if ($table->defaults) { foreach ($table->defaults->default as $default) { - $k = $v = $params = $dates_values = array(); + $k = $v = $params = $dates_values = []; $nonce = random::generatePassword(16); foreach ($default->data as $data) { $k = trim($data['key']); @@ -498,7 +498,7 @@ abstract class base implements cache_cacheableInterface $data = $this->app['auth.password-encoder']->encodePassword($data, $nonce); if ($k === 'nonce') $data = $nonce; - $v = trim(str_replace(array("\r\n", "\r", "\n", "\t"), '', $data)); + $v = trim(str_replace(["\r\n", "\r", "\n", "\t"], '', $data)); if (trim(mb_strtolower($v)) == 'now()') $dates_values [$k] = 'NOW()'; @@ -508,19 +508,19 @@ abstract class base implements cache_cacheableInterface $separator = ((count($params) > 0 && count($dates_values) > 0) ? ', ' : ''); - $defaults_stmt[] = array( + $defaults_stmt[] = [ 'sql' => 'INSERT INTO `' . $table['name'] . '` (' . implode(', ', array_keys($params)) . $separator . implode(', ', array_keys($dates_values)) . ') VALUES (:' . implode(', :', array_keys($params)) . $separator . implode(', ', array_values($dates_values)) . ') ' , 'params' => $params - ); + ]; } } $engine = mb_strtolower(trim($table->engine)); - $engine = in_array($engine, array('innodb', 'myisam')) ? $engine : 'innodb'; + $engine = in_array($engine, ['innodb', 'myisam']) ? $engine : 'innodb'; $create_stmt .= implode(',', $field_stmt); $create_stmt .= ") ENGINE=" . $engine . " CHARACTER SET utf8 COLLATE utf8_unicode_ci;"; @@ -535,10 +535,10 @@ abstract class base implements cache_cacheableInterface $stmt->execute($def['params']); $stmt->closeCursor(); } catch (Exception $e) { - $recommends[] = array( + $recommends[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $def['sql'] - ); + ]; } } @@ -547,8 +547,8 @@ abstract class base implements cache_cacheableInterface protected function upgradeTable(SimpleXMLElement $table) { - $correct_table = array('fields' => array(), 'indexes' => array(), 'collation' => array()); - $alter = $alter_pre = $return = array(); + $correct_table = ['fields' => [], 'indexes' => [], 'collation' => []]; + $alter = $alter_pre = $return = []; foreach ($table->fields->field as $field) { $expr = trim((string) $field->type); @@ -559,9 +559,9 @@ abstract class base implements cache_cacheableInterface $collation = trim((string) $field->collation) != '' ? trim((string) $field->collation) : 'utf8_unicode_ci'; - if (in_array(strtolower((string) $field->type), array('text', 'longtext', 'mediumtext', 'tinytext')) + if (in_array(strtolower((string) $field->type), ['text', 'longtext', 'mediumtext', 'tinytext']) || substr(strtolower((string) $field->type), 0, 7) == 'varchar' - || in_array(substr(strtolower((string) $field->type), 0, 4), array('char', 'enum'))) { + || in_array(substr(strtolower((string) $field->type), 0, 4), ['char', 'enum'])) { $collations = array_reverse(explode('_', $collation)); $code = array_pop($collations); @@ -587,7 +587,7 @@ abstract class base implements cache_cacheableInterface if ($table->indexes) { foreach ($table->indexes->index as $index) { $i_name = (string) $index->name; - $expr = array(); + $expr = []; foreach ($index->fields->field as $field) $expr[] = '`' . trim((string) $field) . '`'; @@ -682,10 +682,10 @@ abstract class base implements cache_cacheableInterface } unset($correct_table['fields'][$f_name]); } else { - $return[] = array( + $return[] = [ 'message' => 'Un champ pourrait etre supprime', 'sql' => "ALTER TABLE " . $this->dbname . ".`" . $table['name'] . "` DROP `$f_name`;" - ); + ]; } } @@ -693,7 +693,7 @@ abstract class base implements cache_cacheableInterface $alter[] = "ALTER TABLE `" . $table['name'] . "` ADD `$f_name` " . $correct_table['fields'][$f_name]; } - $tIndex = array(); + $tIndex = []; $sql = "SHOW INDEXES FROM `" . $table['name'] . "`"; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); @@ -702,12 +702,12 @@ abstract class base implements cache_cacheableInterface foreach ($rs2 as $row2) { if ( ! isset($tIndex[$row2['Key_name']])) - $tIndex[$row2['Key_name']] = array('unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => array()); + $tIndex[$row2['Key_name']] = ['unique' => ((int) ($row2['Non_unique']) == 0), 'columns' => []]; $tIndex[$row2['Key_name']]['columns'][(int) ($row2['Seq_in_index'])] = $row2['Column_name']; } foreach ($tIndex as $kIndex => $vIndex) { - $strColumns = array(); + $strColumns = []; foreach ($vIndex['columns'] as $column) $strColumns[] = '`' . $column . '`'; @@ -733,10 +733,10 @@ abstract class base implements cache_cacheableInterface unset($correct_table['indexes'][$kIndex]); } else { - $return[] = array( + $return[] = [ 'message' => 'Un index pourrait etre supprime', 'sql' => 'ALTER TABLE ' . $this->dbname . '.`' . $table['name'] . '` DROP ' . $full_name_index . ';' - ); + ]; } } @@ -749,10 +749,10 @@ abstract class base implements cache_cacheableInterface $stmt->execute(); $stmt->closeCursor(); } catch (Exception $e) { - $return[] = array( + $return[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $a - ); + ]; } } @@ -762,10 +762,10 @@ abstract class base implements cache_cacheableInterface $stmt->execute(); $stmt->closeCursor(); } catch (Exception $e) { - $return[] = array( + $return[] = [ 'message' => sprintf(_('Erreur lors de la tentative ; errreur : %s'), $e->getMessage()), 'sql' => $a - ); + ]; } } @@ -778,7 +778,7 @@ abstract class base implements cache_cacheableInterface return true; } - $list_patches = array(); + $list_patches = []; $upgrader->add_steps(1)->set_current_message(_('Looking for patches')); diff --git a/lib/classes/cache/databox.php b/lib/classes/cache/databox.php index 8275df3f97..7ec25c2461 100644 --- a/lib/classes/cache/databox.php +++ b/lib/classes/cache/databox.php @@ -62,7 +62,7 @@ class cache_databox $sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id'; $stmt = $connsbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -89,10 +89,10 @@ class cache_databox $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="record" AND value = :value'; - $params = array( + $params = [ ':site_id' => $app['phraseanet.registry']->get('GV_ServerName') , ':value' => $row['value'] - ); + ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); @@ -113,10 +113,10 @@ class cache_databox $sql = 'DELETE FROM memcached WHERE site_id = :site_id AND type="structure" AND value = :value'; - $params = array( + $params = [ ':site_id' => $app['phraseanet.registry']->get('GV_ServerName') , ':value' => $row['value'] - ); + ]; $stmt = $connsbas->prepare($sql); $stmt->execute($params); @@ -134,7 +134,7 @@ class cache_databox $sql = 'UPDATE sitepreff SET memcached_update = :date'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':date' => $now)); + $stmt->execute([':date' => $now]); $stmt->closeCursor(); self::$refreshing = false; @@ -158,7 +158,7 @@ class cache_databox WHERE site_id != :site_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -168,7 +168,7 @@ class cache_databox $stmt = $connbas->prepare($sql); foreach ($rs as $row) { - $stmt->execute(array(':site_id' => $row['site_id'], ':type' => $type, ':value' => $value)); + $stmt->execute([':site_id' => $row['site_id'], ':type' => $type, ':value' => $value]); } $stmt->closeCursor(); @@ -182,7 +182,7 @@ class cache_databox $sql = 'SELECT site_id FROM clients WHERE site_id = :site_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $rowCount = $stmt->rowCount(); $stmt->closeCursor(); @@ -192,7 +192,7 @@ class cache_databox $sql = 'INSERT INTO clients (site_id) VALUES (:site_id)'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':site_id' => $app['phraseanet.registry']->get('GV_ServerName'))); + $stmt->execute([':site_id' => $app['phraseanet.registry']->get('GV_ServerName')]); $stmt->closeCursor(); return; diff --git a/lib/classes/caption/Field/Value.php b/lib/classes/caption/Field/Value.php index b1722c1632..af9190449d 100644 --- a/lib/classes/caption/Field/Value.php +++ b/lib/classes/caption/Field/Value.php @@ -56,7 +56,7 @@ class caption_Field_Value implements cache_cacheableInterface protected $record; protected $app; - protected static $localCache = array(); + protected static $localCache = []; /** * @@ -96,7 +96,7 @@ class caption_Field_Value implements cache_cacheableInterface FROM metadatas WHERE id = :id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -133,11 +133,11 @@ class caption_Field_Value implements cache_cacheableInterface } } - $datas = array( + $datas = [ 'value' => $this->value, 'vocabularyId' => $this->VocabularyId, 'vocabularyType' => $this->VocabularyType ? $this->VocabularyType->getType() : null, - ); + ]; $this->set_data_to_cache($datas); @@ -185,7 +185,7 @@ class caption_Field_Value implements cache_cacheableInterface $sql = 'DELETE FROM metadatas WHERE id = :id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':id' => $this->id)); + $stmt->execute([':id' => $this->id]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -200,11 +200,11 @@ class caption_Field_Value implements cache_cacheableInterface { $connbas = $this->databox_field->get_connection(); - $params = array( + $params = [ ':VocabType' => null , ':VocabularyId' => null , ':meta_id' => $this->getId() - ); + ]; $sql_up = 'UPDATE metadatas SET VocabularyType = :VocabType, VocabularyId = :VocabularyId @@ -224,11 +224,11 @@ class caption_Field_Value implements cache_cacheableInterface { $connbas = $this->databox_field->get_connection(); - $params = array( + $params = [ ':VocabType' => $vocabulary->getType() , ':VocabularyId' => $vocab_id , ':meta_id' => $this->getId() - ); + ]; $sql_up = 'UPDATE metadatas SET VocabularyType = :VocabType, VocabularyId = :VocabularyId @@ -248,10 +248,10 @@ class caption_Field_Value implements cache_cacheableInterface $connbas = $this->databox_field->get_connection(); - $params = array( + $params = [ ':meta_id' => $this->id , ':value' => $value - ); + ]; $sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id'; $stmt_up = $connbas->prepare($sql_up); @@ -309,13 +309,13 @@ class caption_Field_Value implements cache_cacheableInterface VALUES (null, :record_id, :field, :value, :VocabType, :VocabId)'; - $params = array( + $params = [ ':record_id' => $record->get_record_id(), ':field' => $databox_field->get_id(), ':value' => $value, ':VocabType' => $vocabulary ? $vocabulary->getType() : null, ':VocabId' => $vocabulary ? $vocabularyId : null, - ); + ]; $stmt_ins = $connbas->prepare($sql_ins); $stmt_ins->execute($params); @@ -355,7 +355,7 @@ class caption_Field_Value implements cache_cacheableInterface $fvalue = $value; - $cleanvalue = str_replace(array("", "", "'"), array("", "", "'"), $fvalue); + $cleanvalue = str_replace(["", "", "'"], ["", "", "'"], $fvalue); list($term_noacc, $context_noacc) = $this->splitTermAndContext($cleanvalue); $term_noacc = $this->app['unicode']->remove_indexer_chars($term_noacc); @@ -375,8 +375,8 @@ class caption_Field_Value implements cache_cacheableInterface if ($node->getAttribute("lng") == $this->app['locale.I18n']) { // le terme est dans la bonne langue, on le rend cliquable list($term, $context) = $this->splitTermAndContext($fvalue); - $term = str_replace(array("", ""), array("", ""), $term); - $context = str_replace(array("", ""), array("", ""), $context); + $term = str_replace(["", ""], ["", ""], $term); + $context = str_replace(["", ""], ["", ""], $context); $qjs = $term; if ($context) { $qjs .= " [" . $context . "]"; @@ -400,8 +400,8 @@ class caption_Field_Value implements cache_cacheableInterface } if (! $lngfound) { list($term, $context) = $this->splitTermAndContext($fvalue); - $term = str_replace(array("", ""), array("", ""), $term); - $context = str_replace(array("", ""), array("", ""), $context); + $term = str_replace(["", ""], ["", ""], $term); + $context = str_replace(["", ""], ["", ""], $context); $qjs = $term; if ($context) { $qjs .= " [" . $context . "]"; @@ -439,7 +439,7 @@ class caption_Field_Value implements cache_cacheableInterface } } - return array($term, $context); + return [$term, $context]; } /** diff --git a/lib/classes/caption/field.php b/lib/classes/caption/field.php index b3cd6299a2..7bacd1d696 100644 --- a/lib/classes/caption/field.php +++ b/lib/classes/caption/field.php @@ -38,7 +38,7 @@ class caption_field implements cache_cacheableInterface protected $record; protected $app; - protected static $localCache = array(); + protected static $localCache = []; /** * @@ -53,7 +53,7 @@ class caption_field implements cache_cacheableInterface $this->app = $app; $this->record = $record; $this->databox_field = $databox_field; - $this->values = array(); + $this->values = []; $rs = $this->get_metadatas_ids(); @@ -85,10 +85,10 @@ class caption_field implements cache_cacheableInterface WHERE record_id = :record_id AND meta_struct_id = :meta_struct_id'; - $params = array( + $params = [ ':record_id' => $this->record->get_record_id() , ':meta_struct_id' => $this->databox_field->get_id() - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -166,7 +166,7 @@ class caption_field implements cache_cacheableInterface else $separator = ' ' . $separator . ' '; - $array_values = array(); + $array_values = []; foreach ($values as $value) { if ($highlight) @@ -281,7 +281,7 @@ class caption_field implements cache_cacheableInterface */ public static function get_multi_values($serialized_value, $separator) { - $values = array(); + $values = []; if (strlen($separator) == 1) { $values = explode($separator, $serialized_value); } else { @@ -304,9 +304,9 @@ class caption_field implements cache_cacheableInterface $sql = 'SELECT count(id) as count_id FROM metadatas WHERE meta_struct_id = :meta_struct_id'; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt->execute($params); $rowcount = $stmt->rowCount(); @@ -319,9 +319,9 @@ class caption_field implements cache_cacheableInterface $sql = 'SELECT record_id, id FROM metadatas WHERE meta_struct_id = :meta_struct_id LIMIT ' . $n . ', ' . $increment; - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -333,7 +333,7 @@ class caption_field implements cache_cacheableInterface foreach ($rs as $row) { try { $record = $databox_field->get_databox()->get_record($row['record_id']); - $record->set_metadatas(array()); + $record->set_metadatas([]); /** * TODO NEUTRON add App @@ -357,9 +357,9 @@ class caption_field implements cache_cacheableInterface WHERE meta_struct_id = :meta_struct_id'; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt->execute($params); $rowcount = $stmt->rowCount(); @@ -373,9 +373,9 @@ class caption_field implements cache_cacheableInterface WHERE meta_struct_id = :meta_struct_id LIMIT ' . $n . ', ' . $increment; - $params = array( + $params = [ ':meta_struct_id' => $databox_field->get_id() - ); + ]; $stmt = $databox_field->get_databox()->get_connection()->prepare($sql); $stmt->execute($params); @@ -389,7 +389,7 @@ class caption_field implements cache_cacheableInterface $record = $databox_field->get_databox()->get_record($row['record_id']); $caption_field = new caption_field($app, $databox_field, $record); $caption_field->delete(); - $record->set_metadatas(array()); + $record->set_metadatas([]); $app['phraseanet.SE']->updateRecord($record); unset($caption_field); diff --git a/lib/classes/caption/record.php b/lib/classes/caption/record.php index 2cd0253a34..b025f0937e 100644 --- a/lib/classes/caption/record.php +++ b/lib/classes/caption/record.php @@ -95,13 +95,13 @@ class caption_record implements caption_interface, cache_cacheableInterface protected function toArray($includeBusinessFields) { - $buffer = array(); + $buffer = []; - foreach ($this->get_fields(array(), $includeBusinessFields) as $field) { + foreach ($this->get_fields([], $includeBusinessFields) as $field) { $vi = $field->get_values(); if ($field->is_multi()) { - $buffer[$field->get_name()] = array(); + $buffer[$field->get_name()] = []; foreach ($vi as $value) { $val = $value->getValue(); $buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $this->sanitizeSerializedValue($val); @@ -113,7 +113,7 @@ class caption_record implements caption_interface, cache_cacheableInterface } } - return array('record' => array('description' => $buffer)); + return ['record' => ['description' => $buffer]]; } protected function serializeXML($includeBusinessFields) @@ -128,7 +128,7 @@ class caption_record implements caption_interface, cache_cacheableInterface $description = $dom_doc->createElement('description'); $record->appendChild($description); - foreach ($this->get_fields(array(), $includeBusinessFields) as $field) { + foreach ($this->get_fields([], $includeBusinessFields) as $field) { $values = $field->get_values(); foreach ($values as $value) { @@ -155,7 +155,7 @@ class caption_record implements caption_interface, cache_cacheableInterface private function sanitizeSerializedValue($value) { - return str_replace(array( + return str_replace([ "\x00", //null "\x01", //start heading "\x02", //start text @@ -184,7 +184,7 @@ class caption_record implements caption_interface, cache_cacheableInterface "\x1D", //group sep "\x1E", //record sep "\x1F", //unit sep - ), '', $value); + ], '', $value); } protected function retrieve_fields() @@ -193,7 +193,7 @@ class caption_record implements caption_interface, cache_cacheableInterface return $this->fields; } - $fields = array(); + $fields = []; try { $fields = $this->get_data_from_cache(); } catch (Exception $e) { @@ -202,13 +202,13 @@ class caption_record implements caption_interface, cache_cacheableInterface WHERE m.record_id = :record_id AND s.id = m.meta_struct_id ORDER BY s.sorter ASC"; $stmt = $this->databox->get_connection()->prepare($sql); - $stmt->execute(array(':record_id' => $this->record->get_record_id())); + $stmt->execute([':record_id' => $this->record->get_record_id()]); $fields = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); $this->set_data_to_cache($fields); } - $rec_fields = array(); + $rec_fields = []; foreach ($fields as $row) { $databox_meta_struct = databox_field::get_instance($this->app, $this->databox, $row['structure_id']); $metadata = new caption_field($this->app, $databox_meta_struct, $this->record); @@ -229,7 +229,7 @@ class caption_record implements caption_interface, cache_cacheableInterface */ public function get_fields(Array $grep_fields = null, $IncludeBusiness = false) { - $fields = array(); + $fields = []; foreach ($this->retrieve_fields() as $meta_struct_id => $field) { if ($grep_fields && ! in_array($field->get_name(), $grep_fields)) { @@ -304,7 +304,7 @@ class caption_record implements caption_interface, cache_cacheableInterface */ protected function highlight_fields($highlight, Array $grep_fields = null, SearchEngineInterface $searchEngine = null, $includeBusiness = false) { - $fields = array(); + $fields = []; foreach ($this->get_fields($grep_fields, $includeBusiness) as $meta_struct_id => $field) { @@ -314,11 +314,11 @@ class caption_record implements caption_interface, cache_cacheableInterface , $highlight ? $field->highlight_thesaurus() : $field->get_serialized_values(false, false) ); - $fields[$field->get_name()] = array( + $fields[$field->get_name()] = [ 'value' => $value, 'label' => $field->get_databox_field()->get_label($this->app['locale.I18n']), 'separator' => $field->get_databox_field()->get_separator(), - ); + ]; } if ($searchEngine instanceof SearchEngineInterface) { diff --git a/lib/classes/collection.php b/lib/classes/collection.php index 7818a6a854..4044effa98 100644 --- a/lib/classes/collection.php +++ b/lib/classes/collection.php @@ -27,12 +27,12 @@ class collection implements cache_cacheableInterface protected $name; protected $prefs; protected $pub_wm; - protected $labels = array(); - private static $_logos = array(); - private static $_stamps = array(); - private static $_watermarks = array(); - private static $_presentations = array(); - private static $_collections = array(); + protected $labels = []; + private static $_logos = []; + private static $_stamps = []; + private static $_watermarks = []; + private static $_presentations = []; + private static $_collections = []; protected $databox; protected $is_active; protected $binary_logo; @@ -79,7 +79,7 @@ class collection implements cache_cacheableInterface label_en, label_fr, label_de, label_nl FROM coll WHERE coll_id = :coll_id'; $stmt = $connbas->prepare($sql); - $stmt->execute(array(':coll_id' => $this->coll_id)); + $stmt->execute([':coll_id' => $this->coll_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ( ! $row) @@ -89,12 +89,12 @@ class collection implements cache_cacheableInterface $this->pub_wm = $row['pub_wm']; $this->name = $row['asciiname']; $this->prefs = $row['prefs']; - $this->labels = array( + $this->labels = [ 'fr' => $row['label_fr'], 'en' => $row['label_en'], 'de' => $row['label_de'], 'nl' => $row['label_nl'], - ); + ]; $conn = connection::getPDOConnection($this->app); @@ -102,7 +102,7 @@ class collection implements cache_cacheableInterface WHERE server_coll_id = :coll_id AND sbas_id = :sbas_id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':coll_id' => $this->coll_id, ':sbas_id' => $this->databox->get_sbas_id())); + $stmt->execute([':coll_id' => $this->coll_id, ':sbas_id' => $this->databox->get_sbas_id()]); $row = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -116,7 +116,7 @@ class collection implements cache_cacheableInterface $stmt->closeCursor(); - $datas = array( + $datas = [ 'is_active' => $this->is_active , 'base_id' => $this->base_id , 'available' => $this->available @@ -125,7 +125,7 @@ class collection implements cache_cacheableInterface , 'ord' => $this->ord , 'prefs' => $this->prefs , 'labels' => $this->labels - ); + ]; $this->set_data_to_cache($datas); @@ -136,7 +136,7 @@ class collection implements cache_cacheableInterface { $sql = 'UPDATE bas SET active = "1" WHERE base_id = :base_id'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $this->is_active = true; @@ -166,7 +166,7 @@ class collection implements cache_cacheableInterface { $sql = 'UPDATE bas SET active=0 WHERE base_id = :base_id'; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $this->is_active = false; $this->delete_data_from_cache(); @@ -186,7 +186,7 @@ class collection implements cache_cacheableInterface ORDER BY record_id DESC LIMIT 0, " . $pass_quantity; $stmt = $this->databox->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -220,10 +220,10 @@ class collection implements cache_cacheableInterface public function set_public_presentation($publi) { - if (in_array($publi, array('none', 'wm', 'stamp'))) { + if (in_array($publi, ['none', 'wm', 'stamp'])) { $sql = 'UPDATE coll SET pub_wm = :pub_wm WHERE coll_id = :coll_id'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':pub_wm' => $publi, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':pub_wm' => $publi, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->pub_wm = $publi; @@ -244,7 +244,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET asciiname = :asciiname WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':asciiname' => $name, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':asciiname' => $name, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->name = $name; @@ -265,7 +265,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET label_$code = :label WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':label' => $label, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':label' => $label, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->labels[$code] = $label; @@ -294,7 +294,7 @@ class collection implements cache_cacheableInterface { $sql = "SELECT COUNT(record_id) AS n FROM record WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $rowbas = $stmt->fetch(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -313,17 +313,17 @@ class collection implements cache_cacheableInterface GROUP BY record.coll_id, subdef.name"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { - $ret[] = array( + $ret[] = [ "coll_id" => (int) $row["coll_id"], "name" => $row["name"], "amount" => (int) $row["n"], - "size" => (int) $row["size"]); + "size" => (int) $row["size"]]; } return $ret; @@ -339,7 +339,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET logo = :logo, majLogo=NOW() WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':logo' => $this->binary_logo, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':logo' => $this->binary_logo, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); return $this; @@ -352,7 +352,7 @@ class collection implements cache_cacheableInterface WHERE r.coll_id = :coll_id AND r.type="image" AND s.name="preview"'; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); while ($row2 = $stmt->fetch(PDO::FETCH_ASSOC)) { @unlink(p4string::addEndSlash($row2['path']) . 'watermark_' . $row2['file']); @@ -369,7 +369,7 @@ class collection implements cache_cacheableInterface WHERE r.coll_id = :coll_id AND r.type="image" AND s.name IN ("preview", "document")'; - $params = array(':coll_id' => $this->get_coll_id()); + $params = [':coll_id' => $this->get_coll_id()]; if ($record_id) { $sql .= ' AND record_id = :record_id'; @@ -395,24 +395,24 @@ class collection implements cache_cacheableInterface $sql = "DELETE FROM coll WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':coll_id' => $this->get_coll_id())); + $stmt->execute([':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $appbox = $this->databox->get_appbox(); $sql = "DELETE FROM bas WHERE base_id = :base_id"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $sql = "DELETE FROM basusr WHERE base_id = :base_id"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $sql = "DELETE FROM demand WHERE base_id = :base_id"; $stmt = $appbox->get_connection()->prepare($sql); - $stmt->execute(array(':base_id' => $this->get_base_id())); + $stmt->execute([':base_id' => $this->get_base_id()]); $stmt->closeCursor(); $this->get_databox()->delete_data_from_cache(databox::CACHE_COLLECTIONS); @@ -488,7 +488,7 @@ class collection implements cache_cacheableInterface $sql = "UPDATE coll SET prefs = :prefs WHERE coll_id = :coll_id"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id())); + $stmt->execute([':prefs' => $this->prefs, ':coll_id' => $this->get_coll_id()]); $stmt->closeCursor(); $this->delete_data_from_cache(); @@ -513,10 +513,10 @@ class collection implements cache_cacheableInterface public function unmount_collection(Application $app) { - $params = array(':base_id' => $this->get_base_id()); + $params = [':base_id' => $this->get_base_id()]; $query = new User_Query($app); - $total = $query->on_base_ids(array($this->get_base_id())) + $total = $query->on_base_ids([$this->get_base_id()]) ->include_phantoms(false) ->include_special_users(true) ->include_invite(true) @@ -568,10 +568,10 @@ class collection implements cache_cacheableInterface $sql = "INSERT INTO coll (coll_id, asciiname, prefs, logo) VALUES (null, :name, :prefs, '')"; - $params = array( + $params = [ ':name' => $name, 'prefs' => $prefs, - ); + ]; $stmt = $connbas->prepare($sql); $stmt->execute($params); @@ -583,7 +583,7 @@ class collection implements cache_cacheableInterface VALUES (null, 1, :server_coll_id, :sbas_id, '')"; $stmt = $conn->prepare($sql); - $stmt->execute(array(':server_coll_id' => $new_id, ':sbas_id' => $sbas_id)); + $stmt->execute([':server_coll_id' => $new_id, ':sbas_id' => $sbas_id]); $stmt->closeCursor(); $new_bas = $conn->lastInsertId(); @@ -606,7 +606,7 @@ class collection implements cache_cacheableInterface public function set_admin($base_id, user_adapter $user) { - $rights = array( + $rights = [ "canputinalbum" => "1", "candwnldhd" => "1", "nowatermark" => "1", @@ -624,7 +624,7 @@ class collection implements cache_cacheableInterface "imgtools" => "1", "manage" => "1", "modify_struct" => "1" - ); + ]; $this->app['acl']->get($user)->update_rights_to_base($base_id, $rights); @@ -638,7 +638,7 @@ class collection implements cache_cacheableInterface VALUES (null, 1, :server_coll_id, :sbas_id, '')"; $stmt = $databox->get_appbox()->get_connection()->prepare($sql); - $stmt->execute(array(':server_coll_id' => $coll_id, ':sbas_id' => $sbas_id)); + $stmt->execute([':server_coll_id' => $coll_id, ':sbas_id' => $sbas_id]); $stmt->closeCursor(); $new_bas = $databox->get_appbox()->get_connection()->lastInsertId(); diff --git a/lib/classes/connection.php b/lib/classes/connection.php index 28427d8a9d..26c36a7133 100644 --- a/lib/classes/connection.php +++ b/lib/classes/connection.php @@ -22,7 +22,7 @@ class connection * * @var Array */ - private static $_PDO_instance = array(); + private static $_PDO_instance = []; /** * @@ -34,7 +34,7 @@ class connection * * @var Array */ - public static $log = array(); + public static $log = []; protected $app; public function __construct(Application $app) @@ -67,8 +67,8 @@ class connection foreach (self::$log as $entry) { $query = $entry['query']; do { - $query = str_replace(array("\n", " "), " ", $query); - } while ($query != str_replace(array("\n", " "), " ", $query)); + $query = str_replace(["\n", " "], " ", $query); + } while ($query != str_replace(["\n", " "], " ", $query)); $totalTime += $entry['time']; $string = $entry['time'] . "\t" . ' - ' . $query . ' - ' . "\n"; @@ -124,7 +124,7 @@ class connection if (!isset(self::$_PDO_instance[$name])) { $hostname = $port = $user = $password = $dbname = false; - $connection_params = array(); + $connection_params = []; if (trim($name) !== 'appbox') { $connection_params = phrasea::sbas_params($app); @@ -147,7 +147,7 @@ class connection } try { - self::$_PDO_instance[$name] = new connection_pdo($name, $hostname, $port, $user, $password, $dbname, array(), $app['debug']); + self::$_PDO_instance[$name] = new connection_pdo($name, $hostname, $port, $user, $password, $dbname, [], $app['debug']); } catch (Exception $e) { throw new Exception('Connection not available'); } diff --git a/lib/classes/connection/abstract.php b/lib/classes/connection/abstract.php index c125577ef4..183a00776c 100644 --- a/lib/classes/connection/abstract.php +++ b/lib/classes/connection/abstract.php @@ -18,7 +18,7 @@ abstract class connection_abstract extends PDO { protected $name; - protected $credentials = array(); + protected $credentials = []; protected $multi_db = true; public function get_credentials() @@ -57,7 +57,7 @@ abstract class connection_abstract extends PDO * @param array $driver_options * @return PDOStatement */ - public function prepare($statement, $driver_options = array()) + public function prepare($statement, $driver_options = []) { return parent::prepare($statement, $driver_options); } diff --git a/lib/classes/connection/interface.php b/lib/classes/connection/interface.php index 18dff96b86..a7474118b2 100644 --- a/lib/classes/connection/interface.php +++ b/lib/classes/connection/interface.php @@ -28,7 +28,7 @@ interface connection_interface public function close(); - public function prepare($statement, $driver_options = array()); + public function prepare($statement, $driver_options = []); public function beginTransaction(); diff --git a/lib/classes/connection/pdo.php b/lib/classes/connection/pdo.php index 603e1ab2b5..423f4ed2c2 100644 --- a/lib/classes/connection/pdo.php +++ b/lib/classes/connection/pdo.php @@ -32,7 +32,7 @@ class connection_pdo extends connection_abstract implements connection_interface * * @return connection_pdo */ - public function __construct($name, $hostname, $port, $user, $passwd, $dbname = false, $options = array(), $debug = false) + public function __construct($name, $hostname, $port, $user, $passwd, $dbname = false, $options = [], $debug = false) { $this->debug = $debug; $this->name = $name; @@ -65,7 +65,7 @@ class connection_pdo extends connection_abstract implements connection_interface * @param type $driver_options * @return PDOStatement */ - public function prepare($statement, $driver_options = array()) + public function prepare($statement, $driver_options = []) { if ($this->debug) { return new connection_pdoStatementDebugger(parent::prepare($statement, $driver_options)); diff --git a/lib/classes/connection/pdoStatementDebugger.php b/lib/classes/connection/pdoStatementDebugger.php index 75aefc94a1..18e75ec4dd 100644 --- a/lib/classes/connection/pdoStatementDebugger.php +++ b/lib/classes/connection/pdoStatementDebugger.php @@ -29,7 +29,7 @@ class connection_pdoStatementDebugger return $this; } - public function execute($params = array()) + public function execute($params = []) { $start = microtime(true); $exception = null; @@ -39,10 +39,10 @@ class connection_pdoStatementDebugger $exception = $e; } $time = microtime(true) - $start; - connection::$log[] = array( + connection::$log[] = [ 'query' => '' . str_replace(array_keys($params), array_values($params), $this->statement->queryString), 'time' => $time - ); + ]; if ($exception instanceof Exception) throw $exception; @@ -51,6 +51,6 @@ class connection_pdoStatementDebugger public function __call($function_name, $parameters) { - return call_user_func_array(array($this->statement, $function_name), $parameters); + return call_user_func_array([$this->statement, $function_name], $parameters); } } diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 2aa5790294..9622b5e6cc 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -32,19 +32,19 @@ class databox extends base * * @var Array */ - protected static $_xpath_thesaurus = array(); + protected static $_xpath_thesaurus = []; /** * * @var Array */ - protected static $_dom_thesaurus = array(); + protected static $_dom_thesaurus = []; /** * * @var Array */ - protected static $_thesaurus = array(); + protected static $_thesaurus = []; /** * @@ -86,7 +86,7 @@ class databox extends base * * @var SimpleXMLElement */ - protected static $_sxml_thesaurus = array(); + protected static $_sxml_thesaurus = []; const BASE_TYPE = self::DATA_BOX; const CACHE_BASE_DATABOX = 'base_infos'; @@ -99,7 +99,7 @@ class databox extends base protected $cache; protected $connection; protected $app; - private $labels = array(); + private $labels = []; private $ord; private $viewname; private $loaded = false; @@ -140,7 +140,7 @@ class databox extends base $sql = 'SELECT ord, viewname, label_en, label_fr, label_de, label_nl FROM sbas WHERE sbas_id = :sbas_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array('sbas_id' => $this->id)); + $stmt->execute(['sbas_id' => $this->id]); $row = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -175,7 +175,7 @@ class databox extends base $sql = 'UPDATE sbas SET viewname = :viewname WHERE sbas_id = :sbas_id'; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':viewname' => $viewname, ':sbas_id' => $this->id)); + $stmt->execute([':viewname' => $viewname, ':sbas_id' => $this->id]); $stmt->closeCursor(); $this->delete_data_from_cache(static::CACHE_BASE_DATABOX); @@ -201,7 +201,7 @@ class databox extends base public function get_collections() { - $ret = array(); + $ret = []; foreach ($this->get_available_collections() as $coll_id) { try { @@ -229,11 +229,11 @@ class databox extends base AND b.active = '1' ORDER BY s.ord ASC, b.ord,b.base_id ASC"; $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array(); + $ret = []; foreach ($rs as $row) { $ret[] = (int) $row['server_coll_id']; @@ -280,7 +280,7 @@ class databox extends base $sql = "UPDATE sbas SET label_$code = :label WHERE sbas_id = :sbas_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':label' => $label, ':sbas_id' => $this->id)); + $stmt->execute([':label' => $label, ':sbas_id' => $this->id]); $stmt->closeCursor(); $this->labels[$code] = $label; @@ -376,15 +376,15 @@ class databox extends base foreach ($rs as $rowbas) { if ( ! isset($trows[$rowbas[$sortk1]])) - $trows[$rowbas[$sortk1]] = array(); - $trows[$rowbas[$sortk1]][$rowbas[$sortk2]] = array( + $trows[$rowbas[$sortk1]] = []; + $trows[$rowbas[$sortk1]][$rowbas[$sortk2]] = [ "coll_id" => $rowbas["coll_id"], "asciiname" => $rowbas["asciiname"], "lostcoll" => $rowbas["lostcoll"], "name" => $rowbas["name"], "n" => $rowbas["n"], "siz" => $rowbas["siz"] - ); + ]; } ksort($trows); @@ -416,7 +416,7 @@ class databox extends base $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); - $ret = array('xml_indexed' => 0, 'thesaurus_indexed' => 0); + $ret = ['xml_indexed' => 0, 'thesaurus_indexed' => 0]; foreach ($rs as $row) { $status = $row['status']; if ($status & 1) @@ -435,7 +435,7 @@ class databox extends base } $query = new User_Query($this->app); - $total = $query->on_sbas_ids(array($this->id)) + $total = $query->on_sbas_ids([$this->id]) ->include_phantoms(false) ->include_special_users(true) ->include_invite(true) @@ -462,7 +462,7 @@ class databox extends base $this->app['EM']->flush(); - $params = array(':site_id' => $this->app['configuration']['main']['key']); + $params = [':site_id' => $this->app['configuration']['main']['key']]; $sql = 'DELETE FROM clients WHERE site_id = :site_id'; $stmt = $this->get_connection()->prepare($sql); @@ -476,12 +476,12 @@ class databox extends base $sql = "DELETE FROM sbas WHERE sbas_id = :sbas_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $stmt->closeCursor(); $sql = "DELETE FROM sbasusr WHERE sbas_id = :sbas_id"; $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $stmt->closeCursor(); $this->app['phraseanet.appbox']->delete_data_from_cache(appbox::CACHE_LIST_BASES); @@ -508,13 +508,13 @@ class databox extends base $user = $credentials['user']; $password = $credentials['password']; - $params = array( + $params = [ ':host' => $host , ':port' => $port , ':dbname' => $dbname , ':user' => $user , ':password' => $password - ); + ]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); @@ -551,14 +551,14 @@ class databox extends base $sql = 'INSERT INTO sbas (sbas_id, ord, host, port, dbname, sqlengine, user, pwd) VALUES (null, :ord, :host, :port, :dbname, "MYSQL", :user, :password)'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':ord' => $ord , ':host' => $host , ':port' => $port , ':dbname' => $dbname , ':user' => $user , ':password' => $password - )); + ]); $stmt->closeCursor(); $sbas_id = (int) $app['phraseanet.appbox']->get_connection()->lastInsertId(); @@ -586,7 +586,7 @@ class databox extends base */ public static function mount(Application $app, $host, $port, $user, $password, $dbname, registry $registry) { - new connection_pdo('test', $host, $port, $user, $password, $dbname, array(), $app['debug']); + new connection_pdo('test', $host, $port, $user, $password, $dbname, [], $app['debug']); $conn = $app['phraseanet.appbox']->get_connection(); $sql = 'SELECT MAX(ord) as ord FROM sbas'; @@ -600,14 +600,14 @@ class databox extends base $sql = 'INSERT INTO sbas (sbas_id, ord, host, port, dbname, sqlengine, user, pwd) VALUES (null, :ord, :host, :port, :dbname, "MYSQL", :user, :password)'; $stmt = $conn->prepare($sql); - $stmt->execute(array( + $stmt->execute([ ':ord' => $ord , ':host' => $host , ':port' => $port , ':dbname' => $dbname , ':user' => $user , ':password' => $password - )); + ]); $stmt->closeCursor(); $sbas_id = (int) $conn->lastInsertId(); @@ -735,7 +735,7 @@ class databox extends base public static function get_available_dcfields() { - return array( + return [ databox_Field_DCESAbstract::Contributor => new databox_Field_DCES_Contributor() , databox_Field_DCESAbstract::Coverage => new databox_Field_DCES_Coverage() , databox_Field_DCESAbstract::Creator => new databox_Field_DCES_Creator() @@ -751,7 +751,7 @@ class databox extends base , databox_Field_DCESAbstract::Subject => new databox_Field_DCES_Subject() , databox_Field_DCESAbstract::Title => new databox_Field_DCES_Title() , databox_Field_DCESAbstract::Type => new databox_Field_DCES_Type() - ); + ]; } /** @@ -761,11 +761,11 @@ class databox extends base public function get_mountable_colls() { $conn = connection::getPDOConnection($this->app); - $colls = array(); + $colls = []; $sql = 'SELECT server_coll_id FROM bas WHERE sbas_id = :sbas_id'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -773,7 +773,7 @@ class databox extends base $colls[] = (int) $row['server_coll_id']; } - $mountable_colls = array(); + $mountable_colls = []; $sql = 'SELECT coll_id, asciiname FROM coll'; @@ -796,11 +796,11 @@ class databox extends base public function get_activable_colls() { $conn = connection::getPDOConnection($this->app); - $base_ids = array(); + $base_ids = []; $sql = 'SELECT base_id FROM bas WHERE sbas_id = :sbas_id AND active = "0"'; $stmt = $conn->prepare($sql); - $stmt->execute(array(':sbas_id' => $this->id)); + $stmt->execute([':sbas_id' => $this->id]); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt->closeCursor(); @@ -829,10 +829,10 @@ class databox extends base $stmt = $this->get_connection()->prepare($sql); $stmt->execute( - array( + [ ':structure' => $this->structure, ':now' => $now - ) + ] ); $stmt->closeCursor(); @@ -858,10 +858,10 @@ class databox extends base WHERE prop='cterms'"; $this->cterms = $dom_cterms->saveXML(); - $params = array( + $params = [ ':xml' => $this->cterms , ':date' => $now - ); + ]; $stmt = $this->get_connection()->prepare($sql); $stmt->execute($params); @@ -879,7 +879,7 @@ class databox extends base $sql = "UPDATE pref SET value = :xml, updated_on = :date WHERE prop='thesaurus'"; $stmt = $this->get_connection()->prepare($sql); - $stmt->execute(array(':xml' => $this->thesaurus, ':date' => $now)); + $stmt->execute([':xml' => $this->thesaurus, ':date' => $now]); $stmt->closeCursor(); $this->delete_data_from_cache(databox::CACHE_THESAURUS); @@ -895,8 +895,8 @@ class databox extends base $contents = file_get_contents($data_template->getPathname()); $contents = str_replace( - array("{{basename}}", "{{datapathnoweb}}") - , array($this->dbname, $path_doc) + ["{{basename}}", "{{datapathnoweb}}"] + , [$this->dbname, $path_doc] , $contents ); @@ -931,12 +931,12 @@ class databox extends base $type = isset($field['type']) ? $field['type'] : 'string'; $type = in_array($type - , array( + , [ databox_field::TYPE_DATE , databox_field::TYPE_NUMBER , databox_field::TYPE_STRING , databox_field::TYPE_TEXT - ) + ] ) ? $type : databox_field::TYPE_STRING; $multi = isset($field['multi']) ? (Boolean) (string) $field['multi'] : false; @@ -973,12 +973,12 @@ class databox extends base $conn = connection::getPDOConnection($this->app); $this->app['acl']->get($user) - ->give_access_to_sbas(array($this->id)) + ->give_access_to_sbas([$this->id]) ->update_rights_to_sbas( - $this->id, array( + $this->id, [ 'bas_manage' => 1, 'bas_modify_struct' => 1, 'bas_modif_th' => 1, 'bas_chupub' => 1 - ) + ] ); $sql = "SELECT * FROM coll"; @@ -992,10 +992,10 @@ class databox extends base (null,'1', :coll_id, :sbas_id)"; $stmt = $conn->prepare($sql); - $base_ids = array(); + $base_ids = []; foreach ($rs as $row) { try { - $stmt->execute(array(':coll_id' => $row['coll_id'], ':sbas_id' => $this->id)); + $stmt->execute([':coll_id' => $row['coll_id'], ':sbas_id' => $this->id]); $base_ids[] = $base_id = $conn->lastInsertId(); if ( ! empty($row['logo'])) { @@ -1008,13 +1008,13 @@ class databox extends base $this->app['acl']->get($user)->give_access_to_base($base_ids); foreach ($base_ids as $base_id) { - $this->app['acl']->get($user)->update_rights_to_base($base_id, array( + $this->app['acl']->get($user)->update_rights_to_base($base_id, [ 'canpush' => 1, 'cancmd' => 1 , 'canputinalbum' => 1, 'candwnldhd' => 1, 'candwnldpreview' => 1, 'canadmin' => 1 , 'actif' => 1, 'canreport' => 1, 'canaddrecord' => 1, 'canmodifrecord' => 1 , 'candeleterecord' => 1, 'chgstatus' => 1, 'imgtools' => 1, 'manage' => 1 , 'modify_struct' => 1, 'nowatermark' => 1 - ) + ] ); } @@ -1039,7 +1039,7 @@ class databox extends base public function clear_logs() { - foreach (array('log', 'log_colls', 'log_docs', 'log_search', 'log_view', 'log_thumb') as $table) { + foreach (['log', 'log_colls', 'log_docs', 'log_search', 'log_view', 'log_thumb'] as $table) { $sql = 'TRUNCATE ' . $table; $stmt = $this->get_connection()->prepare($sql); $stmt->execute(); @@ -1309,9 +1309,9 @@ class databox extends base $sx_structure = simplexml_load_string($structure); $subdefgroup = $sx_structure->subdefs[0]; - $AvSubdefs = array(); + $AvSubdefs = []; - $errors = array(); + $errors = []; foreach ($subdefgroup as $k => $subdefs) { $subdefgroup_name = trim((string) $subdefs->attributes()->name); @@ -1322,7 +1322,7 @@ class databox extends base } if ( ! isset($AvSubdefs[$subdefgroup_name])) - $AvSubdefs[$subdefgroup_name] = array(); + $AvSubdefs[$subdefgroup_name] = []; foreach ($subdefs as $sd) { $sd_name = trim(mb_strtolower((string) $sd->attributes()->name)); @@ -1331,7 +1331,7 @@ class databox extends base $errors[] = _('ERREUR : Les name de subdef sont uniques par groupe de subdefs et necessaire'); continue; } - if ( ! in_array($sd_class, array('thumbnail', 'preview', 'document'))) { + if ( ! in_array($sd_class, ['thumbnail', 'preview', 'document'])) { $errors[] = _('ERREUR : La classe de subdef est necessaire et egal a "thumbnail","preview" ou "document"'); continue; } @@ -1371,10 +1371,10 @@ class databox extends base $stmt->closeCursor(); foreach ($rs as $row) { - $TOU[$row['locale']] = array('updated_on' => $row['updated_on'], 'value' => $row['value']); + $TOU[$row['locale']] = ['updated_on' => $row['updated_on'], 'value' => $row['value']]; } - $missing_locale = array(); + $missing_locale = []; $avLanguages = $this->app['locales.available']; foreach ($avLanguages as $code => $language) { @@ -1389,8 +1389,8 @@ class databox extends base VALUES (null, 'ToU', '', :locale, :date, NOW())"; $stmt = $this->get_connection()->prepare($sql); foreach ($missing_locale as $v) { - $stmt->execute(array(':locale' => $v, ':date' => $date)); - $TOU[$v] = array('updated_on' => $date, 'value' => ''); + $stmt->execute([':locale' => $v, ':date' => $date]); + $TOU[$v] = ['updated_on' => $date, 'value' => '']; } $stmt->closeCursor(); $this->cgus = $TOU; @@ -1403,7 +1403,7 @@ class databox extends base public function update_cgus($locale, $terms, $reset_date) { - $terms = str_replace(array("\r\n", "\n", "\r"), array('', '', ''), strip_tags($terms, '