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/Intl
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-12-31 03:57:34 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-01-09 00:13:30 +0300
commit6245e0f77046614391a03ba18b2bc530d9b1b1a7 (patch)
tree9ac35162a87f5af593eb99bda9ea9d313ff48cf2 /core/Intl
parent8f342d0fb3f5661cb7fc1cafeabf93684ac478f8 (diff)
Created data provider classes in a new Intl component
Less code in `Piwik\Common`, less static classes, more isolated components.
Diffstat (limited to 'core/Intl')
-rw-r--r--core/Intl/Data/Provider/LanguageDataProvider.php45
-rw-r--r--core/Intl/Data/Provider/RegionDataProvider.php49
2 files changed, 94 insertions, 0 deletions
diff --git a/core/Intl/Data/Provider/LanguageDataProvider.php b/core/Intl/Data/Provider/LanguageDataProvider.php
new file mode 100644
index 0000000000..8369d8b1a7
--- /dev/null
+++ b/core/Intl/Data/Provider/LanguageDataProvider.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Intl\Data\Provider;
+
+/**
+ * Provides language data.
+ */
+class LanguageDataProvider
+{
+ /**
+ * Returns the list of valid language codes.
+ *
+ * @return string[] Array of 2 letter ISO code => language name (in english).
+ * E.g. `array('en' => 'English', 'ja' => 'Japanese')`.
+ * @api
+ */
+ public static function getLanguageList()
+ {
+ require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Languages.php';
+
+ $languagesList = $GLOBALS['Piwik_LanguageList'];
+ return $languagesList;
+ }
+
+ /**
+ * Returns the list of language to country mappings.
+ *
+ * @return string[] Array of 2 letter ISO language code => 2 letter ISO country code.
+ * E.g. `array('fr' => 'fr') // French => France`.
+ * @api
+ */
+ public static function getLanguageToCountryList()
+ {
+ require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/LanguageToCountry.php';
+
+ $languagesList = $GLOBALS['Piwik_LanguageToCountry'];
+ return $languagesList;
+ }
+}
diff --git a/core/Intl/Data/Provider/RegionDataProvider.php b/core/Intl/Data/Provider/RegionDataProvider.php
new file mode 100644
index 0000000000..b47aa4ab9c
--- /dev/null
+++ b/core/Intl/Data/Provider/RegionDataProvider.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Intl\Data\Provider;
+
+/**
+ * Provides region related data (continents, countries, etc.).
+ */
+class RegionDataProvider
+{
+ /**
+ * Returns the list of continent codes.
+ *
+ * @return string[] Array of 3 letter continent codes
+ * @api
+ */
+ public function getContinentList()
+ {
+ require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Countries.php';
+
+ return $GLOBALS['Piwik_ContinentList'];
+ }
+
+ /**
+ * Returns the list of valid country codes.
+ *
+ * @param bool $includeInternalCodes
+ * @return string[] Array of 2 letter country ISO codes => 3 letter continent code
+ * @api
+ */
+ public static function getCountryList($includeInternalCodes = false)
+ {
+ require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Countries.php';
+
+ $countriesList = $GLOBALS['Piwik_CountryList'];
+ $extras = $GLOBALS['Piwik_CountryList_Extras'];
+
+ if ($includeInternalCodes) {
+ return array_merge($countriesList, $extras);
+ }
+
+ return $countriesList;
+ }
+}