Skip to content

Commit

Permalink
refs #4126 added possibility to define introductions, display inline …
Browse files Browse the repository at this point in the history
…help
  • Loading branch information
tsteur committed Oct 23, 2013
1 parent 5080cf2 commit 3ded6de
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
22 changes: 17 additions & 5 deletions core/Plugin/Settings.php
Expand Up @@ -31,13 +31,14 @@ class Settings

// what about stuff like date etc?
protected $defaultTypes = array();
protected $defaultFields = array();
protected $defaultOptions = array();
private $defaultTypes = array();
private $defaultFields = array();
private $defaultOptions = array();

protected $settings = array();
protected $settingsValues = array();
private $settings = array();
private $settingsValues = array();

private $introduction;
private $pluginName;

public function __construct($pluginName)
Expand Down Expand Up @@ -65,6 +66,7 @@ public function __construct($pluginName)
'displayedForCurrentUser' => false,
'fieldAttributes' => array(),
'fieldOptions' => array(),
'introduction' => null,
'description' => null,
'inlineHelp' => null,
'filter' => null,
Expand All @@ -81,6 +83,11 @@ protected function init()
{
}

protected function addIntroduction($introduction)
{
$this->introduction = $introduction;
}

protected function addPerUserSetting($name, $title, array $options = array())
{
$options['displayedForCurrentUser'] = !Piwik::isUserIsAnonymous();
Expand All @@ -99,6 +106,11 @@ protected function addSystemSetting($name, $title, array $options = array())
$this->addSetting($name, $name, $title, $options);
}

public function getIntroduction()
{
return $this->introduction;
}

public function getSettingsForCurrentUser()
{
return array_values(array_filter($this->getSettings(), function ($setting) {
Expand Down
29 changes: 28 additions & 1 deletion plugins/CoreAdminHome/templates/pluginSettings.twig
Expand Up @@ -16,14 +16,31 @@

<h3 id="{{ pluginName|e('html_attr') }}">{{ pluginName }}</h3>

<table class="adminTable" style='width:620px;' id="pluginSettings" data-pluginname="{{ pluginName }}">
{% if settings.getIntroduction %}
<p class="pluginIntroduction">
{{ settings.getIntroduction }}
</p>
{% endif %}

<table class="adminTable" style='width:820px;' id="pluginSettings" data-pluginname="{{ pluginName }}">

{% for setting in settings.getSettingsForCurrentUser %}
{% if setting.isUserSetting %}
{% set settingValue = settings.getPerUserSettingValue(setting.name) %}
{% else %}
{% set settingValue = settings.getSystemSettingValue(setting.name) %}
{% endif %}

{% if setting.introduction %}
<tr>
<td colspan="3">
<p class="settingIntroduction">
{{ setting.introduction }}
</p>
</td>
</tr>
{% endif %}

<tr>
<td style='width:400px'>
{{ setting.title }}
Expand Down Expand Up @@ -90,6 +107,16 @@
</label>
</fieldset>
</td>
<td style="width:200px">
{% if setting.inlineHelp %}
<div class="ui-widget">
<div class="ui-inline-help ui-state-highlight ui-corner-all">
<span class="ui-icon ui-icon-info" style="float:left;margin-right:.3em;"></span>
{{ setting.inlineHelp }}
</div>
</div>
{% endif %}
</td>
</tr>

{% endfor %}
Expand Down

0 comments on commit 3ded6de

Please sign in to comment.