10a5b05ebSAndreas Gohr<?php 2d4f83172SAndreas Gohr 30a5b05ebSAndreas Gohr/** 40a5b05ebSAndreas Gohr * additional setting classes specific to these settings 50a5b05ebSAndreas Gohr * 60a5b05ebSAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 70a5b05ebSAndreas Gohr */ 80a5b05ebSAndreas Gohr 90a5b05ebSAndreas Gohrnamespace dokuwiki\plugin\config\core\Setting; 100a5b05ebSAndreas Gohr 110a5b05ebSAndreas Gohr/** 120a5b05ebSAndreas Gohr * Class setting_renderer 130a5b05ebSAndreas Gohr */ 148c7c53b0SAndreas Gohrclass SettingRenderer extends SettingMultichoice 158c7c53b0SAndreas Gohr{ 16467c1427SAndreas Gohr protected $prompts = []; 17467c1427SAndreas Gohr protected $format; 180a5b05ebSAndreas Gohr 190a5b05ebSAndreas Gohr /** @inheritdoc */ 20d868eb89SAndreas Gohr public function initialize($default = null, $local = null, $protected = null) 21d868eb89SAndreas Gohr { 220a5b05ebSAndreas Gohr $format = $this->format; 230a5b05ebSAndreas Gohr 240a5b05ebSAndreas Gohr foreach (plugin_list('renderer') as $plugin) { 250a5b05ebSAndreas Gohr $renderer = plugin_load('renderer', $plugin); 26*bafb9437SAndreas Gohr if ($renderer && method_exists($renderer, 'canRender') && $renderer->canRender($format)) { 270a5b05ebSAndreas Gohr $this->choices[] = $plugin; 280a5b05ebSAndreas Gohr 290a5b05ebSAndreas Gohr $info = $renderer->getInfo(); 300a5b05ebSAndreas Gohr $this->prompts[$plugin] = $info['name']; 310a5b05ebSAndreas Gohr } 320a5b05ebSAndreas Gohr } 330a5b05ebSAndreas Gohr 340a5b05ebSAndreas Gohr parent::initialize($default, $local, $protected); 350a5b05ebSAndreas Gohr } 360a5b05ebSAndreas Gohr 370a5b05ebSAndreas Gohr /** @inheritdoc */ 38d868eb89SAndreas Gohr public function html(\admin_plugin_config $plugin, $echo = false) 39d868eb89SAndreas Gohr { 400a5b05ebSAndreas Gohr 410a5b05ebSAndreas Gohr // make some language adjustments (there must be a better way) 420a5b05ebSAndreas Gohr // transfer some plugin names to the config plugin 430a5b05ebSAndreas Gohr foreach ($this->choices as $choice) { 440a5b05ebSAndreas Gohr if (!$plugin->getLang($this->key . '_o_' . $choice)) { 450a5b05ebSAndreas Gohr if (!isset($this->prompts[$choice])) { 460a5b05ebSAndreas Gohr $plugin->addLang( 470a5b05ebSAndreas Gohr $this->key . '_o_' . $choice, 480a5b05ebSAndreas Gohr sprintf($plugin->getLang('renderer__core'), $choice) 490a5b05ebSAndreas Gohr ); 500a5b05ebSAndreas Gohr } else { 510a5b05ebSAndreas Gohr $plugin->addLang( 520a5b05ebSAndreas Gohr $this->key . '_o_' . $choice, 530a5b05ebSAndreas Gohr sprintf($plugin->getLang('renderer__plugin'), $this->prompts[$choice]) 540a5b05ebSAndreas Gohr ); 550a5b05ebSAndreas Gohr } 560a5b05ebSAndreas Gohr } 570a5b05ebSAndreas Gohr } 580a5b05ebSAndreas Gohr return parent::html($plugin, $echo); 590a5b05ebSAndreas Gohr } 600a5b05ebSAndreas Gohr} 61