Add "refresh_frequency" option

This commit is contained in:
Dmitriy Simushev 2014-11-14 13:45:38 +00:00
parent 823cea36a7
commit da3f44846f
2 changed files with 36 additions and 1 deletions

View File

@ -37,6 +37,26 @@ use Mibew\Plugin\PluginInterface;
*/
class Plugin extends AbstractPlugin implements PluginInterface
{
/**
* List of the plugin configs.
*
* @var array
*/
protected $config;
/**
* Class constructor.
*
* @param array $config List of the plugin config. The following options are
* supported:
* - 'refresh_frequency': int, time in seconds between button refreshes.
* The default value is 3.
*/
public function __construct($config)
{
$this->config = $config + array('refresh_frequency' => 3);
}
/**
* The plugin does not need extra initialization thus it is always ready to
* work.
@ -79,7 +99,7 @@ class Plugin extends AbstractPlugin implements PluginInterface
if ($args['generator'] instanceof ImageGenerator) {
// Only image buttons should be refreshed
$script = HTML5\html('script');
$script->addChild($this->buildRefreshJs(3));
$script->addChild($this->buildRefreshJs($this->config['refresh_frequency']));
$script->setAttribute('type', 'text/javascript');
$last_index = count($args['button']->getChildren()) - 1;

View File

@ -14,9 +14,24 @@ If the "plugins" stucture looks like `plugins: []` it will become:
plugins:
-
name: "Mibew:ButtonRefresh"
config: # Plugin's configurations are described below
refresh_frequency: 3
```
## Plugin's configurations
The plugin can be configured with values in "`<Mibew root>`/configs/config.yml" file.
### config.ignore_emoticons
Type: `Integer`
Default: `3`
Specify time in seconds between button refreshes. This value is optional and can be skipped.
## Build from sources
There are several actions one should do before use the latest version of the plugin from the repository: