Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorsgiehl <stefan@piwik.org>2013-09-02 01:48:47 +0400
committersgiehl <stefan@piwik.org>2013-09-04 02:15:15 +0400
commiteb22c13f74361cdfeffd826eb2eb8f5783c7e49a (patch)
treebfdd8fbc2985e444461359a2dbe1b4ee9c1fe5da /core
parentc6fff1aebdaf3fa1658f2d3553b2064b5a491ef7 (diff)
code improvements; added missing tests
Diffstat (limited to 'core')
-rw-r--r--core/Translate/Writer.php21
1 files changed, 7 insertions, 14 deletions
diff --git a/core/Translate/Writer.php b/core/Translate/Writer.php
index a1b295fa07..66e34449ec 100644
--- a/core/Translate/Writer.php
+++ b/core/Translate/Writer.php
@@ -99,10 +99,16 @@ class Writer
/**
* @param string $language ISO 639-1 alpha-2 language code
+ *
+ * @throws \Exception
*/
public function setLanguage($language)
{
- $this->_language = $language;
+ if (!preg_match('/^([a-z]{2,3}(-[a-z]{2,3})?)$/i', $language)) {
+ throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($language)));
+ }
+
+ $this->_language = strtolower($language);
}
/**
@@ -185,21 +191,8 @@ class Writer
{
if (empty($lang)) $lang = $this->getLanguage();
- if (!Common::isValidFilename($lang) ||
- ($base !== 'lang' && $base !== 'tmp')
- ) {
- throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($lang)));
- }
-
if (!empty($this->_pluginName)) {
- $installedPlugins = PluginsManager::getInstance()->readPluginsDirectory();
-
- if (!in_array($this->_pluginName, $installedPlugins)) {
-
- throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($lang)));
- }
-
if ($base == 'tmp') {
return sprintf('%s/tmp/plugins/%s/lang/%s.json', PIWIK_INCLUDE_PATH, $this->_pluginName, $lang);
} else {