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