Conditions | 8 |
Paths | 2 |
Total Lines | 46 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
9 | public function fetch($sections) |
||
10 | { |
||
11 | $options = array(); |
||
12 | $sections = SectionManager::fetch($sections); |
||
13 | if (!empty($sections)) { |
||
14 | foreach ($sections as $section) { |
||
15 | $section_fields = $section->fetchFields(); |
||
16 | if(!is_array($section_fields)) { |
||
17 | continue; |
||
18 | } |
||
19 | |||
20 | $fields = array(); |
||
21 | foreach($section_fields as $f) { |
||
22 | $modes = $f->fetchIncludableElements(); |
||
23 | |||
24 | if (is_array($modes)) { |
||
25 | // include default |
||
26 | $fields[] = array( |
||
27 | 'id' => $f->get('id'), |
||
28 | 'name' => $f->get('label'), |
||
29 | 'handle' => $f->get('element_name'), |
||
30 | 'type' => $f->get('type'), |
||
31 | 'default' => true, |
||
32 | ); |
||
33 | if (count($modes) > 1) { |
||
34 | foreach ($modes as $mode) { |
||
35 | $fields[] = array( |
||
36 | 'id' => $f->get('id'), |
||
37 | 'name' => $f->get('label'), |
||
38 | 'handle' => $mode, |
||
39 | 'type' => $f->get('type') |
||
40 | ); |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | $options[] = array( |
||
47 | 'name' => $section->get('name'), |
||
48 | 'handle' => $section->get('handle'), |
||
49 | 'fields' => $fields |
||
50 | ); |
||
51 | } |
||
52 | } |
||
53 | return $options; |
||
54 | } |
||
55 | } |
||
56 |