| Conditions | 28 |
| Paths | > 20000 |
| Total Lines | 137 |
| Code Lines | 84 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 75 | public function init() |
||
| 76 | { |
||
| 77 | // list of configured options |
||
| 78 | $configured = []; |
||
| 79 | $this->setting['selector'] = 'textarea'; |
||
| 80 | $this->setting['theme'] = 'modern'; |
||
| 81 | |||
| 82 | // Load default settings |
||
| 83 | if (!($this->setting = @include($GLOBALS['xoops']->path('var/configs/tinymce.php')))) { |
||
| 84 | $this->setting = include __DIR__ . '/settings.php'; |
||
| 85 | } |
||
| 86 | |||
| 87 | // get editor language (from ...) |
||
| 88 | if (is_readable(XOOPS_ROOT_PATH . $this->rootpath . '/langs/' . $this->config['language'] . '.js')) { |
||
| 89 | $this->setting['language'] = $this->config['language']; |
||
| 90 | $configured[] = 'language'; |
||
| 91 | } |
||
| 92 | |||
| 93 | $this->setting['content_css'] = implode(',', $this->loadCss()); |
||
| 94 | $configured[] = 'content_css'; |
||
| 95 | |||
| 96 | if (!empty($this->config['theme']) && is_dir(XOOPS_ROOT_PATH . $this->rootpath . '/themes/' . $this->config['theme'])) { |
||
| 97 | $this->setting['theme'] = $this->config['theme']; |
||
| 98 | $configured[] = 'theme'; |
||
| 99 | } |
||
| 100 | |||
| 101 | if (!empty($this->config['mode'])) { |
||
| 102 | $this->setting['mode'] = $this->config['mode']; |
||
| 103 | $configured[] = 'mode'; |
||
| 104 | } |
||
| 105 | |||
| 106 | // load all plugins except the plugins in setting["exclude_plugins"] |
||
| 107 | $this->setting['plugins'] = implode(',', $this->loadPlugins()); |
||
| 108 | $configured[] = 'plugins'; |
||
| 109 | |||
| 110 | if ('simple' !== $this->setting['theme']) { |
||
| 111 | if (empty($this->config['buttons'])) { |
||
| 112 | $this->config['buttons'][] = [ |
||
| 113 | 'before' => '', |
||
| 114 | 'add' => '', |
||
| 115 | ]; |
||
| 116 | $this->config['buttons'][] = [ |
||
| 117 | 'before' => '', |
||
| 118 | 'add' => '', |
||
| 119 | ]; |
||
| 120 | $this->config['buttons'][] = [ |
||
| 121 | 'before' => '', |
||
| 122 | 'add' => '', |
||
| 123 | ]; |
||
| 124 | } |
||
| 125 | $i = 0; |
||
| 126 | foreach ($this->config['buttons'] as $button) { |
||
| 127 | ++$i; |
||
| 128 | if (isset($button['before'])) { |
||
| 129 | $this->setting['theme_' . $this->setting['theme'] . "_buttons{$i}_add_before"] = $button['before']; |
||
| 130 | } |
||
| 131 | if (isset($button['add'])) { |
||
| 132 | $this->setting['theme_' . $this->setting['theme'] . "_buttons{$i}_add"] = $button['add']; |
||
| 133 | } |
||
| 134 | if (isset($button[''])) { |
||
| 135 | $this->setting['theme_' . $this->setting['theme'] . "_buttons{$i}"] = $button['']; |
||
| 136 | } |
||
| 137 | } |
||
| 138 | $configured[] = 'buttons'; |
||
| 139 | |||
| 140 | if (isset($this->config['toolbar_location'])) { |
||
| 141 | $this->setting['theme_' . $this->setting['theme'] . '_toolbar_location'] = $this->config['toolbar_location']; |
||
| 142 | $configured[] = 'toolbar_location'; |
||
| 143 | } else { |
||
| 144 | $this->setting['theme_' . $this->setting['theme'] . '_toolbar_location'] = 'top'; |
||
| 145 | } |
||
| 146 | |||
| 147 | if (isset($this->config['toolbar_align'])) { |
||
| 148 | $this->setting['theme_' . $this->setting['theme'] . '_toolbar_align'] = $this->config['toolbar_align']; |
||
| 149 | $configured[] = 'toolbar_align'; |
||
| 150 | } else { |
||
| 151 | $this->setting['theme_' . $this->setting['theme'] . '_toolbar_align'] = 'left'; |
||
| 152 | } |
||
| 153 | |||
| 154 | if (isset($this->config['statusbar_location'])) { |
||
| 155 | $this->setting['theme_' . $this->setting['theme'] . '_statusbar_location'] = $this->config['statusbar_location']; |
||
| 156 | $configured[] = 'statusbar_location'; |
||
| 157 | } |
||
| 158 | |||
| 159 | if (isset($this->config['path_location'])) { |
||
| 160 | $this->setting['theme_' . $this->setting['theme'] . '_path_location'] = $this->config['path_location']; |
||
| 161 | $configured[] = 'path_location'; |
||
| 162 | } |
||
| 163 | |||
| 164 | if (isset($this->config['resize_horizontal'])) { |
||
| 165 | $this->setting['theme_' . $this->setting['theme'] . '_resize_horizontal'] = $this->config['resize_horizontal']; |
||
| 166 | $configured[] = 'resize_horizontal'; |
||
| 167 | } |
||
| 168 | |||
| 169 | if (isset($this->config['resizing'])) { |
||
| 170 | $this->setting['theme_' . $this->setting['theme'] . '_resizing'] = $this->config['resizing']; |
||
| 171 | $configured[] = 'resizing'; |
||
| 172 | } |
||
| 173 | |||
| 174 | if (!empty($this->config['fonts'])) { |
||
| 175 | $this->setting['theme_' . $this->setting['theme'] . '_fonts'] = $this->config['fonts']; |
||
| 176 | $configured[] = 'fonts'; |
||
| 177 | } |
||
| 178 | |||
| 179 | for ($i = 1; $i <= 4; ++$i) { |
||
| 180 | $buttons = []; |
||
| 181 | if (isset($this->setting['theme_' . $this->setting['theme'] . "_buttons{$i}"])) { |
||
| 182 | $checklist = explode(',', $this->setting['theme_' . $this->setting['theme'] . "_buttons{$i}"]); |
||
| 183 | foreach ($checklist as $plugin) { |
||
| 184 | if (false != strpos(strtolower($plugin), 'xoops')) { |
||
|
|
|||
| 185 | if (in_array($plugin, $this->xoopsPlugins)) { |
||
| 186 | $buttons[] = $plugin; |
||
| 187 | } |
||
| 188 | } else { |
||
| 189 | $buttons[] = $plugin; |
||
| 190 | } |
||
| 191 | } |
||
| 192 | $this->setting['theme_' . $this->setting['theme'] . "_buttons{$i}"] = implode(',', $buttons); |
||
| 193 | } |
||
| 194 | } |
||
| 195 | } |
||
| 196 | |||
| 197 | $configured = array_unique($configured); |
||
| 198 | foreach ($this->config as $key => $val) { |
||
| 199 | if (isset($this->setting[$key]) || in_array($key, $configured)) { |
||
| 200 | continue; |
||
| 201 | } |
||
| 202 | $this->setting[$key] = $val; |
||
| 203 | } |
||
| 204 | |||
| 205 | if (!is_dir(XOOPS_ROOT_PATH . $this->rootpath . '/themes/' . $this->setting['theme'] . '/docs/' . $this->setting['language'] . '/')) { |
||
| 206 | $this->setting['docs_language'] = 'en'; |
||
| 207 | } |
||
| 208 | |||
| 209 | unset($this->config, $configured); |
||
| 210 | |||
| 211 | return true; |
||
| 212 | } |
||
| 379 |