1 | <?php |
||
23 | abstract class HtmlEditorConfig extends Object { |
||
24 | |||
25 | /** |
||
26 | * Array of registered configurations |
||
27 | * |
||
28 | * @var HtmlEditorConfig[] |
||
29 | */ |
||
30 | protected static $configs = array(); |
||
31 | |||
32 | /** |
||
33 | * Identifier key of current config. This will match an array key in $configs. |
||
34 | * If left blank, will fall back to value of default_config set via config. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected static $current = null; |
||
39 | |||
40 | /** |
||
41 | * Name of default config. This will be ignored if $current is assigned a value. |
||
42 | * |
||
43 | * @config |
||
44 | * @var string |
||
45 | */ |
||
46 | private static $default_config = 'default'; |
||
47 | |||
48 | /** |
||
49 | * Get the HtmlEditorConfig object for the given identifier. This is a correct way to get an HtmlEditorConfig |
||
50 | * instance - do not call 'new' |
||
51 | * |
||
52 | * @param string $identifier The identifier for the config set. If omitted, the active config is returned. |
||
53 | * @return HtmlEditorConfig The configuration object. |
||
54 | * This will be created if it does not yet exist for that identifier |
||
55 | */ |
||
56 | public static function get($identifier = null) { |
||
66 | |||
67 | /** |
||
68 | * Assign a new config for the given identifier |
||
69 | * |
||
70 | * @param string $identifier A specific identifier |
||
71 | * @param HtmlEditorConfig $config |
||
72 | * @return HtmlEditorConfig The assigned config |
||
73 | */ |
||
74 | public static function set_config($identifier, HtmlEditorConfig $config) { |
||
78 | |||
79 | /** |
||
80 | * Set the currently active configuration object. Note that the existing active |
||
81 | * config will not be renamed to the new identifier. |
||
82 | * |
||
83 | * @param string $identifier The identifier for the config set |
||
84 | */ |
||
85 | public static function set_active_identifier($identifier) { |
||
88 | |||
89 | /** |
||
90 | * Get the currently active configuration identifier. Will fall back to default_config |
||
91 | * if unassigned. |
||
92 | * |
||
93 | * @return string The active configuration identifier |
||
94 | */ |
||
95 | public static function get_active_identifier() { |
||
99 | |||
100 | /** |
||
101 | * Get the currently active configuration object |
||
102 | * |
||
103 | * @return HtmlEditorConfig The active configuration object |
||
104 | */ |
||
105 | public static function get_active() { |
||
109 | |||
110 | /** |
||
111 | * Assigns the currently active config an explicit instance |
||
112 | * |
||
113 | * @param HtmlEditorConfig $config |
||
114 | * @return HtmlEditorConfig The given config |
||
115 | */ |
||
116 | public static function set_active(HtmlEditorConfig $config) { |
||
120 | |||
121 | /** |
||
122 | * Get the available configurations as a map of friendly_name to |
||
123 | * configuration name. |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | public static function get_available_configs_map() { |
||
136 | |||
137 | /** |
||
138 | * Get the current value of an option |
||
139 | * |
||
140 | * @param string $key The key of the option to get |
||
141 | * @return mixed The value of the specified option |
||
142 | */ |
||
143 | abstract public function getOption($key); |
||
144 | |||
145 | /** |
||
146 | * Set the value of one option |
||
147 | * @param string $key The key of the option to set |
||
148 | * @param mixed $value The value of the option to set |
||
149 | * @return $this |
||
150 | */ |
||
151 | abstract public function setOption($key, $value); |
||
152 | |||
153 | /** |
||
154 | * Set multiple options. This does not merge recursively, but only at the top level. |
||
155 | * |
||
156 | * @param array $options The options to set, as keys and values of the array |
||
157 | * @return $this |
||
158 | */ |
||
159 | abstract public function setOptions($options); |
||
160 | |||
161 | /** |
||
162 | * Associative array of data-attributes to apply to the underlying text-area |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | abstract public function getAttributes(); |
||
167 | |||
168 | /** |
||
169 | * Initialise the editor on the client side |
||
170 | */ |
||
171 | abstract public function init(); |
||
172 | |||
173 | } |
||
174 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: