diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2013-10-24 05:43:51 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2013-10-24 05:43:51 +0400 |
commit | 52e8a0d868069c090997aaa134ecc51ef275b4c2 (patch) | |
tree | ef24bf3a645e4140875c7aa5261687e5d9d6ca4a /plugins/ExampleSettingsPlugin/Settings.php | |
parent | 0f2af694d5ae42215a3afb3ea642d163fefa56ec (diff) |
refs #4126 added more example, handle type array and field multi select correct, code cleanup
Diffstat (limited to 'plugins/ExampleSettingsPlugin/Settings.php')
-rw-r--r-- | plugins/ExampleSettingsPlugin/Settings.php | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/plugins/ExampleSettingsPlugin/Settings.php b/plugins/ExampleSettingsPlugin/Settings.php index 400b74184d..89afa86b37 100644 --- a/plugins/ExampleSettingsPlugin/Settings.php +++ b/plugins/ExampleSettingsPlugin/Settings.php @@ -32,8 +32,17 @@ class Settings extends PluginSettings // User setting --> textbox converted to int defining a validator and filter $this->addSetting($this->getRefreshIntervalSetting()); - // System setting --> allows selection of a value + // System setting --> allows selection of a single value $this->addSetting($this->getMetricSetting()); + + // System setting --> allows selection of multiple values + $this->addSetting($this->getBrowsersSetting()); + + // System setting --> textarea + $this->addSetting($this->getDescriptionSetting()); + + // System setting --> textarea + $this->addSetting($this->getPasswordSetting()); } public function isAutoRefreshEnabled() @@ -93,10 +102,44 @@ class Settings extends PluginSettings $metric->type = static::TYPE_STRING; $metric->field = static::FIELD_SINGLE_SELECT; $metric->fieldOptions = array('nb_visits' => 'Visits', 'nb_actions' => 'Actions', 'visitors' => 'Visitors'); - $metric->introduction = 'Only super users can change this setting.'; - $metric->description = Piwik::translate('LiveTab_MetricDescription'); + $metric->introduction = 'Only super users can change the following settings:'; + $metric->description = 'Choose the metric that should be displayed in the browser tab'; $metric->defaultValue = 'nb_visits'; return $metric; } + + private function getBrowsersSetting() + { + $browsers = new SystemSetting('browsers', 'Supported Browsers'); + $browsers->type = static::TYPE_ARRAY; + $browsers->field = static::FIELD_MULTI_SELECT; + $browsers->fieldOptions = array('firefox' => 'Firefox', 'chromium' => 'Chromium', 'safari' => 'safari'); + $browsers->description = 'The value will be only displayed in the following browsers'; + $browsers->defaultValue = array('firefox', 'chromium', 'safari'); + + return $browsers; + } + + private function getDescriptionSetting() + { + $description = new SystemSetting('description', 'Description for value'); + $description->field = static::FIELD_TEXTAREA; + $description->description = 'This description will be displayed next to the value'; + $description->defaultValue = "This is the value: \nAnother line"; + + return $description; + } + + private function getPasswordSetting() + { + $description = new SystemSetting('password', 'API password'); + $description->field = static::FIELD_PASSWORD; + $description->description = 'Password for the 3rd API where we fetch the value'; + $description->filter = function ($value) { + return sha1($value . 'salt'); + }; + + return $description; + } } |