| Conditions | 28 |
| Paths | > 20000 |
| Total Lines | 142 |
| Code Lines | 88 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 74 | public function init() |
||
| 75 | { |
||
| 76 | // list of configured options |
||
| 77 | $configured = array(); |
||
| 78 | $this->setting["selector"] = "textarea"; |
||
| 79 | $this->setting["theme"] = "modern"; |
||
| 80 | |||
| 81 | // Load default settings |
||
| 82 | if (!($this->setting = @include($GLOBALS['xoops']->path("var/configs/tinymce.php")))) { |
||
| 83 | $this->setting = include __DIR__ . "/settings.php"; |
||
| 84 | } |
||
| 85 | |||
| 86 | // get editor language (from ...) |
||
| 87 | if (is_readable(\XoopsBaseConfig::get('root-path') . $this->rootpath . '/langs/' . $this->config["language"] . '.js')) { |
||
| 88 | $this->setting["language"] = $this->config["language"]; |
||
| 89 | $configured[] = "language"; |
||
| 90 | } |
||
| 91 | |||
| 92 | $this->setting["content_css"] = implode(",", $this->loadCss()); |
||
| 93 | $configured[] = "content_css"; |
||
| 94 | |||
| 95 | if (!empty($this->config["theme"]) |
||
| 96 | && is_dir(\XoopsBaseConfig::get('root-path') . $this->rootpath . "/themes/" . $this->config["theme"]) |
||
| 97 | ) { |
||
| 98 | $this->setting["theme"] = $this->config["theme"]; |
||
| 99 | $configured[] = "theme"; |
||
| 100 | } |
||
| 101 | |||
| 102 | if (!empty($this->config["mode"])) { |
||
| 103 | $this->setting["mode"] = $this->config["mode"]; |
||
| 104 | $configured[] = "mode"; |
||
| 105 | } |
||
| 106 | |||
| 107 | // load all plugins except the plugins in setting["exclude_plugins"] |
||
| 108 | $this->setting["plugins"] = implode(",", $this->loadPlugins()); |
||
| 109 | $configured[] = "plugins"; |
||
| 110 | |||
| 111 | if ($this->setting["theme"] !== "simple") { |
||
| 112 | if (empty($this->config["buttons"])) { |
||
| 113 | $this->config["buttons"][] = array( |
||
| 114 | "before" => "", |
||
| 115 | "add" => "", |
||
| 116 | ); |
||
| 117 | $this->config["buttons"][] = array( |
||
| 118 | "before" => "", |
||
| 119 | "add" => "", |
||
| 120 | ); |
||
| 121 | $this->config["buttons"][] = array( |
||
| 122 | "before" => "", |
||
| 123 | "add" => "", |
||
| 124 | ); |
||
| 125 | } |
||
| 126 | $i = 0; |
||
| 127 | foreach ($this->config["buttons"] as $button) { |
||
| 128 | $i++; |
||
| 129 | if (isset($button["before"])) { |
||
| 130 | $this->setting["theme_" . $this->setting["theme"] . "_buttons{$i}_add_before"] = $button["before"]; |
||
| 131 | } |
||
| 132 | if (isset($button["add"])) { |
||
| 133 | $this->setting["theme_" . $this->setting["theme"] . "_buttons{$i}_add"] = $button["add"]; |
||
| 134 | } |
||
| 135 | if (isset($button[""])) { |
||
| 136 | $this->setting["theme_" . $this->setting["theme"] . "_buttons{$i}"] = $button[""]; |
||
| 137 | } |
||
| 138 | } |
||
| 139 | $configured[] = "buttons"; |
||
| 140 | |||
| 141 | if (isset($this->config["toolbar_location"])) { |
||
| 142 | $this->setting["theme_" . $this->setting["theme"] . "_toolbar_location"] |
||
| 143 | = $this->config["toolbar_location"]; |
||
| 144 | $configured[] = "toolbar_location"; |
||
| 145 | } else { |
||
| 146 | $this->setting["theme_" . $this->setting["theme"] . "_toolbar_location"] = "top"; |
||
| 147 | } |
||
| 148 | |||
| 149 | if (isset($this->config["toolbar_align"])) { |
||
| 150 | $this->setting["theme_" . $this->setting["theme"] . "_toolbar_align"] = $this->config["toolbar_align"]; |
||
| 151 | $configured[] = "toolbar_align"; |
||
| 152 | } else { |
||
| 153 | $this->setting["theme_" . $this->setting["theme"] . "_toolbar_align"] = "left"; |
||
| 154 | } |
||
| 155 | |||
| 156 | if (isset($this->config["statusbar_location"])) { |
||
| 157 | $this->setting["theme_" . $this->setting["theme"] . "_statusbar_location"] |
||
| 158 | = $this->config["statusbar_location"]; |
||
| 159 | $configured[] = "statusbar_location"; |
||
| 160 | } |
||
| 161 | |||
| 162 | if (isset($this->config["path_location"])) { |
||
| 163 | $this->setting["theme_" . $this->setting["theme"] . "_path_location"] = $this->config["path_location"]; |
||
| 164 | $configured[] = "path_location"; |
||
| 165 | } |
||
| 166 | |||
| 167 | if (isset($this->config["resize_horizontal"])) { |
||
| 168 | $this->setting["theme_" . $this->setting["theme"] . "_resize_horizontal"] |
||
| 169 | = $this->config["resize_horizontal"]; |
||
| 170 | $configured[] = "resize_horizontal"; |
||
| 171 | } |
||
| 172 | |||
| 173 | if (isset($this->config["resizing"])) { |
||
| 174 | $this->setting["theme_" . $this->setting["theme"] . "_resizing"] = $this->config["resizing"]; |
||
| 175 | $configured[] = "resizing"; |
||
| 176 | } |
||
| 177 | |||
| 178 | if (!empty($this->config["fonts"])) { |
||
| 179 | $this->setting["theme_" . $this->setting["theme"] . "_fonts"] = $this->config["fonts"]; |
||
| 180 | $configured[] = "fonts"; |
||
| 181 | } |
||
| 182 | |||
| 183 | for ($i=1; $i <= 4; $i++) { |
||
| 184 | $buttons = array(); |
||
| 185 | if (isset($this->setting["theme_" . $this->setting["theme"] . "_buttons{$i}"])) { |
||
| 186 | $checklist = explode(",", $this->setting["theme_" . $this->setting["theme"] . "_buttons{$i}"]); |
||
| 187 | foreach ($checklist as $plugin) { |
||
| 188 | if (strpos(strtolower($plugin), "xoops") !== false) { |
||
| 189 | if (in_array($plugin, $this->xoopsPlugins)) { |
||
| 190 | $buttons[] = $plugin; |
||
| 191 | } |
||
| 192 | } else { |
||
| 193 | $buttons[] = $plugin; |
||
| 194 | } |
||
| 195 | } |
||
| 196 | $this->setting["theme_" . $this->setting["theme"] . "_buttons{$i}"] = implode(",", $buttons); |
||
| 197 | } |
||
| 198 | } |
||
| 199 | } |
||
| 200 | |||
| 201 | $configured = array_unique($configured); |
||
| 202 | foreach ($this->config as $key => $val) { |
||
| 203 | if (isset($this->setting[$key]) || in_array($key, $configured)) { |
||
| 204 | continue; |
||
| 205 | } |
||
| 206 | $this->setting[$key] = $val; |
||
| 207 | } |
||
| 208 | |||
| 209 | if (!is_dir(\XoopsBaseConfig::get('root-path') . $this->rootpath . "/themes/" . $this->setting["theme"] . '/docs/' . $this->setting["language"] . '/')) { |
||
| 210 | $this->setting["docs_language"] = "en"; |
||
| 211 | } |
||
| 212 | |||
| 213 | unset($this->config, $configured); |
||
| 214 | |||
| 215 | return true; |
||
| 216 | } |
||
| 393 |