| Conditions | 12 |
| Paths | 13 |
| Total Lines | 62 |
| 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 |
||
| 55 | public function cssStyleini() |
||
| 56 | { |
||
| 57 | static $combined = []; |
||
| 58 | if (!empty($combined) && !$this->reinit) { |
||
| 59 | return $combined; |
||
| 60 | } |
||
| 61 | |||
| 62 | global $conf; |
||
| 63 | global $config_cascade; |
||
| 64 | $stylesheets = array(); // mode, file => base |
||
| 65 | |||
| 66 | // guaranteed placeholder => value |
||
| 67 | $replacements = $this->defaultReplacements; |
||
| 68 | |||
| 69 | // merge all styles from config cascade |
||
| 70 | if (!is_array($config_cascade['styleini'])) { |
||
| 71 | trigger_error('Missing config cascade for styleini', E_USER_WARNING); |
||
| 72 | } |
||
| 73 | |||
| 74 | // allow replacement overwrites in preview mode |
||
| 75 | if ($this->preview) { |
||
| 76 | $config_cascade['styleini']['local'][] = $conf['cachedir'] . '/preview.ini'; |
||
| 77 | } |
||
| 78 | |||
| 79 | $combined['stylesheets'] = []; |
||
| 80 | $combined['replacements'] = []; |
||
| 81 | |||
| 82 | foreach (array('default', 'local', 'protected') as $config_group) { |
||
| 83 | if (empty($config_cascade['styleini'][$config_group])) continue; |
||
| 84 | |||
| 85 | // set proper server dirs |
||
| 86 | $webbase = $this->getWebbase($config_group); |
||
| 87 | |||
| 88 | foreach ($config_cascade['styleini'][$config_group] as $inifile) { |
||
| 89 | // replace the placeholder with the name of the current template |
||
| 90 | $inifile = str_replace('%TEMPLATE%', $this->tpl, $inifile); |
||
| 91 | |||
| 92 | $incbase = dirname($inifile) . '/'; |
||
| 93 | |||
| 94 | if (file_exists($inifile)) { |
||
| 95 | $config = parse_ini_file($inifile, true); |
||
| 96 | |||
| 97 | if (is_array($config['stylesheets'])) { |
||
| 98 | |||
| 99 | foreach ($config['stylesheets'] as $inifile => $mode) { |
||
| 100 | // validate and include style files |
||
| 101 | $stylesheets = array_merge($stylesheets, $this->getValidatedStyles($stylesheets, $inifile, $mode, $incbase, $webbase)); |
||
| 102 | $combined['stylesheets'] = array_merge($combined['stylesheets'], $stylesheets); |
||
| 103 | } |
||
| 104 | } |
||
| 105 | |||
| 106 | if (is_array($config['replacements'])) { |
||
| 107 | $replacements = array_replace($replacements, $this->cssFixreplacementurls($config['replacements'], $webbase)); |
||
| 108 | $combined['replacements'] = array_merge($combined['replacements'], $replacements); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | |||
| 115 | return $combined; |
||
| 116 | } |
||
| 117 | |||
| 181 |