Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
12 | class Basic extends Toolbar |
||
13 | { |
||
14 | /** |
||
15 | * Default plugins that will be use in all toolbars |
||
16 | * In order to add a new plugin you have to load it in default/layout/head.tpl |
||
17 | * @var array |
||
18 | */ |
||
19 | public $defaultPlugins = array( |
||
20 | 'adobeair', |
||
21 | 'ajax', |
||
22 | 'audio', |
||
23 | 'bidi', |
||
24 | 'colorbutton', |
||
25 | 'colordialog', |
||
26 | 'dialogui', |
||
27 | 'dialogadvtab', |
||
28 | 'div', |
||
29 | //if you activate this plugin the html, head tags will not be saved |
||
30 | //'divarea', |
||
31 | 'docprops', |
||
32 | 'find', |
||
33 | 'flash', |
||
34 | 'font', |
||
35 | 'iframe', |
||
36 | 'iframedialog', |
||
37 | 'indentblock', |
||
38 | 'justify', |
||
39 | 'language', |
||
40 | 'lineutils', |
||
41 | 'liststyle', |
||
42 | 'newpage', |
||
43 | 'oembed', |
||
44 | 'pagebreak', |
||
45 | 'preview', |
||
46 | 'print', |
||
47 | 'save', |
||
48 | 'selectall', |
||
49 | 'sharedspace', |
||
50 | 'showblocks', |
||
51 | 'smiley', |
||
52 | 'sourcedialog', |
||
53 | 'stylesheetparser', |
||
54 | 'tableresize', |
||
55 | 'templates', |
||
56 | 'uicolor', |
||
57 | 'video', |
||
58 | 'widget', |
||
59 | 'wikilink', |
||
60 | 'wordcount', |
||
61 | 'xml', |
||
62 | ); |
||
63 | |||
64 | /** |
||
65 | * Plugins this toolbar |
||
66 | * @var array |
||
67 | */ |
||
68 | public $plugins = array(); |
||
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | public function __construct( |
||
134 | |||
135 | /** |
||
136 | * Get the toolbar config |
||
137 | * @return array |
||
138 | */ |
||
139 | public function getConfig() |
||
140 | { |
||
141 | $config = array(); |
||
142 | if (api_get_setting('more_buttons_maximized_mode') === 'true') { |
||
143 | $config['toolbar_minToolbar'] = $this->getMinimizedToolbar(); |
||
144 | |||
145 | $config['toolbar_maxToolbar'] = $this->getMaximizedToolbar(); |
||
146 | } |
||
147 | |||
148 | $config['customConfig'] = api_get_path(WEB_LIBRARY_PATH).'javascript/ckeditor/config_js.php'; |
||
149 | $config['flash_flvPlayer'] = api_get_path(REL_PATH).'web/assets/ckeditor/plugins/flash/swf/player.swf'; |
||
150 | |||
151 | /*filebrowserFlashBrowseUrl |
||
152 | filebrowserFlashUploadUrl |
||
153 | filebrowserImageBrowseLinkUrl |
||
154 | filebrowserImageBrowseUrl |
||
155 | filebrowserImageUploadUrl |
||
156 | filebrowserUploadUrl*/ |
||
157 | |||
158 | $config['extraPlugins'] = $this->getPluginsToString(); |
||
159 | |||
160 | //$config['oembed_maxWidth'] = '560'; |
||
161 | //$config['oembed_maxHeight'] = '315'; |
||
162 | |||
163 | /*$config['wordcount'] = array( |
||
164 | // Whether or not you want to show the Word Count |
||
165 | 'showWordCount' => true, |
||
166 | // Whether or not you want to show the Char Count |
||
167 | 'showCharCount' => true, |
||
168 | // Option to limit the characters in the Editor |
||
169 | 'charLimit' => 'unlimited', |
||
170 | // Option to limit the words in the Editor |
||
171 | 'wordLimit' => 'unlimited' |
||
172 | );*/ |
||
173 | |||
174 | //$config['skins'] = 'moono'; |
||
175 | |||
176 | View Code Duplication | if (isset($this->config)) { |
|
177 | $this->config = array_merge($config, $this->config); |
||
178 | } else { |
||
179 | $this->config = $config; |
||
180 | } |
||
181 | |||
182 | //$config['width'] = '100'; |
||
183 | //$config['height'] = '200'; |
||
184 | return $this->config; |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * Get the default toolbar configuration when the setting more_buttons_maximized_mode is false |
||
189 | * @return array |
||
190 | */ |
||
191 | protected function getNormalToolbar() |
||
195 | |||
196 | /** |
||
197 | * Get the toolbar configuration when CKEditor is minimized |
||
198 | * @return array |
||
199 | */ |
||
200 | protected function getMinimizedToolbar() |
||
213 | |||
214 | /** |
||
215 | * Get the toolbar configuration when CKEditor is maximized |
||
216 | * @return array |
||
217 | */ |
||
218 | View Code Duplication | protected function getMaximizedToolbar() |
|
251 | |||
252 | } |
||
253 |