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 |
||
0 ignored issues
–
show
|
|||
11 | { |
||
12 | public function view() |
||
13 | { |
||
14 | $sort = General::sanitize($_REQUEST['sort']); |
||
15 | if (empty($sort)) { |
||
16 | $sort = 'sortorder'; |
||
17 | } |
||
0 ignored issues
–
show
|
|||
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 |
Classes in PHP are usually named in CamelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.
Thus the name database provider becomes
DatabaseProvider
.