mirror of
https://github.com/Mibew/button-refresh-plugin.git
synced 2025-01-22 17:40:32 +03:00
Add "refresh_frequency" option
This commit is contained in:
parent
823cea36a7
commit
da3f44846f
22
Plugin.php
22
Plugin.php
@ -37,6 +37,26 @@ use Mibew\Plugin\PluginInterface;
|
|||||||
*/
|
*/
|
||||||
class Plugin extends AbstractPlugin implements 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
|
* The plugin does not need extra initialization thus it is always ready to
|
||||||
* work.
|
* work.
|
||||||
@ -79,7 +99,7 @@ class Plugin extends AbstractPlugin implements PluginInterface
|
|||||||
if ($args['generator'] instanceof ImageGenerator) {
|
if ($args['generator'] instanceof ImageGenerator) {
|
||||||
// Only image buttons should be refreshed
|
// Only image buttons should be refreshed
|
||||||
$script = HTML5\html('script');
|
$script = HTML5\html('script');
|
||||||
$script->addChild($this->buildRefreshJs(3));
|
$script->addChild($this->buildRefreshJs($this->config['refresh_frequency']));
|
||||||
$script->setAttribute('type', 'text/javascript');
|
$script->setAttribute('type', 'text/javascript');
|
||||||
|
|
||||||
$last_index = count($args['button']->getChildren()) - 1;
|
$last_index = count($args['button']->getChildren()) - 1;
|
||||||
|
15
README.md
15
README.md
@ -14,9 +14,24 @@ If the "plugins" stucture looks like `plugins: []` it will become:
|
|||||||
plugins:
|
plugins:
|
||||||
-
|
-
|
||||||
name: "Mibew:ButtonRefresh"
|
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
|
## Build from sources
|
||||||
|
|
||||||
There are several actions one should do before use the latest version of the plugin from the repository:
|
There are several actions one should do before use the latest version of the plugin from the repository:
|
||||||
|
Loading…
Reference in New Issue
Block a user