diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-03-18 13:59:44 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-03-18 13:59:44 +0100 |
commit | 76455204c0851b8bf373164140c7987e853925d2 (patch) | |
tree | 5ad7fe7eeeb66fcc87d56f3deaad0fc21e8e47e4 /lib/private/l10n | |
parent | 23c0f4ff5f3b0023b4a2413536504d7065975a76 (diff) | |
download | nextcloud-server-76455204c0851b8bf373164140c7987e853925d2.tar.gz nextcloud-server-76455204c0851b8bf373164140c7987e853925d2.zip |
Inject server root - allows proper testing and separation of concerns
Diffstat (limited to 'lib/private/l10n')
-rw-r--r-- | lib/private/l10n/factory.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php index 198c5605413..fd093c3601b 100644 --- a/lib/private/l10n/factory.php +++ b/lib/private/l10n/factory.php @@ -64,17 +64,23 @@ class Factory implements IFactory { /** @var IUserSession */ protected $userSession; + /** @var string */ + protected $serverRoot; + /** * @param IConfig $config * @param IRequest $request * @param IUserSession $userSession + * @param string $serverRoot */ public function __construct(IConfig $config, IRequest $request, - IUserSession $userSession) { + IUserSession $userSession, + $serverRoot) { $this->config = $config; $this->request = $request; $this->userSession = $userSession; + $this->serverRoot = $serverRoot; } /** @@ -189,7 +195,7 @@ class Factory implements IFactory { // merge with translations from theme $theme = $this->config->getSystemValue('theme'); if (!empty($theme)) { - $themeDir = \OC::$SERVERROOT . '/themes/' . $theme . substr($dir, strlen(\OC::$SERVERROOT)); + $themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot)); if (is_dir($themeDir)) { $files = scandir($themeDir); @@ -280,9 +286,9 @@ class Factory implements IFactory { $i18nDir = $this->findL10nDir($app); $transFile = strip_tags($i18nDir) . strip_tags($lang) . '.json'; - if ((\OC_Helper::isSubDirectory($transFile, \OC::$SERVERROOT . '/core/l10n/') - || \OC_Helper::isSubDirectory($transFile, \OC::$SERVERROOT . '/lib/l10n/') - || \OC_Helper::isSubDirectory($transFile, \OC::$SERVERROOT . '/settings/l10n/') + if ((\OC_Helper::isSubDirectory($transFile, $this->serverRoot . '/core/l10n/') + || \OC_Helper::isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/') + || \OC_Helper::isSubDirectory($transFile, $this->serverRoot . '/settings/l10n/') || \OC_Helper::isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/') ) && file_exists($transFile)) { @@ -293,7 +299,7 @@ class Factory implements IFactory { // merge with translations from theme $theme = $this->config->getSystemValue('theme'); if (!empty($theme)) { - $transFile = \OC::$SERVERROOT . '/themes/' . $theme . substr($transFile, strlen(\OC::$SERVERROOT)); + $transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot)); if (file_exists($transFile)) { $languageFiles[] = $transFile; } @@ -310,14 +316,14 @@ class Factory implements IFactory { */ protected function findL10nDir($app = null) { if (in_array($app, ['core', 'lib', 'settings'])) { - if (file_exists(\OC::$SERVERROOT . '/' . $app . '/l10n/')) { - return \OC::$SERVERROOT . '/' . $app . '/l10n/'; + if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) { + return $this->serverRoot . '/' . $app . '/l10n/'; } } else if ($app && \OC_App::getAppPath($app) !== false) { // Check if the app is in the app folder return \OC_App::getAppPath($app) . '/l10n/'; } - return \OC::$SERVERROOT . '/core/l10n/'; + return $this->serverRoot . '/core/l10n/'; } |