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
diff options
context:
space:
mode:
authorBenaka Moorthi <benaka.moorthi@gmail.com>2013-07-19 18:27:58 +0400
committerBenaka Moorthi <benaka.moorthi@gmail.com>2013-07-19 18:27:58 +0400
commit332e43403992cc114a21cb03aa8296a9a8da16d8 (patch)
tree9b4ebe724900ead5fe46c8e157d6517998d3b2d0 /core/Plugin/MetadataLoader.php
parente108ded1a30deeb19317e3604b74e674be111152 (diff)
Refs #3942, allow server-side and JS UI code to use colors defined in CSS.
Notes: - Removed colors.piwik.json loading code. No longer necessary. - UserCountryMap is the only remaining portion of Piwik that doesn't use this technique. Not yet, anyway.
Diffstat (limited to 'core/Plugin/MetadataLoader.php')
-rw-r--r--core/Plugin/MetadataLoader.php49
1 files changed, 1 insertions, 48 deletions
diff --git a/core/Plugin/MetadataLoader.php b/core/Plugin/MetadataLoader.php
index 1fe999edce..8bdd5b9ff8 100644
--- a/core/Plugin/MetadataLoader.php
+++ b/core/Plugin/MetadataLoader.php
@@ -17,15 +17,10 @@ require_once PIWIK_INCLUDE_PATH . '/core/Version.php';
/**
* Loads plugin metadata found in the following files:
* - plugin.piwik.json
- * - colors.piwik.json
*/
class Piwik_Plugin_MetadataLoader
{
const PLUGIN_JSON_FILENAME = 'plugin.piwik.json';
- const COLORS_JSON_FILENAME = 'colors.piwik.json';
-
- const SHORT_COLOR_LENGTH = 4;
- const LONG_COLOR_LENGTH = 7;
/**
* The name of the plugin whose metadata will be loaded.
@@ -53,8 +48,7 @@ class Piwik_Plugin_MetadataLoader
{
return array_merge(
$this->getDefaultPluginInformation(),
- $this->loadPluginInfoJson(),
- $this->loadPluginColorsJson()
+ $this->loadPluginInfoJson()
);
}
@@ -79,47 +73,6 @@ class Piwik_Plugin_MetadataLoader
return $this->loadJsonMetadata($path);
}
- private function loadPluginColorsJson()
- {
- $path = Piwik_PluginsManager::getPluginsDirectory() . $this->pluginName . '/' . self::COLORS_JSON_FILENAME;
- $info = $this->loadJsonMetadata($path);
- $info = $this->cleanAndValidatePluginColorsJson($path, $info);
- return $info;
- }
-
- private function cleanAndValidatePluginColorsJson($path, $info)
- {
- // check that if "colors" exists, it is an array
- $colors = isset($info["colors"]) ? $info["colors"] : array();
- if (!is_array($colors)) {
- throw new Exception("The 'colors' value in '$path' must be an object mapping names with colors.");
- }
-
- // validate each color
- foreach ($colors as $color) {
- if (!$this->isStringColorValid($color)) {
- throw new Exception("Invalid color string '$color' in '$path'.");
- }
- }
-
- return array("colors" => $colors); // make sure only 'colors' element is loaded
- }
-
- private function isStringColorValid($color)
- {
- if (strlen($color) !== self::SHORT_COLOR_LENGTH
- && strlen($color) !== self::LONG_COLOR_LENGTH
- ) {
- return false;
- }
-
- if ($color[0] !== '#') {
- return false;
- }
-
- return ctype_xdigit(substr($color, 1)); // check if other digits are hex
- }
-
private function loadJsonMetadata($path)
{
if (!file_exists($path)) {