GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — 2.6.x (#2558)
by Nicolas
05:04
created

contentAjaxSections::view()   D

Complexity

Conditions 9
Paths 4

Size

Total Lines 43
Code Lines 26

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 43
rs 4.909
cc 9
eloc 26
nc 4
nop 0
1
<?php
2
/**
3
 * @package content
4
 */
5
/**
6
 * The AjaxSections page return an object of all sections and their fields
7
 * that are available for pre-population
8
 */
9
10
class contentAjaxSections extends JSONPage
11
{
12
    public function view()
13
    {
14
        $sort = General::sanitize($_REQUEST['sort']);
15
        if (empty($sort)) {
16
            $sort = 'sortorder';
17
        }
18
        $sections = SectionManager::fetch(null, 'ASC', $sort);
19
        $options = array();
20
21
        if (is_array($sections) && !empty($sections)) {
22
            foreach ($sections as $section) {
23
                $section_fields = $section->fetchFields();
24
25
                if (!is_array($section_fields)) {
26
                    continue;
27
                }
28
29
                $fields = array();
30
31
                foreach ($section_fields as $f) {
32
                    if ($f->canPrePopulate()) {
33
                        $fields[] = array(
34
                            'id' => $f->get('id'),
35
                            'name' => $f->get('label'),
36
                            'handle' => $f->get('element_name'),
37
                            'type' => $f->get('type')
38
                        );
39
                    }
40
                }
41
42
                if (!empty($fields)) {
43
                    $options[] = array(
44
                        'id' => $section->get('id'),
45
                        'name' => $section->get('name'),
46
                        'handle' => $section->get('handle'),
47
                        'fields' => $fields
48
                    );
49
                }
50
            }
51
        }
52
53
        $this->_Result['sections'] = $options;
54
    }
55
}
56