Source of file CustomHtmlEditorConfig.php
Size: 3,194 Bytes - Last Modified: 2021-12-23T10:05:50+00:00
/var/www/docs.ssmods.com/process/src/code/CustomHtmlEditorConfig.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 | <?php /** * This basically just exists to give us getter methods for protected properties of HTMLEditorConfig * We "wrap" the HTMLEditorConfig object in an HTMLEditorConfig subclass so it has access to the * protected $settings property * This actually just stores the identifier rather than the object itself because we need to know * the identifier for the JS. * * It also provides a copy() static method that duplicates editor configs for convenience * */ class CustomHTMLEditorConfig extends HTMLEditorConfig { /** * The identifier string */ public $configIdentifier; /** * Constructor is passed the identifier of teh HTMLEditorConfig we want to wrap * * @param string $identifier Can't use an instance of HTMLEditorConfig to create * because we need to know the identifier */ function __construct($identifier) { $this->configIdentifier = $identifier; } /** * Used like HTMLEditorConfig::get() but returns the config wrapped in an CustomHTMLEditorConfig * * @param string $identifier */ public static function get($identifier = 'default') { return new CustomHTMLEditorConfig($identifier); } /** * Creates a new config by cloning an existing one. Just a helplful utility function * * @param string $newIdentifier The ID of the new config we're creating * @param mixed HtmlEditorConfig|string $old The old config we're copying, * either as an ID string or the object itself * @param string $name Option friendly name for the new config. If left blank, friendly_name * is set to the new ID * * @return HTMLEditorConfig */ public static function copy($newIdentifier, $old, $name = null) { if (is_string($old)) { $old = HTMLEditorConfig::get($old); } $newConfig = HTMLEditorConfig::get($newIdentifier); foreach ($old->settings as $key => $value) { $newConfig->setOption($key, $value); } $newConfig->plugins = $old->getPlugins(); $newConfig->buttons = $old->buttons; if ($name) { $newConfig->setOption('friendly_name', $name); } else { $newConfig->setOption('friendly_name', $newIdentifier); } return $newConfig; } /** * Returns the settings array of the wrapped config * * @return array */ public function getSettings() { return $this->getConfig()->settings; } /** * Returns the wrapped config * * @return HtmlEditorConfig */ public function getConfig() { return HTMLEditorConfig::get($this->configIdentifier); } /** * Returns the buttons array of the wrapped config * * @return array */ public function getButtons() { return $this->getConfig()->buttons; } /** * Returns the plugins array of the wrapped config * * @return array */ public function getPlugins() { return $this->getConfig()->plugins; } } |