blob: 224bcd2c320c1242bd13d0d6d63583bb69ee40dd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?php
/**
* additional setting classes specific to these settings
*
* @author Chris Smith <chris@jalakai.co.uk>
*/
namespace dokuwiki\plugin\config\core\Setting;
/**
* Class setting_renderer
*/
class SettingRenderer extends SettingMultichoice
{
protected $prompts = [];
protected $format;
/** @inheritdoc */
public function initialize($default = null, $local = null, $protected = null)
{
$format = $this->format;
foreach (plugin_list('renderer') as $plugin) {
$renderer = plugin_load('renderer', $plugin);
if ($renderer && method_exists($renderer, 'canRender') && $renderer->canRender($format)) {
$this->choices[] = $plugin;
$info = $renderer->getInfo();
$this->prompts[$plugin] = $info['name'];
}
}
parent::initialize($default, $local, $protected);
}
/** @inheritdoc */
public function html(\admin_plugin_config $plugin, $echo = false)
{
// make some language adjustments (there must be a better way)
// transfer some plugin names to the config plugin
foreach ($this->choices as $choice) {
if (!$plugin->getLang($this->key . '_o_' . $choice)) {
if (!isset($this->prompts[$choice])) {
$plugin->addLang(
$this->key . '_o_' . $choice,
sprintf($plugin->getLang('renderer__core'), $choice)
);
} else {
$plugin->addLang(
$this->key . '_o_' . $choice,
sprintf($plugin->getLang('renderer__plugin'), $this->prompts[$choice])
);
}
}
}
return parent::html($plugin, $echo);
}
}
|