]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1635 from ArthurHoaro/feature/phpcs
authorArthurHoaro <arthur@hoa.ro>
Tue, 10 Nov 2020 09:46:04 +0000 (10:46 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Nov 2020 09:46:04 +0000 (10:46 +0100)
1  2 
application/config/ConfigManager.php
application/front/controller/admin/ServerController.php

index 3260d7c0967b603077183b0ae80ed12105933792,a0acc94d7d6f19e7bd1f3ee20e0bd3e2422e6283..717a038f7912fa2bc2b403d2d38a1101f6041238
@@@ -1,4 -1,5 +1,5 @@@
  <?php
  namespace Shaarli\Config;
  
  use Shaarli\Config\Exception\MissingFieldConfigException;
@@@ -20,7 -21,7 +21,7 @@@ class ConfigManage
       */
      protected static $NOT_FOUND = 'NOT_FOUND';
  
-     public static $DEFAULT_PLUGINS = array('qrcode');
+     public static $DEFAULT_PLUGINS = ['qrcode'];
  
      /**
       * @var string Config folder.
      public function set($setting, $value, $write = false, $isLoggedIn = false)
      {
          if (empty($setting) || ! is_string($setting)) {
-             throw new \Exception(t('Invalid setting key parameter. String expected, got: '). gettype($setting));
+             throw new \Exception(t('Invalid setting key parameter. String expected, got: ') . gettype($setting));
          }
  
          // During the ConfigIO transition, map legacy settings to the new ones.
      public function remove($setting, $write = false, $isLoggedIn = false)
      {
          if (empty($setting) || ! is_string($setting)) {
-             throw new \Exception(t('Invalid setting key parameter. String expected, got: '). gettype($setting));
+             throw new \Exception(t('Invalid setting key parameter. String expected, got: ') . gettype($setting));
          }
  
          // During the ConfigIO transition, map legacy settings to the new ones.
      public function write($isLoggedIn)
      {
          // These fields are required in configuration.
-         $mandatoryFields = array(
+         $mandatoryFields = [
              'credentials.login',
              'credentials.hash',
              'credentials.salt',
              'general.title',
              'general.header_link',
              'privacy.default_private_links',
-         );
+         ];
  
          // Only logged in user can alter config.
          if (is_file($this->getConfigFileExt()) && !$isLoggedIn) {
          $this->setEmpty('general.enable_async_metadata', true);
          $this->setEmpty('general.tags_separator', ' ');
  
 -        $this->setEmpty('updates.check_updates', false);
 -        $this->setEmpty('updates.check_updates_branch', 'stable');
 +        $this->setEmpty('updates.check_updates', true);
 +        $this->setEmpty('updates.check_updates_branch', 'latest');
          $this->setEmpty('updates.check_updates_interval', 86400);
  
          $this->setEmpty('feed.rss_permalinks', true);
          $this->setEmpty('translation.mode', 'php');
          $this->setEmpty('translation.extensions', []);
  
-         $this->setEmpty('plugins', array());
+         $this->setEmpty('plugins', []);
  
          $this->setEmpty('formatter', 'markdown');
      }
index 780151dd7debfcc1490545af7fc318322a31508b,575a2f9dce082b24806b8fef0ef8ab82a62222c8..fabeaf2f26b09643709bbf1a23f156361fa6bb75
@@@ -25,16 -25,9 +25,16 @@@ class ServerController extends ShaarliA
       */
      public function index(Request $request, Response $response): Response
      {
 -        $latestVersion = 'v' . ApplicationUtils::getVersion(
 -            ApplicationUtils::$GIT_RAW_URL . '/latest/' . ApplicationUtils::$VERSION_FILE
 -        );
 +        $releaseUrl = ApplicationUtils::$GITHUB_URL . '/releases/';
 +        if ($this->container->conf->get('updates.check_updates', true)) {
 +            $latestVersion = 'v' . ApplicationUtils::getVersion(
 +                ApplicationUtils::$GIT_RAW_URL . '/latest/' . ApplicationUtils::$VERSION_FILE
 +            );
 +            $releaseUrl .= 'tag/' . $latestVersion;
 +        } else {
 +            $latestVersion = t('Check disabled');
 +        }
 +
          $currentVersion = ApplicationUtils::getVersion('./shaarli_version.php');
          $currentVersion = $currentVersion === 'dev' ? $currentVersion : 'v' . $currentVersion;
          $phpEol = new \DateTimeImmutable(ApplicationUtils::getPhpEol(PHP_VERSION));
@@@ -44,7 -37,7 +44,7 @@@
          $this->assignView('php_has_reached_eol', $phpEol < new \DateTimeImmutable());
          $this->assignView('php_extensions', ApplicationUtils::getPhpExtensionsRequirement());
          $this->assignView('permissions', ApplicationUtils::checkResourcePermissions($this->container->conf));
 -        $this->assignView('release_url', ApplicationUtils::$GITHUB_URL . '/releases/tag/' . $latestVersion);
 +        $this->assignView('release_url', $releaseUrl);
          $this->assignView('latest_version', $latestVersion);
          $this->assignView('current_version', $currentVersion);
          $this->assignView('thumbnails_mode', $this->container->conf->get('thumbnails.mode'));
@@@ -72,7 -65,9 +72,9 @@@
  
              $this->saveWarningMessage(
                  t('Thumbnails cache has been cleared.') . ' ' .
-                 '<a href="'. $this->container->basePath .'/admin/thumbnails">' . t('Please synchronize them.') .'</a>'
+                 '<a href="' . $this->container->basePath . '/admin/thumbnails">' .
+                     t('Please synchronize them.') .
+                 '</a>'
              );
          } else {
              $folders = [