| Conditions | 8 |
| Paths | 8 |
| Total Lines | 44 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public static function parse_yaml_formats(string $identifier = 'cms'): array |
||
| 16 | { |
||
| 17 | $yamlFormats = TinyMCEConfig::config()->get('formats'); |
||
| 18 | |||
| 19 | if (! isset($yamlFormats[$identifier])) { |
||
| 20 | user_error('no editor formats for ' . $identifier); |
||
| 21 | return []; |
||
| 22 | } |
||
| 23 | |||
| 24 | $parsedFormats = []; |
||
| 25 | |||
| 26 | foreach ($yamlFormats[$identifier] as $sectionTitle => $sectionFormats) { |
||
| 27 | $formats = []; |
||
| 28 | $sort = 100; |
||
| 29 | |||
| 30 | foreach ($sectionFormats as $sTitle => $sFormat) { |
||
| 31 | if (isset($sFormat['disabled']) && $sFormat['disabled']) { |
||
| 32 | continue; |
||
| 33 | } |
||
| 34 | |||
| 35 | $title = $sTitle; |
||
| 36 | |||
| 37 | if (isset($sFormat['title'])) { |
||
| 38 | $title = $sFormat['title']; |
||
| 39 | } |
||
| 40 | |||
| 41 | if (! isset($sFormat['sort'])) { |
||
| 42 | $sFormat['sort'] = $sort; |
||
| 43 | } |
||
| 44 | |||
| 45 | $formats[] = ['title' => $title] + $sFormat; |
||
| 46 | } |
||
| 47 | |||
| 48 | usort($formats, function ($x, $y) { |
||
| 49 | return $x['sort'] <=> $y['sort']; |
||
| 50 | }); |
||
| 51 | |||
| 52 | $parsedFormats[] = [ |
||
| 53 | 'title' => $sectionTitle, |
||
| 54 | 'items' => $formats, |
||
| 55 | ]; |
||
| 56 | } |
||
| 57 | |||
| 58 | return $parsedFormats; |
||
| 59 | } |
||
| 61 |